/* =============================================================================
   legal.css — shared redesign for the Terms / Privacy pages
   -----------------------------------------------------------------------------
   Loaded LAST (after the per-page bundle) on the three legal routes:
     /privacy            (Foreword — light, red accent)
     /wp-floormap/privacy + /wp-floormap/terms (WP FloorMap — dark, blue accent)

   Theming is driven by CSS variables on .legal-page, overridden under
   body.wpfm-page .legal-page. Everything is scoped to .legal-page so these
   rules win over (and supersede) the older .privacy-main / .legal-* rules in
   hero.css and wp-floormap.css by load order at equal specificity.

   The two-column layout pairs the content with a sticky, auto-generated
   table of contents (built by legal-toc.js) that scroll-spies the active
   section. On narrow screens the TOC collapses into an "On this page"
   disclosure pinned above the content.
   ========================================================================== */

.legal-page {
  /* Light / Foreword palette (default) */
  --lg-bg:          #ececec;
  --lg-surface:     rgba(255, 255, 255, 0.72);
  --lg-surface-2:   rgba(255, 255, 255, 0.9);
  --lg-ink:         #181818;
  --lg-body:        #3a3a3a;
  --lg-muted:       #6c6c6c;
  --lg-accent:      #ed0000;
  --lg-accent-ink:  #ed0000;
  --lg-accent-soft: rgba(237, 0, 0, 0.10);
  --lg-accent-line: rgba(237, 0, 0, 0.22);
  --lg-line:        rgba(0, 0, 0, 0.10);
  --lg-line-strong: rgba(0, 0, 0, 0.16);
  --lg-rail:        rgba(0, 0, 0, 0.12);
  --lg-toc-idle:    #707070;
  --lg-shadow:      0 1px 2px rgba(0,0,0,.04), 0 18px 48px -28px rgba(0,0,0,.28);
  --lg-sans: "Scala Sans", "Gill Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;

  --lg-header-offset: 104px;   /* clears the fixed site header on anchor jumps */

  position: relative;
  z-index: 1;
  background: var(--lg-bg);
  /* neutralise the old .main-cover gradient/negative-margin tricks */
  padding: 0 0 0 0 !important;
  margin: 0 !important;
}

body.wpfm-page .legal-page {
  /* Dark / WP FloorMap palette */
  --lg-bg:          #0a0a23;
  --lg-surface:     rgba(22, 23, 48, 0.55);
  --lg-surface-2:   rgba(22, 23, 48, 0.8);
  --lg-ink:         #ffffff;
  --lg-body:        #cfd2e6;
  --lg-muted:       #9aa0c4;
  --lg-accent:      #6b7bff;
  --lg-accent-ink:  #aab2ff;
  --lg-accent-soft: rgba(107, 123, 255, 0.14);
  --lg-accent-line: rgba(107, 123, 255, 0.34);
  --lg-line:        rgba(255, 255, 255, 0.10);
  --lg-line-strong: rgba(255, 255, 255, 0.16);
  --lg-rail:        rgba(255, 255, 255, 0.12);
  --lg-toc-idle:    #8c93bd;
  --lg-shadow:      0 1px 2px rgba(0,0,0,.3), 0 24px 60px -30px rgba(0,0,0,.7);
}

/* The old decorative parallax blocks + main-cover fade are dropped for a
   cleaner editorial look; hide them in case any remain in the markup. */
.legal-page .legal-deco { display: none !important; }

/* ---- Shell + reading rhythm ---------------------------------------------- */
.legal-page .legal-shell {
  max-width: 1180px;
  margin: 0 auto;
  padding: var(--lg-header-offset) clamp(18px, 5vw, 48px) 0;
  box-sizing: border-box;
}

/* ---- Hero ----------------------------------------------------------------- */
.legal-page .legal-hero {
  display: block;
  max-width: none;
  margin: 0 0 14px;
  padding: clamp(20px, 4vw, 40px) 0 clamp(24px, 4vw, 38px);
  border-bottom: 1px solid var(--lg-line);
}
.legal-page .legal-hero .legal-subtitle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  width: auto;
  margin: 0 0 14px;
  padding: 5px 12px;
  border: 1px solid var(--lg-accent-line);
  border-radius: 999px;
  background: var(--lg-accent-soft);
  color: var(--lg-accent-ink);
  font-family: var(--lg-sans);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.legal-page .legal-hero .legal-subtitle a { color: inherit; text-decoration: none; }
.legal-page .legal-hero .legal-subtitle a:hover { text-decoration: underline; text-underline-offset: 3px; }

.legal-page .legal-hero h1 {
  margin: 0;
  color: var(--lg-ink);
  font-size: clamp(2.1rem, 1.4rem + 2.6vw, 3.4rem);
  font-weight: 800;
  line-height: 1.06;
  letter-spacing: -0.02em;
  text-align: left;
  hyphens: none;
}
body.wpfm-page .legal-page .legal-hero h1 { font-weight: 600; letter-spacing: -0.01em; }

.legal-page .legal-hero .legal-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 12px;
  margin-top: 22px;
}
.legal-page .legal-hero .legal-meta .meta-item {
  background: var(--lg-surface);
  border: 1px solid var(--lg-line);
  border-radius: 12px;
  padding: 10px 16px;
  font-family: var(--lg-sans);
  font-size: 0.9rem;
  color: var(--lg-body);
  line-height: 1.35;
}
.legal-page .legal-hero .legal-meta .meta-item strong {
  display: block;
  margin-bottom: 3px;
  color: var(--lg-muted);
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.legal-page .legal-hero .legal-meta .meta-item a {
  color: var(--lg-accent-ink);
  /* override the site-wide `a { text-decoration: underline dotted #ed0000 }`
     so the underline matches the page accent (periwinkle on WPFM, not red) */
  text-decoration: underline;
  text-decoration-style: solid;
  text-decoration-color: var(--lg-accent-line);
  text-underline-offset: 2px;
}
.legal-page .legal-hero .legal-meta .meta-item a:hover { text-decoration-color: var(--lg-accent); }

/* ---- Two-column layout ---------------------------------------------------- */
.legal-page .legal-layout {
  display: grid;
  grid-template-columns: minmax(0, 248px) minmax(0, 1fr);
  gap: clamp(28px, 4vw, 64px);
  align-items: start;
  padding-bottom: 80px;
}

/* ---- Table of contents ---------------------------------------------------- */
.legal-page .legal-toc {
  position: sticky;
  top: var(--lg-header-offset);
  align-self: start;
  max-height: calc(100vh - var(--lg-header-offset) - 28px);
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.legal-page .legal-toc__toggle {
  display: none; /* desktop: the TOC is always open */
  width: 100%;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0;
  padding: 13px 16px;
  border: 1px solid var(--lg-line-strong);
  border-radius: 12px;
  background: var(--lg-surface-2);
  color: var(--lg-ink);
  font-family: var(--lg-sans);
  font-size: 0.86rem;
  font-weight: 600;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  text-align: left;
}
.legal-page .legal-toc__toggle .legal-toc__toggle-label { display: flex; flex-direction: column; min-width: 0; }
.legal-page .legal-toc__toggle .legal-toc__eyebrow {
  font-size: 0.62rem; font-weight: 700; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--lg-muted);
}
.legal-page .legal-toc__toggle .legal-toc__current {
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--lg-ink);
}
.legal-page .legal-toc__toggle .legal-toc__chevron {
  flex: none; width: 16px; height: 16px; transition: transform .25s ease; color: var(--lg-muted);
}
.legal-page .legal-toc__toggle[aria-expanded="true"] .legal-toc__chevron { transform: rotate(180deg); }

.legal-page .legal-toc__heading {
  margin: 0 0 14px;
  padding: 0 0 0 14px;
  font-family: var(--lg-sans);
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--lg-muted);
}

/* the scrolling rail */
.legal-page .legal-toc__nav {
  position: relative;
  flex: 1 1 auto;
  overflow-y: auto;
  overflow-x: hidden;
  min-height: 0;
  padding: 2px 4px 2px 0;
  scrollbar-width: thin;
  scrollbar-color: var(--lg-rail) transparent;
}
.legal-page .legal-toc__nav::-webkit-scrollbar { width: 6px; }
.legal-page .legal-toc__nav::-webkit-scrollbar-thumb { background: var(--lg-rail); border-radius: 6px; }

.legal-page .legal-toc__list { list-style: none; margin: 0; padding: 0; position: relative; }
/* the faint vertical guide rail; the accent "fill" element (.legal-toc__fill)
   is injected by legal-toc.js and grows to the active item */
.legal-page .legal-toc__list::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 2px;
  border-radius: 2px;
  background: var(--lg-rail);
}

.legal-page .legal-toc__item { margin: 0; }
.legal-page .legal-toc__link {
  display: block;
  position: relative;
  padding: 5px 6px 5px 16px;
  border: 0;
  background: none;
  color: var(--lg-toc-idle);
  font-family: var(--lg-sans);
  font-size: 0.82rem;
  line-height: 1.32;
  text-decoration: none;
  border-radius: 6px;
  transition: color .18s ease, background-color .18s ease;
  cursor: pointer;
}
.legal-page .legal-toc__link .legal-toc__num {
  color: var(--lg-muted);
  font-variant-numeric: tabular-nums;
  margin-right: 7px;
  font-size: 0.78em;
  opacity: .85;
}
.legal-page .legal-toc__link:hover { color: var(--lg-ink); background: var(--lg-accent-soft); }
.legal-page .legal-toc__link:focus-visible,
.legal-page .legal-toc__toggle:focus-visible {
  outline: 2px solid var(--lg-accent);
  outline-offset: 2px;
  border-radius: 6px;
}
.legal-page .legal-toc__link.is-active { color: var(--lg-accent-ink); font-weight: 700; }
.legal-page .legal-toc__link.is-active .legal-toc__num { color: var(--lg-accent-ink); opacity: 1; }

/* nested sub-headings (h3/h4) */
.legal-page .legal-toc__link--sub { padding-left: 30px; font-size: 0.78rem; color: var(--lg-muted); }
.legal-page .legal-toc__link--sub.is-active { color: var(--lg-accent-ink); }

/* "Part A / Part B / General" group dividers */
.legal-page .legal-toc__group {
  margin: 16px 0 5px;
  padding: 0 6px 0 16px;
  font-family: var(--lg-sans);
  font-size: 0.64rem;
  font-weight: 700;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--lg-muted);
}
.legal-page .legal-toc__group:first-child { margin-top: 0; }

/* ---- Content body --------------------------------------------------------- */
.legal-page .legal-body {
  max-width: 760px;
  margin: 0;
  padding: 0;
  min-width: 0;
}
.legal-page .legal-section {
  background: none;
  border: 0;
  border-radius: 0;
  backdrop-filter: none;
  padding: 30px 0;
  margin: 0;
  border-top: 1px solid var(--lg-line);
  scroll-margin-top: var(--lg-header-offset);
}
.legal-page .legal-body > .legal-section:first-child { border-top: 0; padding-top: 4px; }

.legal-page .legal-section h2 {
  margin: 0 0 14px;
  padding: 0;
  border: 0;
  color: var(--lg-ink);
  font-size: 1.42rem;
  font-weight: 700;
  line-height: 1.22;
  letter-spacing: -0.01em;
  text-transform: none;
  hyphens: none;
}
body.wpfm-page .legal-page .legal-section h2 { font-weight: 600; }

.legal-page .legal-section h3 {
  margin: 26px 0 8px;
  color: var(--lg-ink);
  font-size: 1.05rem;
  font-weight: 700;
  text-transform: none;
  letter-spacing: 0;
  scroll-margin-top: var(--lg-header-offset);
}
body.wpfm-page .legal-page .legal-section h3 { font-weight: 600; }

.legal-page .legal-section p,
.legal-page .legal-section li {
  font-size: 1.02rem;
  line-height: 1.72;
  color: var(--lg-body);
}
.legal-page .legal-section p { margin: 0 0 1rem; }
.legal-page .legal-section p:last-child { margin-bottom: 0; }
.legal-page .legal-section strong { color: var(--lg-ink); font-weight: 700; }
.legal-page .legal-section ul,
.legal-page .legal-section ol { margin: 0 0 1rem; padding-left: 1.35rem; }
.legal-page .legal-section li { margin-bottom: 0.5rem; padding-left: 0.2rem; }
.legal-page .legal-section li::marker { color: var(--lg-accent); }
.legal-page .legal-section a {
  color: var(--lg-accent-ink);
  text-decoration: underline;
  text-decoration-color: var(--lg-accent-line);
  text-underline-offset: 2px;
  transition: text-decoration-color .2s ease;
}
.legal-page .legal-section a:hover { text-decoration-color: var(--lg-accent); }
.legal-page .legal-section code {
  background: var(--lg-accent-soft);
  border: 1px solid var(--lg-line);
  padding: 1px 6px;
  border-radius: 5px;
  font-size: 0.85em;
  color: var(--lg-ink);
}

/* intro lead with drop cap */
.legal-page .legal-section.intro {
  border-top: 0;
  padding-top: 4px;
  padding-bottom: 34px;
}
.legal-page .legal-section.intro p { font-size: 1.08rem; line-height: 1.66; color: var(--lg-body); }
.legal-page .legal-section.intro p:first-child { margin-top: 0; }
.legal-page .legal-section.intro p:first-child::first-letter {
  float: left;
  margin: 0.06em 0.12em 0 0;
  font-family: "Yinit", "AGaramond", "Garamond", serif;
  font-weight: normal;
  font-size: 3.8em;
  line-height: 0.78;
  color: var(--lg-accent);
}

/* "Part A / Part B / General" big in-body dividers */
.legal-page .legal-section.legal-part {
  border-top: 1px solid var(--lg-line-strong);
  margin-top: 18px;
  padding: 34px 0 8px;
}
.legal-page .legal-section.legal-part::before {
  content: "";
  display: block;
  width: 40px;
  height: 3px;
  margin-bottom: 16px;
  border-radius: 3px;
  background: var(--lg-accent);
}
.legal-page .legal-section.legal-part h2 {
  font-size: 1.62rem;
  letter-spacing: -0.015em;
}
.legal-page .legal-section.legal-part p { color: var(--lg-muted); }
.legal-page .legal-body > .legal-section.legal-part:first-child { margin-top: 0; }

/* ---- Footer --------------------------------------------------------------- */
.legal-page .legal-footer {
  max-width: 1180px;
  margin: 0 auto;
  padding: 32px clamp(18px, 5vw, 48px) 72px;
  border-top: 1px solid var(--lg-line);
  text-align: center;
}
.legal-page .legal-footer .footer-links {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 18px;
}
.legal-page .legal-footer .footer-links a {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 18px;
  border: 1px solid var(--lg-accent-line);
  border-radius: 999px;
  background: var(--lg-surface);
  color: var(--lg-ink);
  font-family: var(--lg-sans);
  font-size: 0.85rem;
  font-weight: 600;
  text-decoration: none;
  transition: background-color .2s ease, border-color .2s ease;
}
.legal-page .legal-footer .footer-links a:hover { background: var(--lg-accent-soft); border-color: var(--lg-accent); }
.legal-page .legal-footer p { margin: 0; font-family: var(--lg-sans); font-size: 0.8rem; color: var(--lg-muted); }

/* ---- Responsive ----------------------------------------------------------- */
@media (max-width: 1024px) {
  .legal-page .legal-layout {
    grid-template-columns: 1fr;
    gap: 0;
  }
  .legal-page .legal-toc {
    position: sticky;
    top: 76px;
    max-height: none;
    z-index: 5;
    margin: 0 0 8px;
    padding: 8px 0;
    background: var(--lg-bg);
  }
  .legal-page .legal-toc__toggle { display: flex; }
  .legal-page .legal-toc__heading { display: none; }
  .legal-page .legal-toc__nav {
    max-height: 0;
    opacity: 0;
    margin-top: 0;
    padding: 0 12px;
    border: 1px solid transparent;
    border-radius: 12px;
    background: var(--lg-surface-2);
    transition: max-height .28s ease, opacity .2s ease, margin .28s ease, padding .28s ease;
  }
  .legal-page .legal-toc.is-open .legal-toc__nav {
    max-height: min(62vh, 460px);
    opacity: 1;
    margin-top: 8px;
    padding: 10px 12px;
    border-color: var(--lg-line);
    box-shadow: var(--lg-shadow);
  }
  .legal-page .legal-body { max-width: none; }
}

@media (max-width: 560px) {
  .legal-page .legal-hero .legal-meta { gap: 8px; }
  .legal-page .legal-hero .legal-meta .meta-item { width: 100%; box-sizing: border-box; }
  .legal-page .legal-section h2 { font-size: 1.26rem; }
  .legal-page .legal-section.legal-part h2 { font-size: 1.4rem; }
  .legal-page .legal-section p,
  .legal-page .legal-section li { font-size: 0.98rem; }
}

/* ---- Motion / print ------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  .legal-page .legal-toc__link,
  .legal-page .legal-toc__fill,
  .legal-page .legal-toc__chevron,
  .legal-page .legal-toc__nav { transition: none; }
  html { scroll-behavior: auto; }
}
@media print {
  .legal-page .legal-toc, .legal-page .legal-toc__toggle { display: none !important; }
  .legal-page .legal-layout { grid-template-columns: 1fr; }
  .legal-page .legal-section { break-inside: avoid; }
}
