:root {
    /* Color Palette - Vibrant Brand Colors */
    --os-blue: #0058eb;
    /* benji2timez Primary Blue */
    --os-light-gray: rgba(255, 255, 255, 0.1);
    --os-dark-gray: rgba(255, 255, 255, 0.4);
    --os-window-bg: rgba(255, 255, 255, 0.15);
    --os-text: #000000;
    --os-border: rgba(255, 255, 255, 0.3);
    --os-highlight: rgba(255, 255, 255, 0.4);

    /* Typography */
    /* Using Andale Mono per user request */
    --font-ui: 'Andale Mono', monospace;

    /* Layout */
    --menu-height: 28px;
    --window-chrome-height: 24px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--os-blue);
    color: var(--os-text);
    font-family: var(--font-ui);
    font-size: 14px;
    text-transform: lowercase;
    overflow: hidden;
    /* Prevent scrolling on the desktop */
    user-select: none;
    /* Prevent accidental text selection while dragging */
    -webkit-font-smoothing: antialiased;
}

/* --- Grain Texture overlay --- */
.grain-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    z-index: 9999;
    opacity: 0.04;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)'/%3E%3C/svg%3E");
}

/* --- Screen Transitions --- */
.screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    /* 300ms smooth fade per requirements */
}

.screen.active {
    opacity: 1;
    pointer-events: auto;
}

/* --- Login Screen --- */
#login-screen {
    background-color: var(--os-blue);
    /* Match brand blue */
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    /* Behind grain, above everything else initially */
}

.bios-dialog {
    background-color: var(--os-blue);
    /* Exact match to desktop */
    padding: 4px;
    box-shadow: 16px 16px 0px #000000;
    /* Distinct block drop shadow */
    width: 480px;
    transform: scale(0.65);
    /* Make window another 15% smaller */
}

.bios-dialog-inner {
    border: 2px solid #000000;
    /* Inner black outline to match text */
    padding: 32px 40px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.bios-label {
    color: #000000;
    font-family: var(--font-ui);
    /* Serifs match the screenshot */
    font-size: 20px;
    font-weight: bold;
    letter-spacing: 0.5px;
    margin-right: 16px;
}

.bios-input-group {
    display: flex;
    align-items: center;
    color: #000000;
    font-size: 20px;
    font-weight: bold;
    font-family: var(--font-ui);
}

.bios-bracket {
    margin: 0 4px;
}

.bios-input-group input {
    background-color: transparent;
    color: #000000;
    border: none;
    outline: none;
    width: 140px;
    font-family: var(--font-ui);
    font-size: 20px;
    font-weight: bold;
    text-align: center;
    letter-spacing: 4px;
    padding: 4px 0;
    transition: transform 0.1s ease;
}

/* Subtle shake animation for error */
@keyframes shake {

    0%,
    100% {
        transform: translateX(0);
    }

    25% {
        transform: translateX(-4px);
    }

    75% {
        transform: translateX(4px);
    }
}

.bios-input-group input.error {
    animation: shake 0.3s ease-in-out;
}

/* --- Menu Bar --- */
.menu-bar {
    height: var(--menu-height);
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(20px) saturate(150%);
    -webkit-backdrop-filter: blur(20px) saturate(150%);
    border-bottom: 1px solid #000000;
    color: #000000;
    text-shadow: 0 1px 0 rgba(255, 255, 255, 0.4);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 16px;
    font-size: 13px;
    font-weight: 500;
    position: relative;
    z-index: 900;
}

.menu-left,
.menu-right {
    display: flex;
    gap: 16px;
    align-items: center;
}

.menu-item {
    cursor: default;
}

.menu-item.logo {
    font-weight: 600;
    margin-right: 8px;
    cursor: pointer;
}

.menu-item.logo:active {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 4px;
}

/* --- Dropdown Menu --- */
.menu-dropdown-container {
    position: relative;
    display: flex;
    align-items: center;
}

.menu-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    margin-top: 4px;
    background: rgba(255, 255, 255, 0.3);
    backdrop-filter: blur(20px) saturate(150%);
    -webkit-backdrop-filter: blur(20px) saturate(150%);
    border: 1px solid #000000;
    border-radius: 0;
    padding: 8px 0;
    min-width: 120px;
    box-shadow: 3px 3px 0 #000000;
    display: flex;
    flex-direction: column;
    z-index: 1000;
}

.menu-dropdown.hidden {
    display: none;
}

.dropdown-item {
    padding: 6px 16px;
    cursor: pointer;
    transition: background 0.2s;
}

.dropdown-item:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* --- Desktop Elements --- */
.desktop-footer {
    position: absolute;
    bottom: 24px;
    left: 0;
    width: 100%;
    text-align: center;
    color: #000000;
    font-size: 14px;
    font-weight: bold;
    z-index: 50;
    pointer-events: none;
}

/* --- Window System --- */
#window-container {
    position: absolute;
    top: var(--menu-height);
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    /* Let clicks pass through to desktop if no window */
}

.os-window {
    position: absolute;
    background: rgba(255, 255, 255, 0.3);
    backdrop-filter: blur(32px) saturate(150%);
    -webkit-backdrop-filter: blur(32px) saturate(150%);
    border: 1px solid #000000;
    border-radius: 0;
    box-shadow: 3px 3px 0 #000000;
    display: flex;
    flex-direction: column;
    pointer-events: auto;
    /* Re-enable clicks for windows */

    /* Animation rules: no bounce, 200ms ease */
    transition: opacity 0.2s ease, transform 0.2s ease;
    opacity: 1;
    overflow: hidden;
    resize: both;
}

/* Inactive window state */
.os-window.inactive {
    opacity: 0.9;
    /* Slight dimming per spec */
}

.os-window.inactive .window-titlebar {
    opacity: 0.8;
}

.window-titlebar {
    height: 24px;
    background-image: repeating-linear-gradient(0deg,
            transparent,
            transparent 1px,
            rgba(0, 0, 0, 0.5) 1px,
            rgba(0, 0, 0, 0.5) 2px);
    border-bottom: 1px solid #000000;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    cursor: grab;
}

.window-titlebar:active {
    cursor: grabbing;
}

.window-title {
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid #000000;
    color: #000000;
    padding: 0 12px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.5px;
    z-index: 2;
    height: 18px;
    line-height: 16px;
    display: inline-block;
}

.window-close-btn {
    position: absolute;
    left: 8px;
    top: 50%;
    transform: translateY(-50%);
    width: 13px;
    height: 13px;
    border-radius: 0;
    background-color: #ffffff;
    border: 1px solid #000000;
    cursor: pointer;
    z-index: 2;
    transition: background-color 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.window-close-btn::before {
    content: '';
    display: block;
    width: 5px;
    height: 5px;
    border: 1px solid #000;
}

.window-close-btn:active {
    background-color: rgba(255, 255, 255, 1);
}

.window-content {
    flex: 1;
    overflow: auto;
    background: transparent;
    padding: 16px;
    position: relative;
    color: #ffffff;
}

/* Hide scrollbar for clean aesthetic but keep functionality */
.window-content::-webkit-scrollbar {
    width: 12px;
}

.window-content::-webkit-scrollbar-track {
    background: var(--os-light-gray);
    border-left: 1px solid var(--os-border);
}

.window-content::-webkit-scrollbar-thumb {
    background-color: var(--os-dark-gray);
    border: 1px solid var(--os-border);
}

/* Content Layouts inside windows (Level 2 & Level 3 previews) */
.icon-view {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: 32px 16px;
    padding: 24px;
    justify-items: center;
    align-items: start;
}

.os-icon {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    width: 100%;
}

.os-icon-graphic {
    width: 60px;
    height: 50px;
    border-radius: 0;
    border: 1px solid #000000;
    background: rgba(255, 255, 255, 0.3);
    backdrop-filter: blur(12px) saturate(150%);
    -webkit-backdrop-filter: blur(12px) saturate(150%);
    box-shadow: 2px 2px 0 #000000;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease, background 0.2s ease;
}

.os-icon-graphic::before {
    content: '';
    width: 24px;
    height: 12px;
    border: 1px solid #000000;
    border-bottom: none;
    border-radius: 0;
    position: absolute;
    top: -12px;
    left: -1px;
    background: inherit;
}

.os-icon-graphic::after {
    display: none;
}

.os-icon-label {
    background-color: transparent;
    color: #000000;
    padding: 2px 4px;
    border-radius: 0;
    font-size: 11px;
    text-align: center;
    text-shadow: none;
    transition: background-color 0.2s ease;
}

.os-icon:active .os-icon-graphic {
    background: rgba(255, 255, 255, 0.35);
    transform: scale(0.95);
}

.os-icon:active .os-icon-label {
    background-color: rgba(255, 255, 255, 0.2);
}

/* --- Level 2 View: Project Grid --- */
.project-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 16px;
    padding: 12px;
}

.project-thumb {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.project-thumb img {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    border-radius: 0;
    border: 1px solid #000000;
    box-shadow: 2px 2px 0 #000000;
    transition: filter 0.2s ease, transform 0.2s ease;
}

.project-thumb:active img {
    filter: brightness(0.8);
    transform: scale(0.97);
}

.project-label {
    font-size: 11px;
    text-align: center;
    background-color: transparent;
    color: #000000;
    padding: 2px 4px;
    border-radius: 0;
    text-shadow: none;
    transition: background-color 0.2s ease;
}

.project-thumb:active .project-label {
    background-color: rgba(255, 255, 255, 0.2);
}

/* --- Level 3 View: Project Detail (Photo Grid / Viewer) --- */
.photo-gallery.grid-view {
    display: grid;
    grid-template-columns: repeat(var(--gallery-cols, 3), 1fr);
    gap: 2px;
    /* Tight grid like iPhone photos */
    padding: 2px;
}

.gallery-desc {
    grid-column: 1 / -1;
    padding: 12px;
    font-family: var(--font-ui);
    font-size: 12px;
    background: rgba(255, 255, 255, 0.1);
    border-bottom: 2px solid transparent;
    /* spacing */
}

.gallery-item {
    aspect-ratio: 1;
    overflow: hidden;
    background: #000;
}

.photo-gallery img.gallery-photo,
.photo-gallery video.gallery-photo {
    width: 100%;
    height: 100%;
    object-fit: cover;
    cursor: pointer;
    transition: filter 0.2s ease;
}

.photo-gallery img.gallery-photo:hover,
.photo-gallery video.gallery-photo:hover {
    filter: brightness(0.9);
}

/* Expanded Photo Viewer inside window */
.photo-viewer {
    position: absolute;
    top: 24px;
    /* Title bar height */
    left: 0;
    right: 0;
    bottom: 0;
    background: #000000;
    /* Solid black for clean viewing */
    z-index: 10;
    display: flex;
    flex-direction: column;
}

.photo-viewer-content {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    cursor: auto;
    /* Handle cursors via JS or let it be neutral */
}

.photo-viewer-content img,
.photo-viewer-content video {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    cursor: zoom-in;
    /* Indicate double click zoom */
}

/* Menu Bar Clock Ticker */
.clock-ticker {
    display: flex;
    gap: 8px;
    align-items: center;
    font-size: 13px;
    font-weight: 500;
    text-transform: uppercase;
}

.clock-sep {
    opacity: 0.5;
}

/* List View Styles */
.list-view-container {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
    background: transparent;
    overflow-y: auto;
    padding: 8px 0;
}

.list-row {
    display: flex;
    align-items: center;
    padding: 6px 16px;
    cursor: pointer;
    color: var(--os-text);
    transition: background 0.1s, color 0.1s;
    user-select: none;
}

.list-row:hover {
    background: #0058d0;
    color: #ffffff;
}

.list-icon-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 12px;
}

.list-label {
    flex: 1;
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 500;
}

.list-arrow {
    font-size: 14px;
    opacity: 0.5;
    margin-left: 8px;
    font-weight: bold;
}

.list-row:hover .list-arrow {
    opacity: 1;
}

.list-row:hover .list-icon-wrapper svg path {
    fill: #ffffff;
}

/* --- Spinners --- */
@keyframes pixel-spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

.pixel-spinner {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    /* Beachball conic gradient in 6 shades of blue */
    background: conic-gradient(#cce4ff 0deg 60deg,
            #99caff 60deg 120deg,
            #66b0ff 120deg 180deg,
            #3395ff 180deg 240deg,
            #007aff 240deg 300deg,
            #005ecc 300deg 360deg);
    animation: pixel-spin 1.2s infinite steps(12);
    position: absolute;
    top: 50%;
    left: 50%;
    margin-top: -12px;
    margin-left: -12px;
    box-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(0, 0, 0, 0.2);
}

/* -------------------------------------
 * MOBILE OPTIMIZATION
 * ------------------------------------- */

@media (max-width: 768px) {

    /* Menu Bar */
    .menu-bar {
        padding: 0 4px;
        height: auto;
        min-height: 48px;
    }

    .menu-item {
        padding: 0 4px;
        font-size: 12px;
    }

    .menu-item.logo {
        font-size: 14px;
        line-height: 1.1;
    }

    /* Hide some clock text to save space if needed, or simply let it scale */
    .clock-ticker {
        font-size: 10px;
        gap: 4px;
    }

    .clock-ticker span {
        white-space: nowrap;
    }

    .clock-sep {
        margin: 0 2px;
    }

    /* Desktop Footer (Copyright) */
    .desktop-footer {
        font-size: 11px;
        padding-bottom: 8px;
    }

    /* BIOS Login Screen */
    .bios-label {
        font-size: 16px;
    }

    .bios-input-group {
        font-size: 24px;
    }

    input#password-input {
        width: 150px;
    }

    /* OS Windows */
    .os-window {
        max-width: 95vw !important;
        max-height: 85vh !important;
    }

    /* Touch targets for titlebar */
    .window-titlebar {
        height: 36px;
        padding-left: 8px;
    }

    .window-close-btn {
        width: 16px;
        height: 16px;
    }

    .window-title {
        font-size: 14px;
    }

    /* Adjust Icon Grid for App/Folder icons */
    .icon-view {
        grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
        gap: 20px 10px;
        padding: 16px;
    }

    .os-icon-graphic {
        width: 50px;
        height: 40px;
    }

    .os-icon-graphic::before {
        width: 20px;
        height: 10px;
        top: -10px;
    }

    .os-icon-label {
        font-size: 11px;
    }

    /* Search Dropdown */
    #search-dropdown {
        width: 200px !important;
        right: -5px;
    }
}