/* ============================================================
   BD Video player — component-scoped CSS
   ============================================================
   This file is designed to be portable: it can be lifted out of
   the parent design system and dropped into any HTML page.

   - Themable / scale-based tokens are scoped under .bd-video as
     --bd-video-* with a design-system fallback chain.
     Inside the design system: tokens flow through.
     Outside the design system: hard-coded fallbacks apply.
   - Incidental primitives (overlay opacities, white text, pill
     radius, focus ring) are inlined directly as literal values
     rather than tokenized. They aren't themable; tokenizing them
     would just add bureaucratic indirection.
   - .svg-icn is defined locally (scoped to .bd-video) so the
     component doesn't depend on the design system's global rule.
   - All classes are namespaced (.bd-video-*) — no leakage.

   When extending or modifying:
   - Add new themable tokens as --bd-video-* with a fallback.
   - Inline incidental literal values directly (don't tokenize).
   - Never reference design system tokens directly inside rules.
   - Keep all selectors scoped under .bd-video.
   ============================================================ */

/* ------ BD VIDEO COMPONENT ------ */
/*
 * Reusable video player with custom controls. Used for the hero showreel
 * on the home page and available for any future video placement.
 *
 * Structure:
 *   .bd-video                 — container (position: relative)
 *   .bd-video-player          — the <video> element
 *   .bd-video-center-play     — large centered play/pause button
 *   .bd-video-unmute-prompt   — large top-center unmute button (autoplay muted only)
 *   .bd-video-scrubber         — seek bar (absolute, full-width bottom)
 *   .bd-video-scrubber-fill    — filled portion of the seek bar
 *   .bd-video-time             — visible time display (e.g. 1:23 / 5:30)
 *   .bd-video-controls        — button row (absolute, bottom-right)
 *   .bd-video-btn             — individual control button (pill)
 *
 * State:
 *   .bd-video.is-preview          — silent preview (autoplay muted); play + unmute always visible
 *   .bd-video.is-controls-hidden — center button + controls bar faded out (auto-hide after 3s)
 *   .bd-video.is-paused          — video is paused (center button stays visible)
 *   .bd-video.is-unmuted         — user has unmuted; hides the unmute prompt permanently
 *
 * JS: bd-video.js (self-initialising, exits early if no .bd-video-player)
 */

/* -- Component tokens — scoped under .bd-video -- */
.bd-video {
  /* COLOR — themable brand surfaces */
  --bd-video-color-accent: var(--text-accent, #3485cd);
  --bd-video-color-cue-bg: var(--yellow-lighter, #fff8e0);
  --bd-video-color-cue-bg-hover: var(--yellow-light, #ffe89c);
  --bd-video-color-cue-text: var(--neutral-900, #1f1f1f);
  --bd-video-color-cue-meta: var(--neutral-700, #565656);

  /* MOTION — design system scale */
  --bd-video-duration-fast: var(--duration-2xs, 100ms);
  --bd-video-duration-transition: var(--duration-s, 400ms);
  --bd-video-duration-mobile-scrubber: var(--duration-m, 600ms);
  --bd-video-duration-fade: var(--duration-2xl, 1200ms);
  --bd-video-ease: var(--ease-out, cubic-bezier(0.16, 1, 0.3, 1));

  /* SPACING — design system scale */
  --bd-video-space-xs: var(--space-xs, 0.5rem);
  --bd-video-space-s: var(--space-s, 0.75rem);
  --bd-video-space-m: var(--space-m, 1rem);
  --bd-video-space-l: var(--space-l, 1.5rem);
  --bd-video-space-xl: var(--space-xl, 2rem);
  --bd-video-space-3xl: var(--space-3xl, 4rem);
  --bd-video-inset: var(--space-s, 0.75rem); /* outer inset for scrubber + cue region */

  /* TYPOGRAPHY — design system scale */
  --bd-video-font-family: var(--font-primary, system-ui, -apple-system, sans-serif);
  --bd-video-font-2xs: var(--font-2xs, 0.75rem);
  --bd-video-font-xs: var(--font-xs, 0.875rem);
  --bd-video-font-m: var(--font-m, 1.125rem);

  /* RADIUS — design system scale (pill is inlined as 999px in the rules) */
  --bd-video-radius-s: var(--radius-s, 6px);
  --bd-video-radius-m: var(--radius-m, 10px);

  position: relative;
  width: 100%;
  /* padding moved to consumer wrapper (e.g. .home-hero) so the player itself
     can carry rounded corners + border without padding visually leaking. */
  overflow: hidden;
}

/* Local .svg-icn — scoped to .bd-video so the component doesn't depend on
   the design system's global rule. */
.bd-video .svg-icn {
  display: flex;
  width: 1.3rem;
  height: 1.3rem;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  aspect-ratio: 1 / 1;
  transition: color var(--bd-video-duration-transition) var(--bd-video-ease);
}

.bd-video-player {
  width: 100%;
  display: block;
  object-fit: cover;
  cursor: pointer;
  overflow: hidden;
}


/* -- Center play/pause button -- */

/* Disable the global :active press transform on video-player buttons.
   The centered buttons use transform for positioning — letting the
   global rule replace it would jump the hit zone away from the cursor
   and silently drop the click. */
.bd-video-center-play:active {
  transform: translate(-50%, -50%);
}

.bd-video-unmute-prompt:active {
  transform: translateX(-50%);
}

.bd-video-btn:active {
  transform: none;
}

.bd-video-center-play {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 72px;
  height: 72px;
  padding: 0;
  background: rgba(0, 0, 0, 0.5);
  border: none;
  border-radius: 999px;
  color: #fff;
  cursor: pointer;
  z-index: 2;
  transition: opacity var(--bd-video-duration-transition) var(--bd-video-ease),
              background-color var(--bd-video-duration-fast) var(--bd-video-ease);
}

.bd-video-center-play:hover {
  background: rgba(0, 0, 0, 0.7);
}

.bd-video-center-play:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

.bd-video-center-play .svg-icn {
  width: 32px;
  height: 32px;
}

/* Hide center button when controls are hidden (playing + idle) */
.bd-video.is-controls-hidden .bd-video-center-play {
  opacity: 0;
  pointer-events: none;
}

/* Always show center button when paused, regardless of hide state */
.bd-video.is-paused .bd-video-center-play {
  opacity: 1;
  pointer-events: auto;
}

/* Tooltip on hover */
.bd-video-center-play[data-tooltip]:hover::after,
.bd-video-btn[data-tooltip]:hover::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + var(--bd-video-space-xs));
  left: 50%;
  transform: translateX(-50%);
  padding: var(--bd-video-space-xs) var(--bd-video-space-s);
  background: rgba(0, 0, 0, 0.8);
  color: #fff;
  font-family: var(--bd-video-font-family);
  font-size: var(--bd-video-font-xs);
  border-radius: var(--bd-video-radius-s);
  white-space: nowrap;
  pointer-events: none;
}


/* -- Unmute prompt (shown when video autoplays muted) -- */

.bd-video-unmute-prompt {
  position: absolute;
  top: var(--bd-video-space-xl);
  left: 50%;
  transform: translateX(-50%);
  display: inline-flex;
  align-items: center;
  gap: var(--bd-video-space-s);
  padding: var(--bd-video-space-s) var(--bd-video-space-l);
  background: rgba(0, 0, 0, 0.7);
  border: none;
  color: #fff;
  font-family: var(--bd-video-font-family);
  font-size: var(--bd-video-font-m);
  cursor: pointer;
  z-index: 2;
  transition: opacity var(--bd-video-duration-transition) var(--bd-video-ease),
              background-color var(--bd-video-duration-fast) var(--bd-video-ease);
}

.bd-video-unmute-prompt:hover {
  background: rgba(0, 0, 0, 0.7);
}

.bd-video-unmute-prompt:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

.bd-video-unmute-prompt .svg-icn {
  width: 24px;
  height: 24px;
}

/* Hide permanently once unmuted */
.bd-video.is-unmuted .bd-video-unmute-prompt {
  display: none;
}




/* -- Scrubber (seek bar) -- */

.bd-video-scrubber {
  position: absolute;
  bottom: var(--bd-video-inset);
  left: var(--bd-video-inset);
  right: var(--bd-video-inset);
  height: var(--bd-video-space-xs);
  background: rgba(0, 0, 0, 0.2);
  cursor: pointer;
  z-index: 3;
  transition: height var(--bd-video-duration-fast) var(--bd-video-ease);
}

/* Expanded hit area — 40px tall touch/click zone overlapping and extending above the track */
.bd-video-scrubber::before {
  content: "";
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 30px;
  cursor: pointer;
  /* background-color: rgba(255, 255, 255, 0.2); */
}

.bd-video:hover .bd-video-scrubber,
.bd-video-scrubber.is-scrubbing,
.bd-video-scrubber:focus-visible {
  height: var(--bd-video-space-s);
}

.bd-video-scrubber:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

.bd-video-scrubber-fill {
  height: 100%;
  width: 0%;
  background: var(--bd-video-color-accent);
  pointer-events: none;
}

/* Preview state — center button + unmute prompt always visible */
.bd-video.is-preview .bd-video-center-play,
.bd-video.is-preview .bd-video-unmute-prompt {
  opacity: 1;
  pointer-events: auto;

}

.bd-video.is-preview .bd-video-center-play {
  background: rgba(0, 0, 0, 0.6);
   width: 90px;
  height: 90px;

}

/* -- Scrubber seek tooltip -- */

.bd-video-seek-tooltip {
  position: absolute;
  bottom: calc(var(--bd-video-space-s) + var(--bd-video-space-l));
  left: 0;
  padding: var(--bd-video-space-xs) var(--bd-video-space-s);
  background: rgba(0, 0, 0, 0.8);
  color: #fff;
  font-family: var(--bd-video-font-family);
  font-size: var(--bd-video-font-xs);
  border-radius: var(--bd-video-radius-s);
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  z-index: 4;
  transform: translateX(-50%);
}

.bd-video-seek-tooltip.is-visible {
  opacity: 1;
}


/* -- Time display -- */

.bd-video-time {
  font-family: var(--bd-video-font-family);
  font-size: var(--bd-video-font-xs);
  color: #fff;
  white-space: nowrap;
  padding: 0 var(--bd-video-space-xs);
}


/* -- Bottom controls (mute, fullscreen) -- */

.bd-video-controls {
  position: absolute;
  padding: 0 var(--bd-video-space-m);
  bottom: var(--bd-video-space-3xl);
  left: var(--bd-video-space-l);
  right: var(--bd-video-space-xl);
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--bd-video-space-xs);
  z-index: 5;
  transition: opacity var(--bd-video-duration-fade) var(--bd-video-ease);
}

.bd-video-controls-right {
  display: flex;
  align-items: center;
  gap: var(--bd-video-space-xs);
}

.bd-video.is-controls-hidden .bd-video-controls {
  opacity: 0;
  pointer-events: none;
}

.bd-video-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  color: #fff;
  background: rgba(0, 0, 0, 0.5);
  border: none;
  border-radius: 999px;
  cursor: pointer;
  transition: background-color var(--bd-video-duration-fast) var(--bd-video-ease);
}

.bd-video-btn:hover {
  background: rgba(0, 0, 0, 0.7);
}

.bd-video-btn:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

.bd-video-btn .svg-icn {
  width: 20px;
  height: 20px;
}

/* Hidden until unmute prompt is dismissed */
.bd-video-btn.is-mute-hidden {
  opacity: 0;
  pointer-events: none;
}

@media (max-width: 768px) {
  .bd-video-center-play {
    width: 64px;
    height: 64px;
  }

  .bd-video-center-play .svg-icn {
    width: 28px;
    height: 28px;
  }

  .bd-video-btn {
    width: 48px;
    height: 48px;
  }

  .bd-video-scrubber {
    height: var(--bd-video-space-s);
  }

  .bd-video:hover .bd-video-scrubber,
  .bd-video-scrubber.is-scrubbing,
  .bd-video-scrubber:focus-visible {
    height: var(--bd-video-space-m);
  }

  .bd-video-time {
    line-height: 48px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .bd-video-controls,
  .bd-video-center-play,
  .bd-video-unmute-prompt,
  .bd-video-scrubber,
  .bd-video-btn,
  .bd-video-cue-slot {
    transition: none;
  }
  .bd-video-cue-slot,
  .bd-video.is-cue-visible .bd-video-cue-slot {
    transform: none;
  }
}


/* -- Cue overlay (timed link cards) -- */
/* Cue colors are themable via --bd-video-color-cue-* tokens (see top of file).
   They never inherit semantic color tokens like --text-primary, because those
   flip in dark mode and the video background doesn't. */

/* Persistent wrapper — always in DOM, hosts aria-live */
.bd-video-cue-region {
  position: absolute;
  top: var(--bd-video-inset);
  left: var(--bd-video-inset);
  z-index: 2;
  pointer-events: none;
}

/* Card — hidden by default via visibility + opacity */
.bd-video-cue-slot {
  display: flex;
  align-items: center;
  gap: var(--bd-video-space-s);
  max-width: 320px;
  padding: var(--bd-video-space-s);
  background: var(--bd-video-color-cue-bg);
  color: var(--bd-video-color-cue-text);
  border-radius: var(--bd-video-radius-s);
  text-decoration: none;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-4px);
  pointer-events: none;
  transition:
    opacity var(--bd-video-duration-transition) var(--bd-video-ease),
    transform var(--bd-video-duration-transition) var(--bd-video-ease),
    visibility 0ms var(--bd-video-duration-transition);
}

.bd-video.is-cue-visible .bd-video-cue-slot {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  pointer-events: auto;
  transition:
    opacity var(--bd-video-duration-transition) var(--bd-video-ease),
    transform var(--bd-video-duration-transition) var(--bd-video-ease),
    visibility 0ms 0ms;
}

.bd-video-cue-thumb {
  width: 64px;
  height: 64px;
  object-fit: cover;
  border-radius: 4px;
  flex-shrink: 0;
}

.bd-video-cue-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.bd-video-cue-title {
  font-size: var(--bd-video-font-xs);
  font-weight: 600;
  line-height: 1.2;
}

.bd-video-cue-excerpt {
  font-size: var(--bd-video-font-2xs);
  line-height: 1.3;
  color: var(--bd-video-color-cue-meta);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Hover / focus */
.bd-video-cue-slot:hover {
  background: var(--bd-video-color-cue-bg-hover);
  transform: translateY(-1px);
}

.bd-video-cue-slot:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

/* Mobile — text only + arrow, no thumbnail or excerpt; card hugs top-left */
@media (max-width: 768px) {
  .bd-video-cue-region {
    top: var(--bd-video-space-s);
    left: var(--bd-video-space-s);
  }
  .bd-video-cue-thumb {
    display: none;
  }
  .bd-video-cue-excerpt {
    display: none;
  }
  .bd-video-cue-slot::after {
    content: "\2192";
    flex-shrink: 0;
    font-size: var(--bd-video-font-xs);
    color: var(--bd-video-color-cue-meta);
  }
}
