/* ============================================================
   Legal pages — content components (Rails-authored)

   The design's legal mockups (legal-*.html) are six-paragraph
   placeholders; the app's Privacy, Terms and Cookies pages carry
   the real text, with a contents list, definition tables, callouts
   and the cookie-preference panel. Those components are restyled
   here in the design's idiom (its tokens, Source Sans 3, its radii)
   and sit inside the design's .legal-hdr + .legal-wrap shell from
   hd/portal-approvals.css. Loaded only on /privacy /terms /cookies.
   ============================================================ */
.legal-wrap{max-width:1100px}
.legal-wrap .legal-grid h2{margin-top:0}
/* ============================================================
 * Legal pages — terms, privacy, cookies
 *
 * Loaded on top of auth.css (which provides the public layout
 * shell + topbar + footer). Adds the legal-specific body chrome:
 *
 *   .legal-hero          — eyebrow + title + lede + meta row
 *   .legal-grid          — sidebar (TOC) + main column
 *   .legal-toc           — sticky table of contents
 *   .legal-body          — section type + spacing
 *   .legal-callout       — plain-English summary box
 *   .legal-deftable      — dt/dd structured key-value lists
 *   .legal-back-top      — scroll-to-top link at section ends
 *   .cookie-panel,
 *   .cookie-cat,
 *   .toggle              — cookie preferences card
 *   .cookie-table        — the per-cookie inventory tables
 * ============================================================ */

/* ---- Hero ---- */

.legal-hero {
  width: 100%;
  max-width: 1100px;
  margin: 24px auto 24px;
  padding: 0 4px;
}
.legal-eyebrow {
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-3);
  font-weight: 600;
}
.legal-title {
  font-family: var(--font);
  font-size: 38px;
  line-height: 1.1;
  letter-spacing: -0.02em;
  font-weight: 500;
  margin: 8px 0 14px;
  color: var(--ink);
}
.legal-lede {
  font-size: 15.5px;
  line-height: 1.6;
  color: var(--ink-2);
  margin: 0 0 20px;
  max-width: 720px;
}

.legal-meta {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
  font-size: 12.5px;
  color: var(--ink-3);
  padding: 12px 0;
  border-top: 1px solid var(--line-2);
  border-bottom: 1px solid var(--line-2);
}
.legal-meta .lm-row strong {
  color: var(--ink);
  font-weight: 500;
  margin-left: 4px;
}

/* ---- Grid: sidebar + body ---- */

.legal-grid {
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 56px;
  align-items: start;
}
@media (max-width: 900px) {
  .legal-grid { grid-template-columns: 1fr; gap: 24px; }
  /* On narrow screens the sticky TOC becomes a non-sticky block at
     the top — long lists of TOC links don't deserve to take over
     the viewport when there's no room for a sidebar. */
  .legal-toc { position: static !important; }
}

/* ---- TOC sidebar ---- */

.legal-toc {
  position: sticky;
  top: 24px;
  font-size: 12.5px;
  align-self: start;
}
.legal-toc h4 {
  margin: 0 0 12px;
  font-size: 10.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-3);
  font-weight: 600;
}
.legal-toc ol {
  list-style: none;
  margin: 0;
  padding: 0;
}
.legal-toc li { margin: 0; }
.legal-toc a {
  display: flex;
  gap: 10px;
  align-items: baseline;
  padding: 6px 10px;
  color: var(--ink-2);
  text-decoration: none;
  border-left: 2px solid transparent;
  border-radius: 0 8px 8px 0;
  transition: color .12s, background .12s, border-color .12s;
}
.legal-toc a:hover {
  color: var(--ink);
  background: var(--tint-stone);
}
.legal-toc a.active {
  color: var(--teal-700);
  border-left-color: var(--teal);
  background: var(--teal-50);
  font-weight: 500;
}
.legal-toc .num {
  font-family: ui-monospace,SFMono-Regular,Menlo,monospace;
  font-size: 10.5px;
  color: var(--ink-4);
  flex-shrink: 0;
}
.legal-toc a.active .num { color: var(--teal); }

/* ---- Legal body ---- */

.legal-body { min-width: 0; } /* allow long lines to wrap inside grid track */
.legal-body section { padding: 24px 0; }
.legal-body section + section { border-top: 1px solid var(--line-2); }
.legal-body section:first-of-type { padding-top: 0; }

.legal-body h2 {
  font-family: var(--font);
  font-size: 24px;
  font-weight: 500;
  letter-spacing: -0.015em;
  margin: 0 0 16px;
  display: flex;
  align-items: baseline;
  gap: 12px;
}
.legal-body h2 .sec-num {
  font-family: ui-monospace,SFMono-Regular,Menlo,monospace;
  font-size: 12px;
  color: var(--ink-4);
  font-weight: 500;
  letter-spacing: 0;
  flex-shrink: 0;
}
.legal-body h3 {
  font-size: 14.5px;
  font-weight: 500;
  margin: 18px 0 8px;
  color: var(--ink);
}
.legal-body p,
.legal-body li {
  font-size: 14px;
  line-height: 1.65;
  color: var(--ink-2);
}
.legal-body p { margin: 0 0 12px; }
.legal-body ul {
  margin: 0 0 16px;
  padding-left: 22px;
}
.legal-body ul li { margin-bottom: 6px; }
.legal-body strong { color: var(--ink); font-weight: 500; }
.legal-body code {
  font-family: ui-monospace,SFMono-Regular,Menlo,monospace;
  font-size: 12.5px;
  background: var(--tint-stone);
  border: 1px solid var(--line-2);
  border-radius: 4px;
  padding: 1px 6px;
  color: var(--ink-2);
}
.legal-body a {
  color: var(--teal-700);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.legal-body a:hover { color: var(--teal); }

/* ---- Plain-English summary callout ---- */

.legal-callout {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 14px 16px;
  margin: 0 0 18px;
  background: var(--teal-50);
  border: 1px solid #b6e8ed;
  border-radius: 12px;
}
.legal-callout .ic {
  color: var(--teal-700);
  flex-shrink: 0;
  margin-top: 2px;
}
.legal-callout p {
  margin: 0;
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--ink);
}
.legal-callout strong { color: var(--ink); }

/* ---- Definition tables (Why we use it / How long we keep it) ---- */

.legal-deftable {
  margin: 0 0 8px;
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 8px 24px;
}
@media (max-width: 600px) {
  .legal-deftable { grid-template-columns: 1fr; gap: 4px 0; }
  .legal-deftable dd { margin-bottom: 12px; }
}
.legal-deftable dt {
  font-size: 13.5px;
  font-weight: 500;
  color: var(--ink);
  padding: 6px 0;
}
.legal-deftable dd {
  font-size: 13.5px;
  line-height: 1.6;
  color: var(--ink-2);
  margin: 0;
  padding: 6px 0;
}

/* ---- Back-to-top link ---- */

.legal-back-top {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 16px;
  font-size: 12.5px;
  color: var(--ink-3) !important;
  text-decoration: none !important;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}
.legal-back-top:hover {
  background: var(--tint-stone);
  color: var(--ink) !important;
}

/* ---- Cookie consent panel ----
   Visual treatment only this pass — toggles aren't wired to a
   consent store yet. Designed to fit alongside the legal body
   sections so it reads as part of the page, not a modal. */

.cookie-panel {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
}
.cookie-cat {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 18px;
  padding: 16px 18px;
  align-items: flex-start;
  border-top: 1px solid var(--line-2);
}
.cookie-cat:first-of-type { border-top: none; }
.cookie-cat-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 8px;
}
.cookie-cat-name .pill.req {
  background: var(--tint-stone);
  color: var(--ink-3);
  border-color: var(--line-2);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 1px 7px;
}
.cookie-cat-desc {
  font-size: 12.5px;
  color: var(--ink-3);
  line-height: 1.55;
  margin-top: 4px;
}
.cookie-cat-list {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 8px;
}
.cookie-cat-list .item {
  font-family: ui-monospace,SFMono-Regular,Menlo,monospace;
  font-size: 11px;
  background: var(--tint-stone);
  border: 1px solid var(--line-2);
  color: var(--ink-3);
  padding: 2px 8px;
  border-radius: 4px;
}

/* iOS-style toggle on each row */
.toggle {
  position: relative;
  display: inline-block;
  width: 38px;
  height: 22px;
  flex-shrink: 0;
  cursor: pointer;
}
.toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}
.toggle::before {
  content: "";
  position: absolute;
  inset: 0;
  background: #d6dde2;
  border-radius: 999px;
  transition: background .15s;
}
.toggle::after {
  content: "";
  position: absolute;
  top: 2px; left: 2px;
  width: 18px; height: 18px;
  background: #fff;
  border-radius: 50%;
  transition: transform .15s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.18);
}
.toggle input:checked ~ ::before,
.toggle input:checked + ::before { background: var(--teal); }
/* The actual selector that works regardless of input position: use
   :has() which is widely supported in evergreen browsers. */
.toggle:has(input:checked)::before { background: var(--teal); }
.toggle:has(input:checked)::after { transform: translateX(16px); }
.toggle.locked::before { background: #c4d9dc; }
.toggle.locked { cursor: not-allowed; }

.cookie-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  border-top: 1px solid var(--line-2);
  background: var(--tint-stone);
  flex-wrap: wrap;
}
.cookie-actions .grow {
  flex: 1;
  min-width: 200px;
  font-size: 12px;
  color: var(--ink-3);
}

/* ---- Cookie inventory tables ---- */

.cookie-table {
  width: 100%;
  border-collapse: collapse;
  margin: 0 0 16px;
  font-size: 13px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
}
.cookie-table thead {
  background: var(--tint-stone);
}
.cookie-table th {
  text-align: left;
  font-size: 10.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-3);
  font-weight: 600;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line-2);
}
.cookie-table td {
  padding: 12px 14px;
  border-top: 1px solid var(--line-2);
  color: var(--ink-2);
  line-height: 1.5;
  vertical-align: top;
}
.cookie-table tbody tr:first-of-type td { border-top: none; }
.cookie-table .mono {
  font-family: ui-monospace,SFMono-Regular,Menlo,monospace;
  font-size: 12px;
  color: var(--ink);
}
.cookie-table .pill {
  font-size: 10.5px;
  padding: 1px 8px;
  white-space: nowrap;
}

@media (max-width: 700px) {
  /* Stack table rows on narrow screens — each <tr> becomes a card,
     headers move into pseudo-labels. Skipping the data-label trick
     here; the column count is small (4) so a stacked treatment
     reads fine without it. */
  .cookie-table thead { display: none; }
  .cookie-table,
  .cookie-table tbody,
  .cookie-table tr,
  .cookie-table td {
    display: block;
    width: 100%;
  }
  .cookie-table tr {
    padding: 10px 14px;
    border-top: 1px solid var(--line-2);
  }
  .cookie-table td {
    padding: 4px 0;
    border: none;
  }
}

/* Shell split: hero above, body below, one visual column. */
.legal-wrap--hero{padding-bottom:0}
.legal-wrap--hero .upd{margin-bottom:0;border-bottom:0;padding-bottom:0}
.legal-wrap--body{padding-top:28px}
.legal-hdr nav a{color:var(--ink-2)}
.legal-hdr nav a:hover{color:var(--ink)}
