/* Threadwork base components.
 *
 * Framework-neutral styles for plain, semantic HTML. Load AFTER
 * ../themes/threadwork.css. Every colour, font, radius, space and duration
 * comes from a custom property defined there: never add a hex value, a font
 * name or a one-off radius in this file (themes/check-usage.py fails if you
 * do). No JavaScript is needed for anything here.
 *
 * Class prefix: thw- (Threadwork). Structure and rules for each component:
 * design/guide/components.md. Live examples: design/guide/preview.html.
 *
 * Breakpoints are the tokens.json values written in em (custom properties
 * cannot be used in media queries): sm 30em, md 48em, lg 64em, xl 80em.
 * Everything works at 320 CSS px wide with no breakpoint at all.
 *
 * Contents
 *  1 Reset and page          9 Tables and summary lists   17 Dialog
 *  2 Typography              10 Cards and hero            18 Details
 *  3 Focus                   11 Tags, strands, Continuum  19 Thread timeline
 *  4 Layout helpers          12 Alerts and banners        20 Term pair, language
 *  5 Skip link, header       13 Breadcrumb                21 Child-voice choices
 *  6 Links                   14 Pagination                22 Print
 *  7 Buttons                 15 Section navigation (tabs alternative)
 *  8 Forms                   16 Footer
 */

/* ------------------------------------------------------------------ */
/* 1 Reset and page                                                    */
/* ------------------------------------------------------------------ */

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  /* SC 2.4.11 Focus Not Obscured: keep a focused control clear of anything
     pinned to the top or bottom of the viewport. */
  scroll-padding-block: var(--focus-scroll-padding) var(--space-12);
}

body {
  margin: 0;
  background: var(--background);
  color: var(--foreground);
  font-family: var(--font-sans);
  font-size: var(--text-body);
  font-weight: var(--weight-body);
  line-height: var(--leading-body);
  /* Long Irish compounds and pasted URLs must wrap, not overflow, at 320px. */
  overflow-wrap: break-word;
}

/* A nested theme (data-theme on any element) repaints itself. */
[data-theme] {
  background: var(--background);
  color: var(--foreground);
}

img,
svg,
video {
  max-inline-size: 100%;
  block-size: auto;
}

button,
input,
select,
textarea {
  margin: 0;
}

[hidden] {
  display: none !important;
}

/* ------------------------------------------------------------------ */
/* 2 Typography                                                        */
/* ------------------------------------------------------------------ */

h1,
h2,
h3,
h4,
h5,
h6,
.thw-display,
.thw-h1,
.thw-h2,
.thw-h3,
.thw-h4 {
  margin-block: 0 var(--space-3);
  font-family: var(--font-display);
  text-wrap: balance;
}

.thw-display {
  font-size: var(--text-display-lg);
  font-weight: var(--weight-display-lg);
  line-height: var(--leading-display-lg);
  letter-spacing: var(--tracking-display-lg);
}

h1,
.thw-h1 {
  font-size: var(--text-display-md);
  font-weight: var(--weight-display-md);
  line-height: var(--leading-display-md);
  letter-spacing: var(--tracking-display-md);
}

h2,
.thw-h2 {
  font-size: var(--text-heading-lg);
  font-weight: var(--weight-heading-lg);
  line-height: var(--leading-heading-lg);
}

h3,
.thw-h3 {
  font-size: var(--text-heading-md);
  font-weight: var(--weight-heading-md);
  line-height: var(--leading-heading-md);
}

h4,
h5,
h6,
.thw-h4 {
  font-size: var(--text-heading-sm);
  font-weight: var(--weight-heading-sm);
  line-height: var(--leading-heading-sm);
}

/* A heading that follows other content gets air above it. */
* + h2,
* + .thw-h2 {
  margin-block-start: var(--space-10);
}

* + h3,
* + .thw-h3 {
  margin-block-start: var(--space-8);
}

* + h4,
* + .thw-h4,
* + h5,
* + h6 {
  margin-block-start: var(--space-6);
}

p,
ul,
ol,
dl,
blockquote,
pre {
  margin-block: 0 var(--space-4);
}

p,
li,
dd,
blockquote {
  max-inline-size: var(--measure);
}

ul,
ol {
  padding-inline-start: var(--space-6);
}

li + li {
  margin-block-start: var(--space-1);
}

strong,
b {
  font-weight: var(--weight-body-strong);
}

small,
.thw-meta {
  font-size: var(--text-meta);
  font-weight: var(--weight-meta);
  line-height: var(--leading-meta);
}

.thw-lead {
  font-size: var(--text-body-lg);
  font-weight: var(--weight-body-lg);
  line-height: var(--leading-body-lg);
}

.thw-muted {
  color: var(--muted-foreground);
}

hr {
  margin-block: var(--space-8);
  border: 0;
  border-block-start: var(--border-hairline) solid var(--border);
}

code,
kbd,
samp,
pre {
  font-family: var(--font-mono);
  font-size: var(--text-meta);
}

code,
kbd {
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
  background: var(--muted);
  color: var(--foreground);
}

pre {
  overflow-x: auto;
  padding: var(--space-4);
  border-radius: var(--radius-sm);
  background: var(--muted);
  color: var(--foreground);
}

pre code {
  padding: 0;
  background: none;
}

/* ------------------------------------------------------------------ */
/* 3 Focus                                                             */
/* ------------------------------------------------------------------ */

/* One indicator for every focusable thing. Outer ring in focus-ring, inner
   halo in focus-halo; the two contrast with each other (see tokens.json ->
   contrast.pairs), so the indicator shows on any surface. In forced-colours
   mode the browser drops the shadow and draws the outline in Highlight.
   Never remove this without replacing it. */
:focus-visible {
  outline: var(--focus-ring-width) solid var(--focus-ring);
  outline-offset: var(--focus-halo-width);
  box-shadow: 0 0 0 var(--focus-halo-width) var(--focus-halo);
}

/* Targets of in-page links (skip link, error summary) clear pinned content. */
:target {
  scroll-margin-block-start: var(--focus-scroll-padding);
}

/* ------------------------------------------------------------------ */
/* 4 Layout helpers                                                    */
/* ------------------------------------------------------------------ */

.thw-container {
  inline-size: 100%;
  max-inline-size: var(--max-width);
  margin-inline: auto;
  padding-inline: var(--screen-padding);
}

/* A row that wraps: button groups, tag lists. */
.thw-cluster {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
  margin: 0 0 var(--space-4);
  padding: 0;
  list-style: none;
}

.thw-cluster > li {
  margin: 0;
}

/* Vertical rhythm between direct children. */
.thw-stack > * {
  margin-block: 0;
}

.thw-stack > * + * {
  margin-block-start: var(--stack-gap, var(--space-4));
}

.thw-stack--lg {
  --stack-gap: var(--space-8);
}

.thw-stack--sm {
  --stack-gap: var(--space-2);
}

/* Tiles that reflow to one column on their own: no breakpoint needed. */
.thw-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 16rem), 1fr));
  gap: var(--space-4);
  margin-block-end: var(--space-6);
}

.thw-section {
  padding-block: var(--space-8);
}

/* Hidden visually, still read by screen readers. */
.thw-visually-hidden {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

@media (min-width: 48em) {
  .thw-container {
    padding-inline: var(--gutter);
  }

  .thw-section {
    padding-block: var(--space-12);
  }
}

/* ------------------------------------------------------------------ */
/* 5 Skip link and site header                                         */
/* ------------------------------------------------------------------ */

.thw-skip-link {
  position: absolute;
  inset-block-start: var(--space-2);
  inset-inline-start: var(--space-2);
  z-index: var(--z-skip-link);
  padding: var(--space-3) var(--space-5);
  border-radius: var(--radius-pill);
  background: var(--primary);
  color: var(--primary-foreground);
  font-weight: var(--weight-body-strong);
  transform: translateY(-200%);
}

.thw-skip-link:focus {
  transform: none;
}

/* The header scrolls with the page. Do not make it sticky: a pinned bar can
   hide the focused control (SC 2.4.11) and eats a small phone screen. */
.thw-header {
  border-block-end: var(--border-hairline) solid var(--border);
  background: var(--background);
}

.thw-header__inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2) var(--space-6);
  padding-block: var(--space-3);
}

/* The wordmark: the A2 drawing as one-colour inline SVG (currentColor, so it follows the text and shows in forced
   colours). The link keeps the 44 px target; the name is the hidden word beside the drawing. */
.thw-wordmark {
  display: inline-flex;
  align-items: center;
  min-block-size: var(--target-touch);
  color: var(--foreground);
  text-decoration: none;
}

.thw-wordmark__mark {
  display: block;
  block-size: var(--space-10);
  inline-size: auto;
}

/* The signed-in person's own links: "My sign-in" and the "Sign out" button, side by side, wrapping on a phone. */
.thw-header__account {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2) var(--space-4);
}

.thw-header__account > form {
  margin: 0;
}

.thw-nav__list {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1) var(--space-2);
  margin: 0;
  padding: 0;
  list-style: none;
}

.thw-nav__list > li {
  margin: 0;
}

.thw-nav__link {
  display: inline-flex;
  align-items: center;
  min-block-size: var(--target-touch);
  padding-inline: var(--space-3);
  border-radius: var(--radius-pill);
  color: var(--foreground);
  font-weight: var(--weight-body-strong);
  text-decoration: none;
}

/* Current page: weight and underline as well as the tint. */
.thw-nav__link[aria-current] {
  background: var(--accent);
  color: var(--accent-foreground);
  text-decoration: underline;
  text-decoration-thickness: var(--border-control);
  text-underline-offset: var(--space-1);
}

/* ------------------------------------------------------------------ */
/* 6 Links                                                             */
/* ------------------------------------------------------------------ */

/* Links are always underlined: colour alone never marks a link (SC 1.4.1). */
a {
  color: var(--link);
  text-decoration: underline;
  text-decoration-thickness: var(--border-hairline);
  text-underline-offset: var(--space-1);
  border-radius: var(--radius-xs);
}

/* A link on its own line, outside a sentence, is a target of its own: at
   least 24px high (SC 2.5.8). A link inside a sentence is exempt and needs
   no class. Links that are always stand-alone (alerts, the thread) have the
   rule built in. */
.thw-link-standalone {
  display: inline-flex;
  align-items: center;
  min-block-size: var(--target-min);
}

@media (hover: hover) {
  a:hover {
    text-decoration-thickness: var(--border-control);
  }

  .thw-nav__link:hover {
    text-decoration: underline;
  }
}

/* ------------------------------------------------------------------ */
/* 7 Buttons                                                           */
/* ------------------------------------------------------------------ */

/* Works on <button>, <a> and <input type="submit">. Default = primary (ink).
   Labels wrap rather than truncate, so longer Irish text fits. */
.thw-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-block-size: var(--control-height);
  min-inline-size: var(--target-touch);
  padding: var(--space-2) var(--space-6);
  border: var(--border-control) solid var(--primary);
  border-radius: var(--radius-pill);
  background: var(--primary);
  color: var(--primary-foreground);
  font-family: var(--font-sans);
  font-size: var(--text-body-strong);
  font-weight: var(--weight-body-strong);
  line-height: var(--leading-heading-sm);
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  transition: background-color var(--motion-fast) var(--ease), transform var(--motion-fast) var(--ease);
}

.thw-button:active {
  transform: scale(var(--press-scale));
}

/* Secondary: outlined. (The source system's "outline" variant; its
   card-coloured "secondary" has no visible edge on a card.) */
.thw-button--secondary {
  background: transparent;
  color: var(--foreground);
}

/* Quiet: text only, underlined so it still reads as an action. */
.thw-button--quiet {
  border-color: transparent;
  background: transparent;
  color: var(--foreground);
  text-decoration: underline;
  text-underline-offset: var(--space-1);
}

/* Danger: irreversible actions only, always behind a confirmation. */
.thw-button--danger {
  border-color: var(--destructive);
  background: var(--destructive);
  color: var(--destructive-foreground);
}

/* Brand: the one standout action on an ink (inverse) block. */
.thw-button--brand {
  border-color: var(--brand-foreground);
  background: var(--brand);
  color: var(--brand-foreground);
}

.thw-button--lg {
  min-block-size: var(--control-height-lg);
}

.thw-button--block {
  display: flex;
  inline-size: 100%;
  border-radius: var(--radius-md);
}

/* Icon-only button: 44 by 44, always with an accessible name. */
.thw-icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  inline-size: var(--icon-button);
  block-size: var(--icon-button);
  padding: 0;
  border: var(--border-control) solid transparent;
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--foreground);
  cursor: pointer;
}

@media (hover: hover) {
  .thw-button:hover {
    border-color: var(--primary-hover);
    background: var(--primary-hover);
  }

  .thw-button--secondary:hover,
  .thw-button--quiet:hover,
  .thw-icon-button:hover {
    border-color: var(--primary);
    background: var(--accent);
    color: var(--accent-foreground);
  }

  .thw-button--danger:hover,
  .thw-button--brand:hover {
    border-color: var(--primary);
  }

  .thw-button--danger:hover {
    background: var(--destructive);
  }

  .thw-button--brand:hover {
    background: var(--brand);
  }

  .thw-hero .thw-button:not([class*="--"]):hover {
    border-color: var(--brand-foreground);
    background: var(--brand-foreground);
    text-decoration: underline;
  }
}

/* Forced colours: every button variant becomes a plain system button with
   an edge; the label must never depend on a fill the system removes. */
@media (forced-colors: active) {
  .thw-button,
  .thw-skip-link {
    border-color: ButtonText;
    background: ButtonFace;
    color: ButtonText;
  }
}

/* Disabled: still readable (disabled-foreground on disabled is a checked
   text pairing) and marked by a dashed edge as well as the fill. Prefer
   leaving a button enabled and explaining what is missing when it is used. */
.thw-button:disabled,
.thw-button[aria-disabled="true"],
.thw-icon-button:disabled,
.thw-icon-button[aria-disabled="true"] {
  border: var(--border-control) dashed var(--input);
  background: var(--disabled);
  color: var(--disabled-foreground);
  text-decoration: none;
  cursor: not-allowed;
  transform: none;
}

/* ------------------------------------------------------------------ */
/* 8 Forms                                                             */
/* ------------------------------------------------------------------ */

/* One question per field block: label, optional hint, optional error, then
   the control. The label is always visible; a placeholder is never the label. */
.thw-field {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-2);
  margin-block-end: var(--space-6);
}

.thw-field > * {
  margin-block: 0;
}

/* Error state: a thick edge beside the whole block as well as the colour. */
.thw-field--error {
  padding-inline-start: var(--space-4);
  border-inline-start: var(--border-emphasis) solid var(--danger);
}

.thw-label,
legend {
  display: block;
  color: var(--foreground);
  font-size: var(--text-body-strong);
  font-weight: var(--weight-body-strong);
  line-height: var(--leading-body-strong);
}

.thw-hint {
  color: var(--muted-foreground);
}

/* Starts with the word "Error:" (or "Earráid:") in the HTML. */
.thw-error-message {
  color: var(--danger);
  font-weight: var(--weight-body-strong);
}

.thw-input,
.thw-textarea,
.thw-select {
  display: block;
  inline-size: 100%;
  min-block-size: var(--input-height);
  margin: 0;
  padding: var(--space-3) var(--space-4);
  border: var(--border-control) solid var(--input);
  border-radius: var(--radius-sm);
  background: var(--background);
  color: var(--foreground);
  font: inherit;
  /* Never below 16px: smaller text makes iOS zoom the page on focus. */
  font-size: var(--text-body);
}

.thw-textarea {
  min-block-size: calc(var(--input-height) * 2.5);
  resize: vertical;
}

/* Width hints for short answers (the field still shrinks on a small screen). */
.thw-input--short {
  max-inline-size: 10rem;
}

.thw-input--medium {
  max-inline-size: 20rem;
}

/* A code the person copies: one field, paste allowed, autocomplete on. */
.thw-input--code {
  max-inline-size: 12rem;
  font-family: var(--font-mono);
  letter-spacing: 0.2em;
}

.thw-input[aria-invalid="true"],
.thw-textarea[aria-invalid="true"],
.thw-select[aria-invalid="true"] {
  border-width: var(--border-emphasis);
  border-color: var(--danger);
}

.thw-input:disabled,
.thw-textarea:disabled,
.thw-select:disabled {
  border-style: dashed;
  background: var(--disabled);
  color: var(--disabled-foreground);
  cursor: not-allowed;
}

/* Read-only values that were filled in for the person (SC 3.3.7). */
.thw-input[readonly],
.thw-textarea[readonly] {
  border-style: dashed;
  background: var(--card);
}

fieldset,
.thw-fieldset {
  min-inline-size: 0;
  margin: 0 0 var(--space-6);
  padding: 0;
  border: 0;
}

legend {
  margin-block-end: var(--space-2);
  padding: 0;
}

/* When the legend is the page's question. */
.thw-legend--lg {
  font-family: var(--font-display);
  font-size: var(--text-heading-md);
  font-weight: var(--weight-heading-md);
  line-height: var(--leading-heading-md);
}

/* Checkbox and radio: a 24px control inside a row at least 44px tall; the
   whole row (control and text) is the target. */
.thw-choice {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  min-block-size: var(--target-touch);
  padding-block: var(--space-2);
}

.thw-choice__input {
  flex: none;
  appearance: none;
  -webkit-appearance: none;
  display: inline-grid;
  place-content: center;
  inline-size: var(--checkbox-size);
  block-size: var(--checkbox-size);
  margin: var(--space-1) 0 0;
  border: var(--border-control) solid var(--input);
  border-radius: var(--radius-xs);
  background: var(--background);
  color: var(--primary-foreground);
  cursor: pointer;
}

.thw-choice__input[type="radio"] {
  border-radius: 50%;
}

.thw-choice__input::before {
  content: "";
  inline-size: var(--space-3);
  block-size: var(--space-3);
  background: currentColor;
  transform: scale(0);
  transition: transform var(--motion-fast) var(--ease);
}

.thw-choice__input[type="checkbox"]::before {
  inline-size: var(--space-4);
  block-size: var(--space-4);
  clip-path: polygon(14% 52%, 0 66%, 38% 100%, 100% 22%, 86% 10%, 37% 70%);
}

.thw-choice__input[type="radio"]::before {
  border-radius: 50%;
}

.thw-choice__input:checked {
  border-color: var(--primary);
  background: var(--primary);
}

.thw-choice__input:checked::before {
  transform: scale(1);
}

.thw-choice__input:disabled {
  border-style: dashed;
  background: var(--disabled);
  color: var(--disabled-foreground);
  cursor: not-allowed;
}

.thw-choice__label {
  padding-block-start: var(--space-1);
  cursor: pointer;
}

.thw-choice__label .thw-hint {
  display: block;
}

/* Error summary: top of the page after a failed submit; receives focus;
   each item links to its field. */
.thw-error-summary {
  margin-block-end: var(--space-8);
  padding: var(--space-5);
  border-inline-start: var(--border-emphasis) solid var(--danger-subtle-foreground);
  border-radius: var(--radius-sm);
  background: var(--danger-subtle);
  color: var(--danger-subtle-foreground);
}

.thw-error-summary > :last-child {
  margin-block-end: 0;
}

.thw-error-summary a {
  color: inherit;
  font-weight: var(--weight-body-strong);
}

@media (forced-colors: active) {
  /* Let the system draw checkboxes and radios in the reader's colours. */
  .thw-choice__input {
    appearance: auto;
    -webkit-appearance: auto;
  }

  .thw-choice__input::before {
    display: none;
  }
}

/* ------------------------------------------------------------------ */
/* 9 Tables and summary lists                                          */
/* ------------------------------------------------------------------ */

/* Real <table> with <caption>, <th scope>. On a narrow screen the wrapper
   scrolls sideways (it is focusable and labelled so keyboard users can
   scroll it); the table is never restyled into blocks, because that drops
   the header-cell association for screen readers. */
.thw-table-wrap {
  /* contains absolutely positioned children (visually hidden text) so they
     scroll with the table instead of widening the page */
  position: relative;
  max-inline-size: 100%;
  margin-block-end: var(--space-6);
  overflow-x: auto;
}

.thw-table {
  inline-size: 100%;
  border-collapse: collapse;
  text-align: start;
}

.thw-table caption {
  padding-block-end: var(--space-3);
  font-family: var(--font-display);
  font-size: var(--text-heading-sm);
  font-weight: var(--weight-heading-sm);
  line-height: var(--leading-heading-sm);
  text-align: start;
}

.thw-table th,
.thw-table td {
  padding: var(--cell-padding-y) var(--cell-padding-x);
  border-block-end: var(--border-hairline) solid var(--border);
  text-align: start;
  vertical-align: top;
}

.thw-table thead th {
  border-block-end: var(--border-control) solid var(--foreground);
  background: var(--card);
  color: var(--card-foreground);
  font-weight: var(--weight-body-strong);
}

.thw-table tbody th {
  font-weight: var(--weight-body-strong);
}

.thw-table .thw-table__number {
  text-align: end;
  font-variant-numeric: tabular-nums;
}

/* Row actions keep the 24px minimum even in the compact density. */
.thw-table td a:not(.thw-button),
.thw-table td button:not(.thw-button),
.thw-table tbody th a:not(.thw-button) {
  display: inline-block;
  min-block-size: var(--target-min);
  min-inline-size: var(--target-min);
}

/* Key and value pairs (handover summary, "check your answers"). Stacks on a
   narrow screen, two columns from md. */
.thw-summary-list {
  margin: 0 0 var(--space-6);
}

.thw-summary-list__row {
  padding-block: var(--space-3);
  border-block-end: var(--border-hairline) solid var(--border);
}

.thw-summary-list dt {
  font-weight: var(--weight-body-strong);
}

.thw-summary-list dd {
  margin: 0;
}

@media (min-width: 48em) {
  .thw-summary-list__row {
    display: grid;
    grid-template-columns: minmax(10rem, 1fr) 2fr;
    gap: var(--space-6);
  }
}

/* ------------------------------------------------------------------ */
/* 10 Cards and hero                                                   */
/* ------------------------------------------------------------------ */

/* Flat: no shadow. The edge is transparent so the card looks borderless,
   but it appears in forced-colours mode and under prefers-contrast: more. */
.thw-card {
  padding: var(--space-5);
  border: var(--border-hairline) solid transparent;
  border-radius: var(--radius-lg);
  background: var(--card);
  color: var(--card-foreground);
}

.thw-card > :last-child {
  margin-block-end: 0;
}

.thw-card--plain {
  border-color: var(--border);
  background: var(--background);
  color: var(--foreground);
}

.thw-card--subtle {
  background: var(--brand-subtle);
  color: var(--brand-subtle-foreground);
}

.thw-card--inverse {
  background: var(--inverse);
  color: var(--inverse-foreground);
}

.thw-card--inverse a {
  color: var(--inverse-accent);
}

.thw-card--inverse .thw-muted {
  color: var(--inverse-muted-foreground);
}

/* The brand block: ink on amber. One per screen. */
.thw-hero {
  padding-block: var(--space-10) var(--space-12);
  border-end-start-radius: var(--radius-xl);
  border-end-end-radius: var(--radius-xl);
  background: var(--brand);
  color: var(--brand-foreground);
}

.thw-hero a {
  color: inherit;
}

.thw-hero .thw-button--secondary {
  border-color: var(--brand-foreground);
  color: var(--brand-foreground);
}

/* On amber the primary button is always ink, in both themes. */
.thw-hero .thw-button:not([class*="--"]) {
  border-color: var(--brand-foreground);
  background: var(--brand-foreground);
  color: var(--brand);
}

/* Under forced colours the system draws the button. This rule must come after
   the one above (same specificity), or the author's amber text is what axe
   reads against the forced background. */
@media (forced-colors: active) {
  .thw-hero .thw-button:not([class*="--"]) {
    border-color: ButtonText;
    background: ButtonFace;
    color: ButtonText;
  }
}

.thw-hero__thread {
  display: block;
  inline-size: 100%;
  margin-block-start: var(--space-6);
  color: var(--brand-foreground);
}

@media (prefers-contrast: more) {
  .thw-card {
    border-color: var(--border);
  }
}

@media (min-width: 48em) {
  .thw-card {
    padding: var(--space-6);
  }
}

/* ------------------------------------------------------------------ */
/* 11 Tags, strands and Continuum levels                               */
/* ------------------------------------------------------------------ */

/* A tag always contains words. The tint supports the words; it is never the
   message. Tags are not interactive. */
.thw-tag {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-1) var(--space-3);
  border: var(--border-hairline) solid transparent;
  border-radius: var(--radius-pill);
  background: var(--muted);
  color: var(--foreground);
  font-size: var(--text-label);
  font-weight: var(--weight-label);
  line-height: var(--leading-label);
}

.thw-tag--success {
  background: var(--success-subtle);
  color: var(--success-subtle-foreground);
}

.thw-tag--warning {
  background: var(--warning-subtle);
  color: var(--warning-subtle-foreground);
}

.thw-tag--danger {
  background: var(--danger-subtle);
  color: var(--danger-subtle-foreground);
}

.thw-tag--info {
  background: var(--info-subtle);
  color: var(--info-subtle-foreground);
}

/* Strands. data-strand sets the colour, the marker shape and the line
   pattern together; the text label is in the HTML. */
[data-strand="teacher"] {
  --strand: var(--strand-teacher);
  --strand-pattern: solid;
}

[data-strand="sna"] {
  --strand: var(--strand-sna);
  --strand-pattern: dashed;
}

[data-strand="parent"] {
  --strand: var(--strand-parent);
  --strand-pattern: dotted;
}

[data-strand="child"] {
  --strand: var(--strand-child);
  --strand-pattern: double;
}

/* The marker: circle (teacher), square (SNA), diamond (parent), triangle
   (child). Decorative: always aria-hidden, always next to its label. */
.thw-mark {
  flex: none;
  display: inline-block;
  inline-size: var(--space-4);
  block-size: var(--space-4);
  background: var(--strand, currentColor);
  forced-color-adjust: none;
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}

[data-strand="teacher"] > .thw-mark,
.thw-mark[data-strand="teacher"] {
  border-radius: 50%;
}

[data-strand="sna"] > .thw-mark,
.thw-mark[data-strand="sna"] {
  clip-path: inset(6%);
}

[data-strand="parent"] > .thw-mark,
.thw-mark[data-strand="parent"] {
  clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%);
}

[data-strand="child"] > .thw-mark,
.thw-mark[data-strand="child"] {
  clip-path: polygon(50% 4%, 100% 96%, 0 96%);
}

/* Strand tag: neutral surface, coloured shape, the strand's name in words. */
.thw-strand {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-1) var(--space-3);
  border: var(--border-hairline) solid transparent;
  border-radius: var(--radius-pill);
  background: var(--card);
  color: var(--card-foreground);
  font-size: var(--text-label);
  font-weight: var(--weight-label);
  line-height: var(--leading-label);
}

.thw-card .thw-strand,
.thw-table thead .thw-strand {
  background: var(--muted);
  color: var(--foreground);
}

/* A voice: what one strand said, in their words. The edge carries the
   strand's line pattern as well as its colour. */
.thw-voice {
  margin-inline: 0;
  padding: var(--space-3) var(--space-4);
  border-inline-start: var(--border-emphasis) var(--strand-pattern, solid) var(--strand, var(--input));
}

.thw-voice[data-strand="child"] {
  /* a double line needs more width to show as two lines */
  border-inline-start-width: calc(var(--border-emphasis) * 2);
}

.thw-voice > :last-child {
  margin-block-end: 0;
}

/* Continuum of Support level: filled steps out of three, in one colour,
   beside the statutory name. Not a traffic light. */
.thw-continuum {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-1) var(--space-3);
  border: var(--border-hairline) solid transparent;
  border-radius: var(--radius-pill);
  background: var(--card);
  color: var(--card-foreground);
  font-size: var(--text-label);
  font-weight: var(--weight-label);
  line-height: var(--leading-label);
}

.thw-card .thw-continuum {
  background: var(--muted);
  color: var(--foreground);
}

.thw-continuum__steps {
  flex: none;
  display: inline-flex;
  gap: var(--space-1);
}

.thw-continuum__steps > span {
  inline-size: var(--space-2);
  block-size: var(--space-4);
  border: var(--border-control) solid var(--continuum);
  forced-color-adjust: none;
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}

.thw-continuum[data-level="1"] .thw-continuum__steps > span:nth-child(-n + 1),
.thw-continuum[data-level="2"] .thw-continuum__steps > span:nth-child(-n + 2),
.thw-continuum[data-level="3"] .thw-continuum__steps > span:nth-child(-n + 3) {
  background: var(--continuum);
}

/* ------------------------------------------------------------------ */
/* 12 Alerts and notification banners                                  */
/* ------------------------------------------------------------------ */

/* Every alert has an icon and a title that says what kind of message it
   is. Use role="status" for things that just happened ("Saved"), and
   role="alert" only for something the person must deal with now. */
.thw-alert {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  margin-block-end: var(--space-6);
  padding: var(--space-4) var(--space-5);
  border-inline-start: var(--border-emphasis) solid var(--info-subtle-foreground);
  border-radius: var(--radius-sm);
  background: var(--info-subtle);
  color: var(--info-subtle-foreground);
}

.thw-alert--success {
  border-color: var(--success-subtle-foreground);
  background: var(--success-subtle);
  color: var(--success-subtle-foreground);
}

.thw-alert--warning {
  border-color: var(--warning-subtle-foreground);
  background: var(--warning-subtle);
  color: var(--warning-subtle-foreground);
}

.thw-alert--danger {
  border-color: var(--danger-subtle-foreground);
  background: var(--danger-subtle);
  color: var(--danger-subtle-foreground);
}

.thw-alert__icon {
  flex: none;
  inline-size: var(--space-6);
  block-size: var(--space-6);
  margin-block-start: var(--space-1);
}

.thw-alert__body {
  flex: 1;
  min-inline-size: 0;
}

.thw-alert__body > * {
  margin-block: 0;
}

.thw-alert__body > * + * {
  margin-block-start: var(--space-1);
}

.thw-alert__title {
  font-weight: var(--weight-body-strong);
}

.thw-alert a {
  display: inline-flex;
  align-items: center;
  min-block-size: var(--target-min);
  color: inherit;
  font-weight: var(--weight-body-strong);
}

/* Banner: the same alert, full width at the top of <main>. It scrolls with
   the page; it is never pinned. */
.thw-alert--banner {
  border-radius: 0;
}

/* ------------------------------------------------------------------ */
/* 13 Breadcrumb                                                       */
/* ------------------------------------------------------------------ */

.thw-breadcrumb__list {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-1) var(--space-2);
  margin: 0 0 var(--space-4);
  padding: 0;
  list-style: none;
}

.thw-breadcrumb__list > li {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  margin: 0;
  min-block-size: var(--target-min);
}

/* A drawn chevron, so no separator character is read aloud. */
.thw-breadcrumb__list > li + li::before {
  content: "";
  inline-size: var(--space-2);
  block-size: var(--space-2);
  border-block-start: var(--border-control) solid var(--muted-foreground);
  border-inline-end: var(--border-control) solid var(--muted-foreground);
  transform: rotate(45deg);
}

/* ------------------------------------------------------------------ */
/* 14 Pagination                                                       */
/* ------------------------------------------------------------------ */

.thw-pagination__list {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--target-gap);
  margin: 0 0 var(--space-6);
  padding: 0;
  list-style: none;
}

.thw-pagination__list > li {
  margin: 0;
}

.thw-pagination__link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-inline-size: var(--target-touch);
  min-block-size: var(--target-touch);
  padding-inline: var(--space-3);
  border: var(--border-control) solid transparent;
  border-radius: var(--radius-pill);
  font-weight: var(--weight-body-strong);
}

/* Current page: an edge and no underline as well as the tint. */
.thw-pagination__link[aria-current] {
  border-color: var(--accent-foreground);
  background: var(--accent);
  color: var(--accent-foreground);
  text-decoration: none;
}

/* ------------------------------------------------------------------ */
/* 15 Section navigation (the tabs alternative)                        */
/* ------------------------------------------------------------------ */

/* Threadwork does not use ARIA tabs by default. A tab set needs script for
   roving focus and arrow keys, hides content from find-in-page, and breaks
   without JavaScript. Instead each "tab" is a real page (or an htmx swap of
   <main> with a pushed URL), and this is a plain <nav> of links with
   aria-current="page". If everything must stay on one page, use headings
   or <details> (section 18). Only build ARIA tabs for a true in-page
   widget, following the ARIA Authoring Practices pattern in full. */
.thw-subnav__list {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1) var(--space-4);
  margin: 0 0 var(--space-6);
  padding: 0;
  border-block-end: var(--border-hairline) solid var(--border);
  list-style: none;
}

.thw-subnav__list > li {
  margin: 0;
}

.thw-subnav__link {
  display: inline-flex;
  align-items: center;
  min-block-size: var(--target-touch);
  padding-inline: var(--space-1);
  border-block-end: var(--border-emphasis) solid transparent;
  color: var(--muted-foreground);
  font-weight: var(--weight-body-strong);
  text-decoration: none;
}

.thw-subnav__link[aria-current] {
  border-block-end-color: var(--primary);
  color: var(--foreground);
}

@media (hover: hover) {
  .thw-subnav__link:hover {
    color: var(--foreground);
    text-decoration: underline;
  }
}

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

/* The ink block. Help and contact links live here, in the same order on
   every page of a surface (SC 3.2.6 Consistent Help). */
.thw-footer {
  margin-block-start: var(--space-16);
  padding-block: var(--space-10);
  background: var(--inverse);
  color: var(--inverse-foreground);
}

.thw-footer a {
  color: var(--inverse-accent);
}

.thw-footer .thw-muted {
  color: var(--inverse-muted-foreground);
}

.thw-footer .thw-cluster a {
  display: inline-flex;
  align-items: center;
  min-block-size: var(--target-touch);
}

/* ------------------------------------------------------------------ */
/* 17 Dialog                                                           */
/* ------------------------------------------------------------------ */

/* Use the native <dialog> element opened with showModal() (one line of
   script, or the declarative command/commandfor attributes where the
   browser supports them). Native modal dialogs trap focus, make the rest of
   the page inert, close on Esc and return focus to the opener: do not
   rebuild any of that. Give the dialog aria-labelledby pointing at its
   heading, put a visible Close button inside a <form method="dialog">, and
   keep the content short. If a task needs more than one decision, use a
   full page instead of a dialog. Without script, link to a confirmation
   page; the dialog is an enhancement. */
.thw-dialog {
  inline-size: min(100% - 2 * var(--screen-padding), 36rem);
  max-block-size: calc(100% - 2 * var(--screen-padding));
  padding: var(--space-6);
  border: var(--border-hairline) solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--popover);
  color: var(--popover-foreground);
  box-shadow: var(--shadow-overlay);
  overflow: auto;
}

.thw-dialog::backdrop {
  background: var(--backdrop);
}

.thw-dialog > :last-child,
.thw-dialog form > :last-child {
  margin-block-end: 0;
}

/* Shown in the page flow for documentation only (the preview). */
.thw-dialog--inline {
  position: static;
  margin: 0;
}

/* ------------------------------------------------------------------ */
/* 18 Details (disclosure)                                             */
/* ------------------------------------------------------------------ */

.thw-details {
  margin-block-end: var(--space-4);
  border-block-end: var(--border-hairline) solid var(--border);
}

.thw-details > summary {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-block-size: var(--target-touch);
  color: var(--link);
  font-weight: var(--weight-body-strong);
  text-decoration: underline;
  text-underline-offset: var(--space-1);
  cursor: pointer;
  list-style: none;
}

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

.thw-details > summary::before {
  content: "";
  flex: none;
  inline-size: var(--space-2);
  block-size: var(--space-2);
  border-block-end: var(--border-control) solid currentColor;
  border-inline-end: var(--border-control) solid currentColor;
  transform: rotate(-45deg);
  transition: transform var(--motion-fast) var(--ease);
}

.thw-details[open] > summary::before {
  transform: rotate(45deg);
}

.thw-details__body {
  padding-block: var(--space-2) var(--space-4);
}

/* ------------------------------------------------------------------ */
/* 19 Thread timeline                                                  */
/* ------------------------------------------------------------------ */

/* The home view of a child's record: one continuous thread with knots.
   Markup is an ordered list (<ol reversed> when newest is first). Each
   event is a <li class="thw-knot" data-strand="...">; school years are
   <li class="thw-thread__year">. The line and markers are decoration: the
   order, dates, strand names and both terms are all in the text.
   The thread runs top to bottom so that it reflows at 320px and at 400%
   zoom; see .thw-thread-strip for the left-to-right overview. */
.thw-thread {
  --thread-gutter: var(--space-10);
  --thread-surface: var(--background);
  position: relative;
  margin: 0 0 var(--space-6);
  padding: 0;
  list-style: none;
}

.thw-card .thw-thread {
  --thread-surface: var(--card);
}

.thw-thread > li {
  position: relative;
  max-inline-size: none;
  margin: 0;
  padding-block-end: var(--space-6);
  padding-inline-start: calc(var(--thread-gutter) + var(--space-3));
}

/* The thread itself: a border, so it survives print and forced colours. */
.thw-thread > li::before {
  content: "";
  position: absolute;
  inset-block: 0;
  inset-inline-start: calc((var(--thread-gutter) - var(--border-emphasis)) / 2);
  border-inline-start: var(--border-emphasis) solid var(--thread-line);
}

.thw-thread__year > * {
  margin: 0;
}

/* Knot: a ring tied on the thread, holding the strand's shape. */
.thw-knot__mark {
  position: absolute;
  inset-block-start: 0;
  inset-inline-start: calc((var(--thread-gutter) - var(--space-8)) / 2);
  display: grid;
  place-items: center;
  inline-size: var(--space-8);
  block-size: var(--space-8);
  border: var(--border-emphasis) solid var(--thread-line);
  border-radius: 50%;
  background: var(--thread-surface);
}

/* Stitch: a small everyday entry. No ring, just the strand shape. */
.thw-knot--stitch > .thw-knot__mark {
  inset-block-start: var(--space-1);
  inset-inline-start: calc((var(--thread-gutter) - var(--space-6)) / 2);
  inline-size: var(--space-6);
  block-size: var(--space-6);
  border-width: var(--border-control);
  border-color: var(--thread-surface);
}

.thw-knot[data-strand="teacher"] .thw-knot__mark > .thw-mark {
  border-radius: 50%;
}

.thw-knot[data-strand="sna"] .thw-knot__mark > .thw-mark {
  clip-path: inset(6%);
}

.thw-knot[data-strand="parent"] .thw-knot__mark > .thw-mark {
  clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%);
}

.thw-knot[data-strand="child"] .thw-knot__mark > .thw-mark {
  clip-path: polygon(50% 4%, 100% 96%, 0 96%);
}

.thw-knot__body > * {
  margin-block: 0;
}

.thw-knot__body > * + * {
  margin-block-start: var(--space-2);
}

.thw-knot__date {
  color: var(--muted-foreground);
  font-size: var(--text-meta);
  font-weight: var(--weight-meta);
  line-height: var(--leading-meta);
}

.thw-knot__title {
  font-size: var(--text-heading-sm);
  font-weight: var(--weight-heading-sm);
  line-height: var(--leading-heading-sm);
}

/* The heading holds the date and then the title, as two pieces of text, so
   that a list of headings reads "10 November 2026, Observation" and never
   the same title ten times (docs/ux/thread-and-year-flow.md, 5.3). */
.thw-knot__title > .thw-knot__date {
  display: block;
}

/* A link to the record's own page: 44px, alone on its line. */
.thw-knot__link,
.thw-thread-strip a,
.thw-thread__start {
  display: inline-flex;
  align-items: center;
  min-block-size: var(--target-touch);
}

/* Left-to-right overview of the school years (the brand motif). A short
   ordered list; it turns into a vertical list below md so nothing scrolls
   sideways. Current year: aria-current="true" plus the words "this year". */
.thw-thread-strip {
  display: flex;
  flex-direction: column;
  margin: 0 0 var(--space-6);
  padding: 0;
  list-style: none;
}

.thw-thread-strip > li {
  position: relative;
  flex: 1;
  max-inline-size: none;
  margin: 0;
  padding: 0 0 var(--space-4) var(--space-8);
  border-inline-start: var(--border-emphasis) solid var(--thread-line);
  font-size: var(--text-meta);
  font-weight: var(--weight-meta);
  line-height: var(--leading-meta);
}

.thw-thread-strip > li::before {
  content: "";
  position: absolute;
  inset-block-start: 0;
  inset-inline-start: calc((var(--space-4) + var(--border-emphasis)) / -2);
  inline-size: var(--space-4);
  block-size: var(--space-4);
  border: var(--border-emphasis) solid var(--thread-line);
  border-radius: 50%;
  background: var(--background);
}

.thw-thread-strip > li[aria-current]::before {
  background: var(--thread-line);
  forced-color-adjust: none;
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}

.thw-thread-strip > li[aria-current] {
  font-weight: var(--weight-body-strong);
}

/* "this year", in words, under the current year's link. */
.thw-thread-strip__now {
  display: block;
}

@media (min-width: 48em) {
  .thw-thread-strip {
    flex-direction: row;
  }

  .thw-thread-strip > li {
    padding: var(--space-5) var(--space-3) 0 0;
    border-inline-start: 0;
    border-block-start: var(--border-emphasis) solid var(--thread-line);
  }

  .thw-thread-strip > li::before {
    inset-block-start: calc((var(--space-4) + var(--border-emphasis)) / -2);
    inset-inline-start: 0;
  }
}

/* ------------------------------------------------------------------ */
/* 20 Bilingual term pair and language switch                          */
/* ------------------------------------------------------------------ */

/* "Snáth · Student Support File": the Threadwork term and the statutory
   term, always together, in titles, navigation and output headings.
   <span class="thw-term-pair">
     <span class="thw-term-pair__thread" lang="ga">Snáth</span>
     <span class="thw-term-pair__dot" aria-hidden="true">·</span>
     <span class="thw-term-pair__statutory">Student Support File</span>
   </span>
   Both terms are real text. The dot is hidden from screen readers. */
.thw-term-pair {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0 var(--space-2);
}

.thw-term-pair__thread {
  font-weight: var(--weight-body-strong);
}

.thw-term-pair__dot {
  color: var(--muted-foreground);
}

/* In body text and meta lines the statutory term is quieter; inside a
   heading both terms keep the heading's own colour and weight. */
p .thw-term-pair__statutory,
li > .thw-term-pair > .thw-term-pair__statutory {
  color: var(--muted-foreground);
}

h1 .thw-term-pair__statutory,
h2 .thw-term-pair__statutory,
h3 .thw-term-pair__statutory,
h4 .thw-term-pair__statutory {
  font-weight: var(--weight-body-lg);
}

/* Language switch: two links named in their own language, each with lang. */
.thw-lang-switch {
  display: inline-flex;
  gap: var(--target-gap);
  margin: 0;
  padding: 0;
  list-style: none;
}

.thw-lang-switch > li {
  margin: 0;
}

.thw-lang-switch a {
  display: inline-flex;
  align-items: center;
  min-block-size: var(--target-touch);
  padding-inline: var(--space-2);
  color: var(--foreground);
  font-weight: var(--weight-body-strong);
}

.thw-lang-switch a[aria-current] {
  text-decoration-thickness: var(--border-emphasis);
}

/* ------------------------------------------------------------------ */
/* 21 Child-voice choices                                              */
/* ------------------------------------------------------------------ */

/* Large picture-and-word choices for the "My views" form. Each choice is a
   real radio or checkbox followed by its <label>:
   <div class="thw-symbol-choice">
     <input class="thw-symbol-choice__input" type="radio" name="..." id="x">
     <label class="thw-symbol-choice__label" for="x">
       <svg class="thw-symbol-choice__symbol" aria-hidden="true">...</svg>
       <span>Reading</span>
     </label>
   </div>
   The word is always shown with the symbol. Selected = thick edge and a
   tick, not just a tint. */
.thw-symbol-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 9rem), 1fr));
  gap: var(--space-4);
}

.thw-symbol-choice {
  position: relative;
}

.thw-symbol-choice__input {
  position: absolute;
  inset-block-start: var(--space-3);
  inset-inline-end: var(--space-3);
  appearance: none;
  -webkit-appearance: none;
  display: grid;
  place-content: center;
  inline-size: var(--checkbox-size);
  block-size: var(--checkbox-size);
  margin: 0;
  border: var(--border-control) solid var(--input);
  border-radius: 50%;
  background: var(--background);
  color: var(--primary-foreground);
  pointer-events: none;
}

.thw-symbol-choice__input::before {
  content: "";
  inline-size: var(--space-3);
  block-size: var(--space-3);
  background: currentColor;
  clip-path: polygon(14% 52%, 0 66%, 38% 100%, 100% 22%, 86% 10%, 37% 70%);
  transform: scale(0);
}

.thw-symbol-choice__input:checked {
  border-color: var(--primary);
  background: var(--primary);
}

.thw-symbol-choice__input:checked::before {
  transform: scale(1);
}

.thw-symbol-choice__label {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  min-block-size: calc(var(--space-16) * 2);
  padding: var(--space-5) var(--space-4);
  border: var(--border-control) solid var(--input);
  border-radius: var(--radius-lg);
  background: var(--background);
  color: var(--foreground);
  font-size: var(--text-body-lg);
  font-weight: var(--weight-body-strong);
  line-height: var(--leading-heading-sm);
  text-align: center;
  cursor: pointer;
}

.thw-symbol-choice__symbol {
  inline-size: var(--space-16);
  block-size: var(--space-16);
}

.thw-symbol-choice__input:checked + .thw-symbol-choice__label {
  border-width: var(--border-emphasis);
  border-color: var(--primary);
  background: var(--accent);
  color: var(--accent-foreground);
}

/* The focus indicator goes round the whole card, not the small control. */
.thw-symbol-choice__input:focus-visible {
  outline: none;
  box-shadow: none;
}

.thw-symbol-choice__input:focus-visible + .thw-symbol-choice__label {
  outline: var(--focus-ring-width) solid var(--focus-ring);
  outline-offset: var(--focus-halo-width);
  box-shadow: 0 0 0 var(--focus-halo-width) var(--focus-halo);
}

@media (forced-colors: active) {
  .thw-symbol-choice__input {
    appearance: auto;
    -webkit-appearance: auto;
  }

  .thw-symbol-choice__input::before {
    display: none;
  }
}

/* ------------------------------------------------------------------ */
/* 22 Print                                                            */
/* ------------------------------------------------------------------ */

/* A4, black on white (the page size, margin and print colours come from
   threadwork.css). Built for the one-page handover summary: wrap it in
   <article class="thw-print-page">. Add class="thw-no-print" to anything
   that is only useful on screen. */
@media print {
  html {
    font-size: var(--print-font-size);
  }

  body {
    line-height: var(--print-line-height);
  }

  .thw-no-print,
  .thw-skip-link,
  .thw-header nav,
  .thw-footer,
  .thw-breadcrumb,
  .thw-pagination,
  .thw-subnav,
  .thw-button,
  .thw-icon-button,
  .thw-lang-switch,
  dialog:not([open]) {
    display: none !important;
  }

  .thw-container {
    max-inline-size: none;
    padding-inline: 0;
  }

  h1,
  .thw-h1 {
    font-size: var(--print-heading-lg);
    letter-spacing: 0;
  }

  h2,
  .thw-h2 {
    font-size: var(--print-heading-md);
  }

  h3,
  .thw-h3,
  h4,
  .thw-h4,
  .thw-knot__title {
    font-size: var(--print-heading-sm);
  }

  small,
  .thw-meta,
  .thw-knot__date,
  .thw-tag,
  .thw-strand,
  .thw-continuum {
    font-size: var(--print-meta);
  }

  h1,
  h2,
  h3,
  h4 {
    break-after: avoid;
  }

  p,
  li {
    max-inline-size: none;
    orphans: 3;
    widows: 3;
  }

  /* Links are printed as plain text; the address of a signed-in page is no
     use on paper and must not leak. */
  a {
    color: inherit;
    text-decoration: none;
  }

  /* Surfaces become outlines: tints do not print reliably. */
  .thw-card,
  .thw-alert,
  .thw-error-summary,
  .thw-tag,
  .thw-strand,
  .thw-continuum,
  .thw-hero {
    border: var(--print-rule) solid var(--foreground);
    border-radius: 0;
    background: none;
    color: var(--foreground);
  }

  .thw-card,
  .thw-alert,
  .thw-knot,
  .thw-voice,
  .thw-summary-list__row,
  .thw-table tr {
    break-inside: avoid;
  }

  .thw-card,
  .thw-alert {
    margin-block-end: var(--print-block-gap);
    padding: var(--print-block-gap);
  }

  .thw-thread > li {
    padding-block-end: var(--print-block-gap);
  }

  .thw-table thead {
    display: table-header-group;
  }

  .thw-table-wrap {
    overflow: visible;
  }

  .thw-table thead th,
  .thw-table th,
  .thw-table td {
    border-block-end: var(--print-rule) solid var(--foreground);
    background: none;
  }

  .thw-summary-list__row {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: var(--print-block-gap);
    padding-block: calc(var(--print-block-gap) / 2);
    border-block-end: var(--print-rule) solid var(--foreground);
  }

  /* One page: tighter rhythm, nothing forced onto a second sheet. */
  .thw-print-page {
    --stack-gap: var(--print-block-gap);
  }

  .thw-print-page h1,
  .thw-print-page h2,
  .thw-print-page h3,
  .thw-print-page p,
  .thw-print-page ul,
  .thw-print-page ol,
  .thw-print-page dl {
    margin-block-end: calc(var(--print-block-gap) / 2);
  }
}

/* ------------------------------------------------------------------ */
/* 23 Authenticator set-up and backup codes (F-061)                    */
/* ------------------------------------------------------------------ */

/* The square code an authenticator app scans: dark squares on paper in
   every theme (an app may not read a light-on-dark code), with the
   quiet zone drawn by the padding. The SVG fills with currentColor. */
.thw-square-code {
  display: block;
  inline-size: 100%;
  max-inline-size: 16rem;
  padding: var(--space-4);
  background: var(--print-paper);
  color: var(--print-ink);
  border: 1px solid var(--border);
}

.thw-square-code svg {
  display: block;
  inline-size: 100%;
  block-size: auto;
}

/* A key or codes to copy by hand: fixed-width, grouped, never broken
   across lines. */
.thw-code-text {
  font-family: var(--font-mono);
  overflow-wrap: anywhere;
}

.thw-code-list {
  display: grid;
  grid-template-columns: repeat(2, max-content);
  gap: var(--space-2) var(--space-8);
  padding: 0;
  list-style: none;
  font-family: var(--font-mono);
  font-size: var(--text-body-lg);
}

/* Only on paper: the heading and lines of a print made from a screen
   page (the backup codes print has no address of its own). */
.thw-print-only {
  display: none;
}

@media print {
  .thw-print-only {
    display: block !important;
  }

  .thw-square-code {
    border: 0;
  }
}
