/* ═══════════════════════════════════════════════════════════════
   Service Terms page (terms.html)
   External on purpose: the CloudFront CSP is style-src 'self', so
   inline <style> blocks are stripped by the browser. Tokens are
   mirrored from css/style.css; if the palette changes, update both.
   ═══════════════════════════════════════════════════════════════ */

/* ── Tokens (mirrored from css/style.css) ───────────────────── */
:root {
  color-scheme: light;

  --cream:    #FAF5EC;
  --cream-2:  #F4ECDD;
  --band:     #F6EFE1;
  --paper:    #FFFDF8;

  --ink:      #292437;
  --ink-2:    #4E4760;
  --muted:    #6E6680;

  --green:        #17A15E;
  --green-deep:   #0C7A46;
  --green-bright: #2ED47F;

  --sun:        #FFC933;
  --sun-bright: #FFD23F;
  --amber-deep: #8A5A00;

  --violet:        #7C3AED;
  --violet-deep:   #5B21B6;
  --violet-bright: #A78BFA;
  --lilac:         #EDE6FB;

  --line:      rgba(41, 36, 55, .12);
  --line-soft: rgba(41, 36, 55, .07);

  --shadow-sm: 0 2px 8px rgba(70, 56, 110, .05), 0 12px 26px -16px rgba(70, 56, 110, .14);
  --shadow-md: 0 4px 14px rgba(70, 56, 110, .07), 0 24px 48px -22px rgba(70, 56, 110, .20);

  --grad-text: linear-gradient(105deg, var(--green-deep), var(--green) 30%, var(--violet) 88%);

  --mono:  'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  --sans:  'Space Grotesk', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --serif: 'Fraunces', Georgia, 'Times New Roman', serif;

  --nav-h: 70px;
  --r: 20px;

  --ease: cubic-bezier(.22, 1, .36, 1);
}

@supports (background: linear-gradient(in oklch, red, blue)) {
  :root {
    --grad-text: linear-gradient(105deg in oklch, var(--green-deep), var(--green) 26%, var(--violet) 92%);
  }
}

/* Dark theme: the cyber-terminal remap, same values as the homepage. */
:root[data-theme="dark"] {
  color-scheme: dark;

  --cream:   #060807;
  --cream-2: #0d1310;
  --band:    #0a0f0c;
  --paper:   #0c1310;

  --ink:   #e6f4ec;
  --ink-2: #a9c3b6;
  --muted: #7d9488;

  --green:        #00ff9c;
  --green-deep:   #00ff9c;
  --green-bright: #00ff9c;

  --sun:        #ffd60a;
  --sun-bright: #ffe14d;
  --amber-deep: #ffd60a;

  --violet:        #b6ff3a;
  --violet-deep:   #d2ff7d;
  --violet-bright: #b6ff3a;
  --lilac:         rgba(182, 255, 58, .13);

  --line:      rgba(0, 255, 156, .2);
  --line-soft: rgba(0, 255, 156, .13);

  --shadow-sm: 0 2px 10px rgba(0, 0, 0, .5),  0 0 0 1px rgba(0, 255, 156, .04);
  --shadow-md: 0 8px 26px rgba(0, 0, 0, .58), 0 0 22px -6px rgba(0, 255, 156, .18);

  --grad-text: linear-gradient(100deg, var(--green), var(--violet) 55%, var(--sun));

  --r: 14px;
}

/* ── Reset ──────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; padding: 0; }

html {
  background: var(--cream);
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--nav-h) + 18px);
  -webkit-text-size-adjust: 100%;
}

body {
  background: var(--cream);
  color: var(--ink);
  font-family: var(--sans);
  font-size: clamp(15px, .55vw + 13.6px, 17px);
  line-height: 1.7;
  accent-color: var(--violet);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

img, svg { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }

::selection { background: var(--violet); color: #FBF7EF; }

:focus-visible {
  outline: 3px solid var(--violet);
  outline-offset: 3px;
  border-radius: 6px;
}

.skip {
  position: fixed; top: -100px; left: 16px; z-index: 999;
  background: var(--violet); color: #fff;
  padding: 10px 18px; border-radius: 999px; font-weight: 700;
  box-shadow: var(--shadow-md);
  transition: top .2s;
}
.skip:focus { top: 14px; }
:root[data-theme="dark"] .skip { color: #04120b; }

/* ── Nav: same bar as the homepage, translucent from the start ── */
.nav {
  position: fixed; top: 0; left: 0; right: 0; z-index: 50;
  height: var(--nav-h);
  display: flex; align-items: center; justify-content: space-between;
  gap: 20px;
  padding: 0 clamp(16px, 4vw, 42px);
  background: rgba(250, 245, 236, .86);
  backdrop-filter: blur(14px) saturate(1.4);
  -webkit-backdrop-filter: blur(14px) saturate(1.4);
  border-bottom: 1px solid var(--line-soft);
  box-shadow: 0 14px 34px -22px rgba(70, 56, 110, .22);
}
:root[data-theme="dark"] .nav {
  background: rgba(6, 8, 7, .82);
  box-shadow: 0 14px 34px -22px rgba(0, 0, 0, .8);
}

.nav__brand { display: flex; align-items: center; gap: 10px; }
.nav__mark { color: var(--violet); display: grid; place-items: center; }
.nav__mark svg { animation: spinSlow 24s linear infinite; }
@keyframes spinSlow { to { transform: rotate(360deg); } }

.nav__name {
  font-family: var(--mono);
  font-weight: 700; font-size: 13.5px; letter-spacing: .2em;
  background: var(--grad-text);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}

.nav__end { display: flex; align-items: center; gap: 14px; }

.nav__back {
  font-family: var(--mono); font-size: 12.5px; letter-spacing: .1em;
  text-transform: uppercase; color: var(--ink-2);
  padding: 9px 14px; border-radius: 999px;
  transition: color .25s, background .25s;
}
.nav__back:hover { color: var(--violet); background: rgba(124, 58, 237, .07); }
:root[data-theme="dark"] .nav__back:hover { background: rgba(0, 255, 156, .08); }

/* theme toggle, same control as the homepage */
.themetog {
  position: relative; flex: none;
  width: 58px; height: 30px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--cream-2);
  transition: border-color .25s, box-shadow .25s;
}
.themetog:hover { border-color: var(--violet); box-shadow: 0 0 0 4px rgba(124, 58, 237, .1); }
.themetog__thumb {
  position: absolute; top: 3px; left: 3px;
  width: 22px; height: 22px; border-radius: 50%;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--sun), var(--sun-bright));
  color: #6b4d00;
  transition: transform .35s var(--ease), background .35s;
}
.themetog__ico { position: absolute; transition: opacity .25s, transform .35s var(--ease); }
.themetog__ico--moon { opacity: 0; transform: rotate(-50deg) scale(.5); }
:root[data-theme="dark"] .themetog__thumb {
  transform: translateX(28px);
  background: linear-gradient(135deg, var(--green), var(--violet));
  color: #04120b;
  box-shadow: 0 0 14px rgba(0, 255, 156, .5);
}
:root[data-theme="dark"] .themetog__ico--sun  { opacity: 0; transform: rotate(50deg) scale(.5); }
:root[data-theme="dark"] .themetog__ico--moon { opacity: 1; transform: none; }
:root[data-theme="dark"] .themetog:hover { box-shadow: 0 0 0 4px rgba(0, 255, 156, .12); }

/* ── Archive notice ─────────────────────────────────────────────
   Only the dated copies under /terms/ use this; /terms itself never
   renders it. It sits above the plate rather than inside it, because
   the plate down is a byte-for-byte copy of the live document and
   nothing may be added there (tests/terms-version.test.mjs). Amber
   rather than red: the page is authentic and citable, just not current. */
.archived {
  max-width: 1060px;
  margin: calc(var(--nav-h) + clamp(24px, 4vw, 40px)) auto calc(-1 * clamp(20px, 4vw, 40px));
  padding: 0 clamp(18px, 4vw, 42px);
}
.archived__tag {
  font-family: var(--mono); font-size: 11px; font-weight: 700;
  letter-spacing: .18em; text-transform: uppercase;
  color: var(--amber-deep);
}
.archived__text {
  margin-top: 4px; padding-left: 14px;
  border-left: 3px solid var(--amber-deep);
  font-size: 14.5px; line-height: 1.7; color: var(--ink-2);
}
.archived__text a { color: inherit; border-bottom: 1px dashed currentColor; }

/* ── Document plate: the official cover block ───────────────── */
.plate {
  max-width: 1060px;
  margin: calc(var(--nav-h) + clamp(40px, 8vw, 76px)) auto 0;
  padding: 0 clamp(18px, 4vw, 42px);
}

.plate__mark {
  display: flex; align-items: center; gap: 14px;
  color: var(--violet);
  font-family: var(--mono); font-weight: 700;
  font-size: 12.5px; letter-spacing: .3em; text-transform: uppercase;
}
.plate__mark .rule { flex: 1; height: 1px; background: var(--line); }

.plate h1 {
  font-family: var(--serif);
  font-weight: 600;
  font-size: clamp(38px, 7vw, 72px);
  line-height: 1.05;
  letter-spacing: -.015em;
  margin: 22px 0 10px;
}
.plate h1 em {
  font-style: italic;
  background: var(--grad-text);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}

.plate__lede {
  max-width: 62ch;
  color: var(--ink-2);
  font-size: clamp(15.5px, 1.4vw, 18px);
}
.plate__lede b { color: var(--ink); }

/* the metadata strip: a spec sheet, not a subtitle */
.plate__meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 0 26px;
  margin: clamp(26px, 4vw, 40px) 0 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.plate__meta div {
  padding: 14px 0 16px;
  font-family: var(--mono);
}
.plate__meta dt {
  font-size: 10.5px; letter-spacing: .22em; text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 4px;
}
.plate__meta dd { font-size: 13px; color: var(--ink); font-weight: 500; }
.plate__meta dd a { color: var(--violet); }
.plate__meta dd a:hover { text-decoration: underline; text-underline-offset: 3px; }

/* ── Document body: sticky contents + measure ───────────────── */
.doc {
  max-width: 1060px;
  margin: 0 auto;
  padding: clamp(34px, 6vw, 64px) clamp(18px, 4vw, 42px) clamp(60px, 8vw, 96px);
  display: grid;
  grid-template-columns: 230px minmax(0, 1fr);
  gap: clamp(28px, 5vw, 64px);
  align-items: start;
}

.toc {
  position: sticky;
  top: calc(var(--nav-h) + 26px);
  font-family: var(--mono);
}
.toc h2 {
  font-size: 10.5px; letter-spacing: .24em; text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 12px;
}
.toc ol { counter-reset: toc; }
.toc li { list-style: none; counter-increment: toc; }
.toc a {
  display: flex; gap: 10px; align-items: baseline;
  padding: 5px 8px; margin-left: -8px;
  border-radius: 8px;
  font-size: 12.5px; line-height: 1.45;
  color: var(--ink-2);
  transition: color .2s, background .2s;
}
.toc a::before {
  content: counter(toc, decimal-leading-zero);
  font-size: 10.5px; color: var(--violet);
  flex: none;
}
.toc a:hover { color: var(--violet-deep); background: var(--lilac); }

.paper {
  background: var(--paper);
  border: 1px solid var(--line-soft);
  border-radius: var(--r);
  box-shadow: var(--shadow-sm);
  padding: clamp(24px, 4.5vw, 56px);
}

/* sections: the numbering is the document's own, so it is set large */
.sec { padding: clamp(26px, 4vw, 38px) 0; border-top: 1px solid var(--line-soft); }
.sec:first-child { padding-top: 0; border-top: 0; }
.sec:last-child { padding-bottom: 0; }

.sec__head {
  display: flex; align-items: baseline; gap: 16px;
  margin-bottom: 16px;
}
.sec__num {
  font-family: var(--mono); font-weight: 700;
  font-size: 13px; letter-spacing: .08em;
  color: var(--violet);
  flex: none;
}
.sec h2 {
  font-family: var(--serif);
  font-weight: 600;
  font-size: clamp(21px, 2.6vw, 27px);
  letter-spacing: -.01em;
  line-height: 1.2;
}

.sec p { max-width: 68ch; color: var(--ink-2); margin-bottom: 14px; }
.sec p:last-child { margin-bottom: 0; }
.sec p b, .sec li b { color: var(--ink); }
.sec ul { max-width: 68ch; margin: 0 0 14px; }
.sec ul li {
  list-style: none; position: relative;
  padding-left: 22px; margin-bottom: 8px;
  color: var(--ink-2);
}
.sec ul li::before {
  content: ''; position: absolute; left: 2px; top: .62em;
  width: 8px; height: 8px; border-radius: 50%;
  background: linear-gradient(135deg, var(--green-bright), var(--violet-bright));
}

/* tables: paper cards with a violet header band */
.tbl-wrap { overflow-x: auto; margin: 18px 0; border-radius: 14px; border: 1px solid var(--line-soft); box-shadow: var(--shadow-sm); }
table { border-collapse: collapse; width: 100%; min-width: 480px; background: var(--paper); }
caption {
  text-align: left;
  font-family: var(--mono); font-size: 10.5px; letter-spacing: .22em;
  text-transform: uppercase; color: var(--muted);
  padding: 12px 16px 10px;
  background: var(--band);
  border-bottom: 1px solid var(--line-soft);
}
th, td { text-align: left; padding: 11px 16px; border-bottom: 1px solid var(--line-soft); font-size: 14.5px; }
thead th {
  font-family: var(--mono); font-size: 11px; letter-spacing: .14em; text-transform: uppercase;
  color: var(--violet-deep);
  background: var(--lilac);
  border-bottom: 1px solid var(--line);
}
tbody tr:last-child td { border-bottom: 0; }
td { color: var(--ink-2); }
td:first-child { color: var(--ink); font-weight: 600; }
.num { font-family: var(--mono); font-size: 13.5px; }

/* Inline literals - storage keys, header names - inside document prose. */
.paper code {
  font-family: var(--mono);
  font-size: 12.5px;
  padding: 2px 7px;
  border-radius: 6px;
  background: var(--lilac);
  color: var(--ink);
}

/* callout: for the clauses that most often surprise people */
.note {
  max-width: 68ch;
  margin: 16px 0;
  padding: 14px 18px;
  border-left: 3px solid var(--violet);
  border-radius: 0 12px 12px 0;
  background: var(--lilac);
  color: var(--ink-2);
  font-size: 14.5px;
}
.note b { color: var(--ink); }

/* ── Footer: the same plum evening as the homepage ──────────── */
.foot {
  position: relative; overflow: hidden;
  background: #241F35;
  color: #F6F1E6;
  padding: 56px 0 48px;
  text-align: center;
}
:root[data-theme="dark"] .foot { background: var(--band); border-top: 1px solid var(--line-soft); }
.foot::before, .foot::after {
  content: ''; position: absolute; pointer-events: none; filter: blur(52px);
}
.foot::before {
  top: -110px; left: -80px; width: 360px; aspect-ratio: 1;
  background: radial-gradient(circle, rgba(46, 212, 127, .2), transparent 70%);
  border-radius: 58% 42% 55% 45% / 55% 48% 52% 45%;
}
.foot::after {
  bottom: -140px; right: -60px; width: 400px; aspect-ratio: 1;
  background: radial-gradient(circle, rgba(124, 58, 237, .3), transparent 70%);
  border-radius: 52% 48% 42% 58% / 45% 52% 55% 48%;
}
.foot__inner { position: relative; z-index: 1; display: grid; gap: 8px; padding: 0 18px; }
.foot__sig {
  font-family: var(--mono); font-weight: 700; font-size: 15px; letter-spacing: .2em;
  background: linear-gradient(90deg, var(--green-bright), var(--sun-bright) 55%, var(--violet-bright));
  -webkit-background-clip: text; background-clip: text; color: transparent;
  width: fit-content; margin-inline: auto;
}
.foot__meta {
  font-family: var(--mono); font-size: 11.5px; letter-spacing: .12em;
  color: rgba(246, 241, 230, .66); text-transform: uppercase;
}
:root[data-theme="dark"] .foot__meta { color: var(--muted); }
.foot__contact { font-size: 13.5px; color: rgba(246, 241, 230, .8); }
:root[data-theme="dark"] .foot__contact { color: var(--ink-2); }
.foot__contact a { text-decoration: underline; text-underline-offset: 3px; }
.foot__contact a:hover { color: var(--sun-bright); }
.foot__home {
  margin-top: 6px;
  font-family: var(--mono); font-size: 12px; letter-spacing: .1em; text-transform: uppercase;
  color: rgba(246, 241, 230, .55);
}
:root[data-theme="dark"] .foot__home { color: var(--muted); }
.foot__home a:hover { color: var(--sun-bright); }

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 940px) {
  /* minmax(0,1fr), not 1fr: the tables' min-width must not widen the page */
  .doc { grid-template-columns: minmax(0, 1fr); }
  .toc { position: static; }
  .toc ol {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 0 18px;
  }
}
/* Narrow phones: "← Back to site" is swapped for the one word "Home" so the
   nav still fits the Store link and the theme toggle. Both rules are scoped to
   the back-to-site link by its href; unscoped they also emptied the Store link
   and appended "Home" to it, which rendered "STOREHOME" and pushed the toggle
   off the screen. Any further nav__back link needs no rule here. */
@media (max-width: 560px) {
  .nav__back[href="./"] span { display: none; }
  .nav__back[href="./"]::after { content: 'Home'; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .nav__mark svg { animation: none; }
  *, *::before, *::after { transition-duration: .01ms !important; }
}

/* ── Print: a clean black-on-white contract ─────────────────── */
@media print {
  :root, :root[data-theme="dark"] {
    --cream: #fff; --paper: #fff; --band: #fff;
    --ink: #000; --ink-2: #1a1a1a; --muted: #444;
    --violet: #000; --violet-deep: #000; --lilac: #fff;
    --line: #bbb; --line-soft: #ddd;
  }
  .nav, .toc, .skip { display: none; }
  .plate { margin-top: 0; }
  .plate h1 em { color: #000; background: none; -webkit-text-fill-color: #000; }
  .doc { display: block; padding-top: 24px; }
  .paper { border: 0; box-shadow: none; padding: 0; }
  .sec { break-inside: avoid-page; }
  .foot { background: #fff; color: #000; padding: 24px 0; }
  .foot::before, .foot::after { display: none; }
  .foot__sig { background: none; -webkit-text-fill-color: #000; color: #000; }
  .foot__meta, .foot__contact, .foot__home { color: #333; }
  .note { background: #fff; border-left-color: #000; }
  thead th { background: #fff; color: #000; }
}
