/* ==========================================================================
   Component — Legal document
   --------------------------------------------------------------------------
   Calm, text-first layout for long legal pages (Privacy Policy, Terms):
   a numbered contents list beside the document body, readable line length
   and a clear rhythm between numbered sections.

   <div class="container legal">
     <nav class="legal__toc" aria-labelledby="toc-title">
       <p class="type-eyebrow" id="toc-title">Contents</p>
       <ol class="legal__toc-list" role="list">
         <li><a class="legal__toc-link" href="#introduction"><span class="legal__number">1</span> <span>Introduction</span></a></li>
       </ol>
     </nav>
     <div class="legal__body">
       <section class="legal__section" id="introduction" aria-labelledby="introduction-title">
         <h2 class="legal__heading" id="introduction-title"><span class="legal__number">1</span> <span>Introduction</span></h2>
         <p>…</p>
         <ul class="legal__list"><li>…</li></ul>
       </section>
     </div>
   </div>

   Contents sit above the body on small screens and in a sticky column at
   the inline start from lg (mirrors in RTL). Section numbers are plain
   text without punctuation, so they read the same in LTR and RTL.

   .legal-pending marks an item that must be confirmed before publication
   (ARCHITECTURE.md, Legal). The bracketed text carries the meaning; the
   demo colours only reinforce it. It wraps, so long notes never overflow.
   WordPress: page-legal.php (page content) + template-parts/legal-toc.php
   ========================================================================== */

.legal {
  display: grid;
  gap: var(--space-8);
}

@media (min-width: 64em) {
  .legal {
    grid-template-columns: minmax(0, 17rem) minmax(0, var(--measure));
    justify-content: start;
    gap: var(--space-9);
  }
}

/* --------------------------------------------------------------------------
   Contents
   -------------------------------------------------------------------------- */
.legal__toc {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  padding-block-start: var(--space-5);
  border-block-start: var(--border-width-strong) solid var(--color-text-primary);
}

@media (min-width: 64em) {
  /* Long lists scroll inside the column rather than being cut off */
  .legal__toc {
    position: sticky;
    inset-block-start: calc(var(--header-height) + var(--space-6));
    align-self: start;
    max-block-size: calc(100dvh - var(--header-height) - var(--space-8));
    overflow-y: auto;
    overscroll-behavior: contain;
    padding-inline-end: var(--space-2);
  }
}

.legal__toc-list {
  display: flex;
  flex-direction: column;
}

.legal__toc-list li {
  border-block-end: var(--border-width) solid var(--color-border);
}

.legal__toc-list li:last-child {
  border-block-end: 0;
}

.legal__toc-link {
  display: grid;
  grid-template-columns: 2.25em minmax(0, 1fr);
  align-items: baseline;
  min-block-size: var(--tap-target-min);
  padding-block: var(--space-2);
  color: var(--color-text-primary);
  font-size: var(--type-body-small-size);
  line-height: var(--leading-snug);
  text-decoration-color: transparent;
}

.legal__toc-link:hover,
.legal__toc-link:focus-visible {
  color: var(--color-link-hover);
  text-decoration-color: currentColor;
}

/* --------------------------------------------------------------------------
   Body
   -------------------------------------------------------------------------- */
.legal__body {
  display: flex;
  flex-direction: column;
  gap: var(--space-8);
  min-inline-size: 0;
}

.legal__section {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  padding-block-start: var(--space-7);
  border-block-start: var(--border-width) solid var(--color-border);
}

.legal__section:first-child {
  padding-block-start: 0;
  border-block-start: 0;
}

.legal__heading {
  display: grid;
  grid-template-columns: 2.25em minmax(0, 1fr);
  align-items: baseline;
  font-family: var(--type-h3-family);
  font-size: var(--type-h3-size);
  font-weight: var(--type-h3-weight);
  line-height: var(--type-h3-leading);
  letter-spacing: var(--type-h3-tracking);
}

.legal__subheading {
  margin-block-start: var(--space-3);
  font-family: var(--type-h4-family);
  font-size: var(--type-body-large-size);
  font-weight: var(--font-weight-semibold);
  line-height: var(--type-h4-leading);
  letter-spacing: 0;
}

.legal__number {
  color: var(--color-text-muted);
  font-variant-numeric: tabular-nums;
}

.legal__list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding-inline-start: var(--space-5);
}

.legal__list li::marker {
  color: var(--color-text-muted);
}

/* Key facts (operator details, document details) as label + value pairs */
.legal__facts {
  display: grid;
  border-block-start: var(--border-width) solid var(--color-border);
}

.legal__fact {
  display: grid;
  gap: var(--space-1);
  padding-block: var(--space-3);
  border-block-end: var(--border-width) solid var(--color-border);
}

@media (min-width: 48em) {
  .legal__fact {
    grid-template-columns: minmax(0, 14rem) minmax(0, 1fr);
    gap: var(--space-5);
  }
}

.legal__fact dt {
  color: var(--color-text-secondary);
  font-size: var(--type-body-small-size);
  font-weight: var(--font-weight-semibold);
}

/* Document details shown under the hero lead */
.legal-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2) var(--space-4);
  color: var(--color-text-secondary);
  font-size: var(--type-body-small-size);
}

/* --------------------------------------------------------------------------
   Pending item (internal review marker, removed before publication)
   -------------------------------------------------------------------------- */
.legal-pending {
  padding-inline: var(--space-1);
  border-radius: var(--radius-sm);
  background-color: var(--color-demo-bg);
  color: var(--color-demo-text);
  font-size: 0.875em;
  font-weight: var(--font-weight-semibold);
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
}

@media (forced-colors: active) {
  .legal-pending {
    outline: var(--border-width) dashed CanvasText;
  }
}
