/* Five9 Lab university layer. Themes, chrome, diagrams, motion. */

html[data-theme="futuristic"] {
  --cc-bg: #061018;
  --cc-surface: #0e1c2c;
  --cc-surface-2: #143049;
  --cc-accent-1: #5ce1ff;
  --cc-accent-2: #ffb020;
  --cc-accent-3: #9b8cff;
  --cc-accent-4: #3ee0a2;
  --cc-text: #e8f4ff;
  --cc-muted: #b7c9dc;
  --cc-line: #24506e;
  --cc-danger: #ff8b9a;
  --cc-ink: #061018;
  --cc-link: #9aefff;
  --cc-ok: #3ee0a2;
  --cc-scope: #03080f;
  --cc-scope-text: #d7f6ff;
  --cc-shadow: 0 22px 50px rgba(0, 0, 0, 0.45);
  --glow: 0 0 24px color-mix(in srgb, var(--cc-accent-1) 45%, transparent);
  color-scheme: dark;
}

html[data-theme="gaming"] {
  --cc-bg: #14081c;
  --cc-surface: #241032;
  --cc-surface-2: #341848;
  --cc-accent-1: #c6ff4a;
  --cc-accent-2: #ff2bd6;
  --cc-accent-3: #2ee9ff;
  --cc-accent-4: #ffe14a;
  --cc-text: #f6ffe8;
  --cc-muted: #e0d0f0;
  --cc-line: #6a3a86;
  --cc-danger: #ff6b8a;
  --cc-ink: #14081c;
  --cc-link: #e8ff9a;
  --cc-ok: #c6ff4a;
  --cc-scope: #0c0612;
  --cc-scope-text: #f6ffe8;
  --cc-shadow: 0 16px 0 #3a1848;
  --glow: 0 0 18px color-mix(in srgb, var(--cc-accent-2) 50%, transparent);
  color-scheme: dark;
}

html[data-theme="neon"] {
  --cc-bg: #05030a;
  --cc-surface: #140818;
  --cc-surface-2: #241028;
  --cc-accent-1: #2ee9ff;
  --cc-accent-2: #ff2bd6;
  --cc-accent-3: #d6ff4a;
  --cc-accent-4: #ff5c7a;
  --cc-text: #f4fbff;
  --cc-muted: #c9d6ea;
  --cc-line: #3a2458;
  --cc-danger: #ff5c7a;
  --cc-ink: #05030a;
  --cc-link: #7ef9ff;
  --cc-ok: #d6ff4a;
  --cc-scope: #020108;
  --cc-scope-text: #f4fbff;
  --cc-shadow: 0 0 32px rgba(46, 233, 255, 0.18);
  --glow: 0 0 22px #ff2bd6;
  color-scheme: dark;
}

html[data-theme="light"] {
  --cc-bg: #f6f1e6;
  --cc-surface: #fffdf8;
  --cc-surface-2: #efe6d6;
  --cc-accent-1: #0f5f78;
  --cc-accent-2: #9a3412;
  --cc-accent-3: #5b21b6;
  --cc-accent-4: #047857;
  --cc-text: #1c1915;
  --cc-muted: #3f3a33;
  --cc-line: #d9cbb6;
  --cc-danger: #9f1239;
  --cc-ink: #fffdf8;
  --cc-link: #0b4f66;
  --cc-ok: #047857;
  --cc-scope: #1c1915;
  --cc-scope-text: #fffdf8;
  --cc-shadow: 0 16px 36px rgba(60, 40, 20, 0.08);
  --glow: none;
  color-scheme: light;
}

body {
  background: transparent;
}
body > *:not(#sky) {
  position: relative;
  z-index: 1;
}
#sky {
  position: fixed;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

#readbar {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  width: 0;
  background: linear-gradient(90deg, var(--cc-accent-1), var(--cc-accent-2));
  z-index: 30;
  pointer-events: none;
}

.utilbar {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 6px 14px;
  background: color-mix(in srgb, var(--cc-bg) 82%, black);
  border-bottom: 1px solid var(--cc-line);
  overflow-x: auto;
  position: sticky;
  top: 0;
  z-index: 8;
}
.utilbar a, .utilbar button.linkish {
  color: var(--cc-muted);
  font-size: 0.78rem;
  text-decoration: none;
  white-space: nowrap;
  background: none;
  border: 0;
  font: inherit;
  cursor: pointer;
  min-height: 32px;
}
.utilbar a:hover, .utilbar button.linkish:hover { color: var(--cc-link); }

.topbar { top: 38px; z-index: 7; flex-wrap: wrap; }
.rail { top: 96px; height: calc(100vh - 96px); }

html[data-theme="neon"] h1,
html[data-theme="gaming"] .brand-name {
  text-shadow: var(--glow);
}

html[data-theme="futuristic"] body,
html[data-theme="futuristic"] {
  background-image:
    linear-gradient(color-mix(in srgb, var(--cc-accent-1) 14%, transparent) 1px, transparent 1px),
    linear-gradient(90deg, color-mix(in srgb, var(--cc-accent-1) 14%, transparent) 1px, transparent 1px);
  background-size: 48px 48px;
  background-position: center top;
}

html[data-theme="gaming"] .panel,
html[data-theme="gaming"] .card,
html[data-theme="gaming"] a.card {
  border-width: 2px;
  border-radius: 4px 18px 4px 18px;
}

html[data-theme="neon"] .panel,
html[data-theme="neon"] a.card {
  box-shadow: var(--glow);
}

.quick-themes { display: flex; gap: 6px; }
.quick-themes .swatch { width: 28px; height: 28px; min-height: 28px; border-radius: 50%; }

.mascot-link {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  text-decoration: none;
  flex: none;
}
#mascot {
  width: 52px;
  height: 52px;
  overflow: visible;
  animation: bob 3.6s ease-in-out infinite;
}
#mascot .head, .mascot-svg .head { fill: #c9844a; }
#mascot .ear, .mascot-svg .ear { fill: #a8653a; }
#mascot .muzzle, .mascot-svg .muzzle { fill: #f0c9a0; }
#mascot .eye, .mascot-svg .eye { fill: #1b120c; }
#mascot .shine, .mascot-svg .shine { fill: #fff; }
#mascot .smile, .mascot-svg .smile { fill: none; stroke: #5a3018; stroke-width: 1.4; }
#mascot .lid, .mascot-svg .lid { fill: #c9844a; transform-box: fill-box; transform-origin: center; animation: blink 4.8s infinite; }
#mascot .tail, .mascot-svg .tail { fill: none; stroke: #a8653a; stroke-width: 3; stroke-linecap: round; animation: wag 1.6s ease-in-out infinite; }
#mascot .prop, .mascot-svg .prop { display: none; }
html[data-look="ivr"] #mascot .prop-ivr,
html[data-look="dial"] #mascot .prop-dial,
html[data-look="boss"] #mascot .prop-boss,
html[data-look="night"] #mascot .prop-night,
html[data-look="dawn"] #mascot .prop-dawn,
html[data-look="dusk"] #mascot .prop-dusk,
html[data-look="egg"] #mascot .prop-egg,
html[data-look="day"] #mascot .prop-day { display: block; }
html[data-egg="1"] #mascot { filter: drop-shadow(0 0 8px var(--cc-accent-2)); }

@keyframes bob { 50% { transform: translateY(-3px); } }
@keyframes blink { 0%, 90%, 100% { transform: scaleY(0.08); } 94% { transform: scaleY(1); } }
@keyframes wag { 50% { transform: rotate(12deg); transform-origin: 8px 40px; } }

.uni-search { display: flex; gap: 6px; align-items: center; min-width: 0; }
.uni-search input { min-height: 36px; width: min(220px, 34vw); }

.site-footer {
  border-top: 1px solid var(--cc-line);
  padding: 22px 16px 28px;
  background: color-mix(in srgb, var(--cc-surface) 90%, transparent);
  margin-top: 12px;
}
.foot-grid {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 16px;
}
.signature { font-weight: 700; letter-spacing: -0.03em; }
.next-labs { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.next-labs a, .chip {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 4px 10px;
  border: 1px solid var(--cc-line);
  border-radius: 999px;
  text-decoration: none;
  color: var(--cc-text);
  background: var(--cc-surface);
}
.legal { font-size: 0.85rem; color: var(--cc-muted); max-width: 80ch; }
.copyright { margin: 8px 0 14px; font-weight: 700; }
.brand-links { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; min-width: 0; }
.brand-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  padding: 2px 10px;
  border: 1px solid color-mix(in srgb, var(--scene-a, var(--cc-accent-1)) 55%, var(--cc-line));
  border-radius: 999px;
  background: color-mix(in srgb, var(--cc-bg) 72%, transparent);
  color: var(--cc-text);
  text-decoration: none;
  font-size: 0.78rem;
  font-weight: 700;
  white-space: nowrap;
}
.brand-icon { width: 16px; height: 16px; flex: none; display: block; }
.share-card { display: block; width: min(100%, 640px); height: auto; aspect-ratio: 1200 / 630; }
#home-stage, #home-stage canvas { width: 108px; height: 108px; aspect-ratio: 1; display: block; }
.glyph { aspect-ratio: 1; display: block; }

.uni-hero, .deck {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}
.snap {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(260px, 32%);
  gap: 12px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  padding-bottom: 6px;
}
.snap .figure, .float-card {
  scroll-snap-align: start;
  background: var(--cc-surface);
  border: 1px solid var(--cc-line);
  border-radius: 16px;
  padding: 10px;
}
.float-card { animation: floaty 7s ease-in-out infinite; }
.float-card:nth-child(2n) { animation-delay: -2s; }
@keyframes floaty { 50% { transform: translateY(-6px); } }

.diag { width: 100%; height: auto; display: block; aspect-ratio: auto; }
.diag-bg { fill: var(--cc-scope); }
.node rect { fill: var(--cc-surface); stroke: var(--cc-accent-1); stroke-width: 1.5; }
.node.tone-b rect { stroke: var(--cc-accent-2); }
.node.tone-c rect { stroke: var(--cc-accent-4); }
.node.tone-d rect { stroke: var(--cc-accent-3); }
.node text, .msg, .lane { fill: var(--cc-scope-text); font-size: 13px; font-family: "Lab UI", "Segoe UI", sans-serif; }
.lane { fill: var(--cc-accent-1); font-size: 12px; }
.lane-line { stroke: var(--cc-line); }
.flow-line { stroke: var(--cc-accent-1); stroke-width: 2; stroke-dasharray: 7 5; animation: march 1.1s linear infinite; }
.arrow-head { fill: var(--cc-accent-2); }
@keyframes march { to { stroke-dashoffset: -24; } }

.explorer { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(220px, 0.6fr); gap: 12px; }
.explorer svg .hot { cursor: pointer; }
.explorer svg .hot rect { transition: stroke-width 0.2s; }
.explorer svg .hot.is-on rect { stroke-width: 3; }

.game-score { font-variant-numeric: tabular-nums; font-size: 1.4rem; }
.choice-grid { display: grid; gap: 8px; }
.choice-grid button { text-align: left; }

.badge-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px; }
.badge {
  border: 1px solid var(--cc-line);
  border-radius: 16px;
  padding: 12px;
  background: var(--cc-surface);
  min-height: 120px;
}
.badge.earned { border-color: var(--cc-accent-4); box-shadow: var(--glow); }
.badge strong { display: block; }

.sheet-list { display: grid; gap: 8px; }
.toast {
  position: fixed;
  right: 12px;
  bottom: 72px;
  background: var(--cc-surface);
  color: var(--cc-text);
  border: 1px solid var(--cc-accent-2);
  border-radius: 12px;
  padding: 10px 12px;
  z-index: 20;
  box-shadow: var(--cc-shadow);
}

html[data-read="1"] .rail { display: none; }
html[data-read="1"] .shell { grid-template-columns: 1fr; }
html[data-read="1"] main { max-width: 78ch; margin: 0 auto; }

.card, a.card {
  transform-style: preserve-3d;
  transition: transform 0.25s ease, border-color 0.25s ease;
}
a.card:hover { transform: translateY(-4px) rotateX(3deg); }

.path-row { display: grid; grid-template-columns: 88px 1fr; gap: 8px; align-items: start; }

@media (max-width: 960px) {
  .foot-grid, .explorer { grid-template-columns: 1fr; }
  .snap { grid-auto-columns: 80%; }
}
.primary-menu {
  flex: 1 0 100%;
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-top: 8px;
}
.primary-menu a {
  flex: none;
  font-weight: 800;
  font-size: 0.95rem;
  letter-spacing: 0.01em;
  text-decoration: none;
  color: var(--cc-ink);
  background: var(--cc-accent-1);
  border-radius: 999px;
  padding: 8px 14px;
  border: 1px solid transparent;
}
.primary-menu a:nth-child(2) { background: var(--cc-accent-2); }
.primary-menu a:nth-child(3) { background: var(--cc-accent-3); color: #fff; }
.primary-menu a:nth-child(4) { background: var(--cc-accent-4); }
.primary-menu a:nth-child(n+5) {
  background: var(--cc-surface-2);
  color: var(--cc-text);
  border-color: var(--cc-line);
}
.primary-menu a[aria-current="page"] { outline: 2px solid var(--cc-text); outline-offset: 2px; }

.crumbs { font-size: 0.85rem; margin: 0 0 6px; color: var(--cc-muted); }
.crumbs a { color: var(--cc-link); }

body[data-route="#/"] #view-title,
body[data-route="#/"] #lede,
body[data-route="#/"] #crumbs { display: none; }
body[data-route="#/"] main { padding-top: 8px; }
.mascot-link, #mascot { width: 48px; height: 48px; }
.topbar { padding: 6px 10px; }

.fold { display: grid; gap: 8px; }
.fold-head, .mini-row {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: nowrap;
}
.fold-head { justify-content: space-between; overflow-x: auto; }
.mini { width: 48px; }
.live-counters { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.live-counters .panel { padding: 8px 10px; }
.live-counters .stat strong { font-size: clamp(1.35rem, 4vw, 2.2rem); font-variant-numeric: tabular-nums; }
.live-counters .stat span { font-size: 0.75rem; }
.spot-row { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.spotlight {
  display: grid;
  align-content: center;
  min-height: 64px;
  padding: 8px 10px;
  border-radius: 16px;
  text-decoration: none;
  color: var(--cc-ink);
  background: var(--cc-accent-1);
  box-shadow: var(--cc-shadow);
}
.spotlight:nth-child(2) { background: var(--cc-accent-2); }
.spotlight:nth-child(3) { background: var(--cc-accent-3); color: #fff; }
.spotlight:nth-child(4) { background: var(--cc-accent-4); }
.spotlight span { font-size: 0.78rem; font-weight: 800; letter-spacing: 0.04em; text-transform: uppercase; }
.spotlight strong { font-size: 1.05rem; white-space: nowrap; }
.fold-art { display: grid; grid-template-columns: minmax(0, 1fr) 150px; gap: 10px; align-items: center; }
.fold-svg { width: 100%; height: auto; max-height: 118px; }
.fold-side { display: grid; justify-items: center; gap: 4px; }
#rough-mark { width: 120px; height: 48px; }
#home-stage { width: 108px; height: 108px; }
#home-stage canvas { width: 108px; height: 108px; }
.fold-tools { display: grid; gap: 8px; }
@media (min-width: 801px) {
  .fold-tools { grid-template-columns: auto minmax(0, 1fr); align-items: start; }
}
.node-box { fill: var(--cc-surface); stroke: var(--cc-accent-1); }
.node-box.b { stroke: var(--cc-accent-2); }
.node-box.c { stroke: var(--cc-accent-4); }
.packet { fill: var(--cc-accent-2); offset-path: path("M78 96 H520"); animation: ride 2.2s linear infinite; }
.packet:nth-child(odd) { animation-delay: -0.7s; fill: var(--cc-accent-1); }
@keyframes ride { to { offset-distance: 100%; } }
.mini { display: grid; justify-items: center; width: 48px; }
.mini .mascot-svg { width: 56px; height: 56px; }
.mini .prop { display: none; }
.mini[data-look="dawn"] .prop-dawn,
.mini[data-look="day"] .prop-day,
.mini[data-look="dusk"] .prop-dusk,
.mini[data-look="night"] .prop-night { display: block; }
.mini-name { font-size: 0.7rem; color: var(--cc-muted); text-transform: capitalize; }
.icon-row { display: flex; gap: 14px; height: 64px; align-items: center; perspective: 700px; transform-style: preserve-3d; }
.cube {
  width: 48px;
  height: 48px;
  position: relative;
  transform-style: preserve-3d;
  animation: spin3d 9s linear infinite;
}
.cube:nth-child(2) { animation-delay: -2s; }
.cube:nth-child(3) { animation-delay: -4s; }
.cube:nth-child(4) { animation-delay: -6s; }
.cube-face, .cube::before, .cube::after {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  border: 1px solid var(--cc-accent-1);
  background: color-mix(in srgb, var(--cc-accent-1) 22%, var(--cc-surface));
  color: var(--cc-text);
  font-size: 0.62rem;
  font-weight: 800;
}
.cube-face { transform: translateZ(24px); }
.cube::before { content: ""; transform: rotateY(90deg) translateZ(24px); background: color-mix(in srgb, var(--cc-accent-2) 35%, var(--cc-surface)); }
.cube::after { content: ""; transform: rotateX(90deg) translateZ(24px); background: color-mix(in srgb, var(--cc-accent-3) 35%, var(--cc-surface)); }
@keyframes spin3d { to { transform: rotateY(360deg) rotateX(16deg); } }
.chart-snap, .chart-grid { display: grid; gap: 10px; }
.chart-snap { grid-auto-flow: column; grid-auto-columns: minmax(220px, 32%); overflow-x: auto; }
.chart-snap .chart-card { max-height: 210px; overflow: auto; }
.chart-grid { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.chart-card, .atlas-grid .figure {
  background: var(--cc-surface);
  border: 1px solid var(--cc-line);
  border-radius: 16px;
  padding: 8px;
}
.atlas-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 12px; }
.chart { width: 100%; height: auto; display: block; }
.chart text { fill: var(--cc-text); font-size: 11px; font-family: "Lab UI", "Segoe UI", sans-serif; }
.chart .bar { fill: var(--cc-accent-1); }
.chart-card:nth-child(2n) .bar { fill: var(--cc-accent-2); }
.chart-card:nth-child(3n) .bar { fill: var(--cc-accent-4); }
#study-map { width: 100%; height: 360px; background: var(--cc-scope); border-radius: 16px; }
#track-band { display: grid; gap: 10px; margin-bottom: 16px; }

@media (max-width: 800px) {
  .spot-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .spotlight { min-height: 68px; }
  .fold-art { grid-template-columns: 1fr; }
  .fold-side, #home-stage { display: none; }
  .fold-svg { max-height: 120px; }
  .mini .mascot-svg { width: 42px; height: 42px; }
  .icon-row { height: 64px; }
  .cube { width: 48px; height: 48px; }
}

@media (max-width: 640px) {
  .topbar { flex-wrap: wrap; }
  #read-focus { display: none; }
  .utilbar { position: static; }
  .topbar { top: 0; }
  .brand-sub { display: none; }
  .uni-search input { width: 42vw; }
  .site-footer { padding-bottom: 96px; }
  #mascot, .mascot-link { width: 42px; height: 42px; }
}

@media print {
  .utilbar, .topbar, .rail, .tabbar, #sky, #readbar, .site-footer .next-labs { display: none !important; }
  body { background: white; color: black; }
}
