/* Context Menu */
.context-menu {
    position: fixed;
    z-index: 20000;
    width: 180px;
    background: rgba(28, 28, 30, 0.6) !important;
    backdrop-filter: blur(25px) saturate(200%) !important;
    -webkit-backdrop-filter: blur(25px) saturate(200%) !important;
    border: 1px solid rgba(255, 255, 255, 0.15) !important;
    border-radius: 10px !important;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.35) !important;
    padding: 5px !important;
    display: none !important;
    flex-direction: column;
}

.context-menu.open {
    display: flex !important;
}

.context-menu .dd-item {
    font-size: 13px !important;
    padding: 6px 12px !important;
    border-radius: 6px !important;
    text-align: left !important;
    color: #fff !important;
    background: transparent !important;
    border: none !important;
    width: 100% !important;
    margin: 0 !important;
}

.context-menu .dd-item:hover {
    background: var(--blue) !important;
}

.context-menu .dd-sep {
    height: 1px !important;
    background: rgba(255, 255, 255, 0.1) !important;
    margin: 4px 6px !important;
}

/* Global macOS Cursors */
* {
    cursor: url('https://raw.githubusercontent.com/vinceliuice/WhiteSur-cursors/master/dist/cursors/left_ptr.svg'), auto !important;
}

a,
button,
[onclick],
.dock-item,
.tl,
.ck,
.tb-btn,
.fs-item,
.sn-item,
.dd-item:not(.disabled),
.lp-item,
.social-btn,
.sidebar-item,
.settings-nav-item,
.finder-icon-item,
.finder-sidebar-item {
    cursor: url('https://raw.githubusercontent.com/vinceliuice/WhiteSur-cursors/master/dist/cursors/hand2.svg'), pointer !important;
}

input,
textarea,
[contenteditable] {
    cursor: url('https://raw.githubusercontent.com/vinceliuice/WhiteSur-cursors/master/dist/cursors/ibeam.svg'), text !important;
}

/* Wallpaper Grid */
.wallpaper-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
    padding: 8px;
}

.wallpaper-thumb {
    width: 100%;
    aspect-ratio: 16/10;
    border-radius: 12px;
    object-fit: cover;
    border: 4px solid transparent;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    background: rgba(255, 255, 255, 0.05);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.wallpaper-thumb:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.wallpaper-thumb.active {
    border-color: #007AFF;
    box-shadow: 0 0 0 2px rgba(0, 122, 255, 0.3);
}

/* Dropdown Animation Overrides */
.dropdown {
    display: block !important;
    opacity: 0;
    transform: scale(0.96) translateY(-8px);
    transition: opacity 0.2s cubic-bezier(0.4, 0, 0.2, 1), transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
    visibility: hidden;
}

.dropdown.open {
    opacity: 1 !important;
    transform: scale(1) translateY(0) !important;
    pointer-events: auto !important;
    visibility: visible !important;
}

/* General Settings UI */
.settings-row select {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #fff;
    border-radius: 6px;
    padding: 4px 8px;
    font-size: 11px;
    outline: none;
}

/* Smooth Boot Fixes */
#desktop {
    background: #000;
}

/* Startup Animations */
#menubar {
    transform: translateY(-100%);
    transition: transform 0.8s cubic-bezier(0.2, 0.8, 0.2, 1);
}

#desktop.system-ready #menubar {
    transform: translateY(0);
}

/* Linear notch fall down as requested */
#menubar.notch::before {
    opacity: 0;
    transform: translateX(-50%) translateY(-100%);
    transition: transform 1.2s linear 0.5s, opacity 0.5s linear 0.5s;
}

#desktop.system-ready #menubar.notch::before {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

#desktop #dock {
    opacity: 0 !important;
    transform: translate(-50%, 150px) !important;
    transition: transform 1.2s cubic-bezier(0.2, 0.8, 0.2, 1), opacity 1.2s ease-out;
    visibility: visible !important;
}

#desktop.system-ready #dock {
    opacity: 1 !important;
    transform: translate(-50%, 0) !important;
}

.desktop-icon {
    opacity: 0;
    transform: scale(0.9) translateY(10px);
    transition: opacity 0.6s var(--smooth), transform 0.6s var(--smooth);
}

#desktop.system-ready .desktop-icon {
    opacity: 1;
    transform: scale(1) translateY(0);
}

/* Stagger icons entry */
#desktop.system-ready .desktop-icon:nth-child(1) {
    transition-delay: 0.8s;
}

#desktop.system-ready .desktop-icon:nth-child(2) {
    transition-delay: 0.9s;
}

#desktop.system-ready .desktop-icon:nth-child(3) {
    transition-delay: 1.0s;
}

#desktop.system-ready .desktop-icon:nth-child(4) {
    transition-delay: 1.1s;
}

/* Boot Logo Refinement */
.apple-logo {
    opacity: 0;
    animation: fadeScale .5s ease forwards .3s, bootLogoPulse 2.5s ease-in-out infinite alternate .8s;
}

@keyframes bootLogoPulse {
    0% {
        transform: scale(1);
        filter: drop-shadow(0 0 0 rgba(255, 255, 255, 0));
    }

    100% {
        transform: scale(1.02);
        filter: drop-shadow(0 0 20px rgba(255, 255, 255, 0.4));
    }
}

/* Achievements App */
.achievements-app-body {
    background: rgba(30, 30, 35, 0.4);
    display: flex;
    flex-direction: column;
    padding: 0;
}

.ach-header {
    background: rgba(255, 255, 255, 0.03);
    padding: 32px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.ach-stats {
    display: flex;
    gap: 48px;
}

.ach-stat-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.ach-stat-val {
    font-size: 36px;
    font-weight: 800;
    color: #fff;
    line-height: 1;
}

.ach-stat-label {
    font-size: 11px;
    color: var(--t3);
    text-transform: uppercase;
    letter-spacing: 0.8px;
    font-weight: 600;
}

.achievements-list-full {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 16px;
}

.achievements-list-full .achievement-item {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
    padding: 16px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    gap: 16px;
    transition: all 0.3s var(--smooth);
}

.achievements-list-full .achievement-item.unlocked {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.1);
}

.achievements-list-full .achievement-icon {
    font-size: 32px;
    width: 60px;
    height: 60px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.achievements-list-full .achievement-info {
    flex: 1;
    min-width: 0;
}

.achievements-list-full .achievement-name {
    font-size: 14px;
    font-weight: 600;
    color: #fff;
    margin-bottom: 2px;
}

.achievements-list-full .achievement-desc {
    font-size: 12px;
    color: var(--t2);
    line-height: 1.4;
}

/* View All button in dropdown */
.btn-ach-view {
    font-size: 10px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #fff;
    padding: 3px 10px;
    border-radius: 100px;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 500;
}

.btn-ach-view:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-1px);
}

/* Dock Item Smooth Removal */
.dock-item {
    transition: all 0.5s cubic-bezier(0.19, 1, 0.22, 1), width 0.5s cubic-bezier(0.19, 1, 0.22, 1), margin 0.5s cubic-bezier(0.19, 1, 0.22, 1);
}

.dock-item.removing {
    transform: scale(0) translateY(40px);
    opacity: 0;
    width: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    pointer-events: none;
}

/* Calculator Scientific Style */
.calc-keys.scientific {
    grid-template-columns: repeat(10, 1fr) !important;
}

.calc-display {
    font-family: 'Inter', sans-serif !important;
    font-weight: 200 !important;
    font-size: 52px !important;
    transition: all 0.3s var(--smooth);
    position: relative;
    overflow: hidden;
}

/* Slide-in animation for numbers */
.calc-display-val {
    display: inline-block;
    animation: numSlideIn 0.2s var(--smooth) forwards;
}

@keyframes numSlideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.calc-keys {
    transition: grid-template-columns 0.4s var(--smooth);
}

.ck-scientific {
    background: #2a2a2c !important;
    font-size: 13px !important;
    opacity: 0;
    transform: scale(0.9);
    transition: all 0.3s var(--smooth);
}

.calc-keys.scientific .ck-scientific {
    opacity: 1;
    transform: scale(1);
}

.ck-scientific:hover {
    background: #3a3a3c !important;
}

/* Result Flash Effect */
.calc-flash {
    animation: calcResultFlash 0.3s var(--smooth);
}

#window-calculator {
    transition: width 0.4s var(--smooth), height 0.4s var(--smooth), top 0.4s var(--smooth), left 0.4s var(--smooth);
}

#window-calculator:has(.scientific) {
    width: 650px !important;
}

@keyframes calcResultFlash {
    0% {
        background: rgba(255, 255, 255, 0.2);
    }

    100% {
        background: transparent;
    }
}

.ck-op.active {
    background: #fff !important;
    color: #ff9f0a !important;
}

.discord-native-overlay {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 300px;
    background: #111214;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.5);
    z-index: 10;
    border: 1px solid rgba(255, 255, 255, 0.05);
    transition: transform 0.3s var(--smooth);
}

.discord-native-overlay:hover {
    transform: translateY(-4px);
}

.discord-banner {
    height: 60px;
    background: var(--blue);
}

.discord-win-avatar {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    border: 6px solid #111214;
    margin-top: -40px;
    margin-left: 16px;
    background: #111214;
    object-fit: cover;
}

.discord-profile-details {
    padding: 16px;
}

.discord-win-name {
    font-size: 20px;
    font-weight: 700;
    color: #fff;
    margin-bottom: 4px;
    border: none !important;
}

.discord-win-status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: #b5bac1;
}

.discord-status-indicator {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #23a55a;
}

/* Tutorial Overlay */
#tutorial-overlay {
    position: fixed;
    inset: 0;
    z-index: 10000;
    background: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(3px);
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.4s var(--smooth);
    pointer-events: none;
    /* Allow clicking through the blur part, but the overlay child handles its own clicks */

    /* The hole trick */
    clip-path: polygon(0% 0%, 0% 100%, 100% 100%, 100% 0%, 0% 0%,
            var(--hole-left, 0) var(--hole-top, 0),
            var(--hole-right, 0) var(--hole-top, 0),
            var(--hole-right, 0) var(--hole-bottom, 0),
            var(--hole-left, 0) var(--hole-bottom, 0),
            var(--hole-left, 0) var(--hole-top, 0));
}

.tutorial-card {
    pointer-events: auto;
    /* Re-enable clicks for the guide card */
}

#tutorial-overlay.hidden {
    display: none;
}

.tutorial-card {
    width: 380px;
    background: rgba(30, 30, 35, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    padding: 30px;
    box-shadow: 0 30px 60px rgba(0, 0, 0, 0.5);
    transform: translateY(0);
    animation: springPop 0.6s var(--spring);
}

.tutorial-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 24px;
}

.tutorial-avatar {
    width: 54px;
    height: 54px;
    border-radius: 50%;
    border: 2px solid var(--blue);
}

.tutorial-title-group h3 {
    margin: 0;
    font-size: 18px;
    color: #fff;
}

.tutorial-title-group span {
    font-size: 12px;
    opacity: 0.5;
    color: #fff;
}

.tutorial-body {
    min-height: 80px;
    margin-bottom: 30px;
}

.tutorial-body p {
    font-size: 15px;
    line-height: 1.6;
    color: rgba(255, 255, 255, 0.9);
    margin: 0;
    font-weight: 500;
}

#tutorial-text.typing::after {
    content: '|';
    margin-left: 2px;
    color: var(--blue);
    animation: blink 0.8s infinite;
}

@keyframes blink {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0;
    }
}

.tutorial-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.btn-tutorial {
    padding: 10px 20px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
}

.btn-tutorial.skip {
    background: rgba(255, 255, 255, 0.05);
    color: rgba(255, 255, 255, 0.6);
}

.btn-tutorial.next {
    background: var(--blue);
    color: white;
    flex: 1;
}

.btn-tutorial:hover {
    transform: translateY(-2px);
    filter: brightness(1.1);
}

.tutorial-progress {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 24px;
}

.tutorial-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    transition: all 0.3s;
}

.tutorial-dot.active {
    background: var(--blue);
    width: 16px;
    border-radius: 3px;
}

@keyframes springPop {
    0% {
        transform: scale(0.8) translateY(40px);
        opacity: 0;
    }

    100% {
        transform: scale(1) translateY(0);
        opacity: 1;
    }
}

.tutorial-highlight {
    position: relative;
    z-index: 10001 !important;
    box-shadow: 0 0 0 4px var(--blue), 0 0 20px var(--blue) !important;
    transition: all 0.3s var(--smooth);
    backdrop-filter: blur(0) !important;
    filter: blur(0) !important;
}

/* YouTube App Styles */
.yt-app {
    display: flex;
    height: 100%;
    background: #0f0f0f;
    color: #fff;
    font-family: 'Inter', sans-serif;
}

.yt-sidebar {
    width: 240px;
    padding: 12px;
    border-right: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex-shrink: 0;
}

.yt-sidebar-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 10px 16px;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s var(--smooth);
    font-size: 13px;
    font-weight: 500;
}

.yt-sidebar-item:hover {
    background: rgba(255, 255, 255, 0.1);
}

.yt-sidebar-item.active {
    background: rgba(255, 255, 255, 0.15);
}

.yt-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    background: #0f0f0f;
}

.yt-header {
    padding: 16px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    background: rgba(15, 15, 15, 0.95);
    backdrop-filter: blur(20px);
    z-index: 10;
}

.yt-search-container {
    flex: 1;
    max-width: 500px;
    display: flex;
    align-items: center;
    background: #121212;
    border: 1px solid #333;
    border-radius: 40px;
    padding: 0 20px;
    margin: 0 40px;
}

.yt-search-input {
    flex: 1;
    background: transparent;
    border: none;
    color: #fff;
    padding: 8px 0;
    font-size: 14px;
    outline: none;
}

.yt-search-btn {
    background: none;
    border: none;
    color: #888;
    padding: 8px;
    cursor: pointer;
}

.yt-user-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.yt-profile-blob {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
}

.yt-video-grid {
    padding: 24px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 24px 16px;
}

.yt-video-card {
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.yt-thumbnail-wrapper {
    position: relative;
    width: 100%;
    aspect-ratio: 16/9;
    background: #222;
    border-radius: 12px;
    overflow: hidden;
}

.yt-thumbnail {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.4s var(--smooth);
}

.yt-video-card:hover .yt-thumbnail {
    transform: scale(1.05);
}

.yt-duration {
    position: absolute;
    bottom: 8px;
    right: 8px;
    background: rgba(0, 0, 0, 0.8);
    padding: 2px 4px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 500;
}

.yt-video-info {
    display: flex;
    gap: 12px;
}

.yt-chan-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.yt-video-meta {
    flex: 1;
}

.yt-video-card {
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 12px;
    transition: transform 0.3s var(--smooth);
}

.yt-video-card:hover {
    transform: translateY(-4px);
}

.yt-video-meta h4 {
    font-size: 14px;
    font-weight: 600;
    margin: 0 0 6px 0;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.yt-video-meta p {
    font-size: 12px;
    color: #888;
    margin: 0;
}

/* Video Player Overlay */
.yt-player-overlay {
    position: absolute;
    inset: 0;
    background: #000;
    z-index: 100;
    display: flex;
    flex-direction: column;
    animation: fadeIn 0.3s var(--smooth);
}

.yt-player-header {
    padding: 12px 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    background: #0f0f0f;
}

.yt-back-btn {
    background: none;
    border: none;
    color: #fff;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
}


.yt-back-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

.yt-video-frame {
    flex: 1;
    width: 100%;
    border: none;
}

/* ====================== SMOOTHNESS & POLISH ====================== */

/* Smooth scrolling in all window bodies */
.win-body {
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
}

/* Silky button interactions */
.btn-primary,
.btn-secondary {
    transition: all 0.2s cubic-bezier(0.25, 0.1, 0.25, 1);
}

.btn-primary:hover {
    filter: brightness(1.15);
    transform: translateY(-1px);
}

.btn-primary:active,
.btn-secondary:active {
    transform: scale(0.97);
    filter: brightness(0.9);
}

/* Smooth traffic light hover */
.tl {
    transition: opacity 0.15s ease, transform 0.15s ease;
}

.tl:hover {
    transform: scale(1.15);
}

.tl:active {
    transform: scale(0.9);
}

/* GPU-composited dock icons */
.dock-item .dock-img {
    transform: translateZ(0);
    backface-visibility: hidden;
}

/* Smoother dock tooltip */
.dock-tooltip {
    transition: opacity 0.2s var(--smooth), transform 0.2s var(--smooth);
}

/* Silky window chrome hover */
.win-chrome {
    transition: background 0.2s var(--smooth);
}

/* Smooth settings nav items */
.settings-nav-item {
    transition: background 0.15s var(--smooth), color 0.15s var(--smooth);
}

/* Smooth Finder items */
.fr {
    transition: background 0.12s var(--smooth);
}

/* Polished scrollbar for dark theme */
.win-body::-webkit-scrollbar {
    width: 8px;
}

.win-body::-webkit-scrollbar-track {
    background: transparent;
}

.win-body::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    border: 2px solid transparent;
    background-clip: padding-box;
}

.win-body::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
    background-clip: padding-box;
}

/* No text selection flicker during drag */
.win-chrome {
    user-select: none;
    -webkit-user-select: none;
}

/* Subtle hover glow for interactive cards */
.gh-repo,
.safari-contact-card,
.yt-video-card {
    transition: transform 0.25s var(--smooth), box-shadow 0.25s var(--smooth), background 0.25s var(--smooth);
}

.gh-repo:hover {
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

/* Smoother context menu */
.context-menu {
    transition: opacity 0.12s var(--smooth), transform 0.12s var(--smooth) !important;
}