/*
  legal.css
  The standalone pages (public/privacy.html, terms.html, health-privacy.html, support.html). They are
  real documents, not SPA routes: they load only fonts.css, tokens.css, this file, and js/legal.js, the
  one small script, which acts only inside the iPhone app's in-app browser (?app=ios, below).
  Tokens only (DESIGN_SYSTEM 2 "Rules of use"): every color is a semantic token, so light and dark
  follow the OS through tokens.css. Ink does the chrome; green appears only in the wordmark's lit cell.
*/

*, *::before, *::after { box-sizing: border-box; }
html { background-color: var(--bg); scroll-padding-top: calc(var(--safe-top) + var(--space-7)); }
@media (prefers-reduced-motion: no-preference) { html { scroll-behavior: smooth; } }
/* The page color sits on <html>, so the grain and the floodlight (z-index -1) paint above it. */
body { min-height: 100vh; min-height: 100dvh; overflow-x: hidden; background: transparent; }
h1, h2, h3, p, ul, ol { margin: 0; }
img, svg { max-width: 100%; }
a { color: var(--link); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }

.icon {
  width: var(--icon-size-sm); height: var(--icon-size-sm); flex: none;
  fill: none; stroke: currentColor; stroke-width: var(--icon-stroke);
  stroke-linecap: round; stroke-linejoin: round; vertical-align: middle;
}
.icon * { vector-effect: non-scaling-stroke; }

.skip {
  position: absolute; left: var(--gutter); top: calc(var(--safe-top) + var(--space-3)); z-index: var(--z-toast);
  padding: var(--space-3) var(--space-5); border-radius: var(--radius-sm);
  background: var(--brand); color: var(--on-brand); font-weight: var(--fw-semibold); text-decoration: none;
  transform: translateY(-200%);
}
.skip:focus { transform: none; }

/* Stadium light over the page, like Today and Reflect (DESIGN_SYSTEM 5 "Atmosphere"). */
.lg-light {
  position: absolute; inset: 0 0 auto; height: 420px; z-index: -1;
  background: var(--floodlight); pointer-events: none;
}

.lg-page {
  position: relative; width: 100%; max-width: 44rem; margin: 0 auto;
  padding: calc(var(--safe-top) + var(--space-5)) calc(var(--gutter) + var(--safe-right)) calc(var(--safe-bottom) + var(--space-9)) calc(var(--gutter) + var(--safe-left));
}

/* ---- Top bar: the app mark and wordmark, and the way back into the app ---- */
.lg-top { display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); min-height: var(--tap); }
.lg-brand { display: inline-flex; align-items: center; gap: var(--space-3); min-height: var(--tap); color: var(--text-1); text-decoration: none; }
.lg-brand img { width: 32px; height: 32px; border-radius: 8px; box-shadow: var(--shadow-1); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .lg-brand img { box-shadow: 0 0 0 1px var(--line-strong), var(--shadow-1); }
}
.wordmark {
  display: inline-flex; align-items: baseline; gap: 0.18em;
  font: 800 21px/1 var(--font-ui); font-stretch: 88%; letter-spacing: -0.03em; color: var(--text-1); white-space: nowrap;
}
.wordmark i { font-family: var(--font-voice); font-style: italic; font-weight: 400; letter-spacing: 0; }
.wordmark__cell {
  width: 0.42em; height: 0.42em; border-radius: 50%; background: var(--status-done);
  display: inline-grid; place-items: center; transform: translateY(-0.02em);
}
.wordmark__cell .icon { width: 0.34em; height: 0.34em; color: var(--on-status-done); stroke-width: 3px; }
.lg-open {
  display: inline-flex; align-items: center; gap: var(--space-2); min-height: var(--tap); padding: 0 var(--space-4);
  border-radius: var(--radius-pill); background: var(--surface); box-shadow: var(--shadow-1), inset 0 0 0 1px var(--line);
  color: var(--text-1); font: var(--fw-semibold) var(--fs-body-s)/1 var(--font-ui); text-decoration: none; white-space: nowrap;
}
.lg-open:hover { background: var(--surface-2); }
.lg-open .icon { width: 16px; height: 16px; }

/* ---- Title block ---- */
.lg-head { margin: var(--space-9) 0 var(--space-7); }
.lg-head .eyebrow { display: block; margin-bottom: var(--space-3); }
.lg-head h1 { font-size: 36px; }
.lg-date { display: flex; align-items: center; gap: var(--space-2); margin-top: var(--space-4); font-size: var(--fs-body-s); color: var(--text-2); }
.lg-date .icon { width: 16px; height: 16px; color: var(--text-3); }
.lg-lead { margin-top: var(--space-5); }
.lg-intro { margin-top: var(--space-6); }

/* ---- Body copy ---- */
.lg-body { font-size: var(--fs-body-l); line-height: 1.55; color: var(--text-1); }
.lg-body p + p, .lg-body p + ul, .lg-body ul + p, .lg-body h3 + p, .lg-body h3 + ul, .lg-body .lg-card + p,
.lg-body p + .lg-card, .lg-body ul + .lg-card, .lg-body .lg-card + .lg-card, .lg-body .lg-pair + p { margin-top: var(--space-4); }
.lg-body ul { padding-left: 1.2em; }
.lg-body li + li { margin-top: var(--space-3); }
.lg-body li::marker { color: var(--text-3); }
.lg-body strong { font-weight: var(--fw-bold); }
.lg-body .muted { color: var(--text-2); }
.lg-body a { font-weight: var(--fw-semibold); overflow-wrap: anywhere; }

.lg-sec { margin-top: var(--space-10); }
.lg-sec h2 {
  display: flex; align-items: baseline; gap: var(--space-4); margin-bottom: var(--space-5);
  font: var(--fw-bold) var(--fs-title-l)/1.15 var(--font-ui); font-stretch: 94%; letter-spacing: var(--track-tight);
}
.lg-n {
  flex: none; min-width: 1.1em; font-family: var(--font-num); font-weight: var(--fw-num);
  font-variation-settings: var(--num-variation); letter-spacing: 0; color: var(--text-3);
}
.lg-sec h3 { margin-top: var(--space-7); font: var(--fw-bold) var(--fs-body-l)/1.3 var(--font-ui); letter-spacing: -0.005em; }
.lg-sec h2 + h3 { margin-top: 0; }

/* ---- Cards: the short version, who sees what, the Google Limited Use statement ---- */
.lg-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-1), var(--inner-highlight); padding: var(--space-6) var(--space-5);
}
.lg-card--well { background: var(--surface-2); box-shadow: none; }
.lg-card__title { display: flex; align-items: center; gap: var(--space-3); margin-bottom: var(--space-4); font: var(--fw-bold) var(--fs-title-s)/1.3 var(--font-ui); }
.lg-card__title .icon { color: var(--text-2); }
.lg-card ul { padding-left: 1.1em; }
.lg-card li + li { margin-top: var(--space-3); }
.lg-card p + p { margin-top: var(--space-3); }

.lg-short { list-style: none; padding: 0 !important; }
.lg-short li { display: grid; grid-template-columns: 22px minmax(0, 1fr); gap: var(--space-3); align-items: start; }
.lg-short .icon { margin-top: 3px; color: var(--text-2); }

.lg-pair { display: grid; gap: var(--space-4); margin-top: var(--space-5); }
@media (min-width: 640px) { .lg-pair { grid-template-columns: 1fr 1fr; } }
.lg-pair .lg-card { font-size: var(--fs-body); }

.lg-quote {
  margin: var(--space-4) 0 0; padding-left: var(--space-5); border-left: 2px solid var(--line-strong);
  font-family: var(--font-voice); font-style: italic; font-variation-settings: var(--voice-variation);
  font-size: var(--fs-voice); line-height: var(--lh-voice); color: var(--text-1);
}

/* ---- On this page (a native disclosure, so it works without script) ---- */
.lg-toc { margin-top: var(--space-7); border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface); box-shadow: var(--shadow-1); }
.lg-toc summary {
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-3);
  min-height: 52px; padding: 0 var(--space-5); cursor: pointer; list-style: none;
  font: var(--fw-semibold) var(--fs-body)/1.2 var(--font-ui); color: var(--text-1); border-radius: var(--radius-lg);
}
.lg-toc summary::-webkit-details-marker { display: none; }
.lg-toc summary .icon { color: var(--text-3); transition: transform var(--dur-base) var(--ease-out); }
.lg-toc[open] summary .icon { transform: rotate(180deg); }
.lg-toc ol { margin: 0; padding: 0 var(--space-5) var(--space-4); list-style: none; counter-reset: toc; border-top: 1px solid var(--line); }
.lg-toc li { counter-increment: toc; }
.lg-toc li + li { margin-top: 0; }
.lg-toc a {
  display: flex; align-items: center; gap: var(--space-4); min-height: var(--tap);
  color: var(--text-1); font-size: var(--fs-body); font-weight: var(--fw-medium); text-decoration: none;
}
.lg-toc a::before {
  content: counter(toc); min-width: 1.4em; font-family: var(--font-num); font-weight: var(--fw-num);
  font-variation-settings: var(--num-variation); color: var(--text-3);
}
.lg-toc a:hover { text-decoration: underline; }

/* ---- Footer ---- */
.lg-foot { margin-top: var(--space-11); padding-top: var(--space-6); border-top: 1px solid var(--line); font-size: var(--fs-body-s); color: var(--text-2); }
.lg-foot nav { display: flex; flex-wrap: wrap; gap: 0 var(--space-5); margin-bottom: var(--space-3); }
.lg-foot a { display: inline-flex; align-items: center; min-height: var(--tap); font-weight: var(--fw-semibold); }
.lg-foot a[aria-current="page"] { text-decoration: none; color: var(--text-2); }

/* ---- Inside the iPhone app's in-app browser (?app=ios; js/legal.js sets <html data-in-app>) ---- */
/* No way into the web app from the sheet: it would show the "Add to Home Screen" card there (R7). */
:root[data-in-app] .lg-open,
:root[data-in-app] .lg-foot a[href="/"] { display: none; }
:root[data-in-app] .lg-brand { pointer-events: none; }

@media (min-width: 640px) {
  .lg-head h1 { font-size: 44px; }
}

@media print {
  .lg-light, .lg-open, .lg-toc, .skip, .lg-foot nav { display: none !important; }
  body.grain::before { display: none; }
  .lg-card { box-shadow: none; }
  .lg-sec { break-inside: avoid-page; }
}
