:root {
  --sand: #e8d6b3;
  --sand-dim: #c9b489;
  --gold: #d9a441;
  --gold-bright: #f0c365;
  --ink: #12100c;
  --ink-soft: rgba(18, 16, 12, 0.72);
  --panel: rgba(20, 17, 12, 0.82);
  --panel-border: rgba(217, 164, 65, 0.32);
  --shadow: 0 18px 60px rgba(0, 0, 0, 0.55);
  --radius: 18px;
  font-family: "Trebuchet MS", "Segoe UI", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }

/* The `hidden` attribute must win over component display rules below
   (e.g. `.btn { display: inline-flex }` would otherwise keep hidden buttons visible). */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  background: #0a0908;
  color: var(--sand);
  overflow: hidden;
}

/* ---- Full-bleed Sketchfab model ---- */
.model {
  position: fixed;
  inset: 0;
  z-index: 0;
  background:
    radial-gradient(1200px 700px at 50% 30%, #1c1710 0%, #0a0908 70%);
}
.model iframe {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
}

/* ---- Entrance panel ---- */
.panel {
  position: fixed;
  z-index: 2;
  inset: 0;
  display: grid;
  place-items: center;
  padding: max(20px, env(safe-area-inset-top)) 20px max(20px, env(safe-area-inset-bottom));
  background: radial-gradient(900px 600px at 50% 45%, rgba(0,0,0,0.35), rgba(0,0,0,0.72));
  transition: background 0.4s ease;
}

.panel__inner {
  width: min(540px, 100%);
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  padding: 28px 28px 22px;
  transition: transform 0.45s cubic-bezier(.2,.8,.2,1), opacity 0.3s ease;
}

.panel__head { text-align: center; margin-bottom: 22px; }

.eyebrow {
  margin: 0 0 6px;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  font-size: 0.68rem;
  color: var(--gold);
  opacity: 0.9;
}
.title {
  margin: 0;
  font-size: clamp(2.1rem, 7vw, 3rem);
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--sand);
  text-shadow: 0 2px 18px rgba(217, 164, 65, 0.25);
}
.subtitle {
  margin: 8px 0 0;
  font-size: 0.95rem;
  color: var(--sand-dim);
}

/* ---- Controls ---- */
.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: center;
}

.btn {
  appearance: none;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 12px 20px;
  font-size: 1rem;
  font-weight: 600;
  color: var(--ink);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  transition: transform 0.12s ease, background 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
  user-select: none;
}
.btn:active { transform: translateY(1px) scale(0.99); }

.btn--primary {
  background: linear-gradient(180deg, var(--gold-bright), var(--gold));
  box-shadow: 0 8px 24px rgba(217, 164, 65, 0.35);
}
.btn--primary:hover { box-shadow: 0 10px 30px rgba(217, 164, 65, 0.5); }

.btn--ghost {
  background: transparent;
  color: var(--sand);
  border-color: var(--panel-border);
}
.btn--ghost:hover { border-color: var(--gold); color: var(--gold-bright); }

.btn--icon {
  background: transparent;
  color: var(--sand);
  border-color: var(--panel-border);
  padding: 11px 13px;
  font-size: 1.1rem;
}
.btn--icon:hover { border-color: var(--gold); }

.btn__icon { font-size: 0.95em; line-height: 1; }

.sound { display: inline-flex; align-items: center; gap: 10px; }

.volume {
  appearance: none;
  width: 110px;
  height: 4px;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--gold) 0 100%);
  background-size: 100% 100%;
  outline: none;
  cursor: pointer;
}
.volume::-webkit-slider-thumb {
  appearance: none;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--sand);
  border: 2px solid var(--gold);
  box-shadow: 0 2px 6px rgba(0,0,0,0.4);
}
.volume::-moz-range-thumb {
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--sand);
  border: 2px solid var(--gold);
}

/* ---- Transcript ---- */
.link {
  display: block;
  margin: 18px auto 0;
  background: none;
  border: none;
  color: var(--gold);
  font-size: 0.9rem;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.link:hover { color: var(--gold-bright); }

.transcript {
  margin-top: 14px;
  max-height: 34vh;
  overflow-y: auto;
  padding: 14px 16px;
  border-radius: 12px;
  background: rgba(0,0,0,0.32);
  border: 1px solid rgba(217,164,65,0.18);
  font-size: 0.92rem;
  line-height: 1.6;
  color: var(--sand-dim);
}
.transcript p { margin: 0 0 12px; }
.transcript p:last-child { margin-bottom: 0; }

.hint {
  margin: 18px 0 0;
  text-align: center;
  font-size: 0.82rem;
  color: var(--sand-dim);
  line-height: 1.5;
}
.hint strong { color: var(--sand); }

.credit {
  margin: 14px 0 0;
  text-align: center;
  font-size: 0.74rem;
  color: rgba(201, 180, 137, 0.7);
}
.credit a { color: var(--gold); text-decoration: none; }
.credit a:hover { text-decoration: underline; }

/* ---- Collapsed state: panel becomes a floating control bar ---- */
.panel[data-state="collapsed"] {
  place-items: end start;
  background: transparent;
  pointer-events: none; /* let the model receive drags; bar re-enables below */
  padding: 16px;
}
.panel[data-state="collapsed"] .panel__inner {
  width: auto;
  pointer-events: auto;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.panel[data-state="collapsed"] .panel__head,
.panel[data-state="collapsed"] .link,
.panel[data-state="collapsed"] .transcript,
.panel[data-state="collapsed"] .hint,
.panel[data-state="collapsed"] .credit { display: none; }

.panel[data-state="collapsed"] .controls {
  flex-wrap: nowrap;
  gap: 8px;
}
.panel[data-state="collapsed"] .btn__label { display: none; }
.panel[data-state="collapsed"] .btn { padding: 10px 12px; }
.panel[data-state="collapsed"] .volume { width: 80px; }

@media (max-width: 380px) {
  .panel[data-state="collapsed"] .volume { width: 60px; }
}
