/* ==========================================================================
   Legal pages — Privacy Policy, Terms of Use, Cookies Policy, DPA
   --------------------------------------------------------------------------
   1. Layout (contents on the left + document)
   2. Side menu: "On this page"
   3. Prose (the legal text)
   4. Tables
   5. Responsive
   ========================================================================== */

/* 1. Layout
   ========================================================================== */
/* Contents + text form one block, centred in the card */
.legal {
  display: grid;
  grid-template-columns: 260px minmax(0, 780px);
  justify-content: center;
  gap: clamp(32px, 5vw, 80px);
  padding: var(--card-pad-y) var(--card-pad-x);
}

/* Last-updated line under the hero lead */
.legal-hero__meta {
  color: var(--color-ink-60);
  font-size: 15px;
}

/* 2. Side menu
   ========================================================================== */
.legal__aside {
  position: sticky;
  top: 24px;
  align-self: start;
  display: flex;
  flex-direction: column;
  gap: 32px;
  /* No inner scroll box: it clipped the toggle arrow and showed scrollbars.
     The longest list (20 items) fits on screen as is. */
}

.legal-toc__title {
  margin-bottom: 12px;
  color: var(--color-ink);
  font-weight: 600;
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

/* "On this page" — collapsible so it can fold away on phones */
.legal-toc__title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  list-style: none;
  cursor: pointer;
}

.legal-toc__title::-webkit-details-marker {
  display: none;
}

.legal-toc__title::after {
  content: "";
  width: 8px;
  height: 8px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  margin-right: 4px; /* room for the rotated arrow so it never touches the edge */
  transform: rotate(45deg) translateY(-3px);
  transition: transform 200ms var(--ease-out);
}

.legal-toc:not([open]) .legal-toc__title::after {
  transform: rotate(-45deg);
}

.legal-toc__list {
  list-style: none; /* headings already carry their own numbers */
  padding: 0;
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--color-ink-10);
}

.legal-toc__link {
  display: block;
  margin-left: -1px;
  padding: 6px 0 6px 14px;
  border-left: 2px solid transparent;
  color: var(--color-ink-60);
  font-size: 13px;
  line-height: 1.4;
  transition:
    color 150ms,
    border-color 150ms;
}

.legal-toc__link:hover {
  color: var(--color-ink);
}

/* Section currently in view (legal.js) */
.legal-toc__link.is-active {
  border-left-color: var(--color-brand);
  color: var(--color-ink);
  font-weight: 600;
}

/* 3. Prose
   ========================================================================== */
.prose {
  max-width: 780px;
  color: var(--color-ink-80);
  font-size: 16px;
  line-height: 1.75;
  overflow-wrap: anywhere;
}

.prose > * + * {
  margin-top: 1.1em;
}

.prose h2 {
  margin-top: 2em;
  padding-top: 1.4em;
  border-top: 1px solid var(--color-ink-10);
  color: var(--color-ink);
  font-family: var(--font-serif);
  font-weight: 400;
  font-size: clamp(22px, 2.2vw, 28px);
  line-height: 1.25;
  letter-spacing: -0.01em;
  scroll-margin-top: 24px;
}

.prose > h2:first-child {
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
}

.prose h3 {
  margin-top: 2em;
  color: var(--color-ink);
  font-weight: 700;
  font-size: 17px;
  line-height: 1.4;
}

.prose h2 + *,
.prose h3 + * {
  margin-top: 0.8em;
}

.prose strong {
  color: var(--color-ink);
  font-weight: 600;
}

.prose a {
  color: var(--color-ink);
  text-decoration: underline;
  text-decoration-color: var(--color-ink-12);
  text-underline-offset: 3px;
  transition: text-decoration-color 150ms;
}

.prose a:hover {
  text-decoration-color: var(--color-brand);
}

.prose ul,
.prose ol {
  padding-left: 1.4em;
}

.prose ul {
  list-style: disc;
}

.prose ol {
  list-style: decimal;
}

.prose li + li {
  margin-top: 0.5em;
}

.prose li::marker {
  color: var(--color-ink-60);
}

.prose ul ul,
.prose ol ol,
.prose ol ul,
.prose ul ol {
  margin-top: 0.5em;
}

/* Numbered clauses (Terms of Use) are anchor targets from "On this page" */
.prose > ol > li[id] {
  scroll-margin-top: 24px;
}

.prose > ol > li[id] + li[id] {
  margin-top: 1.2em;
}

.legal-indent {
  padding-left: 1.4em;
}

/* 4. Tables
   ========================================================================== */
.legal-table-wrap {
  margin-top: 1.4em;
  border: 1px solid var(--color-ink-10);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.legal-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  line-height: 1.55;
}

.legal-table th,
.legal-table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--color-ink-06);
  text-align: left;
  vertical-align: top;
}

.legal-table thead th {
  background: var(--color-ink);
  color: #fff;
  font-weight: 600;
  font-size: 13px;
}

.legal-table__group th {
  background: var(--color-surface-muted);
  color: var(--color-ink);
  font-weight: 600;
}

.legal-table tbody tr:last-child td {
  border-bottom: 0;
}

.legal-table td + td {
  border-left: 1px solid var(--color-ink-06);
}

.legal-table ul {
  margin: 0;
  padding-left: 1.1em;
}

.legal-table li + li {
  margin-top: 0.2em;
}

/* 5. Responsive
   ========================================================================== */
@media (max-width: 1024px) {
  .legal {
    grid-template-columns: minmax(0, 1fr);
    gap: 32px;
  }

  /* Side menu moves above the text and stops being sticky */
  .legal__aside {
    position: static;
    gap: 20px;
  }

  .legal-toc {
    padding: 16px;
    border-radius: var(--radius-md);
    background: var(--color-surface-muted);
  }

  .legal-toc[open] .legal-toc__title {
    margin-bottom: 12px;
  }

  .legal-toc__title {
    margin-bottom: 0;
  }
}

/* Phones: each table row becomes a card, cells are labelled by their column */
@media (max-width: 640px) {
  .legal-table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
  }

  .legal-table,
  .legal-table tbody,
  .legal-table tr,
  .legal-table th,
  .legal-table td {
    display: block;
  }

  .legal-table td + td {
    border-left: 0;
  }

  .legal-table td::before {
    content: attr(data-label);
    display: block;
    margin-bottom: 4px;
    color: var(--color-ink-60);
    font-weight: 600;
    font-size: 12px;
  }

  .legal-table tbody tr:not(.legal-table__group) {
    border-bottom: 1px solid var(--color-ink-10);
  }

  .prose {
    font-size: 15px;
  }
}
