/* The legal pages (/privacy, /terms, /legal, /support, /delete-account): reading text under the
 * band (navy in the dark, pane white in the sun), no map, no app code. They load fonts.css,
 * styles.css (the tokens and the base) and components.css before this file, so both themes come
 * from the one token block. */

/* The band's brand lines up with the reading column below it. */
.legal-head {
  display: flex;
  align-items: center;
  min-height: 56px;
  padding: 0 max(var(--s-5), calc((100% - 44rem) / 2 + var(--s-5)));
}

.legal-top {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  min-height: var(--tap);
  color: var(--text);
  text-decoration: none;
}

.legal-top .mark {
  width: 30px;
}

/* The funnel is yellow; on the sunlit band it is the same funnel in navy ink (shell.css). */
:root[data-theme="light"] .legal-top .mark {
  content: url("/img/gustly-mark-ink.v3.svg");
}

.legal-top .wordmark {
  font-size: var(--t-d1);
}

/* The theme chip (js/theme.js) at the band's right end. The landing's chip rules live in landing.css,
 * which these pages do not load, so its word switch is repeated here (the same two rules). */
.legal-head .landing-theme {
  margin-left: auto;
  color: var(--muted);
}

:where(:root:not([data-theme="light"])) .legal-head .landing-theme .theme-go-dark,
:where(:root[data-theme="light"]) .legal-head .landing-theme .theme-go-light {
  display: none;
}

.legal {
  max-width: 44rem;
  margin: 0 auto;
  padding: var(--s-6) var(--s-5) var(--s-7);
}

.legal h1 {
  margin: 0 0 var(--s-2);
  font: 800 italic var(--t-d3) / var(--lh-tight) var(--font-display);
  letter-spacing: var(--track-display);
}

.legal h2 {
  margin: var(--s-6) 0 var(--s-2);
  font: 800 italic var(--t-d1) / var(--lh-snug) var(--font-display);
  letter-spacing: var(--track-display);
}

.updated {
  margin: 0 0 var(--s-5);
  font-size: var(--t-meta);
  color: var(--faint);
}

.legal p,
.legal li {
  color: var(--muted);
}

.legal strong {
  color: var(--text);
}

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

.legal ul,
.legal ol {
  padding-left: var(--s-4);
}

.legal li + li {
  margin-top: var(--s-1);
}

.legal table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--t-meta);
}

.legal th,
.legal td {
  padding: var(--s-2);
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.legal th {
  color: var(--text);
}

.legal td {
  color: var(--muted);
}

.table-wrap {
  overflow-x: auto;
}

/* A phone reads the three-column table as one block per row: what, then why, then the legal
 * basis, each later cell named by its column, so nothing squeezes into 90 px columns. */
@media (max-width: 599px) {
  .stack thead {
    display: none;
  }

  .stack tr {
    display: block;
    padding: var(--s-2) 0;
    border-bottom: 1px solid var(--line);
  }

  .stack td {
    display: block;
    padding: var(--s-0) 0;
    border: 0;
  }

  .stack td:nth-child(2)::before {
    content: "Why: ";
  }

  .stack td:nth-child(3)::before {
    content: "Legal basis: ";
  }

  .stack td:not(:first-child)::before {
    font-weight: 600;
    color: var(--text);
  }
}

/* The safety line in the terms: a raised block with a warning edge. */
.callout {
  margin: var(--s-4) 0;
  padding: var(--s-3) var(--s-4);
  border-left: var(--bar) solid var(--warn);
  background: var(--raise);
  box-shadow: var(--elev-1);
}

.legal .callout p {
  margin: 0;
  color: var(--text);
}

.delete-box {
  justify-items: start;
  margin: var(--s-5) 0;
}

.legal .delete-status {
  margin: 0;
}

.legal-foot {
  display: flex;
  flex-wrap: wrap;
  gap: 0 var(--s-4);
  margin-top: var(--s-7);
  padding-top: var(--s-3);
  border-top: 1px solid var(--line);
  font-size: var(--t-meta);
}

.legal .legal-foot a {
  display: inline-flex;
  align-items: center;
  min-height: var(--tap);
  color: var(--faint);
}

/* Every page opens with the same three parts: "In short" (a card), "On this page" (anchors to the
 * h2s) and the text. Anchored headings stop clear of the top edge. */
.legal h2[id] {
  scroll-margin-top: var(--s-4);
}

.legal .summary {
  margin: var(--s-4) 0 var(--s-5);
}

.legal .summary-h,
.legal .toc-h {
  margin: 0;
  font: 700 var(--t-meta) / var(--lh-ui) var(--font-ui);
  letter-spacing: 0;
  text-transform: uppercase;
  color: var(--text);
}

.legal .summary ul {
  margin: 0;
}

.legal .summary li {
  color: var(--text);
}

.toc {
  margin: 0 0 var(--s-5);
  padding-left: var(--s-4);
  border-left: 1px solid var(--line-strong);
}

.toc ol {
  margin: var(--s-1) 0 0;
  padding-left: var(--s-4);
  columns: 2 16rem;
  column-gap: var(--s-5);
}

.legal .toc li {
  margin: 0;
  break-inside: avoid;
}

.legal .toc a {
  display: inline-flex;
  align-items: center;
  min-height: var(--tap);
}

/* The hub: one row per page, its name and one line on what it holds; the whole row is the link. */
.legal .legal-index {
  margin: 0;
  padding: 0;
  list-style: none;
  border-top: 1px solid var(--line);
}

.legal .legal-index li {
  margin: 0;
  border-bottom: 1px solid var(--line);
}

.legal .legal-index a {
  display: grid;
  gap: var(--s-0);
  padding: var(--s-3) 0;
  text-decoration: none;
}

.legal .legal-index a strong {
  color: var(--accent-text);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.legal .legal-index a span {
  color: var(--muted);
}

/* A fact that exists only once the owner registers (docs/legal_pages.md): said plainly, marked. */
.legal .pending {
  padding-left: var(--s-2);
  border-left: var(--bar) solid var(--warn);
  font-style: italic;
  color: var(--text);
}

.legal td.pending {
  padding-left: var(--s-2);
}

.legal .count {
  font-size: var(--t-meta);
}

/* The sources table on a phone: one block per source, the later cells named. */
@media (max-width: 599px) {
  .sources thead {
    display: none;
  }

  .sources tr {
    display: block;
    padding: var(--s-2) 0;
    border-bottom: 1px solid var(--line);
  }

  .sources td {
    display: block;
    padding: var(--s-0) 0;
    border: 0;
  }

  .sources td:nth-child(2)::before {
    content: "Country: ";
  }

  .sources td:nth-child(3)::before {
    content: "Credit: ";
  }

  .sources td:nth-child(4)::before {
    content: "Licence: ";
  }

  .sources td:not(:first-child)::before {
    font-weight: 600;
    color: var(--text);
  }
}

.legal .legal-owner {
  margin: var(--s-2) 0 0;
  font-size: var(--t-meta);
  color: var(--faint);
}

/* On paper: the text alone, black on white, no band, chip or link rows. */
@media print {
  .legal-head,
  .legal-foot,
  .toc {
    display: none;
  }

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

  .legal,
  .legal p,
  .legal li,
  .legal td,
  .legal th,
  .legal a,
  .legal h1,
  .legal h2,
  .legal strong {
    color: var(--ink);
  }

  .legal .summary::before {
    box-shadow: none;
  }

  .legal h2 {
    break-after: avoid;
  }

  .legal tr {
    break-inside: avoid;
  }
}
