@font-face {
    font-family: "W95Fa";
    src: url("../../../assets/fonts/W95FA.otf") format("opentype");
}
@font-face {
    font-family: "CursedGothic";
    src: url("../../../assets/fonts/cursed_gothic/CursedGothic.ttf")
        format("truetype");
}
@font-face {
    font-family: "CursedGothic-Witch";
    src: url("../../../assets/fonts/cursed_gothic/CursedGothic-Witch.ttf")
        format("truetype");
}
@font-face {
    font-family: "FreePixel";
    src: url("../../../assets/fonts/FreePixel.ttf") format("truetype");
}

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

:root {
    /* Color */
    --page-bg: #cc66ff;
    --video-bg: #ffb3e6;
    --video-bg-mid: #ff80d5;
    --ink: #000;

    /* Font size */
    --fs-1: 0.75rem;
    --fs-2: 0.8rem;
    --fs-3: 1rem;
    --fs-4: 26px;
    --fs-5: 28px;
    --fs-6: 22px;
    --fs-7: 2.2rem;
    --fs-display: clamp(2rem, 5vw, 3.8rem);

    /* Spacing */
    --sp-1: 4px;
    --sp-2: 6px;
    --sp-3: 8px;
    --sp-4: 10px;
    --sp-5: 12px;
    --sp-6: 16px;
    --sp-7: 20px;
    --sp-8: 24px;
    --sp-9: 32px;
}

body {
    background: var(--page-bg);
    font-family: "FreePixel", "W95Fa", "Courier New", monospace;
    min-height: 100vh;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: var(--sp-8);
}

/* ── PAGE SHELL ── */
.page {
    width: 100%;
    max-width: 1180px;
    background: var(--page-bg);
}

/* ── TITLE ── */
.title-bar {
    text-align: center;
    padding: var(--sp-7) 0 var(--sp-6);
}
.title-bar h1 {
    font-family: "CursedGothic", "W95Fa", monospace;
    font-size: var(--fs-display);
    font-weight: 800;
    color: var(--ink);
    line-height: 1;
    letter-spacing: -0.01em;
    text-shadow: none;
}
.title-bar .home-title {
    cursor: pointer;
    display: inline-block;
}
.title-bar .home-title:hover,
.title-bar .home-title:focus-visible {
    text-decoration: underline;
}

/* ── MAIN LAYOUT ── */
.main-layout {
    display: flex;
    gap: 0;
    align-items: stretch;
    min-height: 0;
}

/* ── LEFT NAV ── */
.left-nav {
    width: 230px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: var(--sp-3);
    padding: var(--sp-5) var(--sp-3) var(--sp-5) 0;
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: var(--sp-2);
    cursor: pointer;
    padding: var(--sp-3) var(--sp-4);
}
.nav-item.active .nav-label {
    text-decoration: underline;
}

/* Holographic icon placeholder */
.nav-icon {
    width: 128px;
    height: 116px;
    border-radius: 50%;
    position: relative;
    overflow: hidden;
    flex-shrink: 0;
    object-fit: contain;
    transition: transform 0.2s ease;
}
.nav-item:hover .nav-icon {
    transform: scale(1.15) rotate(25deg);
}

/* Each icon gets its own holographic gradient */
.icon-obsolence {
    background: linear-gradient(
        135deg,
        #8b5cf6 0%,
        #c084fc 20%,
        #818cf8 35%,
        #6366f1 50%,
        #a78bfa 65%,
        #7c3aed 80%,
        #4f46e5 100%
    );
    box-shadow:
        inset 0 0 10px rgba(255, 255, 255, 0.3),
        0 2px 8px rgba(0, 0, 0, 0.3);
}
.icon-obsolence::after {
    content: "✦";
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--fs-5);
    color: rgba(255, 255, 255, 0.9);
    text-shadow: 0 0 6px #c084fc;
}

.icon-reflections {
    background: radial-gradient(
        circle at 40% 35%,
        #a5f3fc 0%,
        #67e8f9 20%,
        #22d3ee 40%,
        #06b6d4 55%,
        #0ea5e9 70%,
        #38bdf8 85%,
        #7dd3fc 100%
    );
    box-shadow:
        inset 0 0 12px rgba(255, 255, 255, 0.4),
        0 2px 8px rgba(0, 0, 0, 0.2);
}
.icon-reflections::after {
    content: "☺";
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--fs-6);
    color: rgba(255, 255, 255, 0.95);
}

.icon-readups {
    background: linear-gradient(
        160deg,
        #fda4af 0%,
        #fb7185 20%,
        #f43f5e 35%,
        #e879a0 50%,
        #d946ef 65%,
        #a855f7 80%,
        #818cf8 100%
    );
    box-shadow:
        inset 0 0 10px rgba(255, 255, 255, 0.3),
        0 2px 8px rgba(0, 0, 0, 0.25);
}
.icon-readups::after {
    content: "✿";
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--fs-5);
    color: rgba(255, 255, 255, 0.9);
}

.icon-credits {
    background: radial-gradient(
        circle at 50% 40%,
        #bfdbfe 0%,
        #93c5fd 25%,
        #60a5fa 45%,
        #3b82f6 60%,
        #818cf8 75%,
        #a5b4fc 90%,
        #c7d2fe 100%
    );
    box-shadow:
        inset 0 0 10px rgba(255, 255, 255, 0.4),
        0 2px 8px rgba(0, 0, 0, 0.2);
}
.icon-credits::after {
    content: "✉";
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--fs-4);
    color: rgba(255, 255, 255, 0.9);
}

.nav-label {
    font-family: "FreePixel", "W95Fa", monospace;
    font-size: var(--fs-6);
    color: var(--ink);
    line-height: 1.2;
    font-weight: bold;
}

/* ── CONTENT AREA ── */
.content-area {
    flex: 1;
    background: var(--video-bg);
    position: relative;
    min-height: 640px;
    overflow: hidden;
}

/* Slim always-visible scrollbar so the long panels read as scrollable.
   Styling ::-webkit-scrollbar opts WebKit out of macOS overlay scrollbars,
   which auto-hide. Setting scrollbar-width/-color here instead would make
   Chrome ignore these rules and keep the hiding overlay bar, so the
   standard properties are scoped to engines without the pseudo-element. */
.content-area::-webkit-scrollbar {
    width: var(--sp-3);
}
.content-area::-webkit-scrollbar-track {
    background: transparent;
}
.content-area::-webkit-scrollbar-thumb {
    background: var(--page-bg);
}
.content-area::-webkit-scrollbar-thumb:hover {
    background: var(--ink);
}

@supports not selector(::-webkit-scrollbar) {
    .content-area {
        scrollbar-width: thin;
        scrollbar-color: var(--page-bg) transparent;
    }
}

/* Sections */
.section {
    display: none;
    width: 100%;
    height: 100%;
}
.section.active {
    display: flex;
    flex-direction: column;
}

/* Enter Obsolence — video */
#section-obsolence {
    background: var(--video-bg);
    align-items: center;
    justify-content: flex-start;
    padding: var(--sp-8);
    min-height: 640px;
}

.video-placeholder {
    width: 100%;
    max-width: 860px;
    aspect-ratio: 16/9;
    background: linear-gradient(
        135deg,
        var(--video-bg) 0%,
        var(--video-bg-mid) 30%,
        var(--page-bg) 60%,
        var(--video-bg) 100%
    );
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.video-placeholder::before {
    content: "";
    position: absolute;
    inset: 0;
    background: radial-gradient(
        ellipse at 60% 70%,
        rgba(255, 180, 220, 0.8) 0%,
        rgba(200, 100, 255, 0.3) 60%,
        transparent 80%
    );
}

.video-label {
    font-family: "W95Fa", monospace;
    font-size: var(--fs-2);
    color: rgba(0, 0, 0, 0.5);
    letter-spacing: 0.1em;
    text-transform: uppercase;
    z-index: 1;
    text-align: center;
}

/* Actual video element (shown when src present) */
.content-video {
    width: 100%;
    max-width: 860px;
    aspect-ratio: 16/9;
    object-fit: cover;
    display: block;
}

/* Intro copy beneath the loop — matches .section-body sizing */
.intro-text {
    width: 100%;
    max-width: 860px;
    margin-top: var(--sp-7);
    font-family: "FreePixel", "W95Fa", monospace;
    font-size: var(--fs-6);
    color: var(--ink);
    line-height: 1.4;
}

.note-tag {
    font-family: "W95Fa", monospace;
    font-size: var(--fs-1);
    color: rgba(0, 0, 0, 0.45);
    margin-top: var(--sp-4);
    letter-spacing: 0.05em;
}

/* Other sections */
#section-reflections,
#section-readups,
#section-credits {
    padding: var(--sp-9);
    background: var(--video-bg);
    min-height: 640px;
}

.section-heading {
    font-family: "CursedGothic", serif;
    font-size: var(--fs-7);
    color: var(--ink);
    margin-bottom: var(--sp-6);
}

.section-body {
    font-family: "FreePixel", "W95Fa", monospace;
    font-size: var(--fs-6);
    color: var(--ink);
    line-height: 1.4;
    width: 100%;
    max-width: none;
    background: rgba(255, 255, 255, 0.3);
    padding: var(--sp-8);
}
.section-body p {
    margin-bottom: var(--sp-5);
}
.section-body p:last-child {
    margin-bottom: 0;
}
.section-image {
    display: block;
    width: 100%;
    height: auto;
    margin: var(--sp-7) 0;
    border: 2px solid var(--ink);
}
.section-body a {
    color: var(--ink);
    text-decoration: underline;
}
.section-body a:hover {
    background: rgba(255, 255, 255, 0.5);
}
.section-body .credits-heading {
    margin-top: var(--sp-7);
}
.section-body .reflection-coda {
    margin-top: var(--sp-7);
    font-style: italic;
    letter-spacing: 0.04em;
    line-height: 1.55;
}

/* ── BACK LINK ── */
.back-link {
    display: block;
    width: fit-content;
    margin-inline: auto;
    padding: var(--sp-3) var(--sp-4);
    font-family: "FreePixel", "W95Fa", monospace;
    font-size: var(--fs-6);
    color: var(--ink);
    text-decoration: underline;
}
.back-link:hover {
    background: rgba(255, 255, 255, 0.5);
}

@media (min-width: 761px) {
    body {
        height: 100vh;
        overflow: hidden;
    }

    .page {
        height: calc(100vh - var(--sp-8) - var(--sp-8));
        display: grid;
        grid-template-rows: auto minmax(0, 1fr);
    }

    /* Two columns: the nav stack with the home link directly beneath it,
       and the content panel spanning both rows so it keeps full height
       and never overlaps the link. */
    .main-layout {
        display: grid;
        grid-template-columns: 230px minmax(0, 1fr);
        grid-template-rows: auto minmax(0, 1fr);
    }

    .left-nav {
        grid-column: 1;
        grid-row: 1;
    }

    .back-link {
        grid-column: 1;
        grid-row: 2;
        align-self: end;
        justify-self: start;
        margin-inline: 0;
    }

    .content-area {
        grid-column: 2;
        grid-row: 1 / -1;
    }

    .title-bar,
    .left-nav {
        position: relative;
        z-index: 2;
    }

    .content-area {
        height: 100%;
        min-height: 0;
        overflow-x: hidden;
        overflow-y: auto;
        /* Reserve the scrollbar gutter so switching to a section that
           doesn't overflow doesn't shift the content sideways. */
        scrollbar-gutter: stable;
    }

    .section {
        height: auto;
        min-height: 100%;
    }

    #section-obsolence,
    #section-reflections,
    #section-readups,
    #section-credits {
        min-height: 100%;
    }
}

@media (max-width: 760px) {
    body {
        padding: var(--sp-5);
    }

    .main-layout {
        flex-direction: column;
    }

    .left-nav {
        width: 100%;
        flex-direction: row;
        flex-wrap: nowrap;
        padding: 0 0 var(--sp-5);
    }

    /* Four equal columns across one row. The first item is wrapped in an
       <a>, so the flex children are <a> + three .nav-item divs — size the
       nav's direct children rather than .nav-item itself. */
    .left-nav > * {
        flex: 1 1 0;
        min-width: 0;
    }

    .nav-item {
        width: auto;
        align-items: center;
        text-align: center;
        padding: var(--sp-1);
    }

    .nav-icon {
        width: 100%;
        max-width: 64px;
        height: auto;
        aspect-ratio: 128 / 116;
    }

    .nav-label {
        font-size: var(--fs-1);
    }

    .section-body,
    .intro-text {
        font-size: var(--fs-3);
    }

    .back-link {
        font-size: var(--fs-3);
    }

    .content-area,
    #section-obsolence,
    #section-reflections,
    #section-readups,
    #section-credits {
        min-height: 520px;
    }

    #section-obsolence,
    #section-reflections,
    #section-readups,
    #section-credits {
        padding: var(--sp-6);
    }

    .section-body {
        padding: var(--sp-6);
    }
}
