/* ============================================================
   THE VEGA METHOD — Ludos design system
   Foundation blocks (fonts, tokens, reset) copied per spec.
   ============================================================ */

/* --- @font-face: vendored from the LudOS deck assets (self-contained) --- */
@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;
}

/* --- Design tokens --- */
:root {
    --bg-dark: #101413;
    --bg-section: #181b19;
    --bg-card: #1e2220;
    --accent-dark: #441e1f;
    --accent: #FF1516;
    --accent-hover: #ff4444;
    --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;
    --font-mono: 'Space Mono', monospace;

    --rail-w: 64px;
}

/* --- Reset --- */
* { 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 OVERLAYS
   ============================================================ */
.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;
}
/* soft red vignette to give the ground depth */
.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%);
}

/* ============================================================
   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;   /* center when it fits, top-align + scroll when it doesn't */
    overflow-y: auto; overflow-x: hidden;
    padding: 72px 88px 88px calc(var(--rail-w) + 72px);
    opacity: 0;
    visibility: hidden;
    transform: translateY(24px);
    transition: opacity .55s ease, transform .55s cubic-bezier(.16,.84,.36,1);
    z-index: 2;
}
.slide.active {
    opacity: 1; visibility: visible; transform: none;
    z-index: 3;
}
.slide.exit-up { transform: translateY(-24px); }

.slide-inner { width: 100%; max-width: 900px; margin: 0 auto; }

/* stagger children of the active slide */
.slide.active [data-rise] {
    animation: rise .6s cubic-bezier(.16,.84,.36,1) 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; }
}

/* ---- 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; } }

/* ============================================================
   DISCIPLINE SLIDE
   ============================================================ */
.disc-head { display: flex; align-items: baseline; gap: 28px; flex-wrap: wrap; }
.disc-num {
    font-family: var(--font-title);
    font-weight: 700;
    font-size: clamp(64px, 11vw, 140px);
    line-height: 0.82;
    color: transparent;
    -webkit-text-stroke: 1.5px var(--text-dim);
    letter-spacing: 0.02em;
}
.disc-name {
    font-family: var(--font-title);
    font-weight: 700;
    font-size: clamp(30px, 6vw, 58px);
    line-height: 0.98;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--accent);
    text-shadow: 0 0 40px rgba(255,21,22,0.28);
}
.rule {
    height: 2px; width: 84px; background: var(--accent);
    margin: 30px 0 26px;
    box-shadow: 0 0 16px rgba(255,21,22,0.5);
}
.lead {
    font-family: var(--font-body);
    font-size: clamp(19px, 2.4vw, 26px);
    line-height: 1.45;
    color: var(--text-primary);
    max-width: 720px;
    margin-bottom: 20px;
    font-weight: 500;
}
.body {
    font-size: clamp(15px, 1.6vw, 17px);
    line-height: 1.75;
    color: var(--text-secondary);
    max-width: 680px;
}
.body + .body { margin-top: 14px; }
.body strong { color: var(--text-primary); font-weight: 600; }

/* ============================================================
   TITLE SLIDE
   ============================================================ */
.title-slide .slide-inner { max-width: 1000px; }
.eyebrow {
    font-family: var(--font-title);
    font-size: clamp(11px, 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(38px, 8vw, 92px);
    line-height: 0.96;
    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; }

/* ============================================================
   MANIFESTO SLIDE
   ============================================================ */
.manifesto .eyebrow { margin-bottom: 34px; }
.manifesto .big {
    font-family: var(--font-title);
    font-weight: 700;
    font-size: clamp(24px, 4.4vw, 46px);
    line-height: 1.08;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    color: var(--text-primary);
    margin-bottom: 34px;
}
.manifesto .big .accent { color: var(--accent); }
.manifesto p {
    font-size: clamp(15px, 1.7vw, 18px);
    color: var(--text-secondary);
    max-width: 720px;
    margin-bottom: 18px;
}
.manifesto p .hl { color: var(--text-primary); }

/* ============================================================
   ACT DIVIDER
   ============================================================ */
.act-slide { align-items: center; text-align: left; }
.act-numeral {
    font-family: var(--font-title);
    font-weight: 700;
    font-size: clamp(90px, 20vw, 260px);
    line-height: 0.8;
    color: transparent;
    -webkit-text-stroke: 2px var(--accent-dark);
    margin-bottom: 8px;
    position: relative;
}
.act-kicker {
    font-family: var(--font-ui);
    font-size: 12px; letter-spacing: 0.3em; text-transform: uppercase;
    color: var(--accent); margin-bottom: 22px;
}
.act-title {
    font-family: var(--font-title);
    font-weight: 700;
    font-size: clamp(30px, 6.5vw, 72px);
    line-height: 0.98; letter-spacing: 0.04em; text-transform: uppercase;
    color: var(--text-primary);
    margin-bottom: 26px;
    text-shadow: 0 0 50px rgba(255,21,22,0.12);
}
.act-summary {
    font-size: clamp(16px, 2vw, 20px);
    color: var(--text-secondary); max-width: 620px; margin-bottom: 40px;
}
.act-list { display: flex; flex-wrap: wrap; gap: 10px 12px; }
.act-list 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: 7px 14px;
}
.act-list span b { color: var(--accent); font-weight: 700; margin-right: 8px; }

/* ============================================================
   EAT — avoid / focus toggle
   ============================================================ */
.toggle {
    display: inline-flex; border: 1px solid var(--border); margin: 4px 0 26px;
}
.toggle button {
    font-family: var(--font-title);
    font-size: 12px; font-weight: 700; letter-spacing: 0.25em;
    text-transform: lowercase;
    background: transparent; color: var(--text-secondary);
    border: none; padding: 12px 30px; cursor: pointer;
    transition: background .2s, color .2s;
}
.toggle button + button { border-left: 1px solid var(--border); }
.toggle button.on { background: var(--accent); color: var(--bg-dark); }
.toggle button:not(.on):hover { color: var(--text-primary); }

.food-panel { display: none; }
.food-panel.on { display: grid; }
.food-grid {
    grid-template-columns: repeat(2, minmax(0,1fr));
    gap: 1px; background: var(--border);
    border: 1px solid var(--border);
    max-width: 780px;
}
.food-item { background: var(--bg-card); padding: 20px 22px; }
.food-item h4 {
    font-family: var(--font-title);
    font-size: 13px; font-weight: 700; letter-spacing: 0.2em; text-transform: uppercase;
    margin-bottom: 8px;
}
.food-panel[data-kind="avoid"] .food-item h4 { color: var(--accent); }
.food-panel[data-kind="focus"] .food-item h4 { color: var(--text-primary); }
.food-item p { font-size: 13.5px; line-height: 1.6; color: var(--text-secondary); }

/* ============================================================
   3-4-3 rhythm diagram
   ============================================================ */
.rhythm { display: flex; flex-wrap: wrap; align-items: stretch; gap: 10px; margin: 6px 0 30px; max-width: 760px; }
.beat {
    flex: 1 1 0; min-width: 0; border: 1px solid var(--border); background: var(--bg-card);
    padding: 18px 16px; position: relative; overflow: hidden;
    opacity: 0; transform: translateY(14px);
}
.slide.active .beat { animation: rise .5s ease forwards; }
.slide.active .beat:nth-child(1) { animation-delay: .2s; }
.slide.active .beat:nth-child(2) { animation-delay: .38s; }
.slide.active .beat:nth-child(3) { animation-delay: .56s; }
.slide.active .beat:nth-child(4) { animation-delay: .74s; }
.beat.rest {
    flex: 1 1 100%;
    background: linear-gradient(90deg, rgba(255,21,22,0.8) 0%, var(--accent) 50%, rgba(255,21,22,0.8) 100%);
    border: none;
    box-shadow: 0 10px 30px rgba(255,21,22,0.25), inset 0 2px 0 rgba(255,255,255,0.2);
    display: flex; align-items: baseline; gap: 22px; padding: 16px;
}
.beat.rest .beat-n { margin-bottom: 0; color: var(--bg-dark); }
.beat.rest .beat-l { color: var(--bg-dark); }
.beat.rest .beat-s { color: var(--bg-dark); opacity: 0.75; }
.beat.rest .pulse { background: var(--bg-dark); }
.beat .beat-n {
    font-family: var(--font-title); font-weight: 700;
    font-size: clamp(28px, 5vw, 46px); line-height: 1;
    color: var(--accent); margin-bottom: 8px;
}
.beat.world .beat-n { color: var(--text-primary); -webkit-text-stroke: 0; }
.beat .beat-l {
    font-family: var(--font-ui); font-size: 11px; letter-spacing: 0.16em;
    text-transform: uppercase; color: var(--text-secondary);
}
.beat .beat-s { font-size: 12px; color: var(--text-dim); margin-top: 6px; line-height: 1.5; }
.beat .pulse {
    position: absolute; left: 0; bottom: 0; height: 3px; width: 100%;
    background: var(--accent); transform: scaleX(0); transform-origin: left;
}
.slide.active .beat .pulse { animation: sweep 1s ease forwards; }
.slide.active .beat.work .pulse { animation-delay: .3s; }
.slide.active .beat.hours .pulse { animation-delay: .48s; }
.slide.active .beat.world .pulse { animation-delay: .66s; }
.slide.active .beat.rest .pulse { animation-delay: .84s; }
@keyframes sweep { to { transform: scaleX(1); } }

/* ============================================================
   CLOSING SLIDE
   ============================================================ */
.close-slide .big {
    font-family: var(--font-title); font-weight: 700;
    font-size: clamp(34px, 8vw, 88px); line-height: 0.96; letter-spacing: 0.03em;
    text-transform: uppercase; color: var(--text-primary); margin-bottom: 34px;
    text-shadow: 0 0 60px rgba(255,21,22,0.18);
}
.close-slide .big .accent { color: var(--accent); }
.recap { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 1px;
    background: var(--border); border: 1px solid var(--border); max-width: 760px; margin-bottom: 34px; }
.recap span {
    background: var(--bg-section); padding: 11px 14px;
    font-family: var(--font-ui); font-size: 11.5px; letter-spacing: 0.12em; text-transform: uppercase;
    color: var(--text-secondary); display: flex; gap: 10px; cursor: pointer; transition: background .2s, color .2s;
}
.recap span:hover { background: var(--bg-card); color: var(--text-primary); }
.recap span b { color: var(--accent); font-weight: 700; }
.close-slide .welcome {
    font-family: var(--font-ui); font-size: 12px; letter-spacing: 0.24em; text-transform: uppercase;
    color: var(--text-dim); border-left: 2px solid var(--accent); padding-left: 16px;
}
.close-slide .welcome b { color: var(--text-primary); font-weight: 400; }

/* ============================================================
   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;
}
.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.act::before { height: 3px; background: var(--text-dim); }
.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); }

#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;
}

/* ============================================================
   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 cubic-bezier(.16,.84,.36,1);
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 768px) {
    :root { --rail-w: 0px; }
    #rail { display: none; }
    .slide { padding: 84px 24px 96px; }
    .meta-row { margin-bottom: 26px; }
    .glyph { width: 42px; height: 42px; }
    .disc-head { gap: 12px; }
    .food-grid, .recap { grid-template-columns: 1fr; }
    .rhythm { flex-direction: column; gap: 6px; margin-bottom: 12px; }
    .beat { flex: 0 0 auto; padding: 12px 14px; }
    .beat.rest { flex-direction: column; gap: 4px; align-items: flex-start; }
    #hint { display: none; }
    #controls { right: 20px; bottom: 20px; }
    .ctrl { background: rgba(16, 20, 19, 0.92); }
    .act-slide { align-items: flex-start; }
}
@media (max-width: 768px) and (orientation: landscape) {
    .slide { justify-content: flex-start; overflow-y: auto; }
}

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