/* Legal pages: the site look (../styles.css) with a readable document
   layout. Header like an app screen, contents list as a sticky sticker
   card, the policy itself in one long card. */

.legal-main { max-width: var(--max); margin: 0 auto; padding: 36px 0 24px; }

.legal-hero { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px 24px; margin-bottom: 28px; }
.legal-hero h1 { font-size: clamp(32px, 4.6vw, 48px); letter-spacing: -0.3px; }
.legal-hero p { margin-top: 8px; max-width: 60ch; color: var(--ink-soft); font-size: 17px; font-weight: 700; }
.legal-hero > div { min-width: 0; }
.updated {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border: 2px solid var(--outline);
  border-radius: 999px;
  background: var(--sun-soft);
  box-shadow: 0 3px 0 var(--shadow);
  font-family: var(--display);
  font-weight: 600;
  font-size: 14px;
  color: var(--ink);
  white-space: nowrap;
}

/* ---------- hub ---------- */

.legal-cards { display: grid; grid-template-columns: repeat(2, 1fr); gap: 18px; }
.legal-card {
  display: flex; gap: 16px; align-items: flex-start;
  padding: 22px 22px 20px;
  color: var(--ink);
  text-decoration: none;
  transition: transform 0.15s cubic-bezier(.3,1.6,.5,1);
}
.legal-card:hover { transform: translateY(-3px); }
.legal-card:active { transform: scale(0.98); }
.legal-card > div { flex: 1; min-width: 0; }
.legal-card h2 { font-size: 22px; margin-bottom: 6px; }
.legal-card p { color: var(--ink-soft); font-size: 15px; }
.legal-card .go { display: inline-flex; align-items: center; gap: 4px; margin-top: 12px; font-family: var(--display); font-weight: 600; color: var(--mint-deep); }
.legal-card .go .icon { width: 18px; height: 18px; }
.legal-card-wide { grid-column: 1 / -1; }
.contact-card { margin-top: 18px; padding: 22px 24px; display: flex; align-items: center; gap: 16px; background: var(--sky-soft); }
.contact-card h2 { font-size: 20px; margin-bottom: 4px; }
.contact-card p { color: var(--prose); }

/* ---------- document pages ---------- */

.legal-layout { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 22px; align-items: start; }
.legal-layout > * { min-width: 0; }

.toc {
  position: sticky;
  top: calc(var(--nav-h) + 18px);
  padding: 18px 16px;
  max-height: calc(100vh - var(--nav-h) - 40px);
  overflow: auto;
  scrollbar-width: thin;
}
.toc summary { list-style: none; cursor: default; }
.toc summary::-webkit-details-marker { display: none; }
.toc h2 { display: inline; font-size: 17px; }
.toc nav { margin-top: 10px; }
.toc ol { margin: 0; padding: 0; list-style: none; counter-reset: toc; }
.toc li { margin: 2px 0; }
.toc a {
  display: flex; align-items: baseline; gap: 10px;
  padding: 6px 10px;
  border-radius: 10px;
  color: var(--ink-soft);
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
  counter-increment: toc;
  transition: background 0.15s ease, color 0.15s ease;
}
.toc a::before { content: counter(toc); flex: none; min-width: 18px; font-family: var(--display); font-weight: 600; font-size: 12px; color: var(--ink-soft); opacity: 0.8; }
.toc a:hover { color: var(--ink); background: var(--sand); }
.toc a[aria-current] { color: var(--ink); background: var(--mint-soft); box-shadow: inset 0 0 0 2px var(--outline); }
.toc a[aria-current]::before { color: var(--mint-deep); opacity: 1; }

.doc { padding: 30px 36px 34px; overflow-wrap: break-word; }
.doc section { scroll-margin-top: calc(var(--nav-h) + 20px); }
.doc section + section { margin-top: 30px; padding-top: 26px; border-top: 2px dashed color-mix(in srgb, var(--ink) 16%, transparent); }
.doc h2 { font-size: 24px; margin-bottom: 12px; }
.doc h3 { font-size: 18px; margin: 20px 0 6px; }
.doc p, .doc li { color: var(--prose); overflow-wrap: anywhere; }
.doc p { margin: 0 0 12px; }
.doc ul, .doc ol { margin: 0 0 12px; padding-left: 22px; }
.doc li { margin: 4px 0; }
.doc li::marker { color: var(--mint-deep); font-weight: 800; }
.doc strong { color: var(--ink); }
.doc code { font-size: 0.9em; padding: 1px 6px; border-radius: 6px; background: var(--sand); color: var(--ink); overflow-wrap: anywhere; }
.doc table { width: 100%; border-collapse: separate; border-spacing: 0; margin: 6px 0 16px; font-size: 15px; border: 2px solid var(--outline); border-radius: 14px; overflow: hidden; }
.doc th, .doc td { text-align: left; vertical-align: top; padding: 10px 12px; border-top: 1.5px solid color-mix(in srgb, var(--ink) 15%, transparent); }
.doc th { background: var(--mint-soft); font-family: var(--display); font-weight: 600; color: var(--ink); border-top: 0; }
.doc td + td, .doc th + th { border-left: 1.5px solid color-mix(in srgb, var(--ink) 15%, transparent); }
.table-wrap { overflow-x: auto; }

.callout {
  margin: 0 0 18px;
  padding: 14px 18px;
  border: 2px solid var(--outline);
  border-radius: 16px;
  background: var(--sky-soft);
  box-shadow: 0 3px 0 var(--shadow);
}
.callout p:last-child { margin-bottom: 0; }

/* ---------- responsive ---------- */

@media (max-width: 860px) {
  .legal-layout { grid-template-columns: 1fr; }
  .toc { position: static; max-height: none; }
  /* Phones/tablets: the contents list folds away so the policy starts sooner. */
  .toc summary { cursor: pointer; position: relative; padding-right: 36px; }
  .toc summary::after {
    content: "+";
    position: absolute; right: 0; top: 50%;
    transform: translateY(-50%);
    width: 28px; height: 28px;
    display: grid; place-items: center;
    border: 2px solid var(--outline);
    border-radius: 9px;
    background: var(--mint-soft);
    box-shadow: 0 2px 0 var(--shadow);
    font-family: var(--display);
    font-weight: 700;
  }
  .toc[open] summary::after { content: "−"; background: var(--sun); color: var(--tile-ink); }
  .doc { padding: 22px 18px; }
  .legal-cards { grid-template-columns: 1fr; }
}

/* Narrow screens: the provider table becomes stacked cards. */
@media (max-width: 600px) {
  .doc table, .doc tbody, .doc tr, .doc td { display: block; width: 100%; }
  .doc table { border: 0; border-radius: 0; overflow: visible; }
  .doc thead { display: none; }
  .doc tr { border: 2px solid var(--outline); border-radius: 14px; margin-bottom: 10px; overflow: hidden; box-shadow: 0 3px 0 var(--shadow); background: var(--card); }
  .doc td { border: 0; border-top: 1.5px dashed color-mix(in srgb, var(--ink) 18%, transparent); padding: 8px 12px; }
  .doc td + td { border-left: 0; }
  .doc td:first-child { border-top: 0; background: var(--mint-soft); font-family: var(--display); color: var(--ink); }
  .doc td[data-label]:not(:first-child)::before {
    content: attr(data-label);
    display: block;
    font-size: 11px;
    font-weight: 900;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--ink-soft);
  }
}

@media (max-width: 480px) {
  .legal-main { padding: 24px 0 16px; }
  .legal-hero { margin-bottom: 20px; }
  .legal-card { padding: 18px 16px; gap: 12px; }
  .contact-card { flex-direction: column; align-items: flex-start; padding: 18px 16px; overflow-wrap: anywhere; }
  .doc { padding: 20px 16px; }
  .doc ul, .doc ol { padding-left: 18px; }
  .callout { padding: 12px 14px; }
}

@media print {
  .toc { display: none !important; }
  .legal-layout { grid-template-columns: 1fr; }
}
