/* ==========================================================================
   Wingcert — legal & policy pages
   Loaded after wingcert.css. Light context throughout.
   ========================================================================== */

/* The legal pages have no dark hero, so the nav is solid from the first pixel.
   wingcert.js leaves .nav-locked alone rather than toggling it on scroll. */
.nav-locked {
  background: rgba(255, 255, 255, 0.78);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-bottom-color: rgba(16, 24, 32, 0.08);
  color: var(--ink-900);
}
.nav-locked .logo-light { display: none; }
.nav-locked .logo-dark { display: block; }

/* ------------------------------------------------------------- header -- */
.legal-head {
  padding-top: clamp(7rem, 12vw, 9.5rem);
  padding-bottom: clamp(2.5rem, 5vw, 3.5rem);
  border-bottom: 1px solid var(--slate-200);
  background:
    radial-gradient(ellipse 70% 100% at 15% 0%, var(--blue-50), transparent 70%),
    var(--white);
}
.legal-head h1 {
  font-size: clamp(2.1rem, 4.4vw, 3.25rem);
  line-height: 1.06;
  letter-spacing: -0.032em;
  font-weight: 700;
  max-width: 20ch;
}
.legal-head .lede { margin-top: 1.15rem; max-width: 62ch; font-size: 1.1rem; }

.legal-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem 2.25rem;
  margin-top: 2.25rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--slate-100);
}
.legal-meta div { font-size: 0.85rem; }
.legal-meta dt {
  font-size: 0.7rem;
  font-weight: 640;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--slate-400);
  margin-bottom: 0.25rem;
}
.legal-meta dd { margin: 0; font-weight: 550; color: var(--ink-900); font-variant-numeric: tabular-nums; }

/* Sibling document switcher */
.legal-switch {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 2rem;
}
.legal-switch a {
  font-size: 0.85rem;
  font-weight: 540;
  padding: 0.45rem 0.95rem;
  border-radius: 980px;
  border: 1px solid var(--slate-200);
  background: var(--white);
  color: var(--slate-500);
  transition: border-color 0.2s, color 0.2s, background-color 0.2s;
}
.legal-switch a:hover { border-color: var(--blue-300); color: var(--blue-700); }
.legal-switch a[aria-current="page"] {
  background: var(--blue-700);
  border-color: var(--blue-700);
  color: #fff;
}

/* -------------------------------------------------------------- body --- */
.legal-body {
  display: grid;
  grid-template-columns: 244px 1fr;
  gap: clamp(2rem, 5vw, 4.5rem);
  align-items: start;
  padding-block: clamp(3rem, 6vw, 4.5rem) clamp(4rem, 8vw, 7rem);
}

/* Table of contents */
.toc { position: sticky; top: 96px; max-height: calc(100vh - 130px); overflow-y: auto; }
.toc h2 {
  font-size: 0.7rem;
  font-weight: 640;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--slate-400);
  margin-bottom: 0.9rem;
}
.toc ol { counter-reset: toc; }
.toc li { margin-bottom: 0.1rem; }
.toc a {
  display: block;
  font-size: 0.855rem;
  line-height: 1.35;
  padding: 0.4rem 0.6rem 0.4rem 0.7rem;
  border-left: 2px solid var(--slate-100);
  color: var(--slate-500);
  transition: color 0.2s, border-color 0.2s, background-color 0.2s;
}
.toc a:hover { color: var(--ink-900); border-left-color: var(--slate-300); }
.toc a.is-current {
  color: var(--blue-700);
  border-left-color: var(--blue-700);
  background: var(--blue-50);
  font-weight: 560;
}
.toc-annex { margin-top: 0.9rem; padding-top: 0.9rem; border-top: 1px solid var(--slate-100); }

/* Prose.
   min-width:0 is load-bearing: as a grid item it would otherwise default to
   min-width:auto and refuse to shrink below the min-width of the widest table
   inside it, pushing the whole page into horizontal overflow on narrow screens
   instead of letting .tbl-wrap scroll internally. */
.prose {
  min-width: 0;
  max-width: 74ch;
  font-size: 1.0125rem;
  line-height: 1.68;
  color: var(--ink-800);
}
.toc { min-width: 0; }
.prose > section { scroll-margin-top: 96px; }
.prose > section + section { margin-top: 3.25rem; }

.prose h2 {
  font-size: clamp(1.3rem, 2.1vw, 1.6rem);
  line-height: 1.2;
  letter-spacing: -0.022em;
  font-weight: 660;
  color: var(--ink-900);
  margin-bottom: 1.1rem;
  padding-bottom: 0.7rem;
  border-bottom: 1px solid var(--slate-200);
}
.prose h2 .num {
  display: inline-block;
  min-width: 1.9em;
  color: var(--blue-700);
  font-variant-numeric: tabular-nums;
}
.prose h3 {
  font-size: 1.0625rem;
  font-weight: 620;
  letter-spacing: -0.012em;
  color: var(--ink-900);
  margin: 2rem 0 0.65rem;
}
.prose h4 {
  font-size: 0.94rem;
  font-weight: 640;
  letter-spacing: 0.02em;
  color: var(--slate-500);
  text-transform: uppercase;
  margin: 1.75rem 0 0.6rem;
}
.prose p { margin-bottom: 1rem; }
.prose p:last-child { margin-bottom: 0; }
.prose strong { font-weight: 620; color: var(--ink-900); }
.prose a:not(.btn) {
  color: var(--blue-700);
  text-decoration: underline;
  text-underline-offset: 2px;
  text-decoration-thickness: 1px;
  text-decoration-color: var(--blue-300);
}
.prose a:not(.btn):hover { text-decoration-color: var(--blue-700); }

/* Numbered clauses — the backbone of the terms and the DPA */
.clauses { counter-reset: clause; }
.clauses > li {
  position: relative;
  padding-left: 3.1rem;
  margin-bottom: 1.05rem;
  counter-increment: clause;
}
/* --sec is set per section as a *quoted* string (style="--sec:'11'"). It must be
   quoted: content: only accepts strings, so an unquoted number invalidates the
   whole declaration and the clause number silently disappears. */
.clauses > li::before {
  content: var(--sec) "." counter(clause);
  position: absolute;
  left: 0;
  top: 0;
  font-size: 0.83rem;
  font-weight: 620;
  color: var(--blue-700);
  font-variant-numeric: tabular-nums;
  line-height: 1.95;
}
.clauses ul, .clauses ol { margin: 0.6rem 0 0.2rem; }

/* Subheadings within a clause list. Kept as <li> so the <ol> stays valid, but
   excluded from the numbering so clause references don't shift. */
.clauses > li.clause-head {
  counter-increment: none;
  padding-left: 0;
  margin-top: 2rem;
  margin-bottom: 0.4rem;
}
.clauses > li.clause-head::before { content: none; }
.clauses > li.clause-head h3 { margin: 0; }

/* Bulleted and lettered lists */
.prose ul.bullets { margin: 0.85rem 0 1.15rem; }
.prose ul.bullets > li {
  position: relative;
  padding-left: 1.4rem;
  margin-bottom: 0.55rem;
}
.prose ul.bullets > li::before {
  content: "";
  position: absolute;
  left: 0.3rem;
  top: 0.72em;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--blue-400);
}
.prose ol.alpha { margin: 0.85rem 0 1.15rem; counter-reset: alpha; }
.prose ol.alpha > li {
  position: relative;
  padding-left: 2.1rem;
  margin-bottom: 0.55rem;
  counter-increment: alpha;
}
.prose ol.alpha > li::before {
  content: "(" counter(alpha, lower-alpha) ")";
  position: absolute;
  left: 0;
  top: 0;
  font-weight: 600;
  color: var(--slate-400);
  font-size: 0.9rem;
  line-height: 1.85;
}

/* Definition blocks */
.defs { margin: 1rem 0 1.25rem; }
.defs dt { font-weight: 620; color: var(--ink-900); margin-top: 0.9rem; font-size: 0.98rem; }
.defs dt:first-child { margin-top: 0; }
.defs dd { margin: 0.2rem 0 0; color: var(--ink-700); }

/* Tables */
.prose .tbl-wrap {
  overflow-x: auto;
  margin: 1.35rem 0 1.6rem;
  border: 1px solid var(--slate-200);
  border-radius: var(--radius);
  -webkit-overflow-scrolling: touch;
}
.prose table {
  width: 100%;
  min-width: 540px;
  border-collapse: collapse;
  font-size: 0.9rem;
}
.prose thead th {
  text-align: left;
  font-size: 0.7rem;
  font-weight: 660;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--slate-500);
  background: var(--slate-50);
  padding: 0.7rem 0.9rem;
  border-bottom: 1px solid var(--slate-200);
  white-space: nowrap;
}
.prose tbody td {
  padding: 0.75rem 0.9rem;
  border-bottom: 1px solid var(--slate-100);
  vertical-align: top;
  line-height: 1.5;
}
.prose tbody tr:last-child td { border-bottom: 0; }
.prose tbody td:first-child { font-weight: 560; color: var(--ink-900); }
.prose code, .prose .ref {
  font-family: var(--font-mono);
  font-size: 0.86em;
  background: var(--blue-50);
  color: var(--blue-700);
  padding: 0.1em 0.4em;
  border-radius: 5px;
  font-weight: 550;
  white-space: nowrap;
}

/* Callouts */
.callout {
  margin: 1.4rem 0;
  padding: 1.15rem 1.35rem;
  border-radius: var(--radius);
  border: 1px solid var(--slate-200);
  background: var(--slate-50);
  font-size: 0.95rem;
  line-height: 1.6;
}
.callout p { margin-bottom: 0.7rem; }
.callout p:last-child { margin-bottom: 0; }
.callout .callout-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 640;
  font-size: 0.87rem;
  letter-spacing: 0.01em;
  color: var(--ink-900);
  margin-bottom: 0.5rem;
}
.callout .callout-title svg { flex-shrink: 0; }
.callout-info { background: var(--blue-50); border-color: var(--blue-100); }
.callout-info .callout-title { color: var(--blue-700); }
.callout-warn { background: var(--warn-soft); border-color: #f0e0bf; }
.callout-warn .callout-title { color: var(--warn); }

/* Placeholders the Wingcert team must fill before publishing.
   Deliberately loud — an unfilled field should be impossible to miss. */
.ph {
  background: #fff2b2;
  border-bottom: 2px solid #e0b93a;
  color: #6b4e00;
  font-weight: 600;
  padding: 0.05em 0.3em;
  border-radius: 3px;
  font-size: 0.95em;
}

/* Draft banner */
.draft-banner {
  background: var(--warn-soft);
  border-bottom: 1px solid #f0e0bf;
  padding: 0.7rem 0;
  font-size: 0.85rem;
  color: #7a5710;
  position: relative;
  z-index: 90;
  margin-top: 68px;
}
.draft-banner .wrap { display: flex; gap: 0.6rem; align-items: flex-start; }
.draft-banner svg { flex-shrink: 0; margin-top: 2px; }
.draft-banner strong { font-weight: 660; }
.draft-banner + .legal-head { padding-top: clamp(2.5rem, 5vw, 4rem); }

/* Signature / contact block */
.sig-block {
  margin-top: 1.4rem;
  padding: 1.35rem 1.5rem;
  border: 1px solid var(--slate-200);
  border-radius: var(--radius);
  background: var(--white);
  font-size: 0.95rem;
  line-height: 1.7;
}
.sig-block strong { display: block; margin-bottom: 0.35rem; }

/* Back to top */
.to-top {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: 3rem;
  font-size: 0.85rem;
  color: var(--slate-400);
  font-weight: 540;
}
.to-top:hover { color: var(--blue-700); }

/* ------------------------------------------------------------ mobile --- */
@media (max-width: 940px) {
  .legal-body { grid-template-columns: 1fr; gap: 0; }
  .toc {
    position: static;
    max-height: none;
    margin-bottom: 2.5rem;
    padding: 1.15rem 1.3rem;
    border: 1px solid var(--slate-200);
    border-radius: var(--radius);
    background: var(--slate-50);
  }
  .toc ol { columns: 2; column-gap: 1.5rem; }
  .toc a { border-left: 0; padding-left: 0; }
  .toc a.is-current { background: none; }
  .prose { max-width: none; }
}

@media (max-width: 600px) {
  .toc ol { columns: 1; }
  .legal-meta { gap: 1.1rem 1.5rem; }
  .clauses > li { padding-left: 2.6rem; }
}

@media print {
  .nav, .toc, .legal-switch, .to-top, .draft-banner { display: none !important; }
  .legal-body { grid-template-columns: 1fr; padding-top: 0; }
  .legal-head { padding-top: 0; }
  .prose { max-width: none; font-size: 10.5pt; }
  .prose > section { break-inside: avoid-page; }
  .ph { background: none; border-bottom: 1px solid #000; }
}
