/*
 * Local Shift Wales: the one stylesheet.
 *
 * Colours come only from the token block below, copied from the Async Digital
 * brand stylesheet, which wins on any conflict. The page copies them instead
 * of linking that stylesheet so it makes no network request but the figures.
 * If the brand stylesheet changes a value, copy it here.
 *
 * The page follows the system appearance: each token is a light-dark() pair,
 * and color-scheme is "light dark" on screen. Print stays light, as in the
 * brand stylesheet, because browsers drop backgrounds when printing.
 */

/* ---------- Tokens ---------- */

/* Plain light values first, for a browser that does not know light-dark(). */
:root {
  --primary: #8B3A2A;
  --accent: #2A3A4A;
  --bg: #FDFBF7;
  --card: #F8F5EE;
  --border: #E8E4DC;
  --text: #1F1C18;
  --muted: #6B6560;
  --well: #F1ECE2;
  --border-strong: #CDC5B7;
  --primary-tint: #F1EAE2;
  --primary-border: #C3A095;

  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --size-h2: 20px;
  --size-h3: 16px;
  --size-intro: 19px;
  --size-body: 16px;
  --size-small: 14px;
  --lh-tight: 1.12;
  --lh-snug: 1.3;
  --lh-normal: 1.4;
  --lh-relaxed: 1.55;
  --weight-medium: 600;
  --weight-bold: 700;
  --radius: 10px;
  --radius-lg: 16px;
  --radius-pill: 999px;
  --wrap: 960px;
  --focus-ring: 3px solid color-mix(in srgb, var(--primary) 70%, transparent);
  --focus-offset: 3px;
}

@supports (color: light-dark(#000, #fff)) {
  :root {
    --primary: light-dark(#8B3A2A, #E0907B);
    --accent: light-dark(#2A3A4A, #9DB1C6);
    --bg: light-dark(#FDFBF7, #1B1916);
    --card: light-dark(#F8F5EE, #24211D);
    --border: light-dark(#E8E4DC, #3A352F);
    --text: light-dark(#1F1C18, #EFE9E0);
    --muted: light-dark(#6B6560, #ABA298);
    --well: light-dark(#F1ECE2, #1A1815);
    --border-strong: light-dark(#CDC5B7, #5C544A);
    --primary-tint: light-dark(#F1EAE2, #382821);
    --primary-border: light-dark(#C3A095, #774336);
  }
  @media screen {
    :root { color-scheme: light dark; }
    :root[data-theme="dark"] { color-scheme: dark; }
  }
}

/* ---------- Base ---------- */

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  padding-bottom: 48px;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: var(--size-body);
  line-height: var(--lh-relaxed);
  overflow-wrap: break-word;
}
h1, h2, h3, p { margin: 0; }
/* Links are body colour with a muted underline; the underline darkens on hover. */
a { color: var(--text); text-decoration-line: underline; text-decoration-color: var(--muted); text-underline-offset: 3px; }
a:hover { text-decoration-color: var(--text); text-decoration-thickness: 2px; }
:focus-visible { outline: var(--focus-ring); outline-offset: var(--focus-offset); }
summary { cursor: pointer; }
[hidden] { display: none !important; }
strong { font-weight: var(--weight-medium); }

/* Read by screen readers, not shown. */
.vh {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}
.small { font-size: var(--size-small); color: var(--muted); margin-top: 2px; }

/* ---------- Header and footer ---------- */

.top { border-bottom: 1px solid var(--border); }
.top__bar {
  max-width: var(--wrap); margin: 0 auto; padding: 12px 16px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
}
.top__logo { display: inline-flex; align-items: center; min-height: 44px; }
.top__logo img { height: 40px; width: auto; display: block; }
.lang-switch a {
  display: inline-flex; align-items: center; min-height: 44px; min-width: 44px;
  padding: 0 4px; font-weight: var(--weight-medium);
}
/* The footer rule spans the content width, not the padded section width. */
.ftr {
  width: calc(100% - 32px); max-width: calc(var(--wrap) - 32px); margin: 56px auto 0; padding: 24px 0 0;
  border-top: 1px solid var(--border);
  display: flex; flex-wrap: wrap; gap: 12px 24px; align-items: center; justify-content: space-between;
  font-size: var(--size-small); color: var(--muted);
}
/* Short stacked paragraphs: maker, mistake, privacy, company details. */
.ftr__text { flex: 1 1 32ch; max-width: 68ch; display: flex; flex-direction: column; gap: 8px; }
.ftr__text p:empty { display: none; }
.ftr__link { display: inline-flex; align-items: center; min-height: 44px; }

/* ---------- Sections ---------- */

.sec { max-width: var(--wrap); margin: 0 auto; padding: 40px 16px 0; }
.sec--wide { padding-top: 56px; }
.sec h2 { font-size: var(--size-h2); line-height: var(--lh-snug); font-weight: var(--weight-medium); }
.lead { margin-top: 8px; max-width: 68ch; }
.note { margin-top: 12px; font-size: var(--size-small); color: var(--muted); max-width: 68ch; }
.status { padding-top: 32px; color: var(--muted); }
/* The failure message is in body colour, so it reads as text and not as a hint. */
.status.is-failed { color: var(--text); }

/* ---------- Hero ---------- */

.eyebrow { margin-bottom: 12px; font-size: var(--size-small); font-weight: var(--weight-medium); color: var(--muted); }
.hero h1 { font-size: clamp(30px, 4vw, 44px); line-height: var(--lh-tight); font-weight: var(--weight-bold); max-width: 24ch; }
.intro { margin-top: 16px; font-size: var(--size-intro); max-width: 60ch; }
.picker { margin-top: 24px; display: flex; flex-direction: column; gap: 8px; max-width: 440px; }
.picker label { font-weight: var(--weight-medium); }
.picker select {
  font: inherit; font-size: 18px; min-height: 52px; width: 100%;
  padding: 10px 14px; border: 1px solid var(--border-strong); border-radius: var(--radius);
  background: var(--card); color: var(--text);
}

/* ---------- Answer card ---------- */

#answer { padding-top: 28px; }
.answer {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: clamp(20px, 3vw, 36px); display: flex; flex-direction: column; gap: 20px;
}
.answer__head { display: flex; flex-direction: column; gap: 8px; }
.answer__meta { font-size: var(--size-small); color: var(--muted); }
.answer h2 { font-size: clamp(28px, 3.4vw, 40px); line-height: 1.15; font-weight: var(--weight-bold); }
.answer__body { display: flex; flex-wrap: wrap; gap: 24px 40px; align-items: flex-start; }
.answer__text { flex: 1 1 300px; min-width: 0; display: flex; flex-direction: column; gap: 16px; }
.answer__sentence { font-size: var(--size-intro); }
.answer__change { font-weight: var(--weight-medium); }
.answer__key { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; font-size: var(--size-small); line-height: 1.5; }
.answer__key li { display: flex; gap: 10px; align-items: flex-start; }
.answer__note { padding-top: 16px; border-top: 1px solid var(--border); font-size: var(--size-small); color: var(--muted); }
/* The link in the note gets a 44px tall touch target without moving any text:
   inline-block keeps it on one line, the padding makes the tap area 44px tall,
   and the equal negative margin stops the padding from pushing the lines apart. */
.answer__note a, .answer__key a { display: inline-block; min-height: 44px; box-sizing: border-box; padding-block: 11px; margin-block: -11px; }

/* The small card swatches in keys and headings. */
.chip { flex: 0 0 auto; width: 12px; height: 15px; margin-top: 3px; border-radius: 2px; }
.chip--fill { background: var(--primary); }
/* The outline mark as the boards draw it: a brick edge and a ring in the colour
   behind it (the key sits on the card), over half brick and half grey, because
   the mark can sit on either fill. */
.chip--out {
  border: 1.5px solid var(--primary); box-shadow: inset 0 0 0 1.5px var(--card);
  background: linear-gradient(90deg, var(--primary) 50%, var(--border-strong) 50%);
}
.chip--rest { background: var(--border-strong); }
.chip--navy { width: 12px; height: 12px; margin-top: 0; border-radius: var(--radius-pill); background: var(--accent); }

/* The two boards. */
.boards { flex: 1 1 440px; min-width: 0; display: flex; align-items: stretch; gap: clamp(8px, 1.6vw, 16px); }
.board { margin: 0; flex: 1 1 0; min-width: 0; max-width: 260px; display: flex; flex-direction: column; }
.board figcaption { margin-bottom: 8px; font-size: var(--size-small); font-weight: var(--weight-medium); flex: 1 0 auto; }
.board__frame { padding: clamp(8px, 1.2vw, 12px); background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); }
.board__svg { display: block; width: 100%; height: auto; overflow: visible; }
.card--fill { fill: var(--primary); }
.card--rest { fill: var(--border-strong); }
/* A square in the chance range keeps its fill and gains the outline mark: a
   brick edge, and an inner ring in the board's background colour (--bg, the
   frame behind the squares), so the mark shows on brick squares too. */
.card--range { stroke: var(--primary); stroke-width: 1.5px; vector-effect: non-scaling-stroke; }
.card__ring { fill: none; stroke: var(--bg); stroke-width: 1.2px; vector-effect: non-scaling-stroke; }
.board__count { margin-top: 10px; font-size: clamp(15px, 1.8vw, 18px); font-weight: var(--weight-bold); line-height: 1.3; }
.boards__arrow { flex: 0 0 auto; align-self: center; color: var(--muted); }
.boards__arrow svg { display: block; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- What this shows ---------- */

.tiles {
  list-style: none; margin: 16px 0 0; padding: 0;
  display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 400px), 1fr)); gap: 12px;
}
.tile { display: flex; gap: 14px; align-items: flex-start; padding: 16px; border: 1px solid var(--border); border-radius: var(--radius-lg); }
.icon { flex: 0 0 auto; fill: none; stroke: var(--text); stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- Keys ---------- */

.legend { list-style: none; margin: 16px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px 24px; font-size: var(--size-small); line-height: var(--lh-normal); }
.legend li { display: flex; gap: 8px; align-items: center; }
.legend--big { gap: 8px 28px; font-size: var(--size-body); font-weight: var(--weight-bold); }
.mk { flex: 0 0 auto; display: inline-block; }
.mk--open, .mk--open-ink, .mk--full, .mk--full-ink { width: 12px; height: 12px; border-radius: var(--radius-pill); }
.mk--open { background: var(--bg); border: 2.5px solid var(--primary); }
.mk--full { background: var(--primary); }
.mk--open-ink { border: 2px solid var(--text); }
.mk--full-ink { background: var(--text); }
.mk--line { width: 24px; height: 3px; border-radius: 2px; background: var(--primary); }
.mk--band { width: 24px; height: 12px; border-radius: 3px; background: var(--primary-tint); border: 1px solid var(--primary-border); }
.mk--src { width: 24px; height: 12px; background: color-mix(in srgb, var(--muted) 10%, transparent); border-left: 1px dashed var(--muted); border-right: 1px dashed var(--muted); }
.mk--dash { width: 24px; height: 0; border-top: 3px dashed var(--primary); }
.mk--rowband { width: 24px; height: 12px; border-radius: 3px; background: var(--well); border: 1px solid var(--border-strong); }
.badge {
  display: inline-block; margin-left: 0; padding: 0 8px; border-radius: var(--radius-pill);
  border: 1px solid var(--border-strong); font-size: 12px; font-weight: var(--weight-medium);
  line-height: 18px; color: var(--muted); vertical-align: 1px;
}
.badge--key { margin-left: 0; flex: 0 0 auto; }

/* ---------- Year by year chart ---------- */

.lc { margin: 24px 0 0 44px; }
.lc__plot { position: relative; height: 260px; }
.lc__layer { position: absolute; inset: 0; }
.lc__tick { position: absolute; left: 0; right: 0; border-top: 1px solid var(--border); }
.lc__tick span {
  position: absolute; right: calc(100% + 8px); top: -10px;
  font-size: 13px; line-height: 20px; color: var(--muted); white-space: nowrap;
}
.lc__src {
  position: absolute; top: 0; bottom: 0;
  /* A grey wash mixed from the muted ink, so the stretch stays visible on the
     page in dark mode and stays distinct from the warm band in light mode. */
  background: color-mix(in srgb, var(--muted) 10%, transparent);
  border-left: 1px dashed var(--muted); border-right: 1px dashed var(--muted);
}
/* The band's label sits on one line, starting 6px inside the band's left
   edge and free to run past its right edge. It spans the plot as a flex row:
   the spacer <i> asks for the band's left offset but may shrink, so when the
   label would pass the chart's right side the spacer gives way and the label
   ends 6px inside that side instead. */
.lc__srclabel { position: absolute; top: 6px; left: 0; right: 6px; display: flex; pointer-events: none; }
.lc__srclabel i { flex: 0 1 calc(var(--src-left) + 6px); min-width: 0; }
.lc__srclabel span {
  flex: none; white-space: nowrap; overflow-wrap: normal; word-break: keep-all;
  font-size: 12px; line-height: 1.3; color: var(--muted);
}
.lc__svg { position: absolute; left: 0; top: 0; width: 100%; height: 100%; overflow: visible; }
.lc__band { fill: var(--primary-tint); stroke: var(--primary-border); stroke-width: 1px; vector-effect: non-scaling-stroke; }
.lc__line { fill: none; stroke: var(--primary); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.lc__line--dash { stroke-dasharray: 5 4; stroke-linecap: butt; }
.lc__years { position: relative; height: 28px; border-top: 1px solid var(--border-strong); }
.lc__years span { position: absolute; top: 6px; transform: translateX(-50%); font-size: 13px; color: var(--muted); }
/* On a narrow screen the label is wider than the shaded stretch, so the
   stretch's dashed right edge would cross it. Lift the label above the plot
   and make room for it there. */
@media (max-width: 480px) {
  .lc__plot { margin-top: 20px; }
  .lc__srclabel { top: -20px; }
}

/* ---------- Folds (details) ---------- */

.fold { border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.fold--list { margin-top: 16px; }
.fold summary { padding: 12px 0; font-weight: var(--weight-medium); min-height: 44px; }
#kinds .fold summary, .fold--method summary { padding: 14px 0; }
.figlist { margin: 0 0 16px; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; font-variant-numeric: tabular-nums; }
.method { margin-top: 12px; border-top: 1px solid var(--border); }
.fold--method { border-top: 0; }
.fold--method p { margin: 0 0 16px; max-width: 68ch; }

/* ---------- Tracks: dots on a shared scale ---------- */

.track { position: relative; height: 28px; flex: 1 1 170px; min-width: 150px; }
.track__base { position: absolute; left: 0; right: 0; top: 13px; height: 2px; background: var(--border); }
.track__band { position: absolute; top: 6px; height: 16px; min-width: 4px; border-radius: 4px; background: var(--band-bg); border: 1px solid var(--band-bd); }
.track__seg { position: absolute; top: 13px; height: 2px; background: var(--ink); opacity: var(--op, 1); }
.dot { position: absolute; top: 14px; width: 12px; height: 12px; margin: -6px 0 0 -6px; border-radius: var(--radius-pill); opacity: var(--op, 1); }
.dot--open { background: var(--bg); border: 2px solid var(--ink); }
.dot--full { background: var(--ink); }
.dot--chart { --ink: var(--primary); }
.dot--chart.dot--open { border-width: 2.5px; }

/* ---------- Kinds of job ---------- */

.kh { margin-top: 28px; font-size: var(--size-h3); line-height: var(--lh-normal); font-weight: var(--weight-medium); display: flex; gap: 10px; align-items: flex-start; }
/* The chip lines up with the first line of a heading that wraps. */
.kh .chip--fill { margin-top: 4px; }
.kh .chip--navy { margin-top: 5px; }
.krows { margin-top: 8px; }
.krows--mid { margin-top: 0; padding-bottom: 8px; }
.krows--last { border-bottom: 1px solid var(--border); }
.krow { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 24px; padding: 14px 0; border-top: 1px solid var(--border); }
.krow--top { --ink: var(--primary); --band-bg: var(--primary-tint); --band-bd: var(--primary-border); }
.krow--rest { --ink: var(--accent); --band-bg: var(--well); --band-bd: var(--border-strong); }
.krow.is-soft { --op: 0.75; }
.krow.is-soft .track__band { border-style: dashed; }
.krow__label { flex: 1 1 300px; min-width: 0; }
.krow__title { font-weight: var(--weight-medium); line-height: var(--lh-normal); }
.krow__vals { flex: 0 0 150px; }
.fromto { font-weight: var(--weight-medium); font-variant-numeric: tabular-nums; white-space: nowrap; }
.krow__soft { flex: 1 1 100%; margin-top: 0; }

/* ---------- Rest of Wales ---------- */

.wrows { margin-top: 16px; border-bottom: 1px solid var(--border); }
.wrow {
  display: flex; flex-wrap: wrap; align-items: center; gap: 4px 16px; padding: 10px 12px;
  border-top: 1px solid var(--border); --ink: var(--primary);
}
.wrow.is-selected { background: var(--card); outline: 1px solid var(--border-strong); outline-offset: -1px; border-radius: var(--radius); }
.wrow__name { flex: 1 1 140px; min-width: 0; }
.wrow.is-selected .wrow__name { font-weight: var(--weight-bold); }
.wrow__vals { flex: 0 0 132px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.track--w { flex: 1 1 180px; height: 22px; order: 3; }
.track--w .track__base, .track--w .track__seg { top: 10px; }
.track--w .dot { top: 11px; }
.wrow__word { flex: 0 0 116px; order: 4; margin-top: 0; }

/* ---------- Sources ---------- */

.sources { margin: 12px 0 0; padding-left: 20px; display: flex; flex-direction: column; gap: 10px; max-width: 72ch; }
