/* =========================================================================
   Exx Player — custom HTML5 video player
   Matches the Exx app's design language: ink/wine/gold glassmorphism,
   Fraunces display type, animated gradient border-glow.
   Everything is scoped under .exxp so it can be dropped into any page
   without colliding with host styles. Include Fraunces + Inter from
   Google Fonts on the host page (the Exx app already does).
   ========================================================================= */

.exxp {
  --ink: #0b0a08;
  --surface: #17140f;
  --surface-raised: #201b13;
  --wine: #6b0f2a;
  --rose: #e8a0ac;
  --gold: #c9a227;
  --gold-bright: #e8c14d;
  --paper: #f3efe4;
  --dim: #8a8272;

  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
  border-radius: 10px;
  overflow: hidden;
  font-family: "Inter", sans-serif;
  color: var(--paper);
  isolation: isolate;
  outline: none;
  -webkit-user-select: none;
  user-select: none;
}

.exxp * { box-sizing: border-box; }

.exxp:fullscreen,
.exxp:-webkit-full-screen {
  border-radius: 0;
  aspect-ratio: unset;
}

.exxp-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
  display: block;
}

/* Reusable frosted-glass surface, identical recipe to the app's .glass */
.exxp-glass {
  background: rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(20px) saturate(160%);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
  border: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

/* Animated gradient ring, identical recipe to the app's .border-glow.
   Reserved for the single boldest moment in the player: the paused /
   poster play button. Everything else stays quiet by comparison. */
.exxp-border-glow { position: relative; }

.exxp-border-glow::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 1.5px;
  background: linear-gradient(115deg, var(--wine), var(--rose), var(--gold), #7a1f4b, var(--wine));
  background-size: 300% 300%;
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  animation: exxp-glowflow 9s linear infinite;
  pointer-events: none;
}

@keyframes exxp-glowflow {
  to { background-position: 300% 0%; }
}

/* --- Poster gate (shown before first play) ------------------------------ */

.exxp-poster {
  position: absolute;
  inset: 0;
  z-index: 3;
  background-size: cover;
  background-position: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 22px;
  text-align: center;
  padding: 24px;
  cursor: pointer;
  transition: opacity 0.5s ease;
}

.exxp-poster::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: radial-gradient(ellipse at center, rgba(107, 15, 42, 0.35), var(--ink) 78%);
}

.exxp-poster.leaving {
  opacity: 0;
  pointer-events: none;
}

.exxp-poster-title {
  font-family: "Fraunces", serif;
  font-weight: 600;
  font-size: clamp(18px, 3vw, 28px);
  max-width: 80%;
}

.exxp-poster-subtitle {
  font-size: 13px;
  color: var(--dim);
  margin-top: -14px;
}

.exxp-poster-play {
  width: 76px;
  height: 76px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--paper);
  transition: transform 0.15s ease, color 0.15s ease;
}

.exxp-poster-play:hover {
  transform: scale(1.06);
  color: var(--gold-bright);
}

.exxp-poster-play svg { width: 26px; height: 26px; margin-left: 3px; }

/* --- Top scrim + title --------------------------------------------------- */

.exxp-top {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 2;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 22px 60px;
  background: linear-gradient(to bottom, rgba(0, 0, 0, 0.75), transparent);
  opacity: 0;
  transform: translateY(-6px);
  transition: opacity 0.3s ease, transform 0.3s ease;
  pointer-events: none;
}

.exxp.controls-visible .exxp-top,
.exxp.paused .exxp-top {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.exxp-top-text { min-width: 0; }

.exxp-title {
  font-family: "Fraunces", serif;
  font-weight: 600;
  font-size: 17px;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 60vw;
}

.exxp-subtitle {
  font-size: 12.5px;
  color: var(--dim);
  margin-top: 2px;
}

.exxp-close {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--paper);
  background: transparent;
  border: none;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.exxp-close:hover { background: rgba(255, 255, 255, 0.1); color: var(--gold-bright); }
.exxp-close svg { width: 16px; height: 16px; }

/* --- Tap zones (double-tap / double-click to seek) ----------------------- */

.exxp-tapzone {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 50%;
  z-index: 1;
  cursor: pointer;
}

.exxp-tapzone.left { left: 0; }
.exxp-tapzone.right { right: 0; }

.exxp-bounce {
  position: absolute;
  top: 50%;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  transform: translate(-50%, -50%) scale(0.7);
  opacity: 0;
  pointer-events: none;
}

.exxp-bounce.left { left: 20%; }
.exxp-bounce.right { left: 80%; }

.exxp-bounce.show {
  animation: exxp-bounce-pop 0.55s ease;
}

@keyframes exxp-bounce-pop {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.7); }
  25% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  75% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(1); }
}

.exxp-bounce-ring {
  width: 56px;
  height: 56px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--paper);
}

.exxp-bounce-ring svg { width: 22px; height: 22px; }
.exxp-bounce-label { font-size: 11.5px; color: var(--paper); background: rgba(0,0,0,0.45); padding: 2px 8px; border-radius: 999px; }

/* --- Center transport (skip back / big play / skip forward) ------------- */

.exxp-center {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 48px;
  opacity: 0;
  transition: opacity 0.25s ease;
  pointer-events: none;
}

.exxp.controls-visible .exxp-center,
.exxp.paused .exxp-center {
  opacity: 1;
  pointer-events: auto;
}

.exxp.buffering .exxp-center { opacity: 0; pointer-events: none; }

.exxp-center-skip {
  width: 52px;
  height: 52px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--paper);
  background: rgba(0, 0, 0, 0.3);
  border: none;
  cursor: pointer;
  transition: transform 0.15s ease, color 0.15s ease, background 0.15s ease;
}

.exxp-center-skip:hover { transform: scale(1.08); color: var(--gold-bright); background: rgba(0, 0, 0, 0.45); }
.exxp-center-skip svg { width: 22px; height: 22px; }

.exxp-center-play {
  width: 82px;
  height: 82px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--paper);
  background: rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(20px) saturate(160%);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
  border: none;
  cursor: pointer;
  transition: transform 0.15s ease, color 0.15s ease;
}

.exxp-center-play:hover { transform: scale(1.05); color: var(--gold-bright); }
.exxp-center-play svg { width: 28px; height: 28px; }
.exxp-center-play .exxp-icon-play { margin-left: 4px; }

/* Only the paused big-play button gets the signature animated ring —
   the one bold flourish in the whole control set. */
.exxp.paused .exxp-center-play { display: flex; }
.exxp:not(.paused) .exxp-center-play { display: none; }

/* Tap-to-toggle-play flash feedback, centered wherever tapped */
.exxp-flash {
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 2;
  width: 84px;
  height: 84px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--paper);
  transform: translate(-50%, -50%) scale(0.6);
  opacity: 0;
  pointer-events: none;
}

.exxp-flash svg { width: 30px; height: 30px; }

.exxp-flash.show { animation: exxp-flash-pop 0.5s ease; }

@keyframes exxp-flash-pop {
  0% { transform: translate(-50%, -50%) scale(0.6); opacity: 0.9; }
  100% { transform: translate(-50%, -50%) scale(1.35); opacity: 0; }
}

/* --- Buffering spinner ---------------------------------------------------- */

.exxp-spinner {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease 0.15s;
}

.exxp.buffering .exxp-spinner { opacity: 1; }

.exxp-spinner-ring {
  width: 44px;
  height: 44px;
  border-radius: 999px;
  border: 3px solid rgba(255, 255, 255, 0.18);
  border-top-color: var(--gold);
  animation: exxp-spin 0.8s linear infinite;
}

@keyframes exxp-spin { to { transform: rotate(360deg); } }

/* --- Bottom control bar --------------------------------------------------- */

.exxp-controls {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 3;
  padding: 14px 18px 12px;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.85), rgba(0, 0, 0, 0));
  opacity: 1;
  transform: translateY(0);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.exxp:not(.controls-visible):not(.paused) .exxp-controls {
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
}

/* Progress bar */

.exxp-progress-wrap {
  position: relative;
  height: 18px;
  display: flex;
  align-items: center;
  cursor: pointer;
  margin-bottom: 2px;
  touch-action: none;
}

.exxp-progress-track {
  position: relative;
  width: 100%;
  height: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.22);
  transition: height 0.12s ease;
}

.exxp-progress-wrap:hover .exxp-progress-track,
.exxp-progress-wrap.scrubbing .exxp-progress-track {
  height: 6px;
}

.exxp-progress-buffered {
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.34);
}

.exxp-progress-fill {
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--wine), var(--gold));
}

.exxp-progress-knob {
  position: absolute;
  top: 50%;
  left: 0%;
  width: 13px;
  height: 13px;
  margin-left: -6.5px;
  border-radius: 999px;
  background: var(--gold-bright);
  box-shadow: 0 0 0 4px rgba(232, 193, 77, 0.22);
  transform: translateY(-50%) scale(0);
  transition: transform 0.12s ease;
}

.exxp-progress-wrap:hover .exxp-progress-knob,
.exxp-progress-wrap.scrubbing .exxp-progress-knob {
  transform: translateY(-50%) scale(1);
}

.exxp-progress-tooltip {
  position: absolute;
  bottom: 20px;
  left: 0%;
  transform: translateX(-50%);
  padding: 4px 9px;
  border-radius: 6px;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  background: rgba(10, 8, 6, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.12);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
  white-space: nowrap;
}

.exxp-progress-wrap:hover .exxp-progress-tooltip,
.exxp-progress-wrap.scrubbing .exxp-progress-tooltip {
  opacity: 1;
}

/* Controls row */

.exxp-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-top: 8px;
}

.exxp-row-left,
.exxp-row-right {
  display: flex;
  align-items: center;
  gap: 2px;
  min-width: 0;
}

.exxp-btn {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--paper);
  background: transparent;
  border: none;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.exxp-btn:hover { background: rgba(255, 255, 255, 0.1); color: var(--gold-bright); }
.exxp-btn:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.exxp-btn svg { width: 18px; height: 18px; }

.exxp-time {
  font-size: 12.5px;
  color: var(--paper);
  opacity: 0.88;
  font-variant-numeric: tabular-nums;
  margin-left: 6px;
  white-space: nowrap;
}

.exxp-time .exxp-time-sep { opacity: 0.5; margin: 0 3px; }

/* Volume */

.exxp-volume {
  display: flex;
  align-items: center;
}

.exxp-volume-slider-wrap {
  width: 0;
  overflow: hidden;
  transition: width 0.2s ease;
}

.exxp-volume:hover .exxp-volume-slider-wrap,
.exxp-volume.active .exxp-volume-slider-wrap {
  width: 76px;
}

.exxp-volume-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 68px;
  height: 4px;
  margin-left: 6px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--gold-bright) 0%, var(--gold-bright) 100%, rgba(255,255,255,0.22) 100%);
  outline: none;
  cursor: pointer;
}

.exxp-volume-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 11px;
  height: 11px;
  border-radius: 999px;
  background: var(--gold-bright);
  box-shadow: 0 0 0 3px rgba(232, 193, 77, 0.2);
  cursor: pointer;
}

.exxp-volume-slider::-moz-range-thumb {
  width: 11px;
  height: 11px;
  border: none;
  border-radius: 999px;
  background: var(--gold-bright);
  cursor: pointer;
}

.exxp-volume-slider::-moz-range-track {
  height: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.22);
}

/* Popover menus (speed, captions) */

.exxp-menu-wrap { position: relative; flex-shrink: 0; }

.exxp-menu {
  position: absolute;
  bottom: calc(100% + 12px);
  right: 0;
  z-index: 4;
  min-width: 132px;
  border-radius: 12px;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 1px;
  opacity: 0;
  transform: translateY(6px) scale(0.98);
  pointer-events: none;
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.exxp-menu.open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.exxp-menu-item {
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--paper);
  background: none;
  border: none;
  font-family: "Inter", sans-serif;
  text-align: left;
  white-space: nowrap;
}

.exxp-menu-item:hover { background: rgba(255, 255, 255, 0.08); }
.exxp-menu-item.active { color: var(--gold-bright); font-weight: 600; }

.exxp-speed-btn { width: auto; padding: 0 8px; font-size: 12.5px; font-weight: 600; gap: 2px; }
.exxp-btn.exxp-cc-active { color: var(--gold-bright); background: rgba(255, 255, 255, 0.08); }

/* --- Error state ----------------------------------------------------------- */

.exxp-error {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--ink);
}

.exxp-error[hidden] { display: none; }

.exxp-error-card {
  max-width: 320px;
  text-align: center;
  padding: 26px 28px;
  border-radius: 16px;
}

.exxp-error-title {
  font-family: "Fraunces", serif;
  font-weight: 600;
  font-size: 18px;
}

.exxp-error-msg {
  font-size: 13.5px;
  color: var(--dim);
  margin-top: 6px;
  line-height: 1.5;
}

.exxp-retry-btn {
  margin-top: 16px;
  padding: 10px 24px;
  border-radius: 999px;
  border: none;
  background: var(--gold);
  color: var(--ink);
  font-weight: 600;
  font-size: 13.5px;
  font-family: "Inter", sans-serif;
  cursor: pointer;
  transition: background 0.15s ease;
}

.exxp-retry-btn:hover { background: var(--gold-bright); }

/* --- Focus / accessibility -------------------------------------------------- */

.exxp:focus-visible {
  box-shadow: 0 0 0 2px var(--gold);
}

@media (prefers-reduced-motion: reduce) {
  .exxp-border-glow::before,
  .exxp-spinner-ring,
  .exxp-bounce.show,
  .exxp-flash.show {
    animation: none !important;
  }
}

/* --- Mobile ------------------------------------------------------------------ */

@media (max-width: 640px) {
  .exxp-top { padding: 14px 14px 44px; }
  .exxp-title { font-size: 14.5px; max-width: 55vw; }
  .exxp-subtitle { font-size: 11.5px; }
  .exxp-center { gap: 30px; }
  .exxp-center-play { width: 66px; height: 66px; }
  .exxp-center-play svg { width: 22px; height: 22px; }
  .exxp-center-skip { width: 42px; height: 42px; }
  .exxp-center-skip svg { width: 18px; height: 18px; }
  .exxp-controls { padding: 10px 12px 10px; }
  .exxp-btn { width: 34px; height: 34px; }
  .exxp-time { font-size: 11.5px; }
  .exxp-volume-slider-wrap,
  .exxp-volume:hover .exxp-volume-slider-wrap { width: 0 !important; }
  .exxp-row { gap: 8px; }
  .exxp-poster-play { width: 64px; height: 64px; }
}

/* Skip-10 icon: circular arrow with a numeral overlaid via CSS (kept out
   of the SVG path data so it always lands dead-center regardless of font) */

.exxp-skip-icon {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
}

.exxp-skip-num {
  position: absolute;
  font-size: 8px;
  font-weight: 700;
  font-family: "Inter", sans-serif;
  transform: translateY(1px);
  pointer-events: none;
}

.exxp-center-skip .exxp-skip-num { font-size: 10px; }

.exxp-icon-play { margin-left: 2px; }
