/* ===== Blank font faces (load FIRST) ===== */

@font-face {
    font-family: 'Nunito Blank';
    src: url('https://fonts.noisefactor.io/fonts/nunito/Nunito-Blank.woff2') format('woff2');
    font-weight: 100 900;
    font-style: normal;
    font-display: block;
}

@font-face {
    font-family: 'Rubik Blank';
    src: url('https://fonts.noisefactor.io/fonts/rubik/Rubik-Blank.woff2') format('woff2');
    font-weight: 100 900;
    font-style: normal;
    font-display: block;
}

@font-face {
    font-family: 'Noto Sans Mono Blank';
    src: url('https://fonts.noisefactor.io/fonts/noto-sans-mono/NotoSansMono-Blank.woff2') format('woff2');
    font-weight: 100 900;
    font-style: normal;
    font-display: block;
}

/* ===== Real font faces ===== */

@font-face {
    font-family: Nunito;
    src: url('https://fonts.noisefactor.io/fonts/nunito/Nunito%5Bwght%5D.woff2') format('woff2');
    font-weight: 400 700;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: Rubik;
    src: url('https://fonts.noisefactor.io/fonts/rubik/Rubik%5Bwght%5D.woff2') format('woff2');
    font-weight: 300 900;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Noto Sans Mono';
    src: url('https://fonts.noisefactor.io/fonts/noto-sans-mono/NotoSansMono%5Bwdth%2Cwght%5D.woff2') format('woff2');
    font-weight: 200 700;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: vcr;
    src: url('https://fonts.noisefactor.io/fonts/vcr-osd-mono/VCR_OSD_MONO_1.001.ttf') format('truetype');
    font-display: swap;
}

@font-face {
    font-family: 'Material Symbols Outlined';
    font-style: normal;
    src: url('https://fonts.noisefactor.io/fonts/material-symbols-outlined/material-symbols-outlined.woff2') format('woff2');
    font-display: block;
}

.material-symbols {
    font-family: 'Material Symbols Outlined';
    font-weight: normal;
    font-style: normal;
    font-size: 1em;
    display: inline-block;
    line-height: 1;
    text-transform: none;
    letter-spacing: normal;
    word-wrap: normal;
    white-space: nowrap;
    direction: ltr;
    font-variation-settings: 'FILL' 0;
    width: 1em;
    overflow: hidden;
    text-align: center;
}

/* ===== CSS custom properties ===== */

:root {
    --color-bg: #121212;
    --color-surface: #1a1a1a;
    --color-text: #f5f5f5;
    --color-muted: #999;
    --color-teal: #4CA8A1;
    --color-blue: #2E6CC4;
    --color-card-hover: #2a2a2a;

    --ui-layer-index: 1;
    --black-layer-index: 2;
    --bumper-layer-index: 5;
    --encoding-layer-index: 6;
    --ui-upper-layer-index: 7;
    --ui-logo-layer-index: 8;
}

/* ===== Body reset ===== */

body {
    margin: 0;
    padding: 0;
    background: var(--color-bg);
    color: var(--color-text);
    font-family: Nunito, 'Nunito Blank';
}

h1, h2, h3, h4, h5, h6 {
    font-family: Rubik, 'Rubik Blank';
    font-weight: 700;
}

a {
    color: var(--color-teal);
}

/* ===== Nav bar ===== */

.site-nav-toggle {
    position: fixed;
    top: 12px;
    right: 12px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: rgba(18, 18, 18, 0.7);
    color: var(--color-text);
    cursor: pointer;
    z-index: 101;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(8px);
}

.site-nav-toggle:hover {
    background: rgba(18, 18, 18, 0.9);
}

.site-nav-menu {
    display: none;
    position: fixed;
    top: 60px;
    right: 12px;
    background: rgba(18, 18, 18, 0.95);
    backdrop-filter: blur(8px);
    border-radius: 8px;
    padding: 16px 20px;
    flex-direction: column;
    gap: 12px;
    z-index: 100;
}

.site-nav-menu.open {
    display: flex;
}

.site-nav-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: var(--color-text);
    font-family: Rubik, 'Rubik Blank';
    font-weight: 700;
    font-size: 1.1rem;
}

.site-nav-brand img {
    width: 32px;
    height: 32px;
}

.site-nav-links {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.site-nav-links a {
    color: var(--color-muted);
    text-decoration: none;
    font-size: 0.9rem;
    transition: color 0.15s;
}

.site-nav-links a:hover {
    color: var(--color-text);
}

/* ===== About modal ===== */

.about-modal {
    width: min(720px, 100vw);
    max-width: 720px;
    min-width: 360px;
    background-color: var(--color-surface);
    border: none;
    border-radius: 12px;
    padding: 0;
    overflow: hidden;
    color: var(--color-text);
}

.about-modal::backdrop {
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
}

.about-modal[open] {
    animation: about-open 0.2s ease-out;
}

@keyframes about-open {
    from {
        opacity: 0;
        transform: scale(0.96) translateY(10px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.about-modal-content {
    display: grid;
    grid-template-columns: min(80%, 320px) 1fr;
    align-items: stretch;
}

.about-modal-graphic {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2.75rem 2.5rem;
    background: linear-gradient(135deg, rgba(76, 168, 161, 0.1) 0%, transparent 100%);
}

.about-modal-logo {
    width: min(80%, 200px);
    max-width: 200px;
    height: auto;
    filter: drop-shadow(0 0 20px var(--color-teal));
}

.about-modal-details {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 1rem;
    padding: 2.75rem 1.5rem;
    color: var(--color-muted);
}

.about-modal-details:focus,
.about-modal-details:focus-visible {
    outline: none;
}

.about-modal-title {
    font-family: Rubik, 'Rubik Blank';
    font-weight: 700;
    font-size: clamp(2.4rem, 5vw, 3rem);
    letter-spacing: 0.05em;
    color: var(--color-text);
    text-shadow: 0 0 20px var(--color-teal);
}

.about-modal-tagline {
    font-size: 1rem;
    letter-spacing: 0.02em;
    color: var(--color-teal);
}

.about-modal-authors {
    font-size: 1rem;
    letter-spacing: 0.01em;
    color: var(--color-muted);
}

.about-modal-copyright {
    font-size: 0.9rem;
    color: var(--color-muted);
}

.about-modal-link {
    color: var(--color-teal);
    text-decoration: none;
    transition: color 0.15s;
}

.about-modal-link:hover {
    color: var(--color-text);
}

.about-modal-build {
    font-size: 0.65rem;
    font-family: 'Noto Sans Mono', 'Noto Sans Mono Blank';
    letter-spacing: 0.08em;
    color: var(--color-muted);
    opacity: 0.7;
}

@media (max-width: 720px) {
    .about-modal {
        width: min(540px, 94vw);
        max-width: 540px;
    }

    .about-modal-content {
        grid-template-columns: 1fr;
        text-align: center;
    }

    .about-modal-graphic {
        padding: 2.25rem 2rem 1.5rem;
    }

    .about-modal-details {
        align-items: center;
        padding: 1.75rem 2rem 2.25rem;
    }

    .about-modal-logo {
        width: min(60%, 180px);
    }
}

/* ===== Fade animations ===== */

.fade-in {
    animation: fade-in 0.5s ease-in forwards;
}

.fade-out {
    animation: fade-out 0.5s ease-out forwards;
}

@keyframes fade-in {
    0% { opacity: 0; }
    100% { opacity: 1; }
}

@keyframes fade-out {
    0% { opacity: 1; }
    100% { opacity: 0; }
}

/* ===== Viewport/overlay rules (inert on pages without matching DOM) ===== */

#debug {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    font-weight: bold;
    padding: 4em 2em;
    z-index: 6;
    opacity: 0;
    pointer-events: none;
}

#debug p {
    text-shadow: 2px 2px 2px #000;
    margin: 0.5em;
}

#main {
    position: relative;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    transition: height 0.3s ease;
}

#main-image {
    position: absolute;
    width: 100%;
    height: 100%;
    object-fit: cover;
    background-color: #000;
}

#main-video {
    position: absolute;
    width: 100%;
    height: 100%;
    object-fit: cover;
    background-color: #000;
    pointer-events: none;
}

canvas {
    position: absolute;
    width: 100%;
    height: auto;
    background-color: #000;
    pointer-events: none;
}

p {
    font-size: 1.2em;
    padding-top: 0;
}

/* ===== Schedule overlays ===== */

.schedule {
    position: fixed;
    top: 5%;
    right: 3%;
    padding: 2em 3em 2em 2em;
    background-color: rgba(0, 0, 0, 0.5);
    border: 0.125em solid #fff;
    font-weight: bold;
    z-index: var(--ui-upper-layer-index);
    opacity: 0;
    pointer-events: none;
}

.schedule h3 {
    margin: 0;
    padding-bottom: 0;
    font-size: 2.0em;
}

.schedule-content {
    padding-left: 1em;
    display: inline-block;
}

.schedule p {
    font-size: 1.75em;
}

.schedule-spacer {
    display: block;
    padding-bottom: 2em;
}

.schedule-icon-eye {
    display: inline-block;
    width: 5.5em;
    height: 5.5em;
    margin-right: 0.5em;
    padding-bottom: 0.5em;
}

.schedule-icon-ear {
    display: inline-block;
    width: 5.5em;
    height: 5.5em;
    padding-bottom: 0.5em;
}

/* ===== Info bar ===== */

#info-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    display: grid;
    grid-template-columns: min-content 1fr min-content;
    align-items: center;
    padding: 1em 2em;
    gap: 1em;
    background-image: linear-gradient(to bottom, rgba(0,0,0,0), rgba(0,0,0,0.75));
    z-index: var(--ui-upper-layer-index);
    opacity: 0;
    pointer-events: none;
    box-sizing: border-box;
}

#info-icon-cell {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: 0.5em 0;
    box-sizing: border-box;
}

.info-icon {
    height: 80%;
    max-height: 4.5em;
    width: auto;
    display: none;
}

.info-icon.visible {
    display: block;
}

#info-content {
    overflow: hidden;
    white-space: nowrap;
}

#info-title {
    font-size: 2.0em;
    margin: 0 0 0.25em 0;
    overflow: hidden;
    text-overflow: ellipsis;
}

#info-description {
    font-size: 1.5em;
    margin: 0.25em 0 0;
    font-weight: bold;
    overflow: hidden;
    text-overflow: ellipsis;
}

#info-logo-cell {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    height: 100%;
    padding: 0.5em 0;
    box-sizing: border-box;
}

#logo {
    height: 100%;
    max-height: 120px;
    width: auto;
    z-index: var(--ui-logo-layer-index);
}

/* ===== Bumper ===== */

#bumper {
    position: fixed;
    top: 0; left: 0;
    height: 100vh;
    width: 100vw;
    z-index: var(--bumper-layer-index);
    object-fit: cover;
    pointer-events: none;
    opacity: 0;
    background-color: #000;
}

/* ===== Overlay black ===== */

#overlay-black {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    width: 100vw;
    z-index: var(--black-layer-index);
    background-color: #000;
    opacity: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    color: #fff;
    pointer-events: none;
}

#overlay-black div {
    font-size: 21pt;
    text-align: center;
    width: 100%;
}

#overlay-black div.smaller {
    font-size: 17pt;
    font-weight: bold;
}

/* ===== Encoding overlay (dedicated element — FSM cannot touch this) ===== */

#encoding-overlay {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    width: 100vw;
    z-index: var(--encoding-layer-index);
    background-color: rgba(0, 0, 0, 0.85);
    opacity: 0;
    transition: opacity 0.5s ease;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    color: #fff;
    pointer-events: none;
}

/* ===== Encoding status ===== */

.encoding-status {
    font-family: Rubik, 'Rubik Blank';
    font-size: 21pt;
    text-align: center;
    color: #ccc;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8);
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.encoding-status .smaller {
    font-size: 17pt;
    font-weight: bold;
    color: #999;
    margin-top: 0.5em;
}

.encoding-logo {
    width: 48px;
    height: 48px;
    margin-bottom: 1em;
    animation: logo-pulse 2s ease-in-out infinite;
}

@keyframes logo-pulse {
    0%, 100% { transform: scale(1); filter: drop-shadow(0 0 0px rgba(255, 255, 255, 0)); }
    50% { transform: scale(1.1); filter: drop-shadow(0 0 8px rgba(255, 255, 255, 0.3)); }
}

.segment-map {
    display: flex;
    flex-wrap: wrap;
    gap: 2px;
    justify-content: center;
    margin: 1.2em auto 0;
    max-width: 320px;
}

.segment-rect {
    width: 6px;
    height: 20px;
    background: #333;
    border-radius: 1px;
    transition: background 0.3s ease;
}

.segment-rect.loaded {
    background: #fff;
}

.segment-count {
    font-size: 11pt;
    color: #555;
    margin-top: 0.6em;
}

.encoding-status .elapsed {
    font-size: 13pt;
    color: #777;
    margin-top: 0.8em;
}

/* ===== Mobile responsive ===== */

@media (max-width: 768px) {
    /* Info bar — scale down */
    #info-bar {
        padding: 0.5em 1em;
    }

    #info-title {
        font-size: 1em;
    }

    #info-description {
        font-size: 0.8em;
    }

    .info-icon {
        max-height: 2.25em;
    }

    #logo {
        max-height: 3em;
    }

    /* Schedule overlays — scale down */
    .schedule {
        padding: 1em 1.5em;
    }

    .schedule h3 {
        font-size: 1.3em;
    }

    .schedule p {
        font-size: 1.15em;
    }

    .schedule-icon-eye,
    .schedule-icon-ear {
        width: 3.5em;
        height: 3.5em;
    }

    /* Encoding overlay — slightly smaller */
    .encoding-status {
        font-size: 16pt;
    }

    .segment-map {
        max-width: 240px;
    }

    .segment-rect {
        width: 4px;
        height: 14px;
    }
}
