/* THE AI ATLAS — Quiet Machine styling.
   Near-black warm canvas, deliberate Inter, hairline detail, two-tier ink. */

:root {
  --bg: #08090A;
  --ink: #F3F4F5;
  --ink-dim: rgba(243,244,245,0.58);
  --ink-faint: rgba(243,244,245,0.32);
  --line: rgba(243,244,245,0.10);
  --line-strong: rgba(243,244,245,0.16);
  --plate: rgba(16,18,20,0.72);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; background: var(--bg); }
body {
  font-family: Inter, system-ui, -apple-system, sans-serif;
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  user-select: none;
}
#stage { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; cursor: grab; touch-action: none; }
#stage:active { cursor: grabbing; }

/* film-grain texture for depth — precision surfaces, not flat black */
.grain {
  position: fixed; inset: 0; z-index: 1; pointer-events: none; opacity: 0.05;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)' opacity='0.6'/%3E%3C/svg%3E");
}

/* ---- shared reveal: blur-to-sharp (Quiet Machine signature) ---- */
.masthead, .legendwrap, .searchwrap, .controls, .hud {
  opacity: 0; filter: blur(10px); transform: translateY(6px);
  transition: opacity .9s ease, filter .9s ease, transform .9s ease;
}
body.ready .masthead { opacity: 1; filter: blur(0); transform: none; transition-delay: .05s; }
body.ready .hud      { opacity: 1; filter: blur(0); transform: none; transition-delay: .18s; }
body.ready .legendwrap { opacity: 1; filter: blur(0); transform: none; transition-delay: .28s; }
body.ready .searchwrap { opacity: 1; filter: blur(0); transform: none; transition-delay: .34s; }
body.ready .controls   { opacity: 1; filter: blur(0); transform: none; transition-delay: .40s; }

/* ---- Masthead ---- */
.masthead { position: fixed; top: 26px; left: 28px; z-index: 5; pointer-events: none; }
.wordmark {
  font-weight: 600; font-size: 15px; letter-spacing: 0.18em; color: var(--ink);
}
.tagline { margin-top: 7px; font-size: 12.5px; font-weight: 400; color: var(--ink-dim); max-width: 260px; line-height: 1.35; }
.span { margin-top: 5px; font-size: 10.5px; letter-spacing: 0.06em; color: var(--ink-faint); text-transform: uppercase; }

/* ---- HUD zoom readout ---- */
.hud {
  position: fixed; top: 30px; left: 50%; transform: translateX(-50%); z-index: 5;
  font-size: 10.5px; font-weight: 600; letter-spacing: 0.22em; color: var(--ink-faint);
  pointer-events: none;
}

/* ---- Field / Timeline toggle ---- */
.modewrap {
  position: fixed; top: 52px; left: 50%; transform: translateX(-50%); z-index: 5;
  display: flex; gap: 2px; padding: 3px;
  background: var(--plate); backdrop-filter: blur(12px);
  border: 1px solid var(--line); border-radius: 9px;
  opacity: 0; filter: blur(10px); transition: opacity .9s ease .5s, filter .9s ease .5s;
}
body.ready .modewrap { opacity: 1; filter: blur(0); }
.mode-btn {
  background: none; border: none; color: var(--ink-faint); cursor: pointer;
  font: inherit; font-size: 11.5px; font-weight: 500; letter-spacing: 0.03em;
  padding: 6px 15px; border-radius: 7px; transition: color .18s, background .18s;
}
.mode-btn:hover { color: var(--ink-dim); }
.mode-btn.on { color: var(--ink); background: rgba(243,244,245,0.10); }
.mode-btn.read { border-left: 1px solid var(--line); border-radius: 0 7px 7px 0; margin-left: 2px; }

/* ---- Verdict panel ---- */
.v-conf {
  display: inline-block; margin-left: 10px; font-size: 9px; letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--ink-faint);
  border: 1px solid var(--line-strong); border-radius: 4px; padding: 2px 7px; vertical-align: 2px;
}
.v-camps { margin-top: 20px; display: flex; flex-direction: column; gap: 16px; }
.v-camp-label { font-size: 12.5px; font-weight: 600; color: var(--ink); margin-bottom: 6px; }
.v-row { display: flex; align-items: center; gap: 9px; margin-top: 4px; }
.v-row span.who { flex: 0 0 44px; font-size: 8.5px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-faint); }
.v-track { flex: 1; height: 5px; background: rgba(243,244,245,0.07); border-radius: 3px; overflow: hidden; }
.v-fill { height: 100%; border-radius: 3px; }
.v-row span.pct { flex: 0 0 34px; text-align: right; font-size: 11px; font-variant-numeric: tabular-nums; color: var(--ink-dim); }
.v-read { margin-top: 22px; font-size: 13.5px; line-height: 1.6; color: var(--ink-dim); border-top: 1px solid var(--line); padding-top: 16px; }
.v-crux { margin-top: 16px; font-size: 12px; line-height: 1.5; color: var(--ink); border-left: 2px solid var(--line-strong); padding-left: 10px; }
.v-crux b { font-size: 9px; letter-spacing: 0.14em; display: block; margin-bottom: 3px; }
.v-disclose {
  margin-top: 26px; font-size: 11px; line-height: 1.55; color: var(--ink-faint);
  border-top: 1px solid var(--line); padding-top: 14px; font-style: italic;
}
.v-all-link { margin-top: 18px; background: none; border: 1px solid var(--line-strong); color: var(--ink-dim);
  width: 100%; padding: 9px; border-radius: 7px; cursor: pointer; font: inherit; font-size: 12px; transition: color .18s, background .18s; }
.v-all-link:hover { color: var(--ink); background: rgba(243,244,245,0.05); }
/* The Read (all-verdicts list) */
.v-item { display: block; width: 100%; text-align: left; background: none; border: none; border-bottom: 1px solid var(--line);
  padding: 14px 0; cursor: pointer; font: inherit; transition: background .16s; }
.v-item:hover { background: rgba(243,244,245,0.035); }
.v-item .v-q { font-size: 13.5px; font-weight: 600; color: var(--ink); display: flex; align-items: center; gap: 8px; }
.v-item .v-q .dot { width: 7px; height: 7px; border-radius: 50%; flex: 0 0 auto; }
.v-item .v-one { margin-top: 5px; font-size: 12px; line-height: 1.5; color: var(--ink-dim); }
.v-item .v-mini { margin-top: 8px; display: flex; height: 4px; border-radius: 2px; overflow: hidden; }
.v-mini i { height: 100%; }

/* In Timeline mode the lanes are the legend — hide the field legend, declutter top-left */
body.timeline .legendwrap { opacity: 0; pointer-events: none; transition: opacity .5s ease; }
body.timeline .tagline, body.timeline .span { opacity: 0; transition: opacity .4s ease; }

/* ---- Legend ---- */
.legendwrap {
  position: fixed; left: 28px; bottom: 26px; z-index: 5; width: 214px;
}
.legend-h {
  font-size: 9.5px; font-weight: 600; letter-spacing: 0.18em; text-transform: uppercase;
  color: var(--ink-faint); margin-bottom: 9px;
}
.legend { display: flex; flex-direction: column; gap: 1px; }
.legend-item {
  display: flex; align-items: center; gap: 9px; width: 100%;
  background: none; border: none; color: var(--ink-dim); cursor: pointer;
  font: inherit; font-size: 12px; padding: 4px 6px; border-radius: 5px;
  text-align: left; transition: background .18s, color .18s;
}
.legend-item:hover { background: rgba(243,244,245,0.05); color: var(--ink); }
.legend-item.active { background: rgba(243,244,245,0.08); color: var(--ink); }
.legend-item .chip { width: 9px; height: 9px; border-radius: 50%; flex: 0 0 auto; }
.legend-item .count { margin-left: auto; font-size: 10.5px; color: var(--ink-faint); font-variant-numeric: tabular-nums; }

.typekey { display: flex; flex-direction: column; gap: 5px; }
.typekey span { display: flex; align-items: center; gap: 9px; font-size: 11px; color: var(--ink-dim); }
.typekey .g { width: 10px; height: 10px; flex: 0 0 auto; }
.g.dev { border-radius: 50%; background: var(--ink-dim); }
.g.pred { width: 0; height: 0; border-top: 5px solid transparent; border-bottom: 5px solid transparent; border-left: 9px solid var(--ink-dim); background: none; }
.g.op { background: var(--ink-dim); transform: rotate(45deg); }
.g.rep { background: var(--ink-dim); }
.g.deb { border-radius: 50%; background: none; border: 1.5px solid var(--ink-dim); }

/* ---- Search ---- */
.searchwrap {
  position: fixed; top: 26px; right: 28px; z-index: 5;
  display: flex; align-items: center; gap: 8px;
  background: var(--plate); backdrop-filter: blur(12px);
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 11px; width: 244px;
}
.searchwrap .s-icon { color: var(--ink-faint); flex: 0 0 auto; }
#search {
  background: none; border: none; outline: none; color: var(--ink);
  font: inherit; font-size: 12.5px; width: 100%;
}
#search::placeholder { color: var(--ink-faint); }
#search-clear {
  display: none; background: none; border: none; color: var(--ink-faint);
  font-size: 16px; line-height: 1; cursor: pointer; padding: 0 2px;
}
#search-clear:hover { color: var(--ink); }

/* ---- Controls ---- */
.controls {
  position: fixed; right: 28px; bottom: 26px; z-index: 5;
  display: flex; flex-direction: column; gap: 6px;
}
.controls button {
  width: 34px; height: 34px; border-radius: 7px;
  background: var(--plate); backdrop-filter: blur(12px);
  border: 1px solid var(--line); color: var(--ink-dim);
  font-size: 16px; cursor: pointer; transition: color .18s, border-color .18s, background .18s;
  display: flex; align-items: center; justify-content: center;
}
.controls button:hover { color: var(--ink); border-color: var(--line-strong); background: rgba(24,26,28,0.9); }

/* ---- Detail panel ---- */
.panel {
  position: fixed; top: 0; right: 0; height: 100%; width: 380px; max-width: 90vw; z-index: 8;
  background: rgba(11,12,13,0.94); backdrop-filter: blur(18px);
  border-left: 1px solid var(--line-strong);
  padding: 30px 30px 40px; overflow-y: auto;
  transform: translateX(100%); transition: transform .5s cubic-bezier(.16,1,.3,1);
  pointer-events: none;
}
.panel.open { transform: none; pointer-events: auto; }
.panel-close {
  position: absolute; top: 20px; right: 22px; background: none; border: none;
  color: var(--ink-faint); font-size: 24px; line-height: 1; cursor: pointer; transition: color .18s;
}
.panel-close:hover { color: var(--ink); }
.panel-kicker { display: flex; align-items: center; gap: 8px; font-size: 11px; font-weight: 600; letter-spacing: 0.04em; }
.panel-kicker .dot { width: 8px; height: 8px; border-radius: 50%; }
.panel-camp { margin-top: 10px; font-size: 12px; color: var(--ink-dim); border-left: 2px solid var(--line-strong); padding-left: 9px; }
.panel-camp b { color: var(--ink); font-weight: 600; }
.panel-type { margin-top: 14px; font-size: 10.5px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-faint); }
.panel-title { margin-top: 8px; font-size: 25px; font-weight: 510; line-height: 1.12; letter-spacing: -0.02em; }
.panel-summary { margin-top: 14px; font-size: 14px; line-height: 1.55; color: var(--ink-dim); }
.panel-meta { margin-top: 22px; display: flex; flex-direction: column; gap: 12px; border-top: 1px solid var(--line); padding-top: 18px; }
.panel-meta > div { font-size: 13px; color: var(--ink); }
.panel-meta span { display: block; font-size: 9.5px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-faint); margin-bottom: 3px; }
.stance { text-transform: uppercase; letter-spacing: 0.1em; font-weight: 600; }
.s-accelerate { color: #5fb3a1; } .s-caution { color: #d3a94f; }
.s-skeptical { color: #c96b6b; } .s-neutral { color: var(--ink-faint); }
.panel-share {
  margin-top: 22px; width: 100%; background: none; border: 1px solid var(--line-strong);
  color: var(--ink-dim); padding: 10px; border-radius: 7px; cursor: pointer;
  font: inherit; font-size: 12px; letter-spacing: 0.02em; transition: color .18s, border-color .18s, background .18s;
}
.panel-share:hover { color: var(--ink); background: rgba(243,244,245,0.05); }
.panel-rel { margin-top: 24px; border-top: 1px solid var(--line); padding-top: 18px; }
.panel-rel-h { font-size: 9.5px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-faint); margin-bottom: 12px; }
.rel-item {
  display: flex; align-items: baseline; gap: 10px; width: 100%; text-align: left;
  background: none; border: none; color: var(--ink-dim); cursor: pointer;
  font: inherit; padding: 8px 8px; border-radius: 6px; margin-left: -8px; transition: background .16s, color .16s;
}
.rel-item:hover { background: rgba(243,244,245,0.05); color: var(--ink); }
.rel-tag { flex: 0 0 auto; font-size: 9.5px; letter-spacing: 0.04em; text-transform: uppercase; border: 1px solid; border-radius: 4px; padding: 2px 6px; }
.rel-title { font-size: 12.5px; line-height: 1.3; }

/* ---- Intro overlay ---- */
.intro {
  position: fixed; inset: 0; z-index: 20;
  background: radial-gradient(120% 100% at 50% 40%, rgba(8,9,10,0.72), rgba(8,9,10,0.95));
  backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center;
  transition: opacity 1s ease, backdrop-filter 1s ease;
}
.intro.gone { opacity: 0; pointer-events: none; backdrop-filter: blur(0); }
.intro-inner { max-width: 560px; padding: 40px; text-align: center;
  animation: rise 1.1s cubic-bezier(.16,1,.3,1) both; }
@keyframes rise { from { opacity: 0; filter: blur(12px); transform: translateY(14px); } to { opacity: 1; filter: blur(0); transform: none; } }
.intro-eyebrow { font-size: 11px; font-weight: 600; letter-spacing: 0.32em; color: var(--ink-faint); }
.intro-h { margin-top: 22px; font-size: clamp(30px, 5vw, 52px); font-weight: 510; line-height: 1.04; letter-spacing: -0.03em; }
.intro-p { margin: 22px auto 0; max-width: 460px; font-size: 15px; line-height: 1.6; color: var(--ink-dim); }
.intro-actions { margin-top: 30px; display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.intro-btn {
  background: var(--ink); color: #08090A; border: none;
  font: inherit; font-size: 13px; font-weight: 600; letter-spacing: 0.02em;
  padding: 13px 26px; border-radius: 8px; cursor: pointer; transition: transform .2s, background .2s, border-color .2s, color .2s;
}
.intro-btn:hover { transform: translateY(-1px); background: #fff; }
.intro-btn.ghost {
  background: transparent; color: var(--ink-dim); border: 1px solid var(--line-strong);
}
.intro-btn.ghost:hover { background: rgba(243,244,245,0.06); color: var(--ink); }

/* ---- Guided-tour caption ---- */
.tourcap {
  position: fixed; bottom: 46px; left: 50%; transform: translateX(-50%) translateY(10px);
  z-index: 9; max-width: 540px; width: max-content; text-align: center;
  background: var(--plate); backdrop-filter: blur(14px);
  border: 1px solid var(--line-strong); border-radius: 10px;
  padding: 13px 20px; font-size: 13.5px; line-height: 1.5; color: var(--ink);
  opacity: 0; pointer-events: none; transition: opacity .45s ease, transform .45s ease;
}
.tourcap.on { opacity: 1; transform: translateX(-50%); pointer-events: auto; }
.tour-skip {
  margin-left: 12px; color: var(--ink-faint); cursor: pointer;
  font-size: 10.5px; letter-spacing: 0.1em; text-transform: uppercase;
}
.tour-skip:hover { color: var(--ink); }

/* one-time attention pulse on the mode toggle after entry */
.modewrap.pulse { animation: modepulse 1.3s ease 2; }
@keyframes modepulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(243,244,245,0); }
  50% { box-shadow: 0 0 0 6px rgba(243,244,245,0.06); }
}
.intro-hint { margin-top: 20px; font-size: 11px; letter-spacing: 0.06em; color: var(--ink-faint); }

/* ---- Mobile ---- */
@media (max-width: 720px) {
  .masthead { top: 14px; left: 16px; right: 16px; }
  .wordmark { font-size: 13px; letter-spacing: 0.16em; }
  .tagline, .span { display: none; }               /* declutter — the map speaks */
  .searchwrap { top: 42px; left: 16px; right: 16px; width: auto; }
  .hud { display: none; }
  .modewrap { top: 88px; }
  /* legend becomes a compact, scrimmed bottom sheet */
  .legendwrap {
    left: 0; right: 0; bottom: 0; width: 100%; padding: 34px 16px 16px;
    max-height: 46vh; overflow-y: auto;
    background: linear-gradient(to top, rgba(8,9,10,0.94) 55%, rgba(8,9,10,0));
  }
  .legend-item { font-size: 12.5px; padding: 6px; }
  .typekey { flex-flow: row wrap; gap: 4px 14px; margin-top: 4px; }
  .controls { right: 14px; bottom: calc(46vh + 14px); }
  .panel { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  .masthead, .legendwrap, .searchwrap, .controls, .hud { transition: none; opacity: 1; filter: none; transform: none; }
  .intro-inner { animation: none; }
  .panel { transition: none; }
}
