/* ===== Lõi trình chiếu: bố cục, slide, hotspot, lớp vẽ ===== */
:root {
  --night: #050914;
  --navy: #0b1530;
  --plat: #a6d4ea;
  --plat-soft: rgba(150, 205, 232, 0.55);
  --plat-faint: rgba(150, 205, 232, 0.18);
  --plat-bright: #e2f3ff;
  --teal: #14c0d0;
  --text: #e6edf5;
  --muted: #8f9db4;
  --display: Montserrat, "Be Vietnam Pro", -apple-system, "Segoe UI", Arial, sans-serif;
  --sans: "Be Vietnam Pro", Inter, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --scale: 1;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--night);
  color: var(--text);
  font-family: var(--sans);
  overflow: hidden;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

body.framed { --scale: 0.84; }

/* ---------- Khung trình chiếu 16:9, co giãn vừa màn hình ---------- */
#viewport {
  position: fixed;
  inset: 0;
  z-index: 2;
  display: grid;
  place-items: center;
  touch-action: pan-y pinch-zoom;
}

#frame {
  position: relative;
  width: min(calc(100vw * var(--scale)), calc(100vh * var(--scale) * 16 / 9));
  width: min(calc(100dvw * var(--scale)), calc(100dvh * var(--scale) * 16 / 9));
  aspect-ratio: 16 / 9;
  transition: width 0.7s cubic-bezier(0.22, 0.8, 0.16, 1), opacity 0.8s ease;
}

#stage {
  position: absolute;
  inset: 0;
  overflow: hidden;
  background: #0a1224;
}

#slides, .slide { position: absolute; inset: 0; }

.slide {
  opacity: 0;
  visibility: hidden;
}
.slide.active { opacity: 1; visibility: visible; z-index: 2; }
.slide.leaving { opacity: 0; visibility: visible; z-index: 1; }

.slide img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
}

/* Vệt sáng quét ngang khi slide xuất hiện */
.shine {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  background: linear-gradient(
    105deg,
    transparent 32%,
    rgba(190, 236, 255, 0.1) 43%,
    rgba(245, 252, 255, 0.34) 50%,
    rgba(190, 236, 255, 0.1) 57%,
    transparent 68%
  );
}

.hotspots { position: absolute; inset: 0; z-index: 3; }

/* ---------- Hotspot audio (trang 14) ---------- */
.hotspot {
  position: absolute;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  border-radius: 2.6% / 11.6%;
  transition: box-shadow 0.25s ease;
}
.hotspot:hover,
.hotspot:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--accent), 0 0 26px color-mix(in srgb, var(--accent) 60%, transparent);
}
.hotspot[data-state="playing"] { animation: hs-pulse 1.6s ease-in-out infinite; }

.hs-btn {
  position: absolute;
  left: 4.64%;
  top: 21.74%;
  width: 12.48%;
  height: 56.5%;
  border-radius: 50%;
  background: var(--accent);
  display: grid;
  place-items: center;
  opacity: 0;
  transition: opacity 0.15s ease;
}
.hs-btn svg { width: 46%; height: 46%; fill: #fff; }
.hotspot[data-state="playing"] .hs-btn { opacity: 1; }

.hs-wave {
  position: absolute;
  left: 21.76%;
  top: 13.8%;
  width: 72.5%;
  height: 72.5%;
  pointer-events: none;
}
.hs-fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: var(--progress, 0%);
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.24));
  border-right: 2px solid #fff;
  border-radius: 3px;
  opacity: 0;
  transition: opacity 0.15s ease;
}
.hotspot:not([data-state="idle"]) .hs-fill { opacity: 1; }

@keyframes hs-pulse {
  0%, 100% { box-shadow: 0 0 0 2px var(--accent), 0 0 10px color-mix(in srgb, var(--accent) 40%, transparent); }
  50% { box-shadow: 0 0 0 2px var(--accent), 0 0 30px color-mix(in srgb, var(--accent) 75%, transparent); }
}

/* ---------- Bút vẽ / laser / hạt vàng ---------- */
#ink {
  position: absolute;
  inset: 0;
  z-index: 4;
  width: 100%;
  height: 100%;
  pointer-events: none;
  touch-action: none;
}
#ink.enabled { pointer-events: auto; cursor: crosshair; }
#ink.enabled[data-tool="eraser"] { cursor: cell; }

#sparkle, #laser {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
}
#sparkle { z-index: 18; }
#laser { z-index: 20; }

body.laser-on, body.laser-on * { cursor: none !important; }
body.idle[data-tool="pointer"]:not(.laser-on) #viewport { cursor: none; }

/* ---------- Màn hình đen / trắng (B / W) ---------- */
#blank { position: fixed; inset: 0; z-index: 15; background: #000; }
#blank[data-color="white"] { background: #fff; }
#blank[hidden] { display: none; }

@media (prefers-reduced-motion: reduce) {
  #frame { transition: none; }
  .hotspot[data-state="playing"] { animation: none; }
}
