/* ---------------------------------------------------------------------------
   Shared stylesheet for the secondary pages: /work/*, /uses.html, /404.html.
   index.html deliberately stays self-contained — it is the page that has to
   paint in one round trip. Everything behind it can afford a second request,
   and three copies of 300 lines of CSS is a worse problem than one GET.
   Tokens are the same names index.html uses, so markup ports between them.
   --------------------------------------------------------------------------- */

:root, :root[data-theme="dark"] {
  --bg:        #0a0f16;
  --bg-elev:   #111a24;
  --bg-elev-2: #16212e;
  --border:    #1f2d3d;
  --text:      #d6e0ec;
  --strong:    #f0f6fc;
  --muted:     #8c9db3;
  /* See index.html: --dim carries the smallest text, so it clears 4.5:1
     against the darkest card it sits on, not just against the page. */
  --dim:       #7a8ba1;
  --accent:    #38bdf8;
  --accent-2:  #22d3ee;
  --accent-3:  #a78bfa;
  --warn:      #f0b849;
  --ok:        #4ade80;
  --on-accent: #06131c;
  --glow-1:    rgba(56, 189, 248, 0.14);
  --glow-2:    rgba(34, 211, 238, 0.10);
  --shadow:    0 10px 30px rgba(0, 0, 0, 0.35);
}

:root[data-theme="light"] {
  --bg:        #f7f9fc;
  --bg-elev:   #ffffff;
  --bg-elev-2: #eef3f9;
  --border:    #d8e1ec;
  --text:      #26313f;
  --strong:    #0d1620;
  --muted:     #55647a;
  --dim:       #5f6d80;
  --accent:    #0a6f9a;
  --accent-2:  #0f6a7c;
  --accent-3:  #6d4fc4;
  --warn:      #8a5a08;
  --ok:        #16803c;
  --on-accent: #ffffff;
  --glow-1:    rgba(10, 111, 154, 0.10);
  --glow-2:    rgba(15, 106, 124, 0.07);
  --shadow:    0 10px 30px rgba(18, 39, 62, 0.08);
}

:root { --radius: 10px; --maxw: 780px; }

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { animation: none !important; transition: none !important; }
}

body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 17px; line-height: 1.75; -webkit-font-smoothing: antialiased;
}
body::before {
  content: ""; position: fixed; inset: 0 0 auto 0; height: 520px; pointer-events: none; z-index: 0;
  background:
    radial-gradient(900px 400px at 20% -10%, var(--glow-1), transparent 70%),
    radial-gradient(700px 360px at 84% -14%, var(--glow-2), transparent 70%);
}
.wrap { position: relative; z-index: 1; max-width: var(--maxw); margin: 0 auto; padding: 0 22px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }

/* Underlined by default — colour alone is not an accessible affordance. Things
   that look interactive because of their shape opt out. */
a { color: var(--accent); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }
.skip, .brand, .navlink, .next a, .links a { text-decoration: none; }
.skip:hover, .brand:hover, .navlink:hover, .next a:hover, .links a:hover { text-decoration: none; }
a:focus-visible, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }
.skip { position: absolute; left: -9999px; background: var(--accent); color: var(--on-accent); padding: 10px 16px; font-weight: 600; }
.skip:focus { left: 0; top: 0; z-index: 100; }

/* --- nav ------------------------------------------------------------------ */
nav {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(10px); border-bottom: 1px solid var(--border);
}
nav .wrap { display: flex; align-items: center; gap: 6px; height: 58px; max-width: 920px; }
.brand { font-weight: 700; letter-spacing: .06em; text-transform: uppercase; font-size: 14px; color: var(--text); margin-right: auto; }
.brand span { color: var(--accent); }
nav a.navlink { color: var(--muted); font-size: 14px; padding: 7px 11px; border-radius: 7px; white-space: nowrap; }
nav a.navlink:hover { color: var(--text); background: var(--bg-elev-2); text-decoration: none; }
.theme-toggle {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; margin-left: 4px; flex: none;
  background: transparent; border: 1px solid var(--border); border-radius: 8px;
  color: var(--muted); cursor: pointer; transition: color .15s, border-color .15s, background .15s;
}
.theme-toggle:hover { color: var(--accent); border-color: var(--accent); background: var(--bg-elev-2); }
.theme-toggle .moon { display: none; }
:root[data-theme="light"] .theme-toggle .moon { display: block; }
:root[data-theme="light"] .theme-toggle .sun  { display: none; }

/* --- article -------------------------------------------------------------- */
header.page { padding: 58px 0 8px; }
.crumb { font-size: 13px; color: var(--dim); margin: 0 0 20px; letter-spacing: .02em; }
.crumb a { color: var(--muted); }
h1 { font-size: clamp(1.9rem, 5vw, 2.7rem); line-height: 1.12; margin: 0 0 16px; letter-spacing: -.02em; color: var(--strong); }
.standfirst { font-size: 1.13rem; color: var(--muted); margin: 0; }

.facts {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px; margin: 32px 0 0;
}
.fact { background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; }
.fact .k { font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--dim); }
.fact .v { font-size: .95rem; color: var(--strong); font-weight: 600; margin-top: 2px; line-height: 1.4; }

main { padding: 10px 0 20px; }
h2 {
  font-size: 13px; font-weight: 700; letter-spacing: .18em; text-transform: uppercase;
  color: var(--accent); margin: 48px 0 20px; display: flex; align-items: center; gap: 13px;
}
h2::after { content: ""; flex: 1; height: 1px; background: var(--border); }
h3 { font-size: 1.06rem; font-weight: 650; color: var(--strong); margin: 30px 0 8px; }
p { margin: 0 0 18px; }
ul, ol { margin: 0 0 18px; padding-left: 22px; }
li { margin-bottom: 9px; }
li::marker { color: var(--dim); }
strong { color: var(--strong); font-weight: 650; }
.muted { color: var(--muted); }

blockquote {
  margin: 24px 0; padding: 2px 0 2px 18px; border-left: 2px solid var(--accent);
  color: var(--muted); font-size: 1.02rem;
}

pre {
  background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 15px 17px; overflow-x: auto; font-size: 13px; line-height: 1.65; margin: 0 0 20px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; color: var(--text);
}
code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .88em; }
p > code, li > code, td > code {
  background: var(--bg-elev-2); border: 1px solid var(--border);
  padding: 1px 5px; border-radius: 4px; color: var(--text);
}
pre .c { color: var(--dim); }
pre .k { color: var(--accent); }
pre .s { color: var(--accent-2); }

/* --- figures / diagrams --------------------------------------------------- */
figure { margin: 28px 0; }
figure .frame {
  background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px 16px; overflow-x: auto;
}
figure svg { display: block; width: 100%; height: auto; min-width: 520px; }
figcaption { margin-top: 10px; font-size: 13.5px; color: var(--dim); line-height: 1.6; }

/* Diagram primitives, so all three drawings share one visual language. */
.d-box   { fill: var(--bg-elev-2); stroke: var(--border); stroke-width: 1; }
.d-box-a { fill: color-mix(in srgb, var(--accent) 12%, transparent); stroke: var(--accent); stroke-width: 1; }
.d-box-w { fill: color-mix(in srgb, var(--warn) 12%, transparent); stroke: var(--warn); stroke-width: 1; }
.d-zone  { fill: none; stroke: var(--border); stroke-width: 1; stroke-dasharray: 4 4; }
.d-t     { fill: var(--text); font-size: 12px; font-family: ui-sans-serif, system-ui, sans-serif; }
.d-t-s   { fill: var(--dim); font-size: 10.5px; font-family: ui-monospace, Menlo, monospace; }
.d-t-h   { fill: var(--muted); font-size: 10px; font-family: ui-sans-serif, system-ui, sans-serif;
           letter-spacing: .12em; text-transform: uppercase; }
.d-line  { stroke: var(--dim); stroke-width: 1.2; fill: none; }
.d-line-a{ stroke: var(--accent); stroke-width: 1.4; fill: none; }
.d-line-d{ stroke: var(--dim); stroke-width: 1.2; fill: none; stroke-dasharray: 4 3; }

/* --- outcome / takeaway --------------------------------------------------- */
.callout {
  background: var(--bg-elev); border: 1px solid var(--border); border-left: 3px solid var(--accent);
  border-radius: var(--radius); padding: 18px 20px; margin: 28px 0;
}
.callout h3 { margin: 0 0 8px; font-size: 12px; letter-spacing: .14em; text-transform: uppercase; color: var(--accent); }
.callout p:last-child { margin-bottom: 0; }
.callout ul { margin-bottom: 0; }

.tags { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; color: var(--dim); }

.next {
  display: flex; flex-wrap: wrap; gap: 12px; margin: 48px 0 0;
  padding-top: 26px; border-top: 1px solid var(--border);
}
.next a {
  flex: 1 1 240px; padding: 14px 16px; background: var(--bg-elev);
  border: 1px solid var(--border); border-radius: var(--radius); color: var(--text);
  transition: border-color .15s, transform .15s;
}
.next a:hover { text-decoration: none; border-color: var(--accent); transform: translateY(-1px); }
.next a .k { display: block; font-size: 10.5px; letter-spacing: .12em; text-transform: uppercase; color: var(--dim); margin-bottom: 3px; }
.next a .v { font-weight: 600; color: var(--strong); font-size: .97rem; }

footer { border-top: 1px solid var(--border); padding: 30px 0 46px; margin-top: 40px; }
footer .wrap { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; max-width: 920px; color: var(--dim); font-size: 13.5px; }
footer .right { margin-left: auto; }
