/* Legal pages (terms.html, privacy-policy.html, advertising.html): the title with "Last updated", numbered
   sections in a readable column, and an "On this page" list, left and sticky on desktop, above the text on mobile.
   Text stays left-aligned: justified text opens uneven gaps between words. */

.lg-page {
  padding-bottom: 56px;
}

.lg {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 20px;
  margin-top: 8px;
}

.lg-head {
  max-width: 68ch;
}

.lg-title {
  margin: 4px 0 6px;
  color: var(--text);
  font-size: clamp(1.75rem, 1.2rem + 2vw, 2.5rem);
  line-height: 1.15;
}

.lg-updated {
  margin: 0 0 12px;
  color: var(--text-muted);
  font-size: .9375rem;
}

.lg-lead {
  margin: 0;
  color: var(--text);
  font-size: 1.0625rem;
  line-height: 1.7;
}

/* "On this page": on mobile a folded box above the text (tap to open); on desktop a quiet list on a thin rail
   beside it, the section being read marked (js/pages/legal.js) */
.lg-toc__menu {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.lg-toc__title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  color: var(--text-muted);
  font-size: .8125rem;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  list-style: none;
  cursor: pointer;
}

.lg-toc__title::-webkit-details-marker {
  display: none;
}

.lg-toc__title::after {
  content: "";
  width: 7px;
  height: 7px;
  margin: -3px 4px 0 0;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg);
  transition: transform .2s ease;
}

.lg-toc__menu[open] .lg-toc__title::after {
  margin-top: 3px;
  transform: rotate(-135deg);
}

.lg-toc ol {
  margin: 0;
  padding: 0 16px 10px;
  list-style: none;
}

.lg-toc__menu a {
  display: block;
  padding: 7px 0;
  color: var(--link);
  font-size: .9375rem;
  line-height: 1.35;
  text-decoration: none;
}

.lg-toc__menu a:hover {
  text-decoration: underline;
}

.lg-toc__help {
  display: none;
}

.lg-text {
  max-width: 68ch;
}

.lg-section {
  scroll-margin-top: 90px;
}

.lg-section + .lg-section {
  margin-top: 28px;
}

.lg-section h2 {
  margin: 0 0 8px;
  color: var(--text);
  font-family: var(--font-heading);
  font-size: 1.375rem;
}

.lg-intro {
  margin-bottom: 28px;
}

.lg-intro p,
.lg-section p,
.lg-section li {
  margin: 0 0 12px;
  color: var(--text);
  font-size: 1.0625rem;
  line-height: 1.75;
}

.lg-section ul {
  margin: 0 0 12px;
  padding-left: 1.25em;
}

.lg-section li {
  margin-bottom: 6px;
}

/* Numbered clauses (advertising.html): the number in its own column, so wrapped lines start under the text */
.lg-section .lg-clause {
  display: grid;
  grid-template-columns: 3em minmax(0, 1fr);
}

.lg-clause__no {
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.lg-section .lg-clause__list {
  padding-left: calc(3em + 1.25em);
}

/* Key words stand out by weight alone, in the text colour: colour inside running text reads as a link or a warning
   and makes the sentence harder to read */
.lg-section b {
  color: var(--text);
  font-weight: 700;
}

/* The two placement options (advertising.html 1.1), side by side from 480px */
.lg-options {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
  margin: 4px 0 16px 3em;
  padding: 0;
  list-style: none;
}

.lg-section .lg-option {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 0;
  padding: 16px 18px;
}

.lg-option__name {
  color: var(--text-muted);
  font-size: .9375rem;
}

.lg-section .lg-option__price {
  color: var(--text);
  font-family: var(--font-heading);
  font-size: 1.75rem;
  line-height: 1.2;
}

.lg-option__split {
  color: var(--text-muted);
  font-size: .875rem;
}

@media (min-width: 480px) {
  .lg-options {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.lg-text a {
  color: var(--link);
}

.lg-more {
  margin-top: 32px;
  padding: 16px 18px;
}

.lg-more p {
  margin: 0;
  color: var(--text);
  line-height: 1.6;
}

@media (min-width: 1024px) {
  .lg {
    grid-template-columns: 260px minmax(0, 68ch);
    column-gap: 48px;
    align-items: start;
  }

  .lg-head {
    grid-column: 2;
  }

  .lg-text {
    grid-column: 2;
    grid-row: 2;
  }

  /* A long list scrolls inside itself rather than running past the screen */
  .lg-toc {
    position: sticky;
    top: 96px;
    grid-column: 1;
    grid-row: 1 / span 2;
    max-height: calc(100vh - 120px);
    overflow-y: auto;
  }

  .lg-toc__menu {
    border: 0;
    background: none;
  }

  .lg-toc__title {
    padding: 4px 0 10px;
    cursor: default;
    pointer-events: none;
  }

  .lg-toc__title::after {
    display: none;
  }

  .lg-toc ol {
    padding: 0;
    border-left: 2px solid var(--border);
  }

  .lg-toc__menu a {
    margin-left: -2px;
    padding: 5px 0 5px 14px;
    border-left: 2px solid transparent;
    color: var(--text-muted);
    font-size: .875rem;
  }

  .lg-toc__menu a:hover {
    color: var(--text);
    text-decoration: none;
  }

  .lg-toc__menu a[aria-current="true"] {
    border-left-color: var(--accent);
    color: var(--text);
    font-weight: 600;
  }

  .lg-toc__help {
    display: block;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
  }

  .lg-toc__help p {
    margin: 0 0 10px;
    color: var(--text-muted);
    font-size: .875rem;
  }
}

/* A clause's rich text from aci-admin: its own paragraphs and lists, and the price cards inside the clause */
.lg-clause__body > :first-child {
  margin-top: 0;
}

.lg-clause__body p {
  margin: 0 0 8px;
}

.lg-clause__body ul,
.lg-clause__body ol {
  margin: 0 0 8px;
  padding-left: 1.25em;
}

.lg-clause__body .lg-options {
  margin-left: 0;
  padding-left: 0;
}

.lg-section strong {
  color: var(--text);
  font-weight: 700;
}
