/* =============================================================================
   CasesTrain — shared design layer
   -----------------------------------------------------------------------------
   Every game carries its own accent from the hub card into play. The accent is
   an RGB triplet in --ac (plus a lighter --ac-hi and deeper --ac-lo) so both the
   Tailwind brand-* utilities and hand-written CSS can use it with any opacity:
       color: rgb(var(--ac));            background: rgb(var(--ac) / 0.12);
   --ac-fg is the text colour that sits on a solid accent fill.
   main.js stamps body[data-game]; Habitat Builder also stamps body[data-terrain].
   ========================================================================== */

:root {
  color-scheme: dark;

  /* default (hub, legal, results fallback): CasesTrain blue */
  --ac: 58 166 255;
  --ac-hi: 93 208 255;
  --ac-lo: 31 127 224;
  --ac-fg: 255 255 255;

  --ink-950: #0b0f14;
  --ink-900: #0f1620;
  --ink-800: #152133;

  --good: 74 222 128;
  --warn: 246 197 96;
  --bad: 248 113 113;

  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-pop: cubic-bezier(0.2, 0.9, 0.3, 1.25);
}

/* Field Study — gold: field notes, sun on the mesa */
[data-game="redrock"]   { --ac: 240 180 41;  --ac-hi: 250 204 92;  --ac-lo: 212 150 20;  --ac-fg: 11 15 20; }
/* Microbial Migration — violet: UV lamp over a petri dish */
[data-game="microbial"] { --ac: 167 139 250; --ac-hi: 196 181 253; --ac-lo: 139 92 246;  --ac-fg: 11 15 20; }
/* Sustainable Future Lab — sky: dawn over the province */
[data-game="sfl"]       { --ac: 116 184 247; --ac-hi: 147 204 255; --ac-lo: 66 149 230;  --ac-fg: 11 15 20; }
/* Maritime Operations — cyan: open water */
[data-game="seawolf"]   { --ac: 93 208 255;  --ac-hi: 140 224 255; --ac-lo: 58 166 255;  --ac-fg: 11 15 20; }
/* Habitat Builder — colour follows the terrain that was rolled */
[data-game="ecosystem"]                        { --ac: 110 231 160; --ac-hi: 150 240 190; --ac-lo: 52 199 122;  --ac-fg: 11 15 20; }
[data-game="ecosystem"][data-terrain="reef"]   { --ac: 255 138 101; --ac-hi: 255 171 143; --ac-lo: 235 105 64;  --ac-fg: 11 15 20; }
[data-game="ecosystem"][data-terrain="alpine"] { --ac: 159 211 255; --ac-hi: 197 229 255; --ac-lo: 110 180 240; --ac-fg: 11 15 20; }
[data-game="ecosystem"][data-terrain="jungle"] { --ac: 110 231 160; --ac-hi: 150 240 190; --ac-lo: 52 199 122;  --ac-fg: 11 15 20; }
[data-game="ecosystem"][data-terrain="savanna"] { --ac: 255 180 87; --ac-hi: 255 205 130; --ac-lo: 224 140 48;  --ac-fg: 11 15 20; }

html,
body {
  font-family: "Inter", ui-sans-serif, system-ui, sans-serif;
}

/* ---------- ground: one dark lab, tinted by the active game ---------- */
body {
  background-color: var(--ink-950);
  background-image:
    radial-gradient(1200px 600px at 80% -10%, rgb(var(--ac) / 0.09), transparent 60%),
    radial-gradient(800px 500px at -10% 110%, rgb(var(--ac-lo) / 0.06), transparent 60%);
  background-attachment: fixed;
  transition: background-color 0.3s;
}

/* Subject tints — deliberately faint; the moving textures are in ambient.css. */
body[data-game="redrock"] {
  /* sun on the mesa; the drifting contours are in ambient.css */
  background-image:
    radial-gradient(1000px 500px at 85% 0%, rgb(var(--ac) / 0.07), transparent 60%),
    radial-gradient(800px 500px at -10% 110%, rgb(var(--ac-lo) / 0.05), transparent 60%);
}
body[data-game="microbial"] {
  /* colonies under a violet lamp */
  background-image:
    radial-gradient(260px 260px at 12% 18%, rgb(var(--ac) / 0.10), transparent 70%),
    radial-gradient(180px 180px at 88% 30%, rgb(var(--ac-hi) / 0.07), transparent 70%),
    radial-gradient(340px 340px at 70% 95%, rgb(var(--ac-lo) / 0.08), transparent 70%);
}
body[data-game="sfl"] {
  /* dawn band */
  background-image:
    linear-gradient(180deg, rgb(var(--ac) / 0.10) 0%, transparent 320px),
    radial-gradient(900px 400px at 100% 100%, rgb(var(--ac-lo) / 0.06), transparent 60%);
}
body[data-game="seawolf"] {
  /* deep water below; the moving swell is in ambient.css */
  background-image:
    radial-gradient(1200px 500px at 50% 110%, rgb(var(--ac) / 0.10), transparent 60%);
}
body[data-game="ecosystem"] {
  background-image:
    radial-gradient(900px 500px at -5% 105%, rgb(var(--ac) / 0.12), transparent 60%),
    radial-gradient(800px 400px at 100% -5%, rgb(var(--ac-lo) / 0.07), transparent 60%);
}

/* ---------- scrollbars ---------- */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.08); border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.16); }

/* ---------- focus ---------- */
:focus-visible {
  outline: 2px solid rgb(var(--ac-hi));
  outline-offset: 2px;
  border-radius: 6px;
}

/* ---------- header timer ---------- */
.timer-chip {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  min-width: 72px;
}
.timer-chip-time {
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 15px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: rgb(241, 245, 249);
  letter-spacing: 0.02em;
  line-height: 1;
  transition: color 0.3s;
}
.timer-chip-bar {
  width: 100%;
  height: 3px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}
.timer-chip-bar > i {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 3px;
  background: rgb(var(--ac));
  transition: width 0.5s linear, background 0.3s;
}
.timer-chip.timer-warn .timer-chip-time { color: rgb(var(--warn)); }
.timer-chip.timer-warn .timer-chip-bar > i { background: rgb(var(--warn)); }
.timer-chip.timer-danger .timer-chip-time { color: rgb(var(--bad)); animation: pulse 1s ease-in-out infinite; }
.timer-chip.timer-danger .timer-chip-bar > i { background: rgb(var(--bad)); }

/* legacy classes still used by Field Study's own header */
.timer-warn { color: rgb(var(--warn)); }
.timer-danger { color: rgb(var(--bad)); animation: pulse 1s ease-in-out infinite; }
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}

/* ---------- motion: answers to an action, never decoration ---------- */
.fade-in { animation: fadeIn 0.25s ease-out both; }
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* a thing that just arrived (a journal entry, a chosen species, a fleet pip) */
.pop { animation: popIn 0.28s var(--ease-pop) both; }
@keyframes popIn {
  0% { transform: scale(0.92); opacity: 0.4; }
  100% { transform: scale(1); opacity: 1; }
}

/* a drop that landed */
.drop-flash { animation: dropFlash 0.55s ease-out; }
@keyframes dropFlash {
  0% { box-shadow: 0 0 0 0 rgb(var(--good) / 0.75); }
  100% { box-shadow: 0 0 0 14px rgb(var(--good) / 0); }
}

/* a wrong move */
.shake { animation: shake 0.35s; }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

/* While something is being dragged, every place it can land shows itself. */
body.is-dragging [data-drop-zone] {
  outline: 2px dashed rgb(var(--ac) / 0.55);
  outline-offset: 3px;
  transition: outline-color 0.15s, background-color 0.15s;
}
body.is-dragging [data-drop-zone].drop-active {
  outline-style: solid;
  outline-color: rgb(var(--good));
  background-color: rgb(var(--good) / 0.10);
}
.dragging { opacity: 0.55; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

/* ---------- small shared atoms ---------- */
.bar-fill-gradient { background: linear-gradient(90deg, rgb(var(--ac)), rgb(var(--ac-hi))); }

.investigated-check::after {
  content: "✓";
  color: rgb(var(--good));
  margin-left: 6px;
  font-weight: 700;
}

.hex-tile { cursor: pointer; transition: filter 0.15s ease, transform 0.15s ease; }
.hex-tile:hover { filter: brightness(1.2); transform: translateY(-1px); }

/* ---------- icons (Lucide, inlined in src/ui/icons.js) ---------- */
.icon { display: inline-block; vertical-align: -0.18em; flex-shrink: 0; }
.icon-tile {
  display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
  border-radius: 10px;
  color: var(--tile);
  background: color-mix(in srgb, var(--tile) 16%, transparent);
  border: 1px solid color-mix(in srgb, var(--tile) 35%, transparent);
}
.icon-tile.icon-tile-round { border-radius: 50%; }

/* ---------- modal (plain CSS so it positions even if the Tailwind CDN lags) ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(4, 7, 11, 0.72);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 16px;
  animation: modalFadeIn 0.18s ease-out;
}
.modal {
  background: rgba(15, 22, 32, 0.97);
  border: 1px solid rgb(var(--ac) / 0.25);
  border-radius: 14px;
  box-shadow: 0 24px 60px -12px rgba(0, 0, 0, 0.7), 0 0 0 1px rgba(255, 255, 255, 0.04) inset;
  max-width: 640px;
  width: 100%;
  padding: 24px;
  max-height: 88vh;
  overflow-y: auto;
  animation: modalSlideIn 0.22s var(--ease-out);
}
@keyframes modalFadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes modalSlideIn {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ---------- Habitat Builder: the habitat strip ---------- */
.habitat-strip {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.habitat-slot {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  line-height: 1;
  border: 1.5px dashed rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.02);
  color: rgba(148, 163, 184, 0.35);
  font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif;
  cursor: default;
  transition: transform 0.15s, border-color 0.15s, background 0.15s;
}
.habitat-slot.filled {
  border-style: solid;
  border-color: var(--tier);
  background: color-mix(in srgb, var(--tier) 14%, transparent);
  cursor: pointer;
}
.habitat-slot.filled:hover { transform: translateY(-2px); background: color-mix(in srgb, var(--tier) 24%, transparent); }
.habitat-slot.filled.has-error { box-shadow: 0 0 0 2px rgb(var(--bad) / 0.7); }
.habitat-slot.filled.has-warning { box-shadow: 0 0 0 2px rgb(var(--warn) / 0.6); }
.habitat-slot-idx {
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 11px;
  font-weight: 600;
}
.habitat-arrow {
  color: rgba(148, 163, 184, 0.35);
  font-size: 14px;
  margin: 0 -2px;
}
.tier-stripe {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--tier);
  opacity: 0.85;
}

/* ---------- Maritime: fleet strip ---------- */
.fleet-strip {
  display: flex;
  align-items: stretch;
  gap: 14px;
  flex-wrap: wrap;
}
.fleet-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 120px;
}
.fleet-group-label {
  font-size: 12px;
  color: rgba(203, 213, 225, 0.85);
  display: flex;
  align-items: center;
  gap: 6px;
}
.fleet-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--zone); }
.fleet-pips { display: flex; gap: 4px; flex-wrap: wrap; min-height: 18px; }
.fleet-pip {
  width: 16px; height: 18px;
  border-radius: 3px 3px 8px 8px;
  background: var(--zone);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.4) inset;
}
.fleet-pip.empty {
  background: transparent;
  border: 1.5px dashed rgba(255, 255, 255, 0.18);
}

/* ---------- scenes: SVG pictures drawn from game state (src/ui/scenes.js) ---------- */
.scene { display: block; width: 100%; height: auto; border-radius: 12px; }
.scene-frame {
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid rgb(var(--ac) / 0.25);
  box-shadow: 0 16px 40px -20px rgba(0, 0, 0, 0.8);
  background: #0b0f14;
}
.hab-slot { transition: transform 0.15s; transform-box: fill-box; transform-origin: center; }
.hab-slot:hover { transform: translateY(-3px); }
.hab-slot:focus-visible { outline: none; }
.hab-slot:focus-visible circle:first-of-type { stroke: rgb(var(--ac-hi)); stroke-width: 3; }
.hab-slot.pop { animation: popIn 0.32s var(--ease-pop) both; }

/* ---------- empty states: 404, no results ---------- */
.empty-state {
  min-height: calc(100vh - 40px);
  display: flex; align-items: center; justify-content: center;
  padding: 32px 16px;
}
.empty-state-card {
  max-width: 460px; width: 100%;
  padding: 32px;
  text-align: center;
  background: rgba(15, 22, 32, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  backdrop-filter: blur(8px);
}
.empty-state-mark { width: 44px; height: 44px; margin: 0 auto 16px; }
.empty-state-mark svg { display: block; }
.empty-state-title {
  font-family: 'Sora', sans-serif;
  font-size: 22px; font-weight: 700;
  color: rgb(248, 250, 252);
  margin: 0 0 8px;
}
.empty-state-text {
  font-size: 14px; line-height: 1.6;
  color: rgba(203, 213, 225, 0.85);
  margin: 0 0 20px;
}
.empty-state-text code {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12.5px;
  background: rgba(255, 255, 255, 0.06);
  padding: 1px 6px; border-radius: 4px;
}
.empty-state-actions { display: flex; justify-content: center; gap: 10px; }

/* ---------- results page ---------- */
.results-top {
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) minmax(280px, 1fr);
  gap: 16px;
  align-items: stretch;
}
@media (max-width: 860px) { .results-top { grid-template-columns: 1fr; } }
.results-snapshot { margin: 0; min-width: 0; display: flex; flex-direction: column; justify-content: center; }
.results-snapshot .scene-frame { background: #0b0f14; }
.results-snapshot-compact { padding: 10px 0; }
.results-snapshot figcaption {
  margin-top: 8px;
  font-size: 12px;
  color: rgba(148, 163, 184, 0.9);
}
.results-lever {
  display: flex; flex-direction: column; justify-content: center; gap: 8px;
  padding: 22px 24px;
  border-radius: 14px;
  background: rgb(var(--ac) / 0.10);
  border: 1px solid rgb(var(--ac) / 0.45);
  box-shadow: 0 16px 40px -24px rgb(var(--ac) / 0.8);
}
.results-lever-kicker {
  font-family: 'Sora', sans-serif;
  font-size: 12px; font-weight: 700;
  color: rgb(var(--ac-hi));
}
.results-lever-text {
  font-family: 'Sora', sans-serif;
  font-size: 17px; font-weight: 600; line-height: 1.4;
  color: rgb(248, 250, 252);
}
.results-lever-meta { font-size: 12px; color: rgba(203, 213, 225, 0.75); }

/* section labels on results: sentence case in the display face instead of tracked caps */
.results-page .uppercase.tracking-wider {
  text-transform: none;
  letter-spacing: 0;
  font-family: 'Sora', sans-serif;
  font-weight: 600;
  color: rgb(226, 232, 240);
}
.results-page h3.uppercase.tracking-wider { font-size: 15px; }
.results-page .text-xs.uppercase.tracking-wider { font-size: 13px; }

/* ---------- hub hero with the latest run ---------- */
.hub-hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 32px;
  align-items: center;
}
@media (min-width: 1000px) {
  .hub-hero-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 520px); gap: 48px; }
}
.hub-hero-scene { margin: 0; min-width: 0; }
.hub-hero-scene .scene-frame { border-color: rgba(255, 255, 255, 0.10); }
.hub-hero-scene figcaption {
  margin-top: 10px;
  font-size: 12px;
  color: rgba(148, 163, 184, 0.85);
  display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap;
}
.hub-hero-scene figcaption b { color: rgb(241, 245, 249); font-weight: 600; }

/* ---------- logo ---------- */
.logo-mark { display: inline-block; vertical-align: middle; flex-shrink: 0; filter: drop-shadow(0 6px 14px rgba(58, 166, 255, 0.25)); }
.logo-lockup { display: inline-flex; align-items: center; gap: 9px; }
.logo-word {
  font-family: 'Sora', sans-serif;
  font-weight: 700; font-size: 15px; letter-spacing: -0.01em;
  color: rgb(241, 245, 249);
}
.logo-word-accent { color: rgb(93, 208, 255); }

/* ---------- Microbial site scene ---------- */
.mm-site-progress { position: relative; overflow: hidden; }
.mm-site-progress .scene { border-radius: 8px; }

/* ---------- Field Study banner ---------- */
.rr-banner { border-radius: 14px; overflow: hidden; margin-bottom: 18px; border: 1px solid rgb(var(--ac) / 0.25); }

/* =============================================================================
   De-templating: no tracked all-caps labels anywhere. Small labels are plain
   sentence-case Inter; the display face (Sora) is reserved for real headings.
   Status words that are meant to shout (READY, NOT VIABLE) are inline styled
   and untouched.
   ========================================================================== */
.rr-page-eyebrow, .rr-section-title, .rr-section-count, .rr-dossier-cat, .rr-meta-label, .rr-nav-section-title,
.rr-q-type, .rr-dossier-facts-label, .rr-q-numeric-unit, .rr-timer-label,
.mm-attr-section-title, .mm-card-attr-label, .mm-site-block-title, .mm-num-cell-label, .mm-choice-cell-label,
.mm-choice-foot, .mm-pill, .mm-tri-prompt,
.sfl-section-title, .sfl-narrative-label,
.eula-section-title,
.uppercase.tracking-wider, .uppercase.tracking-wide, .uppercase.tracking-widest {
  text-transform: none !important;
  letter-spacing: 0 !important;
  font-family: 'Inter', system-ui, sans-serif !important;
}
.rr-section-title { font-size: 14px !important; font-weight: 600 !important; color: rgb(226, 232, 240) !important; }
.rr-section-title .rr-section-count { font-weight: 400 !important; }
.rr-page-eyebrow, .rr-nav-section-title, .rr-dossier-cat, .rr-meta-label, .rr-q-type, .rr-dossier-facts-label,
.mm-site-block-title, .mm-attr-section-title, .sfl-section-title, .sfl-narrative-label, .mm-card-attr-label,
.mm-num-cell-label, .mm-choice-cell-label {
  font-size: 12px !important; font-weight: 500 !important; color: rgba(148, 163, 184, 0.9) !important;
}
.eula-section-title { font-size: 14px !important; font-weight: 600 !important; color: rgb(226, 232, 240) !important; }
.mm-pill { font-size: 12px !important; font-weight: 500 !important; }
.uppercase.tracking-wider, .uppercase.tracking-wide { font-weight: 500; color: rgba(148, 163, 184, 0.9); }
.uppercase.tracking-wider.text-xs, .uppercase.tracking-wide.text-xs { font-size: 12px; }
.uppercase.tracking-wider.text-sm { font-size: 14px; font-weight: 600; color: rgb(226, 232, 240); }

/* Phones: the mark alone is enough; the exercise title needs the room. */
@media (max-width: 640px) {
  .app-header .logo-word { display: none; }
}
