/* ==========================================================================
   CINEMATIC MOTION, ATMOSPHERE & SUBTLE MICRO-INTERACTIONS
   ========================================================================== */

@keyframes kenBurnsSlow {
  0% {
    transform: scale(1) translate3d(0, 0, 0);
  }
  100% {
    transform: scale(1.055) translate3d(-0.8%, -0.5%, 0);
  }
}

@keyframes fadeInCinema {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes sceneImageReveal {
  from {
    opacity: 0;
    filter: brightness(0.85) blur(3px);
  }
  to {
    opacity: 1;
    filter: brightness(1) blur(0);
  }
}

@keyframes flashBurst {
  0% { opacity: 0; }
  12% { opacity: 0.92; }
  45% { opacity: 0.25; }
  100% { opacity: 0; }
}

@keyframes smsGlitchPulse {
  0%, 100% {
    transform: translateX(0);
    text-shadow: 0 0 12px rgba(106, 211, 232, 0.45);
  }
  20% {
    transform: translateX(-2px);
    text-shadow: 2px 0 rgba(106, 211, 232, 0.7), -2px 0 rgba(217, 107, 118, 0.55);
  }
  40% {
    transform: translateX(2px);
    opacity: 0.85;
  }
  60% {
    transform: translateX(-1px);
    text-shadow: -1px 0 rgba(106, 211, 232, 0.8), 1px 0 rgba(226, 186, 109, 0.45);
  }
}

@keyframes subtlePulseDot {
  0%, 100% { opacity: 0.5; transform: scale(0.95); }
  50% { opacity: 1; transform: scale(1.15); }
}

@keyframes toastSlideIn {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Live 3-Bar Audio Equalizer Indicator */
@keyframes eqBarBounce {
  0%, 100% { transform: scaleY(0.32); }
  50% { transform: scaleY(1); }
}

.eq-bars {
  display: none;
  align-items: flex-end;
  gap: 2px;
  height: 12px;
  width: 12px;
  flex-shrink: 0;
}

.eq-bars i {
  display: block;
  width: 2.5px;
  height: 100%;
  border-radius: 99px;
  background: currentColor;
  transform-origin: bottom;
  animation: eqBarBounce 0.72s ease-in-out infinite;
}

.eq-bars i:nth-child(2) {
  animation-delay: 0.18s;
  animation-duration: 0.58s;
}

.eq-bars i:nth-child(3) {
  animation-delay: 0.34s;
  animation-duration: 0.82s;
}

.reader-bgm-top.on .eq-bars,
.dock-bgm-btn.on .eq-bars,
.cinema-speak-btn.speaking .eq-bars,
.dock-speak-btn.speaking .eq-bars,
.dock-autoplay-btn.playing .eq-bars {
  display: inline-flex;
}

.reader-bgm-top.on .bgm-icon-note,
.dock-bgm-btn.on .bgm-icon-note,
.cinema-speak-btn.speaking .speak-icon-vol,
.dock-speak-btn.speaking .speak-icon-vol {
  display: none;
}

.scene-img-active {
  animation:
    sceneImageReveal 0.75s var(--ease-cinema) forwards,
    kenBurnsSlow 20s ease-out forwards;
}

.fade-in-up {
  animation: fadeInCinema 0.48s var(--ease-cinema) forwards;
}

.flash-overlay {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 55% 45%, #ffffff 0%, #fff7e0 45%, rgba(255, 255, 255, 0) 85%);
  pointer-events: none;
  opacity: 0;
  z-index: 12;
}

.flash-overlay.trigger {
  animation: flashBurst 0.65s ease-out forwards;
}

/* Rain Canvas Overlay — ultra subtle, moody */
.rain-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 5;
  opacity: 0.45;
  transition: opacity 0.6s ease;
}

.rain-canvas.hidden {
  opacity: 0;
}

/* Holographic Future SMS Card over Stage */
.sms-stage-card {
  position: absolute;
  bottom: 18px;
  right: 18px;
  max-width: 440px;
  background: rgba(9, 14, 26, 0.84);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border: 1px solid rgba(106, 211, 232, 0.34);
  border-radius: var(--radius-md);
  padding: 13px 17px;
  z-index: 9;
  box-shadow:
    0 18px 42px rgba(0, 0, 0, 0.55),
    inset 0 1px 0 rgba(106, 211, 232, 0.18);
  animation: fadeInCinema 0.55s var(--ease-cinema) forwards;
}

.sms-stage-card.overwrite-mode {
  border-color: rgba(217, 107, 118, 0.42);
  box-shadow:
    0 18px 46px rgba(0, 0, 0, 0.62),
    0 0 28px rgba(106, 211, 232, 0.12);
}

.sms-stage-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  font-size: 10.5px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--cyan-time);
  margin-bottom: 7px;
  opacity: 0.92;
  white-space: nowrap;
}

.sms-stage-sender {
  display: flex;
  align-items: center;
  gap: 6px;
}

.sms-live-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--cyan-time);
  animation: subtlePulseDot 1.8s infinite;
}

.sms-stage-card.overwrite-mode .sms-live-dot {
  background: var(--crimson-alert);
}

.sms-stage-body {
  font-family: var(--font-zh);
  font-size: 16px;
  font-weight: 500;
  line-height: 1.55;
  color: #eef9fc;
  letter-spacing: 0.02em;
}

.sms-stage-body.glitching {
  animation: smsGlitchPulse 0.38s linear infinite;
}

.sms-stage-sub {
  margin-top: 6px;
  font-size: 12px;
  color: rgba(210, 224, 238, 0.74);
  line-height: 1.45;
}

.sms-overwrite-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
  font-size: 10.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--crimson-alert);
  opacity: 0;
  transition: opacity 0.6s ease;
}

.sms-overwrite-tag.visible {
  opacity: 1;
}

/* Emergency Subway Alert Badge on Stage */
.alert-stage-pill {
  position: absolute;
  top: 18px;
  left: 18px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 13px;
  border-radius: 99px;
  background: rgba(28, 12, 16, 0.8);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(217, 107, 118, 0.38);
  color: #f4b6bc;
  font-size: 11.5px;
  letter-spacing: 0.04em;
  z-index: 9;
  animation: fadeInCinema 0.5s var(--ease-cinema) forwards;
}

.alert-stage-pill .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--crimson-alert);
  animation: subtlePulseDot 1.1s infinite;
}

/* ==========================================================================
   INTERACTIVE PUZZLES (EP6 SAFE KEYPAD & EP8 FAKE SMS INSPECTION)
   ========================================================================== */

.puzzle-card {
  margin-top: 10px;
  padding: 16px 18px;
  border-radius: 12px;
  background: rgba(10, 14, 26, 0.72);
  border: 1px solid rgba(226, 186, 109, 0.24);
  animation: fadeInCinema 0.4s var(--ease-cinema) forwards;
}

.puzzle-hint-box {
  font-size: 12.5px;
  color: var(--text-secondary);
  line-height: 1.55;
  margin-bottom: 12px;
}

.keypad-display {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: 10px;
  background: rgba(5, 8, 15, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.09);
  font-family: ui-monospace, 'Cascadia Mono', Consolas, monospace;
  font-size: 20px;
  letter-spacing: 0.22em;
  color: var(--gold-primary);
  margin-bottom: 12px;
  min-height: 46px;
}

.keypad-display.error {
  border-color: rgba(217, 107, 118, 0.55);
  color: var(--crimson-alert);
}

.keypad-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 6px;
  margin-bottom: 10px;
}

.keypad-key {
  padding: 9px 6px;
  border-radius: 8px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid rgba(255, 255, 255, 0.09);
  transition: all 0.16s ease;
}

.keypad-key:hover {
  background: rgba(226, 186, 109, 0.12);
  border-color: rgba(226, 186, 109, 0.4);
  color: var(--gold-primary);
}

.keypad-key.confirm {
  background: rgba(226, 186, 109, 0.18);
  border-color: rgba(226, 186, 109, 0.42);
  color: var(--gold-primary);
  font-weight: 600;
}

.puzzle-feedback {
  font-size: 12.5px;
  min-height: 20px;
  color: var(--text-secondary);
  margin-top: 6px;
}

.puzzle-feedback.ok {
  color: var(--emerald-safe);
}

.puzzle-feedback.err {
  color: #f0959e;
}

/* Ep 8 Fake SMS Token Inspection */
.inspect-sms-box {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  padding: 14px 16px;
  border-radius: 10px;
  background: rgba(6, 10, 20, 0.85);
  border: 1px solid rgba(106, 211, 232, 0.25);
  margin-bottom: 12px;
}

.sms-token-btn {
  padding: 6px 11px;
  border-radius: 8px;
  font-family: var(--font-zh);
  font-size: 17px;
  color: #eef8fc;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.1);
  transition: all 0.2s ease;
}

.sms-token-btn:hover {
  border-color: rgba(106, 211, 232, 0.5);
  background: rgba(106, 211, 232, 0.1);
}

.sms-token-btn.flagged {
  border-color: rgba(217, 107, 118, 0.65);
  background: rgba(217, 107, 118, 0.16);
  color: #ffd0d5;
}

.inspect-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.ending-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 12px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 8px;
}

.ending-badge.true {
  color: var(--gold-primary);
  background: rgba(226, 186, 109, 0.14);
  border: 1px solid rgba(226, 186, 109, 0.35);
}

.ending-badge.alt {
  color: var(--cyan-time);
  background: rgba(106, 211, 232, 0.12);
  border: 1px solid rgba(106, 211, 232, 0.3);
}

.ending-badge.loop {
  color: #f4a4ac;
  background: rgba(217, 107, 118, 0.14);
  border: 1px solid rgba(217, 107, 118, 0.35);
}

/* ==========================================================================
   MOTION COMIC DIRECTOR (CAMERA CHOREOGRAPHY, PARTICLES & LIGHT PULSE)
   ========================================================================== */

@keyframes camDollyIn {
  0% { transform: scale(1) translate3d(0, 0, 0); }
  100% { transform: scale(1.1) translate3d(0, -1.2%, 0); }
}

@keyframes camPanLeft {
  0% { transform: scale(1.085) translate3d(2.2%, 0, 0); }
  100% { transform: scale(1.085) translate3d(-2.2%, -0.35%, 0); }
}

@keyframes camPanRight {
  0% { transform: scale(1.085) translate3d(-2.2%, -0.35%, 0); }
  100% { transform: scale(1.085) translate3d(2.2%, 0, 0); }
}

@keyframes camPullBack {
  0% { transform: scale(1.11) translate3d(0, -1%, 0); }
  100% { transform: scale(1.01) translate3d(0, 0, 0); }
}

@keyframes camFloatHandheld {
  0% { transform: scale(1.055) translate3d(0, 0, 0) rotate(0deg); }
  33% { transform: scale(1.08) translate3d(-0.65%, -0.55%, 0) rotate(-0.32deg); }
  66% { transform: scale(1.07) translate3d(0.55%, -0.85%, 0) rotate(0.28deg); }
  100% { transform: scale(1.095) translate3d(-0.2%, -0.35%, 0) rotate(0deg); }
}

@keyframes camDiagonalPush {
  0% { transform: scale(1.03) translate3d(-1.7%, 0.9%, 0); }
  100% { transform: scale(1.1) translate3d(1.5%, -1.3%, 0); }
}

@keyframes lightPulseBreath {
  0%, 100% {
    opacity: 0.22;
    transform: scale(1);
  }
  50% {
    opacity: 0.58;
    transform: scale(1.06);
  }
}

@keyframes speakingSweepLine {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

.cinema-motion-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 3;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.45s ease;
}

body.cinema-motion-on .cinema-motion-canvas {
  opacity: 1;
}

.cinema-light-pulse {
  position: absolute;
  inset: -6%;
  z-index: 2;
  pointer-events: none;
  opacity: 0;
  mix-blend-mode: screen;
  background: radial-gradient(
    ellipse 72% 58% at 50% 44%,
    var(--motion-glow-color, rgba(226, 186, 109, 0.22)) 0%,
    rgba(0, 0, 0, 0) 72%
  );
  transition: opacity 0.45s ease;
}

body.cinema-motion-on .cinema-light-pulse {
  animation: lightPulseBreath 5.2s ease-in-out infinite;
}

/* Crossfade & multi-shot camera choreography during Motion Comic mode */
body.cinema-motion-on .cinema-img {
  transition: opacity 0.56s var(--ease-cinema);
}

body.cinema-motion-on .cinema-img.cam-dolly-in {
  animation: camDollyIn var(--cam-dur, 6.2s) cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

body.cinema-motion-on .cinema-img.cam-pan-left {
  animation: camPanLeft var(--cam-dur, 6.6s) cubic-bezier(0.32, 0.22, 0.38, 1) forwards;
}

body.cinema-motion-on .cinema-img.cam-pan-right {
  animation: camPanRight var(--cam-dur, 6.6s) cubic-bezier(0.32, 0.22, 0.38, 1) forwards;
}

body.cinema-motion-on .cinema-img.cam-pull-back {
  animation: camPullBack var(--cam-dur, 6.4s) cubic-bezier(0.22, 0.61, 0.36, 1) forwards;
}

body.cinema-motion-on .cinema-img.cam-float-handheld {
  animation: camFloatHandheld var(--cam-dur, 6.8s) ease-in-out forwards;
}

body.cinema-motion-on .cinema-img.cam-diagonal-push {
  animation: camDiagonalPush var(--cam-dur, 6.5s) cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

/* Subtle live speaking shimmer along frame bottom edge & dialogue panel when Auto-Play is active */
body.cinema-speaking-live .cinema-frame::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 2px;
  z-index: 10;
  pointer-events: none;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(226, 186, 109, 0.85) 35%,
    rgba(255, 240, 198, 0.95) 50%,
    rgba(226, 186, 109, 0.85) 65%,
    transparent 100%
  );
  background-size: 200% 100%;
  animation: speakingSweepLine 2.4s linear infinite;
}

body.cinema-speaking-live .cinema-dialogue-panel {
  border-color: var(--border-gold);
}

.motion-chip {
  padding: 4px 8px;
  font-size: 11.5px;
}

@media (prefers-reduced-motion: reduce) {
  .cinema-motion-canvas,
  .cinema-light-pulse,
  body.cinema-speaking-live .cinema-frame::after {
    display: none !important;
  }
  body.cinema-motion-on .cinema-img[class*='cam-'] {
    animation: none !important;
  }
}

