:root {
  --serif: "Playfair Display", Georgia, serif;
  --mono: "JetBrains Mono", Consolas, monospace;

  --ash: #070405;
  --blood: #b3121a;
  --ember: #ff4b1f;
  --bone: #f4efe8;
  --bone-dim: rgba(244, 239, 232, 0.58);

  --plate-w: min(100vw, 178vh); /* plate is 1672×941 */
  --gate-w: min(100vw, 150vh);
  --gate-drop: calc(var(--gate-w) * -0.062);
}

*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background: var(--ash);
  color: var(--bone);
  font-family: var(--mono);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; cursor: pointer; }
a { color: inherit; text-decoration: none; }
ul { list-style: none; }

/* ── Stage ─────────────────────────────────────────── */
.stage {
  position: fixed;
  inset: 0;
  isolation: isolate;
  overflow: hidden;
  background: linear-gradient(to bottom, #2a060b 0%, #55090f 26%, #3d070c 60%, #0b0304 92%, #060203 100%);
}

/* Layer 0 — background plate */
.layer-bg { position: absolute; inset: 0; z-index: 0; }
.bg-plate {
  position: absolute;
  left: 50%;
  top: 50%;
  width: var(--plate-w);
  height: auto;
  max-height: 100%;
  transform: translate(-50%, -50%);
  filter: brightness(0.84) saturate(1.04) contrast(1.02);
}
.bg-scrim {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(128% 82% at 50% 42%, transparent 34%, rgba(6, 2, 3, 0.42) 76%, rgba(4, 1, 2, 0.78) 100%),
    linear-gradient(to bottom, rgba(5, 2, 3, 0.66) 0%, rgba(5, 2, 3, 0.12) 20%, transparent 42%, rgba(4, 1, 2, 0.5) 88%, rgba(4, 1, 2, 0.8) 100%);
}

/* Shared gate geometry (curtain and gate use the exact same rect) */
.gate-box {
  position: absolute;
  left: 50%;
  bottom: var(--gate-drop);
  width: var(--gate-w);
  aspect-ratio: 1536 / 1024;
  transform: translateX(-50%);
}

/* Layer 1 — the inscription cloth inside the archway */
.layer-curtain { position: absolute; inset: 0; z-index: 1; }
.arch-window {
  position: absolute;
  left: 36.4%;
  top: 40%;
  width: 26.6%;
  height: 45%;
  overflow: hidden;
}
.arch-glow {
  position: absolute;
  inset: -20% -30%;
  background:
    radial-gradient(58% 50% at 50% 92%, rgba(255, 116, 48, 0.62) 0%, rgba(176, 26, 16, 0.34) 44%, transparent 78%),
    radial-gradient(86% 66% at 50% 26%, rgba(104, 10, 12, 0.34) 0%, transparent 100%),
    linear-gradient(to bottom, rgba(5, 2, 3, 0.93), rgba(5, 2, 3, 0.8));
  filter: blur(12px);
}
#cloth {
  position: absolute;
  mix-blend-mode: screen;
}
.arch-inner-shadow {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(to bottom, rgba(5, 2, 3, 0.85) 0%, transparent 16%, transparent 80%, rgba(5, 2, 3, 0.7) 100%),
    linear-gradient(to right, rgba(5, 2, 3, 0.75) 0%, transparent 14%, transparent 86%, rgba(5, 2, 3, 0.75) 100%);
}

/* Layer 2 — the gate itself */
.layer-gate { position: absolute; inset: 0; z-index: 2; pointer-events: none; }
.gate-relic {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: fill;
  filter: contrast(1.05) drop-shadow(0 24px 48px rgba(0, 0, 0, 0.7));
}

/* Layer 3 — chrome */
.layer-chrome {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: clamp(22px, 4.4vh, 52px) clamp(18px, 2.6vw, 38px) clamp(12px, 1.8vh, 20px);
  pointer-events: none;
}
.layer-chrome::before {
  content: "";
  position: absolute;
  left: 0;
  bottom: 0;
  width: 66%;
  height: 62%;
  background:
    radial-gradient(78% 92% at 6% 100%, rgba(4, 1, 2, 0.9) 0%, rgba(4, 1, 2, 0.62) 40%, transparent 78%),
    linear-gradient(to top, rgba(4, 1, 2, 0.72) 0%, transparent 46%);
  pointer-events: none;
}
.navbar, .baseline { position: relative; }
.pill, .copy, .meta { pointer-events: auto; }

/* ── Navbar pill ───────────────────────────────────── */
.pill {
  display: flex;
  align-items: center;
  gap: clamp(12px, 1.8vw, 28px);
  padding: 6px 6px 6px clamp(16px, 1.8vw, 24px);
  background: #fbf9f6;
  border-radius: 999px;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.9) inset, 0 12px 40px rgba(0, 0, 0, 0.6), 0 2px 6px rgba(0, 0, 0, 0.45);
}
.wordmark {
  font-family: var(--serif);
  font-weight: 700;
  font-size: clamp(15px, 1.4vw, 19px);
  color: #120a09;
  letter-spacing: -0.015em;
}
.pill-links {
  display: flex;
  align-items: center;
  gap: 10px;
}
.pill-links a {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: rgba(18, 10, 9, 0.6);
  transition: color .25s ease;
}
.pill-links a:hover, .pill-links a.is-current { color: #120a09; }
.pill-links .dot { color: rgba(18, 10, 9, 0.28); font-size: 11px; }

.sound {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: transparent;
  border: 1px solid rgba(18, 10, 9, 0.18);
  border-radius: 999px;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.06em;
  color: rgba(18, 10, 9, 0.72);
  text-transform: uppercase;
}
.sound-bars { display: inline-flex; align-items: center; gap: 2px; height: 11px; }
.sound-bars i {
  display: block;
  width: 2px;
  height: 11px;
  background: var(--ember);
  border-radius: 1px;
  transform-origin: 50% 50%;
  animation: sound-bar 0.9s ease-in-out infinite alternate;
}
.sound-bars i:nth-child(1) { animation-delay: -0.6s; }
.sound-bars i:nth-child(2) { animation-delay: -0.3s; }
.sound-bars i:nth-child(3) { animation-delay: 0s; }
@keyframes sound-bar { from { transform: scaleY(0.32); } to { transform: scaleY(1); } }
.sound.is-off .sound-bars i {
  background: rgba(18, 10, 9, 0.3);
  animation: none;
  transform: scaleY(0.28);
}

.play {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 18px 9px 15px;
  background: #120a09;
  color: #f6f2ec;
  border: 0;
  border-radius: 999px;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  transition: background-color .25s ease, transform .25s ease;
}
.play:hover { background: #2c1512; transform: translateY(-1px); }
.play-glyph {
  width: 0;
  height: 0;
  border-left: 7px solid #ff4b1f;
  border-top: 4.5px solid transparent;
  border-bottom: 4.5px solid transparent;
}

/* ── Footer copy + meta ────────────────────────────── */
.baseline {
  margin-top: auto;
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: clamp(20px, 6vw, 90px);
}
.copy { max-width: clamp(300px, 32vw, 480px); }
.eyebrow {
  font-family: var(--mono);
  font-size: clamp(8px, 0.62vw, 10px);
  letter-spacing: 0.26em;
  text-transform: uppercase;
  color: rgba(244, 239, 232, 0.56);
  margin-bottom: clamp(8px, 1.2vh, 14px);
  text-shadow: 0 1px 14px rgba(0, 0, 0, 0.95);
}
.headline {
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(28px, 2.9vw, 48px);
  line-height: 1.0;
  letter-spacing: -0.028em;
  color: #fdfaf6;
  text-shadow: 0 2px 30px rgba(0, 0, 0, 0.9), 0 0 70px rgba(0, 0, 0, 0.75);
  white-space: nowrap;
}
.headline em {
  display: block;
  font-style: italic;
  font-weight: 400;
  background: linear-gradient(180deg, #ffe0c2 0%, #ff7132 55%, #c8201a 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: none;
  padding-bottom: 0.08em;
}
.lede {
  margin-top: clamp(10px, 1.6vh, 18px);
  font-family: var(--mono);
  font-size: clamp(10px, 0.74vw, 11.5px);
  font-weight: 300;
  line-height: 1.75;
  color: rgba(244, 239, 232, 0.58);
}
.lede .hint {
  display: block;
  margin-top: 5px;
  color: rgba(255, 124, 66, 0.9);
  letter-spacing: 0.03em;
}
.meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: rgba(244, 239, 232, 0.34);
  text-align: right;
}
.meta [data-fps] { letter-spacing: 0.12em; color: rgba(255, 124, 66, 0.5); }

/* ── Controls panel ────────────────────────────────── */
.panel {
  position: fixed;
  right: 0;
  top: 0;
  z-index: 20;
  width: min(340px, 92vw);
  height: 100%;
  display: flex;
  flex-direction: column;
  background: rgba(11, 5, 6, 0.93);
  -webkit-backdrop-filter: blur(18px);
  backdrop-filter: blur(18px);
  border-left: 1px solid rgba(255, 124, 66, 0.16);
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(0.22, 0.8, 0.28, 1);
  font-family: var(--mono);
  color: var(--bone);
}
.panel.is-open { transform: translateX(0); }
.panel__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 22px 14px;
  border-bottom: 1px solid rgba(255, 124, 66, 0.12);
}
.panel__title { font-size: 11px; letter-spacing: 0.2em; text-transform: uppercase; color: rgba(255, 124, 66, 0.9); }
.panel__close, .panel__reset {
  background: transparent;
  border: 1px solid rgba(244, 239, 232, 0.18);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(244, 239, 232, 0.72);
}
.panel__close:hover, .panel__reset:hover { color: var(--bone); border-color: rgba(255, 124, 66, 0.5); }
.panel__body { flex: 1; overflow-y: auto; padding: 8px 22px 20px; }
.panel section { padding: 14px 0 6px; border-bottom: 1px solid rgba(244, 239, 232, 0.06); }
.panel h3 {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: rgba(244, 239, 232, 0.5);
  margin-bottom: 10px;
}
.panel h3 small { color: rgba(255, 124, 66, 0.6); letter-spacing: 0.1em; }
.ctl { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; margin-bottom: 12px; font-size: 10.5px; }
.ctl label { color: rgba(244, 239, 232, 0.7); }
.ctl output { color: rgba(255, 124, 66, 0.85); font-variant-numeric: tabular-nums; }
.ctl input[type=range] { grid-column: 1 / -1; width: 100%; accent-color: #ff4b1f; }
.panel__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 22px 20px;
  border-top: 1px solid rgba(255, 124, 66, 0.12);
  font-size: 9.5px;
  letter-spacing: 0.1em;
  color: rgba(244, 239, 232, 0.45);
  text-transform: uppercase;
}

/* ── Responsive ────────────────────────────────────── */
@media (max-aspect-ratio: 1/1) {
  :root { --gate-w: min(150vw, 120vh); }
}
@media (max-width: 760px) {
  :root {
    --gate-w: min(215vw, 118vh);
    --gate-drop: calc(var(--gate-w) * -0.075);
  }
  .pill { gap: 10px; }
  .pill-links { display: none; }
  .headline { white-space: normal; }
  .baseline { flex-direction: column; align-items: flex-start; }
  .meta { align-items: flex-start; text-align: left; }
  .meta span:nth-child(3) { display: none; }
}
@media (max-height: 560px) {
  .lede, .eyebrow { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .sound-bars i { animation: none; }
}
