/* Act 0 Introduction Scene — Immersive Living Room Viewport */

.act0-container {
  position: relative;
  width: 100%;
  height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 50% 30%, #FFFDFB 0%, var(--palette-peach-light) 65%, var(--palette-peach) 100%);
  padding: 1rem;
  box-sizing: border-box;
  overflow: hidden;
}

/* Main Cinematic Viewport Card */
.act0-viewport-card {
  position: relative;
  width: min(94vw, 1300px);
  aspect-ratio: 16 / 9;
  max-height: 84vh;
  border-radius: var(--radius-xl);
  overflow: hidden;
  box-shadow: var(--elev-card);
  border: 4px solid var(--palette-warm-white);
  background: var(--palette-text-dark);
  cursor: pointer;
  user-select: none;
}

/* Background Scene Illustration */
.act0-scene-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  pointer-events: none;
}

/* Overlay Layer for Speech Bubbles & Controls */
.act0-speech-layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

/* ==========================================================
   AUTHENTIC SEAMLESS SPEECH BUBBLES WITH UNIFIED STEMS
   ========================================================== */

.speech-bubble {
  position: absolute;
  padding: 1.1rem 1.4rem;
  border-radius: var(--radius-xl);
  box-shadow: 
    0 16px 36px -4px rgba(56, 36, 24, 0.28),
    0 4px 12px rgba(56, 36, 24, 0.15);
  pointer-events: auto;
  cursor: default;
  box-sizing: border-box;
  animation: bubblePop 0.3s var(--ease-back) forwards;
  z-index: 20;
}

@keyframes bubblePop {
  0% {
    opacity: 0;
    transform: scale(0.92) translateY(6px);
  }
  100% {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.speech-bubble-speaker {
  font-family: var(--font-family-display);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 0.35rem;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

/* Bubble typography standard, design-language.md §6.3.1: every speaker, every act. */
.speech-bubble-text {
  font-family: var(--font-family-display);
  font-size: clamp(1rem, 1.25vw, 1.2rem);
  line-height: 1.4;
  margin: 0;
  font-weight: 600;
}

/* --- Callie's Speech Bubble (White / Dark Brown, seamless stem pointing toward Callie) --- */
.speech-bubble.callie-bubble {
  background: var(--palette-warm-white);
  border: 3px solid var(--palette-brown-dark);
  color: var(--palette-brown-dark);
}

.speech-bubble.callie-bubble .speech-bubble-speaker {
  color: var(--palette-teal-dark);
}

/* Callie Seamless Angled Stem: Outer border + Inner mask.
   Horizontal position reads --stem-right so Edit Mode's stem handle (and any
   saved value in visual-overrides.css) actually moves the tail. The fallbacks
   are the previous hardcoded values, so the default rendering is unchanged.
   The ::after is inset 2px from the ::before to keep the border seamless. */
.speech-bubble.callie-bubble::before {
  content: '';
  position: absolute;
  bottom: -22px;
  right: var(--stem-right, 28px);
  width: 0;
  height: 0;
  border-left: 18px solid transparent;
  border-right: 6px solid transparent;
  border-top: 22px solid var(--palette-brown-dark);
  z-index: 1;
}

.speech-bubble.callie-bubble::after {
  content: '';
  position: absolute;
  bottom: -18px;
  right: calc(var(--stem-right, 28px) + 2px);
  width: 0;
  height: 0;
  border-left: 15px solid transparent;
  border-right: 5px solid transparent;
  border-top: 19px solid var(--palette-warm-white);
  z-index: 2;
}

/* --- Tay's Speech Bubble (Peach / Orange, seamless stem pointing toward Tay) --- */
.speech-bubble.tay-bubble {
  background: var(--color-heat-tint);
  border: 3px solid var(--color-heat);
  color: var(--color-heat-deep);
}

.speech-bubble.tay-bubble .speech-bubble-speaker {
  /* WCAG AA: #EA580C on #FFF8F3 was 3.39:1. --color-heat is 4.93:1. */
  color: var(--color-heat);
}

.speech-bubble.tay-bubble .tay-onomatopoeia {
  font-weight: 800;
  color: var(--color-heat);
  font-style: normal;
  display: inline;
  margin-right: 0.2rem;
  text-transform: uppercase;
}

.speech-bubble.tay-bubble .tay-sub-dialogue {
  font-style: italic;
  color: var(--color-heat-deep);
  display: inline;
}

/* Tay Seamless Angled Stem: Outer border + Inner mask.
   Mirrors Callie's stem but reads --stem-left (Edit Mode writes --stem-left for
   every non-Callie bubble). Fallbacks preserve the previous rendering exactly. */
.speech-bubble.tay-bubble::before {
  content: '';
  position: absolute;
  bottom: -22px;
  left: var(--stem-left, 24px);
  width: 0;
  height: 0;
  border-left: 6px solid transparent;
  border-right: 18px solid transparent;
  border-top: 22px solid var(--color-heat);
  z-index: 1;
}

.speech-bubble.tay-bubble::after {
  content: '';
  position: absolute;
  bottom: -18px;
  left: calc(var(--stem-left, 24px) + 2px);
  width: 0;
  height: 0;
  border-left: 5px solid transparent;
  border-right: 15px solid transparent;
  border-top: 19px solid var(--color-heat-tint);
  z-index: 2;
}

/* ==========================================================
   NAVIGATION OVERLAYS & HUD
   ========================================================== */

.act0-nav-bar {
  position: absolute;
  bottom: 1.25rem;
  left: 1.5rem;
  right: 1.5rem;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  pointer-events: none;
  z-index: 30;
}

.act0-nav-group {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  height: 100%;
  pointer-events: auto;
}

.act0-hud-btn {
  background: var(--surface-hud-btn);
  backdrop-filter: blur(8px);
  color: var(--text-inverse);
  border: 1.5px solid var(--hairline-light);
  font-family: var(--font-family-display);
  font-size: 0.92rem;
  font-weight: 700;
  height: 40px;
  padding: 0 1.2rem;
  border-radius: var(--radius-pill);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  box-sizing: border-box;
  transition: background-color var(--dur-fast) var(--ease-out-expo),
              border-color var(--dur-fast) var(--ease-out-expo),
              color var(--dur-fast) var(--ease-out-expo),
              box-shadow var(--dur-fast) var(--ease-out-expo),
              opacity var(--dur-fast) var(--ease-out-expo),
              transform var(--dur-fast) var(--ease-out-expo);
  box-shadow: var(--elev-2);
}

.act0-hud-btn:hover:not(:disabled) {
  background: var(--surface-hud-btn-hover);
  transform: translateY(-2px);
  border-color: var(--hairline-light-strong);
}

.act0-hud-btn:focus-visible {
  outline: var(--focus-ring-width) solid var(--focus-ring-on-dark);
  outline-offset: var(--focus-ring-offset);
  background: var(--surface-hud-btn-hover);
  border-color: var(--hairline-light-strong);
}

.act0-hud-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.act0-hud-btn.btn-start {
  /* WCAG AA: white on #EA580C was 3.56:1. --color-heat is 5.18:1, and matches
     Act 1's .btn-action-primary so the module has one primary-action colour. */
  background: var(--color-heat);
  color: var(--text-inverse);
  border: 2px solid var(--color-amber-tint);
  font-size: 1rem;
  font-weight: 800;
  height: 40px;
  padding: 0 1.4rem;
  box-shadow: 0 6px 20px rgba(194, 65, 12, 0.4);
  animation: pulseStartBtn 1.8s infinite;
}

.act0-hud-btn.btn-start:focus-visible {
  background: var(--color-heat-hover);
  border-color: var(--palette-warm-white);
  outline: var(--focus-ring-width) solid var(--focus-ring-on-dark);
  outline-offset: var(--focus-ring-offset);
}

.act0-hud-btn.btn-start:hover {
  background: var(--color-heat-hover) !important;
  color: var(--text-inverse) !important;
  border-color: var(--palette-warm-white) !important;
  box-shadow: 0 8px 24px rgba(154, 52, 18, 0.6) !important;
  transform: translateY(-2px);
}

@keyframes pulseStartBtn {
  0%, 100% { box-shadow: 0 6px 20px rgba(251, 146, 60, 0.45); }
  50% { box-shadow: 0 8px 28px rgba(251, 146, 60, 0.7); }
}


/* ==========================================================
   REDUCED MOTION
   Looping animation is switched off entirely; entrances are shortened rather
   than removed, so the element still appears (and keeps any transform its
   final keyframe is responsible for).
   ========================================================== */

@media (prefers-reduced-motion: reduce) {
  .act0-hud-btn.btn-start {
    animation: none;
  }

  .speech-bubble {
    animation-duration: 0.01s;
    animation-delay: 0s;
  }

  .act0-hud-btn,
  .act0-hud-btn:hover:not(:disabled) {
    transition: none;
    transform: none;
  }
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .act0-container {
    padding: 0.5rem;
    height: 100vh;
    justify-content: center;
  }
  .act0-viewport-card {
    width: 100%;
    aspect-ratio: 4 / 3;
    max-height: 86vh;
    border-radius: var(--radius-lg);
  }
  .speech-bubble {
    --bubble-max-w: min(92vw, 360px);
    max-width: min(92vw, 360px) !important;
    padding: 0.85rem 1.1rem;
    border-radius: var(--radius-lg);
  }
  .speech-bubble.callie-bubble {
    top: 5% !important;
    left: 4% !important;
    --stem-right: 32px;
  }
  .speech-bubble.tay-bubble {
    top: 18% !important;
    left: auto !important;
    right: 4% !important;
    --stem-left: 28px;
  }
  .speech-bubble-text {
    font-size: clamp(0.92rem, 3.2vw, 1.05rem);
    line-height: 1.38;
  }
  .act0-nav-bar {
    bottom: max(0.65rem, env(safe-area-inset-bottom, 0.65rem));
    left: 0.65rem;
    right: 0.65rem;
    height: 44px;
  }
  .act0-hud-btn {
    height: 42px;
    min-width: 44px;
    padding: 0 1rem;
    font-size: 0.88rem;
    touch-action: manipulation;
  }
}

@media (max-width: 480px) {
  .act0-container {
    padding: 0.25rem;
  }
  .speech-bubble {
    padding: 0.7rem 0.9rem;
  }
  .speech-bubble-speaker {
    font-size: 0.75rem;
    margin-bottom: 0.2rem;
  }
  .act0-hud-btn {
    height: 40px;
    padding: 0 0.85rem;
    font-size: 0.82rem;
  }
}

.act0-hud-btn.vo-mute-btn {
  width: 40px;
  padding: 0;
  border-radius: 50%;
}

/* Act 0 HUD marker */
.act0-hud-top {
  position: absolute;
  top: 1.25rem;
  right: 1.5rem;
  height: 48px;
  display: flex;
  align-items: center;
  pointer-events: none;
  z-index: 40;
}

@media (max-width: 768px) {
  .act0-hud-top {
    top: 0.6rem;
    right: 0.6rem;
  }
}

@media (max-width: 480px) {
  .act0-hud-top {
    display: none;
  }
}
