/*
 * Slateway public site.
 *
 * DIRECTION: editorial and engineered. A legal instrument set like good
 * technical documentation, not a wall of unstyled prose and not a marketing
 * page wearing a policy as a costume. Numbered sections, a persistent
 * contents rail, hairline rules, a measured column. The reader is either a
 * driver checking what is recorded about them or a reviewer deciding whether
 * this platform is credible, and both are served by the same thing: clarity
 * that looks deliberate.
 *
 * Dark first. The dark expression is the design's home and the light one is
 * its equal counterpart, not an afterthought (U5). Both are reviewed.
 *
 * Poppins throughout, because the wordmark is Poppins and a second display
 * family would fight it. Contrast comes from weight, size and tracking, which
 * is the discipline this brand asks for.
 *
 * No raw hex appears here. Every colour resolves from tokens.css, generated
 * from the vendored brand pack, and surfaces are derived with color-mix
 * against CSS keywords rather than by typing a new value. check-brand.mjs
 * fails the build on any hex in this file.
 *
 * There is no amber. It is fenced to status and this site has none.
 */

:root {
  color-scheme: light dark;

  /* Light is declared on the bare root so no colour has its only definition
     inside a media query. A page that borrows its ground from the host
     renders unpredictably. */
  --surface: var(--colour-paper);
  --surface-raised: white;
  --surface-sunken: color-mix(in srgb, var(--colour-paper) 55%, white);
  --text: var(--colour-ink);
  --text-muted: color-mix(in srgb, var(--colour-ink) 62%, var(--colour-paper));
  --text-faint: color-mix(in srgb, var(--colour-ink) 42%, var(--colour-paper));
  --rule: var(--colour-hairline);
  --rule-strong: color-mix(in srgb, var(--colour-hairline) 70%, var(--colour-ink));
  --link: var(--colour-primary);
  --link-hover: var(--colour-deep);
  --accent: var(--colour-primary);
  --accent-wash: color-mix(in srgb, var(--colour-primary) 6%, white);
  --shadow: 0 1px 2px color-mix(in srgb, var(--colour-ink) 8%, transparent),
    0 8px 24px color-mix(in srgb, var(--colour-ink) 6%, transparent);

  /* Legal prose past roughly 70 characters loses the reader's place on every
     line return. */
  --measure: 68ch;
  --rail: 15rem;
  --gutter: clamp(1.25rem, 4vw, 3rem);

  --step-0: 1rem;
  --step-1: 1.125rem;
  --step-3: clamp(1.5rem, 1.1rem + 1.8vw, 2rem);
  --step-4: clamp(2rem, 1.3rem + 3.4vw, 3.25rem);
}

@media (prefers-color-scheme: dark) {
  :root {
    --surface: var(--colour-ink);
    --surface-raised: color-mix(in srgb, var(--colour-ink) 90%, white);
    --surface-sunken: color-mix(in srgb, var(--colour-ink) 96%, black);
    --text: var(--colour-paper);
    --text-muted: color-mix(in srgb, var(--colour-paper) 68%, var(--colour-ink));
    --text-faint: color-mix(in srgb, var(--colour-paper) 45%, var(--colour-ink));
    --rule: color-mix(in srgb, var(--colour-ink) 78%, white);
    --rule-strong: color-mix(in srgb, var(--colour-ink) 62%, white);
    /* Lifted so contrast holds against ink. Never a link that fails on the
       design's home background. */
    --link: color-mix(in srgb, var(--colour-primary) 50%, white);
    --link-hover: color-mix(in srgb, var(--colour-primary) 25%, white);
    --accent: color-mix(in srgb, var(--colour-primary) 55%, white);
    --accent-wash: color-mix(in srgb, var(--colour-primary) 14%, var(--colour-ink));
    --shadow: 0 1px 2px color-mix(in srgb, black 40%, transparent),
      0 12px 32px color-mix(in srgb, black 32%, transparent);
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--surface);
  color: var(--text);
  font-family: var(--font-family);
  font-size: var(--step-0);
  line-height: 1.7;
  overflow-x: hidden;
  text-rendering: optimizeLegibility;

  /* Atmosphere rather than a flat fill: one wide, very low opacity wash of
     the brand blue behind the masthead, so the page has a top rather than
     beginning abruptly. */
  background-image: radial-gradient(
    120ch 40rem at 50% -18rem,
    color-mix(in srgb, var(--colour-primary) 12%, transparent),
    transparent 70%
  );
  background-repeat: no-repeat;
  background-attachment: fixed;
}

/* Accessibility furniture
   ------------------------------------------------------------------ */

.skip-link {
  position: absolute;
  left: 0.5rem;
  top: -4rem;
  z-index: 20;
  background: var(--surface-raised);
  color: var(--text);
  border: 1px solid var(--rule-strong);
  border-radius: 0.5rem;
  padding: 0.75rem 1rem;
  box-shadow: var(--shadow);
  transition: top 0.15s ease;
}

.skip-link:focus {
  top: 0.5rem;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 0.25rem;
}

/* Masthead
   ------------------------------------------------------------------ */

.masthead {
  position: sticky;
  top: 0;
  z-index: 10;
  border-bottom: 1px solid var(--rule);
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  backdrop-filter: saturate(1.6) blur(12px);
}

.masthead__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.875rem 0;
}

.lockup {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  /* Clear space equals one chevron height on all four sides. Nothing enters
     it. */
  padding: 0.5rem;
  margin: -0.5rem;
  border-radius: 0.5rem;
}

/* The lockup is an image, never live text. The wordmark ships as outlined
   paths precisely so it cannot be re typeset slightly wrong. Minimum lockup
   width is 100px; below that the icon alone would be used, which this header
   never reaches. */
.lockup__image {
  display: block;
  width: auto;
  height: 1.75rem;
  min-width: var(--min-lockup-width);
}

.masthead__label {
  font-size: 0.75rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-faint);
  font-weight: 600;
}

/* Layout
   ------------------------------------------------------------------ */

.shell {
  width: 100%;
  max-width: 76rem;
  margin: 0 auto;
  padding: 0 var(--gutter);
}

.doc {
  display: block;
  padding: clamp(2.5rem, 6vw, 4.5rem) 0 2rem;
}

/* The contents rail sits beside the prose on a wide screen and becomes a
   disclosure above it on a narrow one. A legal page is navigated rather than
   read start to finish, and a reader looking for the deletion clause should
   not have to scroll the whole document for it. */
@media (min-width: 64rem) {
  .doc {
    display: grid;
    grid-template-columns: var(--rail) minmax(0, 1fr);
    gap: clamp(2rem, 5vw, 4rem);
    align-items: start;
  }
}

.doc__body {
  min-width: 0;
  counter-reset: section;
}

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

.doc__head {
  margin-bottom: clamp(2rem, 4vw, 3rem);
  padding-bottom: clamp(1.5rem, 3vw, 2rem);
  border-bottom: 1px solid var(--rule);
}

h1 {
  font-size: var(--step-4);
  line-height: 1.05;
  letter-spacing: -0.03em;
  font-weight: 600;
  margin: 0 0 0.75rem;
  text-wrap: balance;
}

.lede {
  font-size: var(--step-1);
  line-height: 1.6;
  color: var(--text-muted);
  max-width: 52ch;
  margin: 0 0 1.5rem;
  text-wrap: pretty;
}

.updated {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8125rem;
  letter-spacing: 0.02em;
  color: var(--text-muted);
  background: var(--surface-sunken);
  border: 1px solid var(--rule);
  border-radius: 999px;
  padding: 0.3125rem 0.75rem;
  margin: 0;
}

.updated::before {
  content: "";
  width: 0.4375rem;
  height: 0.4375rem;
  border-radius: 50%;
  background: var(--accent);
  flex: none;
}

/* Contents rail
   ------------------------------------------------------------------ */

.toc {
  font-size: 0.875rem;
  margin: 0 0 2.5rem;
  border: 1px solid var(--rule);
  border-radius: 0.75rem;
  background: var(--surface-sunken);
  padding: 0.25rem 1rem;
}

.toc__summary {
  cursor: pointer;
  padding: 0.75rem 0;
  font-weight: 600;
  letter-spacing: 0.02em;
  list-style: none;
}

.toc__summary::-webkit-details-marker {
  display: none;
}

.toc__summary::after {
  content: "";
  float: right;
  width: 0.5rem;
  height: 0.5rem;
  margin-top: 0.4rem;
  border-right: 1.5px solid var(--text-faint);
  border-bottom: 1.5px solid var(--text-faint);
  transform: rotate(45deg);
  transition: transform 0.2s ease;
}

.toc[open] .toc__summary::after {
  transform: rotate(-135deg);
}

.toc__list {
  list-style: none;
  margin: 0;
  padding: 0 0 0.75rem;
  counter-reset: toc;
}

.toc__list li {
  max-width: none;
  margin: 0;
}

.toc__list a {
  display: flex;
  gap: 0.625rem;
  padding: 0.3125rem 0;
  color: var(--text-muted);
  text-decoration: none;
  line-height: 1.45;
  counter-increment: toc;
}

.toc__list a::before {
  content: counter(toc, decimal-leading-zero);
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
  font-size: 0.75rem;
  padding-top: 0.15rem;
  flex: none;
}

.toc__list a:hover,
.toc__list a:focus-visible {
  color: var(--link-hover);
}

@media (min-width: 64rem) {
  .toc {
    position: sticky;
    top: 5rem;
    margin: 0;
    max-height: calc(100vh - 7rem);
    overflow-y: auto;
  }

  /* On a wide screen it is a rail rather than a disclosure, so the control
     is inert and the list always shown. */
  .toc__summary {
    pointer-events: none;
    color: var(--text-faint);
    font-size: 0.75rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    border-bottom: 1px solid var(--rule);
  }

  .toc__summary::after {
    display: none;
  }
}

/* Prose
   ------------------------------------------------------------------ */

.doc__body h2 {
  font-size: var(--step-3);
  line-height: 1.2;
  letter-spacing: -0.02em;
  font-weight: 600;
  margin: 3.25rem 0 1rem;
  padding-top: 1.75rem;
  border-top: 1px solid var(--rule);
  /* Clears the sticky masthead when an anchor is followed. */
  scroll-margin-top: 5.5rem;
  text-wrap: balance;
  counter-increment: section;
  position: relative;
}

.doc__body h2::before {
  content: counter(section, decimal-leading-zero);
  display: block;
  font-size: 0.75rem;
  letter-spacing: 0.12em;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 0.5rem;
  font-variant-numeric: tabular-nums;
}

.doc__body h2:first-of-type {
  margin-top: 0;
  border-top: 0;
  padding-top: 0;
}

.doc__body h3 {
  font-size: var(--step-1);
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 2rem 0 0.5rem;
  scroll-margin-top: 5.5rem;
}

/* The permalink appears on hover and on keyboard focus, never as permanent
   punctuation beside every heading. */
.anchor {
  position: absolute;
  left: -1.5rem;
  color: var(--text-faint);
  text-decoration: none;
  opacity: 0;
  transition: opacity 0.15s ease;
  font-weight: 400;
}

.doc__body h2:hover .anchor,
.anchor:focus-visible {
  opacity: 1;
}

@media (max-width: 63.999rem) {
  .anchor {
    display: none;
  }
}

p,
.doc__body li {
  max-width: var(--measure);
  text-wrap: pretty;
}

.doc__body ul,
.doc__body ol {
  padding-left: 1.25rem;
}

.doc__body li {
  margin-bottom: 0.5rem;
  padding-left: 0.25rem;
}

.doc__body li::marker {
  color: var(--text-faint);
}

a {
  color: var(--link);
  text-underline-offset: 0.2em;
  text-decoration-thickness: 1px;
}

a:hover,
a:focus {
  color: var(--link-hover);
}

strong {
  font-weight: 600;
  color: var(--text);
}

/* Tables
   ------------------------------------------------------------------ */

.table-scroll {
  overflow-x: auto;
  margin: 1.5rem 0;
  border: 1px solid var(--rule);
  border-radius: 0.75rem;
  background: var(--surface-raised);
}

table {
  border-collapse: collapse;
  min-width: 34rem;
  width: 100%;
  font-size: 0.9375rem;
}

thead th {
  background: var(--surface-sunken);
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 600;
}

th,
td {
  text-align: left;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--rule);
  vertical-align: top;
}

tbody tr:last-child th,
tbody tr:last-child td {
  border-bottom: 0;
}

tbody th {
  font-weight: 600;
}

/* Callout
   ------------------------------------------------------------------ */

.callout {
  background: var(--accent-wash);
  border: 1px solid color-mix(in srgb, var(--accent) 25%, transparent);
  border-left: 3px solid var(--accent);
  border-radius: 0.5rem;
  padding: 1.25rem 1.5rem;
  margin: 1.75rem 0;
}

.callout > :first-child {
  margin-top: 0;
}

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

/* Home
   ------------------------------------------------------------------ */

.home-hero {
  padding: clamp(3rem, 9vw, 6rem) 0 clamp(1.5rem, 4vw, 2.5rem);
}

.home-hero h1 {
  max-width: 16ch;
}

/* Footer
   ------------------------------------------------------------------ */

footer {
  border-top: 1px solid var(--rule);
  background: var(--surface-sunken);
  padding: clamp(2.5rem, 5vw, 4rem) 0 clamp(2rem, 4vw, 3rem);
  margin-top: clamp(3rem, 8vw, 6rem);
  color: var(--text-muted);
  font-size: 0.9375rem;
}

.footer-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem 4rem;
  justify-content: space-between;
  align-items: center;
}

.footer-links {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.625rem 2rem;
}

.footer-links li {
  max-width: none;
}

.footer-links a {
  text-decoration: none;
}

.footer-links a:hover,
.footer-links a:focus-visible {
  text-decoration: underline;
}

.footer-legal {
  margin: 2rem 0 0;
  padding-top: 1.5rem;
  border-top: 1px solid var(--rule);
  font-size: 0.875rem;
  color: var(--text-faint);
  max-width: none;
}

/* Page load, kept to one orchestrated moment rather than scattered about
   ------------------------------------------------------------------ */

@media (prefers-reduced-motion: no-preference) {
  .doc__head,
  .doc__body,
  .toc {
    animation: rise 0.5s cubic-bezier(0.22, 1, 0.36, 1) backwards;
  }

  .toc {
    animation-delay: 0.06s;
  }

  .doc__body {
    animation-delay: 0.12s;
  }
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(0.75rem);
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* Print. A legal page gets printed and filed, and a reader who does that
   should not get a sticky header across the first paragraph or a contents
   rail wasting a column.
   ------------------------------------------------------------------ */

@media print {
  .masthead,
  .toc,
  .skip-link,
  footer nav {
    display: none !important;
  }

  body {
    background: none;
    color: black;
    font-size: 11pt;
  }

  .doc {
    display: block;
    padding: 0;
  }

  a {
    color: black;
    text-decoration: underline;
  }

  /* A printed page loses every link target, so the destination is written
     out beside it. */
  .doc__body a[href^="http"]::after,
  .doc__body a[href^="mailto"]::after {
    content: " (" attr(href) ")";
    font-size: 0.85em;
    word-break: break-all;
  }

  h2,
  h3 {
    break-after: avoid;
  }

  table,
  .callout {
    break-inside: avoid;
  }
}

/* A page with no contents rail stays a single column at every width. The
   home page is read top to bottom rather than navigated, so a rail beside it
   would be an empty gutter. */
.doc--plain {
  display: block;
}

/* The head spans both columns so the rail sits beside the prose rather than
   beside the title. */
@media (min-width: 64rem) {
  .doc {
    grid-template-areas: "head head" "toc body";
  }

  .doc__head {
    grid-area: head;
  }

  .toc {
    grid-area: toc;
  }

  .doc__body {
    grid-area: body;
  }
}

/* On a narrow screen the rail is a real block in the flow, so an open list
   of sixteen sections would push the document itself off the first screen.
   Capped and scrollable instead: present, and not in the way. */
@media (max-width: 63.999rem) {
  .toc__list {
    max-height: 40vh;
    overflow-y: auto;
  }
}
