* { box-sizing: border-box; }

:root {
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --gold: #d6b268;
  --gold-pale: #f5e5bd;
  --ivory: #f5ecde;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #0d0a08;
  color: var(--ivory);
  font-family: "Amiri", Georgia, serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

.gl-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  z-index: 0;
}

html[data-phase="gold"] .gl-canvas { cursor: grab; }
html[data-phase="gold"] .gl-canvas.is-hover-frame { cursor: pointer; }
html[data-phase="gold"] .gl-canvas:active { cursor: grabbing; }

/* ---------- Whisper-Quiet Museum HUD (Zero Pills) ---------- */
.hud {
  position: fixed;
  top: 0;
  inset-inline: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(18px + var(--safe-top)) clamp(20px, 5vw, 52px) 22px;
  pointer-events: none;
}

.hud > * { pointer-events: auto; }

.hud__brand {
  display: inline-flex;
  align-items: baseline;
  gap: 12px;
  text-decoration: none;
  color: var(--ivory);
}

.hud__brand-ar {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.hud__brand-en {
  font-size: 10px;
  color: rgba(214, 178, 104, 0.72);
}

.hud__end {
  display: flex;
  align-items: center;
  gap: 22px;
}

.hud__icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  padding: 6px;
  color: rgba(245, 236, 222, 0.62);
  cursor: pointer;
  transition: color 0.3s ease, transform 0.4s var(--ease);
}

.hud__icon-btn:hover {
  color: var(--gold-pale);
  transform: rotate(-45deg);
}

html[data-phase="chat"] #replay-btn { display: none; }

/* Minimal 3-bar sound wave toggle */
.hud__sound {
  display: inline-flex;
  align-items: flex-end;
  gap: 3px;
  height: 16px;
  padding: 2px 4px;
  background: transparent;
  border: none;
  cursor: pointer;
}

.sound-bar {
  width: 1.5px;
  height: 5px;
  background: rgba(245, 236, 222, 0.48);
  transition: height 0.3s ease, background-color 0.3s ease;
}

.hud__sound[aria-pressed="true"] .sound-bar {
  background: var(--gold-pale);
  animation: eq-wave 1.1s ease-in-out infinite;
}
.hud__sound[aria-pressed="true"] .sound-bar:nth-child(2) { animation-delay: 0.2s; }
.hud__sound[aria-pressed="true"] .sound-bar:nth-child(3) { animation-delay: 0.4s; }

@keyframes eq-wave {
  0%, 100% { height: 4px; }
  50% { height: 14px; }
}

.hud__link {
  color: rgba(245, 236, 222, 0.84);
  text-decoration: none;
  font-size: 16px;
  padding-bottom: 3px;
  border-bottom: 1px solid rgba(214, 178, 104, 0.45);
  transition: color 0.3s ease, border-color 0.3s ease;
}

.hud__link:hover {
  color: var(--gold-pale);
  border-bottom-color: var(--gold-pale);
}

/* ---------- Phase 0: Moody Frosted Chat Fragment ---------- */
.chat-stage {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(28px, 5.5vh, 46px);
  padding: calc(70px + var(--safe-top)) 20px calc(28px + var(--safe-bottom));
  transition: opacity 0.45s ease, transform 0.7s var(--ease);
}

html[data-phase="gold"] .chat-stage {
  opacity: 0;
  transform: scale(1.1);
  pointer-events: none;
}

.wa-card {
  position: relative;
  width: min(86vw, 314px);
  background: linear-gradient(155deg, rgba(36, 44, 49, 0.74), rgba(18, 22, 25, 0.84));
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px 4px 16px 16px;
  padding: 10px;
  box-shadow: 0 34px 90px rgba(0, 0, 0, 0.65), inset 0 1px 0 rgba(255, 255, 255, 0.09);
  font-family: system-ui, -apple-system, sans-serif;
  cursor: pointer;
  overflow: hidden;
  animation: wa-float 5.5s ease-in-out infinite;
  transition: border-color 0.45s ease, box-shadow 0.45s ease;
}

.wa-card:hover {
  border-color: rgba(214, 178, 104, 0.42);
  box-shadow: 0 36px 95px rgba(0, 0, 0, 0.7), 0 0 42px rgba(214, 178, 104, 0.16);
}

/* Molten gold fracture hairline glowing quietly along the corner */
.wa-card__vein {
  position: absolute;
  inset: 0;
  background: radial-gradient(180px circle at 18% 12%, rgba(232, 195, 118, 0.2), transparent 65%);
  pointer-events: none;
  opacity: 0.65;
  transition: opacity 0.45s ease;
}
.wa-card:hover .wa-card__vein { opacity: 1; }

@keyframes wa-float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

.wa-card__media {
  height: clamp(138px, 21vh, 168px);
  border-radius: 10px;
  background: linear-gradient(145deg, rgba(44, 52, 57, 0.85), rgba(24, 29, 33, 0.92));
  border: 1px solid rgba(255, 255, 255, 0.05);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: rgba(210, 218, 224, 0.34);
}

.wa-card__file { font-size: 10px; letter-spacing: 0.16em; font-family: monospace; }
.wa-card__sub { font-size: 11px; opacity: 0.68; }

.wa-card__text {
  margin: 11px 4px 6px;
  font-size: 14px;
  line-height: 1.55;
  color: rgba(224, 232, 236, 0.82);
}

.wa-card__meta {
  display: flex;
  justify-content: flex-end;
  gap: 5px;
  font-size: 11px;
  color: rgba(215, 224, 229, 0.44);
  padding: 0 4px 2px;
}

.wa-ticks { color: #53bdeb; font-weight: 700; }

.chat-provocation {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
}

.chat-question {
  margin: 0;
  font-weight: 400;
  font-size: clamp(26px, 5.4vw, 46px);
  line-height: 1.35;
  color: rgba(247, 239, 226, 0.95);
  text-shadow: 0 8px 34px rgba(0, 0, 0, 0.6);
}

/* Whisper-luxury shatter affordance (zero heavy rectangular box) */
.shatter-cta {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  padding: 10px 4px;
  background: transparent;
  border: none;
  border-bottom: 1px solid rgba(214, 178, 104, 0.55);
  color: var(--gold-pale);
  font-family: "Amiri", Georgia, serif;
  font-size: clamp(18px, 4vw, 21px);
  cursor: pointer;
  transition: color 0.35s ease, border-color 0.35s ease, transform 0.35s var(--ease);
}

.shatter-cta:hover {
  color: #ffffff;
  border-bottom-color: #ffffff;
  transform: translateY(-2px);
}

.shatter-cta__orb {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--gold-pale);
  box-shadow: 0 0 18px rgba(245, 229, 189, 0.85);
  animation: orb-breathe 2.2s ease-in-out infinite;
}

@keyframes orb-breathe {
  0%, 100% { transform: scale(0.75); opacity: 0.55; }
  50% { transform: scale(1.25); opacity: 1; }
}

/* ---------- Phase 1: Centered Sculptural Gallery Overlay ---------- */
.gallery-stage {
  position: fixed;
  inset: 0;
  z-index: 15;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.95s var(--ease) 0.4s;
}

html[data-phase="gold"] .gallery-stage { opacity: 1; }

.gallery-manifesto {
  position: fixed;
  top: calc(58px + var(--safe-top));
  inset-inline: 16px;
  text-align: center;
  margin: 0;
  font-size: clamp(15px, 3.6vw, 20px);
  color: rgba(245, 236, 222, 0.78);
  text-shadow: 0 4px 20px rgba(0, 0, 0, 0.8);
  transition: opacity 0.55s ease;
}

.nogl-fallback {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -62%);
  width: min(64vw, 240px);
  aspect-ratio: 9 / 14;
  border: 1px solid var(--gold);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.7);
  overflow: hidden;
}
.nogl-fallback img { width: 100%; height: 100%; object-fit: cover; display: block; }

.captions-mount {
  position: fixed;
  inset: 0;
  pointer-events: none;
}

.cap {
  position: absolute;
  inset-inline: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 18px 20px calc(56px + var(--safe-bottom));
  background: linear-gradient(to top, rgba(13, 10, 8, 0.88) 0%, rgba(13, 10, 8, 0.36) 68%, transparent 100%);
  opacity: 0;
  pointer-events: none;
  will-change: opacity, transform;
}

.cap.is-live .cap-actions { pointer-events: auto; }

.cap--closing {
  inset: 0;
  justify-content: center;
  background: none;
  padding: 24px;
}

.cap--closing .cap-eyebrow { margin-bottom: 16px; }

.cap-eyebrow {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 4px;
  font-size: 11px;
  color: var(--gold);
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.9);
}

.cap-eyebrow__sep {
  width: 24px;
  height: 1px;
  background: rgba(214, 178, 104, 0.52);
}

.cap-title {
  margin: 0 0 4px;
  font-weight: 400;
  font-size: clamp(28px, 6.4vw, 46px);
  line-height: 1.15;
  color: #fcf6ea;
  text-shadow: 0 8px 30px rgba(0, 0, 0, 0.85);
}

.cap-tagline {
  margin: 0 0 14px;
  max-width: 42ch;
  font-size: clamp(15px, 3.8vw, 18px);
  line-height: 1.65;
  color: rgba(245, 236, 222, 0.84);
  text-shadow: 0 3px 16px rgba(0, 0, 0, 0.9);
}

.cap-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 24px;
}

.cap-link-primary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  border-top: none;
  border-inline: none;
  border-bottom: 1px solid var(--gold);
  background: transparent;
  color: var(--gold-pale);
  font-family: "Amiri", Georgia, serif;
  font-size: clamp(17px, 4.2vw, 19px);
  text-decoration: none;
  cursor: pointer;
  transition: color 0.3s ease, border-color 0.3s ease;
}

.cap-link-primary:hover {
  color: #ffffff;
  border-bottom-color: #ffffff;
}

.cap-link-quiet {
  background: transparent;
  border: none;
  padding: 6px 0;
  color: rgba(245, 236, 222, 0.74);
  font-family: "Amiri", Georgia, serif;
  font-size: clamp(15px, 3.8vw, 17px);
  cursor: pointer;
  transition: color 0.3s ease;
}

.cap-link-quiet:hover { color: var(--gold-pale); }

/* ---------- Editorial Closing Act (Zero Boxy Buttons) ---------- */
.cap-closing-title {
  margin: 0 0 16px;
  font-weight: 400;
  font-size: clamp(27px, 6.4vw, 62px);
  line-height: 1.24;
  color: #fcf6ea;
  text-shadow: 0 10px 40px rgba(0, 0, 0, 0.75);
}

.cap-closing-sub {
  margin: 0 0 34px;
  max-width: 38ch;
  font-size: clamp(16px, 3.9vw, 21px);
  line-height: 1.85;
  color: rgba(245, 236, 222, 0.8);
}

.closing-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
}

.closing-signature {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 14px;
  padding: 12px 2px;
  color: var(--gold-pale);
  text-decoration: none;
  font-size: clamp(20px, 4.6vw, 24px);
  border-bottom: 1px solid rgba(214, 178, 104, 0.75);
  transition: color 0.35s ease, border-color 0.35s ease, transform 0.35s var(--ease);
}

.closing-signature:hover {
  color: #ffffff;
  border-bottom-color: #ffffff;
  transform: translateY(-2px);
}

.closing-whisper {
  background: transparent;
  border: none;
  padding: 6px 4px;
  color: rgba(245, 236, 222, 0.68);
  font-family: "Amiri", Georgia, serif;
  font-size: 16px;
  cursor: pointer;
  transition: color 0.3s ease;
}

.closing-whisper:hover { color: var(--gold-pale); }

/* ---------- Horizontal Progress Rail ---------- */
.h-rail {
  position: fixed;
  bottom: calc(10px + var(--safe-bottom));
  inset-inline: 0;
  z-index: 25;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  pointer-events: none;
}

.h-rail__dots {
  display: flex;
  align-items: center;
  gap: 8px;
  pointer-events: auto;
}

html[data-phase="chat"] .h-rail__dots { pointer-events: none; }

.h-dot {
  width: 22px;
  height: 30px;
  padding: 14px 0;
  border: none;
  background: rgba(245, 236, 222, 0.28);
  background-clip: content-box;
  cursor: pointer;
  transition: width 0.35s ease, background-color 0.35s ease;
}

.h-dot.is-active {
  width: 44px;
  background: var(--gold-pale);
  background-clip: content-box;
}

.h-rail__hint {
  font-size: 12px;
  color: rgba(245, 229, 189, 0.7);
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.9);
  transition: opacity 0.6s ease;
}

@media (max-width: 600px) {
  .hud__brand-en { display: none; }
  .hud__end { gap: 16px; }
  .h-rail__hint { font-size: 11px; }
}

@media (prefers-reduced-motion: reduce) {
  .wa-card, .shatter-cta__orb, .hud__sound[aria-pressed="true"] .sound-bar { animation: none; }
}
