/* ============================================================
   LEGAL — components/legal.css
   Shared shell for all the legal pages:
   privacy.html · cookies.html · terms.html · eula.html
   Requires components/base.css to be loaded BEFORE.
   ============================================================ */

:root {
  --lg-bg: #16120D;
  --lg-surface: #2C241D;
  --lg-surface-2: #362D24;
  --lg-border: rgba(255, 255, 255, 0.08);
  --lg-border-soft: rgba(255, 255, 255, 0.05);
  --lg-text:          rgba(255, 255, 255, 0.90);
  --lg-body:          rgba(255, 255, 255, 0.66);
  --lg-muted:         rgba(255, 255, 255, 0.56);
  --lg-dim:           rgba(255, 255, 255, 0.48);
  --lg-accent:        #FF5A1F;
  --lg-accent-soft:   rgba(255, 90, 31, 0.12);
  --lg-mint:          #00D4AA;
  --lg-measure:       68ch;
}

.legal {
  background: var(--lg-bg);
  color: var(--lg-text);
  font-family: var(--font-body);
}

body.legal-page {
  background: var(--lg-bg);
  color: var(--lg-text);
  font-family: var(--font-body);
}

/* Anchor below the fixed nav */
.legal [id] { scroll-margin-top: calc(var(--nav-height, 64px) + 24px); }

/* ============================================================
   HERO
   ============================================================ */
.legal-hero {
  position: relative;
  padding: calc(var(--nav-height, 64px) + 88px) 0 56px;
  border-bottom: 1px solid var(--lg-border-soft);
  overflow: hidden;
}

.legal-hero::before {
  content: '';
  position: absolute;
  top: -240px;
  left: 50%;
  width: 900px;
  height: 520px;
  transform: translateX(-50%);
  background: radial-gradient(ellipse at center, rgba(255, 90, 31, 0.10), transparent 68%);
  pointer-events: none;
}

.legal-hero-inner {
  position: relative;
  z-index: 1;
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 var(--sp-3);
}

.legal-breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--lg-dim);
  margin-bottom: 28px;
}

.legal-breadcrumb a {
  /* Full-height hit area (44px) without moving the line */
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  margin-block: -12px;
  color: var(--lg-muted);
  transition: color var(--transition);
}
.legal-breadcrumb a:hover { color: var(--lg-accent); }
.legal-breadcrumb span[aria-current] { color: var(--lg-body); }

.legal-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: var(--fs-label);
  font-weight: 550;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--lg-accent);
  margin-bottom: 18px;
}

.legal-eyebrow::before {
  content: '';
  width: 20px;
  height: 1px;
  background: var(--lg-accent);
}

.legal-hero h1 {
  font-family: var(--font-display);
  font-size: clamp(36px, 6vw, 60px);
  font-weight: 500;
  line-height: 1.04;
  letter-spacing: -0.035em;
  color: #fff;
  margin: 0 0 20px;
  max-width: 16ch;
}

.legal-lede {
  font-size: clamp(16px, 2vw, 19px);
  line-height: 1.65;
  color: var(--lg-body);
  max-width: 58ch;
  margin: 0;
}

/* ── Meta bar (dates + actions) ── */
.legal-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 28px;
  margin-top: 40px;
  padding-top: 28px;
  border-top: 1px solid var(--lg-border-soft);
}

.legal-meta-item {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.legal-meta-label {
  font-size: var(--fs-label);
  font-weight: 550;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--lg-dim);
}

.legal-meta-value {
  font-size: 14px;
  font-weight: 500;
  color: var(--lg-text);
}

.legal-meta-actions {
  display: flex;
  gap: 10px;
  margin-left: auto;
}

.legal-action {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 16px;
  border: 1px solid var(--lg-border);
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.03);
  color: var(--lg-body);
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  transition: color var(--transition), background-color var(--transition), border-color var(--transition), opacity var(--transition), transform var(--transition), box-shadow var(--transition);
}

.legal-action:hover {
  color: #fff;
  border-color: rgba(255, 255, 255, 0.20);
  background: rgba(255, 255, 255, 0.07);
}

.legal-action svg { flex-shrink: 0; }

/* ============================================================
   LAYOUT — sidebar TOC + content
   ============================================================ */
.legal-layout {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 64px var(--sp-3) 96px;
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 64px;
  align-items: start;
}

/* ── TOC ── */
.legal-toc {
  position: sticky;
  top: calc(var(--nav-height, 64px) + 32px);
  max-height: calc(100vh - var(--nav-height, 64px) - 64px);
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.14) transparent;
}

.legal-toc::-webkit-scrollbar { width: 4px; }
.legal-toc::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.14); border-radius: 4px; }

.legal-toc-title {
  font-size: 10px;
  font-weight: 550;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--lg-dim);
  margin: 0 0 16px;
  padding-left: 14px;
}

.legal-toc ol {
  list-style: none;
  margin: 0;
  padding: 0;
  counter-reset: toc;
  border-left: 1px solid var(--lg-border);
}

.legal-toc li { counter-increment: toc; }

.legal-toc a {
  display: block;
  position: relative;
  padding: 7px 12px 7px 14px;
  font-size: 13.5px;
  line-height: 1.45;
  color: var(--lg-muted);
  border-left: 2px solid transparent;
  margin-left: -1px;
  transition: color var(--transition), border-color var(--transition);
}

.legal-toc a::before {
  content: counter(toc) '.';
  display: inline-block;
  width: 20px;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  color: var(--lg-dim);
}

.legal-toc a:hover { color: var(--lg-text); }

.legal-toc a.is-active {
  color: #fff;
  border-left-color: var(--lg-accent);
  font-weight: 500;
}

.legal-toc a.is-active::before { color: var(--lg-accent); }

/* ── Mobile TOC toggle ── */
.legal-toc-toggle {
  display: none;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  border: 1px solid var(--lg-border);
  border-radius: var(--radius-md);
  background: var(--lg-surface);
  color: var(--lg-text);
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
}

.legal-toc-toggle svg { transition: transform var(--transition); }
.legal-toc-toggle[aria-expanded="true"] svg { transform: rotate(180deg); }

/* ============================================================
   CONTENT
   ============================================================ */
/* Text keeps a comfortable reading measure; tables and grids
   use the full column width, which is where they help legibility. */
.legal-content { max-width: none; }

.legal-content h2,
.legal-content h3,
.legal-content h4,
.legal-content p,
.legal-content ul,
.legal-content ol,
.legal-note { max-width: var(--lg-measure); }

.legal-section { padding-bottom: 8px; }
.legal-section + .legal-section { margin-top: 56px; }

.legal-content h2 {
  position: relative;
  font-family: var(--font-display);
  font-size: clamp(22px, 3vw, 27px);
  font-weight: 550;
  line-height: 1.25;
  letter-spacing: -0.02em;
  color: #fff;
  margin: 0 0 8px;
}

.legal-section-num {
  display: block;
  font-size: var(--fs-label);
  font-weight: 550;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.14em;
  color: var(--lg-accent);
  margin-bottom: 10px;
}

.legal-content h3 {
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 550;
  letter-spacing: -0.01em;
  color: rgba(255, 255, 255, 0.92);
  margin: 32px 0 10px;
}

.legal-content h4 {
  font-size: 14px;
  font-weight: 550;
  color: rgba(255, 255, 255, 0.86);
  margin: 24px 0 8px;
}

.legal-content p {
  font-size: 15.5px;
  line-height: 1.78;
  color: var(--lg-body);
  margin: 0 0 16px;
}

.legal-content > p:first-of-type,
.legal-section > p:first-of-type { margin-top: 16px; }

.legal-content a:not(.legal-action):not(.legal-doc-card) {
  color: var(--lg-accent);
  text-decoration: underline;
  text-decoration-color: rgba(255, 90, 31, 0.35);
  text-underline-offset: 3px;
  transition: text-decoration-color var(--transition);
}

.legal-content a:not(.legal-action):not(.legal-doc-card):hover {
  text-decoration-color: var(--lg-accent);
}

.legal-content strong { color: rgba(255, 255, 255, 0.88); font-weight: 550; }

.legal-content ul,
.legal-content ol {
  margin: 0 0 18px;
  padding-left: 0;
  list-style: none;
}

.legal-content li {
  position: relative;
  padding-left: 22px;
  font-size: 15.5px;
  line-height: 1.75;
  color: var(--lg-body);
  margin-bottom: 9px;
}

.legal-content ul > li::before {
  content: '';
  position: absolute;
  left: 4px;
  top: 11px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: rgba(255, 90, 31, 0.55);
}

.legal-content ol { counter-reset: olist; }
.legal-content ol > li { counter-increment: olist; }
.legal-content ol > li::before {
  content: counter(olist) '.';
  position: absolute;
  left: 0;
  top: 0;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  color: var(--lg-accent);
  font-weight: 550;
}

/* ── Tables ── */
.legal-table-wrap {
  margin: 22px 0 26px;
  border: 1px solid var(--lg-border);
  border-radius: var(--radius-md);
  overflow-x: auto;
  background: rgba(255, 255, 255, 0.02);
  -webkit-overflow-scrolling: touch;
}

.legal-table {
  width: 100%;
  min-width: 520px;
  border-collapse: collapse;
  font-size: 13.5px;
}

.legal-table caption {
  text-align: left;
  padding: 14px 18px 0;
  font-size: 12px;
  color: var(--lg-dim);
}

.legal-table th {
  text-align: left;
  padding: 13px 18px;
  font-size: 10.5px;
  font-weight: 550;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--lg-muted);
  background: rgba(255, 255, 255, 0.03);
  border-bottom: 1px solid var(--lg-border);
  white-space: nowrap;
}

.legal-table td {
  padding: 14px 18px;
  line-height: 1.6;
  color: var(--lg-body);
  border-bottom: 1px solid var(--lg-border-soft);
  vertical-align: top;
}

.legal-table tbody tr:last-child td { border-bottom: none; }
.legal-table tbody tr:hover td { background: rgba(255, 255, 255, 0.015); }

.legal-table td:first-child {
  color: rgba(255, 255, 255, 0.88);
  font-weight: 500;
}

.legal-table code {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--lg-mint);
  background: rgba(0, 212, 170, 0.08);
  padding: 2px 6px;
  border-radius: 4px;
  white-space: nowrap;
}

/* ── Callouts ── */
.legal-note {
  display: flex;
  gap: 14px;
  margin: 24px 0;
  padding: 18px 20px;
  border-radius: var(--radius-md);
  border: 1px solid var(--lg-border);
  background: var(--lg-surface);
}

.legal-note--accent {
  border-color: rgba(255, 90, 31, 0.28);
  background: linear-gradient(180deg, rgba(255, 90, 31, 0.10), rgba(255, 90, 31, 0.03));
}

.legal-note-icon {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  margin-top: 2px;
  color: var(--lg-accent);
}

.legal-note-body p { margin: 0 0 8px; font-size: 14.5px; }
.legal-note-body p:last-child { margin-bottom: 0; }
.legal-note-title {
  display: block;
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 550;
  letter-spacing: -0.015em;
  color: #fff;
  margin-bottom: 10px;
  text-wrap: balance;
}

.legal-note--accent .legal-note-title { font-size: 17.5px; }

/* ── Rights / definitions cards ── */
.legal-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 12px;
  margin: 22px 0 26px;
}

.legal-card {
  padding: 18px 20px;
  border: 1px solid var(--lg-border);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.02);
  transition: border-color var(--transition), background var(--transition);
}

.legal-card:hover {
  border-color: rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.04);
}

.legal-card-title {
  display: block;
  font-size: 14px;
  font-weight: 550;
  color: #fff;
  margin-bottom: 6px;
}

.legal-card p {
  font-size: 13.5px;
  line-height: 1.6;
  color: var(--lg-muted);
  margin: 0;
}

/* ── Contact block ── */
.legal-contact-block {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1px;
  margin: 24px 0;
  border: 1px solid var(--lg-border);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--lg-border);
}

.legal-contact-item {
  padding: 20px;
  background: var(--lg-surface);
}

.legal-contact-item h4 {
  margin: 0 0 8px;
  font-size: var(--fs-label);
  font-weight: 550;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--lg-dim);
}

.legal-contact-item p,
.legal-contact-item address {
  margin: 0;
  font-size: 14px;
  font-style: normal;
  line-height: 1.65;
  color: var(--lg-body);
}

/* A lone email address in a contact block: 44px hit area without
   moving the line (padding offset by margin) */
.legal-contact-item p > a:only-child {
  display: inline-block;
  padding-block: 12px;
  margin-block: -12px;
}

/* ── Document footer ── */
.legal-docs {
  margin-top: 72px;
  padding-top: 40px;
  border-top: 1px solid var(--lg-border-soft);
}

.legal-docs-title {
  font-size: 11px;
  font-weight: 550;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--lg-dim);
  margin: 0 0 18px;
}

.legal-docs-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 10px;
}

.legal-doc-card {
  /* Title above its one-line summary: side by side, both squeezed into
     narrow columns on phones */
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  padding: 16px 18px;
  border: 1px solid var(--lg-border);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.02);
  font-size: 14px;
  font-weight: 500;
  color: var(--lg-body);
  transition: color var(--transition), background-color var(--transition), border-color var(--transition), opacity var(--transition), transform var(--transition), box-shadow var(--transition);
}

@media (hover: hover) and (pointer: fine) {
  .legal-doc-card:hover {
    color: #fff;
    border-color: rgba(255, 90, 31, 0.35);
    background: rgba(255, 90, 31, 0.06);
    transform: translateY(-1px);
  }
}

.legal-docs .legal-doc-card .legal-card-title { margin: 0; }
.legal-docs .legal-doc-card p {
  max-width: none;
  margin: 0;
  font-size: var(--fs-small);
  line-height: 1.55;
  color: var(--lg-muted);
}

.legal-doc-card svg { color: var(--lg-dim); transition: color var(--transition), transform var(--transition); }
@media (hover: hover) and (pointer: fine) { .legal-doc-card:hover svg { color: var(--lg-accent); transform: translateX(2px); } }

/* ── Reading progress ── */
.legal-progress {
  position: fixed;
  top: var(--nav-height, 64px);
  left: 0;
  height: 2px;
  width: 0;
  background: var(--lg-accent);
  z-index: 90;
  transition: width 0.1s linear;
  pointer-events: none;
}

/* ── Back to top ── */
.legal-top {
  position: fixed;
  right: 24px;
  bottom: 24px;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1px solid var(--lg-border);
  background: rgba(44, 36, 29, 0.9);
  backdrop-filter: blur(12px);
  color: var(--lg-body);
  opacity: 0;
  visibility: hidden;
  transform: translateY(8px);
  transition: color var(--transition), background-color var(--transition), border-color var(--transition), opacity var(--transition), transform var(--transition), box-shadow var(--transition);
  z-index: 89;
}

.legal-top.is-visible { opacity: 1; visibility: visible; transform: translateY(0); }
/* Footer in view: step aside (legal.js) */
.legal-top.is-visible.is-docked { opacity: 0; visibility: hidden; transform: translateY(8px); }
.legal-top:hover { color: #fff; border-color: rgba(255, 255, 255, 0.2); }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 1024px) {
  .legal-layout { grid-template-columns: 220px minmax(0, 1fr); gap: 40px; }
}

@media (max-width: 860px) {
  .legal-layout {
    grid-template-columns: minmax(0, 1fr);
    gap: 24px;
    padding-top: 40px;
  }

  .legal-toc-toggle { display: flex; }

  .legal-toc {
    position: static;
    max-height: none;
    overflow: visible;
    display: none;
    padding: 4px 0 8px;
  }

  .legal-toc.is-open { display: block; }
  .legal-toc-title { display: none; }
  .legal-meta-actions { margin-left: 0; width: 100%; }
}

/* ── Tables → stacked cards on mobile ──
   A 5-column cookie inventory is unreadable inside a 340px horizontal
   scroll. Each row becomes a card of label/value pairs, taking the
   label from the <th> via data-label. */
@media (max-width: 620px) {
  .legal-table-wrap {
    border: none;
    background: none;
    border-radius: 0;
    overflow-x: visible;
  }

  .legal-table { min-width: 0; display: block; }
  .legal-table thead { display: none; }
  .legal-table tbody { display: block; }

  /* With the table as display:block the caption loses its width and collapses
     to a one-word column: it has to be given back explicitly. */
  .legal-table caption {
    display: block;
    width: 100%;
    padding: 0 0 12px;
    font-size: 12.5px;
    line-height: 1.55;
    color: var(--lg-muted);
  }

  .legal-table tr {
    display: block;
    margin-bottom: 10px;
    padding: 6px 0;
    border: 1px solid var(--lg-border);
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.02);
  }

  .legal-table tbody tr:last-child { margin-bottom: 0; }
  .legal-table tbody tr:hover td { background: none; }

  .legal-table td {
    display: block;
    padding: 9px 16px;
    border-bottom: none;
    font-size: 14px;
  }

  .legal-table td + td { border-top: 1px solid var(--lg-border-soft); }

  .legal-table td::before {
    content: attr(data-label);
    display: block;
    margin-bottom: 4px;
    font-size: 10px;
    font-weight: 550;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--lg-dim);
  }

  .legal-table td:empty { display: none; }

  .legal-table td:first-child {
    font-size: 15px;
    font-weight: 550;
    color: #fff;
  }

  .legal-table code { white-space: normal; word-break: break-word; }

  /* Long URLs (browser support, third-party notices) */
  .legal-table td,
  .legal-table td a { overflow-wrap: anywhere; }
}

@media (max-width: 560px) {
  .legal-hero { padding-top: calc(var(--nav-height, 64px) + 56px); padding-bottom: 40px; }
  .legal-meta { gap: 16px; }
  .legal-meta-item { min-width: 44%; }
  .legal-contact-block { grid-template-columns: 1fr; }
  .legal-top { right: 16px; bottom: 16px; }
}

/* ============================================================
   PRINT
   ============================================================ */
@media print {
  .legal, body.legal-page { background: #fff !important; color: #000 !important; }
  nav, .footer, .legal-toc, .legal-toc-toggle, .legal-top,
  .legal-progress, .legal-meta-actions, .legal-docs, [data-nav], [data-footer],
  .cc-banner, .cc-modal { display: none !important; }
  .legal-hero { padding: 0 0 20px; border-bottom: 1px solid #ccc; }
  .legal-hero::before { display: none; }
  .legal-hero h1 { color: #000; font-size: 28px; }
  .legal-layout { display: block; padding: 0; max-width: none; }
  .legal-content { max-width: none; }
  .legal-content h2, .legal-content h3, .legal-content h4 { color: #000; page-break-after: avoid; }
  .legal-content p, .legal-content li, .legal-lede { color: #222; font-size: 11pt; }
  .legal-table th, .legal-table td { color: #222; border-color: #ccc; }
  .legal-note, .legal-card, .legal-contact-item { border: 1px solid #ccc; background: #fafafa; }
  .legal-section { page-break-inside: avoid; }
  a { color: #000 !important; }
}

@media (prefers-reduced-motion: reduce) {
  .legal-progress, .legal-top, .legal-doc-card, .legal-card { transition: none; }
}


/* ── Links inside running text ──
   WCAG 1.4.1: if colour is the only distinguishing feature it needs 3:1 against
   the surrounding text. Here it was 1.24:1, so the underline does the job. */
.legal-body p a,
.legal-body li a {
  text-decoration: underline;
  text-underline-offset: 2px;
  text-decoration-thickness: 1px;
}
.legal-body p a:hover,
.legal-body li a:hover { text-decoration-thickness: 2px; }
