/* ==========================================================================
   Public landing page.
   One long scroll: a hero that gets out of the way, a sticky stage that
   cycles through working mock-ups of each feature, and a closing figure.
   Everything reads from tokens.css, so both themes come free.
   ========================================================================== */

.home-body {
  background:
    radial-gradient(ellipse 70% 45% at 12% -5%, var(--accent-fill), transparent 62%),
    var(--bg);
}

.home {
  display: block;
}

/* ---------- Slim header -------------------------------------------------- */

.home-topbar {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 40;
  padding: var(--space-4) var(--space-5);
  transition: background var(--dur-base) var(--ease-out),
              border-color var(--dur-base) var(--ease-out);
  border-bottom: 1px solid transparent;
}

/* Opaque rather than blurred: a backdrop-filter here forced a full-width
   repaint on every scrolled frame, which is felt as scroll weight long
   before it is seen as blur. */
.home-topbar.is-stuck {
  background: var(--bg);
  border-bottom-color: var(--line-faint);
}

.home-topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  max-width: var(--shell-max);
  margin: 0 auto;
}

.home-topbar-actions {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.home-topbar-cta {
  padding-block: 0.55rem;
  font-size: var(--text-small);
  opacity: 0;
  transform: translateY(-6px);
  pointer-events: none;
  transition: opacity var(--dur-base) var(--ease-out),
              transform var(--dur-base) var(--ease-out);
}

.home-topbar.is-stuck .home-topbar-cta {
  opacity: 1;
  transform: none;
  pointer-events: auto;
}

.home-topbar.is-stuck .home-topbar-chip {
  display: none;
}

/* ---------- Hero --------------------------------------------------------- */

.home-hero {
  position: relative;
  min-height: 100svh;
  display: grid;
  align-content: center;
  padding: clamp(6rem, 14vh, 9rem) var(--space-5) var(--space-8);
  overflow: hidden;
}

.hero-field {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

/* Follows the pointer, so the page feels alive before anything is scrolled. */
.hero-glow {
  position: absolute;
  width: 46rem;
  height: 46rem;
  left: 0;
  top: 0;
  margin: -23rem 0 0 -23rem;
  border-radius: 50%;
  background: radial-gradient(circle, var(--accent-glow), transparent 62%);
  opacity: 0.75;
  will-change: transform;
  /* Resting position, for coarse pointers where nothing tracks it. */
  transform: translate3d(50vw, 42vh, 0);
}

.hero-inner {
  position: relative;
  width: 100%;
  max-width: var(--shell-max);
  margin: 0 auto;
}

.hero-eyebrow {
  display: block;
  margin-bottom: var(--space-4);
}

.hero-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(2.75rem, 1.2rem + 7.2vw, 8rem);
  line-height: 0.94;
  letter-spacing: -0.035em;
  color: var(--text-strong);
  margin: 0 0 var(--space-5);
  max-width: 16ch;
}

.hero-line {
  display: block;
}

/* Each word is its own clipping window so the intro can slide them up. */
.hero-word {
  display: inline-block;
  overflow: hidden;
  vertical-align: bottom;
  padding-bottom: 0.06em;
}

.hero-word > span,
.hero-word-inner {
  display: inline-block;
}

.hero-word-accent {
  color: var(--accent-text);
}

.hero-lead {
  font-size: clamp(1.0625rem, 1rem + 0.45vw, 1.375rem);
  line-height: 1.55;
  color: var(--text-muted);
  max-width: 46ch;
  margin: 0 0 var(--space-6);
}

.hero-actions {
  display: flex;
  align-items: center;
  gap: var(--space-5);
  flex-wrap: wrap;
}

.hero-cta {
  font-size: var(--text-lead);
  padding: 0.95rem 1.6rem;
}

.hero-note {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  margin: 0;
  font-size: var(--text-small);
  color: var(--text-faint);
}

.hero-scroll-cue {
  position: absolute;
  left: 50%;
  bottom: var(--space-6);
  transform: translateX(-50%);
  display: grid;
  justify-items: center;
  gap: var(--space-2);
}

.hero-scroll-label {
  font-family: var(--font-data);
  font-size: var(--text-micro);
  letter-spacing: var(--tracking-eyebrow);
  text-transform: uppercase;
  color: var(--text-faint);
}

.hero-scroll-rail {
  position: relative;
  display: block;
  width: 1px;
  height: 3rem;
  background: linear-gradient(to bottom, var(--line-strong), transparent);
  overflow: hidden;
}

.hero-scroll-dot {
  position: absolute;
  left: -1px;
  width: 3px;
  height: 0.75rem;
  border-radius: var(--radius-pill);
  background: var(--accent);
  animation: home-scroll-dot 2.1s var(--ease-in-out) infinite;
}

@keyframes home-scroll-dot {
  0%   { top: -0.75rem; opacity: 0; }
  30%  { opacity: 1; }
  100% { top: 3rem; opacity: 0; }
}

/* ---------- Scroll story ------------------------------------------------- */

.home-story {
  position: relative;
  padding: 0 var(--space-5);
}

.story-inner {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.02fr);
  gap: clamp(var(--space-6), 5vw, var(--space-8));
  align-items: start;
  max-width: var(--shell-max);
  margin: 0 auto;
}

/* The stage is second in the source (so the copy reads first without CSS)
   and pulled to the right column here. */
.story-stage {
  grid-column: 2;
  grid-row: 1;
  position: sticky;
  top: 0;
  height: 100svh;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: var(--space-5);
}

.story-copy {
  grid-column: 1;
  grid-row: 1;
}

.stage-frame {
  position: relative;
  width: 100%;
  max-width: 34rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-md);
  overflow: hidden;
}

.stage-bar {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--line-faint);
  background: var(--surface-inset);
}

.stage-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--line-strong);
  opacity: 0.7;
}

.stage-bar-label {
  margin-left: auto;
  font-family: var(--font-data);
  font-size: var(--text-micro);
  letter-spacing: var(--tracking-eyebrow);
  text-transform: uppercase;
  color: var(--text-faint);
}

/* All screens share one box; height is the tallest of them. */
.stage-screens {
  position: relative;
  display: grid;
}

.stage-screen {
  grid-area: 1 / 1;
  display: grid;
  align-content: start;
  gap: var(--space-4);
  padding: var(--space-5);
  min-height: 27rem;
  opacity: 0;
  visibility: hidden;
  transform: translateY(14px) scale(0.985);
}

.stage-screen.is-active {
  opacity: 1;
  visibility: visible;
  transform: none;
}

/* No motion engine — because it failed to load, or because the reader asked
   for less motion. There is no cross-fade to sequence the screens, so they
   simply stack down the page in the same order as the copy beside them. */
html:not(.js-motion) .story-stage,
html.home-static .story-stage {
  position: static;
  height: auto;
}

html:not(.js-motion) .stage-screens,
html.home-static .stage-screens {
  display: grid;
  gap: 0;
}

html:not(.js-motion) .stage-screen,
html.home-static .stage-screen {
  grid-area: auto;
  opacity: 1;
  visibility: visible;
  transform: none;
}

html:not(.js-motion) .stage-screen + .stage-screen,
html.home-static .stage-screen + .stage-screen {
  border-top: 1px solid var(--line-faint);
}

html:not(.js-motion) .stage-steps,
html.home-static .stage-steps {
  display: none;
}

/* ---------- Mock-up parts (shared) --------------------------------------- */

.mock-head {
  display: grid;
  gap: var(--space-1);
}

.mock-eyebrow {
  font-family: var(--font-data);
  font-size: var(--text-micro);
  letter-spacing: var(--tracking-eyebrow);
  text-transform: uppercase;
  color: var(--text-faint);
}

.mock-title {
  font-family: var(--font-display);
  font-size: var(--text-h2);
  line-height: 1.15;
  letter-spacing: var(--tracking-tight);
  color: var(--text-strong);
}

.mock-money {
  font-family: var(--font-data);
  font-variant-numeric: tabular-nums;
}

.mock-title-tail {
  font-family: var(--font-body);
  font-size: var(--text-body);
  color: var(--text-muted);
}

.mock-delta {
  font-size: var(--text-small);
  margin-left: var(--space-2);
}

.mock-figure {
  font-family: var(--font-data);
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

.is-up  { color: var(--up); }
.is-down { color: var(--down); }

.mock-bar {
  height: 6px;
  border-radius: var(--radius-pill);
  background: var(--surface-inset);
  border: 1px solid var(--line-faint);
  overflow: hidden;
}

.mock-bar > i {
  display: block;
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: var(--accent);
}

.mock-progress {
  display: grid;
  gap: var(--space-2);
}

.mock-progress-top {
  display: flex;
  justify-content: space-between;
  font-size: var(--text-small);
  color: var(--text-muted);
}

/* ---------- Learning mock ------------------------------------------------ */

.mock-units {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: var(--space-2);
}

.mock-units li {
  display: grid;
  grid-template-columns: 1.25rem 1fr auto;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3);
  border: 1px solid var(--line-faint);
  border-radius: var(--radius-md);
  background: var(--surface-inset);
  font-size: var(--text-small);
  color: var(--text-muted);
}

.mock-units li.is-done .mock-check { color: var(--up); }
.mock-units li.is-current {
  border-color: var(--accent-line);
  background: var(--accent-fill);
  color: var(--text);
}
.mock-units li.is-current .mock-check { color: var(--accent-text); }

.mock-unit-name { color: inherit; }
.mock-unit-meta {
  font-family: var(--font-data);
  font-size: var(--text-micro);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-faint);
}

.mock-quiz {
  display: grid;
  gap: var(--space-2);
  padding: var(--space-4);
  border: 1px dashed var(--line);
  border-radius: var(--radius-md);
}

.mock-question {
  margin: 0;
  font-size: var(--text-body);
  color: var(--text);
}

.mock-answer {
  justify-self: start;
  padding: 0.4rem 0.75rem;
  border-radius: var(--radius-pill);
  border: 1px solid var(--up);
  background: var(--up-fill);
  color: var(--up);
  font-size: var(--text-small);
}

/* ---------- Money mock --------------------------------------------------- */

.mock-split { display: grid; gap: var(--space-3); }

.mock-split-bar {
  display: flex;
  gap: 3px;
  height: 14px;
}

.mock-split-bar > i {
  display: block;
  width: 0;
  border-radius: var(--radius-sm);
}

.mock-split-bar .is-save  { background: var(--accent); }
.mock-split-bar .is-spend { background: var(--line-strong); }
.mock-split-bar .is-give  { background: var(--gold); }

.mock-legend {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-4);
  font-size: var(--text-small);
  color: var(--text-muted);
}

.mock-legend li { display: inline-flex; align-items: center; gap: var(--space-2); }
.mock-legend b { color: var(--text); font-family: var(--font-data); }

.mock-legend .key {
  width: 10px;
  height: 10px;
  border-radius: 3px;
}
.mock-legend .key.is-save  { background: var(--accent); }
.mock-legend .key.is-spend { background: var(--line-strong); }
.mock-legend .key.is-give  { background: var(--gold); }

.mock-goal {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-4);
  border: 1px solid var(--line-faint);
  border-radius: var(--radius-md);
  background: var(--surface-inset);
}

.mock-goal-copy { display: grid; gap: var(--space-1); }
.mock-goal-copy strong { color: var(--text-strong); }
.mock-goal-meta {
  font-family: var(--font-data);
  font-size: var(--text-caption);
  color: var(--text-muted);
}

.mock-ring {
  position: relative;
  width: 72px;
  height: 72px;
  flex: none;
}

.mock-ring svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.ring-track,
.ring-value {
  fill: none;
  stroke-width: 7;
  stroke-linecap: round;
}

.ring-track { stroke: var(--line); }
.ring-value { stroke: var(--accent); }

.mock-ring-label {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-data);
  font-size: var(--text-caption);
  color: var(--text-strong);
  white-space: nowrap;
}

.mock-ledger {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 1px;
  background: var(--line-faint);
  border: 1px solid var(--line-faint);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.mock-ledger li {
  display: flex;
  justify-content: space-between;
  padding: var(--space-3) var(--space-4);
  background: var(--surface);
  font-size: var(--text-small);
  color: var(--text-muted);
}

.mock-ledger b {
  font-family: var(--font-data);
  color: var(--text);
}

/* ---------- Trading mock ------------------------------------------------- */

.mock-chart {
  height: 9.5rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--line-faint);
  background: var(--surface-inset);
  overflow: hidden;
}

.mock-chart svg { width: 100%; height: 100%; display: block; }

.mock-chart-line {
  fill: none;
  stroke: var(--accent);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.mock-chart-area {
  fill: var(--accent);
  opacity: 0.14;
}

.mock-chart-grid {
  stroke: var(--line-faint);
  stroke-width: 1;
}

.mock-ticker-row { display: grid; gap: var(--space-2); }

.mock-ticker {
  display: grid;
  grid-template-columns: 4rem 1fr auto;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--line-faint);
  border-radius: var(--radius-md);
  background: var(--surface-inset);
  font-size: var(--text-small);
}

.mock-symbol {
  font-family: var(--font-data);
  font-weight: 600;
  color: var(--text-strong);
}

.mock-shares { color: var(--text-muted); }
.mock-ticker b { font-family: var(--font-data); }

.mock-caution {
  margin: 0;
  font-size: var(--text-caption);
  color: var(--text-faint);
}

/* ---------- Coach mock --------------------------------------------------- */

.mock-chat {
  display: grid;
  gap: var(--space-3);
  justify-items: start;
}

.bubble {
  margin: 0;
  max-width: 88%;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-lg);
  font-size: var(--text-small);
  line-height: 1.55;
}

.bubble.is-you {
  justify-self: end;
  background: var(--accent);
  color: var(--text-on-accent);
  border-bottom-right-radius: var(--radius-sm);
}

.bubble.is-coach {
  background: var(--surface-inset);
  border: 1px solid var(--line-faint);
  color: var(--text);
  border-bottom-left-radius: var(--radius-sm);
}

.bubble.is-typing {
  display: inline-flex;
  gap: 5px;
  padding: var(--space-4);
}

.bubble.is-typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-faint);
  animation: home-typing 1.2s var(--ease-in-out) infinite;
}

.bubble.is-typing span:nth-child(2) { animation-delay: 0.15s; }
.bubble.is-typing span:nth-child(3) { animation-delay: 0.3s; }

@keyframes home-typing {
  0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
  30%           { opacity: 1;   transform: translateY(-3px); }
}

/* ---------- News mock ---------------------------------------------------- */

.mock-news {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: var(--space-3);
}

.mock-news li {
  display: grid;
  gap: var(--space-2);
  padding: var(--space-4);
  border: 1px solid var(--line-faint);
  border-radius: var(--radius-md);
  background: var(--surface-inset);
}

.mock-news strong {
  font-size: var(--text-body);
  color: var(--text-strong);
  line-height: 1.35;
}

.mock-news-tag {
  justify-self: start;
  padding: 0.2rem 0.6rem;
  border-radius: var(--radius-pill);
  background: var(--accent-fill);
  border: 1px solid var(--accent-line);
  color: var(--accent-text);
  font-family: var(--font-data);
  font-size: var(--text-micro);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.mock-news-why {
  font-size: var(--text-caption);
  color: var(--text-muted);
}

/* ---------- Stage step dots ---------------------------------------------- */

.stage-steps {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  gap: var(--space-2);
}

.stage-steps li > span {
  display: block;
  width: 2rem;
  height: 3px;
  border-radius: var(--radius-pill);
  background: var(--line);
  transition: background var(--dur-base) var(--ease-out);
}

.stage-steps li.is-active > span { background: var(--accent); }
.stage-steps li.is-past > span   { background: var(--line-strong); }

/* ---------- Story copy --------------------------------------------------- */

.copy-block {
  min-height: 68svh;
  display: grid;
  align-content: center;
  gap: var(--space-4);
  padding: var(--space-6) 0;
  max-width: 34rem;
}

.copy-index {
  font-family: var(--font-data);
  font-size: var(--text-caption);
  letter-spacing: var(--tracking-eyebrow);
  color: var(--accent-text);
}

.copy-block h2 {
  font-family: var(--font-display);
  font-size: clamp(1.75rem, 1.2rem + 2.1vw, 3.25rem);
  line-height: 1.05;
  letter-spacing: -0.03em;
  color: var(--text-strong);
  margin: 0;
}

.copy-block > p {
  margin: 0;
  font-size: var(--text-lead);
  line-height: 1.6;
  color: var(--text-muted);
}

.copy-points {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: var(--space-2);
  border-top: 1px solid var(--line-faint);
  padding-top: var(--space-4);
}

.copy-points li {
  position: relative;
  padding-left: 1.4rem;
  font-size: var(--text-small);
  color: var(--text);
}

.copy-points li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.5em;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
}

/* The active block is the one the stage is showing; the rest recede. This
   used to be two scrubbed tweens per block — eleven scroll-linked
   animations recomputing on every frame. A class and a transition read the
   same and cost nothing while scrolling. */
html.js-motion:not(.home-static) .copy-block {
  opacity: 0.32;
  transition: opacity var(--dur-slow) var(--ease-out);
}

html.js-motion:not(.home-static) .copy-block.is-current {
  opacity: 1;
}

/* ---------- Closing figure ----------------------------------------------- */

.home-close {
  padding: clamp(var(--space-7), 9vh, 6rem) var(--space-5);
}

.close-inner {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: clamp(var(--space-6), 5vw, var(--space-8));
  align-items: center;
  max-width: var(--shell-max);
  margin: 0 auto;
  padding: clamp(var(--space-6), 5vw, var(--space-8));
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface-feature);
  color: var(--text-on-feature);
  box-shadow: var(--shadow-lg);
}

.close-copy { display: grid; gap: var(--space-4); justify-items: start; }

.close-copy .eyebrow { color: var(--text-on-feature-muted); }

.close-copy h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.75rem, 1.2rem + 2.2vw, 3rem);
  line-height: 1.1;
  letter-spacing: -0.03em;
  color: var(--text-on-feature);
}

.close-figure {
  font-family: var(--font-data);
  font-variant-numeric: tabular-nums;
  color: var(--accent-on-feature);
}

.close-copy > p {
  margin: 0;
  font-size: var(--text-body);
  line-height: 1.65;
  color: var(--text-on-feature-muted);
  max-width: 46ch;
}

.close-breakdown {
  display: flex;
  gap: var(--space-7);
  margin: 0;
  padding-top: var(--space-4);
  border-top: 1px solid var(--line-on-feature);
  width: 100%;
}

.close-breakdown dt {
  font-family: var(--font-data);
  font-size: var(--text-micro);
  letter-spacing: var(--tracking-eyebrow);
  text-transform: uppercase;
  color: var(--text-on-feature-muted);
  margin-bottom: var(--space-1);
}

.close-breakdown dd {
  margin: 0;
  font-family: var(--font-data);
  font-size: var(--text-h2);
  color: var(--text-on-feature);
}

.close-chart {
  min-height: 16rem;
}

.close-chart svg { width: 100%; height: 100%; display: block; }

.close-line {
  fill: none;
  stroke: var(--accent-on-feature);
  stroke-width: 2.5;
  stroke-linecap: round;
}

.close-area {
  fill: var(--accent-on-feature);
  opacity: 0.16;
}

.close-base {
  stroke: var(--line-on-feature);
  stroke-width: 1;
}

/* ---------- Footer ------------------------------------------------------- */

.home-footer {
  padding: var(--space-6) var(--space-5) var(--space-8);
  text-align: center;
}

.home-footer p {
  max-width: var(--reading-max);
  margin: 0 auto;
  font-size: var(--text-caption);
  color: var(--text-faint);
}

/* ---------- Narrow screens ----------------------------------------------- */

@media (max-width: 60rem) {
  .story-inner {
    grid-template-columns: minmax(0, 1fr);
  }

  /* The stage moves above the copy and stays pinned to the top of the
     viewport while the copy for the matching feature scrolls under it. */
  .story-stage {
    grid-column: 1;
    grid-row: 1;
    height: auto;
    top: 4.5rem;
    padding: var(--space-4) 0;
    z-index: 2;
    background: linear-gradient(to bottom, var(--bg) 82%, transparent);
  }

  .story-copy {
    grid-column: 1;
    grid-row: 2;
  }

  .stage-frame { max-width: 100%; }
  .stage-screen { min-height: 20rem; padding: var(--space-4); }

  .copy-block {
    min-height: 56svh;
    max-width: none;
    padding: var(--space-5) 0;
  }

  .close-inner { grid-template-columns: minmax(0, 1fr); }
  .close-chart { min-height: 11rem; }
  .home-topbar-chip { display: none; }
}

@media (max-width: 34rem) {
  .hero-actions { gap: var(--space-3); }
  .close-breakdown { gap: var(--space-5); }
}

/* ---------- Reduced motion ----------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  .hero-scroll-dot,
  .bubble.is-typing span {
    animation: none;
  }

  /* The stage stacking is handled by the html:not(.js-motion) rules above,
     which reduced-motion readers always match. */
  .copy-block { min-height: 0; }
}

html.home-static .copy-block {
  min-height: 0;
}
