/*
 * Standalone player page (/player/{id}/), shown inside an iframe on the watch page.
 * Layers, bottom to top: main video and its controls, pre-roll ad stage, promo overlay.
 */

html,
body {
  height: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden;
  background: #000;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
}

[hidden] {
  display: none !important;
}

button,
input {
  font-family: inherit;
}

.vcp {
  position: fixed;
  inset: 0;
  outline: 0;
  color: #fff;
  /* Two quick taps are the player's own gesture, not the browser's zoom. */
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
}

.vcp-missing {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  color: #ddd;
  font-size: 15px;
  text-align: center;
}

/* ---------- Main video ---------- */

.vcp-main {
  position: fixed;
  inset: 0;
}

.vcp-video {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 100%;
  max-width: 100%;
  height: 100%;
  max-height: 100%;
  background: #000;
  object-fit: contain;
  transform: translate(-50%, -50%);
}

.vcp-embed,
.vcp-embed iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

.vcp.is-idle[data-state="playing"] {
  cursor: none;
}

/* Subtitles step up while the control bar is on screen (Chrome and Safari; elsewhere they stay put). */
.vcp-video::-webkit-media-text-track-container {
  transition: transform 0.25s;
}

.vcp:not(.is-idle, [data-state="idle"]) .vcp-video::-webkit-media-text-track-container {
  transform: translateY(-64px);
}

/* ---------- Buttons and icons ---------- */

.vcp-btn {
  display: grid;
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  padding: 0;
  place-items: center;
  border: 0;
  background: none;
  color: rgb(255 255 255 / 80%);
  cursor: pointer;
}

.vcp-btn:hover,
.vcp-btn:focus-visible {
  color: #fff;
}

.vcp-btn:focus-visible,
.vcp-volume:focus-visible {
  outline: 2px solid rgb(255 255 255 / 70%);
  outline-offset: -4px;
}

/* The rail shows focus on its knob; a box around the whole bar would cover the picture. */
.vcp-rail:focus-visible {
  outline: 0;
}

.vcp-rail:focus-visible .vcp-rail__knob {
  box-shadow: 0 0 0 3px rgb(255 255 255 / 35%);
}

.vcp-btn svg {
  display: block;
  width: 24px;
  height: 24px;
  fill: currentColor;
}

/* A button carries every icon it can show; the player state picks one. */
.vcp-btn svg[data-icon="pause"],
.vcp-btn svg[data-icon="replay"],
.vcp-btn svg[data-icon="muted"],
.vcp-btn svg[data-icon="shrink"],
.vcp[data-state="playing"] [data-vcp="toggle"] svg[data-icon="play"],
.vcp[data-state="complete"] [data-vcp="toggle"] svg[data-icon="play"],
.vcp.is-muted [data-vcp="mute"] svg[data-icon="volume"],
.vcp.is-fullscreen [data-vcp="fullscreen"] svg[data-icon="fullscreen"] {
  display: none;
}

.vcp[data-state="playing"] [data-vcp="toggle"] svg[data-icon="pause"],
.vcp[data-state="complete"] [data-vcp="toggle"] svg[data-icon="replay"],
.vcp.is-muted [data-vcp="mute"] svg[data-icon="muted"],
.vcp.is-fullscreen [data-vcp="fullscreen"] svg[data-icon="shrink"] {
  display: block;
}

/* ---------- Centre display ---------- */

.vcp-display {
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 28px;
  pointer-events: none;
  transform: translate(-50%, -50%);
  transition: opacity 0.25s;
}

.vcp-display .vcp-btn {
  width: auto;
  height: auto;
  color: #fff;
  filter: drop-shadow(0 0 6px rgb(0 0 0 / 60%));
  pointer-events: auto;
}

.vcp-display__play svg {
  width: 77px;
  height: 77px;
}

.vcp-display__side svg {
  width: 36px;
  height: 36px;
}

.vcp-display .vcp-btn:hover {
  transform: scale(1.08);
}

/* Mouse: icons only while stopped. Touch: icons whenever the controls are up. */
.vcp[data-state="playing"]:not(.is-touch) .vcp-display,
.vcp.is-touch.is-idle[data-state="playing"] .vcp-display,
.vcp[data-state="error"] .vcp-display {
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
}

.vcp[data-state="idle"] .vcp-display__side,
.vcp.is-live .vcp-display__side,
.vcp.is-buffering .vcp-display__play {
  visibility: hidden;
}

.vcp-spinner {
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 11;
  display: none;
  width: 56px;
  height: 56px;
  margin: -31px 0 0 -31px;
  border: 3px solid rgb(255 255 255 / 25%);
  border-top-color: #fff;
  border-radius: 50%;
  animation: vcp-spin 0.9s linear infinite;
  pointer-events: none;
}

.vcp.is-buffering:not([data-state="error"]) .vcp-spinner {
  display: block;
}

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

.vcp-error {
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 12;
  width: min(86%, 420px);
  padding: 18px 20px;
  border-radius: 6px;
  background: rgb(20 20 20 / 92%);
  font-size: 14px;
  line-height: 1.6;
  text-align: center;
  transform: translate(-50%, -50%);
}

.vcp-error p {
  margin: 0 0 12px;
}

.vcp-error__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

.vcp-error__retry,
.vcp-error__next {
  padding: 8px 22px;
  border: 1px solid #fff;
  border-radius: 4px;
  background: #fff;
  color: #000;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}

.vcp-error__next {
  background: none;
  color: #fff;
}

.vcp-error__retry:focus-visible,
.vcp-error__next:focus-visible {
  outline: 2px solid rgb(255 255 255 / 70%);
  outline-offset: 2px;
}

/* Small print for the person who gets the problem report. */
.vcp-error__code {
  display: block;
  margin-top: 10px;
  color: rgb(255 255 255 / 45%);
  font-size: 11px;
  -webkit-user-select: text;
  user-select: text;
}

.vcp-error__code:empty {
  display: none;
}

/* ---------- Messages in the picture ---------- */

/* What a key press or a double tap just did. */
.vcp-osd {
  position: absolute;
  top: 20%;
  left: 50%;
  z-index: 13;
  padding: 8px 14px;
  border-radius: 20px;
  background: rgb(20 20 20 / 78%);
  font-size: 15px;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  pointer-events: none;
  transform: translate(-50%, -50%);
  white-space: nowrap;
}

.vcp-osd[data-side="left"] {
  top: 50%;
  left: 18%;
}

.vcp-osd[data-side="right"] {
  top: 50%;
  left: 82%;
}

/* Something the viewer should know and does not have to act on. */
.vcp-notice {
  position: absolute;
  bottom: 72px;
  left: 12px;
  z-index: 21;
  display: flex;
  max-width: calc(100% - 24px);
  box-sizing: border-box;
  align-items: center;
  gap: 10px;
  padding: 7px 12px;
  border-radius: 4px;
  background: rgb(20 20 20 / 88%);
  font-size: 13px;
  line-height: 1.4;
}

.vcp[data-state="error"] .vcp-osd,
.vcp[data-state="error"] .vcp-notice {
  display: none;
}

/* ---------- Control bar ---------- */

.vcp-controls {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 20;
  padding: 0 8px;
  transition: opacity 0.25s;
}

.vcp-controls::before {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: -1;
  height: 140px;
  background: linear-gradient(180deg, transparent, rgb(0 0 0 / 55%) 62%, rgb(0 0 0 / 82%));
  content: "";
  pointer-events: none;
}

/* Bright scenes would otherwise swallow the white icons. */
.vcp-bar .vcp-btn svg {
  filter: drop-shadow(0 0 2px rgb(0 0 0 / 70%));
}

.vcp[data-state="idle"] .vcp-controls,
.vcp[data-state="error"] .vcp-controls,
.vcp.is-idle[data-state="playing"] .vcp-controls {
  opacity: 0;
  pointer-events: none;
}

.vcp-rail {
  position: relative;
  height: 18px;
  margin: 0 8px;
  cursor: pointer;
  touch-action: none;
}

.vcp-rail::before,
.vcp-rail__buffer,
.vcp-rail__progress {
  position: absolute;
  top: 7px;
  left: 0;
  height: 4px;
  border-radius: 2px;
}

.vcp-rail::before {
  right: 0;
  background: rgb(255 255 255 / 30%);
  content: "";
}

.vcp-rail__buffer {
  width: 0;
  background: rgb(255 255 255 / 35%);
}

.vcp-rail__progress {
  width: 0;
  background: #f2f2f2;
}

.vcp-rail__knob {
  position: absolute;
  top: 3px;
  left: 0;
  width: 12px;
  height: 12px;
  margin-left: -6px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 4px rgb(0 0 0 / 50%);
  opacity: 0;
  transition: opacity 0.15s;
}

.vcp-rail:hover .vcp-rail__knob,
.vcp-rail:focus-visible .vcp-rail__knob,
.vcp-rail.is-dragging .vcp-rail__knob,
.vcp.is-touch .vcp-rail__knob {
  opacity: 1;
}

.vcp-rail__tip {
  position: absolute;
  bottom: 22px;
  padding: 3px 7px;
  border-radius: 3px;
  background: rgb(20 20 20 / 90%);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  pointer-events: none;
  transform: translateX(-50%);
  white-space: nowrap;
}

.vcp.is-live .vcp-rail {
  visibility: hidden;
}

.vcp.is-live .vcp-bar [data-vcp="seek"] {
  display: none;
}

.vcp-bar {
  display: flex;
  align-items: center;
  height: 44px;
}

.vcp-bar__space {
  flex: 1 1 auto;
}

.vcp-time {
  flex: 0 0 auto;
  padding: 0 8px;
  color: rgb(255 255 255 / 90%);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 0 3px rgb(0 0 0 / 80%);
  white-space: nowrap;
}

.vcp-volume {
  flex: 0 0 auto;
  width: 0;
  height: 18px;
  margin: 0;
  background: none;
  opacity: 0;
  cursor: pointer;
  transition: width 0.15s, opacity 0.15s;
  -webkit-appearance: none;
  appearance: none;
}

.vcp-bar:hover .vcp-volume,
.vcp-volume:focus-visible {
  width: 70px;
  margin-right: 6px;
  opacity: 1;
}

.vcp-volume::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 2px;
  background: rgb(255 255 255 / 35%);
}

.vcp-volume::-moz-range-track {
  height: 4px;
  border-radius: 2px;
  background: rgb(255 255 255 / 35%);
}

.vcp-volume::-moz-range-progress {
  height: 4px;
  border-radius: 2px;
  background: #fff;
}

.vcp-volume::-webkit-slider-thumb {
  width: 12px;
  height: 12px;
  margin-top: -4px;
  border: 0;
  border-radius: 50%;
  background: #fff;
  -webkit-appearance: none;
}

.vcp-volume::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border: 0;
  border-radius: 50%;
  background: #fff;
}

/* Phones set the volume with their own buttons. */
.vcp.is-touch .vcp-volume {
  display: none;
}

/* ---------- Settings menu ---------- */

.vcp-menu {
  position: absolute;
  right: 12px;
  bottom: 68px;
  z-index: 30;
  display: flex;
  flex-direction: column;
  min-width: 190px;
  max-width: calc(100% - 24px);
  max-height: calc(100% - 84px);
  overflow: hidden;
  border-radius: 4px;
  background: rgb(33 33 33 / 94%);
  font-size: 14px;
}

/* Up to four tabs; a narrow frame scrolls them sideways instead of squeezing the words. */
.vcp-menu__tabs {
  display: flex;
  flex: 0 0 auto;
  overflow-x: auto;
  border-bottom: 1px solid rgb(255 255 255 / 15%);
  scrollbar-width: none;
}

.vcp-menu__tabs::-webkit-scrollbar {
  display: none;
}

.vcp-menu__tab {
  flex: 1 0 auto;
  padding: 10px 12px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: none;
  color: rgb(255 255 255 / 65%);
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
}

.vcp-menu__tab[aria-selected="true"] {
  border-bottom-color: #fff;
  color: #fff;
}

.vcp-menu__tab:focus-visible {
  background: rgb(255 255 255 / 12%);
  color: #fff;
  outline: 0;
}

.vcp-menu__list {
  flex: 1 1 auto;
  padding: 4px 0;
  overflow-y: auto;
}

.vcp-menu__item {
  display: block;
  width: 100%;
  padding: 8px 16px 8px 34px;
  border: 0;
  background: none;
  color: rgb(255 255 255 / 80%);
  font-size: 14px;
  text-align: left;
  cursor: pointer;
}

.vcp-menu__item:hover,
.vcp-menu__item:focus-visible {
  background: rgb(255 255 255 / 12%);
  color: #fff;
  outline: 0;
}

.vcp-menu__item[aria-checked="true"] {
  background: no-repeat 12px center / 14px url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='%23fff' d='M9 16.17 4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z'/%3E%3C/svg%3E");
  color: #fff;
  font-weight: 700;
}

/* ---------- Corner logo ---------- */

.vcp-logo {
  position: absolute;
  top: 0;
  z-index: 15;
  display: block;
  width: clamp(78px, 13.8vw, 156px);
  height: clamp(78px, 13.8vw, 156px);
  margin: 8px;
  filter: drop-shadow(0 1px 3px rgb(0 0 0 / 50%));
  opacity: 0.92;
}

.vcp-logo:hover {
  opacity: 1;
}

.vcp-logo--top-left {
  left: 0;
}

.vcp-logo--top-right {
  right: 0;
}

.vcp-logo img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: left top;
}

.vcp-logo--top-right img {
  object-position: right top;
}

@media (width >= 768px) {
  .vcp-logo {
    width: clamp(86px, 10vw, 115px);
    height: clamp(86px, 10vw, 115px);
  }
}

@media (width >= 1200px) {
  .vcp-logo {
    width: clamp(101px, 7.2vw, 137px);
    height: clamp(101px, 7.2vw, 137px);
  }
}

@media (width <= 768px) {
  .vcp-logo {
    margin: 4px;
  }
}

@media (width <= 380px) {
  .vcp-logo {
    width: 62px;
    height: 62px;
    margin: 2px;
  }
}

@media (orientation: landscape) and (height <= 500px) {
  .vcp-logo {
    width: clamp(62px, 10.3vh, 86px);
    height: clamp(62px, 10.3vh, 86px);
  }
}

/* ---------- Pre-roll ad stage ---------- */

.vcp-ad {
  position: fixed;
  inset: 0;
  z-index: 8888;
  background: #000;
}

.vcp-ad__video {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 100vw;
  max-height: 100vh;
  aspect-ratio: 16 / 9;
  background: #000;
  cursor: pointer;
  object-fit: contain;
  transform: translate(-50%, -50%);
}

.vcp-ad__play {
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 9001;
  display: flex;
  width: 80px;
  height: 80px;
  padding: 0;
  align-items: center;
  justify-content: center;
  border: 3px solid rgb(255 255 255 / 80%);
  border-radius: 50%;
  background: rgb(0 0 0 / 70%);
  cursor: pointer;
  transform: translate(-50%, -50%);
  transition: all 0.3s;
}

.vcp-ad__play:hover {
  background: rgb(0 0 0 / 90%);
  transform: translate(-50%, -50%) scale(1.08);
}

.vcp-ad__play svg {
  width: 40px;
  height: 40px;
  fill: #fff;
}

.vcp-ad__loading {
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 9002;
  display: none;
  color: #fff;
  font-size: 14px;
  text-shadow: 0 1px 3px #000;
  transform: translate(-50%, -50%);
}

.vcp-ad__loading.is-active {
  display: block;
}

.vcp-ad__badge {
  position: absolute;
  bottom: 12px;
  left: 12px;
  z-index: 9000;
  padding: 4px 9px;
  border-radius: 4px;
  background: rgb(0 0 0 / 60%);
  color: rgb(255 255 255 / 90%);
  font-size: 12px;
}

.vcp-ad__skip,
.vcp-ad__cta {
  position: absolute;
  z-index: 9000;
  padding: 12px 18px;
  border: none;
  border-radius: 6px;
  box-shadow: 0 4px 16px rgb(0 0 0 / 30%), 0 2px 8px rgb(0 0 0 / 20%);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
}

.vcp-ad__skip {
  right: 0;
  bottom: 15%;
  border: 1px solid #049;
  background: #06c;
}

.vcp-ad__skip:hover:not(:disabled) {
  background: #07d;
}

.vcp-ad__skip:disabled {
  background: rgb(0 0 0 / 60%);
  box-shadow: none;
  cursor: not-allowed;
  opacity: 0.6;
}

.vcp-ad__cta {
  top: 10%;
  right: 8px;
  max-width: 70%;
  overflow: hidden;
  border: 1px solid rgb(255 215 0 / 50%);
  background: linear-gradient(135deg, gold, orange, #ff8c00);
  color: #000;
  text-decoration: none;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.vcp-ad__cta:hover {
  box-shadow: 0 6px 20px rgb(255 215 0 / 60%), 0 3px 10px rgb(255 140 0 / 40%);
  transform: translateY(-1px);
}

/* ---------- Promo overlay ---------- */

.vcp-promo {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  box-sizing: border-box;
  padding: 20px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgb(0 0 0 / 75%);
}

.vcp-promo__items {
  display: flex;
  max-width: 90%;
  padding: 10px;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border-radius: 5px;
  line-height: 0;
}

.vcp-promo__items a {
  display: block;
  max-width: calc(50% - 5px);
  flex: 0 auto;
  line-height: 0;
}

.vcp-promo__items a.solo {
  max-width: 100%;
}

.vcp-promo__items img {
  display: block;
  width: 100%;
  height: auto;
  max-height: calc(100vh - 120px);
}

.vcp-promo__close {
  margin-top: 15px;
  padding: 8px 25px;
  border: 2px solid #fff;
  border-radius: 20px;
  background: red;
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
}

/* ---------- Narrow frames ---------- */

@media (width <= 560px) {
  .vcp-controls {
    padding: 0 2px;
  }

  .vcp-btn {
    width: 38px;
    height: 40px;
  }

  .vcp-bar {
    height: 40px;
  }

  .vcp-time {
    padding: 0 4px;
    font-size: 12px;
  }

  .vcp-display {
    gap: 22px;
  }

  .vcp-display__play svg {
    width: 60px;
    height: 60px;
  }

  .vcp-display__side svg {
    width: 30px;
    height: 30px;
  }

  .vcp-spinner {
    width: 44px;
    height: 44px;
    margin: -25px 0 0 -25px;
  }

  /* The centre display already offers the ten-second jump here. */
  .vcp-btn--ten,
  .vcp-btn--pip {
    display: none;
  }

  .vcp-menu {
    right: 6px;
    bottom: 60px;
    max-width: calc(100% - 12px);
    max-height: calc(100% - 66px);
  }

  .vcp-notice {
    bottom: 64px;
    left: 6px;
    max-width: calc(100% - 12px);
  }

  .vcp-osd {
    padding: 6px 12px;
    font-size: 13px;
  }

  .vcp-ad__play {
    width: 64px;
    height: 64px;
  }

  .vcp-ad__play svg {
    width: 32px;
    height: 32px;
  }

  .vcp-ad__skip,
  .vcp-ad__cta {
    padding: 9px 13px;
    font-size: 13px;
  }
}

@media (width <= 330px) {
  .vcp-btn--wide {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .vcp-spinner {
    animation-duration: 2.4s;
  }
}
