/*
 * Terms, privacy and cookies pages (WP5). Layout only: colors, type, radii and shadows come from the tokens in site.css.
 */

/* One page width for the company and legal pages: the 220px rail, a gap and
   the reading column. company.css sets the same measure. */
.legal {
  --page: calc(220px + var(--space-7) + var(--prose));

  display: grid;
  grid-template-columns: 220px minmax(0, var(--prose));
  column-gap: var(--space-7);
  align-items: start;
  padding-inline: max(var(--gutter), calc((100% - var(--page)) / 2));
}

.legal-main {
  min-width: 0;
}

/* -------------------------------------------------------------------- head */

/* The heading keeps the shared page-heading scale from site.css. */
.legal-head {
  margin-bottom: var(--space-6);
}

.legal-head > h1 {
  margin-bottom: var(--space-3);
}

.legal-meta {
  margin: 0;
  color: var(--muted);
  font-size: var(--text-xs);
  font-weight: 500;
  line-height: 1.4;
}

/* ---------------------------------------------------------- "On this page" */

/* From 900px: a rail that stays in view beside the text. */
.legal-rail {
  position: sticky;
  top: calc(var(--header-height) + var(--space-5));
  max-height: calc(100dvh - var(--header-height) - var(--space-7));
  /* Room for the focus ring, which the scroll box would otherwise cut. */
  margin: calc(var(--space-1) * -1);
  padding: var(--space-1);
  overflow-y: auto;
  font-size: var(--text-sm);
  line-height: 20px;
}

.legal-rail-title {
  margin: 0 0 var(--space-2);
  color: var(--text);
  font-size: var(--text-xs);
  font-weight: 600;
  line-height: 1.4;
}

.legal-rail > ol,
.legal-toc > ol {
  margin: 0;
  list-style: none;
}

.legal-rail > ol {
  padding: 0;
}

.legal-rail li,
.legal-toc li {
  max-width: none;
}

.legal-rail a {
  display: block;
  padding: 6px 0;
  color: var(--muted);
  text-decoration: none;
}

.legal-rail a:hover {
  color: var(--text);
  text-decoration: underline;
}

@media (pointer: coarse) {
  .legal-rail a {
    display: flex;
    align-items: center;
    min-height: var(--control-height);
  }
}

/* Under 900px: the same links in one closed row above the text. The box has
   the same 16px inside on every edge, open or closed. */
.legal-toc {
  display: none;
  margin: 0 0 var(--space-6);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  background: var(--surface);
  font-size: var(--text-sm);
  line-height: 20px;
}

.legal-toc > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  min-height: var(--control-height-lg);
  padding: var(--space-4);
  border-radius: var(--radius-card);
  color: var(--text);
  font-weight: 600;
  cursor: pointer;
  list-style: none;
}

.legal-toc > summary::-webkit-details-marker {
  display: none;
}

.legal-toc > summary::after {
  flex: none;
  color: var(--muted);
  font-size: var(--text-xl);
  font-weight: 400;
  line-height: 1;
  content: "+";
  transition: transform var(--fast) var(--ease);
}

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

.legal-toc > ol {
  padding: 0 var(--space-4) var(--space-1);
}

.legal-toc a {
  display: flex;
  align-items: center;
  min-height: var(--control-height);
}

@media (max-width: 899px) {
  .legal {
    grid-template-columns: minmax(0, var(--prose));
    justify-content: center;
  }

  .legal-rail {
    display: none;
  }

  .legal-toc {
    display: block;
  }
}

/* -------------------------------------------------------------------- body */

.legal-body {
  line-height: 1.7;
}

/* The column is the reading width already. */
.legal-body :where(p, li) {
  max-width: none;
}

.legal-body h2 {
  margin: var(--space-7) 0 var(--space-3);
  font-size: calc(var(--text-xl) * 1.3);
  line-height: 1.2;
  scroll-margin-top: calc(var(--header-height) + var(--space-5));
}

.legal-body ul {
  padding-left: var(--space-5);
}

.legal-body li {
  margin-bottom: var(--space-2);
}

.legal-body .table-wrap {
  margin-top: var(--space-4);
}

.legal-body .button-row {
  margin-top: var(--space-5);
}

.legal-body > :last-child {
  margin-bottom: 0;
}

/* On a phone each row of a legal table is a small card (table-stack in
   site.css), so a cookie name is never broken and no column is cut. */

/* From tablet width up the cookie table gives its room to the sentence
   column. The name column is as narrow as its longest name, which is never
   broken, the two short columns are narrow and their headings may wrap,
   and "What it is for" takes everything left. */
@media (min-width: 640px) {
  .legal-body .table thead th {
    white-space: normal;
  }

  .legal-body .table thead th:first-child {
    width: 1%;
  }

  .legal-body .table thead th:nth-child(2),
  .legal-body .table thead th:nth-child(4) {
    width: 14%;
  }
}

@media (prefers-reduced-motion: reduce) {
  .legal-toc > summary::after {
    transition: none;
  }
}
