/* ============================================================
   TBM Picture-in-Picture Video System
   State-of-the-art cinematic video component
   Built for tbmcleaning.com
   ============================================================ */

/* ---- CSS Custom Properties ---- */
:root {
  --pip-accent: #00a651;
  --pip-accent-dark: #008a43;
  --pip-dark: #0a0a0a;
  --pip-overlay: rgba(0, 0, 0, 0.55);
  --pip-radius: 12px;
  --pip-transition: cubic-bezier(0.4, 0, 0.2, 1);
  --pip-width: 400px;
  --pip-aspect: 16 / 9;
  --pip-shadow: 0 25px 60px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.08);
  --pip-z: 9990;
}

/* ---- Hero Video Section (Full Width) ---- */
.tbm-video-hero {
  position: relative;
  width: 100%;
  max-width: 100%;
  overflow: hidden;
  background: var(--pip-dark);
}

.tbm-video-hero__inner {
  position: relative;
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

.tbm-video-hero__viewport {
  position: relative;
  width: 100%;
  aspect-ratio: var(--pip-aspect);
  border-radius: var(--pip-radius);
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
  background: #000;
  cursor: pointer;
}

.tbm-video-hero__video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.6s var(--pip-transition);
}

.tbm-video-hero__viewport:hover .tbm-video-hero__video {
  transform: scale(1.02);
}

/* ---- Cinematic Letterbox Bars ---- */
.tbm-video-hero__letterbox {
  position: absolute;
  left: 0;
  right: 0;
  height: 8%;
  background: var(--pip-dark);
  z-index: 2;
  pointer-events: none;
  transition: opacity 0.5s var(--pip-transition);
}

.tbm-video-hero__letterbox--top { top: 0; }
.tbm-video-hero__letterbox--bottom { bottom: 0; }

.tbm-video-hero__viewport.is-playing .tbm-video-hero__letterbox {
  opacity: 0;
}

/* ---- Dark Gradient Overlay ---- */
.tbm-video-hero__overlay {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg,
      rgba(0, 0, 0, 0.3) 0%,
      transparent 30%,
      transparent 60%,
      rgba(0, 0, 0, 0.6) 100%
    );
  z-index: 3;
  pointer-events: none;
  transition: opacity 0.5s var(--pip-transition);
}

/* ---- Play Button (Initial State) ---- */
.tbm-video-hero__play-btn {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 5;
  width: 96px;
  height: 96px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.9);
  background: rgba(0, 166, 81, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.4s var(--pip-transition);
  box-shadow:
    0 0 0 0 rgba(0, 166, 81, 0.4),
    0 8px 32px rgba(0, 0, 0, 0.4);
  animation: tbm-pip-pulse 2.5s ease-in-out infinite;
}

.tbm-video-hero__play-btn:hover {
  background: rgba(0, 166, 81, 1);
  transform: translate(-50%, -50%) scale(1.1);
  box-shadow:
    0 0 0 12px rgba(0, 166, 81, 0.2),
    0 12px 40px rgba(0, 0, 0, 0.5);
}

.tbm-video-hero__play-btn:active {
  transform: translate(-50%, -50%) scale(0.95);
}

.tbm-video-hero__play-btn svg {
  width: 36px;
  height: 36px;
  fill: white;
  margin-left: 4px;
}

.tbm-video-hero__viewport.is-playing .tbm-video-hero__play-btn {
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -50%) scale(0.5);
}

@keyframes tbm-pip-pulse {
  0%, 100% {
    box-shadow:
      0 0 0 0 rgba(0, 166, 81, 0.4),
      0 8px 32px rgba(0, 0, 0, 0.4);
  }
  50% {
    box-shadow:
      0 0 0 20px rgba(0, 166, 81, 0),
      0 8px 32px rgba(0, 0, 0, 0.4);
  }
}

/* ---- Branding Overlay ---- */
.tbm-video-hero__branding {
  position: absolute;
  bottom: 10%;
  left: 0;
  right: 0;
  z-index: 4;
  text-align: center;
  pointer-events: none;
  transition: opacity 0.5s var(--pip-transition);
}

.tbm-video-hero__viewport.is-playing .tbm-video-hero__branding {
  opacity: 0;
}

.tbm-video-hero__branding-badge {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 24px;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-radius: 50px;
  border: 1px solid rgba(255, 255, 255, 0.15);
}

.tbm-video-hero__branding-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--pip-accent);
  animation: tbm-pip-dot-blink 2s ease-in-out infinite;
}

@keyframes tbm-pip-dot-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

.tbm-video-hero__branding-text {
  color: white;
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* ---- Inline Controls Bar ---- */
.tbm-video-hero__controls {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 6;
  padding: 16px 20px;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.7));
  display: flex;
  align-items: center;
  gap: 12px;
  opacity: 0;
  transition: opacity 0.3s var(--pip-transition);
}

.tbm-video-hero__viewport:hover .tbm-video-hero__controls,
.tbm-video-hero__viewport.is-playing .tbm-video-hero__controls {
  opacity: 1;
}

.tbm-video-hero__controls button {
  background: none;
  border: none;
  color: white;
  cursor: pointer;
  padding: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  transition: background 0.2s ease;
}

.tbm-video-hero__controls button:hover {
  background: rgba(255, 255, 255, 0.15);
}

.tbm-video-hero__controls button svg {
  width: 22px;
  height: 22px;
}

/* Progress bar */
.tbm-video-hero__progress {
  flex: 1;
  height: 4px;
  background: rgba(255, 255, 255, 0.25);
  border-radius: 4px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: height 0.15s ease;
}

.tbm-video-hero__progress-bar {
  height: 100%;
  background: var(--pip-accent);
  border-radius: 4px;
  width: 0%;
  transition: width 0.1s linear;
}

.tbm-video-hero__progress:hover {
  height: 6px;
}

.tbm-video-hero__time {
  color: rgba(255, 255, 255, 0.7);
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  min-width: 70px;
  text-align: right;
}

/* ---- Section Padding & Background ---- */
.tbm-video-section {
  padding: 4rem 0 3rem;
  background: linear-gradient(180deg, #000 0%, #0d1117 40%, #0d1117 60%, #000 100%);
  position: relative;
  overflow: hidden;
}

.tbm-video-section::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 60%;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(0, 166, 81, 0.4), transparent);
}

.tbm-video-section__header {
  text-align: center;
  max-width: 700px;
  margin: 0 auto 2.5rem;
  padding: 0 1.5rem;
}

.tbm-video-section__eyebrow {
  display: inline-block;
  color: var(--pip-accent);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  margin-bottom: 0.75rem;
}

.tbm-video-section__title {
  color: white;
  font-size: 2rem;
  font-weight: 700;
  line-height: 1.3;
  margin: 0 0 0.75rem;
}

.tbm-video-section__subtitle {
  color: rgba(255, 255, 255, 0.6);
  font-size: 1.05rem;
  line-height: 1.6;
  margin: 0;
}

/* ================================================
   PICTURE-IN-PICTURE FLOATING MODE
   ================================================ */

.tbm-pip-float {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: var(--pip-width);
  aspect-ratio: var(--pip-aspect);
  z-index: var(--pip-z);
  border-radius: var(--pip-radius);
  overflow: hidden;
  box-shadow: var(--pip-shadow);
  background: #000;
  transform: translateY(120%) scale(0.8);
  opacity: 0;
  pointer-events: none;
  transition:
    transform 0.5s var(--pip-transition),
    opacity 0.5s var(--pip-transition);
}

.tbm-pip-float.is-visible {
  transform: translateY(0) scale(1);
  opacity: 1;
  pointer-events: auto;
}

.tbm-pip-float.is-dragging {
  transition: none;
  cursor: grabbing;
}

.tbm-pip-float__video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* ---- PiP Drag Handle ---- */
.tbm-pip-float__drag {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 32px;
  cursor: grab;
  z-index: 2;
  background: linear-gradient(180deg, rgba(0,0,0,0.5), transparent);
}

.tbm-pip-float__drag::after {
  content: '';
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  width: 40px;
  height: 4px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.3);
}

/* ---- PiP Controls Overlay ---- */
.tbm-pip-float__controls {
  position: absolute;
  top: 8px;
  right: 8px;
  display: flex;
  gap: 6px;
  z-index: 3;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.tbm-pip-float:hover .tbm-pip-float__controls {
  opacity: 1;
}

.tbm-pip-float__btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.tbm-pip-float__btn:hover {
  background: rgba(0, 166, 81, 0.85);
  transform: scale(1.1);
}

.tbm-pip-float__btn svg {
  width: 16px;
  height: 16px;
}

/* ---- PiP Bottom Bar ---- */
.tbm-pip-float__bar {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 8px 12px;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.8));
  display: flex;
  align-items: center;
  gap: 8px;
  z-index: 3;
}

.tbm-pip-float__bar-progress {
  flex: 1;
  height: 3px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 3px;
  overflow: hidden;
  cursor: pointer;
}

.tbm-pip-float__bar-progress-fill {
  height: 100%;
  width: 0%;
  background: var(--pip-accent);
  border-radius: 3px;
  transition: width 0.1s linear;
}

.tbm-pip-float__bar-label {
  color: white;
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  white-space: nowrap;
  opacity: 0.7;
}

/* ---- PiP Play/Pause overlay ---- */
.tbm-pip-float__play-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
  cursor: pointer;
  background: rgba(0, 0, 0, 0.25);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.tbm-pip-float:hover .tbm-pip-float__play-overlay {
  opacity: 1;
}

.tbm-pip-float__play-overlay svg {
  width: 44px;
  height: 44px;
  fill: white;
  filter: drop-shadow(0 2px 8px rgba(0,0,0,0.4));
}

/* ================================================
   RESPONSIVE DESIGN
   ================================================ */

@media (max-width: 1024px) {
  :root {
    --pip-width: 340px;
  }

  .tbm-video-section {
    padding: 3rem 0 2.5rem;
  }

  .tbm-video-section__title {
    font-size: 1.75rem;
  }
}

@media (max-width: 768px) {
  :root {
    --pip-width: 280px;
  }

  .tbm-video-hero__play-btn {
    width: 72px;
    height: 72px;
  }

  .tbm-video-hero__play-btn svg {
    width: 28px;
    height: 28px;
  }

  .tbm-video-section {
    padding: 2.5rem 0 2rem;
  }

  .tbm-video-section__header {
    margin-bottom: 1.5rem;
  }

  .tbm-video-section__title {
    font-size: 1.5rem;
  }

  .tbm-video-section__subtitle {
    font-size: 0.95rem;
  }

  .tbm-video-hero__inner {
    padding: 0 1rem;
  }

  .tbm-video-hero__controls {
    padding: 12px 14px;
  }

  .tbm-video-hero__time {
    font-size: 0.65rem;
    min-width: 55px;
  }

  .tbm-pip-float {
    bottom: 16px;
    right: 16px;
  }
}

@media (max-width: 480px) {
  :root {
    --pip-width: 220px;
  }

  .tbm-video-hero__play-btn {
    width: 60px;
    height: 60px;
    border-width: 2px;
  }

  .tbm-video-hero__play-btn svg {
    width: 22px;
    height: 22px;
  }

  .tbm-video-section {
    padding: 2rem 0 1.5rem;
  }

  .tbm-video-section__title {
    font-size: 1.3rem;
  }

  .tbm-video-hero__branding-badge {
    padding: 6px 14px;
  }

  .tbm-video-hero__branding-text {
    font-size: 0.7rem;
  }

  .tbm-pip-float {
    bottom: 12px;
    right: 12px;
    border-radius: 8px;
  }
}

/* ---- Reduced Motion ---- */
@media (prefers-reduced-motion: reduce) {
  .tbm-video-hero__play-btn {
    animation: none;
  }

  .tbm-pip-float {
    transition: opacity 0.3s ease;
    transform: none !important;
  }

  .tbm-pip-float.is-visible {
    transform: none !important;
  }

  .tbm-video-hero__video {
    transition: none;
  }

  .tbm-video-hero__viewport:hover .tbm-video-hero__video {
    transform: none;
  }
}

/* ---- Focus Styles (Accessibility) ---- */
.tbm-video-hero__play-btn:focus-visible,
.tbm-pip-float__btn:focus-visible,
.tbm-video-hero__controls button:focus-visible {
  outline: 2px solid var(--pip-accent);
  outline-offset: 2px;
}

/* ---- Print: Hide video ---- */
@media print {
  .tbm-video-section,
  .tbm-pip-float {
    display: none !important;
  }
}
