/* v7 legal pages: Terms, Privacy, Cookies, Sub-processors and the Licence, with their versioned copies.
   The documents are the live text word for word; this sheet only sets them. A contents column on the
   left follows the reader, the document runs on a reading measure on the right.

   Mono labels keep the case the document gives them: caps are typed into copy, never applied here. */

/* The same column and gutters as .wrap, so the document lines up with the nav above it */
.legal__wrap {
  max-width: calc(var(--content) + 2 * 40px);
  margin-inline: auto;
  padding-block: 72px 112px;
  padding-left: var(--gutter);
  padding-right: var(--gutter-r);
  display: grid;
  grid-template-columns: 240px minmax(0, 760px);
  justify-content: space-between;
  column-gap: 64px;
}

/* ── Head ─────────────────────────────────────────────────────────────────── */

.legal__head { grid-column: 1 / -1; display: grid; gap: 16px; justify-items: start; padding-bottom: 48px; margin-bottom: 56px; border-bottom: 1px solid var(--line); }
.legal__title { font-size: clamp(36px, 5vw, 56px); line-height: 1.1; font-weight: 700; color: var(--fg); max-width: 900px; }
.legal__updated { font-family: var(--mono); font-size: 12px; line-height: 16px; color: var(--fg-4); }
.legal__lead { font-size: 18px; line-height: 30px; color: var(--fg-3); max-width: 720px; }
.legal__lead a { color: var(--fg); text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--line-interactive); }

/* ── Contents ─────────────────────────────────────────────────────────────── */

.legal__toc { grid-column: 1; grid-row: 2 / span 2; position: sticky; top: calc(var(--nav-h) + 32px); align-self: start; max-height: calc(100vh - var(--nav-h) - 64px); overflow-y: auto; display: grid; gap: 12px; padding-right: 8px; scrollbar-width: thin; }
.legal__toch { font-family: var(--mono); font-size: 12px; line-height: 16px; color: var(--fg-4); }
.legal__toclist { list-style: none; margin: 0; padding: 0; display: grid; gap: 1px; border-left: 1px solid var(--line); }
.legal__toclist a { position: relative; display: grid; grid-template-columns: 22px minmax(0, 1fr); padding: 5px 0 5px 14px; font-size: 13px; line-height: 19px; color: var(--fg-4); transition: color 120ms ease; }
.legal__toclist a::before { content: ''; position: absolute; left: -1px; top: 5px; bottom: 5px; width: 2px; background: var(--fg); transform: scaleY(0); transition: transform 150ms ease; }
.legal__toclist a:hover { color: var(--fg-2); }
.legal__toclist a[aria-current='true'] { color: var(--fg); }
.legal__toclist a[aria-current='true']::before { transform: scaleY(1); }
.legal__tocnum { font-family: var(--mono); font-size: 11px; color: var(--fg-disabled); }

/* ── Body ─────────────────────────────────────────────────────────────────── */

.legal__body { grid-column: 2; min-width: 0; display: grid; gap: 48px; font-size: 15px; line-height: 25px; color: var(--fg-2); }
.clause { display: grid; gap: 14px; scroll-margin-top: 96px; }
.clause [id] { scroll-margin-top: 96px; }
.clause__title { display: flex; gap: 12px; font-size: 20px; line-height: 28px; font-weight: 600; color: var(--fg); }
.clause__sub { display: flex; gap: 10px; margin-top: 12px; font-size: 15px; line-height: 24px; font-weight: 600; color: var(--fg); }
.clause__num { font-family: var(--mono); font-size: 13px; font-weight: 400; color: var(--fg-4); padding-top: 2px; flex: none; }
.clause__para { position: relative; padding-left: 52px; }
.clause__para--sub { padding-left: 100px; }
.clause__ref { position: absolute; left: 0; top: 0; font-family: var(--mono); font-size: 12px; line-height: 25px; color: var(--fg-4); }
.clause__para--sub .clause__ref { left: 52px; }
.clause__def { padding-left: 52px; }
.clause strong, .clause b { font-weight: 600; color: var(--fg); }
.clause ul, .clause ol { margin: 0; padding-left: 72px; display: grid; gap: 8px; }
.clause a, .legal__contact a { color: var(--fg); text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--line-interactive); }
.clause a:hover, .legal__contact a:hover { text-decoration-color: var(--fg); }
.clause--schedule { padding-top: 40px; border-top: 1px solid var(--line); }

/* ── Tables ───────────────────────────────────────────────────────────────── */

.legal__table { overflow-x: auto; border: 1px solid var(--line-strong); border-radius: 12px; }
.legal__table table { width: 100%; border-collapse: collapse; font-size: 14px; line-height: 21px; }
.legal__table th, .legal__table td { padding: 12px 16px; text-align: left; vertical-align: top; border-top: 1px solid var(--line); }
.legal__table thead th { border-top: 0; background: var(--bg-soft); font-family: var(--mono); font-size: 11px; line-height: 16px; font-weight: 400; color: var(--fg-4); }
.legal__table tbody tr:first-child > * { border-top: 0; }
.legal__table thead + tbody tr:first-child > * { border-top: 1px solid var(--line); }
.legal__table td { color: var(--fg-2); }
.legal__table td p + p { margin-top: 8px; }
.legal__table--keyed th[scope='row'] { width: 32%; background: var(--bg-soft); font-weight: 500; color: var(--fg); }

/* ── Contact and the other documents ──────────────────────────────────────── */

.legal__contact { display: grid; gap: 4px; padding: 20px 24px; border: 1px solid var(--line-strong); border-radius: 12px; background: var(--bg-soft); font-size: 14px; line-height: 22px; color: var(--fg-2); }
.legal__contacth { font-family: var(--mono); font-size: 11px; color: var(--fg-4); }
.legal__also { grid-column: 2; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-top: 72px; }
.legal__alsolink { display: grid; gap: 18px; padding: 18px 20px; border: 1px solid var(--line-strong); border-radius: 12px; font-size: 15px; font-weight: 500; color: var(--fg); transition: border-color 120ms ease; }
.legal__alsolink:hover { border-color: var(--line-interactive); }
.legal__alsonum { font-family: var(--mono); font-size: 11px; color: var(--fg-4); }

@media (max-width: 960px) {
  .legal__wrap { grid-template-columns: minmax(0, 1fr); padding-top: 48px; }
  .legal__toc { grid-column: 1; grid-row: auto; position: static; max-height: none; margin-bottom: 48px; padding: 16px 20px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg-soft); }
  .legal__toclist { border-left: 0; }
  .legal__toclist a { padding-left: 0; }
  .legal__toclist a::before { display: none; }
  .legal__body, .legal__also { grid-column: 1; }
}
@media (max-width: 640px) {
  .clause__para { padding-left: 40px; }
  /* Room for the longest sub clause number (13.10.1) and a gap before the text */
  .clause__para--sub { padding-left: 60px; }
  .clause__para--sub .clause__ref { left: 0; }
  .clause__def { padding-left: 0; }
  .clause ul, .clause ol { padding-left: 56px; }
  .legal__also { grid-template-columns: minmax(0, 1fr); }
  .legal__table--stack thead { display: none; }
  .legal__table--stack tr { display: grid; padding: 12px 16px; border-top: 1px solid var(--line); }
  .legal__table--stack tbody tr:first-child { border-top: 0; }
  .legal__table--stack td { display: grid; grid-template-columns: 112px minmax(0, 1fr); gap: 12px; padding: 4px 0; border: 0 !important; }
  .legal__table--stack td::before { content: attr(data-label); font-family: var(--mono); font-size: 11px; color: var(--fg-4); }
  .legal__table--keyed tr { display: grid; }
  .legal__table--keyed th[scope='row'] { width: auto; }
}

/* ── Phones and tablets: the contents folds away ─────────────────────────────
   Above the document the full list is a wall before clause 1 (1,070px on Terms). js/v7/legal.js adds
   .is-folding and a row that opens it: the list's own heading and its count. Open, each entry is a 44px
   row. With no script the list stays open as above. */
.legal__tocbtn, .legal__tocjump { display: none; }
@media (max-width: 960px) {
  .legal__toc.is-folding { gap: 0; padding: 0; }
  .legal__toc.is-folding .legal__toch { display: none; }
  .legal__tocbtn { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 52px; padding: 0 20px; border: 0; border-radius: 12px; background: none; color: var(--fg-2); font-family: var(--mono); font-size: 12px; line-height: 16px; text-align: left; cursor: pointer; }
  .legal__toccount { display: inline-flex; align-items: center; height: 20px; padding-inline: 6px; border-radius: 6px; background: var(--bg-sunken); color: var(--fg-3); font-variant-numeric: tabular-nums; }
  .legal__tocchev { width: 7px; height: 7px; margin: -4px 4px 0 auto; border-right: 1.5px solid var(--fg-3); border-bottom: 1.5px solid var(--fg-3); transform: rotate(45deg); transition: transform 150ms ease; }
  .legal__toc.is-open .legal__tocchev { margin-top: 4px; transform: rotate(225deg); }
  .legal__toc.is-folding .legal__toclist { display: none; padding: 0 20px 8px; }
  .legal__toc.is-folding.is-open .legal__toclist { display: grid; border-top: 1px solid var(--line); padding-top: 4px; }
  .legal__toclist a { grid-template-columns: 30px minmax(0, 1fr); align-items: center; min-height: 44px; padding-block: 10px; font-size: 14px; line-height: 20px; color: var(--fg-3); }
  .legal__toclist li + li a { border-top: 1px solid var(--line); }

  /* Back to the contents, once the list has scrolled away: a small button on the gutter */
  .legal__tocjump {
    position: fixed;
    z-index: 30;
    right: var(--gutter-r);
    bottom: max(16px, env(safe-area-inset-bottom, 0px));
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 44px;
    padding-inline: 14px;
    border: 1px solid var(--line-strong);
    border-radius: 10px;
    background: var(--surface);
    box-shadow: var(--lt-shadow-overlay);
    font-family: var(--mono);
    font-size: 12px;
    line-height: 16px;
    color: var(--fg-2);
    opacity: 0;
    visibility: hidden;
    transition: opacity 120ms ease, visibility 0s 120ms;
  }
  .legal__tocjump.is-shown { opacity: 1; visibility: visible; transition: opacity 120ms ease; }
  .legal__tocjump-chev { width: 7px; height: 7px; margin-top: 3px; border-left: 1.5px solid var(--fg-3); border-top: 1.5px solid var(--fg-3); transform: rotate(45deg); }
}
/* Mono labels and numbers come up to the 12px floor on a phone or tablet, and the contact address gets a
   40px touch target without changing how it looks */
@media (max-width: 1023px) {
  .legal__tocnum, .legal__contacth, .legal__alsonum, .legal__table thead th, .legal__table--stack td::before { font-size: 12px; }
  .legal__tocnum { line-height: 20px; }
  .legal__contact a { position: relative; }
  .legal__contact a::after { content: ''; position: absolute; inset: -11px -4px; }
}

/* ── Phones: the end of the page ──────────────────────────────────────────── */
@media (max-width: 640px) {
  .legal__wrap { padding-bottom: 64px; }
  /* The other documents are a compact list, not three tall cards */
  .legal__also { gap: 0; margin-top: 56px; border-top: 1px solid var(--line); }
  .legal__alsolink { grid-template-columns: 32px minmax(0, 1fr); align-items: center; gap: 8px; min-height: 52px; padding: 0; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; }
  /* A sub-processor card takes its name as its title */
  .legal__table--stack td:first-child { display: block; padding-bottom: 6px; font-size: 15px; line-height: 22px; font-weight: 600; color: var(--fg); }
  .legal__table--stack td:first-child::before { display: none; }
}
/* On the smallest phones a label sits above its value, so the value keeps the card's full width */
@media (max-width: 400px) {
  .legal__table--stack td { grid-template-columns: minmax(0, 1fr); gap: 2px; padding: 6px 0; }
}

/* ══ The legal pages to the website standard (Johnny, 11 Nov; the skill leotrace-website) ══════════════════
   Layout and type only; the clause numbering and its indents stay as they are. The label goes; the title
   takes the headline role, Medium with negative tracking; the page opens 96 below the nav and ends 128 above
   the footer; the contents' numbers read at more than 3:1; the gaps come onto the scale. ══════════════════ */
.legal .legal__title { font: var(--t-headline); letter-spacing: var(--tr-headline); text-wrap: balance; }
.legal .legal__wrap { padding-block: 96px 128px; }
.legal .legal__head { padding-bottom: 48px; margin-bottom: 48px; }
.legal .legal__tocnum { font-size: 12px; color: var(--fg-4); }
.legal .clause { gap: 16px; }
.legal .legal__also { margin-top: 64px; }
@media (max-width: 1023px) {
  .legal .legal__wrap { padding-block: 64px 96px; }
}
@media (max-width: 760px) {
  .legal .legal__wrap { padding-block: 48px 64px; }
  .legal .legal__head { padding-bottom: 32px; margin-bottom: 32px; }
}
