/*
 * Styles for the published legal documents (terms, privacy, and the index
 * that links them). These are plain static pages rather than a part of the
 * Svelte app on purpose: a reviewer opening a link from a Discord developer
 * portal gets a real document with a real `<title>`, a canonical URL and
 * working markup, with no JavaScript required and no dependency on the site
 * bundle being built or fresh.
 *
 * The palette and the two faces are the site's own, reused as literals rather
 * than as tokens: this file is served outside the bundle, so the custom
 * properties defined in `src/shared/tokens.css` are not in scope here. Keep
 * the two in step when either changes.
 */

/* Same faces the site bundles. `font-display: swap` so the text is readable
   before the face arrives - a legal document that flashes blank is worse
   than one that flashes in a fallback serif. */
@font-face {
  font-family: 'DossierSerif';
  src: url('/fonts/DossierSerif-Regular.ttf') format('truetype');
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: 'DossierSerif';
  src: url('/fonts/DossierSerif-Bold.ttf') format('truetype');
  font-weight: 700;
  font-display: swap;
}
@font-face {
  font-family: 'DossierMono';
  src: url('/fonts/DossierMono-Regular.ttf') format('truetype');
  font-weight: 400;
  font-display: swap;
}

:root {
  --paper: #efe9da;
  --ink: #2b2a26;
  --muted: #5d5a50;
  --faint: #8b8577;
  --rule: #cbc4b1;
  --rule-strong: #9c9480;
  --accent: #2f6f9f;
  --band: #7fa8c9;
  --font-text: 'DossierSerif', 'Iowan Old Style', Georgia, 'Times New Roman', serif;
  --font-figure: 'DossierMono', ui-monospace, 'Cascadia Mono', Consolas, monospace;
  --gutter: clamp(16px, 4vw, 40px);
  --measure: 68ch;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #14171c;
    --ink: #e7e3d7;
    --muted: #9a958a;
    --faint: #6b675e;
    --rule: #2b2f36;
    --rule-strong: #464c56;
    --accent: #6fa8d8;
    --band: #2f4a63;
  }
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  padding: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-text);
  font-size: 17px;
  line-height: 1.62;
}

/* The plate frame the rest of the site sits in, so a legal page does not look
   bolted on from somewhere else. Decorative: it is a single fixed element
   behind the text and costs nothing to remove. */
.frame {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  box-shadow:
    inset 0 0 0 1px var(--paper),
    inset 0 0 0 10px var(--ink),
    inset 0 0 0 11px var(--paper),
    inset 0 0 0 13px var(--ink);
}

.wrap {
  max-width: 860px;
  margin: 0 auto;
  padding: 0 var(--gutter) 72px;
}

/* ---- masthead ---------------------------------------------------------- */

.masthead {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px 18px;
  padding: 20px 0 14px;
}

.masthead .brand {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--ink);
  text-decoration: none;
}

.masthead .brand:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.masthead .kicker {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--faint);
}

.masthead nav {
  margin-left: auto;
  display: flex;
  flex-wrap: wrap;
  gap: 0 16px;
}

.masthead nav a {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  text-decoration: none;
}

.masthead nav a:hover {
  color: var(--ink);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.masthead nav a[aria-current='page'] {
  color: var(--ink);
  border-bottom: 2px solid var(--band);
}

/* ---- title block ------------------------------------------------------- */

h1 {
  font-size: clamp(1.9rem, 1.3rem + 2.4vw, 2.9rem);
  line-height: 1.14;
  letter-spacing: -0.012em;
  margin: 18px 0 6px;
  max-width: 22ch;
}

.standfirst {
  margin: 0 0 20px;
  color: var(--muted);
  font-size: 1.06rem;
  max-width: var(--measure);
}

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 22px;
  margin: 0 0 26px;
  padding: 10px 0;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  font-family: var(--font-figure);
  font-size: 0.76rem;
  color: var(--muted);
}

.meta b {
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--faint);
}

/* ---- contents ---------------------------------------------------------- */

.toc {
  margin: 0 0 38px;
  padding: 16px 20px;
  border: 1px solid var(--rule);
  border-left: 3px solid var(--band);
}

.toc h2 {
  margin: 0 0 8px;
  font-size: 0.72rem;
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--faint);
}

.toc ol {
  margin: 0;
  padding: 0;
  list-style: none;
  columns: 2;
  column-gap: 28px;
}

.toc li {
  margin: 0;
  font-size: 0.9rem;
  break-inside: avoid;
}

.toc a {
  color: var(--muted);
  text-decoration: none;
}

.toc a:hover {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.toc a::before {
  content: counter(item) '. ';
  color: var(--faint);
  font-family: var(--font-figure);
  font-size: 0.82em;
}

.toc ol {
  counter-reset: item;
}

@media (max-width: 560px) {
  .toc ol {
    columns: 1;
  }
}

/* ---- body -------------------------------------------------------------- */

.doc {
  max-width: var(--measure);
}

.doc section {
  margin: 0 0 34px;
  scroll-margin-top: 20px;
}

.doc h2 {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin: 0 0 8px;
  font-size: 1.24rem;
  line-height: 1.25;
  padding-bottom: 5px;
  border-bottom: 1px solid var(--rule);
}

.doc h2 .n {
  flex: 0 0 auto;
  font-family: var(--font-figure);
  font-size: 0.72rem;
  font-weight: 400;
  color: var(--faint);
  letter-spacing: 0.08em;
}

.doc h3 {
  margin: 20px 0 6px;
  font-size: 1.02rem;
}

.doc p,
.doc li {
  max-width: var(--measure);
}

.doc p {
  margin: 0 0 12px;
}

.doc ul,
.doc ol.body {
  margin: 0 0 12px;
  padding-left: 22px;
}

.doc li {
  margin: 0 0 6px;
}

.doc a {
  color: var(--accent);
  text-underline-offset: 3px;
}

.doc strong {
  font-weight: 700;
}

.doc code,
.doc .fig {
  font-family: var(--font-figure);
  font-size: 0.86em;
}

/* A defined term. Used for the handful of words the documents capitalise -
   `the Operator`, `the Service` - so a reader can see at a glance that a
   phrase carries a fixed meaning rather than emphasis. */
.doc dfn {
  font-style: normal;
  font-weight: 700;
}

/* Tables: the data tables are the reason these pages are worth styling
   carefully, because they are where a reviewer checks the claims. */
.doc table {
  width: 100%;
  margin: 0 0 14px;
  border-collapse: collapse;
  font-size: 0.88rem;
  line-height: 1.5;
}

.doc caption {
  margin-bottom: 6px;
  font-family: var(--font-figure);
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--faint);
  text-align: left;
}

.doc th,
.doc td {
  padding: 8px 10px;
  border: 1px solid var(--rule);
  text-align: left;
  vertical-align: top;
}

.doc th {
  background: color-mix(in oklab, var(--paper), var(--ink) 6%);
  font-weight: 700;
}

.doc td:first-child {
  font-weight: 700;
}

@media (max-width: 620px) {
  .doc table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
  }
  .doc td,
  .doc th {
    white-space: normal;
  }
}

.doc blockquote {
  margin: 0 0 14px;
  padding: 2px 0 2px 16px;
  border-left: 3px solid var(--rule-strong);
  color: var(--muted);
  font-size: 0.95rem;
}

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

.doc .callout {
  margin: 0 0 16px;
  padding: 12px 16px;
  border: 1px solid var(--rule);
  border-left: 3px solid var(--accent);
  background: color-mix(in oklab, var(--paper), var(--ink) 4%);
  font-size: 0.94rem;
}

.doc .callout p:last-child {
  margin-bottom: 0;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---- colophon ---------------------------------------------------------- */

.colophon {
  margin-top: 46px;
  padding-top: 16px;
  border-top: 1px solid var(--rule);
  font-size: 0.86rem;
  color: var(--muted);
}

.colophon p {
  margin: 0 0 8px;
}

.colophon a {
  color: var(--accent);
}

.home-link {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--faint);
  text-decoration: none;
}

.home-link:hover {
  color: var(--ink);
}

/* ---- print -------------------------------------------------------------
   A reviewer may well print these, or export them to a PDF for their
   records. Everything decorative goes; nothing is left depending on colour. */

@media print {
  :root {
    --paper: #fff;
    --ink: #000;
    --muted: #333;
    --faint: #555;
    --rule: #bbb;
    --rule-strong: #888;
    --accent: #000;
  }

  body {
    font-size: 11.5pt;
    line-height: 1.5;
  }

  .frame,
  .toc {
    display: none;
  }

  .wrap {
    max-width: none;
    padding: 0;
  }

  .doc a::after {
    content: ' (' attr(href) ')';
    font-size: 0.82em;
    color: #555;
    word-break: break-all;
  }

  /* Internal anchors would print as "(#what-we-collect)". */
  .doc a[href^='#']::after {
    content: '';
  }

  .doc section {
    break-inside: avoid-page;
  }

  .doc table {
    break-inside: avoid;
  }
}