/* ==========================================================================
   StilUp — legal & support documents  (/privacy, /terms, /support)

   Loaded only by resources/views/legal/layout.blade.php, AFTER /site/styles.css,
   which supplies: the 21 :root tokens, the `* { margin:0; padding:0 }` reset,
   body, html { scroll-behavior: smooth }, :focus-visible, .eyebrow, .btn*,
   the whole .nav block, the whole .footer block, and the prefers-reduced-motion
   block. styles.css is NEVER modified — every adjustment here is scoped to
   .legal-page (the <body> class), which both makes this file incapable of
   altering the landing page and wins on specificity over styles.css's
   single-class rules without a single !important.

   Mobile-first: one @media (min-width: 1024px) query for the two-column rail,
   plus two max-width refinements that reuse styles.css's own 860/560 stops.
   There is deliberately no `max-width: 1023px` query, so no fractional-zoom
   dead zone can exist between the breakpoints.

   CRITICAL: styles.css:28 zeroes every default margin and every list
   padding-left. A prose page must therefore author all of it. That is most of
   what this file is. If this file fails to load, these pages are not
   "unstyled" — they are an unreadable margin-less slab. See the test.
   ========================================================================== */

/* The brand palette is light-only by construction (styles.css has no
   prefers-color-scheme and no [data-theme] block anywhere). Declaring it stops
   the UA painting dark form controls and scrollbars against a permanently pale
   page — which is what the old legal layout's `color-scheme: light dark` did.
   Must sit on the root element to take effect. */
:root { color-scheme: light; }

.legal-page {
  --nav-h: 74px;        /* static fallback; overwritten at runtime from the real box */
  --rail-w: 260px;
  --sheet-w: 772px;     /* 260 + 40 gap + 772 = 1072 = the chrome's content box */
  --measure: 66ch;      /* ~68 characters of Plus Jakarta Sans at 17px */
  --anchor-off: calc(var(--nav-h) + 18px);
}

/* ---------- skip link ---------- */
.legal-page .skip-link {
  position: fixed;
  left: 16px;
  top: -100px;
  z-index: 100;
  background: var(--white);
  color: var(--iris-deep);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  padding: 10px 18px;
  border-radius: 999px;
  box-shadow: var(--shadow-card);
  transition: top .15s ease;
}
.legal-page .skip-link:focus { top: 12px; }

/* ---------- chrome adjustments (nav + footer come from styles.css) ----------
   Footer colours are deliberately NOT overridden: the footer must render
   identically to the landing page's, which is the one component a visitor sees
   twice within ten seconds. --muted's marginal contrast is inherited and
   applies equally to `/`; the fix belongs upstream, not here. */
.legal-page .nav-links a[aria-current="page"],
.legal-page .footer-links a[aria-current="page"] {
  color: var(--iris-deep);
  font-weight: 600;
}

/* ---------- shell ----------
   Single column by default. The sheet is 772px wide in BOTH modes (820 - 48 of
   gutter), so the measure never changes when the rail appears. */
.legal-page .doc-shell {
  max-width: 820px;
  margin: 0 auto;
  padding: 36px 24px 80px;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 20px;
}
.legal-page .doc-rail,
.legal-page .doc { min-width: 0; }

/* ---------- table of contents (built by the layout's script) ---------- */
.legal-page .doc-toc summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-family: var(--font);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.4;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--iris-deep);
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 11px 18px;
}
.legal-page .doc-toc summary::-webkit-details-marker { display: none; }
.legal-page .doc-toc summary::after {
  content: "+";
  font-size: 20px;
  font-weight: 400;
  line-height: 1;
  letter-spacing: 0;
  color: var(--iris-deep);
  transition: rotate .2s ease;
}
.legal-page .doc-toc[open] summary::after { rotate: 45deg; }

.legal-page .doc-toc-list {
  list-style: none;
  margin: 10px 0 0;
  padding: 10px;
  display: grid;
  gap: 1px;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-card);
}
.legal-page .doc-toc-link {
  display: block;
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  line-height: 1.4;
  color: var(--ink-soft);
  padding: 7px 12px;
  border-left: 2px solid transparent;
  border-radius: 0 8px 8px 0;
  transition: color .15s ease, background .15s ease, border-color .15s ease;
}
.legal-page .doc-toc-link:hover {
  color: var(--iris-deep);
  background: var(--lavender-soft);
}
/* The active pair (--iris-deep on --lavender-soft, 5.5:1) is the same
   combination styles.css already ships for .lang-btn.is-active and
   .bt-btn.is-active. */
.legal-page .doc-toc-link.is-active {
  color: var(--iris-deep);
  font-weight: 700;
  background: var(--lavender-soft);
  border-left-color: var(--iris);
}
.legal-page .doc-toc-list .is-sub .doc-toc-link {
  padding-left: 26px;
  font-size: 13px;
}

/* ---------- language note ---------- */
.legal-page .doc-note {
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--ink-soft);
}
.legal-page .doc-note a {
  color: var(--iris-deep);
  text-decoration: underline;
  text-underline-offset: 2px;
  overflow-wrap: break-word;
}

/* ---------- wide: rail + sheet ----------
   Gated on .has-toc, which the script adds only after the rail is populated —
   so with JS off (or no heading ids) the page stays a single centred column
   instead of leaving a 260px empty gutter beside the sheet. */
@media (min-width: 1024px) {
  .legal-page.has-toc .doc-shell {
    max-width: 1120px;
    padding-top: 52px;
    grid-template-columns: var(--rail-w) minmax(0, var(--sheet-w));
    grid-template-areas:
      "rail doc"
      "note doc";
    grid-template-rows: auto 1fr;
    column-gap: 40px;
    row-gap: 24px;
  }
  .legal-page.has-toc .doc-rail {
    grid-area: rail;
    position: sticky;
    top: calc(var(--nav-h) + 24px);
    align-self: start;
    max-height: calc(100vh - var(--nav-h) - 48px);
    overflow-y: auto;
    overscroll-behavior: contain;
    padding-right: 6px;
  }
  .legal-page.has-toc .doc { grid-area: doc; }
  .legal-page.has-toc .doc-note { grid-area: note; }

  /* The disclosure drops its pill and becomes a quiet rail heading. */
  .legal-page.has-toc .doc-toc summary {
    background: none;
    border: 0;
    border-bottom: 1px solid var(--line);
    border-radius: 0;
    padding: 0 2px 12px;
    color: var(--ink-soft);
  }
  /* In rail mode the disclosure is permanently open and the summary is acting
     as a plain heading, so the marker is removed: a rotated "+" reads as a
     dismiss affordance, and collapsing the rail would hide the list with no
     visible control left to reopen it. The toggle is also pinned open in the
     layout's script, which covers keyboard activation too. */
  .legal-page.has-toc .doc-toc summary::after { content: none; }
  .legal-page.has-toc .doc-toc summary { cursor: default; }
  .legal-page.has-toc .doc-toc-list {
    margin-top: 12px;
    padding: 0;
    background: none;
    border: 0;
    box-shadow: none;
    border-radius: 0;
  }
  .legal-page.has-toc .doc-toc-link { border-left-color: var(--line); }
  .legal-page.has-toc .doc-toc-link.is-active { border-left-color: var(--iris); }
}

/* ---------- the document sheet ----------
   --white on --cloud at var(--radius) with var(--shadow-card) is exactly how
   styles.css draws .step and .faq-item. At 772px the .07-alpha shadow alone
   reads flat, so a --line hairline carries the edge (the border + shadow
   pairing .plan-popular already uses). */
.legal-page .doc {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  padding: clamp(28px, 3.4vw, 48px) clamp(22px, 4vw, 52px) clamp(36px, 4.4vw, 56px);
  scroll-margin-top: var(--anchor-off);
}
.legal-page .doc:focus { outline: none; }
/* Same specificity as the rule above, declared after it, so the skip link's
   target still shows a ring for keyboard users. */
.legal-page .doc:focus-visible {
  outline: 3px solid var(--iris);
  outline-offset: 2px;
}

.legal-page .doc-body {
  max-width: var(--measure);
  font-size: 17px;
  line-height: 1.7;
  color: var(--ink);
}

/* ---------- masthead ----------
   The element keeps styles.css's .eyebrow class for identity, but every
   property the prose rules below would otherwise clobber is restated here at
   (0,3,0). Values are copied verbatim from styles.css:47-54. */
.legal-page .doc-body > .eyebrow {
  font-size: 13px;
  font-weight: 700;
  line-height: 1.4;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--iris-deep);   /* --iris is 4.47:1 on white; --iris-deep is 6.3:1 */
  margin: 0 0 12px;
}
.legal-page .doc-body h1 {
  /* .section-title's own clamp, not an invented one. */
  font-size: clamp(28px, 4vw, 42px);
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -.02em;
  color: var(--ink);
  margin: 0 0 12px;
  text-wrap: balance;
}
/* Purely typographic ON PURPOSE. privacy and terms put a date in .updated;
   support puts the tagline "We're here to help". Any date-shaped treatment —
   badge, pill, calendar glyph, monospace — would render that tagline as a fake
   timestamp. The hairline below does the masthead work instead. */
.legal-page .doc-body > .updated {
  font-size: 15.5px;
  font-weight: 500;
  line-height: 1.6;
  color: var(--ink-soft);
  margin: 0 0 28px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--line);
}
/* The lead paragraph. All three pages open with one directly after .updated. */
.legal-page .doc-body > .updated + p {
  font-size: 18px;
  color: var(--ink-soft);
  margin-bottom: 26px;
}

/* ---------- headings ----------
   The h2 hairline is the load-bearing typographic decision: it turns terms'
   17 flat clauses and privacy's 11 into visibly discrete, countable units. */
.legal-page .doc-body h2 {
  font-size: 24px;
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: -.01em;
  color: var(--ink);
  margin: 44px 0 16px;
  padding-top: 26px;
  border-top: 1px solid var(--line);
  scroll-margin-top: var(--anchor-off);
  text-wrap: balance;
}
.legal-page .doc-body h3 {
  font-size: 19px;
  font-weight: 700;
  line-height: 1.4;
  color: var(--ink);
  margin: 30px 0 8px;
  scroll-margin-top: var(--anchor-off);
  text-wrap: balance;
}
.legal-page .doc-body h4 {
  font-size: 17px;
  font-weight: 700;
  line-height: 1.45;
  color: var(--ink);
  margin: 24px 0 6px;
  scroll-margin-top: var(--anchor-off);
}
.legal-page .doc-body h5,
.legal-page .doc-body h6 {
  font-size: 15.5px;
  font-weight: 700;
  line-height: 1.45;
  color: var(--ink);
  margin: 20px 0 6px;
}
/* Stops 44+30px of stacked margin opening a hole at privacy 1 -> 1.1 and at
   support's "Getting started" -> "Building your closet". */
.legal-page .doc-body h2 + h3 { margin-top: 22px; }
.legal-page .doc-body h3 + h4 { margin-top: 16px; }
/* Headings receive focus only programmatically, from the hashchange handler.
   The scroll plus the active rail entry are the indicator; a 3px ring around a
   24px heading reads as a rendering fault. */
.legal-page .doc-body h1:focus,
.legal-page .doc-body h2:focus,
.legal-page .doc-body h3:focus,
.legal-page .doc-body h4:focus { outline: none; }

/* ---------- prose ---------- */
.legal-page .doc-body p {
  margin: 0 0 22px;
  text-wrap: pretty;
}
.legal-page .doc-body ul,
.legal-page .doc-body ol {
  margin: 0 0 22px;
  padding-left: 26px;
}
.legal-page .doc-body ul { list-style: disc outside; }
.legal-page .doc-body ol { list-style: decimal outside; padding-left: 28px; }
.legal-page .doc-body li {
  margin: 0 0 12px;
  text-wrap: pretty;
}
.legal-page .doc-body li:last-child { margin-bottom: 0; }
/* A neutral brand-tinted disc — never a check mark. support.blade.php's
   three-step iOS cancellation procedure is marked up as a <ul>, and a tick
   would read "already done". Markers are decorative and only need 3:1. */
.legal-page .doc-body ul > li::marker { color: var(--iris); }
.legal-page .doc-body ol > li::marker {
  color: var(--iris-deep);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.legal-page .doc-body ul ul,
.legal-page .doc-body ul ol,
.legal-page .doc-body ol ul,
.legal-page .doc-body ol ol { margin: 12px 0 0; }
.legal-page .doc-body ul ul { list-style: circle outside; }
.legal-page .doc-body > *:last-child { margin-bottom: 0; }

/* 20 occurrences across the three pages in four distinct roles: run-in bullet
   labels (terms 4, privacy 4, support "Email:"), the company name in both
   <br>-built contact blocks, iOS UI element names, and one semantic negation
   ("we do NOT receive"). All stay INLINE — display:block would wreck the
   negation and the run-in sentences. Weight is declared explicitly because
   Plus Jakarta Sans ships 300-800 and the UA's "bolder" mapping is not
   guaranteed to land on 700. */
.legal-page .doc-body strong { font-weight: 700; color: var(--ink); }
.legal-page .doc-body em { font-style: italic; }
.legal-page .doc-body small { font-size: 13.5px; line-height: 1.5; color: var(--ink-soft); }

/* styles.css has NO rule for a bare <a> in prose — every anchor rule there is
   scoped to .nav-links a / .footer-links a / .btn / .store-badge — so these
   would otherwise render as default browser blue. --iris-deep (6.3:1) not
   --iris (4.47:1, fails AA). Never colour alone: the underline is always on.
   break-word keeps office.elarge@gmail.com and reportaproblem.apple.com from
   pushing a horizontal scrollbar at 320px. */
.legal-page .doc-body a {
  color: var(--iris-deep);
  font-weight: 500;
  text-decoration: underline;
  text-decoration-thickness: 1.5px;
  text-decoration-color: rgba(79, 70, 229, .45);  /* --iris-deep at 45% */
  text-underline-offset: 3px;
  overflow-wrap: break-word;
  transition: text-decoration-color .15s ease, color .15s ease;
}
.legal-page .doc-body a:hover {
  color: var(--iris);
  text-decoration-color: currentColor;
}

/* The <br>-built contact blocks at privacy:137-139 and terms:174-176 get NO
   rule at all. They are the company-identification block Apple reviewers look
   for, and nothing in this file introduces a `display` change on any child of
   a <p>, so the three lines survive at line-height 1.7. Do not card them. */

/* ---------- elements no page uses yet, styled so the next content edit cannot
   land on UA defaults inside an App-Store-facing legal document ---------- */
.legal-page .doc-body hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 36px 0;
}
.legal-page .doc-body blockquote {
  margin: 0 0 22px;
  padding: 4px 0 4px 20px;
  border-left: 3px solid var(--lavender);
  color: var(--ink-soft);
}
.legal-page .doc-body dl { margin: 0 0 22px; }
.legal-page .doc-body dt { font-weight: 700; color: var(--ink); margin-top: 14px; }
.legal-page .doc-body dd { margin: 4px 0 0; color: var(--ink); }
.legal-page .doc-body code,
.legal-page .doc-body pre {
  font-family: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
  font-size: .92em;
  background: var(--cloud);
  border: 1px solid var(--line);
  border-radius: 6px;
}
.legal-page .doc-body code { padding: 1px 5px; }
.legal-page .doc-body pre { padding: 14px 16px; margin: 0 0 22px; overflow-x: auto; }
.legal-page .doc-body pre code { background: none; border: 0; padding: 0; }
.legal-page .doc-table-wrap { overflow-x: auto; margin: 0 0 22px; }
.legal-page .doc-body table { width: 100%; border-collapse: collapse; font-size: 15.5px; }
.legal-page .doc-body th,
.legal-page .doc-body td {
  text-align: left;
  vertical-align: top;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
}
.legal-page .doc-body th { font-weight: 700; color: var(--ink); }

/* ---------- responsive ---------- */
@media (max-width: 860px) {
  /* styles.css:441 hides .nav-links at this width with no hamburger. That is
     allowed to stand — it keeps the sticky bar one ~70px row on the longest
     documents on the property, and all three cross-document links are in the
     footer. But styles.css:119 zeroes .nav-right's auto margin whenever
     .nav-links precedes it, and a display:none sibling still matches `+`, so
     the lone CTA would bunch against the brand. Give it back. */
  .legal-page .nav-links + .nav-right { margin-left: auto; }
  .legal-page .doc-shell { padding: 28px 20px 72px; }
  .legal-page .doc-body h2 { font-size: 22px; margin-top: 38px; padding-top: 22px; }
  .legal-page .doc-body h3 { font-size: 18px; }
  .legal-page .doc-body > .updated + p { font-size: 17.5px; }
}

@media (max-width: 560px) {
  /* Gutters are cut hard rather than shrinking the type: at a 360px viewport
     this yields ~306px of text column at 17px (~34-36 characters). Body copy
     stays 17px — shrinking prose on the device where these documents are
     mostly read would be backwards. */
  .legal-page .doc-shell { padding: 22px 10px 64px; gap: 18px; }
  .legal-page .doc {
    padding: 26px 16px 32px;
    border-radius: 18px;
  }
  .legal-page .doc-body h1 { margin-bottom: 10px; }
  .legal-page .doc-body h2 { font-size: 21px; }
  .legal-page .doc-body ul,
  .legal-page .doc-body ol { padding-left: 22px; }
}

/* Landscape phones: a 70px sticky bar over a 400px-tall viewport on a
   1117-word document is real estate these documents cannot spare. styles.css
   never had to solve this. */
@media (max-height: 480px) and (orientation: landscape) {
  .legal-page .nav { position: static; }
  .legal-page { --anchor-off: 12px; }
}

/* ---------- motion ----------
   styles.css already handles html { scroll-behavior } and .btn under reduced
   motion, which covers every TOC jump (they are plain fragment navigation, not
   JS smooth-scrolling). Nothing on this page is JS-visibility-dependent:
   .reveal is used NOWHERE, deliberately — its opacity:0 with no <noscript>
   fallback would render a blank policy to an Apple reviewer if the script
   failed. */
@media (prefers-reduced-motion: reduce) {
  .legal-page .skip-link,
  .legal-page .doc-toc summary::after,
  .legal-page .doc-toc-link,
  .legal-page .doc-body a { transition: none; }
}

/* ---------- forced colours ----------
   .brand-word paints text with background-clip and color:transparent, which
   renders INVISIBLE when backgrounds are stripped. styles.css has no
   forced-colors block at all. */
@media (forced-colors: active) {
  .legal-page .brand-word {
    background: none;
    color: CanvasText;
    -webkit-text-fill-color: CanvasText;
  }
  .legal-page .doc { border: 1px solid CanvasText; }
  .legal-page .doc-toc-link.is-active { color: Highlight; border-left-color: Highlight; }
  .legal-page .doc-body ul > li::marker,
  .legal-page .doc-body ol > li::marker { color: CanvasText; }
}

/* ---------- print ----------
   A privacy policy is a document reviewers and users save as PDF. styles.css
   has no print block: the sticky nav lands mid-page, the --cloud ground burns
   ink, and .brand-word (color: transparent) prints BLANK. */
@media print {
  @page { margin: 18mm; }

  .legal-page { background: #fff; }
  .legal-page .nav,
  .legal-page .doc-rail,
  .legal-page .skip-link,
  .legal-page .footer-links { display: none !important; }

  .legal-page .doc-shell {
    display: block;
    max-width: none;
    margin: 0;
    padding: 0;
  }
  .legal-page .doc {
    background: #fff;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    padding: 0;
  }
  /* ~75 characters at 11pt, instead of the ~110 an unbounded page width gives. */
  .legal-page .doc-body {
    max-width: 34em;
    font-size: 11pt;
    line-height: 1.55;
    color: #000;
  }
  .legal-page .doc-body > .eyebrow { color: #000; font-size: 8.5pt; }
  .legal-page .doc-body h1 { font-size: 22pt; }
  .legal-page .doc-body h2 {
    font-size: 13pt;
    margin-top: 20pt;
    padding-top: 10pt;
    break-after: avoid;
    page-break-after: avoid;
  }
  .legal-page .doc-body h3,
  .legal-page .doc-body h4 {
    font-size: 11.5pt;
    break-after: avoid;
    page-break-after: avoid;
  }
  .legal-page .doc-body p { orphans: 3; widows: 3; }
  .legal-page .doc-body li {
    orphans: 2;
    widows: 2;
    break-inside: avoid;
    page-break-inside: avoid;
  }
  .legal-page .doc-body ul > li::marker,
  .legal-page .doc-body ol > li::marker { color: #000; }
  .legal-page .doc-body strong { color: #000; }
  .legal-page .doc-body a {
    color: #000;
    text-decoration: underline;
    text-decoration-color: #000;
  }
  /* support's only external link is labelled "reportaproblem.apple.com" with
     no scheme, so the printed URL is a real gain. Scoped to .doc-body so nav
     and footer links are never expanded, and http-only so the seven mailto
     links — whose labels already ARE the address — are not doubled. */
  .legal-page .doc-body a[href^="http"]::after {
    content: " (" attr(href) ")";
    font-size: 9pt;
    word-break: break-all;
  }
  .legal-page .doc-note { color: #000; font-size: 9pt; margin-top: 14pt; }
  .legal-page .footer { background: #fff; padding: 12pt 0 0; }
  .legal-page .footer-inner { display: block; }
  .legal-page .footer-copy {
    width: auto;
    color: #000;
    border-top: 1px solid #999;
    font-size: 9pt;
  }
  .legal-page .footer-brand p { color: #000; font-size: 9pt; }
  .legal-page .brand-word {
    background: none;
    color: #000;
    -webkit-text-fill-color: #000;
  }
}
