/* Algorithm Zoo — dark hall, lit exhibits, museum-placard typography.
   Palette: ink #0a0d13 · panel #12161f · paper #e9e4d8 · amber #ffac38 · signal red #ff4632 */

:root {
  --ink: #0a0d13;
  --panel: rgba(18, 22, 31, 0.86);
  --line: rgba(233, 228, 216, 0.14);
  --paper: #e9e4d8;
  --paper-dim: rgba(233, 228, 216, 0.62);
  --amber: #ffac38;
  --red: #ff4632;
  --serif: "Newsreader", Georgia, serif;
  --sans: "Archivo", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--ink);
  color: var(--paper);
  font-family: var(--sans);
  overflow: hidden;
}

#zoo {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

/* ---------- masthead ---------- */

#masthead {
  position: fixed;
  top: 28px;
  left: 32px;
  max-width: 340px;
  pointer-events: none;
}
#masthead h1 {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 2rem;
  margin: 0 0 6px;
  letter-spacing: 0.01em;
}
#masthead p {
  margin: 0;
  font-size: 0.85rem;
  line-height: 1.5;
  color: var(--paper-dim);
}
#masthead a {
  color: var(--amber);
  pointer-events: auto;
}

/* ---------- exhibit index ---------- */

#index {
  position: fixed;
  top: 120px;
  left: 32px;
  bottom: 32px;
  width: 250px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
#index-list {
  overflow-y: auto;
  padding-right: 8px;
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
  mask-image: linear-gradient(to bottom, transparent, black 12px, black calc(100% - 20px), transparent);
  padding-block: 12px 24px;
}
.wing-section { margin-bottom: 18px; }
.wing-section h2 {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  margin: 0 0 6px;
  color: var(--paper);
}
.wing-section h2.empty { color: var(--paper-dim); }
.wing-section .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex: none;
}
.wing-section .count {
  margin-left: auto;
  font-weight: 400;
  font-size: 0.72rem;
  color: var(--paper-dim);
}
.exhibit-btn {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  border-left: 2px solid transparent;
  color: var(--paper-dim);
  font: 400 0.85rem/1.4 var(--sans);
  padding: 5px 10px;
  cursor: pointer;
  transition: color 120ms, border-color 120ms;
}
.exhibit-btn:hover { color: var(--paper); }
.exhibit-btn.active {
  color: var(--paper);
  border-left-color: var(--amber);
}
.exhibit-btn:focus-visible,
button:focus-visible,
select:focus-visible {
  outline: 2px solid var(--amber);
  outline-offset: 2px;
}

#btn-overview {
  align-self: flex-start;
  background: none;
  border: 1px solid var(--line);
  border-radius: 3px;
  color: var(--paper-dim);
  font: 500 0.78rem var(--sans);
  padding: 7px 12px;
  cursor: pointer;
}
#btn-overview:hover { color: var(--paper); border-color: var(--paper-dim); }

/* ---------- placard ---------- */

#placard {
  position: fixed;
  right: 32px;
  top: 50%;
  transform: translateY(-50%);
  width: 320px;
  background: var(--panel);
  backdrop-filter: blur(14px);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 24px 26px 20px;
}
.wing-tag {
  margin: 0 0 2px;
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.04em;
}
#placard h2 {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 1.55rem;
  line-height: 1.15;
  margin: 0 0 14px;
}
.complexity {
  display: flex;
  gap: 28px;
  margin: 0 0 14px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}
.complexity dt {
  font-size: 0.7rem;
  color: var(--paper-dim);
  margin-bottom: 2px;
}
.complexity dd {
  margin: 0;
  font-size: 0.92rem;
  font-weight: 500;
}
#ex-desc {
  font-family: var(--serif);
  font-size: 0.98rem;
  line-height: 1.55;
  color: var(--paper);
  margin: 0 0 16px;
}
#ex-caption {
  margin: 0;
  min-height: 3em;
  font-size: 0.86rem;
  line-height: 1.45;
  color: var(--amber);
  border-left: 2px solid var(--amber);
  padding-left: 12px;
}

/* ---------- playback bar ---------- */

#playbar {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--panel);
  backdrop-filter: blur(14px);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 10px 16px;
}
#playbar button {
  background: none;
  border: none;
  color: var(--paper);
  font-size: 1rem;
  width: 34px;
  height: 34px;
  border-radius: 3px;
  cursor: pointer;
}
#playbar button:hover { background: rgba(233, 228, 216, 0.08); }
#btn-play { font-size: 1.15rem; color: var(--amber); }
#speed {
  background: none;
  border: 1px solid var(--line);
  border-radius: 3px;
  color: var(--paper);
  font: 500 0.8rem var(--sans);
  padding: 5px 6px;
}
#speed option { background: #12161f; }
#progress {
  width: 160px;
  height: 3px;
  background: var(--line);
  border-radius: 2px;
  overflow: hidden;
}
#progress-fill {
  height: 100%;
  width: 0;
  background: var(--amber);
  transition: width 160ms linear;
}
#progress-text {
  font-size: 0.75rem;
  color: var(--paper-dim);
  min-width: 52px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* ---------- errors ---------- */

#load-error {
  position: fixed;
  left: 50%;
  top: 40%;
  transform: translateX(-50%);
  max-width: 460px;
  background: var(--panel);
  border: 1px solid var(--red);
  border-radius: 4px;
  padding: 18px 22px;
  font-size: 0.9rem;
  line-height: 1.5;
}

/* ---------- small screens ---------- */

@media (max-width: 900px) {
  #masthead { max-width: 240px; }
  #index { display: none; }
  #placard {
    right: 12px;
    left: 12px;
    top: auto;
    bottom: 90px;
    transform: none;
    width: auto;
    max-height: 40vh;
    overflow-y: auto;
  }
  #playbar { bottom: 12px; width: calc(100% - 24px); justify-content: center; }
  #progress { width: 90px; }
}

@media (prefers-reduced-motion: reduce) {
  #progress-fill { transition: none; }
}
