/* Legal pages (/privacy, /terms and their /hr counterparts). Loaded *after*
   landing.css, which supplies every design token plus the shared header,
   footer and button styles — this file only adds long-form document
   typography and the sticky table of contents. Generated markup comes from
   scripts/build_legal_pages.py; the prose comes from .docs/legal/. */

/* ---------------- Header tweaks ---------------- */

/* The landing header hides its nav, language switch and theme controls below
   900px and moves them into a hamburger panel. These pages have no such panel
   — and the language switch is the one control a legal page must never lose,
   since each language is a separate URL. So everything stays in the header and
   wraps instead; only the "open the app" CTA drops on narrow screens. */
.site-header .main-nav {
  display: flex;
  gap: var(--space-4);
  flex-wrap: wrap;
}
.site-header .header-actions > .lang-switch,
.site-header .header-actions > .theme-controls {
  display: flex;
}
.site-header .main-nav a[aria-current="page"] {
  color: var(--primary);
  font-weight: 600;
}

/* landing.css styles .lang-switch *buttons*; here the switch navigates, so the
   same treatment has to reach anchors. */
.lang-switch a {
  appearance: none;
  border: none;
  background: transparent;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  color: var(--on-surface-variant);
  text-decoration: none;
  padding: 6px 10px;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: background-color var(--dur-short) var(--ease-standard),
    color var(--dur-short) var(--ease-standard);
}
.lang-switch a[aria-pressed="true"] {
  background: var(--primary-container);
  color: var(--on-primary-container);
}
.lang-switch a:hover {
  color: var(--primary);
}

@media (max-width: 720px) {
  .site-header .header-row {
    height: auto;
    flex-wrap: wrap;
    padding-top: var(--space-3);
    padding-bottom: var(--space-3);
    gap: var(--space-3);
  }
  .site-header .header-actions > .header-cta {
    display: none;
  }
  .site-header .main-nav {
    order: 3;
    width: 100%;
    gap: var(--space-5);
  }
}

/* ---------------- Layout ---------------- */

.legal-main {
  padding: var(--space-8) 0 var(--space-10);
}
.legal-layout {
  display: block;
}
@media (min-width: 1000px) {
  .legal-layout {
    display: grid;
    grid-template-columns: 260px minmax(0, 1fr);
    gap: var(--space-8);
    align-items: start;
  }
}

/* ---------------- Table of contents ---------------- */

.legal-toc {
  margin-bottom: var(--space-6);
  padding: var(--space-4);
  background: var(--surface-container);
  border-radius: var(--radius-lg);
}
@media (min-width: 1000px) {
  .legal-toc {
    position: sticky;
    top: 96px;
    max-height: calc(100vh - 128px);
    overflow-y: auto;
    margin-bottom: 0;
    background: transparent;
    padding: 0;
  }
}
.legal-toc .toc-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--primary);
  margin: 0 0 var(--space-3);
}
.legal-toc ol {
  list-style: none;
  margin: 0;
  padding: 0;
  counter-reset: none;
}
.legal-toc li {
  margin: 0;
}
.legal-toc a {
  display: block;
  padding: 6px 0;
  font-size: 0.88rem;
  line-height: 1.35;
  color: var(--on-surface-variant);
  text-decoration: none;
  border-left: 2px solid transparent;
  padding-left: var(--space-3);
  transition: color var(--dur-short) var(--ease-standard),
    border-color var(--dur-short) var(--ease-standard);
}
.legal-toc a:hover {
  color: var(--primary);
}
.legal-toc a.active {
  color: var(--primary);
  border-left-color: var(--primary);
  font-weight: 600;
}

/* ---------------- Document ---------------- */

.legal-doc {
  max-width: 74ch;
  font-size: 1rem;
  line-height: 1.7;
  color: var(--on-surface);
}
.legal-doc h1 {
  font-size: clamp(2rem, 5vw, 2.8rem);
  margin-bottom: var(--space-2);
}
.legal-doc h2 {
  font-size: clamp(1.35rem, 2.6vw, 1.7rem);
  margin-top: var(--space-8);
  margin-bottom: var(--space-4);
  scroll-margin-top: 96px;
}
.legal-doc h3 {
  font-size: 1.08rem;
  margin-top: var(--space-6);
  margin-bottom: var(--space-2);
  color: var(--on-surface-variant);
  scroll-margin-top: 96px;
}
.legal-doc p {
  margin: 0 0 var(--space-4);
}
.legal-doc strong {
  font-weight: 700;
  color: var(--on-surface);
}
.legal-doc a {
  color: var(--primary);
  text-underline-offset: 3px;
}
.legal-doc code {
  font-size: 0.9em;
  background: var(--surface-container);
  border-radius: var(--radius-xs);
  padding: 1px 5px;
}

/* The `#` beside each heading — a copyable deep link, invisible until hover so
   it never competes with the heading itself. */
.legal-doc .anchor {
  margin-left: var(--space-2);
  color: var(--outline);
  text-decoration: none;
  font-weight: 400;
  opacity: 0;
  transition: opacity var(--dur-short) var(--ease-standard);
}
.legal-doc h2:hover .anchor,
.legal-doc h3:hover .anchor,
.legal-doc .anchor:focus {
  opacity: 1;
}

.legal-doc .doc-meta {
  color: var(--on-surface-variant);
  font-size: 0.95rem;
  margin-bottom: var(--space-6);
}

/* Cross-references (§4, §10.2) — a quiet tint rather than a full link colour,
   since a dense legal text has a lot of them. */
.legal-doc .xref {
  color: var(--primary);
  text-decoration: none;
  border-bottom: 1px dotted color-mix(in srgb, var(--primary) 50%, transparent);
  white-space: nowrap;
}
.legal-doc .xref:hover {
  border-bottom-style: solid;
}

.legal-doc hr {
  border: none;
  border-top: 1px solid var(--outline-variant);
  margin: var(--space-6) 0;
}

.legal-doc ul {
  margin: 0 0 var(--space-4);
  padding-left: var(--space-5);
}
.legal-doc li {
  margin-bottom: var(--space-2);
}
.legal-doc li::marker {
  color: var(--primary);
}

/* ---------------- Tables ---------------- */

/* Wide two- and three-column tables (the lawful-basis and processor tables)
   scroll inside their own box rather than pushing the page sideways. */
.legal-doc .table-wrap {
  overflow-x: auto;
  margin: 0 0 var(--space-5);
  border: 1px solid var(--outline-variant);
  border-radius: var(--radius-md);
  background: var(--surface-lowest);
}
.legal-doc table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
  min-width: 30rem;
}
.legal-doc thead th {
  text-align: left;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.82rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--on-surface-variant);
  background: var(--surface-container);
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--outline-variant);
  white-space: nowrap;
}
.legal-doc tbody td {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--outline-variant);
  vertical-align: top;
  line-height: 1.55;
}
.legal-doc tbody tr:last-child td {
  border-bottom: none;
}
.legal-doc tbody tr:nth-child(even) td {
  background: color-mix(in srgb, var(--surface-container) 45%, transparent);
}

/* First column of a two-column table is the label — keep it readable but tight. */
.legal-doc tbody td:first-child {
  font-weight: 600;
  min-width: 11rem;
}

@media (max-width: 600px) {
  .legal-doc {
    font-size: 0.97rem;
  }
  .legal-doc table {
    font-size: 0.88rem;
  }
}

@media print {
  .site-header,
  .site-footer,
  .legal-toc,
  .skip-link,
  .legal-doc .anchor {
    display: none !important;
  }
  .legal-doc {
    max-width: none;
  }
  .legal-doc .table-wrap {
    overflow: visible;
  }
}

/* ---------------- Embedded (the app's in-app viewer) ---------------- */

/* `?embed=1` - the same document, same URL, rendered inside the Darko app's
   WebView (Profile > About > Terms/Privacy). The app supplies the app bar and
   the way back, so every piece of site chrome is dead weight in there: header,
   table of contents, footer, skip link and the per-heading `#` anchors all go,
   leaving the prose and nothing else. Deliberately a query parameter on the
   canonical URL rather than a second route or a second generated file - one
   document, one URL, one copy of the text to keep current, and `<link
   rel="canonical">` already points crawlers at the bare path. `data-embed` is
   set by the blocking bootstrap in <head> (scripts/build_legal_pages.py), so
   the chrome is never painted and then removed. */
[data-embed] .site-header,
[data-embed] .site-footer,
[data-embed] .legal-toc,
[data-embed] .skip-link,
[data-embed] .legal-doc .anchor {
  display: none !important;
}

/* Without the sticky header there is nothing to scroll a target heading clear
   of, and no 1000px sidebar column to reserve. */
[data-embed] .legal-layout {
  display: block;
}
[data-embed] .legal-main {
  padding: var(--space-5) 0 var(--space-8);
}
[data-embed] .legal-doc {
  max-width: none;
}
[data-embed] .legal-doc h2,
[data-embed] .legal-doc h3 {
  scroll-margin-top: var(--space-4);
}

/* A phone-width column, not a desktop hero: the document title shouldn't eat
   a third of the first screen. */
[data-embed] .legal-doc h1 {
  font-size: clamp(1.6rem, 6vw, 2.1rem);
}
