/* ==========================================================================
   Field Letter Press: shared interface layer (adopted 16 November 2026)
   Loaded after site.css and landing.css on every page by gen/ui.py.
   Ten techniques, one stylesheet, brand tokens left as they were:
     1 concentric radii        2 alpha borders        3 OKLCH palette
     4 OKLCH gradients         5 matched icon weight  6 masked edges
     7 blurred icon swaps      8 dark-surface depth   9 dynamic viewport units
    10 multiply blending (evaluated; see section 10)
   The publication stays near-square and paper-led. Nothing here adds a theme,
   a new colour or a new component.
   ========================================================================== */

@property --fl { syntax: '<length>'; inherits: false; initial-value: 0px; }
@property --fr { syntax: '<length>'; inherits: false; initial-value: 0px; }

/* ---------- 0. tokens ---------- */
:root {
  /* motion */
  --dur-fast: 120ms;
  --dur-base: 180ms;
  --dur-swap: 200ms;
  --ease-out: cubic-bezier(.2, .7, .2, 1);

  /* 1. radius scale. outer = inner + inset, capped so the page stays near-square */
  --r-1: 2px;                                  /* controls, thumbnails, image frames */
  --r-cap: 6px;                                /* no corner on this site is rounder than this */
  --inset: 20px;                               /* padding of the container being rounded; set per component */
  --r-outer: min(calc(var(--r-1) + var(--inset)), var(--r-cap));

  /* 2. borders as ink at a given opacity, so they take the tone of the surface under them */
  --bd-hair: rgb(34 40 43 / .17);              /* dividers, card edges */
  --bd-rule: rgb(34 40 43 / .38);              /* structural rules */
  --bd-ctl: rgb(34 40 43 / .55);               /* control outlines: 3:1 against paper */

  /* 5. icons: one stroke weight, matched to 700-weight 12-13px labels */
  --ic-stroke: 1.6px;
  --ic-ctl: 16px;
  --ic-compact: 14px;

  /* 9. safe areas */
  --sa-t: env(safe-area-inset-top, 0px);
  --sa-r: env(safe-area-inset-right, 0px);
  --sa-b: env(safe-area-inset-bottom, 0px);
  --sa-l: env(safe-area-inset-left, 0px);
  --ui-pad: clamp(18px, 3vw, 48px);
}

/* ---------- 3. OKLCH palette: the same brand colours, expressed perceptually ----------
   Each value below is the existing hex converted to OKLCH, so hues are untouched.
   Hover, pressed, disabled and selected tones are mixed from the base in OKLCH,
   which keeps their hue and moves lightness in even steps. */
@supports (color: oklch(0 0 0)) {
  :root {
    --forest: oklch(38.9% .059 180);
    --forestd: oklch(32.8% .049 180);
    --steel: oklch(44.7% .059 234);
    --brick: oklch(56.3% .134 34);
    --brickd: oklch(49.1% .123 33);
    --rust: oklch(49.1% .123 33);
    --rustd: oklch(43% .11 33);
    --brass: oklch(66.5% .102 79);
    --brassl: oklch(84.4% .08 86);
    --paper: oklch(96.1% .011 90);
    --bone: oklch(92.2% .012 92);
    --limestone: oklch(92.2% .012 92);
    --ink: oklch(27.2% .01 229);
    --muted: oklch(47.8% .013 211);
    --bd-hair: oklch(27.2% .01 229 / .17);
    --bd-rule: oklch(27.2% .01 229 / .38);
    --bd-ctl: oklch(27.2% .01 229 / .55);
  }
}

/* state tones: written once, used by every control */
:root {
  --forest-hover: #123D36;
  --forest-press: #0E322C;
  --forest-off: #8FA6A1;
  --forest-wash: #E1E7E1;
  --ink-wash: #E7E5DD;
}
@supports (color: color-mix(in oklch, red, blue)) {
  :root {
    --forest-hover: color-mix(in oklch, var(--forest) 84%, black);
    --forest-press: color-mix(in oklch, var(--forest) 70%, black);
    --forest-off: color-mix(in oklch, var(--forest) 42%, var(--paper));
    --forest-wash: color-mix(in oklch, var(--forest) 9%, var(--paper));
    --ink-wash: color-mix(in oklch, var(--ink) 7%, var(--paper));
  }
}

/* 2. the two existing line tokens now carry alpha; the fallback is the same ink at the same opacity */
:root {
  --rule: var(--bd-rule);
  --line: var(--bd-hair);
}

/* dark surfaces: lines are white at low opacity, not grey */
.util, .cut, footer, footer.dark, .dark, .cta {
  --rule: rgb(255 255 255 / .26);
  --line: rgb(255 255 255 / .14);
}
@supports (color: oklch(0 0 0)) {
  .util, .cut, footer, footer.dark, .dark, .cta {
    --rule: oklch(100% 0 0 / .26);
    --line: oklch(100% 0 0 / .14);
  }
}

/* hard-coded greys in the reference and landing sheets move to the same tokens */
table.ref th, table.ref td { border-color: var(--line); }
.leadfig img { border-color: var(--line); }

/* control outlines are stronger than hairlines so a control is still findable without its label */
.ghost, .chip, .chips a, .endmod .shr a, .endmod .shr button, .fieldlinks a { border-color: var(--bd-ctl); }
.chip[aria-pressed=true] { border-color: var(--forest); }

/* ---------- 3 (cont.). predictable states for every control ---------- */
.btn { transition: background-color var(--dur-fast) var(--ease-out), border-color var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out); }
.btn:hover { background: var(--forest-hover); border-color: var(--forest-hover); }
.btn:active { background: var(--forest-press); border-color: var(--forest-press); }
.btn:disabled, .btn[aria-disabled=true] { background: var(--forest-off); border-color: var(--forest-off); color: var(--paper); cursor: not-allowed; }
/* landing pages use a paper button on the forest band: its states run the other way */
.cta .btn:hover { background: var(--bone); color: var(--forestd); }
.cta .btn:active { background: color-mix(in srgb, var(--bone) 80%, var(--ink)); }

.ghost, .chip, .endmod .shr a, .endmod .shr button, .fieldlinks a {
  transition: background-color var(--dur-fast) var(--ease-out), border-color var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out);
}
.ghost:hover { border-color: var(--ink); background: var(--ink-wash); }
.ghost:active { background: color-mix(in srgb, var(--ink-wash) 70%, var(--ink)); }
.ghost:disabled, .ghost[aria-disabled=true] { color: var(--muted); border-color: var(--bd-hair); background: transparent; cursor: not-allowed; }
.chip:hover { border-color: var(--ink); background: var(--ink-wash); }
.chip[aria-pressed=true]:hover { background: var(--forest-hover); border-color: var(--forest-hover); }
.chip[aria-pressed=true]:active { background: var(--forest-press); }
.chip:disabled { color: var(--muted); border-color: var(--bd-hair); cursor: not-allowed; }
.navrow a.cur, .navrow a[aria-current] { border-bottom-color: var(--forest); }
.navrow a:hover { color: var(--forest); }
.navrow a:active { color: var(--forest-press); }

/* ---------- 1. concentric radii ---------- */
/* controls and frames sit on the base radius everywhere, including the pages that used square corners */
.btn, .ghost, .chip, .chips a, .endmod .shr a, .endmod .shr button, .fieldlinks a,
input[type=email], input[type=search], input[type=text], textarea { border-radius: var(--r-1); }

/* framed media: the frame carries a 1px border, so the image inside is clipped to the frame minus that border */
.dcard .dimg { border-radius: var(--r-1); }
.leadfig img { border-radius: var(--r-1); }
.withth .th img, .thw img, .arts li.withpth .pth, figure.ph img, .desks3 .ph img { border-radius: var(--r-1); }

/* panels that hold controls: outer radius follows the formula above */
.endmod, .fieldlinks { --inset: 20px; border-radius: var(--r-outer); }
.endmod { --inset: 24px; }
/* the older boxed components keep the V5 base corner; they hold no nested controls */
.card, .box, .spot, .tag { border-radius: var(--r-1); }
.endmod .shr a, .endmod .shr button { border-radius: var(--r-1); }
/* rule-topped editorial bands (In brief, newsletter, listen) stay square on purpose: a rounded rule reads as a card */

/* ---------- 4. OKLCH gradients: two surfaces, nothing else ---------- */
@supports (background: linear-gradient(in oklch, red, blue)) {
  /* the forest feature panel gets a tonal lift from top to bottom; contrast with its white text only rises */
  .cut { background: linear-gradient(in oklch 168deg, color-mix(in oklch, var(--forest) 93%, white), var(--forestd)); }
  /* the reading-progress rule runs brick to brass as it fills */
  .readbar { background: linear-gradient(in oklch 90deg, var(--brickd), var(--brass)); }
}

/* ---------- 8. depth on the dark surfaces the site already has ---------- */
.cut { border: 1px solid rgb(255 255 255 / .10); box-shadow: inset 0 1px 0 rgb(255 255 255 / .10), 0 1px 2px rgb(18 61 54 / .18), 0 10px 24px -14px rgb(18 61 54 / .45); }
.cut .cl-t { border-color: var(--rule); }
footer { box-shadow: inset 0 1px 0 rgb(255 255 255 / .06); }
footer nav a, footer .fgrid > * + * { border-color: var(--line); }
.util { box-shadow: inset 0 -1px 0 rgb(255 255 255 / .08); }

/* ---------- 5. matched icon weight ---------- */
/* a vector-effect keeps the stroke at --ic-stroke whatever size the icon is drawn at */
svg.ic, .mast .ghost svg, .artbar svg {
  stroke-width: var(--ic-stroke);
  stroke-linecap: square;
  stroke-linejoin: miter;
}
svg.ic *, .mast .ghost svg *, .artbar svg * { vector-effect: non-scaling-stroke; }
.mast .ghost svg { width: var(--ic-ctl); height: var(--ic-ctl); flex: none; }
.ghost .ic, .artbar .ic { width: var(--ic-compact); height: var(--ic-compact); margin-right: 8px; vertical-align: -2px; }
.kick .ic, .chi .ic { width: var(--ic-ctl); height: var(--ic-ctl); vertical-align: -3px; }
.body h2 svg.ic, .sum strong svg.ic { --ic-stroke: 2px; }
.ghost { align-items: center; }

/* ---------- 7. blurred icon swaps ---------- */
.swap { display: inline-grid; place-items: center; width: var(--ic-ctl); height: var(--ic-ctl); flex: none; margin-right: 8px; vertical-align: -3px; }
.ghost .swap, .artbar .swap { width: var(--ic-compact); height: var(--ic-compact); vertical-align: -2px; }
.mast .ghost .swap { margin-right: 0; vertical-align: baseline; }
.swap > svg { grid-area: 1 / 1; width: 100%; height: 100%; margin: 0 !important; }
.swap > .is-b { opacity: 0; }
.lbl { display: inline-grid; }
.lbl > span { grid-area: 1 / 1; }
.lbl > .is-b { opacity: 0; }

@media (prefers-reduced-motion: no-preference) {
  .swap > svg { transition: opacity var(--dur-swap) var(--ease-out), transform var(--dur-swap) var(--ease-out), filter var(--dur-swap) var(--ease-out); }
  .swap > .is-b { transform: scale(.6); filter: blur(3px); }
  .lbl > span { transition: opacity var(--dur-swap) var(--ease-out); }
}
/* menu button: tracks aria-expanded, so the visual and the announced state cannot disagree */
#menubtn[aria-expanded=true] .swap > .is-a { opacity: 0; }
#menubtn[aria-expanded=true] .swap > .is-b { opacity: 1; transform: none; filter: none; }
@media (prefers-reduced-motion: no-preference) {
  #menubtn[aria-expanded=true] .swap > .is-a { transform: scale(.6) rotate(45deg); filter: blur(3px); }
}
/* copy button: data-state is set by ui.js */
[data-state=done] .swap > .is-a { opacity: 0; }
[data-state=done] .swap > .is-b { opacity: 1; transform: none; filter: none; }
[data-state=done] .lbl > .is-a { opacity: 0; }
[data-state=done] .lbl > .is-b { opacity: 1; }
@media (prefers-reduced-motion: no-preference) {
  [data-state=done] .swap > .is-a { transform: scale(.6); filter: blur(3px); }
}
[data-state=done], .ghost[data-state=done]:hover { color: var(--forest); border-color: var(--forest); }

.flp-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* ---------- 6. masked edges on horizontal scrollers ----------
   ui.js sets --fl and --fr to 28px only on the side where more content exists,
   so the first and last items are never faded while they are at rest. */
[data-fade] {
  -webkit-mask-image: linear-gradient(to right, transparent 0, #000 var(--fl, 0px), #000 calc(100% - var(--fr, 0px)), transparent 100%);
  mask-image: linear-gradient(to right, transparent 0, #000 var(--fl, 0px), #000 calc(100% - var(--fr, 0px)), transparent 100%);
}
@media (prefers-reduced-motion: no-preference) {
  [data-fade] { transition: --fl var(--dur-base) var(--ease-out), --fr var(--dur-base) var(--ease-out); }
}

/* ---------- 9. dynamic viewport units and safe areas ---------- */
/* the rule that already existed on the home and article pages, now on a small-viewport unit; landing pages never had one */
header.site ~ main { min-height: 70vh; min-height: 70svh; }
.wrap, .narrow {
  padding-left: max(var(--pad, var(--ui-pad)), var(--sa-l));
  padding-right: max(var(--pad, var(--ui-pad)), var(--sa-r));
}
.sticky { padding-bottom: calc(8px + var(--sa-b)); padding-left: max(18px, var(--sa-l)); padding-right: max(8px, var(--sa-r)); }
footer::after { content: ""; display: block; height: var(--sa-b); }
/* the open sections menu sits inside a sticky bar, so it must scroll within the visible viewport */
.mega { max-height: calc(100vh - 56px); max-height: calc(100dvh - 56px); overflow-y: auto; overscroll-behavior: contain; }
/* the dark rail extends under the status bar when the page is installed or the browser reports a top inset */
.util { padding-top: var(--sa-t); }
/* readbar clears the notch */
.readbar { top: var(--sa-t); }

/* hit areas reach 44px on touch screens without changing layout */
@media (pointer: coarse) {
  .mast .ghost, .mast .btn, .artbar .ghost, .chip, .navrow a, .navrow .more { position: relative; }
  .mast .ghost::after, .mast .btn::after, .artbar .ghost::after, .chip::after { content: ""; position: absolute; inset: -5px -3px; }
  .navrow a, .navrow .more { min-height: 44px; display: inline-flex; align-items: center; padding-top: 0; padding-bottom: 0; }
}

/* ---------- 10. multiply blending ----------
   Evaluated on every image class on the site (see UI_RELEASE_REPORT.md). It is applied only where an
   image has a pure white ground sitting on paper; nothing below matches an existing image today.
   Photographs, the paper-toned plates and the lead diagrams are left alone: multiplying a ground that
   is already paper-toned darkens it instead of dissolving it. */
img[data-ground=white] { mix-blend-mode: multiply; }

/* ---------- accessibility: skip link, and a 24px pointer target where a section flag sits 1px above a headline ----------
   The skip link is off-screen until it takes keyboard focus.  The flag rule applies only where the flag is an
   inline box in a plain block (the photo cards), so the padding enlarges the clickable area (WCAG 2.2 SC 2.5.8)
   without moving any text.  Flags elsewhere already clear the 24px spacing test and are left alone, because
   they are flex items there and padding would change the layout. */
.skip { position: absolute; left: -999px; top: 0; z-index: 1000; }
.skip:focus { left: 8px; top: 8px; padding: 8px 12px; background: #fff; color: #22282B; font: 600 14px/1.2 var(--sans, system-ui, sans-serif); text-decoration: underline; }
.withph > div > a.flag { padding-top: 9px; }
/* Story lists (Latest and similar): on a phone the sector link and the desk link wrap onto two lines 6px apart.
   The sector link is a flex item, so its extra padding is cancelled by an equal negative margin; the desk link is
   inline, so its padding does not move anything.  Full-page pixel comparison: identical at 390, 768 and 1440 px. */
.ftxt > div:first-child > a.kick { padding-top: 9px; margin-top: -9px; }
.ftxt > div:first-child > .by a { padding-bottom: 9px; }
main[tabindex="-1"]:focus { outline: none; }   /* a region, not a control: no ring around the whole page */

/* ---------- focus stays obvious ---------- */
:focus-visible { outline: 2px solid var(--forest); outline-offset: 2px; }
.cut :focus-visible, footer :focus-visible, .util :focus-visible { outline-color: var(--brassl); }

/* ---------- reduced motion: no blur, no scale, no travel ---------- */
@media (prefers-reduced-motion: reduce) {
  .swap > svg, .lbl > span, [data-fade], .btn, .ghost, .chip { transition-duration: .01ms !important; }
  .swap > .is-b, #menubtn[aria-expanded=true] .swap > .is-a, [data-state=done] .swap > .is-a { transform: none !important; filter: none !important; }
}
@media print { .readbar { display: none; } [data-fade] { -webkit-mask-image: none; mask-image: none; } }
