:root {
    --void: #08090A;
    --calib-orange: #FF4500;
    --ui-border: #333;
}

body {
    background: var(--void);
    color: #fff;
    font-family: 'Courier New', monospace;
    margin: 0;
    height: 100vh;
    display: flex;
    flex-direction: column; /* Stacks Nav and Terminal */
    justify-content: center;
    align-items: center;
    overflow: hidden;
    padding-top: 20px;
}

/* CRT SCANLINE OVERLAY */
body::before {
    content: " ";
    position: fixed;
    top: 0; left: 0; bottom: 0; right: 0;
    background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.15) 50%), 
                linear-gradient(90deg, rgba(255, 0, 0, 0.03), rgba(0, 255, 0, 0.01), rgba(0, 0, 2, 0.03));
    z-index: 9999;
    background-size: 100% 2px, 3px 100%;
    pointer-events: none;
}

/* GLOBAL NAVIGATION */
.global-nav {
    width: 90vw;
    display: flex;
    justify-content: space-between;
    align-items: flex-end; /* Aligns links with the bottom of the logo/text */
    padding: 10px 0;
    margin-bottom: 10px;
    border-bottom: 1px solid var(--ui-border);
}

.brand-container {
    display: flex;
    align-items: center;
    gap: 15px;
    max-height: 60px; /* Limits the vertical space the logo can take */
}

.global-nav .brand { color: var(--calib-orange); font-weight: bold; }
.nav-links { list-style: none; display: flex; gap: 20px; padding: 0; margin: 0; }
.nav-links a { color: #fff; text-decoration: none; }
.nav-links a:hover { color: var(--calib-orange); }

.nav-logo {
    height: 5rem; /* Scales with text height */
    width: auto;  /* Prevents stretching */
    filter: grayscale(1) brightness(1.5); /* Keeps the CRT vibe */
}

.viewport-logo {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 45%; /* Adjusts ghost logo scale */
    max-width: 300px;
    opacity: 0.05; /* Very faint */
    z-index: 3;
    pointer-events: none;
    display: none; /* Controlled by JS */
    filter: grayscale(1) contrast(1.2); /* Hardware burn-in effect */
}

.brand-main {
    color: var(--calib-orange);
    font-weight: bold;
    font-size: 1.4rem; /* Main title prominence */
    letter-spacing: 2px;
}

.brand-tagline {
    font-size: 0.85rem; /* Secondary tagline */
    color: #888;
    margin-top: 1px;
    text-transform: uppercase;
}

/* TERMINAL LAYOUT */
.terminal {
    width: 90vw; 
    height: 85vh;
    border: 2px solid var(--ui-border);
    display: grid;
    grid-template-rows: auto 1fr auto;
    background-color: #0c0d0e;
    overflow: hidden;
}

header { padding: 10px 20px; border-bottom: 1px solid var(--ui-border); }

.command-center {
    display: grid;
    grid-template-columns: 1fr 300px; /* Two-column layout for desktop */
    height: 100%;
    overflow: hidden;
}

.viewport { 
    position: relative; 
    border-right: 1px solid var(--ui-border); 
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
}

/* VIDEO CONTAINER */
.media-container {
    position: relative;
    width: 100%;
    flex: 1;
    aspect-ratio: 16 / 9;
    background: #000;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

.media-container video { 
    width: 100%; 
    height: 100%; 
    object-fit: contain; 
}

#static-canvas {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    z-index: 2;
    background: transparent;
    pointer-events: none;
    opacity: 0.15;
    display: none; /* Controlled by JS */
}

.viewport-console {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    z-index: 10;
    background: rgba(8, 9, 10, 0.8);
    padding: 20px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    pointer-events: none;
    transition: opacity 0.5s ease;
}

/* THEATER MODE */
.command-center.theater-mode { grid-template-columns: 1fr; }
.command-center.theater-mode .side-panel { display: none; }

/* TICKER SYSTEM */
footer {
    padding: 10px 20px;
    background: #050505;
    border-top: 1px solid var(--ui-border);
    height: 40px;
}

.ticker {
    width: 90%;
    max-width: 800px;
    margin: 0 0 0 20px; /* Pins container to the left */
    overflow: hidden;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: flex-start; /* Pins text start point to the left */
    position: relative;
}

.ticker-inner {
    display: inline-block;
    white-space: nowrap;
    color: var(--calib-orange);
    font-family: 'Courier New', monospace;
}

.ticker-inner.scroll-active {
    padding-left: 100%;
    animation: marquee 20s linear infinite;
}

@keyframes marquee {
    0% { transform: translateX(0); }
    100% { transform: translateX(-100%); }
}

/* UTILS */
.jitter-text { display: inline-block; animation: text-jitter 5s infinite; }
@keyframes text-jitter {
    0%, 90%, 100% { transform: translate(0, 0); }
    92% { transform: translate(-2px, 1px); }
    98% { transform: translate(1px, 2px); }
}

.side-panel { padding: 20px; background: rgba(15, 15, 15, 0.8); overflow-y: auto; }
.side-panel li { padding: 8px 0; cursor: pointer; color: #fff; list-style: none; }
.side-panel li:hover { color: var(--calib-orange); }

.transport-console {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    padding: 15px;
    background: #050505;
    border-top: 1px solid var(--ui-border);
    align-items: center;
    transition: opacity 0.5s ease;
}

.transport-console.is-dimmed { opacity: 0.2; } /* Play-state dimming */

.ctrl-btn {
    background: transparent;
    border: 1px solid var(--ui-border);
    color: var(--calib-orange);
    padding: 8px 16px;
    font-weight: bold;
    cursor: pointer;
}

/* RESPONSIVE DESIGN BREAKPOINT */
@media (max-width: 900px) {
    /* Header Stacking */
    .global-nav {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }

    .nav-logo {
        height: 2.5rem; /* Shrinks logo for mobile */
    }

    .brand-main {
        font-size: 0.9rem; /* Shrinks title for mobile */
    }

    /* Layout Stacking - Fixed the 'Crowding' issue */
    .command-center {
        grid-template-columns: 1fr; /* Force single column */
        grid-template-rows: auto 1fr; /* Video top, Directory bottom */
        overflow-y: auto; /* Allows scrolling to the directory */
    }

    .viewport {
        border-right: none;
        border-bottom: 1px solid var(--ui-border);
    }

    .side-panel {
        max-height: 400px;
        border-top: 2px solid var(--ui-border);
    }
}

/* Fullscreen Styling */
#media-container:fullscreen {
    width: 100vw;
    height: 100vh;
    background-color: #000;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Ensure Safari-specific fullscreen works similarly */
#media-container:-webkit-full-screen {
    width: 100%;
    height: 100%;
    background-color: #000;
}

/* Optional: Hide the CRT scanlines in fullscreen if they look too thick on mobile */
#media-container:fullscreen ~ .viewport-logo {
    width: 60%; /* Make the ghost logo larger in fullscreen */
}