/* Newborn Brain 3D — compact neonatal anatomy console */
:root {
  /* --- brand / chrome --- */
  --accent:        #F29B8F;
  --accent-press:  #D97870;
  --accent-soft:   rgba(242, 155, 143, 0.16);
  --accent-ring:   rgba(242, 155, 143, 0.44);

  /* --- ink (on light glass) --- */
  --ink:        #172631;
  --ink-soft:   #405765;
  --ink-faint:  #647D8B;
  --ink-ghost:  #8FA1AA;
  --hair:       rgba(45, 72, 86, 0.16);
  --hair-2:     rgba(45, 72, 86, 0.10);

  /* --- light frosted glass --- */
  --glass:        rgba(246, 249, 252, 0.91);
  --glass-solid:  rgba(250, 252, 253, 0.99);
  --glass-hi:     rgba(255, 255, 255, 0.72);
  --glass-edge:   rgba(71, 98, 112, 0.20);
  --glass-shadow: 0 18px 54px rgba(49, 69, 80, 0.20), 0 1px 0 rgba(255,255,255,.85) inset;
  --field:        rgba(232, 239, 244, 0.82);

  /* --- specimen stage (dark) --- */
  --stage-1: #EAF1F5;
  --stage-2: #D7E2E9;
  --stage-3: #C7D4DD;
  --on-stage:        #20343F;
  --on-stage-soft:   #5F7784;

  /* --- 11 subsystem colors (mirror of BRAIN.palette) --- */
  --c-cortex:        #A9827B;
  --c-white_matter:  #B99991;
  --c-deep_grey:     #747A82;
  --c-diencephalon:  #8D91CF;
  --c-brainstem:     #D7A06D;
  --c-cerebellum:    #A9827B;
  --c-ventricles:    #74C9E8;
  --c-arteries:      #E35D70;
  --c-veins_sinuses: #667FC4;
  --c-cranial_nerves:#D6C765;
  --c-meninges_dura: #B96BB1;

  --r-lg: 18px;
  --r-md: 13px;
  --r-sm: 9px;
  --font: 'Manrope', system-ui, -apple-system, sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, monospace;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0; height: 100%;
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overscroll-behavior: none;
}
body { overflow: hidden; background: #D7E2E9; color: var(--ink); }
#root { position: fixed; inset: 0; }

/* ---------- stage ---------- */
.stage {
  position: absolute; inset: 0;
  background:
    radial-gradient(120% 95% at 50% 38%, var(--stage-1) 0%, var(--stage-2) 46%, var(--stage-3) 100%);
}
.stage::after {  /* subtle vignette + grain feel */
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(130% 100% at 50% 45%, transparent 58%, rgba(56,79,91,0.16) 100%);
}
canvas.three { position: absolute; inset: 0; display: block; width: 100%; height: 100%; }

.project-credit {
  position: absolute;
  z-index: 11;
  left: 16px;
  bottom: 16px;
  max-width: min(620px, calc(100vw - 32px));
  color: rgba(49, 68, 79, 0.72);
  font-size: 10.5px;
  line-height: 1.45;
  letter-spacing: 0.01em;
}
.project-credit a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
.project-credit a:hover { color: var(--ink); }
.project-credit.mobile {
  left: 14px;
  right: 14px;
  bottom: calc(72px + env(safe-area-inset-bottom));
  max-width: none;
  text-align: center;
  font-size: 8.5px;
  line-height: 1.35;
  pointer-events: auto;
}

.volume-slice-view {
  position: absolute;
  inset: 0 min(40vw, 520px) 0 0;
  z-index: 3;
  overflow: hidden;
  background: #dbe4ec;
}
.volume-slice-canvas {
  position: absolute;
  inset: 4.5% 3% 16%;
  width: 94%;
  height: 79.5%;
  object-fit: contain;
  display: block;
  background: #dbe4ec;
  filter: contrast(1.04);
}
.volume-slice-status {
  position: absolute;
  top: 18px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 13px;
  border: 1px solid rgba(77,99,113,.18);
  border-radius: 11px;
  background: rgba(248,251,253,.9);
  box-shadow: 0 6px 22px rgba(40,57,68,.09);
  color: #2f4551;
  pointer-events: none;
}
.volume-slice-status strong { font-size: 12px; }
.volume-slice-status span { font-size: 10px; color: #607783; }
.volume-slice-hover {
  position: absolute;
  top: 76px;
  left: 50%;
  transform: translateX(-50%);
  padding: 6px 11px;
  border-radius: 999px;
  background: rgba(28,43,52,.9);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  pointer-events: none;
}
.volume-slice-key {
  position: absolute;
  left: 18px;
  bottom: 20px;
  display: grid;
  grid-template-columns: repeat(2, max-content);
  gap: 5px 13px;
  padding: 8px 10px;
  border: 1px solid rgba(77,99,113,.16);
  border-radius: 10px;
  background: rgba(248,251,253,.86);
  color: #4d6673;
  font-size: 9.5px;
  pointer-events: none;
}
.volume-slice-key span { display: flex; align-items: center; gap: 5px; }
.volume-slice-key i { width: 7px; height: 7px; border-radius: 50%; box-shadow: 0 0 0 1px rgba(34,51,60,.12); }
.volume-slice-orientation span {
  position: absolute;
  color: #536d7a;
  font: 700 11px/1 var(--mono);
  opacity: .82;
  pointer-events: none;
}
.volume-slice-orientation .top { top: 62px; left: 50%; }
.volume-slice-orientation .bottom { bottom: 19%; left: 50%; }
.volume-slice-orientation .left { left: 18px; top: 44%; }
.volume-slice-orientation .right { right: 18px; top: 44%; }

@media (max-width: 1100px) {
  .volume-slice-view { right: 380px; }
}

.mobile-dock {
  position: absolute;
  z-index: 46;
  left: 8px;
  right: 8px;
  bottom: max(8px, env(safe-area-inset-bottom));
  height: 48px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  padding: 5px;
  border-radius: 16px;
}
.mobile-dock button {
  border: 0;
  border-radius: 11px;
  background: transparent;
  color: var(--ink-faint);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  font-size: 12px;
  font-weight: 750;
  touch-action: manipulation;
}
.mobile-dock button.active { background: var(--accent); color: #172631; }

.mobile-slice-compact {
  position: absolute;
  z-index: 45;
  left: 8px;
  right: 8px;
  bottom: 64px;
  min-height: 54px;
  display: grid;
  grid-template-columns: 82px minmax(0, 1fr) 42px 42px;
  align-items: center;
  gap: 8px;
  padding: 7px 8px 7px 12px;
  border-radius: 15px;
  color: var(--ink);
}
.mobile-slice-compact-title { display: flex; flex-direction: column; gap: 2px; font-size: 12px; }
.mobile-slice-compact-title span { color: var(--ink-faint); font-size: 10px; }
.mobile-slice-compact input[type="range"] { width: 100%; min-height: 32px; }
.mobile-slice-compact button {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  border: 1px solid var(--glass-edge);
  background: rgba(255,255,255,.56);
  color: var(--ink-soft);
}

.mobile-control-compact {
  position: absolute;
  z-index: 45;
  left: 8px;
  right: 8px;
  bottom: 64px;
  min-height: 54px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) 42px;
  align-items: center;
  gap: 10px;
  padding: 7px 8px 7px 14px;
  border-radius: 15px;
}
.mobile-control-compact > span:first-child { display: flex; align-items: center; gap: 8px; color: var(--ink); font-size: 12.5px; font-weight: 800; }
.mobile-control-compact-hint { color: var(--ink-faint); font-size: 10.5px; text-align: right; }
.mobile-control-compact button {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  border: 1px solid var(--glass-edge);
  background: rgba(255,255,255,.56);
  color: var(--ink-soft);
}

@media (max-width: 640px) {
  .volume-slice-view { right: 0; }
  .volume-slice-canvas { inset: 9% 2% 28%; width: 96%; height: 63%; }
  .volume-slice-status { top: 58px; max-width: calc(100vw - 32px); text-align: center; }
  .volume-slice-key { left: 10px; bottom: 58px; max-width: calc(100vw - 20px); }
  .mobile-slice-panel input[type="range"] { min-height: 28px; }
  .mobile-slice-compact { bottom: calc(64px + env(safe-area-inset-bottom)); }
  .mobile-control-compact { bottom: calc(64px + env(safe-area-inset-bottom)); }
  button, input, a { -webkit-tap-highlight-color: transparent; }
}

/* ---------- floating window chrome ---------- */
.glass {
  background: var(--glass);
  -webkit-backdrop-filter: blur(26px) saturate(165%);
  backdrop-filter: blur(26px) saturate(165%);
  border: 1px solid var(--glass-edge);
  box-shadow: var(--glass-shadow);
  border-radius: var(--r-lg);
}
.glass-top-hi { background-image: linear-gradient(var(--glass-hi), transparent 90px); }

/* scrollbars inside panels */
.scroll { scrollbar-width: thin; scrollbar-color: rgba(20,24,36,0.22) transparent; }
.scroll::-webkit-scrollbar { width: 9px; }
.scroll::-webkit-scrollbar-thumb { background: rgba(20,24,36,0.18); border-radius: 9px; border: 2px solid transparent; background-clip: padding-box; }
.scroll::-webkit-scrollbar-thumb:hover { background: rgba(20,24,36,0.30); background-clip: padding-box; }
.preset-rail { scrollbar-width: thin; scrollbar-color: rgba(242,155,143,.35) transparent; }
.preset-rail::-webkit-scrollbar { height: 5px; }
.preset-rail::-webkit-scrollbar-thumb { background: rgba(242,155,143,.35); border-radius: 9px; }

/* ---------- focus ---------- */
:focus-visible { outline: 2px solid var(--accent-ring); outline-offset: 1px; }
button { font-family: inherit; cursor: pointer; }

/* ---------- helpers ---------- */
.mono { font-family: var(--mono); font-feature-settings: "tnum" 1; }
.eyebrow {
  font-family: var(--mono); font-weight: 500;
  font-size: 10px; letter-spacing: 0.13em; text-transform: uppercase;
  color: var(--ink-faint);
}
.noselect { -webkit-user-select: none; user-select: none; }

@keyframes popIn { from { opacity: 0; transform: translateY(8px) scale(0.98); } to { opacity: 1; transform: none; } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes riseIn { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
.pop { animation: popIn 0.32s cubic-bezier(0.16, 1, 0.3, 1); }
.rise { animation: riseIn 0.42s cubic-bezier(0.16, 1, 0.3, 1) both; }
.fade { animation: fadeIn 0.3s ease both; }   /* opacity-only - safe for translateX-centred cards */

@media (prefers-reduced-motion: reduce) {
  .pop, .rise { animation: none; }
}

/* ---------- cinematic narration / lesson cards (dark glass over the stage) ---------- */
.glass-dark {
  --on-stage: #F8FAFC;
  --on-stage-soft: #D5DEE7;
  background: rgba(13, 17, 26, 0.66);
  -webkit-backdrop-filter: blur(22px) saturate(150%);
  backdrop-filter: blur(22px) saturate(150%);
  border: 1px solid rgba(255,255,255,0.10);
  box-shadow: 0 1px 2px rgba(0,0,0,0.4), 0 18px 48px -10px rgba(0,0,0,0.6);
  border-radius: var(--r-lg);
  color: var(--on-stage);
}
.eyebrow-light { color: var(--on-stage-soft); }

/* fade hint at the bottom of a scrollable panel body (Systems / Learn) */
.panel-fade {
  position: absolute; left: 1px; right: 1px; bottom: 0; height: 34px;
  pointer-events: none; border-radius: 0 0 var(--r-lg) var(--r-lg);
  background: linear-gradient(to bottom, rgba(249,250,252,0), var(--glass));
}
.scroll-dark { scrollbar-width: thin; scrollbar-color: rgba(255,255,255,0.22) transparent; }
.scroll-dark::-webkit-scrollbar { width: 8px; }
.scroll-dark::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.18); border-radius: 9px; }
