/* ==========================================================================
   Ripple Motions type + spacing system. Loaded LAST on every page.
   Lives in a cascade layer with !important, so it beats every font-size,
   font-weight and hero/section spacing rule in page CSS. Page CSS may only
   set colour and layout.

   FIVE text styles on every page (size + weight = one style):
     1 Display   h1                                   64 / 600   (mobile 40)
     2 Heading   h2, big result numbers               44 / 600   (mobile 32)
     3 Title     h3, card titles, names, questions,   20 / 600   (mobile 18)
                 links, bold (buttons use Body)
     4 Body      every paragraph, list, statement,    20 / 400   (mobile 18)
                 quote, nav link, form field
     5 Small     roles, follower counts, captions,    17 / 400   (mobile 16)
                 footer legal, meta
   Rule: bigger = more important. A detail is never bigger than the thing
   it belongs to. Every body text on the site is the same size.

   Spacing: 8px scale only (8 16 24 32 40 48 64 96 128).
     Page top (first section)  120px  (mobile 72)   same on every page
     Section padding           128px  (mobile 80)
     Heading -> its paragraph   24px
     Section head -> content    64px  (mobile 40)
     Inside a group < between groups.
   ========================================================================== */
:root {
  --t1: clamp(2.5rem, 4.6vw, 4rem);
  --t2: clamp(2rem, 3.2vw, 2.75rem);
  --t3: 1.25rem;
  --t4: 1.25rem;
  --t5: 1.0625rem;
  --sec: 88px;
  --top: 96px;
  --gap-head: 48px;
}
@media (max-width: 720px) {
  :root { --t1: 2.5rem; --t2: 2rem; --t3: 1.125rem; --t4: 1.125rem; --t5: 1rem; --sec: 60px; --top: 56px; --gap-head: 32px; }
}

@layer rm-system {

  /* ---------- 4 · Body: default for EVERY element ---------- */
  body, body * {
    font-size: var(--t4) !important; font-weight: 400 !important;
    line-height: 1.6 !important; letter-spacing: -0.01em !important;
  }

  /* ---------- 3 · Title ---------- */
  body :is(h3, h4, h5, h6, b, strong, dt, th, summary, label, .link, .step, .h3-bridge,
           .cx-back, .ct-soc a, .fq-ask b),
  body :is(h3, h4, summary, b, strong, .link) * {
    font-size: var(--t3) !important; font-weight: 600 !important;
    line-height: 1.4 !important; letter-spacing: -0.015em !important;
  }

  /* buttons: Body weight (Ryan: bold buttons read too heavy) */
  body :is(.btn, button, .btn *, button *) { font-size: var(--t4) !important; font-weight: 400 !important; line-height: 1.4 !important; }

  /* ---------- 2 · Heading ---------- */
  body :is(h2, .big, .hx-facts4 strong, .ab-stats strong, .nums b, .facts strong, .r2-facts b,
           .r2-wide-stats b, .r2-cards .body > strong, .h3-stats strong, .h5-stats strong, .cx-stat .v, .hx-case .big,
           .hx-avatars strong, .hx-proofs strong),
  body :is(h2, .cx-stat .v, .h3-stats strong) * {
    font-size: var(--t2) !important; font-weight: 600 !important;
    line-height: 1.12 !important; letter-spacing: -0.035em !important;
  }

  /* ---------- 1 · Display ---------- */
  body h1, body h1 * {
    font-size: var(--t1) !important; font-weight: 600 !important;
    line-height: 1.06 !important; letter-spacing: -0.04em !important;
  }

  /* ---------- 5 · Small (details only) ---------- */
  body :is(small, figcaption, .role, .meta, .legal, .legal *, .frame-bar, .frame-bar *, .hero-note, .hero-note *,
           .client span, .client span *, .tv-card span, .tv-card > span, .tv-meta, .rv-q figcaption span,
           .h3-names span, .h5-people span, .r2-cards h3 span, .cx-by, .cx-by *, .emailed, .ct-form label span,
           .ab-team .role, .cite, .cite small, .hx-avatars span) {
    font-size: var(--t5) !important; font-weight: 400 !important;
    line-height: 1.5 !important; letter-spacing: 0 !important;
  }
  /* a name inside a small caption row stays a Title */
  body :is(figcaption b, .cx-by b, .rv-q figcaption b) {
    font-size: var(--t3) !important; font-weight: 600 !important; line-height: 1.4 !important; letter-spacing: -0.015em !important;
  }
  body .cx-by b { display: block; }
  /* home case cards: client name is a small label so the headline leads */
  /* case cards: headline = section heading (t2), context = body (t4), name/role = small (t5) */
  body .h3-cases .card h3 { font-size: var(--t2) !important; font-weight: 600 !important; line-height: 1.1 !important; letter-spacing: -0.035em !important; }
  body .h3-cases .card .cc > p { font-size: var(--t4) !important; font-weight: 400 !important; }
  body .h3-cases .client span { font-size: var(--t5) !important; }
  body .h3-cases .client b { font-size: var(--t5) !important; font-weight: 600 !important; line-height: 1.4 !important; letter-spacing: -0.01em !important; }
  /* legal pages: 15 numbered sections read as Titles, not Headings */
  body .lg-body h2 { font-size: var(--t3) !important; font-weight: 600 !important; line-height: 1.4 !important; letter-spacing: -0.015em !important; }
  /* results portrait card: the client name is a Heading on the photo fade */
  body .r3-who figcaption b { font-size: var(--t2) !important; font-weight: 600 !important; line-height: 1.05 !important; letter-spacing: -0.035em !important; }
  @media (max-width: 720px) {
    body .r3-case .r3-who figcaption b { font-size: var(--t3) !important; line-height: 1.3 !important; letter-spacing: -0.01em !important; }
    body .r3-case .r3-who figcaption span { font-size: var(--t5) !important; }
    body .r3-case .r3-nums b { font-size: var(--t2) !important; font-weight: 600 !important; line-height: 1.1 !important; letter-spacing: -0.03em !important; }
    body .r3-case .r3-nums span { font-size: var(--t5) !important; line-height: 1.4 !important; }
  }

  /* ---------- Spacing: page top is identical on every page ---------- */
  body main > :first-child:is(.h3-hero, .r3-hero, .ab-hero, .fq, .ct, .cs-hero) {
    padding-top: var(--top) !important;
  }
  body :is(.h3-hero, .r3-hero, .ab-hero) { padding-bottom: 72px !important; text-align: left !important; }
  body :is(.fq, .ct) { padding-bottom: var(--sec) !important; }
  body .cs-hero { padding-bottom: 48px !important; }

  /* every hero: h1 -> lede 24px, lede -> actions 40px, same widths */
  body :is(.h3-hero, .r3-hero, .ab-hero, .cs-hero) h1 { margin: 0 !important; max-width: 820px !important; text-align: left !important; }
  body :is(.h3-lede, .r3-lede, .ab-hero .sub, .fq-side > p, .ct-intro, .cs-hero .sub) {
    margin: 24px 0 0 !important; max-width: 40ch !important; text-align: left !important;
  }
  body :is(.h3-actions, .ab-hero .acts) { margin-top: 40px !important; justify-content: flex-start !important; }

  /* one section rhythm */
  body :is(.section, .h3-sec, .r3-case, .r3-sec, .ab-sec, .ab-mission, .ab-cta, .cta.r2-c1, .hm-cta, .cs-cta) {
    padding-top: var(--sec) !important; padding-bottom: var(--sec) !important;
  }
  /* section heads: heading -> paragraph 24px, head -> content 64px */
  body :is(.h3-head, .tv-head, .head) { margin-bottom: var(--gap-head) !important; }
  body :is(.h3-head, .tv-head, .head, .ab-story, .h3-split, .r3-copy) h2 { margin: 0 !important; }
  body :is(.h3-head, .tv-head, .head) h2 + p,
  body :is(.ab-story, .h3-split) h2 + p { margin-top: 24px !important; }
  body .r3-copy h2 { margin-bottom: 24px !important; }
  body .h3-bridge { margin-top: var(--gap-head) !important; }

  /* case pages: back link sits above the hero line so the h1 lands where every other page's h1 does */
  body .cs-hero { position: relative !important; }
  body .cs-hero .cx-back { position: absolute !important; top: calc(var(--top) - 48px) !important; margin: 0 !important; }
  body .cs-top { align-items: start !important; }
  body .cs-top h1 .name { display: block !important; color: var(--ink-3) !important; margin: 0 0 16px !important; font-size: var(--t3) !important; font-weight: 600 !important; line-height: 1.3 !important; letter-spacing: -0.01em !important; }
  @media (max-width: 900px) { body .cs-portrait { order: 2 !important; } }
  @media (max-width: 720px) {
    /* results on phones: cases read as one list of cards, not five full-height sections */
    html body .r3-case.r3-case { padding-top: 8px !important; padding-bottom: 8px !important; }
    html body .r3-hero + .r3-case.r3-case { padding-top: 24px !important; }
    html body .r3-case.r3-case:has(+ :not(.r3-case)) { padding-bottom: var(--sec) !important; }
  }
  @media (max-width: 720px) { body :is(.h3-hero, .r3-hero, .ab-hero) { padding-bottom: 48px !important; } body .cs-hero { padding-bottom: 32px !important; } }

  /* batch67: home 'Not your typical agency' on phones: our side reads first, theirs is quiet */
  @media (max-width: 900px) {
    body .h5-vs .them { font-size: var(--t5) !important; color: var(--ink-3); }
    body .h5-vs .us { font-weight: 600 !important; color: var(--ink); }
  }
}
