/* Public site stylesheet. Dark-first, no framework, no build step, no JavaScript dependency.
   The private admin dashboard keeps its own light-first CSS inside the edge function; the two never share. */

:root {
  --background-canvas: #0e1014;
  --background-sunken: #0a0c0f;
  --surface-card: #171a21;
  --surface-raised: #1e222b;
  --line: #2a2f3a;
  --line-strong: #3a4150;
  --text-primary: #e9ecf1;
  --text-secondary: #a6afbd;
  --text-muted: #7c8797;
  --signal-primary: #7aa7ff;
  --signal-visited: #a99bff;

  /* Narrative Drift palette. These describe how far apart the narratives are in ONE snapshot;
     they are never used to express a change between snapshots. */
  --drift-low: #5fb98a;
  --drift-moderate: #d9a441;
  --drift-high: #e2705a;
  --drift-track: #262b34;

  --radius: 12px;
  --measure: 68ch;
}

@media (prefers-color-scheme: light) {
  :root {
    --background-canvas: #f7f8fa;
    --background-sunken: #eef0f4;
    --surface-card: #ffffff;
    --surface-raised: #f2f4f8;
    --line: #dfe3ea;
    --line-strong: #c4cbd6;
    --text-primary: #12151a;
    --text-secondary: #4a5361;
    --text-muted: #6b7583;
    --signal-primary: #1f5fbf;
    --signal-visited: #6b4fc4;
    --drift-track: #e3e6ec;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--background-canvas);
  color: var(--text-primary);
  font: 16px/1.6 system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", Arial, sans-serif;
}

a { color: var(--signal-primary); text-decoration: none; }
a:hover { text-decoration: underline; }
a:visited { color: var(--signal-visited); }
:focus-visible { outline: 2px solid var(--signal-primary); outline-offset: 2px; }

.skip { position: absolute; left: -9999px; }
.skip:focus { left: 8px; top: 8px; background: var(--surface-card); padding: 8px 12px; border-radius: 8px; z-index: 10; }

header.site {
  border-bottom: 1px solid var(--line);
  background: var(--background-sunken);
}
header.site .inner, main, footer.site .inner {
  max-width: 860px; margin: 0 auto; padding: 0 20px;
}
header.site .inner { display: flex; align-items: baseline; gap: 20px; flex-wrap: wrap; padding-top: 14px; padding-bottom: 14px; }
header.site .brand { font-weight: 700; font-size: 17px; color: var(--text-primary); }
header.site nav a { color: var(--text-secondary); margin-right: 16px; font-size: 15px; }
header.site nav a[aria-current="page"] { color: var(--text-primary); font-weight: 600; }

main { padding-top: 26px; padding-bottom: 60px; }

h1 { font-size: 30px; line-height: 1.2; margin: 0 0 10px; letter-spacing: -0.01em; }
h2 { font-size: 20px; margin: 38px 0 12px; }
h3 { font-size: 13px; margin: 30px 0 10px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.07em; font-weight: 700; }
p { margin: 0 0 14px; max-width: var(--measure); }

/* ---- hero: everything a reader needs in the first viewport ---- */
.hero { background: var(--surface-card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px 22px; margin-bottom: 24px; }
.hero .eyebrow { font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-muted); margin-bottom: 8px; }
.hero .standfirst { font-size: 17px; color: var(--text-secondary); max-width: var(--measure); margin-bottom: 16px; }
.hero .split { border-left: 3px solid var(--line-strong); padding-left: 14px; margin: 0 0 16px; color: var(--text-primary); }

.drift { display: flex; align-items: center; gap: 12px; margin: 14px 0; }
.drift .label { font-size: 12px; text-transform: uppercase; letter-spacing: 0.07em; color: var(--text-muted); }
.drift .value { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.drift .bar { flex: 1; max-width: 200px; height: 6px; border-radius: 999px; background: var(--drift-track); overflow: hidden; }
.drift .bar > i { display: block; height: 100%; border-radius: 999px; }
.drift-low .value, .drift-low .bar > i { color: var(--drift-low); background: var(--drift-low); }
.drift-moderate .value, .drift-moderate .bar > i { color: var(--drift-moderate); background: var(--drift-moderate); }
.drift-high .value, .drift-high .bar > i { color: var(--drift-high); background: var(--drift-high); }
.drift-low .value, .drift-moderate .value, .drift-high .value { background: none; }

.facts { display: flex; flex-wrap: wrap; gap: 6px 20px; margin: 0; padding: 0; list-style: none; color: var(--text-secondary); font-size: 14px; }
.facts b { color: var(--text-primary); font-variant-numeric: tabular-nums; font-weight: 600; }

.changed { background: var(--surface-raised); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; margin: 20px 0; }
.changed .kicker { font-size: 12px; text-transform: uppercase; letter-spacing: 0.07em; color: var(--text-muted); margin-bottom: 6px; }
.changed p:last-child { margin-bottom: 0; }

/* ---- cards / index ---- */
.cards { display: grid; gap: 14px; margin: 0; padding: 0; list-style: none; }
.card { background: var(--surface-card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; }
.card h3.title { font-size: 19px; text-transform: none; letter-spacing: 0; color: var(--text-primary); margin: 0 0 8px; font-weight: 650; }
.card p { font-size: 15px; color: var(--text-secondary); margin-bottom: 10px; }
.badge { display: inline-block; font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--line-strong); color: var(--text-secondary); margin-right: 6px; }

/* ---- timeline ---- */
.timeline { list-style: none; margin: 0; padding: 0; border-left: 2px solid var(--line); }
.timeline > li { position: relative; padding: 0 0 26px 22px; }
.timeline > li::before { content: ""; position: absolute; left: -7px; top: 6px; width: 12px; height: 12px; border-radius: 50%; background: var(--surface-raised); border: 2px solid var(--line-strong); }
.timeline > li:target { background: var(--surface-raised); border-radius: var(--radius); padding-top: 10px; padding-bottom: 14px; }
.timeline > li:target::before { border-color: var(--signal-primary); }
.timeline .when { font-size: 13px; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.timeline .snap { font-size: 14px; color: var(--text-secondary); margin: 4px 0 8px; }
.timeline .change { max-width: var(--measure); margin: 0; }
.timeline .initial { color: var(--text-muted); font-style: normal; }
.anchor { font-size: 12px; color: var(--text-muted); }

/* ---- reader worlds ---- */
.worlds { display: grid; gap: 14px; padding: 0; margin: 0; list-style: none; }
.world { background: var(--surface-card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; }
.world .outlet { font-weight: 650; margin-bottom: 8px; }
.world .believe { color: var(--text-primary); }

/* ---- coverage footprint ---- */
table { width: 100%; border-collapse: collapse; font-size: 14px; margin: 0 0 14px; }
caption { text-align: left; color: var(--text-muted); font-size: 13px; padding-bottom: 8px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--text-muted); font-weight: 600; font-size: 13px; }
td.rank { font-variant-numeric: tabular-nums; white-space: nowrap; }
.provenance { color: var(--text-muted); font-size: 13px; max-width: var(--measure); }

/* ---- method integrity / self-critique ---- */
.integrity { background: var(--surface-card); border: 1px solid var(--line-strong); border-radius: var(--radius); padding: 16px 18px; margin: 20px 0; }
.integrity .score { font-variant-numeric: tabular-nums; font-weight: 700; }
.integrity .counter { border-left: 3px solid var(--drift-moderate); padding-left: 14px; margin: 12px 0; }
details { margin: 12px 0; }
details > summary { cursor: pointer; color: var(--signal-primary); font-size: 15px; }
details[open] > summary { margin-bottom: 10px; }
details ul { padding-left: 20px; }

.assessment { border-left: 3px solid var(--drift-moderate); padding-left: 16px; }

footer.site { border-top: 1px solid var(--line); margin-top: 50px; background: var(--background-sunken); }
footer.site .inner { padding-top: 20px; padding-bottom: 30px; color: var(--text-muted); font-size: 13px; }
footer.site p { max-width: var(--measure); }

.share { background: var(--surface-raised); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; margin: 20px 0; font-size: 14px; color: var(--text-secondary); }
.share code { color: var(--text-primary); word-break: break-all; }

@media (max-width: 620px) {
  h1 { font-size: 25px; }
  .drift .bar { max-width: none; }
}
