/* TILO website — one stylesheet, no build step.
   Palette and type follow the app (src/theme/palettes.ts): #0F0F11 night, #FFFFFF / #F5F4F1 day,
   #F2540B only for action, active state and progress. Oswald for display, Manrope for text. */

@font-face { font-family: "Oswald"; src: url("fonts/oswald-700.ttf") format("truetype"); font-weight: 700; font-display: swap; }
@font-face { font-family: "Oswald"; src: url("fonts/oswald-600.ttf") format("truetype"); font-weight: 600; font-display: swap; }
@font-face { font-family: "Manrope"; src: url("fonts/manrope-400.ttf") format("truetype"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Manrope"; src: url("fonts/manrope-600.ttf") format("truetype"); font-weight: 600; font-display: swap; }

:root {
  --night: #0F0F11;
  --night-2: #1A1A1D;
  --night-3: #242428;
  --paper: #FFFFFF;
  --warm: #F5F4F1;
  --line: #E4E3DE;
  --ink: #0F0F0E;
  --ink-2: #5F5E58;      /* 6.3:1 on white, 5.8:1 on warm */
  --snow: #F4F3EF;
  --snow-2: #A6A59E;     /* 7.6:1 on night */
  --accent: #F2540B;
  --accent-hover: #FF6A24;
  --protein: #32ADE6; --carbs: #30D158; --fat: #FF9F0A;
  --bronze: #B08D57; --silver: #C7CDD6; --gold: #E8C468;

  --display: "Oswald", "Arial Narrow", "Helvetica Neue", Arial, sans-serif;
  --text: "Manrope", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --gutter: clamp(16px, 4.5vw, 64px);
  --max: 1320px;
  --nav-h: 64px;
  --ease: cubic-bezier(.2, .7, .2, 1);
  color-scheme: dark light;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; overflow-x: clip; }
body {
  margin: 0; background: var(--night); color: var(--snow);
  font: 400 1.0625rem/1.6 var(--text);
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
  overflow-x: clip;
}
img, svg, canvas { display: block; max-width: 100%; }
h1, h2, h3, p, figure, ol, ul, dl, dd { margin: 0; }
ul[role="list"], ol[role="list"] { list-style: none; padding: 0; }
a { color: inherit; }
button { font: inherit; color: inherit; }
section[id] { scroll-margin-top: var(--nav-h); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }

.skip-link {
  position: absolute; left: 16px; top: -100px; z-index: 100;
  padding: 12px 18px; background: var(--snow); color: var(--night); font-weight: 600; border-radius: 8px;
}
.skip-link:focus { top: 12px; }
[tabindex="-1"]:focus { outline: none; }

.wrap { width: 100%; max-width: calc(var(--max) + 2 * var(--gutter)); margin: 0 auto; padding: 0 var(--gutter); }
.dark { background: var(--night); color: var(--snow); }
.light { background: var(--paper); color: var(--ink); }
.warm { background: var(--warm); color: var(--ink); }

/* ---- Type ------------------------------------------------------------------ */
.eyebrow, .chapter, .step-h, .preview-note, .ur-title, .ur-glance dt, .ur-focus span, .us-eff span, .us-week > p {
  font: 600 .8125rem/1.2 var(--text); letter-spacing: .14em; text-transform: uppercase;
}
.chapter { display: flex; align-items: center; gap: 14px; margin-bottom: clamp(20px, 3vw, 36px); }
.chapter span { font-family: var(--display); font-size: 1rem; letter-spacing: .04em; }
.chapter::after { content: ""; width: 48px; height: 2px; background: var(--accent); }
.display-2 {
  font: 700 clamp(3rem, 8.4vw, 7.75rem)/.9 var(--display);
  text-transform: uppercase; letter-spacing: -.01em;
}
.lead { font-size: clamp(1.0625rem, 1.5vw, 1.3125rem); line-height: 1.5; max-width: 34ch; }
.dark .lead, .dark .fineprint { color: var(--snow-2); }
.light .lead, .warm .lead { color: var(--ink-2); }
.fineprint { font-size: .9375rem; line-height: 1.55; max-width: 52ch; color: var(--snow-2); }
.fineprint--dark { color: var(--ink-2); margin-top: clamp(28px, 4vw, 48px); }
.preview-note { display: block; grid-column: 1 / -1; margin-top: 20px; font-size: .75rem; letter-spacing: .12em; color: var(--ink-2); }
.ui-workout .preview-note, .ui-chat .preview-note, .ui-sleep .preview-note, .ui-level .preview-note { color: var(--snow-2); }

/* ---- Buttons --------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 52px; padding: 0 26px; border-radius: 999px; border: 1px solid transparent;
  font: 600 1rem/1 var(--text); text-decoration: none; white-space: nowrap;
  transition: background-color .2s, border-color .2s, color .2s;
}
.btn-lg { height: 56px; padding: 0 30px; font-size: 1.0625rem; }
.btn-sm { height: 40px; padding: 0 18px; font-size: .9375rem; }
/* Night text on the accent: white on #F2540B is only 3.47:1; #0F0F11 gives ~6:1. */
.btn-primary { background: var(--accent); color: var(--night); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-ghost { border-color: rgba(244, 243, 239, .3); color: var(--snow); }
.btn-ghost:hover { border-color: var(--snow); }
.actions { display: flex; flex-wrap: wrap; gap: 12px; }

/* ---- Header / nav ---------------------------------------------------------- */
.site-header { position: fixed; inset: 0 0 auto; z-index: 50; color: var(--snow); }
.site-header::before {
  content: ""; position: absolute; inset: 0; z-index: -1; opacity: 0;
  background: rgba(15, 15, 17, .94); border-bottom: 1px solid rgba(255, 255, 255, .07);
  -webkit-backdrop-filter: saturate(160%) blur(18px); backdrop-filter: saturate(160%) blur(18px);
  transition: opacity .3s;
}
.site-header.scrolled::before, .site-header.menu-open::before,
body:has(> main.page) .site-header::before { opacity: 1; }
.nav {
  display: flex; align-items: center; gap: 24px; height: var(--nav-h);
  max-width: calc(var(--max) + 2 * var(--gutter)); margin: 0 auto; padding: 0 var(--gutter);
}
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; font: 700 1.375rem/1 var(--display); letter-spacing: .08em; }
.brand img { width: 28px; height: 28px; border-radius: 7px; }
.nav-links { display: flex; gap: 28px; margin-left: auto; }
.nav-links a { text-decoration: none; font-size: .9375rem; font-weight: 600; color: var(--snow-2); transition: color .2s; }
.nav-links a:hover { color: var(--snow); }
.menu-btn { display: none; }
.menu { display: none; }

@media (max-width: 959px) {
  .nav { gap: 12px; }
  .nav-links { display: none; }
  .nav-cta { margin-left: auto; }
  .menu-btn {
    display: grid; place-content: center; gap: 6px; width: 44px; height: 44px; margin-right: -8px;
    background: none; border: 0; border-radius: 10px; cursor: pointer;
  }
  .menu-btn span { width: 22px; height: 2px; background: currentColor; border-radius: 2px; transition: transform .25s var(--ease); }
  .menu-btn[aria-expanded="true"] span:first-child { transform: translateY(4px) rotate(45deg); }
  .menu-btn[aria-expanded="true"] span:last-child { transform: translateY(-4px) rotate(-45deg); }
  .menu:not([hidden]) {
    display: flex; flex-direction: column; justify-content: space-between; gap: 32px;
    position: fixed; inset: var(--nav-h) 0 0; padding: 24px var(--gutter) max(32px, env(safe-area-inset-bottom));
    background: var(--night); overflow-y: auto;
  }
  .menu ul { display: grid; }
  .menu li + li { border-top: 1px solid rgba(255, 255, 255, .09); }
  .menu li a {
    display: flex; align-items: baseline; gap: 16px; padding: 14px 0; text-decoration: none;
    font: 700 clamp(2.25rem, 10vw, 3.25rem)/1 var(--display); text-transform: uppercase;
  }
  .menu li a span { font-size: .875rem; color: var(--snow-2); letter-spacing: .06em; }
}
@media (max-width: 359px) { .nav-cta { display: none; } .menu-btn { margin-left: auto; } }

/* ---- Stage (shared 3D canvas + poster) ------------------------------------- */
.stage { position: relative; }
.stage-frame { position: relative; width: 100%; height: 100%; }
.stage-poster, .stage-canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.stage-poster { object-fit: contain; transition: opacity .6s var(--ease); }
.stage-canvas { opacity: 0; transition: opacity .6s var(--ease); touch-action: pan-y; cursor: grab; }
.stage-canvas:active { cursor: grabbing; }
.stage-canvas.is-shown { opacity: 1; }
.stage.is-live .stage-poster { opacity: 0; }

/* ---- Hero ------------------------------------------------------------------ */
.hero {
  position: relative; display: grid; min-height: 100svh;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  grid-template-rows: var(--nav-h) auto 1fr auto auto;
  column-gap: 16px; padding: 0 var(--gutter) 28px;
  max-width: calc(var(--max) + 2 * var(--gutter)); margin: 0 auto;
  isolation: isolate;
}
.hero::before { /* soft floor light behind the body, not a gradient wash */
  content: ""; position: absolute; z-index: -1; right: 0; bottom: 8%; width: min(100%, 900px); height: 40%; background: radial-gradient(closest-side, rgba(242, 84, 11, .10), transparent);
  pointer-events: none;
}
.hero-inner { display: contents; }
.hero .eyebrow { grid-column: 1 / 7; grid-row: 2; padding-top: clamp(24px, 5vh, 56px); color: var(--snow-2); }
.hero-title {
  grid-column: 1 / -1; grid-row: 3; align-self: center; position: relative; z-index: 0; pointer-events: none;
  font: 700 clamp(4.5rem, 14.2vw, 14.5rem)/.84 var(--display); text-transform: uppercase; letter-spacing: -.015em;
}
.hero-title .line { display: block; }
.hero-title .line + .line { padding-left: 1.3em; }
.hero-foot { grid-column: 1 / 6; grid-row: 4; display: grid; gap: 28px; padding-bottom: 36px; position: relative; z-index: 2; }
.hero-lead { font-size: clamp(1.0625rem, 1.4vw, 1.25rem); color: var(--snow-2); max-width: 32ch; }
.stage--hero {
  grid-column: 6 / 13; grid-row: 1 / 5; z-index: 1; justify-self: center; align-self: end;
  height: min(94svh, 1000px); aspect-ratio: 2 / 3; max-width: 100%;
}
.hero-tags {
  position: absolute; inset: 0; list-style: none; padding: 0; margin: 0; pointer-events: none;
  font: 600 .8125rem/1 var(--text);
}
.hero-tags li {
  position: absolute; display: flex; align-items: center; gap: 8px; padding: 9px 13px;
  background: rgba(26, 26, 29, .78); border: 1px solid rgba(255, 255, 255, .09); border-radius: 999px;
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); white-space: nowrap;
}
.hero-tags li:nth-child(1) { top: 22%; right: 74%; }
.hero-tags li:nth-child(2) { top: 76%; left: 64%; }
.hero-tags i { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 10px rgba(242, 84, 11, .7); }
.hero-tags li:nth-child(2) i { background: #BB6C44; box-shadow: none; }
.sex-toggle {
  position: absolute; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 3;
  display: flex; padding: 4px; background: rgba(26, 26, 29, .82); border: 1px solid rgba(255, 255, 255, .09); border-radius: 999px;
}
.sex-toggle button {
  min-width: 84px; height: 38px; padding: 0 16px; border: 0; border-radius: 999px; background: none; cursor: pointer;
  font-size: .875rem; font-weight: 600; color: var(--snow-2); transition: background-color .2s, color .2s;
}
.sex-toggle button[aria-pressed="true"] { background: var(--snow); color: var(--night); }
.drag-hint { display: none; }
@media (pointer: fine) { .stage.is-live .drag-hint {
  display: block; position: absolute; right: 0; bottom: 30px; font-size: .75rem; letter-spacing: .12em; text-transform: uppercase; color: var(--snow-2);
} }
.hero-index {
  grid-column: 1 / -1; grid-row: 5; display: grid; grid-template-columns: repeat(5, 1fr); gap: 16px;
  border-top: 1px solid rgba(255, 255, 255, .12); padding-top: 16px; position: relative; z-index: 2;
}
.hero-index a { display: flex; gap: 10px; align-items: baseline; text-decoration: none; font-weight: 600; font-size: .9375rem; color: var(--snow-2); transition: color .2s; }
.hero-index a:hover { color: var(--snow); }
.hero-index span { font: 600 .8125rem/1 var(--display); color: var(--accent); letter-spacing: .04em; }

@media (max-width: 859px) {
  .hero { grid-template-columns: minmax(0, 1fr); grid-template-rows: var(--nav-h) auto auto auto auto; min-height: 0; padding-bottom: 20px; }
  .hero .eyebrow { grid-column: 1; grid-row: 2; padding-top: 20px; }
  .hero-title { grid-column: 1; grid-row: 3; font-size: clamp(3.75rem, 19.5vw, 7.5rem); padding-top: 10px; }
  .hero-title .line + .line { padding-left: 0; }
  .stage--hero { grid-column: 1; grid-row: 4; height: min(64svh, 560px); margin-top: -12vw; align-self: start; }
  .hero-foot { grid-column: 1; grid-row: 5; padding: 8px 0 0; gap: 22px; }
  .hero-foot .actions .btn { flex: 1 1 100%; }
  .hero-index { display: none; }
  .hero-tags li { font-size: .75rem; padding: 7px 10px; }
  .hero-tags li:nth-child(1) { right: auto; left: -4px; top: 30%; }
  .hero-tags li:nth-child(2) { left: auto; right: -4px; top: 62%; }
  .sex-toggle { bottom: 6px; }
  .hero::before { bottom: 30%; }
}

/* ---- 01 Train -------------------------------------------------------------- */
.train { padding: clamp(96px, 14vw, 180px) 0 clamp(110px, 14vw, 190px); }
.train-grid { display: grid; grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); gap: clamp(40px, 6vw, 96px); align-items: center; margin-top: clamp(48px, 7vw, 96px); }
.ui-workout {
  position: relative; background: var(--night); color: var(--snow);
  border-radius: clamp(28px, 3vw, 40px); padding: clamp(22px, 3vw, 40px);
  box-shadow: 0 40px 80px -40px rgba(15, 15, 17, .55);
}
.uw-top { display: flex; justify-content: space-between; align-items: center; font: 600 .8125rem/1 var(--text); letter-spacing: .14em; color: var(--snow-2); }
.uw-pill { padding: 7px 12px; border-radius: 999px; background: var(--night-3); color: var(--snow); letter-spacing: .04em; font-variant-numeric: tabular-nums; }
.uw-body { display: grid; grid-template-columns: 1fr auto; grid-template-rows: auto auto auto; column-gap: 20px; margin-top: clamp(28px, 5vw, 64px); align-items: end; }
.uw-ex { grid-column: 1 / -1; display: flex; align-items: center; gap: 12px; font-size: clamp(1.125rem, 1.8vw, 1.5rem); font-weight: 600; }
.uw-badge { padding: 4px 10px; border-radius: 999px; background: rgba(242, 84, 11, .16); color: var(--accent); font-size: .875rem; }
.uw-num { font: 700 clamp(4.25rem, 11vw, 10.5rem)/.9 var(--display); letter-spacing: -.02em; margin-top: 10px; font-variant-numeric: tabular-nums; }
.uw-num small { font-size: .32em; margin-left: .12em; color: var(--snow-2); letter-spacing: .02em; }
.uw-num em { font-style: normal; color: var(--snow-2); margin: 0 .12em; font-weight: 600; }
.uw-last { grid-column: 1; color: var(--snow-2); font-size: .9375rem; margin-top: 12px; }
.uw-rest { grid-column: 2; grid-row: 2 / 4; position: relative; width: clamp(96px, 12vw, 150px); aspect-ratio: 1; }
.uw-rest svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.uw-rest circle { fill: none; stroke-width: 8; }
.uw-rest .t { stroke: var(--night-3); }
.uw-rest .f { stroke: var(--accent); stroke-linecap: round; }
.uw-rest p { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }
.uw-rest b { font: 700 clamp(1.5rem, 2.6vw, 2.25rem)/1 var(--display); font-variant-numeric: tabular-nums; }
.uw-rest span { font-size: .6875rem; letter-spacing: .14em; text-transform: uppercase; color: var(--snow-2); margin-top: 4px; }
.facts { display: grid; }
.facts li { padding: clamp(20px, 2.4vw, 30px) 0; border-top: 1px solid var(--line); }
.facts li:last-child { border-bottom: 1px solid var(--line); }
.facts h3 { font: 700 clamp(1.5rem, 2.4vw, 2rem)/1.05 var(--display); text-transform: uppercase; }
.facts p { color: var(--ink-2); margin-top: 8px; max-width: 38ch; }

@media (max-width: 859px) {
  .train-grid { grid-template-columns: minmax(0, 1fr); gap: 72px; }
  .ui-workout { margin-right: calc(-1 * var(--gutter)); border-radius: 28px 0 0 28px; }
}

/* ---- Body story (sticky) ---------------------------------------------------- */
.story { position: relative; }
.story-grid {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: clamp(24px, 5vw, 80px);
  max-width: calc(var(--max) + 2 * var(--gutter)); margin: 0 auto; padding: 0 var(--gutter);
}
.story-stage { position: sticky; top: 0; height: 100svh; display: grid; place-items: center; padding: calc(var(--nav-h) + 12px) 0 28px; }
.stage--story { height: 100%; aspect-ratio: 2 / 3; max-width: 100%; }
.story-rail {
  position: absolute; left: 8%; right: 8%; bottom: 4px; display: flex; align-items: center; gap: 12px;
  font: 600 .75rem/1 var(--text); letter-spacing: .1em; color: var(--snow-2);
}
.story-rail i { flex: 1; height: 2px; background: var(--night-3); position: relative; border-radius: 2px; }
.story-rail b {
  position: absolute; inset: 0 auto 0 0; width: 100%; background: var(--accent); border-radius: 2px;
  transform-origin: left; transform: scaleX(var(--story-p, 0)); transition: transform .6s var(--ease);
}
.story-head { padding-top: clamp(120px, 18vh, 200px); min-height: 70svh; }
.story-head .display-2 { font-size: clamp(3rem, 6.4vw, 6.25rem); }
.story-head .lead { margin-top: 24px; }
.steps { display: grid; }
.steps li { min-height: 78svh; display: flex; flex-direction: column; justify-content: center; transition: opacity .5s var(--ease); }
html.js .steps li:not(.is-active) { opacity: .28; }
.step-h { font: 700 clamp(3.5rem, 7vw, 6rem)/1 var(--display); letter-spacing: -.01em; color: var(--accent); }
.steps h3 { font: 700 clamp(1.625rem, 2.6vw, 2.25rem)/1.05 var(--display); text-transform: uppercase; margin-top: 12px; }
.steps p:not(.step-h) { color: var(--snow-2); margin-top: 12px; max-width: 36ch; font-size: 1.125rem; }
.story .fineprint { padding: 0 0 clamp(96px, 14vh, 160px); }

@media (max-width: 859px) {
  .story-grid { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .story-stage {
    top: 0; height: 58svh; z-index: 2; padding: calc(var(--nav-h) + 4px) 0 26px;
    background: var(--night);
  }
  /* Fade below the sticky stage, so step copy never shows through behind the 0-60 h rail. */
  .story-stage::after { content: ""; position: absolute; left: 0; right: 0; top: 100%; height: 48px; background: linear-gradient(var(--night), rgba(15, 15, 17, 0)); pointer-events: none; }
  .story-copy { position: relative; z-index: 1; }
  .story-head { order: -1; padding-top: 32px; min-height: 0; margin-bottom: 18svh; }
  .story-grid > .story-stage { order: 0; }
  .steps li { min-height: 52svh; justify-content: flex-end; padding-bottom: 12svh; }
  .step-h { font-size: 3.25rem; }
}

/* ---- 02 Food --------------------------------------------------------------- */
.food { padding: clamp(96px, 14vw, 180px) 0; }
.kcal {
  position: relative; display: grid; grid-template-columns: auto minmax(0, 1fr); gap: clamp(24px, 4vw, 64px); align-items: end;
  margin-top: clamp(56px, 8vw, 112px);
}
.kcal-num { font: 700 clamp(6rem, 23vw, 21rem)/.78 var(--display); letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.kcal-label { font: 700 clamp(1.5rem, 2.6vw, 2.25rem)/1 var(--display); text-transform: uppercase; }
.kcal-label span { color: var(--ink-2); font-weight: 600; }
.macros { display: grid; gap: 18px; margin-top: 28px; max-width: 440px; }
.macros div { display: grid; grid-template-columns: 1fr auto; row-gap: 8px; font-weight: 600; }
.macros span { font-size: .9375rem; }
.macros b { font-variant-numeric: tabular-nums; }
.macros small { color: var(--ink-2); font-weight: 400; font-size: .875rem; }
.macros i { grid-column: 1 / -1; height: 8px; border-radius: 8px; background: var(--line); position: relative; overflow: hidden; }
.macros i::after { content: ""; position: absolute; inset: 0 auto 0 0; width: var(--p); background: var(--c); border-radius: 8px; }
.macros div:nth-child(1) { --c: var(--protein); --p: 79%; }
.macros div:nth-child(2) { --c: var(--carbs); --p: 66%; }
.macros div:nth-child(3) { --c: var(--fat); --p: 68%; }
.modes { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: clamp(24px, 3vw, 48px); margin-top: clamp(96px, 12vw, 160px); counter-reset: m; }
.modes li { border-top: 2px solid var(--ink); padding-top: 22px; }
.modes h3 { font: 700 clamp(2.25rem, 4.4vw, 4rem)/.95 var(--display); text-transform: uppercase; }
.modes p { color: var(--ink-2); margin-top: 14px; max-width: 32ch; }

@media (max-width: 859px) {
  .kcal { grid-template-columns: minmax(0, 1fr); gap: 20px; }
  .kcal-num { font-size: clamp(6rem, 34vw, 11rem); }
  .modes { grid-template-columns: minmax(0, 1fr); gap: 40px; }
}

/* ---- 03 Sleep -------------------------------------------------------------- */
.sleep { padding: clamp(96px, 14vw, 180px) 0; }
.sleep-grid { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); gap: clamp(48px, 7vw, 120px); align-items: center; }
.sleep-copy .lead { margin-top: 28px; }
.ui-sleep { position: relative; background: var(--night-2); border-radius: clamp(28px, 3vw, 40px); padding: clamp(24px, 3.4vw, 44px); border: 1px solid rgba(255, 255, 255, .05); }
.us-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; }
.us-total { font: 700 clamp(4rem, 8.6vw, 8rem)/.85 var(--display); letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.us-total small { font-size: .42em; color: var(--snow-2); margin: 0 .08em; }
.us-eff { text-align: right; display: grid; gap: 6px; }
.us-eff b { font: 700 2rem/1 var(--display); }
.us-eff span { color: var(--snow-2); font-size: .75rem; }
.us-stages { display: flex; gap: 4px; height: 14px; margin-top: 32px; }
.us-stages i { border-radius: 4px; }
.us-stages i:nth-child(1), .us-legend li:nth-child(1) i { background: #5E5CE6; }
.us-stages i:nth-child(2), .us-legend li:nth-child(2) i { background: #9A8CFF; }
.us-stages i:nth-child(3), .us-legend li:nth-child(3) i { background: #4A4A58; }
.us-stages i:nth-child(1) { width: 18%; } .us-stages i:nth-child(2) { width: 24%; } .us-stages i:nth-child(3) { flex: 1; }
.us-legend { display: flex; flex-wrap: wrap; gap: 8px 22px; list-style: none; padding: 0; margin-top: 14px; font-size: .875rem; color: var(--snow-2); }
.us-legend li { display: flex; align-items: center; gap: 8px; }
.us-legend i { width: 8px; height: 8px; border-radius: 2px; }
.us-legend b { color: var(--snow); font-weight: 600; }
.us-week { margin-top: 36px; }
.us-week > p { color: var(--snow-2); font-size: .75rem; }
.us-bars { position: relative; display: grid; grid-template-columns: repeat(7, 1fr); gap: 10px; align-items: end; height: 140px; margin-top: 16px; }
.us-bars i { height: var(--h); background: var(--night-3); border-radius: 6px 6px 2px 2px; }
.us-bars i:nth-child(1) { --h: 78%; } .us-bars i:nth-child(2) { --h: 88%; } .us-bars i:nth-child(3) { --h: 70%; }
.us-bars i:nth-child(4) { --h: 92%; } .us-bars i:nth-child(5) { --h: 81%; } .us-bars i:nth-child(6) { --h: 74%; }
.us-bars i:nth-child(7) { --h: 96%; }
.us-bars i.is-now { background: #9A8CFF; }
.us-goal { /* 8 h goal on a 9.6 h scale */
  position: absolute; left: 0; right: 0; top: 17%; border-top: 1px dashed rgba(244, 243, 239, .45);
  display: flex; justify-content: flex-start; padding-top: 4px; z-index: 1; pointer-events: none;
  font-size: .6875rem; letter-spacing: .1em; text-transform: uppercase; color: var(--snow-2);
}

@media (max-width: 859px) { .sleep-grid { grid-template-columns: minmax(0, 1fr); } }

/* ---- 04 Recovery & AI ------------------------------------------------------ */
.ai { padding: clamp(96px, 14vw, 180px) 0; overflow: hidden; }
.ai .display-2 { font-size: clamp(4.5rem, 15vw, 14rem); line-height: .82; }
.ai-lead { margin-top: 28px; max-width: 46ch; }
.ai-layers { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); margin-top: clamp(56px, 8vw, 110px); }
.ui-chat {
  position: relative; grid-column: 1 / 9; grid-row: 1; background: var(--night); color: var(--snow);
  border-radius: clamp(28px, 3vw, 40px); padding: clamp(24px, 4vw, 56px) clamp(22px, 4vw, 56px) clamp(64px, 8vw, 120px);
  display: grid; gap: 18px; align-content: start;
}
.bubble { max-width: 34em; padding: 16px 20px; border-radius: 22px; font-size: clamp(1rem, 1.35vw, 1.1875rem); line-height: 1.5; }
.bubble--me { justify-self: end; background: var(--accent); color: var(--night); font-weight: 600; border-bottom-right-radius: 6px; }
.bubble--tilo { background: var(--night-2); border-bottom-left-radius: 6px; }
.sources { display: flex; align-items: center; gap: 8px; margin-top: 14px; font-size: .8125rem; font-weight: 600; color: var(--snow-2); }
.sources i { font-style: normal; display: inline-grid; place-content: center; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 999px; background: var(--night-3); color: var(--snow); }
.ui-review {
  position: relative; grid-column: 7 / 13; grid-row: 1; align-self: end; margin-bottom: -40px; transform: translateY(40%);
  background: var(--paper); color: var(--ink); border: 1px solid var(--line);
  border-radius: 28px; padding: clamp(22px, 2.6vw, 34px); box-shadow: 0 40px 90px -30px rgba(15, 15, 17, .35);
}
.ai-layers { padding-bottom: 12%; }
.ur-title { color: var(--ink-2); }
.ur-glance { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 18px; }
.ur-glance dt { color: var(--ink-2); font-size: .6875rem; }
.ur-glance dd { font: 700 clamp(2.5rem, 4vw, 3.5rem)/1 var(--display); margin-top: 6px; }
.ur-glance p { font-size: .8125rem; color: var(--ink-2); margin-top: 4px; }
.ur-focus { margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--line); font-weight: 600; font-size: 1.0625rem; display: grid; gap: 6px; }
.ur-focus span { color: var(--ink-2); font-size: .6875rem; }

@media (max-width: 859px) {
  .ai-layers { grid-template-columns: minmax(0, 1fr); padding-bottom: 0; }
  .ui-chat { grid-column: 1; grid-row: 1; margin: 0 calc(-1 * var(--gutter)); border-radius: 0; padding-bottom: 96px; }
  .ui-review { grid-column: 1; grid-row: 2; transform: none; margin: -56px 0 28px 12px; }
}

/* ---- 05 Progress ----------------------------------------------------------- */
.progress { padding: clamp(80px, 10vw, 140px) 0 clamp(96px, 12vw, 160px); }
.progress-grid {
  display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); gap: clamp(32px, 6vw, 96px); align-items: center;
  max-width: calc(var(--max) + 2 * var(--gutter)); margin: 0 auto; padding: 0 var(--gutter);
}
.stage--progress { height: min(86svh, 860px); aspect-ratio: 2 / 3; max-width: 100%; justify-self: center; }
.progress-copy .lead { margin-top: 24px; }
.medals { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-top: 40px; }
.medals li { display: grid; gap: 4px; padding: 18px 0 0; border-top: 2px solid var(--ink); }
.medals i { width: 36px; height: 36px; border-radius: 50%; margin-bottom: 10px; box-shadow: inset 0 -6px 12px rgba(0, 0, 0, .18); }
.medals li:nth-child(1) i { background: var(--bronze); }
.medals li:nth-child(2) i { background: var(--silver); }
.medals li:nth-child(3) i { background: var(--gold); }
.medals b { font: 700 1.5rem/1 var(--display); text-transform: uppercase; }
.medals span { color: var(--ink-2); font-size: .9375rem; }
.ui-level { position: relative; margin-top: 56px; background: var(--night); color: var(--snow); border-radius: 28px; padding: clamp(22px, 2.6vw, 32px); }
.ul-row { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; }
.ul-lvl { font: 600 1rem/1 var(--display); letter-spacing: .08em; color: var(--snow-2); }
.ul-lvl b { font-size: 3rem; color: var(--snow); margin-left: 4px; }
.ul-name { font: 700 1.75rem/1 var(--display); letter-spacing: .04em; }
.ul-xp { margin-left: auto; font-weight: 600; color: var(--snow-2); font-variant-numeric: tabular-nums; }
.ul-bar { height: 8px; border-radius: 8px; background: var(--night-3); margin-top: 18px; overflow: hidden; }
.ul-bar i { display: block; height: 100%; width: 79%; background: var(--accent); border-radius: 8px; }
.ul-earn { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }
.ul-earn span { padding: 7px 12px; border-radius: 999px; background: var(--night-2); font-size: .8125rem; font-weight: 600; color: var(--snow-2); }

@media (max-width: 859px) {
  .progress-grid { grid-template-columns: minmax(0, 1fr); }
  .stage--progress { order: 2; height: min(70svh, 600px); }
  .medals { gap: 10px; }
  .medals b { font-size: 1.25rem; }
  .medals span { font-size: .8125rem; }
}

/* ---- CTA + footer ---------------------------------------------------------- */
.cta { padding: clamp(110px, 16vw, 220px) 0 clamp(80px, 10vw, 140px); }
.cta-title { font: 700 clamp(4rem, 13.5vw, 13rem)/.84 var(--display); text-transform: uppercase; letter-spacing: -.015em; }
.cta-foot { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 32px; margin-top: clamp(40px, 5vw, 72px); }
.site-footer { background: var(--night); color: var(--snow-2); border-top: 1px solid rgba(255, 255, 255, .08); padding: 48px 0 max(40px, env(safe-area-inset-bottom)); font-size: .875rem; }
.footer-grid { display: grid; grid-template-columns: auto 1fr; gap: 24px 48px; align-items: center; }
.site-footer .brand { color: var(--snow); }
.footer-links { display: flex; flex-wrap: wrap; gap: 8px 28px; justify-content: flex-end; }
.footer-links a { font-weight: 600; text-decoration: none; color: var(--snow); }
.footer-links a:hover { text-decoration: underline; }
.credits, .copyright { grid-column: 1 / -1; max-width: 90ch; line-height: 1.6; }
.credits a { text-underline-offset: 2px; }

@media (max-width: 859px) {
  .cta-foot .actions { width: 100%; }
  .cta-foot .actions .btn { flex: 1 1 100%; }
  .footer-grid { grid-template-columns: minmax(0, 1fr); }
  .footer-links { justify-content: flex-start; }
}

/* ---- Reveal (JS only, never hides content without JS) ------------------------ */
html.js .reveal { opacity: 0; transform: translateY(28px); transition: opacity .9s var(--ease), transform .9s var(--ease); }
html.js .reveal.is-in { opacity: 1; transform: none; }

/* ---- Motion polish: previews "come alive" on reveal. Final state is the default,
   so no-JS and reduced motion (instant reveal) always show the real values. ---- */
.hero-title .line { animation: rise 1.1s var(--ease) both; }
.hero-title .line + .line { animation-delay: .12s; }
.hero .eyebrow, .hero-foot { animation: fade 1.2s .35s var(--ease) both; }
@keyframes rise { from { opacity: 0; transform: translateY(.35em); } }
@keyframes fade { from { opacity: 0; } }
.dot { color: var(--accent); }

/* Warm halo that breathes behind the body. */
.stage--hero::before {
  content: ""; position: absolute; z-index: -1; left: 50%; top: 18%; width: 120%; aspect-ratio: 1; transform: translateX(-50%);
  background: radial-gradient(closest-side, rgba(242, 84, 11, .22), rgba(242, 84, 11, .06) 55%, transparent);
  animation: breathe 6s ease-in-out infinite alternate; pointer-events: none;
}
@keyframes breathe { from { opacity: .55; } to { opacity: 1; } }

/* Film grain on the dark hero and CTA (inline SVG noise, allowed by img-src data:).
   z-index -1 keeps it above the section background but BELOW the content — in particular
   below the live WebGL canvas. Over the canvas, mix-blend-mode forced a backdrop read-back
   on every rendered frame and dropped frames while the story states scrolled. */
.hero::after, .cta::after {
  content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none; opacity: .09; mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
.cta { position: relative; overflow: hidden; isolation: isolate; }
.cta::before {
  content: ""; position: absolute; z-index: -1; left: -10%; bottom: -40%; width: 90%; aspect-ratio: 1;
  background: radial-gradient(closest-side, rgba(242, 84, 11, .18), transparent); pointer-events: none;
}

.uw-rest .f, .macros i::after, .us-stages i, .us-bars i, .ul-bar i {
  transition: stroke-dashoffset 1.4s .3s var(--ease), width 1.2s .3s var(--ease), transform 1s var(--ease);
}
html.js .ui-workout:not(.is-in) .uw-rest .f { stroke-dashoffset: 100; }
html.js .kcal:not(.is-in) .macros i::after { width: 0; }
.macros div:nth-child(2) i::after { transition-delay: .45s; }
.macros div:nth-child(3) i::after { transition-delay: .6s; }
.us-stages i { transform-origin: left; }
html.js .ui-sleep:not(.is-in) .us-stages i { transform: scaleX(0); }
.us-bars i { transform-origin: bottom; }
html.js .ui-sleep:not(.is-in) .us-bars i { transform: scaleY(0); }
.us-bars i:nth-child(2) { transition-delay: .06s; } .us-bars i:nth-child(3) { transition-delay: .12s; }
.us-bars i:nth-child(4) { transition-delay: .18s; } .us-bars i:nth-child(5) { transition-delay: .24s; }
.us-bars i:nth-child(6) { transition-delay: .3s; } .us-bars i:nth-child(7) { transition-delay: .36s; }
.ul-bar i { transform-origin: left; transition-delay: .3s; }
html.js .ui-level:not(.is-in) .ul-bar i { transform: scaleX(0); }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; }
  html.js .reveal { opacity: 1; transform: none; }
}

/* ---- Legal pages (privacy, 404) --------------------------------------------- */
.page { background: var(--paper); color: var(--ink); padding: calc(var(--nav-h) + 72px) 0 120px; min-height: 80svh; }
.page .display-2 { font-size: clamp(3rem, 8vw, 6rem); }
.prose { max-width: 68ch; margin-top: 40px; }
.prose h2 { font: 700 clamp(1.5rem, 2.6vw, 2rem)/1.1 var(--display); text-transform: uppercase; margin: 48px 0 12px; }
.prose p, .prose li { color: #3E3D38; }
.prose p + p, .prose ul { margin-top: 14px; }
.prose ul { padding-left: 1.2em; }
.prose li + li { margin-top: 6px; }
.prose a { color: var(--ink); text-underline-offset: 3px; }
.prose .lead { max-width: none; color: var(--ink); }
.not-found-cta { margin-top: 40px; }
.prose .note { padding: 16px 20px; border-left: 3px solid var(--accent); background: var(--warm); }

/* ---- Contact form ----------------------------------------------------------- */
.contact-form { margin: 32px 0 8px; display: grid; gap: 22px; max-width: 34rem; }
.field { display: grid; gap: 8px; }
.field label { font-weight: 600; }
.field .opt { font-weight: 400; color: var(--ink-2); }
.field input, .field textarea {
  width: 100%; padding: 12px 14px; border-radius: 12px; resize: vertical;
  color: var(--ink); background: var(--paper); border: 1px solid var(--line);
  font: inherit; font-size: 1rem;
}
.field input:focus-visible, .field textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-color: var(--accent); }
.contact-form .btn { justify-self: start; }
/* Honeypot: off-screen rather than hidden, so bots that skip hidden fields still fill it. */
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.form-status { margin: 24px 0; padding: 14px 16px; border-radius: 12px; border-left: 3px solid; }
.form-status--ok { border-color: var(--accent); background: rgba(242, 84, 11, .08); }
.form-status--bad { border-color: #b00020; background: rgba(176, 0, 32, .08); }
