/* GemVerse — gallery styling. A jeweller's vault: near-black plum,
 * burgundy velvet, brass and glass. Layout follows the museum-wide
 * system: --margin gutters, header top-left, list panel docked right
 * and top-aligned with the header, info panel bottom-left sharing the
 * header's left edge, single-column flow under 640px. */

:root {
  --margin: 20px;
  --panel-w: 340px;
  --gold: #c9a227;
  --gold-soft: rgba(201, 162, 39, 0.55);
  --ink: #f0e9f2;
  --ink-dim: #b3a4b8;
  : rgba(18, 10, 22, 0.92);
  --panel-border: rgba(201, 162, 39, 0.35);
  --night: #0a0610;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--night);
  color: var(--ink);
  font-family: "Inter", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
}

body { display: flex; flex-direction: column; }

#stage { position: fixed; inset: 0; }
#stage canvas { display: block; }

/* ---------- header (top-left, at --margin) ---------- */

.topbar {
  position: fixed;
  top: var(--margin);
  left: var(--margin);
  z-index: 20;
  pointer-events: none;
}

.brand-block { pointer-events: auto; }

.back-link {
  display: inline-block;
  color: var(--gold);
  text-decoration: none;
  font-size: 13px;
  letter-spacing: 0.01em;
  margin-bottom: 4px;
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.9);
}
.back-link:hover { text-decoration: underline; }

.topbar h1 {
  margin: 0;
  font-family: "Archivo", Georgia, serif;
  font-size: 32px;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.05;
  text-shadow: 0 2px 14px rgba(0, 0, 0, 0.85);
}

.subtitle {
  margin: 3px 0 0;
  color: var(--ink-dim);
  font-size: 13.5px;
  letter-spacing: 0.01em;
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.9);
}

/* ---------- shared panel chrome ---------- */

.list-panel, .panel {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 18px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), 0 18px 50px rgba(0, 0, 0, 0.45);
  scrollbar-width: thin;
  scrollbar-color: var(--gold-soft) transparent;
}

/* ---------- vault list (right, top aligned with header) ---------- */

.list-panel {
  position: fixed;
  z-index: 20;
  top: var(--margin);
  right: var(--margin);
  width: var(--panel-w);
  max-height: calc(100vh - var(--margin) - 150px);
  overflow-y: auto;
  padding: 18px 18px 16px;
}

.list-title {
  margin: 0 0 2px;
  font-family: "Archivo", Georgia, serif;
  letter-spacing: -0.01em;
  font-size: 21px;
  font-weight: 600;
}
.list-sub {
  margin: 0 0 12px;
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--ink-dim);
}

.gem-list { display: flex; flex-direction: column; gap: 6px; }

.gem-item {
  appearance: none;
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  min-height: 40px;
  padding: 9px 12px;
  border: 1px solid rgba(201, 162, 39, 0.16);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.03);
  color: var(--ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.18s, background 0.18s, transform 0.18s, box-shadow 0.18s;
}
.gem-item:hover { border-color: var(--gold-soft); background: rgba(255, 255, 255, 0.05); transform: translateX(2px); }
.gem-item.active { border-color: var(--gold); background: rgba(201, 162, 39, 0.14); box-shadow: inset 3px 0 0 var(--gold); font-weight: 600; }

.gem-dot {
  flex: none;
  width: 15px; height: 15px;
  border-radius: 50%;
  box-shadow: inset -2px -3px 5px rgba(0, 0, 0, 0.45), inset 2px 3px 4px rgba(255, 255, 255, 0.35), 0 0 8px rgba(0, 0, 0, 0.4);
}
.gem-name { font-size: 14.5px; font-weight: 600; letter-spacing: 0.02em; }
.gem-mohs { margin-left: auto; font-size: 11.5px; color: var(--ink-dim); letter-spacing: 0.04em; white-space: nowrap; }

.vault-controls {
  margin-top: 14px;
  padding-top: 13px;
  border-top: 1px solid rgba(201, 162, 39, 0.18);
  display: flex;
  flex-direction: column;
  gap: 11px;
}
.slider-row {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-dim);
}
.slider-row input[type="range"] {
  flex: 1;
  appearance: none;
  -webkit-appearance: none;
  height: 4px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.14);
  outline: none;
  cursor: pointer;
}
.slider-row input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 12px; height: 12px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid var(--gold);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
  cursor: pointer;
}
.slider-row input[type="range"]::-moz-range-thumb {
  width: 12px; height: 12px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid var(--gold);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
  cursor: pointer;
}
.slider-row input[type="range"]::-moz-range-track {
  height: 4px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.14);
}

/* ---------- buttons ---------- */

.btn {
  appearance: none;
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 36px;
  border: 1px solid var(--panel-border);
  background: rgba(24, 14, 30, 0.85);
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  padding: 9px 16px;
  border-radius: 999px;
  cursor: pointer;
  transition: border-color 0.18s, background 0.18s, transform 0.18s;
}
.btn:hover { border-color: var(--gold); background: rgba(44, 26, 52, 0.9); transform: translateY(-1px); }
.btn:active { transform: scale(0.97); }
.btn-small { font-size: 12.5px; padding: 6px 14px; }

/* ---------- info panel (bottom-left, header's left edge) ---------- */

.panel {
  position: fixed;
  z-index: 20;
  left: var(--margin);
  bottom: 118px;
  width: 392px;
  max-width: calc(100vw - var(--panel-w) - (var(--margin) * 3));
  max-height: calc(100vh - 330px);
  overflow-y: auto;
  padding: 20px 22px 18px;
  transition: opacity 0.35s ease, transform 0.35s ease;
}
.panel.closed {
  opacity: 0;
  transform: translateX(-24px);
  pointer-events: none;
}

.panel-close {
  position: absolute;
  top: 8px; right: 12px;
  border: none;
  background: none;
  color: var(--ink-dim);
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  padding: 4px;
}
.panel-close:hover { color: var(--ink); }

.eyebrow {
  margin: 0 0 6px;
  color: var(--gold);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.panel h2 {
  margin: 0 0 6px;
  font-family: "Archivo", Georgia, serif;
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.tagline {
  margin: 0 0 12px;
  font-family: "Archivo", Georgia, serif;
  letter-spacing: -0.01em;
  font-size: 16px;
  font-style: italic;
  color: var(--ink-dim);
}

.stats {
  margin: 0 0 12px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 16px;
}
.stat dt {
  font-size: 10px;
  letter-spacing: 0.01em;
  color: var(--ink-dim);
  margin-bottom: 2px;
}
.stat dd { margin: 0; font-size: 15px; font-weight: 600; line-height: 1.4; color: var(--ink); }
.stat sub { font-size: 9.5px; }

.description {
  margin: 0;
  font-size: 14px;
  line-height: 1.65;
  color: var(--ink);
}

.fact {
  margin-top: 15px;
  padding: 12px 14px;
  border-left: 3px solid var(--gold);
  background: rgba(201, 162, 39, 0.08);
  border-radius: 12px;
}
.fact-label {
  margin: 0 0 4px;
  font-size: 11px;
  letter-spacing: 0.01em;
  color: var(--gold);
}
.fact-text { margin: 0; font-size: 13.5px; line-height: 1.55; color: var(--ink); }

/* ---------- gem navigation (bottom centre) ---------- */

.exhibit-nav {
  position: fixed;
  z-index: 20;
  left: 50%;
  bottom: 44px;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

#now-viewing {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 16px;
  letter-spacing: 0.06em;
  color: var(--ink);
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.9);
  white-space: nowrap;
}

.nav-row { display: flex; align-items: center; gap: 14px; }

.nav-btn {
  appearance: none;
  width: 42px; height: 42px;
  border-radius: 50%;
  border: 1px solid var(--panel-border);
  background: var(--panel-bg);
  color: var(--gold);
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
  transition: border-color 0.2s, transform 0.15s;
}
.nav-btn:hover { border-color: var(--gold); transform: translateY(-1px); }
.nav-btn:active { transform: scale(0.94); }

.dots { display: flex; gap: 9px; }
.dot {
  appearance: none;
  width: 11px; height: 11px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid var(--gold-soft);
  background: rgba(255, 255, 255, 0.12);
  cursor: pointer;
  transition: background 0.2s, transform 0.2s;
}
.dot:hover { transform: scale(1.25); }
.dot.active { background: var(--gold); transform: scale(1.3); }

/* ---------- misc ---------- */

.hint {
  position: fixed;
  z-index: 15;
  left: 0; right: 0;
  bottom: 13px;
  text-align: center;
  font-size: 12.5px;
  letter-spacing: 0.04em;
  color: var(--ink-dim);
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.9);
  pointer-events: none;
  padding: 0 12px;
}

#tooltip {
  position: fixed;
  z-index: 30;
  pointer-events: none;
  padding: 5px 11px;
  border-radius: 999px;
  border: 1px solid var(--panel-border);
  background: rgba(10, 6, 14, 0.9);
  color: #ffd968;
  font-size: 12.5px;
  letter-spacing: 0.05em;
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.15s;
  transform: translate(-50%, -160%);
}
#tooltip.show { opacity: 1; }

.overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  background: var(--night);
  color: var(--ink-dim);
  font-size: 15px;
  letter-spacing: 0.06em;
  text-align: center;
  padding: 24px;
  transition: opacity 0.5s ease;
}
.overlay.gone { opacity: 0; pointer-events: none; }
.overlay-error { background: rgba(10, 6, 16, 0.97); line-height: 1.6; }

.spinner {
  width: 42px; height: 42px;
  border-radius: 50%;
  border: 3px solid rgba(201, 162, 39, 0.2);
  border-top-color: var(--gold);
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- tablet: narrower panels ---------- */

@media (max-width: 1023px) {
  :root { --margin: 16px; --panel-w: 292px; }
  .topbar h1 { font-size: 27px; }
  .subtitle { font-size: 12px; }
  .panel { width: 340px; bottom: 112px; }
  .panel h2 { font-size: 23px; }
  .dots { gap: 7px; }
}

/* ---------- phones: single-column flow ---------- */

@media (max-width: 640px) {
  :root { --margin: 12px; }

  html, body { height: auto; overflow-x: hidden; overflow-y: auto; }

  .topbar { position: static; order: 0; padding: 4px 2px 10px; }
  .topbar h1 { font-size: 24px; }
  .subtitle { font-size: 11px; }

  #stage { position: relative; inset: auto; order: 1; flex: none; width: 100%; height: 56vh; }

  .exhibit-nav { position: static; order: 2; transform: none; padding: 12px 0 2px; }
  #now-viewing { font-size: 15px; }

  .panel {
    position: static; order: 3;
    width: auto; max-width: none; max-height: none;
    margin: 12px var(--margin) 0;
    overflow: visible;
  }
  .panel.closed { display: none; }
  .panel h2 { font-size: 22px; }

  .list-panel {
    position: static; order: 4;
    width: auto; max-height: none;
    margin: 12px var(--margin) 0;
    overflow: visible;
  }
  .gem-list { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .gem-item { padding: 10px; }
  .gem-mohs { display: none; }
  .vault-controls .btn { width: 100%; }

  .hint { position: static; order: 5; padding: 14px 12px 18px; }
}

/* The fail overlay must obey its hidden attribute (author display rules would otherwise override it) */
#webgl-fail[hidden]{display:none !important}

/* ================= THREE-SECTION LAYOUT =================
   Desktop: LEFT data column (header + gem panel) · CENTER stage ·
   RIGHT switcher column (vault list + controls + prev/next). */
.layout {
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr) 340px;
  height: 100vh;
  height: 100dvh;
  width: 100%;
}
.col-left, .col-right {
  background: #0c0714;
  display: flex; flex-direction: column;
  gap: 16px;
  padding: 20px;
  min-height: 0;
  min-width: 0;
}
.col-left { border-right: 1px solid rgba(201, 162, 39, 0.35); }
.col-right { border-left: 1px solid rgba(201, 162, 39, 0.35); }
.col-left .topbar { position: static; flex: none; padding: 0; }
.col-left .panel {
  position: static;
  width: auto; max-width: none; max-height: none;
  flex: 1; min-height: 0;
  overflow-y: auto;
}
.stage-wrap { position: relative; min-width: 0; min-height: 0; }
.stage-wrap #stage { position: absolute; inset: 0; }
.stage-wrap .hint { position: absolute; }
.col-right .list-panel {
  position: static;
  width: auto; max-height: none;
  flex: 1; min-height: 0;
  overflow-y: auto;
}
.col-right .exhibit-nav { position: static; transform: none; flex: none; padding-top: 4px; }

/* ---------- tablet: 272px side columns ---------- */
@media (max-width: 1023px) {
  .layout { grid-template-columns: 272px minmax(0, 1fr) 272px; }
  .col-left, .col-right { padding: 14px; gap: 12px; }
  .col-left .panel { width: auto; }
}

/* ---------- mobile: single-column stack ----------
   header -> stage (56vh) -> switcher -> data -> controls */
@media (max-width: 640px) {
  .layout { display: flex; flex-direction: column; height: auto; }
  .col-left, .col-right { display: contents; }
  .col-left .topbar { order: 1; margin: 12px 12px 0; }
  .stage-wrap { order: 2; height: 56vh; flex: none; margin: 12px 12px 0; }
  .stage-wrap #stage { position: absolute; inset: 0; height: auto; }
  .col-right .list-panel { order: 3; margin: 12px 12px 0; flex: none; overflow: visible; }
  .col-left .panel { order: 4; margin: 12px 12px 0; flex: none; overflow: visible; }
  .col-right .exhibit-nav { order: 5; margin: 12px 12px 0; }
}

/* ================= PREMIUM UI PASS ================= */
::selection { background: var(--gold); color: #0b0e18; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.stage-wrap::after {
  content: ""; position: absolute; inset: 0; z-index: 1; pointer-events: none;
  background: radial-gradient(ellipse at center, transparent 55%, rgba(0, 0, 0, 0.38) 100%);
}
.stage-wrap #stage canvas { cursor: grab; }
.stage-wrap #stage canvas:active { cursor: grabbing; }
.col-left .panel::-webkit-scrollbar, .col-right .list-panel::-webkit-scrollbar { width: 8px; }
.col-left .panel::-webkit-scrollbar-thumb, .col-right .list-panel::-webkit-scrollbar-thumb { background: rgba(201, 162, 39, 0.35); border-radius: 99px; }
@keyframes panelIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
.panel-in { animation: panelIn 0.45s cubic-bezier(0.22, 0.8, 0.32, 1); }
.loader-wordmark { font-family: "Inter", sans-serif; font-size: 11px; font-weight: 600; letter-spacing: 0.01em; color: var(--ink-dim); margin: 0; }
.loader-bar { width: 160px; height: 3px; border-radius: 99px; background: rgba(255, 255, 255, 0.10); overflow: hidden; }
.loader-bar span { display: block; height: 100%; width: 40%; border-radius: 99px; background: var(--gold); animation: loadslide 1.2s ease-in-out infinite; }
@keyframes loadslide { 0% { transform: translateX(-110%); } 100% { transform: translateX(280%); } }
.overlay-error > p {
  background: var(--panel-bg); border: 1px solid var(--panel-border); border-radius: 18px;
  padding: 28px 30px; max-width: 540px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), 0 18px 50px rgba(0, 0, 0, 0.45);
}
.overlay-error > p strong { font-family: "Archivo", Georgia, serif; letter-spacing: -0.01em; font-size: 22px; font-weight: 600; color: var(--ink); display: block; margin-bottom: 8px; }
#rotate-toggle[aria-pressed="true"] {
  background: linear-gradient(135deg, var(--gold), #e8c95c);
  color: #0b0e18; border-color: transparent; font-weight: 600;
  box-shadow: 0 4px 18px rgba(201, 162, 39, 0.45);
}
.stage-wrap .hint {
  width: fit-content; margin-inline: auto;
  background: rgba(10, 6, 16, 0.92);
  border: 1px solid rgba(201, 162, 39, 0.18);
  border-radius: 999px; padding: 6px 14px;
}
@media (prefers-reduced-motion: reduce) {
  .panel-in { animation: none; }
  .loader-bar span { animation: none; transform: none; width: 60%; }
}
