/* EU or Not — single stylesheet, no external fonts, no CDN. */

:root {
  --bg: #fbfaf7;
  --bg-raised: #ffffff;
  --ink: #14181f;
  --ink-soft: #4d5665;
  --rule: #e2ded4;
  --accent: #0b2545;
  --accent-soft: #1d4e89;
  --flag: #ffcc00;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --serif: "Iowan Old Style", "Charter", Georgia, "Times New Roman", serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, Helvetica, Arial, sans-serif;
  --measure: 68ch;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0a0e14;
    --bg-raised: #121821;
    --ink: #e8e6e1;
    --ink-soft: #9aa4b2;
    --rule: #232b36;
    --accent: #7fb3ff;
    --accent-soft: #a8c8ff;
  }
}

:root[data-theme="dark"] {
  --bg: #0a0e14;
  --bg-raised: #121821;
  --ink: #e8e6e1;
  --ink-soft: #9aa4b2;
  --rule: #232b36;
  --accent: #7fb3ff;
  --accent-soft: #a8c8ff;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 18px;
  line-height: 1.65;
  text-rendering: optimizeLegibility;
}

.wrap { width: min(100% - 2.5rem, 46rem); margin-inline: auto; }

a { color: var(--accent-soft); text-underline-offset: 3px; text-decoration-thickness: 1px; }
a:hover { color: var(--ink); }

.skip {
  position: absolute; left: -9999px;
}
.skip:focus { left: 1rem; top: 1rem; background: var(--bg-raised); padding: .5rem .75rem; z-index: 10; }

/* Header */
.site-head { border-bottom: 1px solid var(--rule); background: var(--bg-raised); }
.head-inner { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .9rem 0; flex-wrap: wrap; }
.brand { display: inline-flex; align-items: baseline; gap: .4rem; text-decoration: none; color: var(--ink); font-weight: 700; letter-spacing: -.02em; }
.brand-mark {
  font-family: var(--mono); background: var(--accent); color: #fff;
  padding: .1rem .4rem; border-radius: 4px; font-size: .95rem;
  box-shadow: inset 0 -3px 0 var(--flag);
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .brand-mark { color: #0a0e14; } }
:root[data-theme="dark"] .brand-mark { color: #0a0e14; }
.brand-text { font-size: 1.05rem; }
/* align-items: center, or the links stretch to the toggle's height and their text
   sits at the top of the stretched box, a few pixels above the button. */
.nav { display: flex; align-items: center; gap: 1.1rem; font-size: .92rem; }
.nav a { color: var(--ink-soft); text-decoration: none; }
.nav a:hover { color: var(--ink); text-decoration: underline; }

/* Theme toggle. Icon shows the theme you get by clicking, not the current one. */
.theme-toggle {
  display: inline-flex; align-items: center; justify-content: center;
  width: 2rem; height: 2rem; padding: 0; margin-left: .1rem;
  background: none; border: 1px solid var(--rule); border-radius: 6px;
  color: var(--ink-soft); cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.theme-toggle:hover { color: var(--ink); border-color: var(--ink-soft); }
.theme-toggle:focus-visible { outline: 2px solid var(--accent-soft); outline-offset: 2px; }
.theme-toggle .icon-sun { display: none; }
.theme-toggle .icon-moon { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .icon-sun { display: block; }
  :root:not([data-theme="light"]) .theme-toggle .icon-moon { display: none; }
}
:root[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
:root[data-theme="light"] .theme-toggle .icon-sun { display: none; }
:root[data-theme="light"] .theme-toggle .icon-moon { display: block; }

/* Hero */
.hero { padding: 3rem 0 1.5rem; border-bottom: 1px solid var(--rule); }
.hero h1 { font-family: var(--serif); font-size: clamp(2rem, 5vw, 2.9rem); line-height: 1.1; margin: 0 0 .6rem; letter-spacing: -.02em; }
.hero p { color: var(--ink-soft); margin: 0; max-width: var(--measure); }

/* Countdown / milestone strip */
.milestones { display: grid; gap: .75rem; grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr)); padding: 1.5rem 0; }
.milestone { background: var(--bg-raised); border: 1px solid var(--rule); border-radius: 8px; padding: .85rem .95rem; }
.milestone .m-date { font-family: var(--mono); font-size: .78rem; color: var(--accent-soft); letter-spacing: .02em; }
.milestone .m-what { display: block; font-size: .95rem; margin-top: .2rem; }

/* Post list */
.list-head { display: flex; align-items: baseline; justify-content: space-between; margin: 2.2rem 0 .5rem; }
.list-head h2 { font-size: 1rem; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-soft); margin: 0; font-weight: 600; }
.posts { list-style: none; padding: 0; margin: 0; }
.posts li { border-top: 1px solid var(--rule); padding: 1.4rem 0; }
.posts a.entry { display: block; text-decoration: none; color: inherit; }
.posts a.entry:hover h3 { color: var(--accent-soft); }
.entry-meta { font-family: var(--mono); font-size: .76rem; color: var(--ink-soft); text-transform: uppercase; letter-spacing: .06em; }
.posts h3 { font-family: var(--serif); font-size: 1.45rem; line-height: 1.25; margin: .3rem 0 .4rem; letter-spacing: -.01em; }
.posts p { margin: 0; color: var(--ink-soft); }

/* Article */
.post, .page { padding: 2.6rem 0 3rem; }
.kicker { font-family: var(--mono); font-size: .76rem; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-soft); margin: 0 0 .6rem; }
.post-head h1, .page-head h1 { font-family: var(--serif); font-size: clamp(1.9rem, 4.6vw, 2.7rem); line-height: 1.12; margin: 0 0 .7rem; letter-spacing: -.02em; }
.standfirst { font-size: 1.12rem; color: var(--ink-soft); margin: 0 0 1.4rem; max-width: var(--measure); }

.keydates { display: grid; gap: .1rem; margin: 1.4rem 0; padding: .9rem 1rem; background: var(--bg-raised); border: 1px solid var(--rule); border-left: 3px solid var(--flag); border-radius: 6px; }
.keydates div { display: grid; grid-template-columns: 9.5rem 1fr; gap: .6rem; padding: .2rem 0; }
.keydates dt { font-family: var(--mono); font-size: .82rem; color: var(--accent-soft); }
.keydates dd { margin: 0; font-size: .95rem; }
@media (max-width: 34rem) { .keydates div { grid-template-columns: 1fr; gap: 0; } }

.prose { max-width: var(--measure); }
.prose h2 { font-family: var(--serif); font-size: 1.5rem; line-height: 1.25; margin: 2.4rem 0 .6rem; letter-spacing: -.01em; }
.prose h3 { font-size: 1.12rem; margin: 1.8rem 0 .4rem; }
.prose p { margin: 0 0 1.1rem; }
.prose ul, .prose ol { margin: 0 0 1.1rem; padding-left: 1.3rem; }
.prose li { margin-bottom: .4rem; }
.prose blockquote { margin: 1.4rem 0; padding: .2rem 0 .2rem 1.1rem; border-left: 3px solid var(--rule); color: var(--ink-soft); font-style: italic; }
.prose code { font-family: var(--mono); font-size: .88em; background: var(--bg-raised); border: 1px solid var(--rule); border-radius: 4px; padding: .05em .35em; }
.prose pre { overflow-x: auto; background: var(--bg-raised); border: 1px solid var(--rule); border-radius: 6px; padding: .9rem 1rem; }
.prose pre code { border: 0; background: none; padding: 0; }
.prose img { max-width: 100%; height: auto; }
.prose hr { border: 0; border-top: 1px solid var(--rule); margin: 2rem 0; }

.table-scroll, .prose table { display: block; overflow-x: auto; max-width: 100%; }
.prose table { border-collapse: collapse; font-size: .93rem; margin: 0 0 1.2rem; }
.prose th, .prose td { border-bottom: 1px solid var(--rule); padding: .5rem .7rem; text-align: left; vertical-align: top; white-space: nowrap; }
.prose th { font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-soft); }
.prose td:last-child, .prose th:last-child { white-space: normal; min-width: 16rem; }

.sources { margin-top: 2.6rem; padding-top: 1.2rem; border-top: 1px solid var(--rule); max-width: var(--measure); }
.sources h2 { font-size: .82rem; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-soft); margin: 0 0 .6rem; }
.sources ol { font-size: .9rem; color: var(--ink-soft); padding-left: 1.2rem; }

.post-foot { margin-top: 1.6rem; }
.tags { display: flex; flex-wrap: wrap; gap: .4rem; margin: 0 0 .6rem; }
.tag { font-family: var(--mono); font-size: .74rem; border: 1px solid var(--rule); border-radius: 100px; padding: .15rem .6rem; color: var(--ink-soft); }
.corrections { font-size: .9rem; color: var(--ink-soft); margin: 0 0 .4rem; padding: .7rem .9rem; background: var(--bg-raised); border: 1px solid var(--rule); border-radius: 6px; max-width: var(--measure); }
.md-hint { font-size: .85rem; color: var(--ink-soft); margin: 0; }

/* Comments */
/* The thread itself uses the full column; only the prose around it keeps the
   reading measure. Cusdis renders in an iframe, so its own layout is cramped
   by anything narrower than the wrapper. */
.comments { margin-top: 2.8rem; padding-top: 1.2rem; border-top: 1px solid var(--rule); }
.comments h2 { font-size: .82rem; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-soft); margin: 0 0 .6rem; max-width: var(--measure); }
.comments-note { font-size: .88rem; color: var(--ink-soft); margin: 0 0 1.1rem; max-width: var(--measure); }
#cusdis_thread { min-height: 16rem; }
#cusdis_thread iframe { display: block; width: 100%; border: 0; }

.related { margin-top: 2.6rem; padding-top: 1.2rem; border-top: 1px solid var(--rule); }
.related h2, .topic-posts h2 { font-size: .82rem; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-soft); margin: 0 0 .8rem; }
.cards { list-style: none; padding: 0; margin: 0; display: grid; gap: .7rem; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); }
.cards a { display: block; text-decoration: none; color: inherit; background: var(--bg-raised); border: 1px solid var(--rule); border-radius: 8px; padding: .85rem; height: 100%; }
.cards a:hover { border-color: var(--accent-soft); }
.card-date { display: block; font-family: var(--mono); font-size: .74rem; color: var(--ink-soft); }
.card-title { display: block; font-weight: 600; margin-top: .25rem; line-height: 1.3; }
.card-desc { display: block; margin-top: .35rem; font-size: .88rem; color: var(--ink-soft); }

/* Timeline page */
/* The line is drawn per item rather than as a border on the <ol>, so the line and
   the dot are positioned inside the same box from the same `left: 0` origin and
   cannot drift apart. --tl-mid is where the dot's centre goes: not half the line
   box (.825em), because the date span's smaller font aligns on the baseline and
   so renders below that; .92em centres the dot on the date text itself. */
.tl {
  --tl-line: 2px; --tl-dot: .6rem; --tl-indent: 1.6rem; --tl-mid: .92em;
  list-style: none; margin: 2rem 0 0; padding: 0;
}
/* margin: 0 overrides `.prose li`'s bottom margin — spacing has to come from the
   padding, which is inside the item, or the line segments part company. */
.tl li { position: relative; margin: 0; padding: 0 0 1.6rem var(--tl-indent); }
.tl li:last-child { padding-bottom: 0; }
.tl li::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0;
  width: var(--tl-line); background: var(--rule);
}
.tl li:first-child::before { top: var(--tl-mid); }
.tl li:last-child::before { bottom: auto; height: var(--tl-mid); }
.tl li::after {
  content: ""; position: absolute;
  left: calc(var(--tl-line) / 2); margin-left: calc(-1 * var(--tl-dot) / 2);
  top: calc(var(--tl-mid) - var(--tl-dot) / 2);
  width: var(--tl-dot); height: var(--tl-dot);
  border-radius: 50%; background: var(--accent-soft);
}
.tl li.done::after { background: var(--rule); }

/* "You are here": a bigger dot in the flag colour with a soft ring, so it reads
   as the reader's position rather than as another milestone. --tl-dot is a
   variable, so the dot grows and stays centred without touching the offsets. */
.tl li.tl-now { --tl-dot: .85rem; }
.tl li.tl-now::after { background: var(--flag); box-shadow: 0 0 0 .3rem rgba(255, 204, 0, .18); }
.tl li.tl-now .tl-date { color: var(--flag); }
.tl li.tl-now h3 { color: var(--ink); }
.tl li.tl-now p { font-size: .9rem; }
.tl-note { margin-top: 2rem; color: var(--ink-soft); font-size: .9rem; }
.tl .tl-date { font-family: var(--mono); font-size: .8rem; color: var(--accent-soft); }
.tl h3 { margin: .15rem 0 .3rem; font-size: 1.05rem; }
.tl p { margin: 0; color: var(--ink-soft); font-size: .95rem; max-width: var(--measure); }

/* Grants page */
.grants-intro { color: var(--ink-soft); font-size: .95rem; max-width: var(--measure); margin: 0 0 1.4rem; }
/* Grid, not flex: the three selects take an equal share of the leftover width and
   the count gets a fixed column, so "29 programmes" shrinks the controls rather
   than wrapping onto a row of its own — and the selects hold still as the number
   changes width while filtering. minmax(0, 1fr) lets a column go narrower than
   its select's intrinsic width. */
.grants-filter { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)) 7rem; align-items: end; gap: .7rem 1rem; padding: .9rem 1rem; background: var(--bg-raised); border: 1px solid var(--rule); border-radius: 8px; margin-bottom: 2rem; }
.grants-filter label { min-width: 0; display: grid; gap: .25rem; font-family: var(--mono); font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-soft); }
.grants-filter select { width: 100%; min-width: 0; font: inherit; font-family: var(--sans); font-size: .9rem; text-transform: none; letter-spacing: 0; color: var(--ink); background: var(--bg); border: 1px solid var(--rule); border-radius: 6px; padding: .35rem .5rem; }
/* Same two-row grid as a filter label, so the number sits on the select row
   rather than floating between the label and the control. */
/* Selector carries .grants-filter so it outranks `.prose p`, whose bottom margin
   would otherwise be part of the count's margin box and push it out of line. */
.grants-filter .grants-count { display: grid; gap: .25rem; margin: 0; font-family: var(--mono); font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-soft); text-align: end; }
/* Padding and a transparent border match the select's box, so the number's text
   sits on the same line as the text inside the controls. */
.grants-count b { font-weight: 400; font-size: .82rem; text-transform: none; letter-spacing: 0; color: var(--ink); white-space: nowrap; padding: .35rem 0; border: 1px solid transparent; }

/* Below this the four columns stop fitting. Two columns puts the count in the cell
   the third select leaves empty, rather than on a row of its own. */
@media (max-width: 34rem) {
  .grants-filter { grid-template-columns: 1fr 1fr; }
}
.grants-group h2 { font-size: .82rem; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-soft); margin: 2.2rem 0 .8rem; }
.grants-group:first-of-type h2 { margin-top: 0; }
.grants { list-style: none; margin: 0; padding: 0; display: grid; gap: .8rem; }
.grant-card { display: block; text-decoration: none; color: inherit; background: var(--bg-raised); border: 1px solid var(--rule); border-left: 3px solid var(--flag); border-radius: 8px; padding: .9rem 1rem; }
.grant-card:hover { border-color: var(--accent-soft); border-left-color: var(--flag); color: inherit; }
.grant-card:hover .grant-name { text-decoration: underline; text-underline-offset: 3px; }
.grant-head { display: flex; flex-wrap: wrap; gap: .2rem 1rem; justify-content: space-between; align-items: baseline; }
.grant-name { font-size: 1.02rem; font-weight: 600; line-height: 1.35; }
.grant-amount { font-family: var(--mono); font-size: .78rem; color: var(--accent-soft); text-align: end; }
.grant-meta { display: flex; flex-wrap: wrap; gap: .35rem; margin-top: .5rem; }
.grant-meta .tag-sector { color: var(--ink-soft); opacity: .8; }
.grant-foot { display: flex; flex-wrap: wrap; gap: .2rem .9rem; justify-content: space-between; align-items: baseline; margin-top: .65rem; font-family: var(--mono); font-size: .76rem; color: var(--ink-soft); }
.grant-more { color: var(--accent-soft); }
.grant-checked { white-space: nowrap; }
.grants-foot { margin-top: 2.4rem; padding-top: 1.1rem; border-top: 1px solid var(--rule); font-size: .88rem; color: var(--ink-soft); }

/* Single grant page */
.grant-amount-lead { margin: .5rem 0 0; font-family: var(--mono); font-size: .92rem; color: var(--accent-soft); }
.grant-facts dt { text-transform: none; }
.outbound { margin-top: 2rem; padding: 1.1rem 1.2rem; background: var(--bg-raised); border: 1px solid var(--rule); border-radius: 8px; }
.outbound-link { display: inline-flex; flex-wrap: wrap; align-items: baseline; gap: .2rem .6rem; font-weight: 600; text-decoration: none; }
.outbound-link::after { content: " ↗"; font-weight: 400; }
.outbound-link:hover { text-decoration: underline; text-underline-offset: 3px; }
.outbound-host { font-family: var(--mono); font-size: .78rem; font-weight: 400; color: var(--ink-soft); word-break: break-word; }
.outbound-note { margin: .6rem 0 0; font-size: .86rem; color: var(--ink-soft); max-width: var(--measure); }
.outbound-note strong { color: var(--ink); }

/* Footer */
.site-foot { border-top: 1px solid var(--rule); background: var(--bg-raised); margin-top: 3rem; padding: 2rem 0 2.5rem; font-size: .88rem; color: var(--ink-soft); }
.foot-brand { font-weight: 600; color: var(--ink); margin: 0 0 .5rem; }
.foot-note { max-width: var(--measure); margin: 0 0 .8rem; }
.foot-links { margin: 0 0 .6rem; }
.foot-copy { margin: 0; font-size: .82rem; }
