/* Legal documents (algemene voorwaarden), NL at the root and EN in /en.
 * Loaded after home.css and sector.css: nav, footer and crumb come from those unchanged.
 * Layout: title block, then a sticky table of contents beside one reading column.
 * Phones get the contents as a collapsed panel above the text (opened by legal.js on wide screens).
 */

/* ============ Title block ============ */
.legal { padding-block: calc(var(--nav-height) + var(--space-xl)) var(--space-3xl); }
.legal-head {
  padding-bottom: var(--space-xl);
  margin-bottom: var(--space-xl);
  border-bottom: var(--rule-hair) solid var(--color-rule-2);
}
.legal-title {
  font-size: var(--text-xl);
  font-weight: 700;
  line-height: 1.07;
  letter-spacing: var(--track-head);
  text-wrap: balance;
  overflow-wrap: anywhere;
}
.legal-head .lede { margin-top: var(--space-md); max-width: 40rem; }
.legal-meta { margin-top: var(--space-md); color: var(--color-ink-2); }

/* ============ Contents + reading column ============ */
.legal-body { display: grid; gap: var(--space-xl); }

.legal-toc { font-size: var(--text-xs); }
.legal-toc > summary {
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-sm);
  min-height: 44px; padding-inline: var(--space-md);
  border-radius: var(--radius-input);
  background: var(--color-paper-2);
  font-weight: 600; color: var(--color-ink);
  cursor: pointer; list-style: none;
}
.legal-toc > summary::-webkit-details-marker { display: none; }
.legal-toc > summary::after {
  content: ""; width: 0.45em; height: 0.45em;
  border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor;
  transform: translateY(-0.15em) rotate(45deg);
  transition: transform var(--dur-short) var(--ease-out);
}
.legal-toc[open] > summary::after { transform: translateY(0.1em) rotate(-135deg); }
.legal-toc ol { padding: var(--space-xs) var(--space-md) var(--space-sm); }
.legal-toc a {
  display: flex; align-items: baseline; gap: var(--space-xs);
  padding-block: var(--space-2xs);
  color: var(--color-ink-2); text-decoration: none;
}
.legal-toc a span { min-width: 1.5em; font-variant-numeric: tabular-nums; }
@media (pointer: coarse) { .legal-toc a { min-height: 44px; align-items: center; } }
@media (hover: hover) and (pointer: fine) { .legal-toc a:hover { color: var(--color-ink); } }
.legal-toc a:active { opacity: 0.6; }

@media (min-width: 64rem) {
  .legal-body { grid-template-columns: 15rem minmax(0, 44rem); gap: var(--space-3xl); align-items: start; }
  .legal-toc {
    position: sticky; top: calc(var(--nav-height) + var(--space-lg));
    max-height: calc(100vh - var(--nav-height) - 2 * var(--space-lg));
    overflow-y: auto;
  }
  /* With the script running, the contents stay open beside the text: the summary becomes a plain label */
  .js .legal-toc > summary { min-height: 0; padding: 0 0 var(--space-xs); background: none; pointer-events: none; }
  .js .legal-toc > summary::after { display: none; }
  .js .legal-toc ol { padding: 0; }
}

/* ============ The document ============ */
.legal-doc { min-width: 0; max-width: 44rem; }
/* Jumps land a little below the floating nav, so a tinted clause shows in full */
.legal-doc [id] { scroll-margin-top: var(--space-lg); }
.legal-doc p, .legal-doc li, .legal-doc dd { line-height: 1.6; text-wrap: pretty; overflow-wrap: break-word; }
.legal-doc li p + p { margin-top: var(--space-xs); }

.legal-card {
  padding: var(--space-lg);
  border-radius: var(--radius-card);
  background: var(--color-paper-2);
}
.legal-card + .legal-card { margin-top: var(--space-md); }

.legal-doc section { margin-top: var(--space-2xl); padding-top: var(--space-xl); border-top: var(--rule-hair) solid var(--color-rule-2); }
.legal-doc section:first-of-type { border-top: 0; padding-top: 0; }
.legal-doc h2 {
  margin-bottom: var(--space-md);
  font-size: var(--text-lg);
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: var(--track-head);
  text-wrap: balance;
}
.art-num {
  display: block; margin-bottom: var(--space-2xs);
  font-family: var(--font-mono); font-size: var(--text-xs); font-weight: 400;
  letter-spacing: 0; color: var(--color-ink-2);
}

/* Numbered clauses: the number hangs in the margin, so a bold lead-in stays inline */
.clauses { display: grid; gap: var(--space-sm); counter-reset: clause; }
.clauses > li { position: relative; isolation: isolate; padding-left: 2.25rem; counter-increment: clause; }
.clauses > li::before {
  content: counter(clause) ".";
  position: absolute; left: 0; top: 0;
  color: var(--color-ink-2); font-variant-numeric: tabular-nums;
}
/* A cross-reference lands on its clause: tint it so the eye finds it */
.clauses > li:target::after {
  content: ""; position: absolute; z-index: -1;
  inset: calc(-1 * var(--space-xs)) calc(-1 * var(--space-sm));
  border-radius: var(--radius-input);
  background: var(--color-tag-bevestig);
}

.dashes { display: grid; gap: var(--space-2xs); margin-top: var(--space-xs); }
.dashes > li { position: relative; padding-left: 1.25rem; }
.dashes > li::before { content: "–"; position: absolute; left: 0; color: var(--color-ink-2); }

.defs { border-top: var(--rule-hair) solid var(--color-rule-2); }
.defs > div { display: grid; gap: var(--space-3xs); padding-block: var(--space-sm); border-bottom: var(--rule-hair) solid var(--color-rule-2); }
.defs dt { font-weight: 600; }
@media (min-width: 40rem) { .defs > div { grid-template-columns: 14rem minmax(0, 1fr); gap: var(--space-lg); } }

.formula { white-space: nowrap; font-variant-numeric: tabular-nums; }
/* Subscripts (P0, S0) without opening up the line they sit on */
.legal-doc sub { position: relative; bottom: -0.25em; font-size: 0.75em; line-height: 0; vertical-align: baseline; }

.legal-doc a {
  color: var(--color-accent);
  text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 0.2em;
  text-decoration-color: color-mix(in oklch, var(--color-accent) 35%, transparent);
}
@media (hover: hover) and (pointer: fine) { .legal-doc a:hover { text-decoration-color: currentColor; } }

.legal-end { margin-top: var(--space-2xl); padding-top: var(--space-lg); border-top: var(--rule-hair) solid var(--color-rule); color: var(--color-ink-2); }

/* ============ Print: the document only ============ */
@media print {
  .skip, .nav, .foot, .crumb, .legal-toc { display: none !important; }
  .legal { padding: 0; }
  .legal-body { display: block; }
  .legal-doc { max-width: none; }
  .legal-doc h2 { break-after: avoid; }
  .clauses > li { break-inside: avoid; }
  .legal-card { padding: 0; background: none; }
  .legal-doc a { color: inherit; text-decoration: none; }
}
