/* The radar screen. Dark, large type, made to be filmed at 1080p. */
:root {
  color-scheme: dark;
  --page: #0b0b0b;
  --surface: #191919;
  --surface-2: #222222;
  --text: #efefef;
  --text-2: #9c9c9c;
  --grid: #303030;
  --axis: #474747;
  --border: rgba(255, 255, 255, 0.10);
  /* mood: a diverging pair with a grey middle (validated; shapes carry it too) */
  --worried: #eb6263;
  --mixed: #8a8a8a;
  --hopeful: #338ced;
  --good: #0aac23;
  --good-text: #53c556;
  --font: system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--page); color: var(--text); font-family: var(--font); }
body { font-size: 18px; line-height: 1.4; }
button { font: inherit; color: inherit; }

.app {
  /* --h is set by radar.js: on a screen smaller than 1080p the page is shrunk to fit */
  height: var(--h, 100vh); transform-origin: 0 0; display: grid; gap: 20px; padding: 24px 32px;
  grid-template-rows: auto 1fr auto auto; grid-template-columns: minmax(0, 1.15fr) minmax(420px, 0.85fr);
  grid-template-areas: "head head" "radar side" "cover cover" "foot foot";
}

/* header */
header { grid-area: head; display: flex; align-items: center; gap: 24px; }
header h1 { margin: 0; font-size: 34px; font-weight: 700; letter-spacing: -0.01em; }
header .sub { color: var(--text-2); font-size: 18px; margin-top: 2px; }
header .grow { flex: 1; }
.status {
  display: inline-flex; align-items: center; gap: 12px; padding: 12px 22px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--border); font-size: 22px; font-weight: 600; min-width: 300px;
  justify-content: center; transition: background .3s, border-color .3s;
}
.status .dot { width: 14px; height: 14px; border-radius: 50%; background: var(--text-2); flex: none; }
.status[data-state="listening"] { border-color: var(--hopeful); }
.status[data-state="listening"] .dot { background: var(--hopeful); animation: pulse 1s infinite; }
.status[data-state="thinking"] .dot, .status[data-state="answering"] .dot,
.status[data-state="asking"] .dot { background: var(--text); animation: pulse 1.4s infinite; }
.status[data-state="mic_missing"] { border-color: var(--worried); }
.status[data-state="mic_missing"] .dot { background: var(--worried); }
.status[data-state="saved"] { border-color: var(--good); }
.status[data-state="saved"] .dot { background: var(--good); }
.status[data-state="off"] { color: var(--text-2); }
@keyframes pulse { 50% { transform: scale(1.5); opacity: .5; } }

/* radar */
.radar-wrap { grid-area: radar; position: relative; min-height: 0; display: flex; align-items: center; justify-content: center; }
#radar { width: 100%; height: 100%; max-height: calc(var(--h, 100vh) - 290px); overflow: visible; }
#radar .ring { fill: none; stroke: var(--grid); stroke-width: 1; }
#radar .spoke { stroke: var(--grid); stroke-width: 1; }
#radar .shape { fill: rgba(239, 239, 239, 0.06); stroke: rgba(239, 239, 239, 0.35); stroke-width: 1.5; transition: d .6s; }
#radar .label { fill: var(--text); font-size: 19px; font-weight: 600; cursor: pointer; }
#radar .label:hover { text-decoration: underline; }
#radar .count { fill: var(--text-2); font-size: 16px; }
#radar .axis-note { fill: var(--text-2); font-size: 13px; }
#radar .centre-n { fill: var(--text); font-size: 56px; font-weight: 700; }
#radar .centre-t { fill: var(--text-2); font-size: 17px; }
#radar .voice { cursor: pointer; }
#radar .voice .hit { fill: transparent; }
#radar .voice.selected .mark { stroke: var(--text); stroke-width: 3; }
#radar .worried { fill: var(--worried); stroke: var(--surface); stroke-width: 2; }
#radar .hopeful { fill: var(--hopeful); stroke: var(--surface); stroke-width: 2; }
#radar .mixed { fill: var(--surface); stroke: var(--mixed); stroke-width: 3; }
#radar .pending { fill: none; stroke: var(--text-2); stroke-width: 2; stroke-dasharray: 3 3; }
#radar .ping { fill: none; stroke: var(--text); stroke-width: 2; animation: ping 1.6s ease-out 3; }
@keyframes ping { from { r: 10; opacity: .9; } to { r: 70; opacity: 0; } }
#radar .sweep { transform-origin: 0 0; animation: sweep 6s linear infinite; }
@keyframes sweep { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  #radar .sweep, #radar .ping, .status .dot { animation: none !important; }
}

.tooltip {
  position: fixed; pointer-events: none; z-index: 10; max-width: 340px; padding: 12px 14px; border-radius: 8px;
  background: var(--surface-2); border: 1px solid var(--border); font-size: 16px; box-shadow: 0 6px 24px rgba(0,0,0,.5);
}
.tooltip .t-meta { color: var(--text-2); font-size: 14px; margin-top: 6px; }

/* side panel */
.side { grid-area: side; display: flex; flex-direction: column; gap: 14px; min-height: 0; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 16px 22px; }
.card h2 { margin: 0 0 12px; font-size: 15px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--text-2); }
.latest { min-height: 215px; }
.latest .quote { font-size: 30px; line-height: 1.3; font-weight: 500; margin: 0; }
.latest .quote.empty { color: var(--text-2); font-weight: 400; }
.latest .orig { color: var(--text-2); font-size: 18px; margin-top: 10px; }
.latest .ask { margin-top: 12px; font-size: 18px; }
.latest .ask b { color: var(--text-2); font-weight: 600; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; align-items: center; }
.chip { display: inline-flex; align-items: center; gap: 8px; padding: 5px 12px; border-radius: 999px; background: var(--surface-2); font-size: 16px; }
.meta { color: var(--text-2); font-size: 16px; margin-top: 12px; }
.new-flash { animation: flash 1.2s ease-out; }
@keyframes flash { from { background: #2a2a2a; } to { background: var(--surface); } }

.themes { flex: 1; min-height: 0; overflow: auto; }
.trow { display: grid; grid-template-columns: 170px 1fr 34px; gap: 12px; align-items: center; padding: 2px 0; cursor: pointer; }
.trow:hover .tname { text-decoration: underline; }
.tname { font-size: 17px; }
.tbar { display: flex; gap: 2px; height: 16px; }
.tbar span { display: block; height: 100%; }
.tbar span:first-child { border-radius: 4px 0 0 4px; }
.tbar span:last-child { border-radius: 0 4px 4px 0; }
.tbar span:only-child { border-radius: 4px; }
.tbar .worried { background: var(--worried); }
.tbar .mixed { background: var(--mixed); }
.tbar .hopeful { background: var(--hopeful); }
.tnum { text-align: right; font-variant-numeric: tabular-nums; color: var(--text-2); }
.cardhead { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; }
.legend { display: flex; gap: 18px; color: var(--text-2); font-size: 15px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }

.shifts .shift { display: flex; gap: 12px; align-items: baseline; padding: 4px 0; font-size: 18px; }
.shifts .arrow { font-weight: 700; width: 22px; text-align: center; }
.shifts .note { color: var(--text-2); font-size: 15px; }
#trend { width: 100%; height: 76px; display: block; margin-top: 10px; overflow: visible; }
#trend .zero { stroke: var(--axis); stroke-width: 1; }
#trend .line { fill: none; stroke: var(--text); stroke-width: 2; }
#trend .lbl { fill: var(--text-2); font-size: 12px; }
#trend .cross { stroke: var(--text-2); stroke-width: 1; }

/* footer */
footer { grid-area: foot; display: flex; align-items: center; gap: 28px; color: var(--text-2); font-size: 17px; }
footer .n { color: var(--text); font-weight: 700; font-size: 22px; }
footer .trust { display: flex; gap: 6px 18px; flex-wrap: wrap; }
footer .trust span::before { content: "✓ "; color: var(--good-text); }
footer .grow { flex: 1; }
.btn { background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 10px 18px; cursor: pointer; font-size: 17px; }
.btn:hover { border-color: var(--text-2); }
.btn.primary { background: var(--text); color: var(--page); border-color: var(--text); font-weight: 600; }

/* modals */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: none; align-items: center; justify-content: center; z-index: 20; }
.modal.open { display: flex; }
.modal .box { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; width: min(1100px, 92vw); max-height: 88vh; display: flex; flex-direction: column; }
.modal .bar { display: flex; align-items: center; gap: 12px; padding: 18px 22px; border-bottom: 1px solid var(--border); }
.modal .bar h3 { margin: 0; flex: 1; font-size: 22px; }
.modal .body { padding: 18px 26px 26px; overflow: auto; }
.brief h3 { font-size: 20px; margin: 22px 0 8px; }
.brief h3:first-child { margin-top: 0; }
.brief p, .brief li { font-size: 18px; }
.brief a.cite { color: var(--hopeful); text-decoration: none; font-size: 14px; }
.brief .by { color: var(--text-2); font-size: 14px; margin-top: 18px; }
table.voices { width: 100%; border-collapse: collapse; font-size: 16px; }
table.voices th { text-align: left; color: var(--text-2); font-weight: 600; padding: 8px; border-bottom: 1px solid var(--axis); position: sticky; top: 0; background: var(--surface); }
table.voices td { padding: 10px 8px; border-bottom: 1px solid var(--grid); vertical-align: top; }
table.voices td.q { width: 50%; }
table.voices td:nth-child(1), table.voices td:nth-child(3) { white-space: nowrap; }
table.voices tr.hl td { background: #262626; }
.link { background: none; border: none; color: var(--text-2); text-decoration: underline; cursor: pointer; padding: 0; font-size: 14px; }

/* trust: who we've heard, how we count, and the ball's own result kept apart */
.cover {
  grid-area: cover; display: flex; flex-wrap: wrap; gap: 8px 40px; align-items: baseline; margin-top: -4px;
  padding: 12px 22px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; font-size: 17px;
}
.cover > div { display: flex; gap: 12px; align-items: baseline; }
.cover b { font-weight: 700; }
.k { font-size: 13px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--text-2); white-space: nowrap; }
.ballhelp {
  display: flex; flex-direction: column; gap: 2px; padding: 8px 18px; border-radius: 12px;
  border: 1px dashed var(--axis); font-size: 17px;
}
.ballhelp[hidden] { display: none; }
.shifts .early { font-size: 15px; color: var(--text-2); padding-bottom: 4px; }
.shifts .early b { color: var(--text); }
.modal .box.narrow { width: min(820px, 92vw); }
.helpbox { margin-top: 24px; padding: 16px 20px; border: 1px dashed var(--axis); border-radius: 12px; }
.helpbox h3 { margin-top: 0; }
.helpbox p { margin: 6px 0; }
.brief .note { color: var(--text-2); font-size: 15px; }
table.voices .after { color: var(--text-2); margin-top: 4px; font-size: 15px; }
table.voices tr.repeat td { color: var(--text-2); }
h4.leftout { margin: 26px 0 6px; font-size: 16px; font-weight: 600; color: var(--text-2); }

@media print {
  body { background: #fff; color: #000; }
  .app, .modal .bar { display: none !important; }
  .modal#briefModal { position: static; display: block; background: none; }
  .modal .box { border: none; width: auto; max-height: none; background: #fff; }
  .brief a.cite { color: #1757ac; }
}

/* public copy: read-only, so no Remove or Count it buttons */
[data-hide], [data-count] { display: none; }
