/* Legal pages: the legal hub (templates/legal.html) and the document layout
   (templates/legal-doc.html) used by every page in content/legal/.
   Loads after site.css and uses its tokens (--bg, --ink, --line, ...).
   Calm on purpose: one reading column, no motion, no decoration.
   The document text is Markdown, so .prose styles plain elements:
   ## headings are the numbered sections, tables sit in a .table-scroll div. */

:root {
  --doc-ink:     #2d2a34;   /* body text, darker than --ink-2 for long reading */
  --doc-amber:   #7a5610;   /* amber that passes AA as text on bone */
  --doc-measure: 68ch;      /* ~70 characters per line */
  --doc-offset:  92px;      /* sticky site header (68px) + air */
  --doc-rail:    232px;     /* left column: meta and contents */
}

html { scroll-padding-top: var(--doc-offset); }

/* ── Quality floor ────────────────────────────────────── */
:focus-visible {
  outline: 2px solid var(--ink); outline-offset: 3px; border-radius: 4px;
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition: none !important; }
  .btn:hover { transform: none; }
}

/* ── Draft strip ──────────────────────────────────────── */
.draft {
  background: rgba(200, 148, 62, 0.10);
  border-bottom: 1px solid rgba(200, 148, 62, 0.38);
}
.draft__row {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 18px;
  padding-top: 12px; padding-bottom: 12px; /* keep .wrap's side padding */
  font-size: 14px; line-height: 1.5; color: var(--doc-ink);
}
.draft__label {
  font-family: var(--mg-font-mono); font-weight: 500; font-size: 13.5px;
  color: var(--doc-amber);
}

/* ── Shared pieces ────────────────────────────────────── */
.crumbs {
  margin: 0 0 32px; font-family: var(--mg-font-mono); font-size: 13px; color: var(--ink-3);
}
.crumbs ol { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.crumbs li + li::before { content: '/'; margin-right: 8px; color: var(--ink-4); }
.crumbs a { border-bottom: 1px solid var(--line); padding-bottom: 1px; }
.crumbs a:hover { border-color: currentColor; color: var(--ink); }

.legal-title {
  font-family: var(--mg-font-mono); font-weight: 500; margin: 0;
  font-size: clamp(40px, 5vw, 68px); line-height: 1; letter-spacing: -0.045em;
  text-wrap: balance;
}
.legal-lede {
  font-size: 19px; line-height: 1.55; color: var(--ink-2);
  max-width: 56ch; margin: 22px 0 0; text-wrap: pretty;
}

/* Text links inside running copy */
.prose a, .rights a {
  text-decoration: underline; text-decoration-thickness: 1px;
  text-decoration-color: var(--ink-4); text-underline-offset: 3px;
  transition: text-decoration-color .15s var(--mg-ease);
}
.prose a:hover, .rights a:hover { text-decoration-color: var(--ink); }

/* ══ Legal hub (legal.html) ══════════════════════════════ */
.hub-head { padding: 64px 0 56px; }
.hub {
  display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 72px;
  align-items: start; padding-bottom: 112px;
}

.doc-group + .doc-group { margin-top: 64px; }
.doc-group__title {
  font-family: var(--mg-font-mono); font-weight: 500; margin: 0;
  font-size: 20px; line-height: 1.3; letter-spacing: -0.02em;
}
.doc-group__sub { margin: 6px 0 18px; font-size: 15px; color: var(--ink-3); max-width: 60ch; }

.docs { width: 100%; border-collapse: collapse; border-top: 1px solid var(--ink); }
.docs th {
  text-align: left; font-family: var(--mg-font-mono); font-weight: 500;
  font-size: 12.5px; color: var(--ink-3);
  padding: 12px 20px 12px 0; border-bottom: 1px solid var(--line);
}
.docs td {
  padding: 18px 20px 18px 0; border-bottom: 1px solid var(--line);
  vertical-align: baseline; font-size: 15px; line-height: 1.5; color: var(--ink-2);
}
.docs th:last-child, .docs td:last-child { padding-right: 0; }
.docs__name { width: 30%; }
.docs__name a {
  font-family: var(--mg-font-mono); font-size: 16px; font-weight: 500;
  letter-spacing: -0.01em; color: var(--ink);
  border-bottom: 1px solid transparent; transition: border-color .15s var(--mg-ease);
}
.docs__name a:hover { border-color: currentColor; }
.docs__covers { max-width: 46ch; }
.docs__date, .docs__ver { font-family: var(--mg-font-mono); font-size: 13px; white-space: nowrap; }
.docs th.docs__date, .docs th.docs__ver { font-size: 12.5px; }

/* Your privacy rights */
.rights {
  background: var(--bg-raised); border: 1px solid var(--line); border-radius: 14px;
  padding: 28px 28px 24px; font-size: 15px; line-height: 1.55; color: var(--ink-2);
}
.rights h2 {
  font-family: var(--mg-font-mono); font-weight: 500; margin: 0 0 10px;
  font-size: 20px; letter-spacing: -0.02em; color: var(--ink);
}
.rights h3 {
  font-family: var(--mg-font-mono); font-weight: 500; margin: 22px 0 6px;
  font-size: 14px; color: var(--ink);
}
.rights p { margin: 0 0 10px; }
.rights ul { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line-2); }
.rights li {
  display: grid; grid-template-columns: 96px 1fr; gap: 12px;
  padding: 9px 0; border-bottom: 1px solid var(--line-2); font-size: 14.5px;
}
.rights li b { font-weight: 500; color: var(--ink); }
.rights__cookies {
  margin-top: 24px; padding-top: 22px; border-top: 1px solid var(--line);
}
.rights__cookies .btn { margin-top: 6px; }

/* ══ Document layout (legal-doc.html) ════════════════════ */
.doc-head { padding: 56px 0 56px; }
.doc-grid {
  display: grid; grid-template-columns: var(--doc-rail) minmax(0, 1fr); gap: 0 72px;
}
.doc-meta { margin: 0; display: grid; gap: 18px; align-content: start; padding-top: 8px; }
.doc-meta dt { font-family: var(--mg-font-mono); font-size: 12.5px; color: var(--ink-4); }
.doc-meta dd { margin: 3px 0 0; font-size: 14.5px; line-height: 1.45; color: var(--ink); }

/* In plain words */
.plain {
  margin-top: 40px; max-width: var(--doc-measure);
  background: var(--bg-raised); border: 1px solid var(--line); border-radius: 12px;
  padding: 24px 28px 22px;
}
.plain h2 {
  font-family: var(--mg-font-mono); font-weight: 500; margin: 0 0 14px;
  font-size: 15px; color: var(--ink);
}
.plain ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.plain li {
  position: relative; padding-left: 20px;
  font-size: 15.5px; line-height: 1.55; color: var(--doc-ink);
}
.plain li::before {
  content: ''; position: absolute; left: 2px; top: 0.78em;
  width: 8px; height: 1px; background: var(--ink-3);
}
.plain__note { margin: 16px 0 0; font-size: 13.5px; color: var(--ink-3); }

/* Body: contents rail + text column */
.doc-body { border-top: 1px solid var(--line); padding-bottom: 112px; }

.toc {
  position: sticky; top: var(--doc-offset); align-self: start;
  max-height: calc(100vh - var(--doc-offset) - 16px); overflow: auto;
  padding: 36px 4px 24px 0;
}
.toc h2 {
  font-family: var(--mg-font-mono); font-weight: 500; margin: 0 0 12px 8px;
  font-size: 13px; color: var(--ink-3);
}
.toc ol { list-style: none; margin: 0; padding: 0; }
.toc a {
  display: grid; grid-template-columns: 26px 1fr; gap: 2px;
  padding: 6px 8px; border-radius: 6px;
  font-size: 14px; line-height: 1.4; color: var(--ink-2);
  transition: background .15s var(--mg-ease), color .15s var(--mg-ease);
}
.toc a:hover { background: var(--line-2); color: var(--ink); }
.toc__n { font-family: var(--mg-font-mono); font-size: 12.5px; color: var(--ink-4); padding-top: 1px; }

.prose {
  padding-top: 36px; min-width: 0; counter-reset: sec;
  font-size: 17px; line-height: 1.7; color: var(--doc-ink);
}
/* Text stays at ~70 characters per line; tables may use the full column. */
.prose > :not(.table-scroll) { max-width: var(--doc-measure); }
.prose p { margin: 0 0 1em; text-wrap: pretty; }
.prose strong { font-weight: 600; color: var(--ink); }
.prose ul { margin: 0 0 1.1em; padding: 0; list-style: none; }
.prose ul > li { position: relative; padding-left: 22px; margin-bottom: .45em; }
.prose ul > li::before {
  content: ''; position: absolute; left: 3px; top: 0.82em;
  width: 8px; height: 1px; background: var(--ink-3);
}

/* Numbered sections: each ## heading, numbered in order (matches the contents). */
.prose > h2 {
  counter-increment: sec;
  display: flex; align-items: baseline; gap: 14px;
  font-family: var(--mg-font-mono); font-weight: 500; margin: 64px 0 18px;
  font-size: 23px; line-height: 1.3; letter-spacing: -0.02em; color: var(--ink);
}
.prose > h2:first-child { margin-top: 0; }
.prose > h2::before { content: counter(sec); flex: none; min-width: 1.4em; color: var(--ink-4); }
.anchor {
  flex: none; font-size: 17px; color: var(--ink-4);
  opacity: 0; transition: opacity .15s var(--mg-ease);
  text-decoration: none !important;
}
.prose > h2:hover .anchor, .anchor:focus-visible { opacity: 1; }
.anchor:hover { color: var(--ink); }
@media (hover: none) { .anchor { opacity: .6; } }

.prose h3 {
  font-family: var(--mg-font-mono); font-weight: 500; margin: 36px 0 10px;
  font-size: 16.5px; line-height: 1.4; letter-spacing: -0.01em; color: var(--ink);
}

/* Tables in documents */
.table-scroll { overflow-x: auto; margin: 24px 0 28px; }
.table-scroll:focus-visible { outline-offset: 6px; }
.prose table {
  width: 100%; border-collapse: collapse; border-top: 1px solid var(--ink);
  font-size: 15px; line-height: 1.5;
}
.prose th {
  text-align: left; vertical-align: bottom; font-family: var(--mg-font-mono); font-weight: 500;
  font-size: 12.5px; color: var(--ink-3); padding: 11px 18px 11px 0;
  border-bottom: 1px solid var(--line);
}
.prose td {
  vertical-align: top; padding: 13px 18px 13px 0; border-bottom: 1px solid var(--line);
}
.prose th:last-child, .prose td:last-child { padding-right: 0; }
.prose td:first-child { font-weight: 500; color: var(--ink); min-width: 9em; }
.prose code { font-family: var(--mg-font-mono); font-size: .88em; }
.prose td:first-child code { font-weight: 500; }
.basis { display: block; font-family: var(--mg-font-mono); font-size: 12.5px; color: var(--ink-3); margin-top: 2px; }

/* Definition lists: rights, contact */
.terms { margin: 20px 0 24px; border-top: 1px solid var(--line); }
.terms > div {
  display: grid; grid-template-columns: 170px 1fr; gap: 20px;
  padding: 14px 0; border-bottom: 1px solid var(--line);
}
.terms dt { font-weight: 600; color: var(--ink); font-size: 16px; line-height: 1.5; }
.terms dt small {
  display: block; font-weight: 400; font-family: var(--mg-font-mono);
  font-size: 12.5px; color: var(--ink-3); margin-top: 2px;
}
.terms dd { margin: 0; font-size: 16px; line-height: 1.6; }

/* A notice that must stand apart (Art. 21(4): right to object) */
.callout {
  margin: 28px 0; padding: 22px 26px 8px;
  background: var(--bg-raised); border: 1px solid var(--line); border-left: 3px solid var(--ink);
  border-radius: 4px 10px 10px 4px;
}
.prose .callout h3 { margin-top: 0; }
.callout p { font-size: 16px; }

.prose blockquote {
  margin: 20px 0 24px; padding: 2px 0 2px 20px; border-left: 2px solid var(--line);
  font-size: 16px; color: var(--ink-2);
}
.prose blockquote p:last-child { margin-bottom: 0; }

/* A whole passage MatGen still has to decide on (keep or remove). */
.prose div.fill {
  display: block; margin: 20px 0 24px; padding: 16px 20px 4px;
  border: 1px dashed var(--lamp-amber); border-radius: 6px;
}

/* End of document */
.doc-end {
  max-width: var(--doc-measure);
  margin-top: 72px; padding-top: 24px; border-top: 1px solid var(--line);
  font-size: 15px; line-height: 1.6; color: var(--ink-3);
}
.doc-end h2 {
  font-family: var(--mg-font-mono); font-weight: 500; margin: 0 0 8px;
  font-size: 14px; color: var(--ink);
}
.doc-end p { margin: 0 0 8px; }

/* ── Responsive ───────────────────────────────────────── */
@media (max-width: 1080px) {
  .hub { grid-template-columns: 1fr; gap: 56px; }
  .rights { max-width: 640px; }
  :root { --doc-rail: 200px; }
  .doc-grid { gap: 0 48px; }
}

@media (max-width: 860px) {
  .hub-head, .doc-head { padding: 40px 0 40px; }
  .doc-grid { grid-template-columns: 1fr; }
  .doc-meta { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); margin-bottom: 28px; padding-top: 0; }
  .toc {
    position: static; max-height: none; margin-top: 28px; padding: 18px 12px;
    border: 1px solid var(--line); border-radius: 12px; background: var(--bg-raised);
  }
  .prose { font-size: 16.5px; }
  .terms > div { grid-template-columns: 1fr; gap: 4px; }
  .prose > h2 { font-size: 21px; gap: 10px; }
}

@media (max-width: 720px) {
  /* Document list turns into stacked rows */
  .docs thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .docs tr {
    display: grid; grid-template-columns: 1fr auto; gap: 6px 16px;
    padding: 16px 0; border-bottom: 1px solid var(--line);
  }
  .docs td { display: block; padding: 0; border: 0; }
  .docs__name { width: auto; }
  .docs__covers { grid-column: 1 / -1; grid-row: 2; }
  .docs__date { grid-column: 1 / -1; grid-row: 3; }
  .docs__ver { grid-column: 2; grid-row: 1; }
  .docs td[data-label]::before { content: attr(data-label) ' '; color: var(--ink-4); }
  .rights { padding: 22px 20px 18px; }
  .rights li { grid-template-columns: 1fr; gap: 2px; }
  .plain { padding: 20px 20px 18px; }
  .callout { padding: 18px 18px 6px; }
}

/* ── Print: legal documents get printed and filed ─────── */
@media print {
  .site-header, .site-footer, .consent, .toc, .skip, .anchor { display: none !important; }
  body { background: #fff; }
  .doc-grid { grid-template-columns: 1fr; }
  .prose { padding-top: 0; font-size: 11pt; }
  .prose > h2 { margin-top: 28px; }
  .prose > h2:first-child { margin-top: 0; }
  .plain, .callout { break-inside: avoid; }
  .prose tr { break-inside: avoid; }
}
