/* =========================================================
   Medsure – Legal pages
   privacy, cookies, terms, gdp-quality, legal-notice.
   Fonts, tokens, header, footer and the cookie banner come
   from base.css (shared by every page). Only the page lives here.
   ========================================================= */

:root {
  --neutral-600: #5B5D6B;
  --ease-out: cubic-bezier(.16, 1, .3, 1);
}

/* =========================================================
   1. Intro: eyebrow, condensed masked title, meta row + page tabs
   ========================================================= */
.legal-hero {
  padding-top: calc(var(--header-h) + 96px);
  padding-bottom: 64px;
}
.eyebrow {
  margin: 0 0 20px;
  font-size: 20px; line-height: 28px; font-weight: 500;
  animation: legal-fade .9s var(--ease-out) both;
}
.legal-title {
  margin: 0;
  font-family: "Mona", sans-serif;
  font-weight: normal;
  text-transform: uppercase;
  font-size: 128px;
  line-height: 118px;
  letter-spacing: -0.01em;
  color: var(--navy-950);
  transform-origin: top left;
}
.legal-title .line { display: block; overflow: hidden; padding-bottom: .02em; }
.legal-title .line > span { display: block; animation: legal-rise 1.3s var(--ease-out) both; }
.legal-title .line:nth-child(1) > span { animation-delay: .15s; }
.legal-title .line:nth-child(2) > span { animation-delay: .27s; }
.legal-title .line:nth-child(3) > span { animation-delay: .39s; }

.legal-meta {
  position: relative;
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: 20px 40px;
  margin-top: 56px; padding-top: 24px;
  animation: legal-fade .9s var(--ease-out) .55s both;
}
/* the rule above the meta row draws in, like the hero progress bar */
.legal-meta::before {
  content: ""; position: absolute; inset: 0 0 auto; height: 1px;
  background: var(--neutral-200);
  transform-origin: left;
  animation: legal-draw 1.4s var(--ease-out) .45s both;
}
.legal-updated { font-size: 14px; line-height: 20px; color: var(--neutral-600); }

.legal-tabs { position: relative; display: flex; flex-wrap: wrap; gap: 8px; }
.legal-tabs a {
  display: inline-flex; align-items: center;
  min-height: 44px; padding: 10px 18px;
  border-radius: 32px;
  background: var(--neutral-100);
  font-size: 14px; line-height: 20px; font-weight: 500;
  white-space: nowrap;
  transition: background-color .2s, color .2s, translate .25s cubic-bezier(.22, 1, .36, 1);
}
.legal-tabs a:hover { background: var(--neutral-200); translate: 0 -2px; }
.legal-tabs a[aria-current] { background: var(--navy-950); color: var(--text-on-navy); }
.legal-tabs a[aria-current]:hover { translate: none; }

@media (max-width: 1199px) {
  .legal-title { font-size: 104px; line-height: 96px; }
}
@media (max-width: 991px) {
  .legal-hero { padding-top: calc(var(--header-h) + 72px); padding-bottom: 48px; }
  .legal-title { font-size: 76px; line-height: 72px; }
  .legal-meta { margin-top: 40px; }
}
@media (max-width: 767px) {
  .legal-hero { padding-top: calc(var(--header-h) + 48px); padding-bottom: 32px; }
  .eyebrow { font-size: 17px; line-height: 24px; margin-bottom: 12px; }
  .legal-title { font-size: 48px; line-height: 46px; }
  /* nowrap: a wrapping column sizes to its content, so the one-line tab row would widen the page */
  .legal-meta { flex-direction: column; flex-wrap: nowrap; align-items: stretch; margin-top: 32px; padding-top: 20px; }
  /* tabs become one swipeable row, edge to edge */
  .legal-tabs {
    flex-wrap: nowrap; overflow-x: auto;
    margin-inline: calc(-1 * var(--pad)); padding-inline: var(--pad);
    scrollbar-width: none;
  }
  .legal-tabs::-webkit-scrollbar { display: none; }
  .legal-tabs a { flex: none; }
}

/* =========================================================
   2. Body: sticky contents list + document
   ========================================================= */
.legal-body {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 0 96px;
  align-items: start;
  padding-top: 32px;
  padding-bottom: 160px;
}

/* Contents list: overline, orange progress line, active section */
.legal-toc {
  position: sticky; top: calc(var(--header-h) + 40px);
  animation: legal-fade .9s var(--ease-out) .7s both;
}
.legal-toc summary {
  display: block; list-style: none;
  margin-bottom: 20px;
  font-size: 11px; line-height: 16px; font-weight: 600;
  letter-spacing: .12em; text-transform: uppercase;
  color: var(--neutral-600);
  cursor: default;
}
.legal-toc summary::-webkit-details-marker { display: none; }
.legal-toc__track { position: relative; padding-left: 20px; }
.legal-toc__track::before,
.legal-toc__fill {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0;
  width: 2px; border-radius: 2px;
}
.legal-toc__track::before { background: var(--neutral-100); }
.legal-toc__fill { background: var(--orange-500); transform: scaleY(0); transform-origin: top; }
.legal-toc ol { margin: 0; padding: 0; list-style: none; }
.legal-toc a {
  display: flex; gap: 12px;
  padding: 8px 0;
  font-size: 15px; line-height: 20px;
  color: var(--neutral-600);
  transition: color .2s, translate .3s var(--ease-out);
}
.legal-toc a:hover { color: var(--navy-950); }
.legal-toc a[aria-current] { color: var(--navy-950); font-weight: 500; translate: 4px 0; }
.toc-num { flex: none; min-width: 20px; font-variant-numeric: tabular-nums; }
.legal-toc a[aria-current] .toc-num { color: var(--orange-text); }

/* Document */
.legal-doc { max-width: 820px; }
.legal-lead {
  margin-bottom: 48px;
  font-size: 24px; line-height: 32px; font-weight: 500;
  color: var(--navy-950);
}
.legal-section {
  position: relative;
  padding: 48px 0 56px;
  scroll-margin-top: calc(var(--header-h) + 24px);
}
.legal-section::before {
  content: ""; position: absolute; inset: 0 0 auto; height: 1px;
  background: var(--neutral-200);
  transform-origin: left;
}
.legal-section.is-in::before { transition: transform 1.4s var(--ease-out); }
.legal-section h2 {
  display: flex; align-items: baseline; gap: 16px;
  margin: 0 0 24px;
  font-size: 28px; line-height: 36px; font-weight: 500;
  color: var(--navy-950);
}
.legal-num {
  flex: none; min-width: 36px;
  font-size: 15px; line-height: 20px; font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--orange-text);
}
/* numbered documents: body text lines up with the heading text, not the number */
.legal-doc--numbered .legal-section > :not(h2) { margin-left: 52px; }
.legal-section > * + * { margin-top: 20px; }
.legal-section p { max-width: 68ch; }

.legal-doc a:not(.legal-next),
.legal-link-btn {
  color: var(--orange-text);
  text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px;
  transition: color .2s;
}
.legal-doc a:not(.legal-next):hover,
.legal-link-btn:hover { color: var(--navy-950); }
.legal-link-btn { display: inline; padding: 0; font: inherit; }

/* bracketed values the client still has to send */
.ph {
  padding: 0 4px; border-radius: 4px;
  background: var(--orange-50); color: var(--orange-text);
  font-weight: 500; white-space: nowrap;
}

/* ---------- Lists ---------- */
.legal-list li { position: relative; padding-left: 24px; max-width: 68ch; }
.legal-list li + li { margin-top: 12px; }
.legal-list li::before {
  content: ""; position: absolute; left: 4px; top: 9px;
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--orange-500);
}
.legal-list strong { font-weight: 600; color: var(--navy-950); }

/* rights: ticks in two columns */
.legal-checks { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 32px; }
.legal-checks li { position: relative; padding-left: 34px; }
.legal-checks li::before {
  content: ""; position: absolute; left: 0; top: 1px;
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--orange-50);
}
.legal-checks li::after {
  content: ""; position: absolute; left: 8px; top: 6px;
  width: 5px; height: 10px;
  border: solid var(--orange-text); border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

/* bold-led items as rows with 1px rules, like the reference's list rows */
.legal-rows li {
  display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 24px;
  padding: 20px 0;
  border-top: 1px solid var(--neutral-200);
}
.legal-rows li:last-child { border-bottom: 1px solid var(--neutral-200); }
.legal-rows strong { font-weight: 600; color: var(--navy-950); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
.legal-table { width: 100%; border-collapse: collapse; font-size: 15px; line-height: 22px; }
.legal-table th {
  padding: 0 24px 12px 0;
  border-bottom: 1px solid var(--navy-950);
  text-align: left; vertical-align: bottom;
  font-size: 11px; line-height: 16px; font-weight: 600;
  letter-spacing: .12em; text-transform: uppercase;
  color: var(--neutral-600);
}
.legal-table td {
  padding: 16px 24px 16px 0;
  border-bottom: 1px solid var(--neutral-200);
  vertical-align: top;
}
.legal-table td:first-child { font-weight: 500; color: var(--navy-950); }
.legal-table tbody tr { transition: background-color .2s; }
.legal-table tbody tr:hover { background: var(--neutral-50); }
.legal-table code { font: 500 14px/20px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }

/* ---------- Panels: address card, company facts, signature ---------- */
.legal-card {
  padding: 28px 32px;
  background: var(--neutral-50);
  border: 1px solid var(--neutral-100);
  border-radius: 16px;
  font-style: normal;
}
.legal-card strong { display: block; margin-bottom: 8px; font-size: 20px; line-height: 28px; font-weight: 500; color: var(--navy-950); }

.legal-facts {
  display: grid; grid-template-columns: minmax(180px, 2fr) 3fr;
  margin-bottom: 0;
  padding: 8px 32px;
  background: var(--neutral-50);
  border: 1px solid var(--neutral-100);
  border-radius: 16px;
}
.legal-facts dt, .legal-facts dd { margin: 0; padding: 16px 0; border-top: 1px solid var(--neutral-200); }
.legal-facts dt:first-of-type, .legal-facts dd:first-of-type { border-top: 0; }
.legal-facts dt { padding-right: 24px; font-size: 14px; line-height: 24px; color: var(--neutral-600); }
.legal-facts dd { font-weight: 500; color: var(--navy-950); }

.legal-sign {
  padding: 32px;
  border: 1px dashed var(--neutral-300);
  border-radius: 16px;
}
.legal-sign p + p { margin-top: 8px; }
.legal-sign__line {
  display: block; width: min(320px, 100%); height: 48px; margin-bottom: 12px;
  border-bottom: 1px solid var(--navy-950);
}
.legal-sign__date { display: flex; align-items: flex-end; gap: 8px; }
.legal-sign__date .legal-sign__line { width: 160px; height: 24px; margin: 0; }

/* ---------- Next page ---------- */
.legal-next {
  display: flex; align-items: center; justify-content: space-between; gap: 24px;
  margin-top: 24px; padding: 40px 0 0;
  border-top: 1px solid var(--navy-950);
  color: var(--navy-950);
}
.legal-next__label {
  display: block;
  font-size: 11px; line-height: 16px; font-weight: 600;
  letter-spacing: .12em; text-transform: uppercase;
  color: var(--neutral-600);
}
.legal-next__title { display: block; margin-top: 8px; font-size: 44px; line-height: 52px; font-weight: 400; letter-spacing: -.01em; }
.legal-next__arrow {
  flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  width: 56px; height: 56px; border-radius: 50%;
  background: var(--orange-500); color: var(--navy-950);
  transition: translate .3s var(--ease-out), background-color .2s;
}
.legal-next:hover .legal-next__arrow { translate: 6px 0; background: var(--orange-600); }
.legal-next__arrow svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* =========================================================
   3. Responsive
   ========================================================= */
@media (max-width: 991px) {
  .legal-body { grid-template-columns: minmax(0, 1fr); padding-bottom: 120px; }

  /* contents list folds into a card above the text */
  .legal-toc {
    position: static;
    margin-bottom: 32px; padding: 0 20px;
    border: 1px solid var(--neutral-200);
    border-radius: 16px;
  }
  .legal-toc summary {
    display: flex; align-items: center; justify-content: space-between;
    min-height: 56px; margin: 0;
    cursor: pointer;
  }
  .legal-toc summary::after {
    content: ""; width: 8px; height: 8px; margin: -4px 4px 0 0;
    border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor;
    transform: rotate(45deg); transition: transform .25s var(--ease-out);
  }
  .legal-toc[open] summary::after { transform: translateY(4px) rotate(-135deg); }
  .legal-toc__track { margin-bottom: 16px; }
  .legal-toc a { align-items: center; min-height: 44px; }
  .legal-toc a[aria-current] { translate: none; }

  .legal-next__title { font-size: 36px; line-height: 44px; }
}
@media (max-width: 767px) {
  .legal-body { padding-top: 16px; padding-bottom: 80px; }
  .legal-lead { margin-bottom: 32px; font-size: 20px; line-height: 28px; }
  .legal-section { padding: 36px 0 40px; }
  .legal-section h2 { gap: 12px; font-size: 22px; line-height: 30px; }
  .legal-num { min-width: 28px; }
  .legal-doc--numbered .legal-section > :not(h2) { margin-left: 0; }

  .legal-checks { grid-template-columns: 1fr; }
  .legal-rows li { grid-template-columns: 1fr; gap: 4px; padding: 16px 0; }

  /* tables stack: each row becomes a block, each cell carries its header */
  .legal-table.is-stackable thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .legal-table.is-stackable tr { display: block; padding: 16px 0; border-bottom: 1px solid var(--neutral-200); }
  .legal-table.is-stackable tbody tr:first-child { border-top: 1px solid var(--navy-950); }
  .legal-table.is-stackable td { display: block; padding: 4px 0; border: 0; }
  .legal-table.is-stackable td::before {
    content: attr(data-label);
    display: block; margin-bottom: 2px;
    font-size: 11px; line-height: 16px; font-weight: 600;
    letter-spacing: .12em; text-transform: uppercase;
    color: var(--neutral-600);
  }
  .legal-table.is-stackable td:first-child::before { display: none; }
  .legal-table.is-stackable td:first-child { font-size: 17px; line-height: 24px; }

  .legal-card, .legal-sign { padding: 24px 20px; }
  .legal-facts { grid-template-columns: 1fr; padding: 4px 20px; }
  .legal-facts dt { padding: 14px 0 0; }
  .legal-facts dd { padding: 2px 0 14px; border-top: 0; }

  .legal-next { padding-top: 32px; }
  .legal-next__title { font-size: 28px; line-height: 36px; }
}

/* =========================================================
   4. Motion
   ========================================================= */
@keyframes legal-rise { from { transform: translateY(105%); } }
@keyframes legal-fade { from { opacity: 0; transform: translateY(16px); } }
@keyframes legal-draw { from { transform: scaleX(0); } }

/* Pre-animation state (removed by JS if GSAP fails) */
.anim .legal-section:not(.is-in)::before { transform: scaleX(0); }
.anim .legal-lead,
.anim .legal-section > :not(.table-wrap, .legal-rows, .legal-checks),
.anim .legal-table tbody tr,
.anim .legal-rows > li,
.anim .legal-checks > li,
.anim .legal-next { opacity: 0; }

/* Motion off: everything visible, no transforms */
@media (prefers-reduced-motion: reduce) {
  .eyebrow, .legal-title .line > span, .legal-meta, .legal-meta::before, .legal-toc { animation: none; }
  *, *::before, *::after { transition-duration: .01ms !important; }
  .legal-tabs a:hover, .legal-next:hover .legal-next__arrow { translate: none; }
}

/* =========================================================
   5. Print: just the document
   ========================================================= */
@media print {
  .header, .footer, .skip-link, .legal-tabs, .legal-toc, .legal-next, .cookie { display: none !important; }
  .legal-hero { padding: 0 0 24px; }
  .legal-title { font-size: 48px; line-height: 48px; }
  .legal-body { display: block; padding: 0; }
  .legal-section { padding: 24px 0; break-inside: avoid-page; }
  .legal-doc--numbered .legal-section > :not(h2) { margin-left: 0; }
  .legal-section::before { transform: none !important; }
  .legal-lead, .legal-section > *, .legal-table tbody tr, .legal-rows > li, .legal-checks > li { opacity: 1 !important; transform: none !important; }
  .ph { background: none; }
}
