/**
 * THE KINGDOM OF MOUKI
 * Royal Video Theater Component Styles
 * Dedicated Video Modal, Adaptive 16:9 / 9:16 Stages, Cinematic Fullscreen & Fairytale Aesthetics
 */

/* Video Theater Modal Container */
.funland-theater {
  position: fixed;
  inset: 0;
  z-index: 2100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  box-sizing: border-box;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.3s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.3s;
}

.funland-theater.is-open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

/* Atmospheric Backdrop with Gaussian Blur */
.funland-theater-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(30, 15, 45, 0.92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  cursor: pointer;
}

/* Theater Dialog Container (Standard Windowed Modal) */
.funland-theater-dialog {
  position: relative;
  z-index: 2105;
  width: 100%;
  max-width: 960px;
  max-height: 94vh;
  display: flex;
  flex-direction: column;
  background: linear-gradient(135deg, rgba(250, 246, 255, 0.98) 0%, rgba(255, 240, 245, 0.98) 100%);
  border: 1.5px solid var(--border-gold-subtle);
  border-radius: 20px;
  box-shadow: 0 30px 70px rgba(61, 44, 77, 0.5), 0 0 40px rgba(232, 197, 71, 0.3);
  box-sizing: border-box;
  overflow: hidden;
  transform: scale(0.94) translateY(12px);
  transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1), max-width 0.35s ease;
}

.funland-theater.is-open .funland-theater-dialog {
  transform: scale(1) translateY(0);
}

/* Adaptive Windowed Stage for 9:16 Vertical Reel (Shinchan Corner) */
.funland-theater-dialog--portrait {
  max-width: 440px !important;
}

/* Theater Header Bar */
.funland-theater-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) var(--space-5);
  border-bottom: 1px solid rgba(232, 197, 71, 0.35);
  background: rgba(255, 255, 255, 0.92);
  flex-shrink: 0;
}

.funland-theater-title-wrap {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  overflow: hidden;
}

.funland-theater-icon {
  font-size: 1.5rem;
  line-height: 1;
  flex-shrink: 0;
}

.funland-theater-title {
  font-family: var(--font-royal);
  font-size: var(--text-base);
  font-weight: 700;
  color: var(--color-velvet-plum);
  margin: 0;
  letter-spacing: 0.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.funland-theater-duration-badge {
  font-family: var(--font-body);
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--color-champagne-gold-dark);
  background: var(--color-champagne-gold-light);
  border: 1px solid rgba(232, 197, 71, 0.6);
  padding: 3px 10px;
  border-radius: 999px;
  margin-left: var(--space-2);
  flex-shrink: 0;
}

.funland-theater-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid var(--border-gold-subtle);
  background: #FFFFFF;
  color: var(--color-velvet-plum);
  font-size: 1.3rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  line-height: 1;
  flex-shrink: 0;
  margin-left: var(--space-3);
}

.funland-theater-close:hover,
.funland-theater-close:focus-visible {
  background: var(--color-champagne-gold-light);
  border-color: var(--color-champagne-gold);
  color: var(--color-champagne-gold-dark);
  transform: scale(1.08);
  outline: 2px solid var(--color-champagne-gold);
  outline-offset: 2px;
}

/* Video Stage Area */
.funland-theater-stage {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000000;
  overflow: hidden;
  width: 100%;
}

/* Responsive aspect wrappers */
.funland-theater-video-wrap {
  width: 100%;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000000;
}

/* 16:9 Landscape Aspect Ratio */
.funland-theater-video-wrap--landscape {
  aspect-ratio: 16 / 9;
  max-height: 68vh;
}

/* 9:16 Portrait Aspect Ratio */
.funland-theater-video-wrap--portrait {
  aspect-ratio: 9 / 16;
  max-height: 72vh;
}

/* Video Element */
.funland-theater-video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  outline: none;
  background: #000000;
}

/* Theater Footer Controls Info */
.funland-theater-footer {
  padding: var(--space-3) var(--space-5);
  border-top: 1px solid rgba(232, 197, 71, 0.35);
  background: rgba(255, 255, 255, 0.92);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-2);
  flex-shrink: 0;
}

.funland-theater-shortcuts {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  font-family: var(--font-body);
  font-size: var(--text-xs);
  color: var(--color-dusk-lavender);
  flex-wrap: wrap;
}

.shortcut-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.shortcut-key {
  display: inline-block;
  padding: 1px 6px;
  background: rgba(61, 44, 77, 0.08);
  border: 1px solid rgba(61, 44, 77, 0.15);
  border-radius: 4px;
  font-family: monospace;
  font-weight: 700;
  font-size: 0.75rem;
  color: var(--color-velvet-plum);
}

.funland-theater-status-note {
  font-family: var(--font-body);
  font-size: var(--text-xs);
  color: var(--color-champagne-gold-dark);
  font-style: italic;
  font-weight: 500;
}

/* ==========================================================================
   CINEMATIC FULLSCREEN MODE (Fix for Empty Pink Area & Aspect Ratios)
   ========================================================================== */
.funland-theater-dialog:fullscreen,
.funland-theater-dialog:-webkit-full-screen,
.funland-theater-dialog.is-fullscreen {
  width: 100vw !important;
  height: 100vh !important;
  max-width: 100vw !important;
  max-height: 100vh !important;
  border-radius: 0 !important;
  border: none !important;
  box-shadow: none !important;
  background: #000000 !important; /* Cinematic pure black; zero pink background */
  transform: none !important;
  padding: 0 !important;
  margin: 0 !important;
  display: flex !important;
  flex-direction: column !important;
  justify-content: space-between !important;
  overflow: hidden !important;
}

/* Header in Fullscreen */
.funland-theater-dialog:fullscreen .funland-theater-header,
.funland-theater-dialog:-webkit-full-screen .funland-theater-header,
.funland-theater-dialog.is-fullscreen .funland-theater-header {
  background: rgba(20, 10, 30, 0.90) !important;
  backdrop-filter: blur(16px) !important;
  -webkit-backdrop-filter: blur(16px) !important;
  border-bottom: 1px solid rgba(232, 197, 71, 0.4) !important;
  padding: var(--space-2) var(--space-5) !important;
  z-index: 30 !important;
  flex-shrink: 0 !important;
}

.funland-theater-dialog:fullscreen .funland-theater-title,
.funland-theater-dialog:-webkit-full-screen .funland-theater-title,
.funland-theater-dialog.is-fullscreen .funland-theater-title {
  color: #FAF6FF !important;
  font-size: 1rem !important;
}

.funland-theater-dialog:fullscreen .funland-theater-close,
.funland-theater-dialog:-webkit-full-screen .funland-theater-close,
.funland-theater-dialog.is-fullscreen .funland-theater-close {
  background: rgba(255, 255, 255, 0.18) !important;
  color: #FAF6FF !important;
  border-color: rgba(232, 197, 71, 0.7) !important;
  box-shadow: 0 0 10px rgba(232, 197, 71, 0.3) !important;
}

.funland-theater-dialog:fullscreen .funland-theater-close:hover,
.funland-theater-dialog:fullscreen .funland-theater-close:focus-visible,
.funland-theater-dialog:-webkit-full-screen .funland-theater-close:hover,
.funland-theater-dialog:-webkit-full-screen .funland-theater-close:focus-visible,
.funland-theater-dialog.is-fullscreen .funland-theater-close:hover,
.funland-theater-dialog.is-fullscreen .funland-theater-close:focus-visible {
  background: var(--color-champagne-gold) !important;
  color: var(--color-velvet-plum) !important;
  transform: scale(1.1) !important;
}

/* Stage in Fullscreen */
.funland-theater-dialog:fullscreen .funland-theater-stage,
.funland-theater-dialog:-webkit-full-screen .funland-theater-stage,
.funland-theater-dialog.is-fullscreen .funland-theater-stage {
  flex: 1 1 auto !important;
  width: 100% !important;
  height: 100% !important;
  max-height: none !important;
  min-height: 0 !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  background: #000000 !important;
  overflow: hidden !important;
  padding: 0 !important;
}

.funland-theater-dialog:fullscreen .funland-theater-video-wrap,
.funland-theater-dialog:-webkit-full-screen .funland-theater-video-wrap,
.funland-theater-dialog.is-fullscreen .funland-theater-video-wrap {
  width: 100% !important;
  height: 100% !important;
  max-width: 100% !important;
  max-height: 100% !important;
  aspect-ratio: auto !important; /* Allow stage bounds to determine dimensions */
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  background: #000000 !important;
}

.funland-theater-dialog:fullscreen .funland-theater-video,
.funland-theater-dialog:-webkit-full-screen .funland-theater-video,
.funland-theater-dialog.is-fullscreen .funland-theater-video {
  width: 100% !important;
  height: 100% !important;
  max-width: 100% !important;
  max-height: 100% !important;
  object-fit: contain !important; /* Preserves 16:9 or 9:16 aspect ratio perfectly; centered with zero distortion */
  background: #000000 !important;
}

/* Footer in Fullscreen (Clean, compact non-overlapping bottom bar) */
.funland-theater-dialog:fullscreen .funland-theater-footer,
.funland-theater-dialog:-webkit-full-screen .funland-theater-footer,
.funland-theater-dialog.is-fullscreen .funland-theater-footer {
  background: rgba(20, 10, 30, 0.90) !important;
  backdrop-filter: blur(16px) !important;
  -webkit-backdrop-filter: blur(16px) !important;
  border-top: 1px solid rgba(232, 197, 71, 0.4) !important;
  color: #FAF6FF !important;
  padding: var(--space-2) var(--space-5) !important;
  z-index: 30 !important;
  flex-shrink: 0 !important;
}

.funland-theater-dialog:fullscreen .funland-theater-shortcuts,
.funland-theater-dialog:-webkit-full-screen .funland-theater-shortcuts,
.funland-theater-dialog.is-fullscreen .funland-theater-shortcuts {
  color: #EEDBFF !important;
}

.funland-theater-dialog:fullscreen .shortcut-key,
.funland-theater-dialog:-webkit-full-screen .shortcut-key,
.funland-theater-dialog.is-fullscreen .shortcut-key {
  background: rgba(255, 255, 255, 0.15) !important;
  border-color: rgba(232, 197, 71, 0.5) !important;
  color: #FFF5CC !important;
}

.funland-theater-dialog:fullscreen .funland-theater-status-note,
.funland-theater-dialog:-webkit-full-screen .funland-theater-status-note,
.funland-theater-dialog.is-fullscreen .funland-theater-status-note {
  color: #E8C547 !important;
}

/* Mobile & Touch Adjustments */
@media (max-width: 600px) {
  .funland-theater {
    padding: var(--space-2);
  }
  .funland-theater-dialog {
    max-height: 98vh;
    border-radius: 16px;
  }
  .funland-theater-header,
  .funland-theater-footer {
    padding: var(--space-2) var(--space-3);
  }
  .funland-theater-title {
    font-size: var(--text-sm);
  }
  .funland-theater-shortcuts {
    display: none;
  }
  .funland-theater-video-wrap--landscape {
    max-height: 52vh;
  }
  .funland-theater-video-wrap--portrait {
    max-height: 70vh;
  }
}

/* Reduced Motion Override */
@media (prefers-reduced-motion: reduce) {
  .funland-theater,
  .funland-theater-dialog,
  .funland-theater-close {
    transition: none !important;
    animation: none !important;
    transform: none !important;
  }
}


/* Decryption Loading & Error Overlays */
.funland-theater-overlay {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  padding: var(--space-4);
  background: rgba(15, 10, 25, 0.94);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: #FFFFFF;
  text-align: center;
}

.funland-theater-overlay[hidden] {
  display: none !important;
}

.theater-spinner {
  width: 44px;
  height: 44px;
  border: 3.5px solid rgba(232, 197, 71, 0.25);
  border-top-color: var(--color-champagne-gold);
  border-radius: 50%;
  animation: theaterSpin 0.9s cubic-bezier(0.5, 0.1, 0.5, 0.9) infinite;
}

@keyframes theaterSpin {
  to {
    transform: rotate(360deg);
  }
}

.theater-overlay-text {
  font-family: var(--font-royal);
  font-size: var(--text-base);
  color: #FFF0F5;
  margin: 0;
  max-width: 400px;
  line-height: 1.5;
  letter-spacing: 0.3px;
}

.theater-error-icon {
  font-size: 2.2rem;
  line-height: 1;
}

.theater-retry-btn {
  margin-top: var(--space-2);
  padding: 8px 22px;
  font-family: var(--font-royal);
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--color-velvet-plum);
  background: linear-gradient(135deg, var(--color-champagne-gold-light), var(--color-champagne-gold));
  border: 1px solid var(--border-gold-subtle);
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.theater-retry-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 15px rgba(232, 197, 71, 0.4);
}
