/* Noonish — legal / support documents.
 *
 * Deliberately standalone rather than layered on site.css: the splash page is
 * a fixed, non-scrolling composition (`overflow: hidden`, everything
 * `position: fixed`), which is exactly wrong for a long document.
 *
 * These pages are read by two audiences with equal claim on them: someone
 * deciding whether to trust the app, and an App Store reviewer checking the
 * URL resolves. Both are served by plain, high-contrast, unfussy text.
 *
 * They follow the splash's mode. The same inline boot script runs here - not a
 * copy of it: render.py lifts it out of index.html at build time, so the two
 * pages cannot drift and the one test covers both. localStorage is per-origin,
 * so a choice made on the splash is already in force by the time a visitor
 * lands on /privacy.
 */

:root[data-theme="light"] {
  --page: #ffffff;
  /* Same colour as the splash's ink. The bar fades to a TRANSPARENT page rather
   * than to `transparent`, which interpolates through transparent-black in some
   * engines and leaves a grey fringe over white. */
  --page-fade: rgba(255,255,255,0);
  --ink: #111111;
  --ink-dim: rgba(0,0,0,.62);
  --rule: rgba(0,0,0,.14);
  --rule-faint: rgba(0,0,0,.07);
  --code-bg: rgba(0,0,0,.06);
  --accent: #1a1a1a;
}

:root[data-theme="dark"] {
  --page: #0e0f0c;
  --page-fade: rgba(14,15,12,0);
  --ink: #f2f3ee;
  --ink-dim: rgba(242,243,238,.62);
  --rule: rgba(242,243,238,.14);
  --rule-faint: rgba(242,243,238,.07);
  --code-bg: rgba(242,243,238,.09);
  --accent: #e8ecdf;
}

:root {
  --measure: 68ch;
  --brand-font: Helvetica, "Helvetica Neue", Arial, sans-serif;
  /* Same gutter and footer size as the splash, so the copyright on this page
   * lands exactly where the copyright on the splash does. */
  --gutter: clamp(20px, 4.375vw, 88px);
  --fs-footer: clamp(12.5px, .984vw, 21px);
  --fade-in: .7s;
  --mode-fade: .3s;
}

*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font-family: var(--brand-font);
  font-size: 17px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  /* iOS: keep the page readable in landscape with a notch */
  padding: 0 max(var(--gutter), env(safe-area-inset-left))
           0 max(var(--gutter), env(safe-area-inset-right));

  /* Matches the splash. CSS-only so a script failure can't strand it hidden. */
  animation: page-in var(--fade-in) ease both;
  transition: background-color var(--mode-fade) ease, color var(--mode-fade) ease;
}

@keyframes page-in { from { opacity: 0 } to { opacity: 1 } }

a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }

/* --- chrome ------------------------------------------------------------ */

/* Full-bleed chrome over a centred measure: the wordmark and the close sit at
 * the viewport edges, on the splash's gutter, while the prose stays readable. */
.doc__bar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 26px 0 18px;
  /* The bar scrolls text underneath itself, so it needs to occlude. */
  background: linear-gradient(to bottom,
    var(--page) 0%, var(--page) 62%, var(--page-fade) 100%);
}

.doc__home {
  font-size: 20px;
  line-height: 1;
  color: var(--ink);
  text-decoration: none;
  transition: opacity .22s ease;
}
.doc__home:hover { opacity: .62; }

.doc__close {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  margin-right: -7px;          /* optically aligns the glyph to the gutter */
  border-radius: 8px;
  color: var(--ink);
  transition: opacity .22s ease;
}
.doc__close svg { width: 19px; height: 19px; display: block; }
.doc__close:hover { opacity: .62; }

.doc {
  max-width: var(--measure);
  margin: 0 auto;
  padding: 26px 0 72px;
}

.doc__foot {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 26px;
  justify-content: space-between;
  align-items: baseline;
  padding: 30px 0 44px;
  border-top: 1px solid var(--rule);
  font-size: var(--fs-footer);
  color: var(--ink);
}
.doc__foot p { margin: 0; }
.doc__legal { display: flex; flex-wrap: wrap; gap: 1.5em; }
.doc__foot a {
  color: inherit;
  text-decoration: none;
  transition: opacity .22s ease;
}
.doc__foot a:hover { opacity: .62; }

/* --- document ----------------------------------------------------------- */

.doc h1 {
  margin: 0 0 6px;
  font-size: clamp(30px, 4.4vw, 40px);
  font-weight: 400;
  line-height: 1.16;
  letter-spacing: -.01em;
}

.doc h2 {
  margin: 46px 0 10px;
  font-size: clamp(21px, 2.6vw, 25px);
  font-weight: 400;
  line-height: 1.25;
}

.doc h3 {
  margin: 34px 0 6px;
  font-size: 18px;
  font-weight: 700;
  line-height: 1.35;
}

.doc p, .doc li { margin: 0 0 15px; }
.doc ul, .doc ol { margin: 0 0 15px; padding-left: 1.35em; }
.doc li { margin-bottom: 7px; }
.doc li::marker { color: var(--ink-dim); }

.doc strong { font-weight: 700; }

.doc hr {
  margin: 42px 0;
  border: 0;
  border-top: 1px solid var(--rule);
}

.doc blockquote {
  margin: 0 0 15px;
  padding: 2px 0 2px 18px;
  border-left: 2px solid var(--rule);
  color: var(--ink-dim);
}

.doc code {
  padding: .12em .34em;
  border-radius: 4px;
  background: var(--code-bg);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: .88em;
}

/* Tables carry the privacy policy's "what we store" matrix, which is the part
 * a reviewer actually reads. It has to survive a phone. */
.doc table {
  width: 100%;
  margin: 0 0 22px;
  border-collapse: collapse;
  font-size: 15px;
}
.doc thead th {
  text-align: left;
  font-weight: 700;
  border-bottom: 1px solid var(--rule);
}
.doc th, .doc td {
  padding: 9px 14px 9px 0;
  vertical-align: top;
  border-bottom: 1px solid var(--rule-faint);
}
.doc tbody tr:last-child td { border-bottom: 0; }

/* Wide content scrolls in its own box rather than the page scrolling sideways. */
.doc__scroll, .doc table { display: block; overflow-x: auto; }
@media (min-width: 640px) { .doc table { display: table; } }

@media (max-width: 560px) {
  body { font-size: 16px; }
  .doc__bar { padding-top: 18px; }
  .doc__foot { justify-content: flex-start; }
}

@media (prefers-reduced-motion: reduce) {
  body { animation: none; transition: none; }
  .doc__home, .doc__close, .doc__foot a { transition: none; }
}
