/* Living Brain prototype v0.1. Islands rule: every element its own tint, dark text on tinted light panels. */
:root {
  --ink: #15112b;
  --ink-2: #2a2450;
  --night: #07060d;
  --gold: #ffc23d;
  --lav: #ece6ff;
  --sky: #e0f0ff;
  --mint: #ddf9ec;
  --peach: #ffeedd;
  --rose: #ffe5f0;
  --lemon: #fff6c9;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --serif: "Instrument Serif", "Iowan Old Style", Georgia, serif;
  --mono: ui-monospace, "JetBrains Mono", "SFMono-Regular", Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
html { scroll-behavior: auto; }
body {
  margin: 0;
  background: var(--night);
  color: var(--ink);
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.55;
  overflow-x: hidden;
}
.mono { font-family: var(--mono); letter-spacing: 0.02em; }

#scene {
  position: fixed; inset: 0;
  width: 100vw; height: 100vh;
  display: block;
  touch-action: pan-y;
  cursor: grab;
}
#scene.dragging { cursor: grabbing; }
#scene.over-hero { cursor: pointer; }

/* Loader */
#loader {
  position: fixed; inset: 0; z-index: 50;
  display: grid; place-items: center;
  background: var(--night);
  transition: opacity 0.8s ease;
}
#loader.done { opacity: 0; pointer-events: none; }
.loader-pill {
  background: var(--lav); color: var(--ink);
  padding: 14px 26px; border-radius: 999px;
  font-size: 15px; display: flex; gap: 14px; align-items: baseline;
}
.loader-pill b { font-family: var(--mono); font-size: 22px; min-width: 3.2em; text-align: right; }

/* HUD */
.hud {
  position: fixed; top: 0; left: 0; right: 0; z-index: 20;
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px; pointer-events: none;
}
.hud-right { display: flex; gap: 10px; }
.hud-pill {
  pointer-events: auto;
  color: var(--ink); text-decoration: none;
  border: 0; border-radius: 999px;
  padding: 8px 16px; font-size: 13px; font-weight: 600;
}
.hud-brand { background: var(--lemon); font-family: var(--font); }
.hud-chapter { background: var(--sky); }
.hud-sound { background: var(--mint); cursor: pointer; font: inherit; font-family: var(--mono); font-size: 13px; font-weight: 600; }
.hud-sound[aria-pressed="true"] { background: var(--peach); }
.hud-pill:focus-visible, .btn:focus-visible, .chip:focus-visible, .btn-small:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; }

/* Chapters: real HTML text, readable without the 3D */
main { position: relative; z-index: 10; pointer-events: none; }
.chapter {
  min-height: 100vh;
  display: flex; align-items: center;
  padding: 90px 16px 60px;
}
.chapter.loop { min-height: 100vh; }
.card {
  pointer-events: auto;
  width: min(460px, 100%);
  margin-left: max(16px, 6vw);
  padding: 26px 28px 24px;
  border-radius: 22px;
  color: var(--ink);
  box-shadow: 0 18px 60px rgba(0,0,0,0.35);
}
.card-1 { background: var(--lav); }
.card-2 { background: var(--sky); }
.card-3 { background: var(--mint); }
.card-4 { background: var(--peach); }
.card-5 { background: var(--rose); }
.card p { margin: 0 0 12px; color: var(--ink-2); }
.card h1, .card h2 {
  font-family: var(--serif); font-weight: 400; font-style: italic;
  font-size: clamp(36px, 5vw, 54px); line-height: 1.04; letter-spacing: -0.01em;
  margin: 0 0 14px; color: var(--ink);
}
.kicker { font-size: 12px; font-weight: 700; text-transform: uppercase; color: #4b2fb0 !important; }
.card-2 .kicker { color: #0b5aa8 !important; }
.card-3 .kicker { color: #0a6b44 !important; }
.card-4 .kicker { color: #9a4a00 !important; }
.card-5 .kicker { color: #a3134f !important; }
.hint { font-size: 12.5px; color: var(--ink-2) !important; margin-top: 14px !important; }

.btn {
  display: inline-block; margin-top: 6px;
  background: var(--lemon); color: var(--ink);
  padding: 12px 20px; border-radius: 999px;
  font-weight: 700; text-decoration: none;
}
.btn:hover { background: #ffec8f; }

/* Hero chips (keyboard / screen-reader way to meet the guardians) */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.chip {
  border: 0; border-radius: 999px; cursor: pointer;
  padding: 7px 13px; font: 600 13.5px var(--font); color: var(--ink);
}

/* Floating labels next to the crystals */
#labels { position: fixed; inset: 0; z-index: 5; pointer-events: none; }
.label {
  position: absolute; transform: translate(-50%, -150%);
  padding: 4px 10px; border-radius: 999px;
  font: 600 12px var(--font); color: var(--ink);
  white-space: nowrap; opacity: 0; transition: opacity 0.25s;
}
.label.show { opacity: 1; }

/* Hero dialog */
dialog#hero {
  border: 0; padding: 0; border-radius: 24px;
  width: min(720px, calc(100vw - 32px));
  color: var(--ink);
  box-shadow: 0 30px 90px rgba(0,0,0,0.55);
}
dialog#hero::backdrop { background: rgba(7,6,13,0.55); }
.hero-inner { display: grid; grid-template-columns: 1fr; }
#hero-img { width: 100%; height: auto; display: block; aspect-ratio: 553 / 309; object-fit: cover; background: #111; }
.hero-text { padding: 20px 24px 22px; }
.hero-text h3 { font-family: var(--serif); font-style: italic; font-weight: 400; font-size: 40px; margin: 0; line-height: 1.1; }
.hero-role { font-weight: 700; margin: 2px 0 8px; }
.hero-text p { margin: 0 0 10px; color: var(--ink-2); }
.hero-nav { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.btn-small { border: 0; border-radius: 999px; padding: 8px 14px; font: 600 13.5px var(--font); color: var(--ink); cursor: pointer; }
.b-prev { background: var(--sky); }
.b-next { background: var(--mint); }
.b-close { background: var(--lemon); }

.proto-note {
  position: fixed; left: 16px; bottom: 12px; z-index: 20; margin: 0;
  background: var(--peach); color: var(--ink);
  padding: 5px 12px; border-radius: 999px; font-size: 11.5px;
}

@media (max-width: 760px) {
  body { font-size: 16px; }
  .chapter { align-items: flex-end; padding-bottom: 70px; }
  .card { margin: 0 auto; padding: 20px; }
  .hud { padding: 12px; }
  .hud-brand { display: none; }
  .proto-note { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  #loader { transition: none; }
}
