/* =====================================================================
   FiThrive - website_fithrive
   Design tokens sourced from the app's palette.md (single source of truth).
   Brand: CTA yellow #E8A617 · dark bg #0D0E26 · text-on-yellow #201703.
   Typeface: Montserrat.
   ===================================================================== */

/* ---------- Design tokens ---------- */
:root {
  /* FiYellow - primary CTA */
  --fi-yellow-50:  #FDF6E8;
  --fi-yellow-100: #FAEDD1;
  --fi-yellow-200: #F6DBA2;
  --fi-yellow-300: #F1CA74;
  --fi-yellow-400: #EDB845;
  --fi-yellow-500: #E8A617; /* brand CTA */
  --fi-yellow-600: #BA8512;
  --fi-yellow-700: #8B640E;
  --fi-yellow-800: #5D4209;
  --fi-yellow-900: #2E2105;
  --fi-yellow-950: #201703; /* text/icon ON yellow */

  /* FiPurple - primary dark background */
  --fi-purple-50:  #ECEDF9;
  --fi-purple-100: #D9DAF2;
  --fi-purple-200: #B3B5E6;
  --fi-purple-300: #8C90D9;
  --fi-purple-400: #666BCC;
  --fi-purple-500: #4046BF;
  --fi-purple-600: #333899;
  --fi-purple-700: #262A73;
  --fi-purple-800: #191C4D;
  --fi-purple-900: #0D0E26; /* brand dark bg */
  --fi-purple-950: #090A1B; /* app background */

  /* Support hues */
  --fi-red-500:   #E91616;
  --fi-teal-500:  #37C8B2;
  --fi-green-500: #97D629;
  --fi-blue-500:  #224BDD;

  /* Neutral / support text */
  --fi-neutral-50:  #F1F1F4;
  --fi-neutral-100: #E3E3E8;
  --fi-neutral-200: #C8C6D2;
  --fi-neutral-300: #ACAABB;
  --fi-neutral-400: #908EA4;
  --fi-neutral-500: #75718E;

  /* ---- Semantic aliases (use these in components) ---- */
  --color-bg:            var(--fi-purple-950);
  --color-surface:       var(--fi-purple-900);
  --color-surface-hover: var(--fi-purple-800);
  --color-border:        var(--fi-purple-800);

  --color-cta:           var(--fi-yellow-500);
  --color-cta-hover:     var(--fi-yellow-400);
  --color-cta-on:        var(--fi-yellow-950); /* text on yellow */
  --color-accent:        var(--fi-yellow-500);

  --color-text:          #FFFFFF;
  --color-text-secondary: var(--fi-neutral-200);
  --color-text-muted:    var(--fi-neutral-400);

  /* Typography */
  --font-sans: 'Montserrat', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;

  /* Fluid type scale (min → max across viewport) */
  --fs-hero:  clamp(2.2rem, 9.7vw, 3.75rem);
  --fs-h2:    clamp(1.75rem, 4vw, 3rem);
  --fs-h3:    clamp(1.25rem, 2.5vw, 1.75rem);
  --fs-body:  clamp(1rem, 1.2vw, 1.125rem);
  --fs-small: 0.875rem;

  /* Layout */
  --container-max: 1200px;
  --gutter: clamp(1.5rem, 8vw, 3rem);   /* generous inset - matches the Figma frame */
  --section-gap: clamp(4rem, 10vw, 8rem);
  --radius: 14px;
  --radius-lg: 24px;

  /* Motion */
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  font-family: var(--font-sans);
  font-size: var(--fs-body);
  line-height: 1.6;
  color: var(--color-text);
  /* Base dark purple + soft brand glow behind the hero (top-center). */
  background:
    radial-gradient(115% 60% at 50% -6%,
      rgba(64, 70, 191, 0.38) 0%,
      rgba(38, 42, 115, 0.14) 32%,
      rgba(13, 14, 38, 0) 60%),
    var(--fi-purple-900);
  background-repeat: no-repeat;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

img, picture, svg, video { display: block; max-width: 100%; height: auto; }

a { color: inherit; text-decoration: none; }

button { font: inherit; color: inherit; cursor: pointer; border: none; background: none; }

h1, h2, h3 { line-height: 1.1; font-weight: 800; letter-spacing: -0.02em; }

:focus-visible { outline: 2px solid var(--color-cta); outline-offset: 3px; border-radius: 4px; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* ---------- Layout helpers ---------- */
.container {
  width: 100%;
  max-width: var(--container-max);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.section { padding-block: var(--section-gap); }

.accent { color: var(--color-accent); }

.eyebrow {
  font-size: var(--fs-small);
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--color-cta);
}

/* ---------- Buttons (palette Rule 1 & 2: solid yellow, #201703 text, no gradient) ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.85rem 1.6rem;
  border-radius: 999px;              /* pill, per the Figma frame */
  font-weight: 700;
  font-size: 1rem;
  line-height: 1;
  transition: transform 0.15s var(--ease), background-color 0.15s var(--ease), border-color 0.15s var(--ease);
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }

/* Smaller pill used in the header */
.btn--sm { padding: 0.6rem 1.2rem; font-size: 0.95rem; }

.btn--solid {
  background: var(--color-cta);
  color: var(--color-cta-on);       /* #201703 on yellow */
}
.btn--solid:hover { background: var(--color-cta-hover); }

.btn--outline {
  background: transparent;
  color: var(--color-cta);          /* yellow text + yellow border */
  border: 1.5px solid var(--color-cta);
}
.btn--outline:hover { background: color-mix(in srgb, var(--color-cta) 12%, transparent); }

/* ---------- Header ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: transparent;
  border-bottom: 1px solid transparent;
  transition: transform 0.3s var(--ease),
              background-color 0.25s var(--ease),
              border-color 0.25s var(--ease);
}
/* Solid, blurred infill + divider once the page is scrolled (added by main.js) */
.site-header.is-scrolled {
  background: rgba(13, 14, 38, 0.9);   /* fallback for browsers without color-mix */
  background: color-mix(in srgb, var(--color-surface) 88%, transparent);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  border-bottom-color: var(--color-border);
}
/* Slide out of view on scroll-down, back in on scroll-up (toggled by main.js) */
.site-header.is-hidden { transform: translateY(-100%); }

/* On legal pages there is no hero to float over, so keep the header solid at ALL times.
   This guarantees the infill + divider even before any scroll and even if JS is unavailable;
   the hide-on-scroll behaviour still applies on top via .is-hidden. */
.legal-page .site-header {
  background: rgba(13, 14, 38, 0.92);
  background: color-mix(in srgb, var(--color-surface) 90%, transparent);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  border-bottom-color: var(--color-border);
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 68px;
  padding-block: 0.5rem;
}
.brand { display: inline-flex; align-items: center; }
.brand-logo { height: 30px; width: auto; }

.header-actions { display: flex; align-items: center; gap: 0.75rem; }

/* Hamburger (mobile-only build: always visible) */
.menu-toggle {
  display: inline-flex;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 40px; height: 40px;
  padding: 9px 8px;
}
.menu-toggle .bar {
  height: 2.5px; width: 100%;
  background: var(--color-text);
  border-radius: 2px;
  transition: transform 0.25s var(--ease), opacity 0.2s var(--ease);
}

/* Mobile drawer */
.drawer-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  opacity: 0; visibility: hidden;
  transition: opacity 0.25s var(--ease), visibility 0.25s var(--ease);
  z-index: 200;
}
.drawer-backdrop.open { opacity: 1; visibility: visible; }

.drawer {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: min(320px, 82vw);
  background: var(--color-surface);
  border-left: 1px solid var(--color-border);
  transform: translateX(100%);
  transition: transform 0.3s var(--ease);
  z-index: 201;
  display: flex; flex-direction: column;
  padding: 1.25rem var(--gutter) 2rem;
}
.drawer.open { transform: translateX(0); }
.drawer-head { display: flex; justify-content: flex-end; }
.drawer-close { width: 44px; height: 44px; font-size: 1.5rem; line-height: 1; }
.drawer nav { display: flex; flex-direction: column; gap: 0.25rem; margin-top: 1rem; }
.drawer nav a {
  padding: 0.9rem 0.25rem;
  font-weight: 600;
  border-bottom: 1px solid var(--color-border);
}
.drawer .btn { margin-top: 1.5rem; }

/* ---------- Hero ---------- */
.hero {
  position: relative;
  padding-top: clamp(3rem, 12vw, 5rem);
  padding-bottom: clamp(3.5rem, 14vw, 6rem);
  overflow: hidden;
}
.hero__title {
  font-size: var(--fs-hero);
  font-weight: 800;
  max-width: 14ch;
}
.hero__subtitle {
  margin-top: 1.5rem;
  font-size: var(--fs-body);
  color: var(--color-text-secondary);
  max-width: 42ch;
}
.hero__actions {
  display: flex;
  flex-wrap: wrap;      /* one row at phone widths; wraps only on very narrow screens */
  gap: 0.6rem;
  margin-top: 2.25rem;
}
/* Slightly tighter pills so both fit side-by-side on one row, per the frame */
.hero__actions .btn { padding: 0.8rem 1.2rem; }

/* ---------- Leaf discovery (chaos story) ---------- */
.leaf-story { position: relative; }

/* Tall track defines how long the stage stays pinned; ~one leaf per --reveal of scroll. */
.leaf-story__track {
  --reveal: 42vh;
  position: relative;
  height: calc(100vh + 7 * var(--reveal));
}
.leaf-story__stage {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: hidden;               /* clips any stray caption; prevents horizontal scroll */
}
.leaf-field {
  position: relative;
  width: 100%;
  max-width: 480px;
  height: 100%;
  margin-inline: auto;
}

.leaf {
  position: absolute;
  left: var(--x);
  top: var(--y);
  --s: 1;
  --ty: 0px;
  transform: translate(-50%, calc(-50% + var(--ty))) scale(var(--s));
  z-index: 2;
  transition: opacity 0.6s var(--ease), transform 0.7s var(--ease), filter 0.6s var(--ease);
  will-change: transform, opacity;
}
/* Rotation lives on the icon only, so captions stay upright/level. */
.leaf__icon {
  height: var(--size);
  width: auto;
  aspect-ratio: 63.73 / 92.33;
  fill: var(--color-cta);
  transform: rotate(var(--rot));
  transition: filter 0.6s var(--ease);
}
.leaf__cap {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  white-space: nowrap;
  /* Grows with the leaf, so the text scales alongside the gradually bigger icons. */
  font-size: calc(0.8rem + var(--size) * 0.06);
  font-weight: 600;
  color: var(--color-text);
  pointer-events: none;
}
.leaf__cap--right { left: 100%;  margin-left: 0.6rem; }
.leaf__cap--left  { right: 100%; margin-right: 0.6rem; text-align: right; }
.leaf__cap--below {
  top: 100%; left: 50%;
  transform: translate(-50%, 0);
  margin-top: 0.6rem;
  text-align: center;
  font-weight: 800;          /* bold - this is the transition line into the payoff */
}

/* When JS is active, leaves start hidden and are revealed one-by-one via state classes.
   Without JS (or with reduced motion) they all stay visible - the fallback below. */
.leaf-story.is-interactive .leaf            { opacity: 0;    --s: 0.62; --ty: 22px; }
.leaf-story.is-interactive .leaf.is-hidden  { opacity: 0;    --s: 0.62; --ty: 22px; }
.leaf-story.is-interactive .leaf.is-seen    { opacity: 0.5;  --s: 0.9;  --ty: 0px; z-index: 2; }
.leaf-story.is-interactive .leaf.is-active  { opacity: 1;    --s: 1.1;  --ty: 0px; z-index: 5; }

/* Seen leaves fall "into the shade"; the active one stays full-brightness and forward. */
.leaf-story.is-interactive .leaf.is-seen   .leaf__icon { filter: brightness(0.82) saturate(0.95); }
.leaf-story.is-interactive .leaf.is-active .leaf__icon { filter: none; }

/* ---------- One platform (payoff heading) ---------- */
.one-platform {
  text-align: center;
  padding-top: clamp(1rem, 4vw, 3rem);
  padding-bottom: clamp(4rem, 12vw, 7rem);
}
/* Centered final leaf - biggest of all, pointing straight down into the heading. */
.one-platform__leaf {
  display: block;
  height: clamp(130px, 36vw, 165px);
  width: auto;
  aspect-ratio: 63.73 / 92.33;
  fill: var(--color-cta);
  margin: 0 auto clamp(2rem, 7vw, 3.25rem);   /* more breathing room before the heading */
}
.one-platform__title {
  font-size: var(--fs-hero);
  font-weight: 800;
  line-height: 1.12;
  max-width: 12ch;
  margin-inline: auto;
}

/* ---------- Footer ---------- */
.site-footer {
  border-top: 1px solid var(--color-border);
  padding-block: clamp(2.5rem, 6vw, 4rem);
  color: var(--color-text-muted);
  font-size: var(--fs-small);
}
.footer-inner {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem 3rem;
  justify-content: space-between;
  align-items: center;
}
.footer-links { display: flex; flex-wrap: wrap; gap: 1.25rem; }
.footer-links a { color: var(--color-text-secondary); transition: color 0.15s var(--ease); }
.footer-links a:hover { color: var(--color-text); }
