/* ==========================================================================
   LEGAL PAGES — Privacy Policy, Terms of Service, Disclaimer
   Two columns: sticky left column (date, title, navigator) and the document
   on the right. On tablet/mobile it stacks and the navigator becomes pills.
   Content is generated from _source/build/legal/*.md (legal_page.py).
   ========================================================================== */

.legal-page {
  --legal-rule: var(--gray-300);
  --legal-arrow: var(--gold-500);
  padding: calc(var(--header-offset) + 40px) 0 var(--space-section);
  background: var(--color-bg);
}

.legal-page__grid {
  display: grid;
  grid-template-columns: repeat(var(--grid-columns), minmax(0, 1fr));
  column-gap: var(--grid-gap);
  align-items: start;
}

.legal-aside   { grid-column: 1 / 6; }
.legal-content { grid-column: 7 / -1; }

/* Guide lines: skip the 2nd one so it doesn't cut through the left column.
   Same positions as .grid-lines (one every 2 columns), drawn one by one. */
@media (min-width: 992px) {
  .legal-page::before {
    --line: linear-gradient(var(--grid-line-color), var(--grid-line-color));
    --step: calc((100% + var(--grid-gap)) / 6);
    background-image: var(--line), var(--line), var(--line), var(--line), var(--line), var(--line);
    background-size: 1px 100%;
    background-repeat: no-repeat;
    background-position:
      0 0,
      calc(var(--step) * 2) 0,
      calc(var(--step) * 3) 0,
      calc(var(--step) * 4) 0,
      calc(var(--step) * 5) 0,
      100% 0;
  }
}

/* Pixel chevron (shared by the navigator and the pager) */
.pixel-arrow {
  width: 9px;
  height: 15px;
  flex-shrink: 0;
  fill: var(--legal-arrow);
}

/* --------------------------------------------------------------------------
   Left column
   -------------------------------------------------------------------------- */
.legal-aside {
  position: sticky;
  top: calc(var(--header-offset) - 20px);
}

.legal-aside__inner {
  max-width: 540px;
}

/* Short screens: the column would not fit while sticky, so it scrolls */
@media (max-height: 800px) {
  .legal-aside {
    position: static;
  }
}

.legal-aside__updated {
  padding-bottom: var(--space-s);
  border-bottom: 1px solid var(--legal-rule);
  color: var(--color-text-strong);
  font-size: var(--text-14);
}

.legal-aside__updated time {
  color: var(--color-text);
  font-weight: var(--weight-semibold);
}

.legal-aside__title {
  margin-top: var(--space-m);
  font-size: var(--text-4xl);
  line-height: var(--leading-tight);
  letter-spacing: var(--tracking-tight);
}

.legal-aside__subtitle {
  max-width: 32ch;
  margin-top: var(--space-xs);
  color: var(--color-text-strong);
  font-size: var(--text-l);
  line-height: var(--leading-snug);
}

/* ---------- Navigator: list of the three pages ---------- */
.legal-nav {
  margin-top: var(--space-l);
}

.legal-nav__label {
  margin-bottom: 12px;
  color: var(--color-label);
  font-size: var(--text-14);
  font-weight: var(--weight-bold);
  letter-spacing: var(--tracking-widest);
  line-height: var(--leading-snug);
  text-transform: uppercase;
}

.legal-nav__list {
  margin: 0;
  padding: 0;
  list-style: none;
  border-top: 1px solid var(--legal-rule);
}

.legal-nav__link {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 4px;
  border-bottom: 1px solid var(--legal-rule);
  color: var(--color-text-strong);
  font-size: var(--text-m);
  line-height: var(--leading-cozy);
  text-decoration: none;
}

.legal-nav__num {
  min-width: 2ch;
  color: var(--color-text-strong);
  font-size: var(--text-14);
  font-weight: var(--weight-bold);
  letter-spacing: var(--tracking-wide);
}

.legal-nav__link .pixel-arrow {
  margin-left: auto;
}

.legal-nav__link:hover {
  color: var(--color-text);
  text-decoration: underline;
  text-underline-offset: 4px;
}

.legal-nav__link[aria-current="page"] {
  color: var(--color-text);
  font-weight: var(--weight-semibold);
}

.legal-nav__link[aria-current="page"] .legal-nav__num {
  color: var(--color-text);
}

/* ---------- Pager: previous / next ---------- */
.legal-pager {
  display: flex;
  gap: 12px;
}

.legal-pager--aside {
  margin-top: var(--space-m);
}

.legal-pager__link {
  display: flex;
  flex: 1 1 0;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border: 1px solid var(--legal-rule);
  border-radius: var(--radius-s);
  color: var(--color-text);
  font-size: var(--text-16);
  font-weight: var(--weight-semibold);
  line-height: var(--leading-snug);
  text-decoration: none;
}

.legal-pager__link--next {
  justify-content: space-between;
}

.legal-pager__hint {
  display: block;
  margin-bottom: 3px;
  color: var(--color-label);
  font-size: var(--text-14);
  font-weight: var(--weight-bold);
  letter-spacing: var(--tracking-widest);
  text-transform: uppercase;
}

.legal-pager__link:hover {
  border-color: var(--color-primary);
}

/* The end-of-document pager only shows when the columns stack */
.legal-pager--end {
  display: none;
}

/* --------------------------------------------------------------------------
   Right column: the document
   -------------------------------------------------------------------------- */
.legal-content {
  max-width: 680px;
}

.legal-content__lead {
  margin-bottom: var(--space-xl);
  color: var(--color-text);
  font-size: var(--text-l);
  font-weight: var(--weight-medium);
  line-height: var(--leading-normal);
}

.legal-section {
  scroll-margin-top: var(--header-offset);
}

.legal-section + .legal-section {
  margin-top: var(--space-xl);
}

.legal-section h2 {
  margin-bottom: var(--space-s);
  font-size: var(--text-2xl);
  line-height: var(--leading-snug);
}

.legal-section p,
.legal-section li {
  color: var(--color-text-strong);
  font-size: var(--text-16);
  line-height: var(--leading-relaxed);
}

.legal-section p + p,
.legal-section p + ul,
.legal-section ul + p {
  margin-top: var(--space-s);
}

.legal-section ul {
  padding-left: 1.2em;
}

.legal-section li + li {
  margin-top: 6px;
}

.legal-section li::marker {
  color: var(--gold-500);
}

.legal-section a {
  color: var(--color-primary);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.legal-section a:hover {
  color: var(--color-primary-dark);
}

/* --------------------------------------------------------------------------
   Tablet and mobile: stack the columns
   -------------------------------------------------------------------------- */
@media (max-width: 991px) {
  .legal-page {
    padding-top: calc(var(--header-offset) + 16px);
  }

  .legal-aside,
  .legal-content {
    grid-column: 1 / -1;
  }

  .legal-aside {
    position: static;
    margin-bottom: var(--space-xl);
  }

  .legal-aside__inner {
    max-width: none;
  }

  /* Navigator becomes a row of pills */
  .legal-nav__list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    max-width: none;
    border-top: 0;
  }

  .legal-nav__link {
    padding: 9px 16px;
    border: 1px solid var(--legal-rule);
    border-radius: var(--radius-pill);
    font-size: var(--text-16);
  }

  .legal-nav__num,
  .legal-nav__link .pixel-arrow {
    display: none;
  }

  .legal-nav__link[aria-current="page"] {
    border-color: var(--ink);
    background: var(--ink);
    color: var(--white);
  }

  /* Pager moves from the top to the end of the document */
  .legal-pager--aside {
    display: none;
  }

  .legal-pager--end {
    display: flex;
    margin-top: var(--space-xl);
    padding-top: var(--space-l);
    border-top: 1px solid var(--legal-rule);
  }
}

@media (max-width: 520px) {
  .legal-pager--end {
    flex-direction: column;
  }
}
