/* =========================================================================
   Legal pages — Terms & Privacy

   Shares its token names with styles.css on purpose: the same `--bg`,
   `--surface`, `--separator`, `--label`, `--accent` and `--ease`. That is what
   makes these pages feel like part of the translator rather than a bolted-on
   document, and it means the theme toggle behaves identically on all three.
   ========================================================================= */

:root {
  --font-sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Segoe UI", system-ui, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  --sp-1: 4px;  --sp-2: 8px;   --sp-3: 12px; --sp-4: 16px;
  --sp-5: 20px; --sp-6: 24px;  --sp-7: 32px; --sp-8: 48px;

  --r-xs: 6px; --r-sm: 8px; --r-md: 12px; --r-lg: 16px; --r-xl: 20px;

  --dur: 200ms;
  --dur-fast: 140ms;
  --ease: cubic-bezier(.32, .72, 0, 1);

  --bar-h: 44px;
  --tap: 44px;
  --prose-w: 70ch;
  --gutter: 20px;
  --shell-max: 1180px;
}

/* ------------------------------------------------------------- light mode */
:root,
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f2f2f7;
  --surface: #ffffff;
  --surface-2: #f9f9fb;
  --label: #000000;
  --label-2: rgba(60, 60, 67, .6);
  --label-3: rgba(60, 60, 67, .3);
  --separator: rgba(60, 60, 67, .29);
  --fill: rgba(120, 120, 128, .12);
  --fill-2: rgba(120, 120, 128, .18);
  --accent: #007aff;
  --accent-press: #0062cc;
  --green: #34c759;
  --orange: #ff9500;
  --on-accent: #ffffff;
  --material: rgba(249, 249, 251, .72);
  --shadow-pop: 0 12px 40px rgba(0, 0, 0, .16);
  --sel: rgba(0, 122, 255, .18);
}

/* -------------------------------------------------------------- dark mode */
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #000000;
  --surface: #1c1c1e;
  --surface-2: #2c2c2e;
  --label: #ffffff;
  --label-2: rgba(235, 235, 245, .6);
  --label-3: rgba(235, 235, 245, .3);
  --separator: rgba(84, 84, 88, .65);
  --fill: rgba(120, 120, 128, .36);
  --fill-2: rgba(120, 120, 128, .28);
  --accent: #0a84ff;
  --accent-press: #409cff;
  --green: #30d158;
  --orange: #ff9f0a;
  --on-accent: #ffffff;
  --material: rgba(28, 28, 30, .72);
  --shadow-pop: 0 16px 48px rgba(0, 0, 0, .6);
  --sel: rgba(10, 132, 255, .28);
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 17px;               /* iOS body */
  line-height: 1.6;
  color: var(--label);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
}

svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

a { color: var(--accent); text-decoration-color: color-mix(in srgb, var(--accent) 40%, transparent); text-underline-offset: 3px; }
a:hover { text-decoration-color: currentColor; }

::selection { background: var(--sel); }

:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent) 55%, transparent);
  outline-offset: 2px;
  border-radius: var(--r-xs);
}

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}

.skip-link {
  position: fixed; top: -100px; left: 50%; transform: translateX(-50%);
  z-index: 200; padding: 12px 20px;
  background: var(--accent); color: var(--on-accent);
  border-radius: 0 0 var(--r-md) var(--r-md);
  text-decoration: none; font-weight: 600;
  transition: top var(--dur) var(--ease);
}
.skip-link:focus { top: 0; }

/* reading progress — sits above the frosted bar, like a scroll indicator */
.progress { position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 50; pointer-events: none; }
.progress__bar {
  height: 100%; width: 0%;
  background: var(--accent);
  transition: width 90ms linear;
}

/* ------------------------------------------------------- navigation bar */
/* Same 44pt frosted bar as the app, so the transition between them is invisible. */
.legal-head {
  position: sticky; top: 0; z-index: 40;
  background: var(--material);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
}
.legal-head__inner {
  max-width: var(--shell-max); margin-inline: auto;
  height: calc(var(--bar-h) + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) var(--gutter) 0;
  display: flex; align-items: center; gap: var(--sp-2);
}
.legal-head__inner::after {
  /* hairline that hugs the bar's own bottom edge */
  content: "";
  position: absolute; left: 0; right: 0;
  top: calc(var(--bar-h) + env(safe-area-inset-top));
  height: 1px;
  background: var(--separator);
  pointer-events: none;
}

/* iOS "back" chevron button: tinted pill, not an outlined chip */
.back-link {
  display: inline-flex; align-items: center; gap: 4px;
  min-height: 32px;
  padding: 5px 11px 5px 6px;
  border-radius: var(--r-sm);
  background: var(--fill);
  color: var(--accent);
  font-size: 16px; font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
  transition: background-color var(--dur-fast) var(--ease);
}
.back-link:hover { background: var(--fill-2); }
.back-link:active { opacity: .6; }
.back-link svg { width: 19px; height: 19px; stroke-width: 2.1; }
@media (max-width: 400px) { .back-link { padding-inline: 6px; } .back-link__text { display: none; } }

.legal-head__title {
  margin: 0 auto 0 0; font-size: 17px; font-weight: 600; letter-spacing: -.015em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* Matches the app's icon-btn so all three pages share one control */
.theme-btn {
  width: var(--tap); height: var(--tap); flex: 0 0 auto;
  display: grid; place-items: center;
  border: 0; border-radius: var(--r-sm);
  background: transparent;
  color: var(--label-2);
  cursor: pointer;
  transition: background-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.theme-btn:hover { background: var(--fill); color: var(--label); }
.theme-btn:active { background: var(--fill-2); }
.theme-btn svg { width: 21px; height: 21px; }
.theme-btn .icon-sun,
.theme-btn .icon-moon,
.theme-btn .icon-auto { display: none; }
:root[data-theme-mode="light"] .theme-btn .icon-sun,
:root:not([data-theme-mode]) .theme-btn .icon-auto { display: block; }
:root[data-theme-mode="dark"] .theme-btn .icon-moon { display: block; }
:root[data-theme-mode="auto"] .theme-btn .icon-auto { display: block; }

/* --------------------------------------------------------------- wrapper */
.legal-shell {
  max-width: var(--shell-max);
  margin-inline: auto;
  padding: var(--sp-7) var(--gutter) var(--sp-8);
  display: grid;
  grid-template-columns: 244px minmax(0, 1fr);
  gap: var(--sp-8);
  align-items: start;
}

/* ------------------------------------------------------------------ toc */
/* Reads as an iOS sidebar list: 44pt rows, rounded highlight, no chrome. */
.toc {
  position: sticky;
  top: calc(var(--bar-h) + var(--sp-4) + env(safe-area-inset-top));
  max-height: calc(100vh - var(--bar-h) - var(--sp-7));
  overflow-y: auto;
  scrollbar-width: none;
}
.toc::-webkit-scrollbar { display: none; }
.toc__label {
  margin: 0 0 var(--sp-1); padding-inline: var(--sp-3);
  font-size: 13px; font-weight: 400;
  letter-spacing: .01em;
  color: var(--label-2);
}
.toc__list { margin: 0; padding: 0; list-style: none; }
.toc__list li { margin: 0; }
.toc__list a {
  display: flex; align-items: center;
  min-height: 36px;
  padding: 6px var(--sp-3);
  border-radius: var(--r-sm);
  color: var(--label);
  font-size: 15px;
  line-height: 1.35;
  text-decoration: none;
  transition: background-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.toc__list a:hover { background: var(--fill); }
.toc__list a.is-current {
  background: var(--fill-2);
  color: var(--accent);
  font-weight: 590;
}

/* ---------------------------------------------------------------- prose */
.doc { max-width: var(--prose-w); }
.doc__eyebrow {
  margin: 0 0 var(--sp-1);
  font-size: 13px; font-weight: 590;
  letter-spacing: .01em;
  color: var(--accent);
}
/* iOS large title */
.doc h1 {
  margin: 0 0 var(--sp-3);
  font-size: 34px;
  line-height: 1.18;
  font-weight: 700;
  letter-spacing: -.022em;
}
.doc__lede { margin: 0 0 var(--sp-4); font-size: 17px; line-height: 1.5; color: var(--label-2); }
.doc__meta {
  display: flex; flex-wrap: wrap; gap: var(--sp-1) var(--sp-5);
  margin: 0 0 var(--sp-6); padding-bottom: var(--sp-5);
  border-bottom: 1px solid var(--separator);
  font-size: 13px; color: var(--label-2);
}
.doc__meta strong { font-weight: 590; color: var(--label); }

/* Title 2 for sections, Headline weight for sub-sections */
.doc h2 {
  margin: var(--sp-8) 0 var(--sp-3);
  font-size: 22px; line-height: 1.27;
  font-weight: 700;
  letter-spacing: -.018em;
  scroll-margin-top: calc(var(--bar-h) + var(--sp-5) + env(safe-area-inset-top));
}
.doc h2:first-of-type { margin-top: 0; }
.doc h3 {
  margin: var(--sp-5) 0 var(--sp-2);
  font-size: 17px; line-height: 1.4;
  font-weight: 590;
  letter-spacing: -.01em;
  scroll-margin-top: calc(var(--bar-h) + var(--sp-5) + env(safe-area-inset-top));
}
.doc p { margin: 0 0 var(--sp-3); }
.doc ul, .doc ol { margin: 0 0 var(--sp-4); padding-left: 24px; }
.doc li { margin-bottom: var(--sp-2); }
.doc li::marker { color: var(--accent); }
.doc strong { font-weight: 590; }
.doc code {
  font-family: var(--font-mono);
  font-size: .85em;
  padding: 2px 6px;
  border-radius: var(--r-xs);
  background: var(--fill);
  color: var(--label);
}

/* --- callout: an inset tinted card, the way iOS surfaces a note --- */
.callout {
  margin: 0 0 var(--sp-5);
  padding: var(--sp-4);
  border-radius: var(--r-md);
  background: color-mix(in srgb, var(--accent) 9%, var(--surface));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 22%, transparent);
  font-size: 16px;
  color: var(--label-2);
}
.callout > :last-child { margin-bottom: 0; }
.callout strong { color: var(--label); font-weight: 590; }
.callout--warn {
  background: color-mix(in srgb, var(--orange) 11%, var(--surface));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--orange) 28%, transparent);
}

/* --- card: plain inset grouped surface --- */
.card {
  margin: 0 0 var(--sp-5);
  padding: var(--sp-4);
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: 0 1px 2px rgba(0, 0, 0, .05);
}
.card h3 { margin-top: 0; }
.card > :last-child { margin-bottom: 0; }

table {
  width: 100%;
  margin: 0 0 var(--sp-5);
  border-collapse: collapse;
  font-size: 15px;
}
th, td {
  padding: var(--sp-2) var(--sp-3);
  text-align: left; vertical-align: top;
  border-bottom: 1px solid var(--separator);
}
th { color: var(--label-2); font-weight: 590; font-size: 13px; }
tr:last-child td { border-bottom: 0; }

/* --- facts: an inset grouped table, rows separated by hairlines --- */
.facts {
  margin: 0 0 var(--sp-5);
  border-radius: var(--r-lg);
  background: var(--surface);
  overflow: hidden;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .05);
}
.facts__row {
  display: grid;
  grid-template-columns: 200px minmax(0, 1fr);
  gap: var(--sp-1) var(--sp-4);
  padding: var(--sp-3) var(--sp-4);
  font-size: 15px;
  line-height: 1.45;
}
.facts__row + .facts__row { border-top: 1px solid var(--separator); }
.facts__key { color: var(--label-2); font-weight: 400; }
.facts__val { color: var(--label); min-width: 0; }
.facts__val code { font-size: .82em; }

/* --- steps: numbered rows joined by a connector, like an onboarding flow --- */
.steps { margin: 0 0 var(--sp-4); padding: 0; list-style: none; counter-reset: step; }
.steps > li {
  position: relative;
  padding: 0 0 var(--sp-4) 36px;
  counter-increment: step;
}
.steps > li::before {
  content: counter(step);
  position: absolute; left: 0; top: 0;
  width: 24px; height: 24px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--accent);
  color: var(--on-accent);
  font-size: 13px; font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.steps > li::after {
  content: "";
  position: absolute; left: 11.5px; top: 30px; bottom: 6px;
  width: 1px;
  background: var(--separator);
}
.steps > li:last-child { padding-bottom: 0; }
.steps > li:last-child::after { display: none; }
.steps p { margin: 0 0 var(--sp-1); color: var(--label); }
.steps > li > :last-child { margin-bottom: 0; }

.doc__foot {
  margin-top: var(--sp-8);
  padding-top: var(--sp-5);
  border-top: 1px solid var(--separator);
  font-size: 15px;
  color: var(--label-2);
}
.doc__nav { display: flex; flex-wrap: wrap; gap: var(--sp-2); margin-top: var(--sp-4); }
/* iOS tinted buttons */
.doc__nav a {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 40px;
  padding: 9px var(--sp-4);
  border-radius: var(--r-md);
  background: var(--fill);
  color: var(--label);
  font-size: 16px; font-weight: 590;
  text-decoration: none;
  transition: background-color var(--dur-fast) var(--ease);
}
.doc__nav a:hover { background: var(--fill-2); }
.doc__nav a:active { opacity: .6; }
.doc__nav svg { width: 17px; height: 17px; }

/* ---------------------------------------------------------------- footer */
.legal-foot { border-top: 1px solid var(--separator); background: var(--surface); }
.legal-foot__inner {
  max-width: var(--shell-max); margin-inline: auto;
  padding: var(--sp-5) var(--gutter) calc(var(--sp-5) + env(safe-area-inset-bottom));
  display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-1) var(--sp-5);
  font-size: 13px; color: var(--label-2);
}
.legal-foot nav { margin-left: auto; display: flex; gap: var(--sp-4); }
.legal-foot a { color: var(--label-2); text-decoration: none; }
.legal-foot a:hover { color: var(--accent); text-decoration: underline; }

/* ============================================================== responsive */
@media (max-width: 940px) {
  .legal-shell {
    grid-template-columns: minmax(0, 1fr);
    gap: var(--sp-5);
    padding: var(--sp-5) var(--gutter) var(--sp-8);
  }
  /* TOC collapses to a two-column grouped card above the document */
  .toc {
    position: static; max-height: none;
    padding: var(--sp-3) var(--sp-2);
    border-radius: var(--r-lg);
    background: var(--surface);
    box-shadow: 0 1px 2px rgba(0, 0, 0, .05);
  }
  .toc__label { padding-inline: var(--sp-3); }
  .toc__list { columns: 2; column-gap: var(--sp-3); }
  .facts__row { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 560px) {
  :root { --gutter: 16px; }
  body { font-size: 16px; }
  .doc h1 { font-size: 30px; }
  .doc h2 { font-size: 20px; margin-top: var(--sp-7); }
  .toc__list { columns: 1; }
  .legal-head__title { font-size: 16px; }
  .legal-foot nav { margin-left: 0; width: 100%; }
  table { display: block; overflow-x: auto; }
  .doc__nav a { flex: 1 1 auto; justify-content: center; }
}

@media print {
  .legal-head, .toc, .legal-foot, .progress, .skip-link { display: none; }
  body { background: #fff; color: #000; font-size: 12pt; }
  .legal-shell { display: block; padding: 0; max-width: none; }
  .doc { max-width: none; }
  .doc h2 { page-break-after: avoid; }
  .card, .facts, .callout { box-shadow: none; border: 1px solid #ccc; }
  a { color: #000; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
  }
}
