/* Canary — editorial light. Two news-born faces: Newsreader (reading, display) and Schibsted Grotesk (data, UI).
   Colour is reserved for status; everything else is ink on cool paper. */

:root {
  --paper: #F6F7F5;
  --paper-2: #EDEFEC;
  --panel: #FFFFFF;
  --ink: #1B2027;
  --ink-2: #434B55;
  --muted: #6A727C;
  --rule: #D5D9D6;
  --rule-strong: #1B2027;
  --green: #2D7A57;
  --amber: #B97A06;
  --red: #B3261E;
  --stale: #A3A9AF;
  --green-wash: #E3F0E9;
  --amber-wash: #F7EBD3;
  --red-wash: #F6DEDB;
  --focus: #1F5FBF;
  --shadow: 0 1px 0 rgba(27, 32, 39, .04);
  --serif: "Newsreader", "Iowan Old Style", Georgia, serif;
  --sans: "Schibsted Grotesk", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #15191D;
    --paper-2: #1C2126;
    --panel: #1A1F24;
    --ink: #E6E8EA;
    --ink-2: #C3C8CD;
    --muted: #8F98A1;
    --rule: #2E353C;
    --rule-strong: #C9CED3;
    --green: #4FB585;
    --amber: #E0A43A;
    --red: #EE6B5F;
    --stale: #6C747C;
    --green-wash: #1D3229;
    --amber-wash: #3A2E17;
    --red-wash: #3D2220;
    --focus: #7FB0FF;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #15191D; --paper-2: #1C2126; --panel: #1A1F24; --ink: #E6E8EA; --ink-2: #C3C8CD; --muted: #8F98A1;
  --rule: #2E353C; --rule-strong: #C9CED3; --green: #4FB585; --amber: #E0A43A; --red: #EE6B5F; --stale: #6C747C;
  --green-wash: #1D3229; --amber-wash: #3A2E17; --red-wash: #3D2220; --focus: #7FB0FF; color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
.r-age { font-variant-numeric: tabular-nums; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 15px/1.45 var(--sans);
  overflow-x: hidden;
}
a { color: inherit; text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--ink); color: var(--paper); padding: 6px 10px; z-index: 50; }
.skip:focus { left: 8px; }

/* ── masthead ── */
.masthead { border-bottom: 1px solid var(--rule); background: var(--paper); }
.masthead-inner {
  max-width: 1480px; margin: 0 auto; padding: 14px 24px 12px;
  display: flex; align-items: baseline; gap: 20px; flex-wrap: wrap;
}
.brand { display: inline-flex; align-items: center; gap: 8px; text-decoration: none; font: 600 26px/1 var(--serif); letter-spacing: -.01em; }
.brand-mark { width: 26px; height: 26px; color: var(--ink); transform: translateY(2px); }
.tagline { margin: 0; color: var(--muted); font: italic 400 16px/1.3 var(--serif); }
.mast-nav { margin-left: auto; display: flex; gap: 18px; align-items: baseline; font-size: 13.5px; color: var(--ink-2); }
.updated { color: var(--muted); }

/* ── hero: world state + strip ── */
main { max-width: 1480px; margin: 0 auto; padding: 0 24px; }
.hero {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  grid-template-areas: "world strip" "head head";
  column-gap: 36px; row-gap: 14px;
  padding: 26px 0 22px;
  border-bottom: 2px solid var(--rule-strong);
}
.world { grid-area: world; display: flex; align-items: flex-end; gap: 16px; }
.world-score { font: 500 88px/0.82 var(--serif); letter-spacing: -.035em; font-variant-numeric: lining-nums tabular-nums; }
.world-score small { display: block; white-space: nowrap; font: 500 12.5px/1.2 var(--sans); letter-spacing: 0; color: var(--muted); margin-bottom: 8px; }
.world-meta p { margin: 0; }
.world-band { font: 600 22px/1.1 var(--serif); display: flex; align-items: center; gap: 8px; }
.world-counts { color: var(--ink-2); font-size: 13.5px; margin-top: 6px !important; }
.world-counts b { font-weight: 600; }

.strip-wrap { grid-area: strip; align-self: end; min-width: 0; }
.strip { display: flex; gap: 10px; align-items: flex-end; width: 100%; }
.strip-group { display: flex; flex-direction: column; gap: 5px; flex: var(--n) 1 0; min-width: 52px; }
.strip-ticks { display: flex; gap: 2px; height: 46px; align-items: stretch; }
.tick {
  flex: 1 1 0; min-width: 3px; border: 0; padding: 0; cursor: pointer;
  background: var(--stale); border-radius: 1px; position: relative;
  transform-origin: bottom; animation: rise .5s cubic-bezier(.2,.7,.3,1) both;
  animation-delay: calc(var(--i) * 6ms);
}
.tick.green { background: var(--green); height: 40%; align-self: flex-end; }
.tick.amber { background: var(--amber); height: 70%; align-self: flex-end; }
.tick.red { background: var(--red); height: 100%; align-self: flex-end; }
.tick.stale { background: var(--stale); height: 40%; align-self: flex-end; }
.tick:hover, .tick:focus-visible { filter: brightness(.85); outline-offset: 1px; }
@keyframes rise { from { transform: scaleY(0); } to { transform: scaleY(1); } }
.strip-label { font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; border-top: 1px solid var(--rule); padding-top: 4px; }
.tip {
  position: fixed; z-index: 40; pointer-events: none; background: var(--ink); color: var(--paper);
  font-size: 12.5px; padding: 5px 8px; border-radius: 3px; max-width: 260px; line-height: 1.3;
}

.headline { grid-area: head; margin: 4px 0 0; max-width: 68ch; font: 400 19px/1.45 var(--serif); color: var(--ink); }

/* ── changes in last 24h ── */
.changes { padding: 14px 0 12px; border-bottom: 1px solid var(--rule); display: flex; gap: 18px; align-items: baseline; flex-wrap: wrap; }
.changes h2 { margin: 0; font: 600 14px/1.3 var(--sans); white-space: nowrap; }
.changes ul { margin: 0; padding: 0; list-style: none; display: flex; flex-wrap: wrap; gap: 6px 18px; }
.changes li button { all: unset; cursor: pointer; font-size: 13.5px; display: inline-flex; gap: 6px; align-items: center; }
.changes li button:hover .c-name { text-decoration: underline; }
.changes li button:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.c-move { color: var(--muted); }

/* ── toolbar ── */
.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px 24px; flex-wrap: wrap; padding: 12px 0; font-size: 13px; color: var(--ink-2); }
.legend { display: flex; gap: 16px; flex-wrap: wrap; }
.lg { display: inline-flex; align-items: center; gap: 6px; }
.filter { display: inline-flex; align-items: center; gap: 7px; cursor: pointer; }
.filter input { accent-color: var(--ink); width: 15px; height: 15px; margin: 0; }

/* status shapes: colour is never the only cue */
.shape { display: inline-block; width: 10px; height: 10px; flex: none; }
.s-green { background: var(--green); border-radius: 50%; }
.s-amber { background: var(--amber); clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%); width: 12px; height: 12px; }
.s-red { background: var(--red); border-radius: 1px; }
.s-stale { background: transparent; border: 1.5px solid var(--stale); border-radius: 50%; }

/* ── board ── */
.board { column-width: 330px; column-gap: 28px; padding-bottom: 28px; }
.domain { break-inside: avoid; margin: 0 0 22px; border-top: 2px solid var(--rule-strong); padding-top: 6px; }
.domain-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-bottom: 2px; }
.domain-head h2 { margin: 0; font: 600 19px/1.25 var(--serif); }
.domain-tally { font-size: 12.5px; color: var(--muted); white-space: nowrap; display: inline-flex; gap: 8px; }
.domain-tally span { display: inline-flex; align-items: center; gap: 4px; }
.domain-tally .shape { transform: scale(.8); }
.rows { list-style: none; margin: 0; padding: 0; }
.row { border-bottom: 1px solid var(--rule); }
.row:last-child { border-bottom: 0; }
.row button {
  all: unset; box-sizing: border-box; cursor: pointer; width: 100%;
  display: grid; grid-template-columns: 14px minmax(0, 1fr) auto; column-gap: 9px; row-gap: 1px;
  align-items: center; padding: 7px 4px 7px 2px;
}
.row button:hover { background: var(--paper-2); }
.row button:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }
.row .shape { justify-self: center; }
.r-name { font-weight: 600; font-size: 14.5px; line-height: 1.25; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.r-right { display: flex; align-items: center; gap: 8px; justify-self: end; }
.r-trend { font-size: 13px; width: 12px; text-align: center; color: var(--muted); }
.r-trend.up { color: var(--red); }
.r-trend.down { color: var(--green); }
.spark { width: 54px; height: 16px; display: block; }
.r-age { font-size: 11.5px; color: var(--muted); min-width: 24px; text-align: right; }
.r-age.is-stale { color: var(--red); font-weight: 600; }
.r-sub { grid-column: 2 / 4; display: flex; gap: 8px; font-size: 13px; color: var(--ink-2); line-height: 1.35; min-width: 0; }
.r-value { font-weight: 500; color: var(--ink); white-space: nowrap; flex: none; }
.r-sum { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; color: var(--ink-2); }
.row.fresh .r-name::after { content: "changed"; margin-left: 7px; font: 600 10.5px/1 var(--sans); color: var(--ink); background: var(--amber-wash); padding: 2px 5px; border-radius: 2px; vertical-align: 2px; }
.row.pending .r-name { color: var(--muted); font-weight: 500; }
.board.flagged .row.st-green, .board.flagged .row.pending { display: none; }
.board.flagged .domain.all-green { display: none; }

/* ── drawer ── */
.scrim { position: fixed; inset: 0; background: rgba(15, 18, 22, .32); z-index: 20; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(560px, 100vw); z-index: 30;
  background: var(--panel); border-left: 1px solid var(--rule); overflow-y: auto;
  padding: 22px 28px 40px; box-shadow: -12px 0 40px rgba(15, 18, 22, .12);
  animation: slide .22s ease-out;
}
@keyframes slide { from { transform: translateX(24px); opacity: 0; } to { transform: none; opacity: 1; } }
.drawer-close { position: sticky; top: 0; float: right; font: 500 13px var(--sans); background: var(--panel); color: var(--ink-2); border: 1px solid var(--rule); border-radius: 3px; padding: 5px 10px; cursor: pointer; }
.drawer-close:hover { color: var(--ink); border-color: var(--ink-2); }
.d-domain { font-size: 13px; color: var(--muted); margin: 2px 0 6px; }
.d-title { font: 600 30px/1.1 var(--serif); margin: 0 0 12px; letter-spacing: -.01em; }
.d-status { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; margin-bottom: 16px; font-size: 14px; }
.pill { display: inline-flex; gap: 7px; align-items: center; font-weight: 600; padding: 4px 10px 4px 8px; border-radius: 3px; }
.pill.green { background: var(--green-wash); }
.pill.amber { background: var(--amber-wash); }
.pill.red { background: var(--red-wash); }
.pill.stale { background: var(--paper-2); }
.d-value { font-weight: 600; }
.d-summary { font: 500 21px/1.35 var(--serif); margin: 0 0 18px; }
.d-sec { margin: 0 0 18px; }
.d-sec h3 { font: 600 13.5px/1.3 var(--sans); margin: 0 0 4px; color: var(--ink); }
.d-sec p { margin: 0; font: 400 16.5px/1.55 var(--serif); color: var(--ink); max-width: 64ch; }
.d-sec.quiet p { color: var(--ink-2); font-size: 15.5px; }
.d-chart { margin: 4px 0 18px; }
.d-chart svg { width: 100%; height: 90px; display: block; }
.d-chart figcaption { font-size: 12px; color: var(--muted); margin-top: 4px; }
.d-hist { display: flex; gap: 2px; height: 14px; margin-top: 4px; }
.d-hist i { flex: 1 1 0; max-width: 10px; border-radius: 1px; }
.d-hist .g { background: var(--green); } .d-hist .a { background: var(--amber); } .d-hist .r { background: var(--red); }
.rubric { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
.rubric li { display: grid; grid-template-columns: 80px 1fr; gap: 10px; font-size: 14px; line-height: 1.4; padding: 6px 8px; border-radius: 3px; color: var(--ink-2); }
.rubric li.on { background: var(--paper-2); color: var(--ink); }
.rubric b { display: inline-flex; gap: 6px; align-items: center; font-weight: 600; color: var(--ink); }
.sources { margin: 0; padding-left: 18px; font-size: 14px; line-height: 1.45; }
.sources li { margin-bottom: 3px; }
.sources span { color: var(--muted); }
.d-meta { font-size: 12.5px; color: var(--muted); border-top: 1px solid var(--rule); padding-top: 10px; margin-top: 22px; }
.d-meta p { margin: 0 0 3px; }

/* ── footer ── */
.foot { max-width: 1480px; margin: 0 auto; padding: 18px 24px 40px; border-top: 1px solid var(--rule); font-size: 13.5px; color: var(--ink-2); }
.foot p { max-width: 90ch; margin: 0 0 8px; }
.foot-small { font-size: 12.5px; color: var(--muted); }
.error { padding: 16px; background: var(--red-wash); border-radius: 3px; }

/* ── responsive ── */
@media (max-width: 1000px) {
  .hero { grid-template-columns: 1fr; grid-template-areas: "world" "strip" "head"; }
  .strip-label { font-size: 10.5px; }
}
@media (max-width: 640px) {
  .masthead-inner { padding: 12px 16px 10px; gap: 4px 14px; }
  .tagline { order: 3; width: 100%; font-size: 14.5px; }
  .mast-nav { margin-left: auto; gap: 12px; font-size: 12.5px; }
  .mast-nav { width: 100%; margin-left: 0; order: 4; }
  .updated { margin-right: auto; }
  main { padding: 0 16px; }
  .foot { padding: 16px 16px 32px; }
  .world-score { font-size: 68px; }
  .strip { gap: 5px; }
  .strip-ticks { height: 36px; gap: 1px; }
  .tick { min-width: 2px; }
  .strip-label { display: none; }
  .strip-group { min-width: 0; }
  .headline { font-size: 17px; }
  .board { column-width: auto; columns: 1; }
  .drawer { padding: 18px 18px 36px; border-left: 0; }
  .d-title { font-size: 26px; }
  .r-sub { flex-wrap: wrap; }
  .r-sum { white-space: normal; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
