/*
 * Family Mic website: extras for the legal pages (terms, privacy, cookies), on top of section 15 of site.css.
 *
 * Page shape:
 *   <main class="legal-page">
 *     <header class="legal-hero"> eyebrow, h1, .lead, .legal-meta, .legal-draft, .legal-tabs </header>
 *     <div class="container legal legal--with-summary">
 *       <section class="legal-summary">  the plain-language "In short" box  </section>
 *       <nav class="legal-toc">          the numbered table of contents     </nav>
 *       <article class="legal-body">     numbered sections                  </article>
 *     </div>
 *   </main>
 * On small screens they stack in that order (summary, contents, full text). From 1000px the contents
 * sit in a sticky column on the inline-start side, next to the summary and the text.
 */

/* The hero ------------------------------------------------------------------------------------- */
.legal-hero .lead { max-width: 640px; margin: 0 auto 16px; }
.legal-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px 18px;
}
.legal-meta .icon { color: var(--coral-pressed); margin-inline-end: 6px; }
.legal-print {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 6px 14px;
  border: 0;
  border-radius: var(--radius-pill);
  background: var(--white);
  box-shadow: var(--shadow-card);
  color: var(--ink-2);
  font: inherit;
  font-size: var(--fs-small);
  font-weight: 500;
  cursor: pointer;
}
.legal-print:hover { color: var(--coral-ink); }
.legal-print .icon { margin: 0; }

/* "Draft: to be reviewed by a lawyer" (FM_CONFIG.legalDraft). */
.legal-draft {
  max-width: 640px;
  margin: 20px auto 0;
  text-align: start;
  border: 2px dashed var(--coral-tint-strong);
}
.legal-draft strong { color: var(--coral-ink); }

/* Terms · Privacy · Cookies, as pills. */
.legal-tabs { margin-block-start: 24px; }
.legal-tabs ul {
  display: inline-flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  margin: 0;
  padding: 6px;
  list-style: none;
  border-radius: var(--radius-pill);
  background: var(--white);
  box-shadow: var(--shadow-card);
}
.legal-tabs a {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 8px 16px;
  border-radius: var(--radius-pill);
  color: var(--ink-2);
  font-size: var(--fs-small);
  font-weight: 500;
  text-decoration: none;
}
.legal-tabs a:hover { background: var(--peach); color: var(--coral-ink); }
.legal-tabs a[aria-current="page"] { background: var(--coral-tint); color: var(--coral-ink); font-weight: 600; }
.legal-tabs .icon { width: 1.1em; height: 1.1em; }
@media (max-width: 479px) {
  .legal-tabs ul { border-radius: var(--radius-card); }
  .legal-tabs a { padding-inline: 12px; }
}

/* Layout: summary, contents and text ------------------------------------------------------------ */
/* minmax(0, 1fr): a wide table scrolls inside its own box instead of widening the page. */
.legal--with-summary { align-items: start; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 1000px) {
  .legal--with-summary { grid-template-columns: 260px minmax(0, 1fr); grid-template-rows: auto 1fr; row-gap: 32px; }
  .legal--with-summary .legal-summary { grid-column: 2; grid-row: 1; }
  .legal--with-summary .legal-toc { grid-column: 1; grid-row: 1 / span 2; }
  .legal--with-summary .legal-body { grid-column: 2; grid-row: 2; }
}

/* The plain-language summary ------------------------------------------------------------------- */
.legal-summary {
  max-width: 760px;
  padding: clamp(22px, 3.4vw, 36px);
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, var(--sun-tint) 0%, #FFF0CF 55%, var(--coral-tint) 140%);
}
.legal-summary__head { display: flex; align-items: center; gap: 14px; margin-block-end: 18px; }
.legal-summary__head .icon-circle { background: var(--white); }
.legal-summary h2 { font-size: clamp(1.375rem, 1.2rem + 0.7vw, 1.75rem); letter-spacing: -0.01em; }
.legal-summary .check-list { gap: 14px; }
.legal-summary .check-list li { color: var(--ink); }
.legal-summary .check-list li::before { background-color: var(--white); }
.legal-summary__foot { margin: 18px 0 0; font-size: var(--fs-small); color: var(--ink-2); }

/* The full text -------------------------------------------------------------------------------- */
.legal-body > section + section { padding-block-start: 40px; border-top: 1px solid var(--hairline); }
.legal-body h2 { display: flex; gap: 0.45em; align-items: baseline; }
.legal-num { color: var(--coral-text); font-variant-numeric: tabular-nums; flex-shrink: 0; }
.legal-body h3 .legal-num { margin-inline-end: 0.35em; color: var(--link); } /* 19px text: the deeper coral keeps 4.5:1 */
.legal-body h3 { display: block; }
.legal-body .lead-in { font-weight: 600; color: var(--ink); }
.legal-body .table-wrap { background: var(--white); }
.legal-body .table td, .legal-body .table th { line-height: 1.5; }
.legal-body .table td:first-child { font-weight: 600; color: var(--ink); }
.legal-body .table code, .legal-body code {
  font-size: 0.92em;
  padding: 1px 6px;
  border-radius: 6px;
  background: var(--peach);
  border: 1px solid var(--hairline);
  white-space: nowrap;
}
.legal-body .callout { margin-block: 20px 24px; }
.legal-body dl.terms-list { margin: 0 0 1em; display: grid; gap: 10px; }
.legal-body dl.terms-list dt { font-weight: 600; color: var(--ink); }
.legal-body dl.terms-list dd { margin: 0; color: var(--ink-2); }
.legal-body .contact-card { margin-block-start: 8px; padding: 22px; border-radius: var(--radius-card); background: var(--peach); }
.legal-body .contact-card dl { min-width: 0; }
/* Email addresses carry a <wbr> after the @, so they wrap there rather than inside the domain. */
.legal-body .contact-card dd { color: var(--ink-2); overflow-wrap: break-word; }
@media (max-width: 479px) { .legal-body .contact-card { flex-direction: column; gap: 12px; } }
.legal-back { margin-block-start: 40px; padding-block-start: 24px; border-top: 1px solid var(--hairline); font-size: var(--fs-small); }
.legal-back a { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; }
.legal-back .icon { transform: rotate(-90deg); }

/* Tables: on phones each row becomes a small card, every value labelled with its column (data-label).
   The pages give their tables explicit roles (role="table", "row", "cell"…), so screen readers that
   drop table semantics when the display changes (Safari) still read them as tables. */
@media (max-width: 639px) {
  .legal-body .table-wrap { border: 0; background: none; overflow: visible; }
  .legal-body .table, .legal-body .table tbody, .legal-body .table tr, .legal-body .table td { display: block; width: 100%; }
  .legal-body .table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .legal-body .table tr { margin-block-end: 12px; padding: 14px 16px; border: 1px solid var(--hairline); border-radius: var(--radius-md); background: var(--white); }
  .legal-body .table td { padding: 4px 0; border: 0; }
  .legal-body .table td:first-child { font-size: 1.0625rem; padding-block-end: 6px; }
  .legal-body .table td[data-label]:not(:first-child)::before {
    content: attr(data-label);
    display: block;
    font-size: var(--fs-tiny);
    font-weight: 600;
    color: var(--ink-soft);
  }
}

/* The table of contents: a few more touches on the site.css base. */
.legal-toc a { min-height: 44px; align-items: center; }
@media (max-width: 999px) {
  .legal-toc { max-width: 760px; }
  .legal-toc ol { grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr)); column-gap: 8px; }
}

/* Print: the text alone, with the draft note and the summary kept. */
@media print {
  .legal-print, .legal-tabs, .legal-back { display: none !important; }
  .legal--with-summary { display: block; }
  .legal-summary, .legal-body { max-width: none; margin-block-end: 24px; }
  .legal-summary { background: none; border: 1px solid #ccc; }
  .legal-body > section { break-inside: auto; }
  .legal-body h2, .legal-body h3 { break-after: avoid; }
}
