﻿/* ============================================================
   ScenePlayer — reusable scenario-based video+audio player.
   Self-contained styles, no dependencies on landing theme.
   Uses CSS custom properties with fallbacks so it works standalone
   or inherits from the landing theme when embedded.
   ============================================================ */

.scene-player {
  --sp-radius: 16px;
  --sp-shadow: 0 16px 48px rgba(0, 0, 0, 0.28);
  --sp-accent: #2C5F8A;
  --sp-accent-hover: #1E4A6E;
  --sp-text: #fff;
  --sp-text-dim: rgba(255, 255, 255, 0.7);
  --sp-bg: #000;
  --sp-overlay-bg: rgba(0, 0, 0, 0.45);
  --sp-control-bg: rgba(0, 0, 0, 0.6);
  --sp-transition: 400ms ease;

  position: relative;
  width: 100%;
  background: var(--sp-bg);
  border-radius: var(--sp-radius);
  overflow: hidden;
  box-shadow: var(--sp-shadow);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  user-select: none;
}

/* ===== Stage (video area) ===== */
.sp-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
  overflow: hidden;
}

.sp-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity var(--sp-transition);
  pointer-events: none;
}

.sp-video--active {
  opacity: 1;
  z-index: 1;
}

/* ===== Poster (shown before play / after end) ===== */
.sp-poster {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  background-color: #000;
  opacity: 0;
  transition: opacity var(--sp-transition);
  z-index: 3;
  pointer-events: none;
}

.sp-poster--visible {
  opacity: 1;
}

/* ===== Overlay (play button) ===== */
.sp-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--sp-overlay-bg);
  z-index: 4;
  transition: opacity var(--sp-transition);
}

.sp-overlay--hidden {
  opacity: 0;
  pointer-events: none;
}

.sp-play-btn {
  width: 64px;
  height: 64px;
  border: none;
  background: transparent;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s, color 0.2s, filter 0.2s;
  filter: drop-shadow(0 4px 16px rgba(0, 0, 0, 0.5));
}

.sp-play-btn:hover {
  color: var(--sp-accent);
  transform: scale(1.1);
}

.sp-play-btn:active {
  transform: scale(0.94);
}

.sp-play-btn svg {
  margin-left: 3px;  /* optical centering of triangle */
}

/* ===== Sound hint (on poster, before play) ===== */
.sp-sound-hint {
  position: absolute;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  padding: 6px 16px;
  background: rgba(0, 0, 0, 0.6);
  color: var(--sp-text);
  font-size: 0.82rem;
  font-weight: 600;
  border-radius: 20px;
  white-space: nowrap;
  backdrop-filter: blur(4px);
  z-index: 5;
}

/* ===== Error ===== */
.sp-error {
  position: absolute;
  top: 12px;
  left: 12px;
  right: 12px;
  padding: 10px 16px;
  background: rgba(231, 76, 60, 0.9);
  color: #fff;
  font-size: 0.85rem;
  border-radius: 8px;
  opacity: 0;
  transition: opacity 0.3s ease;
  z-index: 6;
  pointer-events: none;
}

.sp-error--visible {
  opacity: 1;
}

/* ===== Controls bar — overlaid at bottom of stage ===== */
.sp-controls {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.6));
  z-index: 6;
  opacity: 1;
  transition: opacity 0.3s ease;
}

/* Hide controls until the user starts playback for the first time */
.scene-player:not(.sp--started) .sp-controls {
  opacity: 0;
  pointer-events: none;
}

.sp-btn {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--sp-text);
  font-size: 0.8rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.sp-btn:hover {
  background: rgba(255, 255, 255, 0.15);
}

.sp-btn--playpause {
  width: 36px;
  font-size: 0.75rem;
  letter-spacing: 1px;
}

.sp-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

/* ===== Progress bar + scene dots ===== */
.sp-progress {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sp-progress-bar {
  position: relative;
  height: 4px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 2px;
  overflow: hidden;
}

.sp-progress-fill {
  height: 100%;
  width: 0%;
  background: var(--sp-accent);
  border-radius: 2px;
  transition: width 0.1s linear;
}

/* ===== Time display ===== */
.sp-time {
  flex-shrink: 0;
  color: var(--sp-text-dim);
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
  font-family: 'JetBrains Mono', 'Inter', monospace;
  min-width: 80px;
  text-align: right;
}

/* ===== States ===== */
.scene-player.sp--ended .sp-play-btn {
  animation: sp-pulse 2s ease-in-out infinite;
}

@keyframes sp-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.06); }
}

/* ===== Fullscreen ===== */
/* When the stage is fullscreen, make it fill the screen and float controls */
.sp-stage:fullscreen {
  width: 100vw;
  height: 100vh;
  background: #000;
}
.sp-stage:-webkit-full-screen {
  width: 100vw;
  height: 100vh;
  background: #000;
}

/* Fullscreen: controls already inside stage, just make them more visible */
.sp-stage:fullscreen .sp-controls,
.sp-stage:-webkit-full-screen .sp-controls {
  padding: 16px 24px 14px;
  background: linear-gradient(transparent, rgba(0,0,0,0.75));
}

.sp-btn--fullscreen {
  font-size: 1rem;
}

.scene-player.sp--ended .sp-overlay {
  background: rgba(0, 0, 0, 0.6);
}

/* ===== Responsive ===== */
@media (max-width: 640px) {
  .sp-play-btn {
    width: 48px;
    height: 48px;
  }
  .sp-play-btn svg {
    width: 40px;
    height: 40px;
  }
  .sp-sound-hint {
    font-size: 0.72rem;
    padding: 4px 12px;
  }
  .sp-controls {
    padding: 8px 10px;
    gap: 8px;
  }
  .sp-time {
    font-size: 0.72rem;
    min-width: 64px;
  }
}

/* ===== When embedded in landing hero (smaller, compact) ===== */
.scene-player--hero {
  --sp-radius: 22px;
  --sp-shadow: 0 16px 40px rgba(30, 20, 16, 0.18);
}

.scene-player--hero .sp-controls {
  background: rgba(0, 0, 0, 0.45);
}

/* Постер в hero — лицо персонажа в верхней части кадра, сдвигаем play-кнопку
   ниже центра, чтобы она не перекрывала лицо */
.scene-player--hero .sp-play-btn {
  position: relative;
  top: 15%;
}

/* ============================================================
   Tablet mockup — clean CSS frame around the player.
   Thin bezel, rounded corners, front camera, home indicator.
   Pure CSS, no images.
   ============================================================ */
.sp-tablet {
  position: relative;
  padding: 16px;
  background:
    linear-gradient(145deg, #2a2a2e 0%, #1a1a1e 30%, #0e0e10 70%, #1a1a1e 100%);
  border-radius: 24px;
  box-shadow:
    /* Outer shadow — floats above page */
    0 20px 50px rgba(30, 20, 16, 0.28),
    0 6px 16px rgba(30, 20, 16, 0.18),
    /* Top edge highlight */
    inset 0 2px 0 rgba(255, 255, 255, 0.1),
    /* Bottom edge shadow */
    inset 0 -1px 0 rgba(0, 0, 0, 0.5),
    /* Side edge highlights */
    inset 1px 0 0 rgba(255, 255, 255, 0.04),
    inset -1px 0 0 rgba(255, 255, 255, 0.04);
}

/* Front camera — small lens dot top center */
.sp-tablet::before {
  content: '';
  position: absolute;
  top: 7px;
  left: 50%;
  transform: translateX(-50%);
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #1a1a1e 0%, #050505 70%);
  box-shadow: inset 0 0 1px rgba(0, 0, 0, 0.9);
  z-index: 20;
  pointer-events: none;
}

/* Home indicator — thin line at bottom center (like iPad) */
.sp-tablet::after {
  content: '';
  position: absolute;
  bottom: 5px;
  left: 50%;
  transform: translateX(-50%);
  width: 80px;
  height: 3px;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 2px;
  z-index: 20;
  pointer-events: none;
}

/* Player fills the tablet screen */
.sp-tablet .scene-player {
  border-radius: 10px;
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.03),
    0 2px 6px rgba(0, 0, 0, 0.3);
  overflow: hidden;
}

/* ===== Mobile: thinner bezel ===== */
@media (max-width: 640px) {
  .sp-tablet {
    padding: 10px;
    border-radius: 16px;
  }
  .sp-tablet::before {
    top: 4px;
    width: 4px;
    height: 4px;
  }
  .sp-tablet::after {
    bottom: 3px;
    width: 50px;
    height: 2px;
  }
  .sp-tablet .scene-player {
    border-radius: 6px;
  }
}
