/* ============================================================
   THE LUDOS INITIATIVE : FALL 2026
   Ludos design system foundation (fonts, tokens, reset)
   ============================================================ */

@font-face {
    font-family: 'Geom Graphic';
    src: url('assets/fonts/geom-graphic-light.otf') format('opentype');
    font-weight: 300;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'Geom Graphic';
    src: url('assets/fonts/geom-graphic-bold.otf') format('opentype');
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'Overpass';
    src: url('assets/fonts/overpass-var.woff2') format('woff2');
    font-weight: 300 600;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'Space Mono';
    src: url('assets/fonts/space-mono-400.woff2') format('woff2');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

:root {
    --bg-dark: #101413;
    --bg-section: #181b19;
    --bg-card: #1e2220;
    --accent-dark: #441e1f;
    --accent: #FF1516;
    --text-primary: #FAFAED;
    --text-secondary: #b8b8a8;
    --text-dim: #6a6a5f;
    --border: #2d302e;

    --font-title: 'Geom Graphic', sans-serif;
    --font-body: 'Overpass', sans-serif;
    --font-ui: 'Space Mono', monospace;

    --rail-w: 64px;
    --ease-out: cubic-bezier(.16,.84,.36,1);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
    background: var(--bg-dark);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-weight: 400;
    font-size: 16px;
    letter-spacing: 0.01em;
    line-height: 1.75;
    overflow: hidden;
    height: 100vh;
}

/* ============================================================
   ATMOSPHERE
   ============================================================ */
.grain, .scanlines {
    position: fixed; inset: 0;
    pointer-events: none;
    z-index: 9000;
}
.grain {
    opacity: 0.07; mix-blend-mode: overlay;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)'/%3E%3C/svg%3E");
    background-repeat: repeat;
}
.scanlines {
    opacity: 0.5;
    background: repeating-linear-gradient(
        to bottom,
        rgba(0,0,0,0) 0px,
        rgba(0,0,0,0) 1px,
        rgba(0,0,0,0.25) 1px,
        rgba(0,0,0,0.25) 2px
    );
    z-index: 8999;
}
.vignette {
    position: fixed; inset: 0; pointer-events: none; z-index: 1;
    background:
        radial-gradient(120% 90% at 82% 8%, rgba(255,21,22,0.06), transparent 55%),
        radial-gradient(140% 120% at 50% 120%, rgba(0,0,0,0.55), transparent 60%);
}
.bottom-scrim {
    position: fixed; left: 0; right: 0; bottom: 0; height: 4.5rem;
    background: linear-gradient(to bottom, rgba(16,20,19,0), rgba(16,20,19,0.9) 62%);
    z-index: 300; pointer-events: none;
}

/* ============================================================
   STAGE + SLIDES
   ============================================================ */
#stage {
    position: relative;
    width: 100vw; height: 100vh;
    overflow: hidden;
}

.slide {
    position: absolute; inset: 0;
    display: flex; flex-direction: column;
    justify-content: safe center;
    overflow-y: auto; overflow-x: hidden;
    padding: 72px 88px 96px calc(var(--rail-w) + 72px);
    opacity: 0;
    visibility: hidden;
    transform: translateY(24px);
    transition: opacity .55s ease, transform .55s var(--ease-out);
    z-index: 2;
}
.slide.active {
    opacity: 1; visibility: visible; transform: none;
    z-index: 3;
}
.slide-inner { width: 100%; max-width: 900px; margin: 0 auto; position: relative; z-index: 4; }

/* stagger children of the active slide */
.slide.active [data-rise] {
    animation: rise .6s var(--ease-out) both;
}
.slide.active [data-rise="1"] { animation-delay: .06s; }
.slide.active [data-rise="2"] { animation-delay: .14s; }
.slide.active [data-rise="3"] { animation-delay: .22s; }
.slide.active [data-rise="4"] { animation-delay: .30s; }
.slide.active [data-rise="5"] { animation-delay: .38s; }
@keyframes rise {
    from { opacity: 0; transform: translateY(16px); }
    to   { opacity: 1; transform: none; }
}

/* 3D scene mount: full-bleed behind slide content */
.scene-mount {
    position: absolute; inset: 0; z-index: 2;
    pointer-events: none;
}
.scene-mount canvas { display: block; width: 100%; height: 100%; }
/* right-half mount: geometry can never reach the text column */
.scene-mount.right-half { left: 46%; }

/* ---- shared meta row: mono tag + glyph ---- */
.meta-row {
    display: flex; align-items: center; justify-content: space-between;
    gap: 24px; margin-bottom: 40px;
}
.tag {
    font-family: var(--font-ui);
    font-size: 12px; font-weight: 400;
    letter-spacing: 0.28em; text-transform: uppercase;
    color: var(--text-dim);
    display: flex; align-items: center; gap: 14px;
}
.tag .tick { color: var(--accent); }
.glyph {
    width: 56px; height: 56px; flex: none;
    color: var(--accent);
}
.glyph svg { width: 100%; height: 100%; display: block; }
.glyph svg [data-draw] {
    stroke-dasharray: 240; stroke-dashoffset: 240;
}
.slide.active .glyph svg [data-draw] {
    animation: draw 1s ease forwards .25s;
}
@keyframes draw { to { stroke-dashoffset: 0; } }

/* small inline glyph for chips/rows */
.glyph-sm {
    width: 22px; height: 22px; flex: none; color: var(--accent);
}
.glyph-sm svg { width: 100%; height: 100%; display: block; }

/* ============================================================
   TITLE SLIDE
   ============================================================ */
.title-slide .slide-inner { max-width: 1000px; }
.cover-logo-shift {
    /* the script strokes lean right; shift left by a quarter of the logo
       width to correct the optical misalignment against the column.
       inline-block so the % refers to the logo, not the column; the
       wrapper exists because the rise entrance animation owns transform
       on the img itself */
    display: inline-block;
    transform: translateX(-25%);
}
.cover-logo {
    width: clamp(300px, 40vw, 620px);
    height: auto;
    margin-bottom: 30px;
    display: block;
    filter: drop-shadow(0 0 40px rgba(255,21,22,0.12));
}
.eyebrow {
    font-family: var(--font-title);
    font-size: clamp(12px, 1.6vw, 13px);
    font-weight: 700; letter-spacing: 0.32em; text-transform: uppercase;
    color: var(--accent);
    margin-bottom: 26px;
}
.title-slide h1 {
    font-family: var(--font-title);
    font-weight: 700;
    font-size: clamp(44px, 9vw, 108px);
    line-height: 0.94;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-primary);
    margin-bottom: 28px;
    text-shadow: 0 0 60px rgba(255,21,22,0.14);
}
.title-slide h1 .accent { color: var(--accent); text-shadow: 0 0 50px rgba(255,21,22,0.4); }
.title-slide .subtitle {
    font-family: var(--font-title);
    font-weight: 300;
    font-size: clamp(16px, 2.4vw, 26px);
    letter-spacing: 0.22em; text-transform: uppercase;
    color: var(--text-secondary);
    margin-bottom: 48px;
}
.creed {
    font-family: var(--font-ui);
    font-size: 12px; letter-spacing: 0.18em; text-transform: uppercase;
    color: var(--text-dim);
    border-left: 2px solid var(--accent);
    padding-left: 18px;
    line-height: 2;
    max-width: 640px;
}
.creed b { color: var(--text-secondary); font-weight: 400; }

/* ============================================================
   STATEMENT SLIDE (one big line + supporting copy)
   ============================================================ */
.state-slide .big {
    font-family: var(--font-title);
    font-weight: 700;
    font-size: clamp(26px, 4.6vw, 52px);
    line-height: 1.06;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    color: var(--text-primary);
    margin-bottom: 30px;
    max-width: 840px;
}
.state-slide .big .accent { color: var(--accent); }
/* red emphasis spans inside body copy must beat the strong color rule */
.state-slide .body .accent, .state-slide .lead .accent { color: var(--accent); }
/* when the accent wraps the strong, the strong inherits the red */
.state-slide .body .accent strong, .state-slide .lead .accent strong { color: inherit; }
/* fraction marker: "1/2" smaller and white beside a red title */
.state-slide .big .frac {
    font-size: 0.42em; color: var(--text-primary);
    letter-spacing: 0.08em; vertical-align: 0.28em;
}
/* LudOS / NixOS casing: "Lud" smaller and white, "OS" full-size red */
.state-slide .big .lud { font-size: 0.62em; }
.card h4 .lud { font-size: 0.78em; }
.card h4 .accent { color: var(--accent); }
.state-slide .lead {
    font-family: var(--font-body);
    font-size: clamp(18px, 2.2vw, 24px);
    line-height: 1.45;
    color: var(--text-primary);
    max-width: 720px;
    margin-bottom: 18px;
    font-weight: 500;
}
.state-slide .body {
    font-size: clamp(15px, 1.6vw, 17px);
    line-height: 1.7;
    color: var(--text-secondary);
    max-width: 680px;
}
.state-slide .body + .body { margin-top: 14px; }
.state-slide .body strong { color: var(--text-primary); font-weight: 600; }
.state-slide .dim-note {
    margin-top: 26px;
    font-family: var(--font-ui);
    font-size: 12px; letter-spacing: 0.14em; text-transform: uppercase;
    color: var(--text-dim);
    max-width: 640px; line-height: 2;
}
.state-slide .dim-note b { color: var(--accent); font-weight: 400; }

/* ============================================================
   CHIP LIST (what this isn't / examples)
   ============================================================ */
.chips { display: flex; flex-wrap: wrap; gap: 10px 12px; max-width: 780px; }
.chips span {
    font-family: var(--font-ui);
    font-size: 12px; letter-spacing: 0.16em; text-transform: uppercase;
    color: var(--text-dim);
    border: 1px solid var(--border);
    padding: 9px 16px;
    display: inline-flex; align-items: center; gap: 10px;
}
.chips span b { color: var(--accent); font-weight: 700; }
.chips span.neg b { color: var(--text-secondary); }
.chips-labeled { display: flex; flex-direction: column; gap: 10px; max-width: 720px; }
.chip-row {
    display: flex; align-items: center; gap: 18px;
    border: 1px solid var(--border);
    background: var(--bg-card);
    padding: 14px 20px;
}
.chip-row .cr-x {
    font-family: var(--font-title); font-weight: 700;
    font-size: 15px; color: var(--accent); letter-spacing: 0.1em;
    flex: none;
}
.chip-row .cr-t {
    font-size: clamp(14px, 1.7vw, 16px); color: var(--text-secondary);
}
.chip-row .cr-t b { color: var(--text-primary); font-weight: 600; }

/* ============================================================
   MANTRA DIVIDER
   ============================================================ */
.mantra-slide { align-items: center; text-align: center; }
.mantra-slide .slide-inner {
    display: flex; flex-direction: column; align-items: center;
}
.mantra-mark {
    width: clamp(56px, 8vw, 84px); height: auto; margin-bottom: 34px;
}
.mantra-line {
    font-family: var(--font-ui);
    font-size: clamp(13px, 1.8vw, 17px);
    letter-spacing: 0.42em; text-transform: lowercase;
    color: var(--text-secondary);
}
.mantra-line b { color: var(--accent); font-weight: 400; }
.mantra-epilogue {
    margin-top: 32px;
    font-family: var(--font-ui);
    font-size: 11px; letter-spacing: 0.3em; text-transform: uppercase;
    color: var(--text-dim);
}

/* ============================================================
   SPLIT LAYOUT (labels left / 3D right)
   ============================================================ */
.split { display: grid; grid-template-columns: minmax(300px, 420px) 1fr; gap: 48px; align-items: center; }
.split-labels { display: flex; flex-direction: column; gap: 2px; }
.split-label {
    border-left: 2px solid var(--border);
    padding: 9px 0 9px 18px;
    transition: border-color .3s;
}
.split-label .sl-k {
    font-family: var(--font-ui); font-size: 11px; letter-spacing: 0.24em;
    text-transform: uppercase; color: var(--text-dim);
}
.split-label .sl-t {
    font-family: var(--font-title); font-weight: 700;
    font-size: clamp(15px, 1.9vw, 20px); letter-spacing: 0.08em; text-transform: uppercase;
    color: var(--text-primary);
    white-space: nowrap;
}
.split-label.final { border-left-color: var(--accent); }
.split-label.final .sl-t { color: var(--accent); }
.sl-arrow {
    display: flex; align-items: center; padding: 0 0 0 20px;
    color: var(--accent);
}
.sl-arrow svg { width: 10px; height: 10px; display: block; }
.split-stage { position: relative; height: clamp(225px, 35vh, 330px); }
.split-stage .scene-mount { position: absolute; inset: 0; }
.state-slide .split { margin-top: 0; }
.state-slide .split-meta { margin-bottom: 34px; }
.state-slide .split-labels .split-label { padding: 8px 0 8px 20px; }

/* ============================================================
   CARD GRID (principles / ship list)
   ============================================================ */
.card-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 1px; background: var(--border); border: 1px solid var(--border); max-width: 860px; }
.card { background: var(--bg-card); padding: 18px 20px; }
.card h4 {
    font-family: var(--font-title);
    font-size: 13px; font-weight: 700; letter-spacing: 0.2em; text-transform: uppercase;
    color: var(--text-primary);
    margin-bottom: 8px;
    display: flex; align-items: center; gap: 12px;
}
.card h4 .glyph-sm { color: var(--accent); }
.card p { font-size: 13.5px; line-height: 1.6; color: var(--text-secondary); }
.card-grid .span-2 { grid-column: 1 / -1; }

/* ============================================================
   PILLAR GRID (seven pillars, glyph + name + gloss)
   ============================================================ */
.pillar-grid { display: grid; grid-template-columns: repeat(7, minmax(0,1fr)); gap: 1px; background: var(--border); border: 1px solid var(--border); max-width: 980px; }
.pillar {
    background: var(--bg-card); padding: 20px 12px 18px;
    display: flex; flex-direction: column; align-items: center; text-align: center; gap: 10px;
}
.pillar .glyph { width: 40px; height: 40px; }
.pillar .p-name {
    font-family: var(--font-title); font-weight: 700;
    font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase;
    color: var(--text-primary);
}
.pillar .p-gloss {
    font-family: var(--font-ui); font-size: 11px; letter-spacing: 0.1em;
    text-transform: uppercase; color: var(--text-dim); line-height: 1.7;
}

/* ============================================================
   LEVELS (ascending steps)
   ============================================================ */
.steps { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 12px; align-items: start; max-width: 900px; }
.step { border: 1px solid var(--border); background: var(--bg-card); padding: 18px 16px; position: relative; height: 320px; overflow: hidden; }
.step .st-n {
    font-family: var(--font-title); font-weight: 700;
    font-size: clamp(22px, 3vw, 32px); line-height: 1;
    color: transparent; -webkit-text-stroke: 1px var(--text-dim);
    margin-bottom: 10px;
}
.step .st-t {
    font-family: var(--font-title); font-weight: 700;
    font-size: 14px; letter-spacing: 0.16em; text-transform: uppercase;
    color: var(--text-primary); margin-bottom: 6px;
}
.step .st-d { font-size: 13px; line-height: 1.55; color: var(--text-secondary); }
/* ascending staircase: exact even rises, equal-height cards */
.step.s1 { margin-top: 78px; }
.step.s2 { margin-top: 52px; }
.step.s3 { margin-top: 26px; }
.step.s4 { margin-top: 0; border-color: var(--accent); background: var(--accent-dark); }
.step.s4 .st-n { -webkit-text-stroke-color: var(--accent); }
.step.s4 .st-t { color: var(--accent); }
.step .st-bar { position: absolute; left: 0; bottom: 0; height: 2px; background: var(--accent); width: 100%; transform: scaleX(0); transform-origin: left; }
.slide.active .step .st-bar { animation: sweep 0.9s var(--ease-out) forwards; }
.slide.active .step.s1 .st-bar { animation-delay: .2s; }
.slide.active .step.s2 .st-bar { animation-delay: .32s; }
.slide.active .step.s3 .st-bar { animation-delay: .44s; }
.slide.active .step.s4 .st-bar { animation-delay: .56s; }
@keyframes sweep { to { transform: scaleX(1); } }

/* ============================================================
   CLOSING SLIDE
   ============================================================ */
.close-slide .big {
    font-family: var(--font-title); font-weight: 700;
    font-size: clamp(34px, 7vw, 80px); line-height: 0.96; letter-spacing: 0.03em;
    text-transform: uppercase; color: var(--text-primary); margin-bottom: 30px;
    text-shadow: 0 0 60px rgba(255,21,22,0.18);
}
.close-slide .big .accent { color: var(--accent); }
.close-slide .body { font-size: clamp(15px, 1.8vw, 18px); color: var(--text-secondary); max-width: 700px; margin-bottom: 30px; }
.close-slide .body strong { color: var(--text-primary); font-weight: 600; }

/* ============================================================
   PROGRESS RAIL (left)
   ============================================================ */
#rail {
    position: fixed; top: 0; left: 0; height: 100vh; width: var(--rail-w);
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 10px; z-index: 400;
    border-right: 1px solid var(--border);
    background: linear-gradient(to right, rgba(0,0,0,0.35), transparent);
}
.rail-dot {
    position: relative; width: 22px; height: 12px; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    background: none; border: none; padding: 0;
}
.rail-dot::before {
    content: ''; width: 14px; height: 2px; background: var(--text-dim);
    transition: background .2s, width .2s;
}
.rail-dot:hover::before { background: var(--text-secondary); width: 20px; }
.rail-dot.on::before { background: var(--accent); width: 22px; box-shadow: 0 0 10px rgba(255,21,22,0.6); }
.rail-dot .rail-label {
    position: absolute; left: 30px; white-space: nowrap;
    font-family: var(--font-ui); font-size: 10px; letter-spacing: 0.14em; text-transform: uppercase;
    color: var(--text-secondary); background: var(--bg-card); border: 1px solid var(--border);
    padding: 4px 9px; opacity: 0; transform: translateX(-6px); pointer-events: none;
    transition: opacity .18s, transform .18s;
}
.rail-dot:hover .rail-label { opacity: 1; transform: none; }

/* ============================================================
   CONTROLS + COUNTER + HINT
   ============================================================ */
#controls {
    position: fixed; right: 40px; bottom: 34px; z-index: 500;
    display: flex; align-items: center; gap: 14px;
}
.ctrl {
    font-family: var(--font-title); font-weight: 700;
    background: transparent; border: 1px solid var(--border);
    color: var(--text-primary); width: 46px; height: 46px;
    cursor: pointer; font-size: 18px; line-height: 1;
    display: flex; align-items: center; justify-content: center;
    transition: background .2s, color .2s, border-color .2s;
}
.ctrl:hover { border-color: var(--accent); color: var(--accent); }
.ctrl:disabled { opacity: 0.3; cursor: default; border-color: var(--border); color: var(--text-dim); }
#counter {
    font-family: var(--font-ui); font-size: 12px; letter-spacing: 0.2em; color: var(--text-dim);
    min-width: 72px; text-align: center;
}
#counter b { color: var(--accent); font-weight: 400; }

#hint {
    position: fixed; left: calc(var(--rail-w) + 40px); bottom: 38px; z-index: 500;
    font-family: var(--font-ui); font-size: 11px; letter-spacing: 0.18em; text-transform: uppercase;
    color: var(--text-dim);
}
#hint kbd {
    font-family: var(--font-ui); color: var(--text-secondary);
    border: 1px solid var(--border); padding: 2px 7px; margin: 0 2px;
}
.hint-mobile { display: none; }

/* ============================================================
   INTRO / PROGRESS BAR (top)
   ============================================================ */
#topbar {
    position: fixed; top: 0; left: 0; height: 2px; z-index: 600;
    background: var(--accent); width: 0; box-shadow: 0 0 12px rgba(255,21,22,0.6);
    transition: width .45s var(--ease-out);
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 768px) {
    :root { --rail-w: 0px; }
    #rail { display: none; }
    .slide { padding: 72px 22px 150px; }
    .bottom-scrim { height: 7.5rem; background: linear-gradient(to bottom, rgba(16,20,19,0), rgba(16,20,19,0.96) 58%); }
    .title-slide .eyebrow { letter-spacing: 0.24em; }
    .state-slide .big { font-size: clamp(24px, 4.6vw, 52px); }
    .mantra-line { letter-spacing: 0.22em; font-size: 12px; }
    /* the logo nearly fills the mobile column: a quarter-width shift would
       clip it, so the nudge is proportional to available room */
    .cover-logo { width: min(74vw, 620px); }
    .cover-logo-shift { transform: translateX(-6%); }
    .meta-row { margin-bottom: 26px; align-items: flex-start; }
    .meta-row .glyph { width: 30px; height: 30px; }
    .tag { font-size: 11px; letter-spacing: 0.2em; line-height: 2; }
    .tag > span:last-child { display: none; }
    .ctrl { background: rgba(16, 20, 19, 0.92); }
    .scene-mount { top: auto; height: 36%; }
    .scene-mount.right-half { left: 0; }
    .scene-mount.full { inset: 0; height: auto; }
    .creed { letter-spacing: 0.13em; font-size: 11px; }
    .card-grid { grid-template-columns: 1fr; }
    .pillar-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
    .steps { grid-template-columns: 1fr; align-items: stretch; }
    .step.s1, .step.s2, .step.s3, .step.s4 { margin-top: 0; height: auto; overflow: visible; }
    .split { grid-template-columns: 1fr; gap: 20px; }
    .split-stage { height: 300px; }
    #hint {
        display: block; left: 16px; bottom: 24px; opacity: 0.85;
        background: var(--bg-dark); border: 1px solid var(--border);
        padding: 4px 9px; font-size: 10px;
    }
    .hint-desktop { display: none; }
    .hint-mobile { display: inline; }
    #controls { right: 20px; bottom: 20px; }
    .mantra-epilogue { letter-spacing: 0.2em; font-size: 10px; }
    #controls { right: 20px; bottom: 20px; }
}

/* reduced motion */
@media (prefers-reduced-motion: reduce) {
    * { animation-duration: .001s !important; transition-duration: .12s !important; }
    .slide { transition: opacity .2s ease; transform: none; }
}
