/* Skiv legal — quiet editorial reading system.
   The shell uses the app's canonical pale-yellow / near-black olive palette.
   The document stays flat and typographic: no glass, no decorative gradients,
   no giant container card. Legal content remains usable without JavaScript. */

:root {
  --paper: #f2f2ec;
  --paper-raised: #fafaf6;
  --paper-sunken: #e8e8e0;
  --ink: #1a1a00;
  --ink-2: #575744;
  --ink-3: #7b7b67;
  --featured: #1a1a00;
  --on-featured: #ffffcc;
  --accent: #ffffcc;
  --accent-tint: #ffffe4;
  --line: rgba(26, 26, 0, 0.13);
  --line-strong: rgba(26, 26, 0, 0.22);
  --warn: #a44636;
  --warn-bg: #f7eae3;

  --rail: 12.5rem;
  --measure: 42rem;
  --gap: clamp(42px, 6vw, 88px);
  --bar: 68px;

  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display",
          "Helvetica Neue", system-ui, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }

html {
  min-width: 320px;
  background: var(--paper);
  color: var(--ink);
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.68;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.vh {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

/* Header */

.bar {
  position: sticky;
  top: 0;
  z-index: 20;
  min-height: var(--bar);
  background: rgba(242, 242, 236, 0.9);
  border-bottom: 1px solid var(--line);
  -webkit-backdrop-filter: blur(18px) saturate(120%);
  backdrop-filter: blur(18px) saturate(120%);
}

.bar__in {
  width: min(1120px, 100%);
  min-height: var(--bar);
  margin-inline: auto;
  padding: 10px clamp(20px, 4vw, 42px);
  display: flex;
  align-items: center;
  gap: 14px;
}

.wordmark {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-size: 1.15rem;
  font-weight: 680;
  letter-spacing: -0.055em;
  line-height: 1;
  text-decoration: none;
}

.wordmark img {
  display: block;
  width: 38px;
  height: 38px;
  object-fit: contain;
}

.bar__section {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  color: var(--ink-3);
  font-size: 0.72rem;
  font-weight: 650;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

.bar__section::before {
  content: "";
  width: 1px;
  height: 20px;
  background: var(--line-strong);
}

.bar__back {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--ink-2);
  font-size: 0.84rem;
  font-weight: 560;
  text-decoration: none;
  transition: color 160ms ease, transform 160ms ease;
}

.bar__back:hover { color: var(--ink); transform: translateX(-2px); }

.wordmark:focus-visible,
.bar__back:focus-visible,
.docs a:focus-visible,
.toc a:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 4px;
  border-radius: 4px;
}

/* Document switcher */

.docs {
  border-bottom: 1px solid var(--line);
  background: var(--paper);
}

.docs__in {
  width: min(1120px, 100%);
  margin-inline: auto;
  padding: 0 clamp(20px, 4vw, 42px);
  display: flex;
  gap: clamp(22px, 3.4vw, 44px);
  overflow-x: auto;
  scrollbar-width: none;
}

.docs__in::-webkit-scrollbar { display: none; }

.docs a {
  position: relative;
  padding: 15px 0 14px;
  white-space: nowrap;
  color: var(--ink-3);
  font-size: 0.82rem;
  font-weight: 520;
  text-decoration: none;
  transition: color 160ms ease;
}

.docs a::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 2px;
  background: transparent;
}

.docs a:hover { color: var(--ink); }
.docs a[aria-current="page"] { color: var(--ink); font-weight: 660; }
.docs a[aria-current="page"]::after { background: var(--ink); }

/* Draft state stays outside the document's hierarchy. */

.draft {
  background: var(--warn-bg);
  border-bottom: 1px solid rgba(164, 70, 54, 0.2);
  color: #683326;
}

.draft__in {
  width: min(1120px, 100%);
  margin-inline: auto;
  padding: 12px clamp(20px, 4vw, 42px);
  font-size: 0.8rem;
  line-height: 1.5;
}

.draft p { margin: 0; color: inherit; }
.draft strong { color: #55281e; }

/* Document grid */

main {
  max-width: var(--measure);
  margin-inline: auto;
  padding: clamp(54px, 7vw, 92px) clamp(22px, 5vw, 42px)
           clamp(130px, 34vh, 360px);
}

body.has-toc main {
  display: grid;
  grid-template-columns: var(--rail) minmax(0, var(--measure));
  justify-content: center;
  column-gap: var(--gap);
  max-width: calc(var(--rail) + var(--gap) + var(--measure) + 84px);
}

.sheet { min-width: 0; }

/* Contents */

.toc {
  position: sticky;
  top: calc(var(--bar) + 28px);
  align-self: start;
  max-height: calc(100vh - var(--bar) - 56px);
  overflow-y: auto;
  padding: 2px 0 24px;
  color: var(--ink-3);
  font-size: 0.8rem;
  line-height: 1.35;
  scrollbar-width: thin;
}

.toc__lab {
  margin: 0 0 16px 14px;
  color: var(--ink-3);
  font-size: 0.66rem;
  font-weight: 680;
  letter-spacing: 0.14em;
  list-style: none;
  pointer-events: none;
  text-transform: uppercase;
}

.toc__lab::-webkit-details-marker { display: none; }
.toc__list { margin: 0; padding: 0; list-style: none; }
.toc__list li { margin: 0; }

.toc a {
  display: grid;
  grid-template-columns: 1.25em minmax(0, 1fr) auto;
  column-gap: 9px;
  padding: 6px 4px 6px 14px;
  border-left: 1px solid var(--line);
  color: var(--ink-3);
  text-decoration: none;
  transition: color 150ms ease, border-color 150ms ease;
}

.toc a:hover { color: var(--ink); }
.toc__n { font-variant-numeric: tabular-nums; }
.toc--plain a { grid-template-columns: minmax(0, 1fr) auto; }
.toc--plain .toc__n { display: none; }

.toc a[aria-current="true"] {
  border-left-color: var(--ink);
  color: var(--ink);
  font-weight: 620;
}

.toc__flag {
  width: 5px;
  height: 5px;
  margin-top: 0.5em;
  border-radius: 99px;
  background: var(--warn);
}

/* Type */

h1 {
  max-width: 12ch;
  margin: 0 0 10px;
  color: var(--ink);
  font-size: clamp(3.15rem, 5vw, 4.6rem);
  font-weight: 650;
  letter-spacing: -0.068em;
  line-height: 0.96;
  text-wrap: balance;
}

.updated {
  margin: 0 0 44px;
  color: var(--ink-3);
  font-size: 0.82rem;
  font-variant-numeric: tabular-nums;
}

h2 {
  margin: 68px 0 16px;
  color: var(--ink);
  font-size: 1.42rem;
  font-weight: 640;
  letter-spacing: -0.035em;
  line-height: 1.22;
  scroll-margin-top: calc(var(--bar) + 28px);
}

h2:first-of-type { margin-top: 10px; }

.h2__n {
  display: inline-block;
  min-width: 2.05em;
  color: var(--ink-3);
  font-weight: 540;
  font-variant-numeric: tabular-nums;
}

h3 {
  margin: 30px 0 9px;
  color: var(--ink);
  font-size: 1rem;
  font-weight: 650;
}

p, li { color: var(--ink-2); }
p { margin: 0 0 15px; }
ul, ol { margin: 0 0 16px; padding-left: 1.25em; }
li { margin-bottom: 8px; }
li::marker { color: var(--ink-3); }
strong { color: var(--ink); font-weight: 650; }

a {
  color: var(--ink);
  text-decoration-color: rgba(26, 26, 0, 0.36);
  text-underline-offset: 3px;
}

/* Summary and notices */

.lede {
  margin: 0 0 46px;
  padding: clamp(24px, 4vw, 34px);
  border-radius: 28px;
  background: var(--featured);
  color: var(--on-featured);
}

.lede > p,
.lede li { color: rgba(255, 255, 235, 0.82); }
.lede strong { color: var(--on-featured); }
.lede > p:last-child { margin-bottom: 0; }

.lede .lede__lab {
  margin: 0 0 14px;
  color: var(--on-featured);
  font-size: 0.67rem;
  font-weight: 720;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

.lede ul { margin: 0; padding-left: 1.15em; }
.lede li { margin-bottom: 8px; }
.lede li:last-child { margin-bottom: 0; }
.lede li::marker { color: var(--on-featured); }

.lede .lede__end {
  margin: 18px 0 0;
  padding-top: 16px;
  border-top: 1px solid rgba(255, 255, 204, 0.2);
  color: rgba(255, 255, 235, 0.58);
  font-size: 0.91rem;
}

.callout {
  margin: 0 0 20px;
  padding: 20px 22px;
  border-left: 3px solid var(--ink);
  border-radius: 0 16px 16px 0;
  background: var(--paper-sunken);
}

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

.todo {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 6px;
  background: var(--warn);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  vertical-align: 2px;
}

/* Tables */

.table-wrap {
  margin: 6px 0 24px;
  overflow-x: auto;
  border: 1px solid var(--line-strong);
  border-radius: 16px;
  background: var(--paper-raised);
}

table {
  width: 100%;
  min-width: 30rem;
  border-collapse: collapse;
  font-size: 0.92rem;
}

th, td {
  padding: 13px 15px;
  text-align: left;
  vertical-align: top;
}

th {
  border-bottom: 1px solid var(--line-strong);
  background: var(--paper-sunken);
  color: var(--ink);
  font-weight: 650;
  white-space: nowrap;
}

td { color: var(--ink-2); }
tbody tr + tr td { border-top: 1px solid var(--line); }

/* Footer */

.foot {
  max-width: var(--measure);
  margin-inline: auto;
  padding: 0 clamp(22px, 5vw, 42px) 72px;
  color: var(--ink-3);
  font-size: 0.82rem;
}

body.has-toc .foot {
  display: grid;
  grid-template-columns: var(--rail) minmax(0, var(--measure));
  justify-content: center;
  column-gap: var(--gap);
  max-width: calc(var(--rail) + var(--gap) + var(--measure) + 84px);
}

body.has-toc .foot > * { grid-column: 2; }

.foot nav {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 22px;
  margin-bottom: 18px;
  padding-top: 26px;
  border-top: 1px solid var(--line);
}

.foot a { color: var(--ink-2); text-decoration: none; }
.foot a:hover { color: var(--ink); text-decoration: underline; }
.foot__legal { margin: 0; color: var(--ink-3); line-height: 1.62; }

/* Tablet: contents becomes a native disclosure above the document. */

@media (max-width: 62rem) {
  body.has-toc main,
  body.has-toc .foot {
    display: block;
    max-width: var(--measure);
  }

  .toc {
    position: static;
    max-height: none;
    margin: 0 0 34px;
    padding: 0;
    overflow: visible;
    border-top: 1px solid var(--line-strong);
    border-bottom: 1px solid var(--line-strong);
  }

  .toc__lab {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 0;
    padding: 15px 2px;
    color: var(--ink-2);
    font-size: 0.7rem;
    cursor: pointer;
    pointer-events: auto;
  }

  .toc__lab::after {
    content: "";
    width: 7px;
    height: 7px;
    margin: -3px 5px 0 0;
    border-right: 1.5px solid var(--ink-2);
    border-bottom: 1.5px solid var(--ink-2);
    transform: rotate(45deg);
    transition: transform 180ms ease;
  }

  .toc__d[open] .toc__lab::after {
    margin-top: 3px;
    transform: rotate(225deg);
  }

  .toc__list { padding: 0 2px 14px; }
  .toc a {
    border-left: 0;
    padding: 7px 0;
    color: var(--ink-2);
    font-size: 0.9rem;
  }
  .toc a[aria-current="true"] { border-left-color: transparent; }

  h2 { margin-top: 54px; }
}

/* Mobile tables become labelled blocks. */

@media (max-width: 37.5rem) {
  .table-wrap {
    overflow: visible;
    border: 0;
    border-radius: 0;
    background: transparent;
  }

  table { min-width: 0; font-size: 0.92rem; }
  table, tbody, tr, td { display: block; width: 100%; }
  thead { display: none; }

  tr {
    margin-bottom: 12px;
    padding: 5px 0;
    border: 1px solid var(--line-strong);
    border-radius: 14px;
    background: var(--paper-raised);
  }

  tbody tr + tr td { border-top: 0; }
  td { padding: 8px 15px; }
  td:first-child { padding-top: 13px; }
  td:last-child { padding-bottom: 13px; }

  td[data-label]::before {
    content: attr(data-label);
    display: block;
    margin-bottom: 2px;
    color: var(--ink-3);
    font-size: 0.65rem;
    font-weight: 680;
    letter-spacing: 0.1em;
    text-transform: uppercase;
  }
}

@media (max-width: 30rem) {
  .bar__in,
  .docs__in,
  .draft__in { padding-left: 18px; padding-right: 18px; }

  .wordmark { font-size: 1.05rem; }
  .wordmark img { width: 36px; height: 36px; }
  .bar__section { font-size: 0.65rem; }
  .bar__back { font-size: 0.8rem; }

  main { padding: 44px 20px 150px; }
  .foot { padding-left: 20px; padding-right: 20px; }

  h1 { font-size: clamp(2.65rem, 13vw, 3.35rem); }
  .updated { margin-bottom: 34px; }
  .lede { padding: 24px 22px; border-radius: 24px; }
  h2 { font-size: 1.32rem; }
}

@media (max-width: 23rem) {
  .bar__section { display: none; }
  .bar__back-label { display: none; }
  .bar__back { font-size: 1.1rem; }
}

@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
