/*
 * Design foundation for the AI Golf Coach site.
 *
 * WHY THIS FILE EXISTS. The site read as generated, and measuring it against three premium
 * product sites on 2026-11-14 said why in numbers: our headings ran 800/800/700 where theirs run
 * 300-500, our h3 was 16px (identical to body) so two sizes did the work of five, and one page
 * carried 1,126 words down 26,983px of scroll. See docs/design/website-design-principles.md.
 *
 * The fix is a scale, not a palette. Size carries hierarchy; weight almost never does.
 *
 * CORRECTION, 2026-11-15. An earlier note here said fonts/manrope-latin.woff2 was subset to the
 * weight axis 500-800, so display type could not go lighter than 500, and called re-subsetting
 * it "the single change that would move this furthest". That was wrong, and the font file says
 * so: its wght axis runs 200-800. The 500 floor came from the @font-face DECLARATION in
 * styles.css, which clamped the range the browser would use. One line, not a font-file job.
 * Display type now runs at 300-400, like the comparisons do.
 */

:root {
  /* Palette: every value mirrors a token the app serves in globals.css, which
     tests/marketing-copy-contract.spec.ts verifies. A new colour has to be added to the app
     first. */
  --background: hsl(42 32% 96%);
  --surface: hsl(0 0% 100%);
  --foreground: hsl(214 28% 16%);
  --foreground-secondary: hsl(216 14% 34%);
  --muted-foreground: hsl(216 12% 40%);
  --accent: hsl(154 46% 35%);
  /* Accent text, not accent fill: the fill is 4.33:1 on the page background, below AA. This is
     the app's own --accent-hover at 5.44:1, and it doubles as the deep stop of the button
     gradient, because the site may not invent a colour the app does not serve. */
  --accent-text: hsl(154 48% 30%);
  --accent-soft: hsl(154 40% 95%);
  --line: hsl(38 24% 84%);

  /* Dark surfaces carry product imagery: an overlay on a swing frame needs to sit on something
     near-black or the lines wash out. Explanation stays on light. The alternation is the rhythm. */
  --ink: hsl(214 32% 9%);
  --ink-soft: hsl(214 26% 14%);
  --ink-line: hsl(214 20% 24%);
  /* --ink-line is 1.62:1 on --ink, which is fine for a card's edge and not for a control's.
     WCAG 1.4.11 wants 3:1 for the visual boundary of a UI component, and on a quiet button
     sitting on a dark band that border is the only thing saying "button". */
  --ink-line-strong: hsl(214 14% 42%);
  --on-ink: hsl(42 32% 96%);
  --on-ink-secondary: hsl(42 12% 72%);

  /*
   * TYPE SCALE. 1.333 from a 16px base, six steps, and nothing between them. The old file had
   * four steps with a 9px gap between heading and body, which is what flattened the page.
   *
   * Each step clamps so a phone gets a size that fits and a desktop gets presence. The minimum
   * of each clamp is the next step down, so the scale never collapses on a narrow screen.
   */
  --step-0: 1rem;                                           /* 16     body     */
  --step-1: clamp(1.1875rem, 1.1rem + 0.4vw, 1.3125rem);    /* 19-21  lead     */
  --step-2: clamp(1.4375rem, 1.3rem + 0.7vw, 1.75rem);      /* 23-28  h3       */
  --step-3: clamp(1.75rem, 1.5rem + 1.3vw, 2.375rem);       /* 28-38  h2       */
  --step-4: clamp(2.125rem, 1.7rem + 2.1vw, 3.125rem);      /* 34-50  h1       */
  --step-5: clamp(2.5rem, 1.9rem + 3.4vw, 4.5rem);          /* 40-72  hero     */
  --step-meta: 0.9375rem;                                   /* 15     captions */
  --step-micro: 0.8125rem;                                  /* 13     eyebrows */

  /* WEIGHT. Display type is light; size carries hierarchy. 300 for the hero, 400 for the rest,
     500 only where a heading sits on a dark panel and needs to hold its own. Nothing is 700+. */
  --weight-hero: 300;
  --weight-display: 400;
  --weight-strong: 500;

  /* Tracking tightens as size grows. Large type at normal tracking is the other half of why a
     page reads amateur: the letters drift apart and nothing holds together. */
  --track-display: -0.035em;
  --track-heading: -0.02em;
  --track-eyebrow: 0.09em;

  /* SPACE. Generous section padding is most of what separates designed from assembled. */
  --space-1: 0.5rem;
  --space-2: 1rem;
  --space-3: 1.5rem;
  --space-4: 2.5rem;
  --space-5: 4rem;
  --space-6: 6.5rem;
  --space-7: 9rem;

  /* RADIUS. One family, five steps. A premium page is consistent about its corners; mixing 8px
     and 24px in one card is the thing that reads as assembled from parts. */
  --radius-xs: 0.5rem;
  --radius-sm: 0.875rem;
  --radius-md: 1.25rem;
  --radius-lg: 1.75rem;
  --radius-xl: 2.25rem;
  --radius-pill: 999px;
  --radius: var(--radius-md);

  /* ELEVATION. Two soft layers rather than one hard one: a tight contact shadow that anchors the
     edge, and a wide diffuse one that lifts it. A single large blur reads as a drop shadow. */
  --shadow-sm: 0 1px 2px hsl(214 28% 16% / 0.05), 0 2px 8px -4px hsl(214 28% 16% / 0.12);
  --shadow-md: 0 1px 2px hsl(214 28% 16% / 0.05), 0 12px 32px -18px hsl(214 28% 16% / 0.25);
  --shadow-lg: 0 2px 4px hsl(214 28% 16% / 0.05), 0 28px 60px -28px hsl(214 28% 16% / 0.32);
  --shadow-ink: 0 2px 6px hsl(0 0% 0% / 0.3), 0 32px 70px -30px hsl(0 0% 0% / 0.65);
  --shadow: var(--shadow-md);

  /* MOTION. Short, and on an ease that decelerates: the difference between a button that
     responds and one that animates. Nothing here runs on scroll. */
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --fast: 120ms;
  --medium: 220ms;

  /* Measure. Body never wider than 68ch, a lead paragraph never wider than 54ch: beyond that the
     eye loses the line return and long-form copy stops being read. */
  --measure: 68ch;
  --measure-lead: 54ch;
  --page: 72rem;

  color-scheme: light;
}

/* ---------- type ---------- */

h1, h2, h3, h4, .display {
  font-family: 'Manrope', 'Manrope Fallback', system-ui, sans-serif;
  font-weight: var(--weight-display);
  letter-spacing: var(--track-heading);
  text-wrap: balance;
  margin: 0;
}

h1, .display {
  font-size: var(--step-4);
  line-height: 1.06;
  letter-spacing: var(--track-display);
}

.hero-title {
  font-size: var(--step-5);
  font-weight: var(--weight-hero);
  line-height: 1.02;
  letter-spacing: var(--track-display);
}

h2 {
  font-size: var(--step-3);
  line-height: 1.12;
  letter-spacing: var(--track-display);
}

h3 { font-size: var(--step-2); line-height: 1.22; }
h4 { font-size: var(--step-1); line-height: 1.35; font-weight: var(--weight-strong); }

.lead {
  font-size: var(--step-1);
  line-height: 1.52;
  text-wrap: pretty;
  max-width: var(--measure-lead);
  color: var(--foreground-secondary);
  font-weight: 400;
}

/* `text-wrap: pretty` on the body copy, and it is worth saying why it is free rather than a bet.
   An unsupported value for a known property is dropped at parse time, so there is no fallback to
   write, nothing to @supports and no CSP implication. Both reviewers checked support separately
   and agreed: WebKit shipped it in Safari 26 / iOS 26, Chrome has had it since 117, Firefox has
   not shipped it. For an iPhone-only product that ordering is the good one - WebKit's is the
   whole-paragraph implementation that fixes the rag across the block, where Chrome's own write-up
   says theirs currently only chases orphans. Older iOS wraps exactly as it does today.

   Do not pixel-compare the two engines. They are different algorithms and will not agree. */
p, li { font-size: var(--step-0); line-height: 1.62; max-width: var(--measure); text-wrap: pretty; }

.meta { font-size: var(--step-meta); color: var(--muted-foreground); }

/* An eyebrow names the section without competing with its heading. */
.eyebrow {
  display: block;
  font-family: 'Manrope', 'Manrope Fallback', system-ui, sans-serif;
  font-size: var(--step-micro);
  font-weight: var(--weight-strong);
  letter-spacing: var(--track-eyebrow);
  text-transform: uppercase;
  color: var(--accent-text);
  margin: 0 0 var(--space-2);
}

.section--ink .eyebrow { color: hsl(154 40% 62%); }

/* ---------- section rhythm ---------- */

/* One idea per section; if it needs two headings it is two sections. */
.section, section { padding-block: var(--space-5); }

@media (min-width: 48rem) {
  .section, section { padding-block: var(--space-6); }
}

.wrap { width: min(100% - 2rem, var(--page)); margin-inline: auto; }

/*
 * A dark section is where the product lives, because an overlay needs something to sit on.
 * The radial wash stops it reading as a flat black box, which is what a dark band does when it
 * is one colour.
 */
.section--ink {
  background:
    radial-gradient(90rem 40rem at 50% -10%, hsl(154 40% 24% / 0.5), transparent 60%),
    var(--ink);
  color: var(--on-ink);
}

.section--ink p,
.section--ink li,
.section--ink .lead,
.section--ink .meta { color: var(--on-ink-secondary); }

.section--ink h1,
.section--ink h2,
.section--ink h3,
.section--ink h4 { color: var(--on-ink); }

/* tokens.css recolours text on a dark section but never anchors, so a link kept --accent-text
   (3.0:1 on --ink) where a 16px link needs 4.5:1. */
.section--ink a { color: var(--on-ink); }

/* Which page you are on, said once. */
.site-header nav a[aria-current="page"] { color: var(--accent-text); }

/*
 * MOTION. Allowed only where it shows something: a button responding to a press, a swing
 * playing, an overlay arriving. Nothing moves on scroll because it can. One query removes all.
 */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ---------- flow ---------- */

/*
 * EVERY HEADING ON THE SITE WAS TOUCHING THE PARAGRAPH UNDER IT.
 *
 * Headings are `margin: 0` (above) and `p` is `margin: 0 0 var(--space-2)` in the styles.css
 * reset, so the space between a heading and the sentence after it was literally zero. On the
 * home page that is four sections where the h2's descenders sit on the line of body text below,
 * and it is the first thing that reads as unset on a page whose type scale is otherwise careful.
 * It had been invisible because the hero gets its spacing from its own layout.
 *
 * A flow rule rather than a margin on every element: the gap belongs to the RELATIONSHIP between
 * two things, so it is declared once, between them.
 *
 * :is() and not :where() on both sides, and that is not a style choice. The first version used
 * :where(), which zeroes specificity - so the rule scored 0,0,0 and lost to `p { margin: 0 0 ...
 * }` in styles.css, which is a type selector at 0,0,1. It changed nothing, and the page heights
 * came back byte-identical, which is how it was caught. :is() takes the highest specificity of
 * its arguments, so this lands at 0,1,1 and beats the reset it is correcting.
 */
:is(h1, h2, h3, h4)
  + :is(p, ul, ol, dl, figure, details, blockquote, .lead, .cta-row, .device-row, .ticks) {
  margin-top: var(--space-3);
}

/* A heading that follows body copy needs more air above it than below it, or the page reads as
   one undifferentiated column. */
:is(p, ul, ol, figure, blockquote) + :is(h2, h3, h4) {
  margin-top: var(--space-4);
}
