/* 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 & responsive ---------- */

@media (max-width: 900px) {
  #masthead {
    max-width: 260px;
    top: 20px;
    left: 20px;
  }
  #index {
    top: 110px;
    left: 20px;
    width: 200px;
  }
  #placard {
    right: 20px;
    top: auto;
    bottom: 84px;
    transform: none;
    width: 290px;
    max-height: 45vh;
    overflow-y: auto;
    padding: 18px 20px;
  }
  #playbar {
    bottom: 16px;
    width: auto;
    max-width: calc(100% - 40px);
    justify-content: center;
  }
  #progress {
    width: 120px;
  }
}

@media (max-width: 680px) {
  #index {
    display: none;
  }
  #placard {
    left: 12px;
    right: 12px;
    width: auto;
    bottom: 80px;
    max-height: 35vh;
    padding: 14px 16px;
  }
  #playbar {
    bottom: 12px;
    width: calc(100% - 24px);
    justify-content: center;
    padding: 8px 12px;
  }
  #progress {
    width: 80px;
  }
}

@media (max-width: 480px) {
  #masthead {
    top: 12px;
    left: 12px;
    right: 12px;
    max-width: none;
  }
  #masthead h1 {
    font-size: 1.35rem;
    margin-bottom: 3px;
  }
  #masthead p {
    font-size: 0.78rem;
    line-height: 1.35;
  }
  #placard h2 {
    font-size: 1.25rem;
    margin-bottom: 8px;
  }
  .complexity {
    gap: 16px;
    margin-bottom: 8px;
    padding-bottom: 8px;
  }
  #ex-desc {
    font-size: 0.85rem;
    line-height: 1.4;
    margin-bottom: 10px;
  }
  #ex-caption {
    font-size: 0.78rem;
    padding-left: 8px;
  }
  #playbar button {
    width: 30px;
    height: 30px;
    font-size: 0.9rem;
  }
}

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

/* --------- share exhibit --------- */

#btn-copy-url {
  margin-top: 12px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: transparent;
  color: var(--paper);
  font: inherit;
  font-size: 0.8rem;
  cursor: pointer;
  transition:
    background 160ms ease,
    border-color 160ms ease;
}

#btn-copy-url:hover {
  background: rgba(255, 172, 56, 0.12);
  border-color: var(--amber);
}

#btn-copy-url:focus-visible {
  outline: 2px solid var(--amber);
  outline-offset: 3px;
}

#copy-feedback {
  display: block;
  min-height: 1.2em;
  margin-top: 6px;
  color: var(--amber);
  font-size: 0.75rem;
}

/* Responsive overlays: tablet & mobile */
@media (max-width: 850px) {
  #index {
    display: none !important;
  }

  .back-button,
  button:has-text("Back to overview"),
  [id*="back"] {
    position: fixed !important;
    top: 16px !important;
    left: 16px !important;
    bottom: auto !important;
    z-index: 100 !important;
  }

  #playbar {
    position: fixed !important;
    bottom: 16px !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
    width: auto !important;
    max-width: 90vw !important;
    z-index: 90 !important;
  }
}

@media (max-width: 480px) {
  #playbar {
    bottom: 10px !important;
    padding: 6px 10px !important;
    transform: translateX(-50%) scale(0.9) !important;
  }
}
