
:root {
  --ground: #0D0F14; --card: #151924; --card-hi: #1A1F2C; --border: #232A38; --grid: #1C2230;
  --text: #E8ECF2; --muted: #9AA4B5; --faint: #6B7487;
  --born: #7FF0C8; --died: #6F6A93; --died-light: #B9B3DA; --amber: #FFB454;
  --display: 'Cormorant Garamond', Georgia, serif;
  --body: 'Instrument Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, 'SFMono-Regular', Menlo, monospace;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; background: var(--ground); }
body {
  margin: 0; color: var(--text); font: 16px/1.55 var(--body);
  /* a moonlit graveyard behind the header and page titles (render/scene.ts) */
  background: url(/static/night.svg) center top / max(1600px, 100%) auto no-repeat, var(--ground);
}
a { color: var(--text); text-decoration-color: #3A4357; text-underline-offset: 3px; }
a:hover { text-decoration-color: var(--text); }
:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }
.wrap { max-width: 1080px; margin: 0 auto; padding: 0 16px; }
.muted { color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.full { width: 100%; }
.mono, .num { font-family: var(--mono); }
.num { text-align: right; font-variant-numeric: tabular-nums; }

/* header */
.site-head { border-bottom: 1px solid var(--border); }
.site-head .wrap { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px 28px; padding-top: 20px; padding-bottom: 16px; }
.wordmark { font: 600 30px/1 var(--display); letter-spacing: .01em; text-decoration: none; }
.wordmark span { color: var(--muted); font-weight: 500; }
nav { display: flex; flex-wrap: wrap; gap: 4px 22px; font-size: 15px; }
nav a { color: var(--muted); text-decoration: none; padding: 4px 0; border-bottom: 1px solid transparent; }
nav a:hover, nav a[aria-current] { color: var(--text); border-bottom-color: var(--amber); }
.head-note { margin-left: auto; font-size: 13px; color: var(--faint); }
.banner { margin: 16px 0 0; padding: 8px 12px; border: 1px solid var(--border); border-radius: 8px; font-size: 14px; color: var(--muted); background: rgba(255, 180, 84, .04); }
.banner strong { color: var(--amber); font-weight: 600; }

main { padding: 32px 0 56px; min-width: 0; }
h1, h2, h3 { font-family: var(--display); font-weight: 600; line-height: 1.12; margin: 0 0 12px; letter-spacing: .005em; }
h1 { font-size: clamp(38px, 6.4vw, 56px); }
h2 { font-size: clamp(26px, 3.4vw, 32px); }
h3 { font-size: 22px; }
.lede { font: italic 400 clamp(20px, 2.6vw, 24px)/1.4 var(--display); color: var(--muted); margin: 0 0 28px; max-width: 52ch; }
/* frosted glass: the night scene shows faintly through */
.card { background: rgba(21, 25, 36, .8); border: 1px solid rgba(48, 57, 76, .7); border-radius: 16px; padding: 24px; min-width: 0;
  backdrop-filter: blur(10px) saturate(120%); -webkit-backdrop-filter: blur(10px) saturate(120%); }
section + section { margin-top: 24px; }

/* museum placard label */
.kicker { display: flex; align-items: center; gap: 10px; font: 600 12px/1 var(--body); letter-spacing: .16em; text-transform: uppercase; color: var(--muted); margin: 0 0 12px; }
.kicker::before { content: ''; width: 18px; height: 1px; background: var(--amber); }
.section-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 16px; }
.section-head h2 { margin-bottom: 14px; }
.section-head a { font-size: 14px; color: var(--muted); }

/* home */
.intro { max-width: 60ch; color: var(--muted); margin: 0 0 22px; font-size: 17px; }
.intro strong { color: var(--text); font-weight: 600; }
.hero { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 28px 40px; padding: 30px 32px; align-items: center;
  background: linear-gradient(160deg, rgba(27, 32, 46, .86) 0%, rgba(21, 25, 36, .8) 55%); }
.eyebrow { font-size: 14px; color: var(--muted); }
.hero-number { font: 500 clamp(84px, 17vw, 152px)/0.95 var(--mono); letter-spacing: -0.04em; margin: 10px 0 8px; }
.hero-caption { font-size: 15px; color: var(--muted); }
.delta { font: 500 15px var(--mono); color: var(--text); }
.verdict { font: italic 400 clamp(23px, 3.2vw, 30px)/1.25 var(--display); margin: 14px 0 0; max-width: 30ch; }

/* stats */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin: 14px 0 24px; }
.stat { padding: 18px 20px; }
.stat-label { font-size: 14px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.stat-value { font: 500 32px/1.15 var(--mono); margin-top: 8px; white-space: nowrap; }
.stat-sub { font-size: 13px; color: var(--faint); margin-top: 4px; }
.glyph { font-size: 12px; }
.glyph.born { color: var(--born); }
.glyph.died { color: var(--died-light); }
.glyph.revived { color: var(--amber); }

/* chart */
.chart { position: relative; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 14px; color: var(--muted); margin-bottom: 8px; }
.legend span { display: inline-flex; align-items: center; gap: 8px; }
.key { display: inline-block; width: 12px; height: 12px; border-radius: 3px; }
.key.line { height: 2px; width: 16px; border-radius: 1px; background: var(--amber); }
.key.born { background: var(--born); }
.key.died { background: var(--died); }
.chart-scroll { position: relative; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.chart-svg { display: block; width: 100%; min-width: 640px; height: auto; }
.chart-svg .grid { stroke: var(--grid); stroke-width: 1; }
.chart-svg .baseline { stroke: #39425A; stroke-width: 1; }
.chart-svg .parity { stroke: #4A5368; stroke-width: 1; }
.chart-svg .idx-line { fill: none; stroke: var(--amber); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart-svg .idx-dot { fill: var(--amber); stroke: var(--card); stroke-width: 2; }
.chart-svg .bar.born { fill: var(--born); }
.chart-svg .bar.died { fill: var(--died); }
.chart-svg text { font-family: var(--mono); }
.chart-svg .tick { fill: var(--muted); font-size: 11px; }
.chart-svg .note, .chart-svg .inf { fill: var(--muted); font-size: 11px; }
.chart-svg .panel-label { fill: var(--muted); font: 12px var(--body); }
.chart-svg .end-label { fill: var(--text); font-size: 13px; }
.chart-svg .cross { stroke: #59627A; stroke-width: 1; }
.chart-svg .band { fill: transparent; cursor: crosshair; }
.chart-svg .band:focus { outline: none; }
.chart-svg .band:focus-visible { fill: rgba(255,255,255,.03); }
.tip { position: absolute; top: 8px; min-width: 170px; background: var(--ground); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; font-size: 13px; pointer-events: none; box-shadow: 0 8px 24px rgba(0,0,0,.4); }
.tip-h { color: var(--muted); margin-bottom: 6px; }
.tip-row { display: flex; align-items: center; gap: 8px; }
.tip-row strong { font: 500 14px var(--mono); min-width: 3.5em; }
.tip-row span { color: var(--muted); }
.tip-key { width: 12px; height: 2px; background: var(--muted); }
.tip-key.idx { background: var(--amber); }
.tip-key.born { background: var(--born); }
.tip-key.died { background: var(--died-light); }
.table-view { margin-top: 12px; font-size: 14px; }
.table-view summary { cursor: pointer; color: var(--muted); }

/* lists */
.columns { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 24px; margin-top: 24px; align-items: start; }
.columns > section { margin-top: 0; }
.people { list-style: none; margin: 0 -10px; padding: 0; }
.people li { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 2px 12px; padding: 11px 10px; border-top: 1px solid var(--border); border-radius: 8px; }
.people li:first-child { border-top: 0; }
.people li:hover { background: rgba(255, 255, 255, .025); }
.people .name { overflow-wrap: anywhere; min-width: 0; }
.people .id { color: var(--faint); font: 12px var(--mono); margin-left: 6px; }
.people .meta { color: var(--muted); font-size: 14px; }
.more { margin: 14px 0 0; font-size: 15px; }

/* tables */
table { width: 100%; border-collapse: collapse; font-size: 15px; }
th { text-align: left; font: 500 13px var(--body); color: var(--muted); padding: 8px 10px; border-bottom: 1px solid var(--border); }
th.num { text-align: right; font-family: var(--body); }
td { padding: 11px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:hover td { background: rgba(255, 255, 255, .02); }
tbody tr:last-child td { border-bottom: 0; }
td.name { overflow-wrap: anywhere; }
td .id { color: var(--faint); font: 12px var(--mono); margin-left: 6px; }
.table-scroll { overflow-x: auto; }
.lifespan { display: flex; align-items: center; justify-content: flex-end; gap: 10px; white-space: nowrap; }
.lifespan svg { width: 90px; height: 6px; flex: none; }

/* filters */
.pills { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 18px; }
.pill { display: inline-flex; align-items: baseline; gap: 8px; padding: 7px 14px; border: 1px solid var(--border); border-radius: 999px; font-size: 14px; color: var(--muted); text-decoration: none; background: var(--card); }
.pill:hover { color: var(--text); border-color: #39425A; }
.pill[aria-current] { color: var(--text); border-color: var(--amber); }
.pill .count { font: 12px var(--mono); color: var(--faint); }
select, input, textarea, button { font: inherit; color: var(--text); background: var(--card); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; }
button { cursor: pointer; background: #1E2433; }
button:hover { border-color: var(--muted); }
.pager { display: flex; justify-content: space-between; margin-top: 16px; }
.empty { color: var(--muted); padding: 12px 0; }

/* agent page */
.agent-head { margin-bottom: 22px; }
.agent-head h1 { margin-bottom: 14px; overflow-wrap: anywhere; }
.status-line { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; color: var(--muted); }
.badge { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; color: var(--text); border: 1px solid var(--border); border-radius: 999px; padding: 4px 12px; background: var(--card); }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 20px 28px; margin: 0; }
.facts dt { font-size: 13px; color: var(--muted); }
.facts dd { margin: 4px 0 0; font: 500 16px var(--mono); overflow-wrap: anywhere; }
.facts .time { display: block; font: 13px var(--mono); color: var(--faint); margin-top: 2px; }
.lifeline svg { display: block; width: 100%; height: auto; }
.lifeline .legend { margin: 12px 0 0; }
.lifeline-sum { display: flex; flex-wrap: wrap; gap: 4px 24px; color: var(--muted); font-size: 14px; margin-top: 10px; }
.lifeline-sum strong { color: var(--text); font: 500 15px var(--mono); }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: grid; grid-template-columns: 130px 1fr; gap: 12px; padding: 10px 0; border-top: 1px solid var(--border); }
.timeline li:first-child { border-top: 0; }
.obituary { background: #F2EBDD; color: #1B1A17; border-radius: 6px; padding: 32px clamp(20px, 4vw, 48px); box-shadow: 0 18px 50px rgba(0, 0, 0, .35); }
.obituary .masthead { font: 400 clamp(30px, 4.6vw, 44px)/1 'UnifrakturMaguntia', 'Old English Text MT', serif; text-align: center; margin: 0 0 10px; }
.obituary .dateline { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; font: 12px 'Old Standard TT', Georgia, serif; letter-spacing: .08em; text-transform: uppercase; color: #5B5548; border-top: 2px solid #1B1A17; border-bottom: 3px double #1B1A17; padding: 6px 0; margin-bottom: 22px; }
.obituary h2 { font-family: 'Playfair Display', Georgia, serif; font-weight: 800; font-size: clamp(28px, 4.4vw, 40px); line-height: 1.1; margin: 0 0 16px; color: #1B1A17; }
.obituary p { font-family: 'Old Standard TT', Georgia, serif; font-size: 18px; line-height: 1.65; margin: 0 0 12px; max-width: 64ch; }
.obituary .epitaph { font-style: italic; border-top: 1px solid #CFC5B0; padding-top: 14px; margin-top: 18px; }
.ghost-story { border-left: 2px solid var(--amber); }

/* prose */
.prose { max-width: 70ch; }
.prose dt { font-weight: 600; margin-top: 18px; }
.prose dt:first-child { margin-top: 0; }
.prose dd { margin: 4px 0 0; color: var(--muted); }
.prose code { font-family: var(--mono); font-size: .92em; color: var(--text); }

/* footer */
footer { border-top: 1px solid var(--border); padding: 32px 0 48px; color: var(--muted); font-size: 14px; }
.foot { display: grid; grid-template-columns: 1.3fr 1.3fr 1fr; gap: 24px 40px; }
.foot h3 { font: 600 12px/1 var(--body); letter-spacing: .16em; text-transform: uppercase; color: var(--faint); margin: 0 0 10px; }
.foot p { margin: 0 0 8px; }
.foot ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
footer a { color: var(--muted); }
footer strong { color: var(--text); font-weight: 600; }

/* ---- atmosphere ---- */
/* film grain over everything, very faint */
body::before { content: ''; position: fixed; inset: 0; pointer-events: none; z-index: 100; opacity: .05;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E"); }
.site-head { position: sticky; top: 0; z-index: 20; background: rgba(13, 15, 20, .78); backdrop-filter: saturate(140%) blur(12px); -webkit-backdrop-filter: saturate(140%) blur(12px); }
.wordmark { display: inline-flex; align-items: center; gap: 10px; }
.mark { width: 26px; height: 26px; color: var(--text); flex: none; transform: translateY(-2px); }
.wordmark:hover .mark { animation: float 1.6s ease-in-out infinite; }
@keyframes float { 0%, 100% { transform: translateY(-2px); } 50% { transform: translateY(-6px); } }
.card { transition: border-color .25s ease; }
.card:hover { border-color: #2C3446; }

/* ---- the hero: a lit exhibit ---- */
.hero { position: relative; overflow: hidden; }
.hero::before { content: ''; position: absolute; left: -10%; top: -40%; width: 70%; height: 150%; pointer-events: none;
  background: radial-gradient(closest-side, rgba(255, 180, 84, .10), rgba(255, 180, 84, 0)); }
.hero > * { position: relative; }
.hero-number { text-shadow: 0 0 60px rgba(255, 180, 84, .18); }

/* census: one mark per agent */
.census { display: grid; gap: 20px; border-left: 1px solid var(--border); padding-left: 32px; }
.census-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 10px; font-size: 15px; color: var(--muted); }
.census-count { font-size: 14px; }
.census-count strong { font: 500 26px/1 var(--mono); color: var(--text); margin-right: 4px; }
.units { display: flex; flex-wrap: wrap; gap: 4px; }
.units i { width: 7px; height: 7px; border-radius: 50%; background: var(--born); opacity: .9; }
.stone { display: inline-block; width: 8px; height: 11px; border-radius: 4px 4px 1px 1px; background: var(--died); }
.stone.wallet_drained { background: var(--died-light); }
.stone.pending { background: #4A5368; }
.units .stone { animation: settle .5s cubic-bezier(.2, .7, .2, 1) both; }
.stone-legend { display: flex; flex-wrap: wrap; gap: 4px 16px; margin-top: 10px; font-size: 13px; color: var(--muted); }
.stone-legend span { display: inline-flex; align-items: center; gap: 7px; }
.census-note { margin: 0; font-size: 14px; color: var(--muted); }
.census-note strong { color: var(--text); font-weight: 600; }

/* ---- the field of headstones ---- */
.field .graves { display: flex; flex-wrap: wrap; gap: 7px; padding: 6px 0 4px; }
.grave { position: relative; width: 16px; height: 21px; border-radius: 8px 8px 2px 2px; background: var(--died);
  transition: transform .15s ease, filter .15s ease; }
.grave::after { content: ''; position: absolute; left: 4px; right: 4px; top: 9px; height: 1px; background: rgba(13, 15, 20, .4); }
.grave.wallet_drained { background: var(--died-light); }
.grave.pending { background: #4A5368; }
.grave:hover, .grave:focus-visible { transform: translateY(-3px); filter: brightness(1.25); }
.field .stone-legend { margin-top: 14px; }

/* ---- agent page ---- */
.agent-hero { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 24px 40px; align-items: end; margin-bottom: 24px; }
.agent-hero .agent-head { margin-bottom: 0; }
.headstone { width: 220px; height: auto; display: block; filter: drop-shadow(0 18px 30px rgba(0, 0, 0, .45)); }
.headstone .hs-kicker { font: 600 11px var(--body); letter-spacing: .3em; fill: #8A93A6; }
.headstone .hs-name { font-family: var(--display); font-weight: 600; fill: #D9DEE7; }
.headstone .hs-dates { font: 12px var(--mono); letter-spacing: .08em; fill: #9AA4B5; }
.headstone .hs-epitaph { font: italic 17px var(--display); fill: #B9B3DA; }
.vital { display: flex; align-items: center; gap: 14px; padding: 16px 20px; border: 1px solid var(--border); border-radius: 14px; background: var(--card); min-width: 260px; }
.vital strong { display: block; font: 600 16px var(--body); }
.vital span { font-size: 14px; color: var(--muted); }
.pulse { width: 12px; height: 12px; border-radius: 50%; background: var(--born); flex: none; animation: pulse 2.2s ease-out infinite; }
.vital.revived .pulse { background: var(--amber); }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(127, 240, 200, .55); } 80%, 100% { box-shadow: 0 0 0 14px rgba(127, 240, 200, 0); } }

/* chart wash */
.chart-svg .idx-wash { fill: var(--amber); opacity: .08; }

/* ---- entrance ---- */
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes settle { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
main > * { animation: rise .6s cubic-bezier(.2, .7, .2, 1) both; }
main > *:nth-child(2) { animation-delay: .05s; }
main > *:nth-child(3) { animation-delay: .1s; }
main > *:nth-child(4) { animation-delay: .15s; }
main > *:nth-child(5) { animation-delay: .2s; }
main > *:nth-child(n+6) { animation-delay: .25s; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

@media (max-width: 760px) {
  /* phones: lower the scene so the intro sits on open sky and the graves peek above the hero */
  body { background: url(/static/night.svg) center 150px / 980px auto no-repeat, linear-gradient(#080A10, #080A10) top / 100% 151px no-repeat, var(--ground); }
  .census { border-left: 0; border-top: 1px solid var(--border); padding: 20px 0 0; }
  .agent-hero { grid-template-columns: minmax(0, 1fr); }
  .headstone { width: 180px; margin: 0 auto; }
  .vital { min-width: 0; }
  .facts { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 18px; }
  .hero { grid-template-columns: minmax(0, 1fr); padding: 24px 20px; }
  .columns { grid-template-columns: minmax(0, 1fr); }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat-value { font-size: 26px; }
  .card { padding: 20px; }
  .foot { grid-template-columns: minmax(0, 1fr); }
  .timeline li { grid-template-columns: 1fr; gap: 2px; }
  .head-note { display: none; }
  .lifespan svg { width: 56px; }
}
