/* ==========================================================================
   DRIPMAX — LEGAL & SUPPORT PAGES
   assets/css/legal.css · loads AFTER assets/css/styles.css
   Owner: ui-styling agent · Implements docs/legal-ux-spec.md verbatim.

   NOTHING here redefines a token, .shell, .nav, .foot, .btn, .sr-only,
   .skip-link, .eyebrow or the global prefers-reduced-motion block. Every
   colour, size, radius, duration and easing below is an existing token.

   Layer strategy: styles.css declares
     @layer reset, tokens, base, components, responsive, focus, motion;
   Rules below are appended to `components` (so they beat base/components in
   styles.css) and to `focus` (for the two deliberate focus overrides).
   @media print is intentionally UNLAYERED so it wins over everything.
   ========================================================================== */

/* --------------------------------------------------------------------------
   0 · THE THREE NEW TOKENS (spec §0.1) — plus the shared chevron mask (§C.4)
   -------------------------------------------------------------------------- */
:root {
  --legal-measure:    68ch;                                              /* §A.1 */
  --legal-body-size:  clamp(1.0625rem, 1.0185rem + 0.1878vw, 1.1250rem); /* 17 → 18px */
  --legal-anchor-off: calc(var(--nav-h) + 1.5rem);                       /* 88px / 96px §B.5 */

  --chevron: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="black" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round"><path d="M6 9l6 6 6-6"/></svg>');
}

@layer components {

  /* ========================================================================
     1 · PAGE SHELL & LAYOUT (spec §G)
     ======================================================================== */

  .legal {
    padding-block: var(--space-8) var(--space-20);   /* 32px / 80px */
  }

  /* 375 + 768: single column. The grid arrives at 1024 (§B.2). */
  .legal-shell {
    display: block;
  }

  /* Anchor offsets — every jump target clears the sticky nav (§B.5):
     88px below 1024, 96px at and above.

     Only ONE of scroll-padding / scroll-margin may carry the offset: a browser
     applies both, so declaring the spec's per-element `scroll-margin` *and* the
     `html` `scroll-padding` lands every fragment at 2 × 96px = 192px. Verified
     in Chromium. `scroll-padding` on the scrollport is the one that also covers
     Tab-driven scroll and find-in-page, so it is the primary; the per-element
     `scroll-margin` is kept purely as the `:has()`-less fallback the spec asks
     to stand alone. */
  html:has(body.legal-page) {
    scroll-padding-block-start: var(--legal-anchor-off);
    /* Cold-load deep-links (/terms#s6) are broken by the global smooth scroll:
       the animation starts against the pre-webfont layout and keeps travelling
       to a stale offset, landing 200–400px past the clause. Verified in
       Chromium. An instant jump also honours §H.12 — smooth-scrolling 4000px
       through a contract is decorative motion. */
    scroll-behavior: auto;
  }
  /* styles.css gives #main an 80px scroll-margin for the landing page; it would
     stack on top of the scroll-padding above. */
  .legal-page #main { scroll-margin-block-start: 0; }

  @supports not selector(:has(*)) {
    .legal-page :is(#main, .legal-head, .legal-toc, .legal-aside,
                    .legal-body section, .faq-item, .faq-cluster) {
      scroll-margin-block-start: var(--legal-anchor-off);
    }
  }

  /* ========================================================================
     2 · BREADCRUMB (spec §D.3)
     ======================================================================== */

  .legal-crumb {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0 var(--space-2);
    margin: 0;
    padding: 0;
    font-size: 0.875rem;                              /* 14px */
    line-height: 1.4;
    color: var(--text-muted);
  }
  .legal-crumb a {
    display: inline-flex;
    align-items: center;
    min-height: var(--touch-min);                     /* 44px */
    color: var(--text-muted);
    text-decoration: none;
    touch-action: manipulation;
    transition: var(--transition-color);
  }
  .legal-crumb a:hover {
    color: var(--text-accent);
    text-decoration: underline;
    text-underline-offset: 0.18em;
  }
  .legal-crumb > span[aria-hidden="true"] { color: var(--border-strong); }
  .legal-crumb [aria-current="page"]      { color: var(--text-secondary); }

  /* ========================================================================
     3 · PAGE HEAD (spec §A.4, §H.19)
     ======================================================================== */

  .legal-head {
    margin-block: var(--space-4) var(--space-10);     /* 16px / 40px */
    max-width: var(--legal-measure);
  }
  .legal-head .eyebrow { margin-block-end: var(--space-3); }

  .legal-title {
    font-family: var(--dm-font-display);
    font-weight: var(--dm-weight-800);
    font-size: clamp(2rem, 1.6rem + 1.7vw, 2.75rem);  /* 32 → 44px */
    line-height: 1.06;
    letter-spacing: var(--tracking-display-lg);
    color: var(--text-primary);
    margin: 0;
    text-wrap: balance;
  }

  /* The effective date is the second-most-checked fact on the page — 15px,
     --text-muted (5.05:1), never smaller, never hidden (§H.19). */
  .legal-date {
    margin: var(--space-3) 0 0;
    font-size: 0.9375rem;                             /* 15px */
    line-height: 1.5;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
  }
  .legal-date time { color: inherit; }

  .legal-lede {
    margin: var(--space-4) 0 0;
    max-width: 52ch;
    font-family: var(--dm-font-body);
    font-size: var(--font-size-body-lg);              /* 17 → 19px */
    font-weight: var(--dm-weight-400);
    line-height: var(--leading-relaxed);
    letter-spacing: var(--tracking-body);
    color: var(--text-secondary);
    text-wrap: pretty;
  }

  /* ========================================================================
     4 · TABLE OF CONTENTS (spec §B)
     ======================================================================== */

  /* --- 4.1 the container: a card on mobile, a bare rail at ≥1024 (§B.8) --- */
  .legal-toc {
    margin-block: 0 var(--space-8);                   /* 32px */
    border: 1px solid var(--border-hairline);
    border-radius: var(--radius-md);                  /* 18px */
    background: var(--surface-raised);
  }

  .legal-toc-d { margin: 0; }

  /* --- 4.2 the summary ---------------------------------------------------- */
  .legal-toc-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
    min-height: 3.25rem;                              /* 52px */
    padding: var(--space-3) var(--space-4);
    list-style: none;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    font-family: var(--dm-font-body);
    font-weight: var(--dm-weight-700);
    font-size: 0.9375rem;
    line-height: 1.3;
    letter-spacing: 0.02em;
    color: var(--text-primary);
  }
  .legal-toc-title::-webkit-details-marker { display: none; }

  /* --- 4.3 the index (§A.5) ---------------------------------------------- */
  .legal-toc ol {
    list-style: none;
    margin: 0;
    padding: 0 var(--space-2) var(--space-3);
    font-variant-numeric: tabular-nums;
  }

  .legal-toc li {
    display: grid;
    grid-template-columns: minmax(0, 1fr);            /* /support: no number */
    align-items: start;
    border-inline-start: 3px solid transparent;
    border-radius: 0 var(--radius-xs) var(--radius-xs) 0;
    transition: var(--transition-color);
  }
  /* 28px right-aligned number gutter so every clause title starts at one x. */
  .legal-toc li:has(> .legal-toc-num) {
    grid-template-columns: 1.75rem minmax(0, 1fr);
    column-gap: var(--space-1);
  }

  .legal-toc-num {
    padding-block: var(--space-2);
    padding-inline: 0;
    text-align: right;
    font-size: 0.9375rem;
    line-height: 1.35;
    font-weight: var(--dm-weight-500);
    color: var(--text-muted);
    transition: var(--transition-color);
  }
  /* The verbatim period lives in the heading, not here — draw it in CSS so the
     index reads "1." while the DOM text stays the bare numeral. Decorative. */
  .legal-toc-num::after { content: "."; }

  .legal-toc li a {
    display: block;
    min-height: var(--touch-min);                     /* 44px on touch */
    padding: var(--space-2) var(--space-3) var(--space-2) var(--space-1);
    font-size: 0.9375rem;
    line-height: 1.35;
    color: var(--text-secondary);
    text-decoration: none;
    touch-action: manipulation;
    overflow-wrap: break-word;
    transition: var(--transition-color);
  }

  .legal-toc li:hover { background: var(--dm-a-crimson-12); }
  .legal-toc li:hover > a,
  .legal-toc li:hover > .legal-toc-num { color: var(--text-accent); }

  /* --- 4.4 chevron (§C.4) ------------------------------------------------- */
  .legal-toc-title::after,
  .faq-q::after {
    content: "";
    flex: 0 0 1.25rem;
    inline-size: 1.25rem;
    block-size: 1.25rem;                              /* 20px */
    background-color: var(--text-accent);
    -webkit-mask: var(--chevron) center / contain no-repeat;
            mask: var(--chevron) center / contain no-repeat;
    transition: transform var(--duration-fast) var(--ease-std);
  }
  .legal-toc-d[open] > .legal-toc-title::after,
  .faq-item[open]   > .faq-q::after { transform: rotate(180deg); }

  /* --- 4.5 JS-free active item — the :target chain (§B.4) -----------------
     Three cues: colour, tint, and a 3px inline-start rule. Never colour alone.
     s1–s16 covers all four pages (/terms is the longest at 16). No JS,
     no scroll-spy, no aria-current. */
  body:has(#s1:target)  .legal-toc li:has(> a[href="#s1"]),
  body:has(#s2:target)  .legal-toc li:has(> a[href="#s2"]),
  body:has(#s3:target)  .legal-toc li:has(> a[href="#s3"]),
  body:has(#s4:target)  .legal-toc li:has(> a[href="#s4"]),
  body:has(#s5:target)  .legal-toc li:has(> a[href="#s5"]),
  body:has(#s6:target)  .legal-toc li:has(> a[href="#s6"]),
  body:has(#s7:target)  .legal-toc li:has(> a[href="#s7"]),
  body:has(#s8:target)  .legal-toc li:has(> a[href="#s8"]),
  body:has(#s9:target)  .legal-toc li:has(> a[href="#s9"]),
  body:has(#s10:target) .legal-toc li:has(> a[href="#s10"]),
  body:has(#s11:target) .legal-toc li:has(> a[href="#s11"]),
  body:has(#s12:target) .legal-toc li:has(> a[href="#s12"]),
  body:has(#s13:target) .legal-toc li:has(> a[href="#s13"]),
  body:has(#s14:target) .legal-toc li:has(> a[href="#s14"]),
  body:has(#s15:target) .legal-toc li:has(> a[href="#s15"]),
  body:has(#s16:target) .legal-toc li:has(> a[href="#s16"]) {
    background: var(--surface-accent-soft);
    border-inline-start-color: var(--dm-crimson);
  }

  body:has(#s1:target)  .legal-toc li:has(> a[href="#s1"])  > :is(a, .legal-toc-num),
  body:has(#s2:target)  .legal-toc li:has(> a[href="#s2"])  > :is(a, .legal-toc-num),
  body:has(#s3:target)  .legal-toc li:has(> a[href="#s3"])  > :is(a, .legal-toc-num),
  body:has(#s4:target)  .legal-toc li:has(> a[href="#s4"])  > :is(a, .legal-toc-num),
  body:has(#s5:target)  .legal-toc li:has(> a[href="#s5"])  > :is(a, .legal-toc-num),
  body:has(#s6:target)  .legal-toc li:has(> a[href="#s6"])  > :is(a, .legal-toc-num),
  body:has(#s7:target)  .legal-toc li:has(> a[href="#s7"])  > :is(a, .legal-toc-num),
  body:has(#s8:target)  .legal-toc li:has(> a[href="#s8"])  > :is(a, .legal-toc-num),
  body:has(#s9:target)  .legal-toc li:has(> a[href="#s9"])  > :is(a, .legal-toc-num),
  body:has(#s10:target) .legal-toc li:has(> a[href="#s10"]) > :is(a, .legal-toc-num),
  body:has(#s11:target) .legal-toc li:has(> a[href="#s11"]) > :is(a, .legal-toc-num),
  body:has(#s12:target) .legal-toc li:has(> a[href="#s12"]) > :is(a, .legal-toc-num),
  body:has(#s13:target) .legal-toc li:has(> a[href="#s13"]) > :is(a, .legal-toc-num),
  body:has(#s14:target) .legal-toc li:has(> a[href="#s14"]) > :is(a, .legal-toc-num),
  body:has(#s15:target) .legal-toc li:has(> a[href="#s15"]) > :is(a, .legal-toc-num),
  body:has(#s16:target) .legal-toc li:has(> a[href="#s16"]) > :is(a, .legal-toc-num) {
    color: var(--text-accent);
  }

  /* ========================================================================
     5 · THE DOCUMENT BODY (spec §A)
     ======================================================================== */

  .legal-body {
    overflow-wrap: break-word;
    font-family: var(--dm-font-body);
    font-size: var(--legal-body-size);                /* 17 → 18px */
    font-weight: var(--dm-weight-400);
    line-height: var(--leading-relaxed);              /* 1.66 */
    letter-spacing: var(--tracking-body);
    color: var(--text-primary);
  }

  /* --- 5.1 measure — on the CHILDREN, never on .legal-body (§A.1) --------- */
  .legal-body > section > :where(p, ul, ol, blockquote, dl, .legal-note, .legal-contact),
  .legal-body > :where(p, ul, ol, blockquote, dl) {
    max-width: var(--legal-measure);
  }

  /* --- 5.2 clause separation: 80px above / 12px below + hairline (§A.4) --- */
  .legal-body section + section {
    margin-block-start: var(--space-8);               /* 32px — 64px total */
    padding-block-start: var(--space-8);
    border-block-start: 1px solid var(--border-hairline);
  }

  /* --- 5.3 headings ------------------------------------------------------- */
  .legal-body h2 {
    font-family: var(--dm-font-display);
    font-weight: var(--dm-weight-700);
    font-size: clamp(1.375rem, 1.2rem + 0.75vw, 1.625rem);  /* 22 → 26px */
    line-height: 1.22;
    letter-spacing: var(--tracking-heading-lg);
    font-variant-numeric: tabular-nums;               /* "1." and "16." align */
    color: var(--text-primary);
    margin: 0 0 var(--space-3);                       /* 12px to first para */
    text-wrap: balance;
  }
  .legal-body h3 {
    font-family: var(--dm-font-body);
    font-weight: var(--dm-weight-700);
    font-size: clamp(1.125rem, 1.05rem + 0.3vw, 1.25rem);   /* 18 → 20px */
    line-height: 1.30;
    letter-spacing: var(--tracking-heading-sm);
    font-variant-numeric: tabular-nums;
    color: var(--text-primary);
    margin: var(--space-7) 0 var(--space-2);
    text-wrap: balance;
  }

  /* --- 5.4 paragraph and list rhythm (§A.3, §A.5) ------------------------- */
  .legal-body p {
    margin: 0 0 1.2em;
    color: var(--text-primary);
    text-wrap: pretty;
  }
  .legal-body p:last-child { margin-block-end: 0; }

  .legal-body p + ul,
  .legal-body p + ol { margin-block-start: 0.35em; }

  /* The reset layer sets `ul, ol { list-style: none }` for the landing page's
     nav/feature lists. Operative enumerations in a contract must show their
     markers, so they are restored explicitly here. */
  .legal-body ul, .faq-a ul { list-style: disc; }
  .legal-body ol, .faq-a ol { list-style: decimal; }
  .legal-body li > ul       { list-style: circle; }

  .legal-body :is(ul, ol) {
    margin: 0 0 1.2em;
    padding-inline-start: 1.25rem;                    /* 20px below 768 */
  }
  .legal-body :is(ul, ol):last-child { margin-block-end: 0; }
  .legal-body li { margin-block: 0.5em; }
  .legal-body li::marker { color: var(--text-accent); }
  .legal-body li > :is(ul, ol) {
    margin-block: 0.5em 0;
    padding-inline-start: 1.25rem;
  }

  .legal-body strong {
    font-weight: var(--dm-weight-700);
    color: var(--text-primary);
  }

  .legal-body code {
    font-family: var(--dm-font-mono);
    font-size: 0.9em;
    padding: 0.1em 0.35em;
    border-radius: var(--radius-xs);
    background: var(--dm-a-ink-04);
    color: var(--text-primary);
    overflow-wrap: anywhere;
  }

  /* --- 5.5 inline links (§A.8) ------------------------------------------- */
  .legal-body a {
    color: var(--text-accent);
    text-decoration: underline;
    text-decoration-thickness: from-font;
    text-underline-offset: 0.18em;
    transition: var(--transition-color);
  }
  .legal-body a:hover {
    color: var(--text-accent-strong);
    text-decoration-thickness: 2px;
  }
  /* Long bare URLs must not blow out the 335px mobile content box. */
  .legal-body a[href^="http"],
  .legal-body a[href^="mailto:"] { overflow-wrap: anywhere; }

  /* --- 5.6 :target treatment on the landed clause (§E.5) ------------------
     Ships together with the section:focus outline suppression in @layer focus
     below — the two rules are a pair and neither is valid alone. */
  .legal-body section:target {
    border-inline-start: 3px solid var(--dm-crimson);
    padding-inline-start: 1.25rem;                    /* 20px */
    margin-inline-start: -1.4375rem;                  /* 23px — text x never moves */
  }
  .legal-body section:target > h2 { color: var(--text-accent-strong); }

  /* ========================================================================
     6 · .legal-note — THE VERBATIM, OPERATIVE CALLOUT (spec §A.6)
     ------------------------------------------------------------------------
     Crimson tint + 4px crimson inline-start bar + 18px radius = "this is the
     operative text". That visual language is used for NOTHING else on these
     pages. See §7 for the deliberately different summary treatment.
     ======================================================================== */

  .legal-note {
    margin-block: var(--space-6);                     /* 24px */
    padding: var(--space-4) var(--space-5);           /* 16 / 20 below 768 */
    border: 1px solid var(--dm-a-crimson-20);
    border-inline-start: 4px solid var(--dm-crimson);
    border-radius: var(--radius-md);                  /* 18px */
    background: var(--surface-accent-soft);           /* → #eadbd8, 13.7:1 */
    font-size: var(--legal-body-size);
    line-height: var(--leading-relaxed);
    color: var(--text-primary);
  }
  .legal-note > * + *      { margin-block-start: 0.9em; }
  .legal-note p            { margin: 0; color: var(--text-primary); }
  .legal-note strong       { color: var(--text-accent-strong); font-weight: var(--dm-weight-700); }
  .legal-note :is(ul, ol)  { margin: 0; }
  .legal-note li::marker   { color: var(--dm-crimson); }

  /* ========================================================================
     7 · .legal-note-summary — THE PLAIN-LANGUAGE ORIENTATION BLOCK (/cgv)
     ------------------------------------------------------------------------
     LEGALLY LOAD-BEARING DISTINCTION. This is NOT operative text; a reader
     must never mistake it for the clause it summarises. So it drops every
     cue the operative callout owns:
       operative  → crimson tint fill · 4px crimson inline-start bar · 18px radius
       summary    → white card · hairline border · no accent bar · 28px radius
     …and it adds one the operative callout never has: the .legal-note-disclaimer
     strip, which is the first thing under the heading.
     ======================================================================== */

  .legal-note-summary {
    margin-block: 0 var(--space-10);                  /* 40px clear of clause 1 */
    padding: clamp(1.25rem, 0.9rem + 1.5vw, 1.75rem);
    max-width: var(--legal-measure);
    border: 1px solid var(--border-soft);
    border-inline-start-width: 1px;                   /* kill the operative bar */
    border-inline-start-color: var(--border-soft);
    border-radius: var(--radius-lg);                  /* 28px — the card family */
    background: var(--surface-raised);                /* white, not crimson */
    color: var(--text-primary);
    box-shadow: none;
  }
  .legal-note-summary > * + * { margin-block-start: 0; }

  .legal-note-summary h2 {
    font-family: var(--dm-font-display);
    font-weight: var(--dm-weight-700);
    font-size: var(--font-size-heading-md);           /* 20 → 24px, below clause h2 */
    line-height: 1.22;
    letter-spacing: var(--tracking-heading-md);
    color: var(--text-primary);
    margin: 0 0 var(--space-3);
  }

  /* The disclaimer is the guard rail. It sits immediately under the heading,
     is visually pinned to it, and never uses --dm-muted (3.49:1). */
  .legal-note-disclaimer {
    margin: 0 0 var(--space-5);
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-sm);
    background: var(--surface-warm);                  /* #e7e0d6 warm block */
    border-inline-start: 3px solid var(--border-strong);
    font-size: 0.9375rem;                             /* 15px */
    line-height: 1.5;
    color: var(--text-secondary);                     /* 8.9:1 on #e7e0d6 */
    max-width: none;
  }

  .legal-note-summary ul {
    list-style: disc;
    margin: 0;
    padding-inline-start: 1.25rem;
    max-width: none;
  }
  .legal-note-summary li          { margin-block: 0.6em; }
  .legal-note-summary li::marker  { color: var(--border-strong); }  /* not crimson */
  .legal-note-summary li:first-child { margin-block-start: 0; }
  .legal-note-summary li:last-child  { margin-block-end: 0; }
  /* Ink, not crimson — crimson lead-ins belong to the operative callout. */
  .legal-note-summary strong { color: var(--text-primary); font-weight: var(--dm-weight-700); }

  /* ========================================================================
     8 · .legal-contact (spec §A.7)
     ======================================================================== */

  .legal-contact {
    margin-block: var(--space-8) 0;
    padding: var(--space-6);
    max-width: var(--legal-measure);
    border: 1px solid var(--border-hairline);
    border-radius: var(--radius-lg);                  /* 28px */
    background: var(--surface-raised);
    font-size: 0.9375rem;
    line-height: 1.55;
    color: var(--text-secondary);
  }
  .legal-contact:first-child { margin-block-start: 0; }

  .legal-contact h2 {
    font-family: var(--dm-font-display);
    font-weight: var(--dm-weight-700);
    font-size: var(--font-size-heading-md);
    line-height: 1.22;
    letter-spacing: var(--tracking-heading-md);
    margin: 0 0 var(--space-2);
  }
  .legal-contact p {
    margin: 0;
    font-size: var(--legal-body-size);
    line-height: var(--leading-relaxed);
    color: var(--text-primary);
  }
  .legal-contact p + p { margin-block-start: 0.9em; }
  .legal-contact strong { color: var(--text-accent-strong); overflow-wrap: anywhere; }

  .legal-contact a[href^="mailto:"] {
    display: inline-flex;
    align-items: center;
    min-height: var(--touch-min);                     /* 44px */
    font-size: 1.0625rem;
    font-weight: var(--dm-weight-600);
    color: var(--text-accent);
    overflow-wrap: anywhere;
  }

  /* The closing "Still stuck?" block on /support — same card, crimson top rule
     so the page has a visible end. Never the operative-callout language. */
  .legal-contact-end {
    margin-block-start: var(--space-16);              /* 64px */
    border-block-start: 3px solid var(--dm-crimson);
  }

  /* ========================================================================
     9 · SUPPORT FAQ (spec §C)
     ======================================================================== */

  /* Cluster label: /support has no <section> elements, so the h2 that opens
     each FAQ group carries the clause-boundary rhythm itself. */
  .faq-cluster {
    margin-block: var(--space-16) var(--space-4);     /* 64px above, 16px below */
    padding-block-start: var(--space-8);
    border-block-start: 1px solid var(--border-hairline);
    max-width: var(--legal-measure);
  }

  .faq {
    max-width: var(--legal-measure);
    margin-block: 0;
  }

  .faq-item {
    border: 1px solid var(--border-hairline);
    border-radius: var(--radius-md);                  /* 18px */
    background: var(--surface-raised);
    margin-block-end: var(--space-3);
    transition: var(--transition-color);
  }
  .faq-item:last-child   { margin-block-end: 0; }
  .faq-item[open]        { border-color: var(--dm-a-crimson-20); }

  .faq-q {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
    min-height: 3.5rem;                               /* 56px, grows with text */
    padding: var(--space-4) var(--space-5);
    cursor: pointer;
    list-style: none;                                 /* kills Firefox ▸ */
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    border-radius: var(--radius-md);
  }
  .faq-q::-webkit-details-marker { display: none; }   /* Safari */

  .faq-q h3 {
    font-family: var(--dm-font-body);
    font-weight: var(--dm-weight-700);
    font-size: clamp(1.0625rem, 1rem + 0.25vw, 1.1875rem);
    line-height: 1.35;
    letter-spacing: -0.008em;
    color: var(--text-primary);
    margin: 0;
    text-wrap: pretty;
  }
  .faq-q:hover { background: var(--dm-a-crimson-12); }
  .faq-q:hover h3 { color: var(--text-accent-strong); }

  .faq-a {
    padding: 0 var(--space-5) var(--space-5);
    max-width: var(--legal-measure);
    font-size: var(--legal-body-size);
    line-height: var(--leading-relaxed);
    color: var(--text-primary);
  }
  .faq-a > * + *      { margin-block-start: 0.9em; }
  .faq-a p            { margin: 0; color: var(--text-primary); }
  .faq-a :is(ul, ol)  { margin: 0; padding-inline-start: 1.25rem; }
  .faq-a li           { margin-block: 0.5em; }
  .faq-a li::marker   { color: var(--text-accent); }

  /* --- 9.1 open/close animation (§C.6) -----------------------------------
     Guarded twice: by @supports (so unsupported engines get the native
     instant open and are never left at block-size 0) and by
     prefers-reduced-motion: no-preference (so reduced motion removes the
     mechanism, not just its duration). The chevron still rotates — rotation
     is state, not motion. */
  @supports (interpolate-size: allow-keywords) and selector(::details-content) {
    @media (prefers-reduced-motion: no-preference) {
      :root { interpolate-size: allow-keywords; }

      .faq-item::details-content {
        block-size: 0;
        overflow: clip;
        transition:
          block-size         var(--duration-base) var(--ease-std),
          content-visibility var(--duration-base) allow-discrete;
      }
      .faq-item[open]::details-content { block-size: auto; }
    }
  }

  /* ========================================================================
     10 · .legal-aside — CROSS-LINKS (spec §D.1)
     ======================================================================== */

  .legal-aside {
    margin-block-start: var(--space-16);              /* 64px > any clause gap */
    padding: clamp(1.5rem, 1rem + 2vw, 2rem);
    border: 1px solid var(--border-hairline);
    border-radius: var(--radius-lg);                  /* 28px */
    background: var(--surface-raised);
    max-width: var(--legal-measure);
  }
  .legal-aside h2 {
    font-family: var(--dm-font-display);
    font-weight: var(--dm-weight-700);
    font-size: 1.25rem;
    line-height: 1.25;
    letter-spacing: var(--tracking-heading-md);
    color: var(--text-primary);
    margin: 0 0 var(--space-3);
  }
  .legal-aside ul {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: var(--space-1);
  }
  .legal-aside li {
    display: grid;
    padding: var(--space-2) var(--space-3);
    margin-inline: calc(var(--space-3) * -1);
    border-radius: var(--radius-sm);
    transition: var(--transition-color);
  }
  .legal-aside li:hover { background: var(--dm-a-crimson-12); }

  .legal-aside a {
    display: inline-flex;
    align-items: center;
    min-height: var(--touch-min);                     /* 44px */
    color: var(--text-accent);
    font-weight: var(--dm-weight-600);
    font-size: 1.0625rem;
    line-height: 1.3;
    text-decoration: none;
    touch-action: manipulation;
    justify-self: start;
  }
  .legal-aside a:hover { color: var(--text-accent-strong); text-decoration: underline; }

  /* the descriptor line under each cross-link */
  .legal-aside li > span {
    display: block;
    font-size: 0.9375rem;                             /* 15px */
    line-height: 1.5;
    color: var(--text-muted);                         /* 5.61:1 on white */
    text-wrap: pretty;
  }

  .legal-aside .legal-contact {
    border: 0;
    border-block-start: 1px solid var(--border-hairline);
    border-radius: 0;
    background: none;
    padding: var(--space-4) 0 0;
    margin: var(--space-5) 0 0;
    max-width: none;
  }

  /* ========================================================================
     11 · RESPONSIVE (spec §G.1)
     ======================================================================== */

  @media (min-width: 768px) {
    .legal { padding-block: var(--space-10) var(--space-24); }
    .legal-shell { max-width: 42.5rem; }              /* 680px */

    /* clause gap 64 → 80px */
    .legal-body section + section {
      margin-block-start: var(--space-10);            /* 40px */
      padding-block-start: var(--space-10);
    }
    .legal-body :is(ul, ol) { padding-inline-start: 1.375rem; }  /* 22px */
    .legal-note { padding: var(--space-5) var(--space-6); }      /* 20 / 24 */
    .faq-cluster { margin-block-start: var(--space-20); padding-block-start: var(--space-10); }
  }

  @media (min-width: 1024px) {
    .legal-shell {
      max-width: 62.5rem;                             /* 1000px */
      display: grid;
      grid-template-columns: 15rem minmax(0, 1fr);    /* minmax(0,…) is mandatory */
      column-gap: var(--space-10);                    /* 40px */
      align-items: start;
    }
    .legal-crumb { grid-column: 1 / -1; grid-row: 1; }
    .legal-head  { grid-column: 1 / -1; grid-row: 2; max-width: 46rem; }
    .legal-toc   { grid-column: 1; grid-row: 3; }
    .legal-body  { grid-column: 2; grid-row: 3; }
    .legal-aside { grid-column: 2; grid-row: 4; }

    /* --- the rail (§B.6) --- */
    .legal-toc {
      position: sticky;
      top: var(--legal-anchor-off);                   /* 96px */
      align-self: start;
      border: 0;
      background: none;
      margin: 0;
    }
    /* The bounded scroller is the LIST, not the rail: it keeps the "On this
       page" label pinned above a long index, and keeps the label out of a
       composited scroll container (which shaves the antialiasing off its
       first glyph in Chromium). Still exactly one nested, bounded scroll
       region on the page — §B.6 / the `scroll-behavior` rule.
       4.5rem = the label (25px) + 47px of bottom breathing room. */
    .legal-toc ol {
      padding: 0 var(--space-1) 0 0;
      max-height: calc(100dvh - var(--legal-anchor-off) - 4.5rem);
      overflow-y: auto;
      overscroll-behavior: contain;
      scrollbar-gutter: stable;
    }
    .legal-toc li a { min-height: 2.25rem; }          /* 36px + 4px gap */

    /* --- forced open, summary becomes a plain label (§B.3) --- */
    .legal-toc-d::details-content {
      content-visibility: visible;
      block-size: auto;
      opacity: 1;
    }
    .legal-toc-title {
      list-style: none;
      cursor: default;
      pointer-events: none;
      min-height: 0;
      /* 3px inline-start matches the list items' transparent active rule AND
         keeps the "O" of "ON THIS PAGE" clear of the rail's overflow clip. */
      padding: 0 0 var(--space-2) 3px;
      font-size: 0.8125rem;
      letter-spacing: var(--tracking-eyebrow);
      text-transform: uppercase;
      color: var(--text-muted);
    }
    .legal-toc-title::-webkit-details-marker { display: none; }
    .legal-toc-title::after { display: none; }        /* no chevron on a label */
  }

  /* Graceful degradation on engines without ::details-content (§B.3):
     the desktop TOC stays a real, clickable, keyboard-operable disclosure. */
  @supports not selector(::details-content) {
    @media (min-width: 1024px) {
      .legal-toc-title {
        pointer-events: auto;
        cursor: pointer;
        min-height: 2.75rem;
        display: flex;
        text-transform: none;
        font-size: 0.9375rem;
        letter-spacing: 0.02em;
        color: var(--text-primary);
      }
      .legal-toc-title::after { display: block; }
    }
  }

  @media (min-width: 1440px) {
    .legal-shell {
      max-width: 68rem;                               /* 1088px */
      grid-template-columns: 16.5rem minmax(0, 1fr);
      column-gap: var(--space-16);                    /* 64px */
    }
    .legal-aside { max-width: none; }
    .legal-aside ul { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-2); }
    .legal-aside li { align-content: start; }
  }
}

/* ==========================================================================
   12 · FOCUS — two deliberate overrides that must outrank @layer focus
   ========================================================================== */
@layer focus {

  /* The sticky rail clips, so the ring is drawn INSIDE the item. */
  .legal-toc li a:focus-visible {
    outline: var(--focus-ring-width) var(--focus-ring-style) var(--focus-ring);
    outline-offset: -1px;
    border-radius: var(--radius-xs);
  }

  /* --details-content is height-clipped by the animation, so inset here too. */
  .faq-q:focus-visible {
    outline: var(--focus-ring-width) var(--focus-ring-style) var(--focus-ring);
    outline-offset: -3px;
    border-radius: var(--radius-md);
  }
  .legal-toc-title:focus-visible {
    outline: var(--focus-ring-width) var(--focus-ring-style) var(--focus-ring);
    outline-offset: -3px;
    border-radius: var(--radius-md);
  }

  /* §E.5 — legitimate ONLY because :target supplies a stronger, persistent
     indicator on the same element at the same moment. These two ship together.
     tabindex="-1" on each section is what makes fragment nav move focus. */
  .legal-body section:focus,
  .legal-body section:focus-visible { outline: none; }

  .legal-aside a:focus-visible,
  .legal-crumb a:focus-visible {
    outline: var(--focus-ring-width) var(--focus-ring-style) var(--focus-ring);
    outline-offset: 2px;
    border-radius: var(--radius-xs);
  }
}

/* ==========================================================================
   13 · PRINT (spec §F) — unlayered on purpose so it beats every layer.
   People print and archive legal terms.
   ========================================================================== */
@media print {

  /* --- F.1 page setup ----------------------------------------------------- */
  @page { margin: 18mm 16mm 20mm; }

  html, body {
    background: #fff !important;
    color: #000 !important;
  }

  /* --- F.3 colour and type (declared before the hides so `*` can't win) ---- */
  .legal-page *,
  .legal-page *::before,
  .legal-page *::after,
  .legal-page ::marker {
    color: #000 !important;
    box-shadow: none !important;
    border-radius: 0 !important;
    background-image: none !important;
  }

  /* --- F.2 hidden --------------------------------------------------------- */
  .legal-page header.nav,
  .legal-page .skip-link,
  .legal-page footer.foot,
  .legal-page .legal-crumb,
  .legal-page .legal-toc,
  .legal-page .faq-q::after,
  .legal-page .legal-toc-title::after { display: none !important; }

  .legal { padding: 0 !important; }

  .legal-shell {
    display: block !important;
    max-width: none !important;
    padding: 0 !important;
  }

  .legal-body { font-family: var(--dm-font-body); font-size: 11pt; line-height: 1.45; }
  .legal-body > section > *,
  .legal-body > * { max-width: none !important; }

  .legal-head { margin-block: 0 8mm; max-width: none; break-after: avoid-page; page-break-after: avoid; }
  .legal-title { font-size: 22pt; line-height: 1.1; }
  .legal-date  { font-size: 10pt; }
  .legal-lede  { font-size: 11pt; max-width: none; }

  .legal-body h2 { font-size: 13pt; line-height: 1.25; font-weight: 700; }
  .legal-body h3,
  .faq-q h3      { font-size: 11.5pt; font-weight: 700; }

  .legal-body section + section { border-block-start: 0.5pt solid #000; }
  .legal-body section:target {
    border-inline-start: 0;
    padding-inline-start: 0;
    margin-inline-start: 0;
  }

  /* The operative callout keeps its prominence via a rule, not a fill. */
  .legal-note {
    background: none !important;
    border: 1.5pt solid #000;
    border-inline-start-width: 1.5pt;
    padding: 3mm 4mm;
    font-size: 11pt;
  }
  /* The summary must still be unmistakably NOT the operative text on paper. */
  .legal-note-summary {
    background: none !important;
    border: 0.5pt dashed #000;
    padding: 3mm 4mm;
  }
  .legal-note-disclaimer {
    background: none !important;
    border-inline-start: 1pt solid #000;
    padding: 1mm 0 1mm 3mm;
    font-size: 9.5pt;
    font-style: italic;
  }

  .legal-contact {
    border: 0;
    border-block-start: 0.5pt solid #000;
    border-radius: 0;
    background: none !important;
    padding: 3mm 0 0;
    max-width: none;
  }
  .legal-contact p { font-size: 11pt; }

  .faq { max-width: none; }
  .faq-cluster { border-block-start: 0.5pt solid #000; margin-block: 8mm 3mm; padding-block-start: 3mm; }
  .faq-item {
    border: 0;
    border-block-end: 0.5pt solid #000;
    background: none !important;
    margin-block-end: 3mm;
  }
  .faq-q { padding: 2mm 0; min-height: 0; }
  .faq-a { padding: 0 0 4mm; max-width: none; font-size: 11pt; }

  /* --- F.6 every FAQ answer prints, whatever its open state ---------------- */
  .faq-item::details-content {
    content-visibility: visible !important;
    block-size: auto !important;
    overflow: visible !important;
    opacity: 1 !important;
  }

  /* --- F.2 the aside: links are dead ink, the contact block is not --------- */
  .legal-aside {
    border: 0;
    background: none !important;
    padding: 0;
    margin-block-start: 10mm;
    max-width: none;
  }
  .legal-aside > h2,
  .legal-aside > ul { display: none; }
  .legal-aside .legal-contact {
    border-block-start: 0.5pt solid #000;
    padding-block-start: 4mm;
  }

  /* --- F.4 expose link targets -------------------------------------------- */
  .legal-page a { color: #000 !important; text-decoration: underline; }
  .legal-body a[href^="http"]::after,
  .faq-a a[href^="http"]::after  { content: " <" attr(href) ">"; }
  .legal-body a[href^="/"]::after,
  .faq-a a[href^="/"]::after     { content: " <https://www.dripmaxapp.com" attr(href) ">"; }
  .legal-body a[href^="#"]::after,
  .legal-body a[href^="mailto:"]::after,
  .faq-a a[href^="#"]::after,
  .faq-a a[href^="mailto:"]::after { content: none; }
  .legal-body a::after,
  .faq-a a::after {
    font-size: 9pt;
    font-weight: 400;
    word-break: break-all;
  }

  /* --- F.5 a clause heading is never orphaned ----------------------------- */
  .legal-body h2,
  .legal-body h3,
  .faq-q h3,
  .faq-cluster {
    break-after: avoid-page;  page-break-after: avoid;
    break-inside: avoid;      page-break-inside: avoid;
  }
  .legal-body h2 + *,
  .legal-body h3 + * { break-before: avoid-page; page-break-before: avoid; }

  .legal-note,
  .legal-note-summary,
  .faq-item,
  .legal-body li     { break-inside: avoid; page-break-inside: avoid; }
  .legal-body p      { orphans: 3; widows: 3; }
  .legal-body section { break-inside: auto; }   /* deliberately NOT avoid */
}
