/* =========================================
   1. FONT DEFINITIONS & IMPORTS
   ========================================= */

@font-face {
    font-family: "Electroharmonix";
    src: url("../assets/fonts/Electroharmonix.otf") format("opentype");
}

@font-face {
    font-family: "Orbitron";
    src: url("../assets/fonts/OrbitronBlack.otf") format("opentype");
}

/* =========================================
   2. THE STAGE (The Void)
   ========================================= */
#gallery-view {
    position: relative;
    height: 100vh;
    height: 100dvh;
    background: #000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    z-index: 10;
    transform: scale(0.95);
    transition: none;
    pointer-events: auto;
}

#cipher-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
}

#gallery-view.view-impact {
    opacity: 1;
    transform: scale(1);
    transition: opacity 1.5s ease-out, transform 1.5s cubic-bezier(0.22, 1, 0.36, 1);
}

#gallery-view.view-skip {
    opacity: 1;
    transform: scale(1);
    transition: opacity 0.05s linear;
}

/* =========================================
   3. THE GRID CONTAINER
   ========================================= */
.mosaic-container {
    position: relative;
    z-index: 2;
    height: 80vh;
    aspect-ratio: 2 / 3;
    transition: filter 0.6s ease, transform 0.6s ease;
}

.mosaic-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: 1.5vh;
    width: 100%;
    height: 100%;
}

/* =========================================
   4. THE CARD 
   ========================================= */
.card {
    position: relative;
    width: 100%;
    height: 100%;
    background: #0a0a0a;
    cursor: pointer;
    overflow: hidden;
    opacity: 0;
    transform: translateY(20px);
    transition: transform 0.4s ease, opacity 0.4s ease;
}

.card.reveal-impact {
    transition: transform 0.8s cubic-bezier(0.25, 1, 0.5, 1), opacity 0.8s ease;
}

.card.reveal-skip {
    transition: transform 0.3s cubic-bezier(0.1, 1, 0.1, 1), opacity 0.2s ease;
}

.card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0.8;
    filter: grayscale(100%) brightness(0.9);
    transition: all 0.6s cubic-bezier(0.25, 1, 0.5, 1);
    will-change: opacity, filter;
}

/* =========================================
   5. HOVER LOGIC & INTERACTIONS
   ========================================= */
.mosaic-grid:hover .card img {
    opacity: 0.3;
    filter: grayscale(100%) blur(2px);
}

.mosaic-grid .card:hover img {
    opacity: 1;
    filter: grayscale(0%) brightness(1.1) blur(0px);
    z-index: 2;
}

.card-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, rgba(0,0,0,0.95) 0%, transparent 50%);
    opacity: 0;
    transition: opacity 0.4s ease;
    pointer-events: none;
}

.card:hover .card-overlay { opacity: 1; }

.card-info {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    padding: 20px;
    transform: translateY(10px);
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.25, 1, 0.5, 1) 0.1s;
    z-index: 5;
    text-align: left;
}

.card:hover .card-info {
    transform: translateY(0);
    opacity: 1;
}

.card-title {
    display: block;
    font-size: 11px;
    font-weight: 800;
    color: #fff;
    letter-spacing: 1px;
    text-transform: uppercase;
    text-shadow: 0 2px 10px rgba(0,0,0,0.8);
    line-height: 1.2;
    margin-bottom: 4px;
}

.card-year {
    display: block;
    font-size: 9px;
    color: #aaa;
    letter-spacing: 1px;
    font-weight: 700;
}

/* Tracing Outline Animation on Click */
.card::after {
    content: '';
    position: absolute;
    inset: 0;
    opacity: 0;
    transform: scale(1.15);
    transition: all 0.3s cubic-bezier(0.25, 1, 0.5, 1);
    pointer-events: none;
    z-index: 10;
}

.card.tracing::after {
    opacity: 1;
    transform: scale(1);
    box-shadow: 0 0 20px rgba(255,255,255,0.4);
}

/* =========================================
   6. THE RAIL (Navigation Spine)
   ========================================= */
.gallery-rail {
    position: relative;
    z-index: 2;
    margin-left: 5vh;
    height: 80vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    border-left: 1px solid rgba(255,255,255,0.1);
    padding-left: 20px;
    transition: filter 0.6s ease;
}

.rail-tabs {
    display: flex;
    flex-direction: column;
    gap: 50px;
}

.rail-tab {
    background: none;
    border: none;
    position: relative;
    display: flex;
    align-items: center;
    cursor: pointer;
    opacity: 0.3;
    transition: opacity 0.4s ease;
    padding: 0;
}

.rail-tab:hover { opacity: 0.6; }
.rail-tab.active { opacity: 1; }

.tab-text {
    writing-mode: vertical-rl;
    transform: rotate(180deg);
    font-family: 'Montserrat', sans-serif;
    font-size: 11px;
    letter-spacing: 3px;
    color: #fff;
    font-weight: 700;
}

.tab-line {
    position: absolute;
    right: -21px;
    width: 2px;
    height: 0%;
    background: #fff;
    transition: height 0.4s ease;
}

.rail-tab.active .tab-line { height: 100%; }

/* =========================================
   7. THE EXPANDED VIEW
   ========================================= */
.expanded-view {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.5s ease;
    background: rgba(0,0,0,0.85);
    backdrop-filter: blur(0px);
}

.expanded-view.active {
    opacity: 1;
    pointer-events: auto;
    backdrop-filter: blur(10px);
}

.expanded-content {
    display: flex;
    width: 80%;
    max-width: 1000px;
    height: 65vh;
    gap: 60px;
    transform: scale(0.95);
    transition: transform 0.6s cubic-bezier(0.16, 1, 0.3, 1);
    position: relative;
}

.expanded-view.active .expanded-content {
    transform: scale(1);
}

.expanded-cover-wrapper {
    flex: 0 0 auto;
    height: 100%;
    aspect-ratio: 2/3;
    box-shadow: 0 20px 60px rgba(0,0,0,0.8);
}

.expanded-cover {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.expanded-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    color: #fff;
    text-align: left;
    padding-right: 40px;
}

.expanded-info h1 {
    font-family: 'Montserrat', sans-serif;
    font-size: clamp(32px, 5vw, 52px);
    font-weight: 800;
    letter-spacing: -2px;
    line-height: 0.95;
    margin-bottom: 20px;
    text-transform: uppercase;
    color: #fff;
    text-wrap: balance;
}

.exp-meta-line {
    font-family: 'Space Mono', monospace;
    font-size: 13px;
    color: #888;
    letter-spacing: 0.5px;
    margin-bottom: 30px;
    text-transform: uppercase;
    border-left: none;
    padding-left: 0;
    display: flex;
    gap: 15px;
}

.exp-tags {
    display: flex;
    gap: 10px;
    margin-bottom: 35px;
}

.exp-tags span {
    display: inline-block;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(0, 0, 0, 0.05);
    padding: 6px 14px;
    font-family: 'Space Mono', monospace;
    font-size: 10px;
    border-radius: 4px;
    color: #ccc;
    text-transform: uppercase;
    transition: all 0.3s ease;
}

.exp-tags span:hover {
    border-color: #fff;
    background: #fff;
    color: #000;
}

.exp-synopsis {
    font-family: 'Montserrat', sans-serif;
    font-size: 15px;
    line-height: 1.7;
    color: #aaa;
    max-width: 600px;
    font-weight: 400;
}

.exp-close {
    position: absolute;
    top: -60px;
    right: 0;
    font-size: 30px;
    cursor: pointer;
    color: #444;
    transition: color 0.3s;
}

.exp-close:hover { color: #fff; }

.nav-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: none;
    color: #444;
    font-size: 3rem;
    cursor: pointer;
    padding: 30px;
    z-index: 110;
    transition: all 0.3s cubic-bezier(0.25, 1, 0.5, 1);
    outline: none;
    display: block;
}

.nav-arrow:hover {
    color: #fff;
    text-shadow: 0 0 15px rgba(255,255,255,0.5);
    transform: translateY(-50%) scale(1.1);
}

.nav-arrow.prev { left: 10px; }
.nav-arrow.next { right: 10px; }

.exp-links {
    margin-top: 30px;
    display: flex;
    gap: 15px;
}

.exp-link-btn {
    text-decoration: none;
    font-family: 'Space Mono', monospace;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    color: #fff;
    background: transparent;
    border: 1px solid rgba(255,255,255,0.3);
    padding: 10px 20px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s ease;
}

.exp-link-btn:hover {
    background: #fff;
    color: #000;
    border-color: #fff;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(255,255,255,0.1);
}

.gallery-view.depth-mode .mosaic-container,
.gallery-view.depth-mode .gallery-rail {
    filter: blur(8px) brightness(0.4);
    pointer-events: none;
}

.swipe-hint {
    display: none;
}

/* =========================================
   8. THEME OVERRIDE EASTER EGG (Desktop)
   ========================================= */
.theme-override-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9000;
}

/* The invisible hit-box trigger */
.theme-trigger {
    width: 30px;
    height: 30px;
    position: absolute;
    bottom: 0;
    right: 0;
    cursor: pointer;
    display: flex;
    align-items: flex-end;
    justify-content: flex-end;
    opacity: 0;
}

.theme-trigger:hover { opacity: 1; }

.theme-trigger::after {
    content: '';
    width: 4px;
    height: 4px;
    background: var(--current-theme-color, #00f3ff); 
    box-shadow: 0 0 8px var(--current-theme-color, #00f3ff); 
    border-radius: 50%;
    display: block;
    margin: 5px;
    opacity: 0.7; 
}

/* The Terminal Menu */
.theme-menu {
    position: absolute;
    bottom: 35px;
    right: 0;
    background: rgba(5, 5, 5, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    backdrop-filter: blur(10px);
    opacity: 0;
    pointer-events: none;
    transform: translateY(10px);
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    white-space: nowrap;
    box-shadow: 0 10px 30px rgba(0,0,0,0.8);
}

.theme-menu.active {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}

.theme-menu-title {
    font-family: 'Space Mono', monospace;
    font-size: 10px;
    color: #666;
    margin-bottom: 5px;
    border-bottom: 1px solid #222;
    padding-bottom: 5px;
}

.theme-btn {
    background: none;
    border: none;
    color: #666;
    font-family: 'Space Mono', monospace;
    font-size: 11px;
    text-align: left;
    cursor: pointer;
    padding: 2px 0;
    transition: color 0.2s ease, transform 0.2s ease;
}

.theme-btn:hover {
    color: #fff;
    transform: translateX(-5px); 
}

.theme-btn.active {
    /* Uses a CSS variable updated by Javascript! */
    color: var(--current-theme-color, #00f3ff); 
    font-weight: bold;
}

@media screen and (max-width: 1024px) {
    .theme-override-container { display: none !important; }
}

/* =========================================
   9. SYSTEM MESSAGE (Theme Override Alert)
   ========================================= */
.sys-message {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.95);
    background: rgba(0, 0, 0, 0.8);
    border: 1px solid var(--current-theme-color, #00f3ff);
    color: var(--current-theme-color, #00f3ff);
    font-family: 'Space Mono', monospace;
    font-size: 14px;
    font-weight: bold;
    letter-spacing: 2px;
    padding: 15px 30px;
    border-radius: 2px;
    backdrop-filter: blur(5px);
    z-index: 9999;
    
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
    box-shadow: 0 0 30px rgba(0,0,0,0.9);
}

.sys-message.flash {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
    animation: sys-flicker 0.1s ease-in-out 3; 
}

@keyframes sys-flicker {
    0%   { opacity: 1; }
    50%  { opacity: 0.5; }
    100% { opacity: 1; }
}

/* --- THE LOCK SCREEN (Terminal Prompt) --- */
.theme-auth {
    position: absolute;
    bottom: 35px;
    right: 0;
    background: rgba(5, 5, 5, 0.95);
    border: 1px solid rgba(255, 0, 60, 0.5); 
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    backdrop-filter: blur(10px);
    opacity: 0;
    pointer-events: none;
    transform: translateY(10px);
    transition: all 0.3s ease;
    box-shadow: 0 10px 30px rgba(0,0,0,0.8);
}

.theme-auth.active {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}

.auth-title {
    font-family: 'Space Mono', monospace;
    font-size: 10px;
    color: #ff003c;
    border-bottom: 1px solid rgba(255, 0, 60, 0.3);
    padding-bottom: 5px;
    letter-spacing: 1px;
}

.auth-input {
    background: transparent;
    border: none;
    color: #fff;
    font-family: 'Space Mono', monospace;
    font-size: 14px;
    outline: none;
    text-align: center;
    letter-spacing: 4px;
    width: 100%;
}

.auth-input::placeholder { color: rgba(255, 255, 255, 0.2); }

/* Shake Animation for Failed Attempts */
.theme-auth.error {
    animation: auth-shake 0.4s cubic-bezier(.36,.07,.19,.97) both;
    border-color: #ff003c;
}

@keyframes auth-shake {
    10%, 90% { transform: translate3d(-2px, 0, 0); }
    20%, 80% { transform: translate3d(4px, 0, 0); }
    30%, 50%, 70% { transform: translate3d(-6px, 0, 0); }
    40%, 60% { transform: translate3d(6px, 0, 0); }
}

/* =========================================
   9: MOBILE ADAPTATION (THE TRUE 3x3)
   ========================================= */
@media screen and (max-width: 768px) {
    /* --- THE CENTERING FIX ---
       Pushes the visual center UP by exactly the height of the bottom rail */
    #gallery-view {
        padding-bottom: 70px; 
        box-sizing: border-box;
    }

    #gallery-view.view-impact {
        transition: opacity 0.6s ease-out !important;
        transform: scale(1) !important;
    }

    /* --- THE RAIL --- */
    .gallery-rail {
        position: fixed;
        bottom: 0;
        left: 0;
        width: 100%;
        height: 70px;
        margin-left: 0;
        border-left: none;
        border-top: 1px solid rgba(255,255,255,0.15);
        background: #050505;
        flex-direction: row;
        padding: 0 15px; 
        box-sizing: border-box; /* Stops padding from breaking viewport width */
        z-index: 50;
    }
    
    .rail-tabs {
        flex-direction: row;
        gap: 0;
        width: 100%;
        justify-content: space-evenly;
        overflow-x: auto;
        scrollbar-width: none;
    }
    
    .rail-tabs::-webkit-scrollbar {
        display: none;
    }
    
    .rail-tab {
        flex: 1;
        justify-content: center;
        height: 100%;
    }
    
    .tab-text {
        writing-mode: horizontal-tb;
        transform: none;
        font-size: 10px;
        letter-spacing: 1px;
    }
    
    .tab-line {
        right: auto;
        top: 0;
        left: 0;
        width: 100%;
        height: 2px;
        background: #fff;
        transform: scaleX(0);
        transition: transform 0.3s ease;
    }
    
    .rail-tab.active .tab-line {
        height: 2px;
        transform: scaleX(1);
    }

    /* --- THE GRID --- */
    .mosaic-container {
        width: 100%;
        height: auto;
        padding: 0 15px; 
        display: flex;
        align-items: center;
    }
    
    .mosaic-grid {
        gap: 8px;
        grid-template-columns: repeat(3, 1fr);
        grid-template-rows: auto;
        align-content: center;
        height: auto;
    }
    
    .card {
        width: 100%;
        aspect-ratio: 2 / 3;
        height: auto;
    }
    
    .card img {
        width: 100%;
        height: 100%;
        object-fit: cover !important;
        opacity: 1 !important;
        filter: grayscale(0%) brightness(1) !important;
    }
    
    .mosaic-grid:hover .card img {
        opacity: 1;
        filter: none;
    }
    
    .card-info, .card-overlay {
        display: none !important;
    }

    /* --- THE EXPANDED VIEW (MINIMALIST MOBILE FIX) --- */
    .expanded-content {
        flex-direction: column;
        width: 90%;
        
        /* THE GHOST SCROLL FIX */
        max-height: 90vh; 
        height: auto;
        overflow-y: auto; 
        
        gap: 25px;
        padding-top: 20px; 
        padding-bottom: 30px; 
    }
    
    /* Spotify-style Poster UX */
    .expanded-cover-wrapper {
        flex: 0 0 auto;
        width: auto; 
        max-width: 100%;
        height: 45vh; 
        aspect-ratio: 2 / 3; 
        margin: 0 auto; 
        box-shadow: 0 15px 40px rgba(0,0,0,0.6);
        border-radius: 4px;
    }
    
    .expanded-cover {
        object-position: center; 
        border-radius: 4px;
    }
    
    .expanded-info {
        padding-right: 0;
        justify-content: flex-start;
        overflow: visible;
        text-align: center; 
    }
    
    .expanded-info h1 {
        font-size: 32px;
        margin-bottom: 15px;
        line-height: 1.1;
    }
    
    .exp-meta-line {
        font-size: 11px;
        margin-bottom: 20px;
        flex-wrap: wrap;
        justify-content: center; 
    }
    
    .exp-tags {
        flex-wrap: wrap;
        gap: 8px;
        margin-bottom: 25px;
        justify-content: center; 
    }
    
    .exp-tags span {
        padding: 6px 12px;
        font-size: 9px;
    }
    
    .exp-synopsis {
        font-size: 14px;
        line-height: 1.6;
        color: #ccc;
        text-align: left; 
    }
    
    /* UI Stripping for Mobile Gestures */
    .nav-arrow {
        display: none !important; 
    }
    
    .exp-close {
        position: fixed; 
        top: 15px;
        right: 15px;
        font-size: 36px;
        color: rgba(255, 255, 255, 0.7); 
        background: transparent; 
        border: none;            
        box-shadow: none;        
        backdrop-filter: none;   
        width: 45px;
        height: 45px;
        display: flex;
        align-items: center;
        justify-content: center;
        z-index: 300; 
        transition: transform 0.2s, color 0.2s;
    }
    
    .exp-close:active {
        transform: scale(0.85); /* Tactile UX pop */
        color: #fff;
    }
}

/* =========================================
   10: TABLET ADAPTATION (Max 1024px)
   ========================================= */
@media screen and (max-width: 1024px) {
    .gallery-rail {
        margin-left: 2vw;
        padding-left: 10px;
    }
    
    .expanded-content {
        width: 95%;
        gap: 30px;
    }

    .expanded-info h1 {
        font-size: clamp(28px, 4vw, 40px);
    }
    
    .nav-arrow {
        display: none !important; 
    }
    
    .exp-close {
        position: fixed; 
        top: 20px;
        right: 20px;
        font-size: 40px;
        color: rgba(255, 255, 255, 0.7);
        background: transparent; 
        border: none;            
        box-shadow: none;        
        backdrop-filter: none;   
        width: 50px;
        height: 50px;
        display: flex;
        align-items: center;
        justify-content: center;
        z-index: 300; 
        transition: transform 0.2s, color 0.2s;
    }
    
    .exp-close:active {
        transform: scale(0.85); 
        color: #fff;
    }

    /* Swipe Gesture Visual Cue */
    .swipe-hint {
        display: block; 
        position: absolute;
        bottom: 40px; 
        left: 50%;
        transform: translateX(-50%);
        font-family: 'Space Mono', monospace;
        color: rgba(255, 255, 255, 0.7);
        font-size: 11px;
        letter-spacing: 4px;
        pointer-events: none; 
        z-index: 200;
        opacity: 0; 
        transition: opacity 0.5s ease;
    }

    .swipe-hint.visible {
        opacity: 1;
        animation: pulse-swipe 2s infinite ease-in-out; 
    }

    @keyframes pulse-swipe {
        0%, 100% { transform: translateX(-50%) scale(0.95); opacity: 0.4; }
        50%      { transform: translateX(-50%) scale(1.05); opacity: 1; }
    }
}

/* Portrait Tablets (iPads held vertically) */
@media screen and (max-width: 1024px) and (orientation: portrait) {
    .expanded-content {
        flex-direction: column;
        
        /* THE GHOST SCROLL FIX */
        max-height: 90vh; 
        height: auto;
        overflow-y: auto; 
        
        padding-top: 20px;
        padding-bottom: 40px; 
    }
    
    .expanded-cover-wrapper {
        flex: 0 0 auto;
        width: auto; 
        max-width: 100%;
        height: 45vh; 
        aspect-ratio: 2 / 3; 
        margin: 0 auto; 
        box-shadow: 0 15px 40px rgba(0,0,0,0.6);
        border-radius: 4px;
    }
    
    .expanded-cover {
        object-position: center; 
        border-radius: 4px;
    }
    
    .expanded-info {
        padding-right: 0;
        justify-content: flex-start;
        overflow: visible;
        text-align: center; 
    }
    
    .exp-meta-line {
        justify-content: center;
        flex-wrap: wrap;
    }
    
    .exp-tags {
        justify-content: center;
        flex-wrap: wrap;
    }
    
    .exp-links {
        justify-content: center;
        margin-top: 30px;
        padding-bottom: 20px; 
    }
    
    .exp-synopsis {
        text-align: left; 
        margin: 0 auto; 
        max-width: 90%; 
    }
}

/* =========================================
   11. SWIPE BOUNDARY ANIMATIONS
   ========================================= */
.bounce-left {
    animation: swipe-bounce-left 0.4s cubic-bezier(0.25, 1, 0.5, 1);
}

.bounce-right {
    animation: swipe-bounce-right 0.4s cubic-bezier(0.25, 1, 0.5, 1);
}

/* Visual tugs when hitting the end of a category array */
@keyframes swipe-bounce-left {
    0%   { transform: translateX(0); }
    40%  { transform: translateX(-40px); } 
    100% { transform: translateX(0); }
}

@keyframes swipe-bounce-right {
    0%   { transform: translateX(0); }
    40%  { transform: translateX(40px); } 
    100% { transform: translateX(0); }
}