/*
 * keystro.ke
 * Copyright (C) 2026 Mike O'Riley
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as
 * published by the Free Software Foundation, either version 3 of the
 * License, or (at your option) any later version.
 */

/**
 * ============================================================================
 * Lesson Hall - curriculum picker
 * ============================================================================
 *
 * Presentation for lesson-hall.html, Lesson Hall's entry point: a motherboard
 * trace path connecting one "chip" node per lesson, replacing the old direct
 * jump straight into lesson one. Keeps the same CRT-monitor bezel as
 * lesson.html and the main menu, duplicated here rather than shared per this
 * project's established per-page convention. No boot sequence - this isn't a
 * landing page.
 *
 * The path is a new sub-metaphor (motherboard/circuitry) rather than a
 * reskin of the main menu's Prodigy-style room-tile grid, while staying in
 * the same "old computer hardware" world (CRT bezel, keystro.ke 9000
 * branding).
 * ============================================================================
 */

:root {
    --ground: #070914;
    --ground-deep: #04050c;
    --bezel: #14131c;
    --bezel-hi: #24222e;

    --ink: #f3f7ff;
    --ink-dim: #8b93c2;

    --cyan: #7febff;
    --cyan-rgb: 127, 235, 255;
    --violet: #8274ff;
    --violet-rgb: 130, 116, 255;
    --magenta: #ff5ce0;
    --magenta-rgb: 255, 92, 224;
    --amber: #ffcb57;
    --amber-rgb: 255, 203, 87;
    --gold: #ffe778;
    --gold-rgb: 255, 231, 120;

    --mono: ui-monospace, SFMono-Regular, "SF Mono", Consolas, "Liberation Mono", Menlo, monospace;
}

* {
    box-sizing: border-box;
}

html,
body {
    height: 100%;
    margin: 0;
}

body {
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    overscroll-behavior: none;
    background: radial-gradient(circle at 50% 20%, #14131c, var(--ground-deep) 70%);
    color: var(--ink);
    font-family: var(--mono);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: clamp(6px, 2vmin, 24px);
}

.skip-link {
    position: absolute;
    top: -100px;
    left: 1rem;
    z-index: 100;
    padding: 0.75rem 1.25rem;
    background: var(--ground);
    color: var(--ink);
    border: 2px solid var(--cyan);
    border-radius: 4px;
    font-family: var(--mono);
    font-weight: 700;
    text-decoration: none;
    transition: top 150ms ease;
}

.skip-link:focus {
    top: 1rem;
}

/* ================= CRT MONITOR BEZEL ================= */

.monitor {
    position: relative;
    width: 100%;
    height: 100%;
    max-width: 2400px;
    max-height: 1400px;
    background: linear-gradient(155deg, var(--bezel-hi), var(--bezel) 40%, #0c0b12);
    border-radius: clamp(10px, 2.4vmin, 28px);
    padding: clamp(8px, 1.6vmin, 22px);
    box-shadow:
        0 30px 70px rgba(0, 0, 0, 0.6),
        inset 0 2px 0 rgba(255, 255, 255, 0.05),
        inset 0 -6px 14px rgba(0, 0, 0, 0.5);
}

.monitor::after {
    content: "keystro.ke 9000";
    position: absolute;
    left: 50%;
    bottom: clamp(2px, 0.8vmin, 8px);
    transform: translateX(-50%);
    font-size: clamp(0.45rem, 1.1vmin, 0.6rem);
    letter-spacing: 0.3em;
    color: rgba(243, 247, 255, 0.18);
}

.screen {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
    border-radius: clamp(6px, 1.4vmin, 10px);
    background: var(--ground);
    box-shadow:
        inset 0 0 0 2px rgba(0, 0, 0, 0.6),
        inset 0 0 60px rgba(0, 0, 0, 0.7),
        inset 0 0 120px rgba(var(--cyan-rgb), 0.06);
}

.crt-overlay {
    position: absolute;
    inset: 0;
    z-index: 50;
    pointer-events: none;
    background:
        repeating-linear-gradient(
            to bottom,
            rgba(0, 0, 0, 0) 0px,
            rgba(0, 0, 0, 0.16) 1px,
            rgba(0, 0, 0, 0) 2px
        ),
        radial-gradient(ellipse at center, transparent 55%, rgba(0, 0, 0, 0.55) 100%);
    mix-blend-mode: multiply;
    animation: crt-flicker 6.5s steps(60, end) infinite;
}

@keyframes crt-flicker {
    0%, 96%, 100% { opacity: 0.92; }
    97% { opacity: 0.98; }
    98% { opacity: 0.86; }
}

.screen-content {
    position: relative;
    z-index: 5;
    width: 100%;
    height: 100%;
    min-height: 0;
    display: flex;
    flex-direction: column;
    padding: clamp(8px, 1.6vmin, 20px) clamp(10px, 2vmin, 26px);
}

@media (prefers-reduced-motion: reduce) {
    .crt-overlay { animation: none; }
}

/* ================= HUD STRIP ================= */

.hud {
    display: flex;
    align-items: center;
    gap: clamp(8px, 2.4vmin, 30px);
    flex-wrap: wrap;
    padding-bottom: clamp(8px, 1.8vmin, 18px);
    border-bottom: 2px solid rgba(var(--cyan-rgb), 0.22);
    font-size: clamp(0.7rem, 2vmin, 1.05rem);
}

.brand-mark {
    color: var(--ink);
    font-weight: 700;
    letter-spacing: 0.04em;
    text-decoration: none;
}

.brand-mark:hover,
.brand-mark:focus-visible {
    color: var(--cyan);
    text-decoration: underline;
}

.lesson-label {
    color: var(--ink-dim);
    letter-spacing: 0.12em;
}

.sound-toggle {
    appearance: none;
    /* WCAG 2.5.8 24px minimum target size, held even at the smallest
       end of the vmin-based padding clamp below. */
    min-height: 28px;
    margin-left: auto;
    background: rgba(var(--cyan-rgb), 0.08);
    border: 1px solid rgba(var(--cyan-rgb), 0.4);
    color: var(--cyan);
    font-family: var(--mono);
    font-size: clamp(0.62rem, 1.4vmin, 0.9rem);
    letter-spacing: 0.05em;
    padding: clamp(4px, 0.9vmin, 8px) clamp(8px, 1.4vmin, 14px);
    cursor: pointer;
}

.sound-toggle:hover,
.sound-toggle:focus-visible {
    background: rgba(var(--cyan-rgb), 0.18);
}

/* ================= HALL BANNER ================= */

.hall-banner {
    text-align: center;
    padding: clamp(10px, 3vmin, 24px) 0 clamp(4px, 1.2vmin, 10px);
}

.hall-kicker {
    margin: 0 0 0.4em;
    font-size: clamp(0.62rem, 1.5vmin, 0.85rem);
    letter-spacing: 0.32em;
    text-transform: uppercase;
    color: var(--ink-dim);
}

.hall-title {
    margin: 0;
    font-size: clamp(1.3rem, 4.4vmin, 2.6rem);
    font-weight: 800;
    color: var(--ink);
    text-shadow: 0 0 18px rgba(var(--cyan-rgb), 0.35);
}

/* ================= TRACE PATH ================= */

/* The one deliberately scrollable region on the whole site - the CRT
   screen itself never scrolls (site-wide rule), but this inner lane gets
   its own horizontal overflow so the path never needs redesigning as
   more lessons are added later, the same way .ticker-bar already moves
   horizontally elsewhere on the menu (there via animation, here via real
   user scroll). */
.trace-viewport {
    flex: 1;
    min-height: 0;
    display: flex;
    align-items: center;
}

.trace-lane {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    gap: clamp(28px, 6vmin, 64px);
    padding: clamp(28px, 7vmin, 72px) clamp(16px, 4vmin, 48px);
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: thin;
    scrollbar-color: rgba(var(--cyan-rgb), 0.4) transparent;
}

.trace-svg {
    position: absolute;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    overflow: visible;
}

.trace-segment {
    stroke-width: 2;
    stroke: rgba(139, 147, 194, 0.16);
}

.trace-segment.is-lit {
    stroke: rgba(var(--cyan-rgb), 0.7);
    stroke-dasharray: 6 5;
    animation: trace-signal 1.4s linear infinite;
}

@keyframes trace-signal {
    to { stroke-dashoffset: -22; }
}

@media (prefers-reduced-motion: reduce) {
    .trace-segment.is-lit {
        animation: none;
    }
}

.trace-node {
    position: relative;
    z-index: 1;
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: clamp(4px, 1vmin, 8px);
    width: clamp(90px, 13vmin, 148px);
    text-align: center;
    text-decoration: none;
    color: var(--ink);
    font-family: var(--mono);
}

.trace-node.is-offset-up {
    transform: translateY(clamp(-26px, -5.5vmin, -14px));
}

.trace-node.is-offset-down {
    transform: translateY(clamp(14px, 5.5vmin, 26px));
}

.node-chip {
    position: relative;
    display: grid;
    place-items: center;
    width: clamp(46px, 9vmin, 78px);
    height: clamp(46px, 9vmin, 78px);
    border-radius: clamp(4px, 1vmin, 8px);
    background: rgba(255, 255, 255, 0.03);
    transition: box-shadow 160ms ease, border-color 160ms ease, background 160ms ease;
}

/* A small top-center notch, like an IC package's pin-1 orientation mark. */
.node-chip::before {
    content: "";
    position: absolute;
    top: -1px;
    left: 50%;
    width: clamp(10px, 2vmin, 16px);
    height: clamp(5px, 1vmin, 8px);
    transform: translateX(-50%);
    border-radius: 0 0 50% 50%;
    background: var(--ground);
}

.node-index {
    font-size: clamp(0.7rem, 1.6vmin, 1rem);
    font-weight: 700;
    letter-spacing: 0.04em;
}

.node-label {
    font-size: clamp(0.6rem, 1.3vmin, 0.85rem);
    line-height: 1.3;
    color: var(--ink-dim);
}

.node-status-note {
    font-size: clamp(0.52rem, 1.1vmin, 0.7rem);
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

/* -------- locked -------- */

.trace-node.is-locked {
    cursor: default;
}

.trace-node.is-locked .node-chip {
    border: 1px dashed rgba(243, 247, 255, 0.18);
}

.trace-node.is-locked .node-chip::before {
    background: transparent;
    border: 1px dashed rgba(243, 247, 255, 0.18);
    border-top: none;
}

/* Only the chip's decorative chrome (border/notch) dims for locked
   nodes - the label is the one thing a player most needs to read to
   know what's coming, so it stays at the same full-strength --ink-dim
   every other page already uses for de-emphasized-but-legible text
   (6.66:1 against --ground), not a further-reduced, sub-3:1 opacity. */
.trace-node.is-locked .node-index,
.trace-node.is-locked .node-label,
.trace-node.is-locked .node-status-note {
    color: var(--ink-dim);
}

/* -------- available (built, not completed) -------- */

.trace-node.is-available .node-chip {
    border: 1px solid rgba(var(--cyan-rgb), 0.6);
    box-shadow: 0 0 0.9rem rgba(var(--cyan-rgb), 0.28);
    animation: node-ready-pulse 2.2s ease-in-out infinite;
}

.trace-node.is-available .node-chip::before {
    background: var(--cyan);
}

.trace-node.is-available .node-index {
    color: var(--cyan);
}

@keyframes node-ready-pulse {
    0%, 100% { box-shadow: 0 0 0.9rem rgba(var(--cyan-rgb), 0.28); }
    50% { box-shadow: 0 0 1.5rem rgba(var(--cyan-rgb), 0.55); }
}

/* -------- completed -------- */

.trace-node.is-completed .node-chip {
    border: 1px solid rgba(var(--cyan-rgb), 0.85);
    background: rgba(var(--cyan-rgb), 0.08);
    box-shadow: 0 0 1.3rem rgba(var(--cyan-rgb), 0.5);
}

.trace-node.is-completed .node-chip::before {
    background: var(--cyan);
}

.trace-node.is-completed .node-index {
    color: var(--cyan);
}

.node-badge {
    position: absolute;
    top: clamp(-10px, -1.6vmin, -6px);
    right: clamp(-10px, -1.6vmin, -6px);
    display: grid;
    place-items: center;
    width: clamp(16px, 3vmin, 22px);
    height: clamp(16px, 3vmin, 22px);
    border-radius: 50%;
    background: rgba(var(--gold-rgb), 0.2);
    border: 1px solid rgba(var(--gold-rgb), 0.85);
    color: var(--gold);
    font-size: clamp(0.55rem, 1.2vmin, 0.75rem);
    font-weight: 700;
    box-shadow: 0 0 0.5rem rgba(var(--gold-rgb), 0.45);
}

/* -------- interaction -------- */

.trace-node:not(.is-locked):hover .node-chip,
.trace-node:not(.is-locked):focus-visible .node-chip {
    background: rgba(var(--cyan-rgb), 0.12);
}

.trace-node:focus-visible {
    outline: 3px solid var(--ink);
    outline-offset: 4px;
    border-radius: clamp(4px, 1vmin, 8px);
}

/* ================= FOOTER ================= */

.screen-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: clamp(6px, 1.6vmin, 14px);
    padding-top: clamp(4px, 1.2vmin, 10px);
    font-size: clamp(0.6rem, 1.3vmin, 0.85rem);
    color: var(--ink-dim);
}

.screen-footer a {
    color: var(--ink-dim);
    text-decoration: none;
}

.screen-footer a:hover,
.screen-footer a:focus-visible {
    color: var(--cyan);
}

/* Manual override for the Options Terminal "Reduce motion" toggle
   (src/settings.js sets data-motion="reduce" on <html>) - a blanket
   animation/transition kill switch, unlike the hand-tuned
   prefers-reduced-motion blocks above which only target this page's own
   specific animated elements. Lets someone reduce motion on this site
   without changing their OS-wide setting. */
:root[data-motion="reduce"] *,
:root[data-motion="reduce"] *::before,
:root[data-motion="reduce"] *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
}
