/* assets/hub-player.css - the look of the player's drawn half (#48).

   Every colour, radius, easing and duration here is a custom property from
   assets/hub-tokens.css (#134). Nothing in this file types a value of its own,
   for the same reason nothing in the HTML types a figure: the token file is
   the site's own stylesheet read back, and a hex code pasted here is a copy
   that drifts.

   WHY EVERY CLASS BEGINS hubp-. The token file also ships component classes -
   .btn, .chip, .badge, .tile, .runtime - and assets/site.css, which every
   /watch page already loads, has its own .btn and .runtime meaning something
   else. Linking the token file on a built page without settling that clash is
   #160. This file touches none of those five names, so it is safe to load
   beside site.css today: only the :root custom properties are shared, and
   those do not collide.

   The fallbacks in each var() are not decoration either. A surface may load
   this file before the token file resolves, or an embed may be dropped on a
   page that has neither, and a player drawn in invisible text is worse than a
   player drawn in the wrong green. */

/* ── Shared ───────────────────────────────────────────────────────────────── */

.hubp-menu,
.hubp-cast,
.hubp-scrub {
  font-family: var(--body, system-ui, sans-serif);
  color: var(--bone, #f5f3ee);
}

.hubp-menu [hidden],
.hubp-cast[hidden],
.hubp-menu[hidden] {
  display: none;
}

/* The focus ring is the token file's own, shared with the television, because
   a keyboard viewer on the site and a remote on a sofa are the same problem. */
.hubp-menu-button:focus-visible,
.hubp-menu-choice:focus-visible,
.hubp-cast:focus-visible,
.hubp-scrub-track:focus-visible {
  outline: 3px solid var(--leaf, #A8F341);
  outline-offset: 3px;
}

/* ── The menus ────────────────────────────────────────────────────────────── */

.hubp-menu {
  position: relative;
  display: inline-block;
}

.hubp-menu-button,
.hubp-cast {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 16px;
  border: 0;
  border-radius: var(--r-pill, 999px);
  background: var(--card, rgba(2, 7, 24, .55));
  box-shadow: inset 0 0 0 1px var(--line-2, rgba(255, 255, 255, .14));
  color: inherit;
  font-family: var(--display, system-ui, sans-serif);
  font-weight: 700;
  font-size: 13px;
  letter-spacing: .04em;
  cursor: pointer;
  transition: background var(--dur-quick, .2s) var(--ease-out, ease),
              box-shadow var(--dur-quick, .2s) var(--ease-out, ease);
}

.hubp-menu-button:hover,
.hubp-cast:hover {
  background: var(--ink-40, #1a1d27);
  box-shadow: inset 0 0 0 1px var(--line-leaf, rgba(168, 243, 65, .22));
}

.hubp-menu-button[aria-expanded="true"] {
  box-shadow: inset 0 0 0 1px var(--leaf, #A8F341);
}

/* The list rises from the button rather than pushing the controls around:
   a control bar that changes height when a menu opens moves the scrub bar
   under the viewer's pointer. */
.hubp-menu-list {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  z-index: 2;
  min-width: 180px;
  max-height: 46vh;
  overflow-y: auto;
  margin: 0;
  padding: 6px;
  list-style: none;
  border-radius: var(--r-md, 14px);
  background: var(--ink-60, #11141b);
  box-shadow: inset 0 0 0 1px var(--line, rgba(255, 255, 255, .08)),
              0 24px 60px rgba(0, 0, 0, .6);
}

.hubp-menu-choice {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 12px;
  border: 0;
  border-radius: var(--r-sm, 8px);
  background: transparent;
  color: var(--mist, #b9bcc7);
  font: inherit;
  font-size: 14px;
  text-align: left;
  cursor: pointer;
  transition: background var(--dur-instant, .15s) var(--ease-out, ease),
              color var(--dur-instant, .15s) var(--ease-out, ease);
}

.hubp-menu-choice:hover {
  background: var(--ink-40, #1a1d27);
  color: var(--bone, #f5f3ee);
}

/* The chosen row is marked with a tick AND with colour. Colour alone fails
   anyone who cannot see the difference, and this is the control that decides
   which language somebody watches in. */
.hubp-menu-choice::before {
  content: "";
  flex: 0 0 auto;
  width: 14px;
  text-align: center;
  color: var(--leaf, #A8F341);
}

.hubp-menu-choice[aria-checked="true"] {
  color: var(--bone, #f5f3ee);
}

.hubp-menu-choice[aria-checked="true"]::before {
  content: "\2713";
}

/* ── One CC panel for subtitles and audio (EF354 p4, #1071) ───────────────── */

/* It opens from the right-hand end of the bar, so it rises to the left
   rather than off the edge of the frame. */
.hubp-menu-languages .hubp-panel {
  left: auto;
  right: 0;
  min-width: 220px;
}

.hubp-panel-group + .hubp-panel-group {
  margin-top: 6px;
  padding-top: 6px;
  box-shadow: inset 0 1px 0 var(--line, rgba(255, 255, 255, .08));
}

.hubp-panel-heading {
  padding: 8px 12px 4px;
  font-family: var(--display, system-ui, sans-serif);
  font-weight: 700;
  font-size: 11px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--mist, #b9bcc7);
}

/* The design ticks on the right of the chosen row; the tick stays a glyph
   AND a colour, as above. */
.hubp-panel .hubp-menu-choice {
  flex-direction: row-reverse;
  justify-content: space-between;
}

.hubp-panel .hubp-menu-choice[aria-checked="true"] {
  background: var(--line-leaf, rgba(168, 243, 65, .12));
}

/* ── The cast button ──────────────────────────────────────────────────────── */

.hubp-cast[aria-pressed="true"] {
  background: rgba(168, 243, 65, .10);
  color: var(--leaf, #A8F341);
  box-shadow: inset 0 0 0 1px var(--leaf, #A8F341);
}

.hubp-cast[aria-busy="true"] {
  color: var(--mist, #b9bcc7);
  cursor: progress;
}

/* ── The scrub bar ────────────────────────────────────────────────────────── */

.hubp-scrub {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
}

.hubp-scrub-track {
  position: relative;
  flex: 1 1 auto;
  height: 6px;
  border-radius: var(--r-pill, 999px);
  background: var(--line-2, rgba(255, 255, 255, .14));
  cursor: pointer;
}

/* The hit area is taller than the bar is drawn. Six pixels is a fair line and
   an unfair target, and a viewer who misses the scrub bar seeks nowhere. */
.hubp-scrub-track::before {
  content: "";
  position: absolute;
  inset: -11px 0;
}

.hubp-scrub-played {
  position: absolute;
  inset: 0 auto 0 0;
  border-radius: inherit;
  background: var(--leaf, #A8F341);
}

.hubp-scrub-marks {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

/* A mark is cut OUT of the bar rather than laid on top of it, so it reads the
   same over the played part and the unplayed part. */
.hubp-scrub-mark {
  position: absolute;
  top: -1px;
  width: 2px;
  height: 8px;
  margin-left: -1px;
  border-radius: 1px;
  background: var(--ink, #040506);
  opacity: .85;
}

.hubp-scrub-handle {
  position: absolute;
  top: 50%;
  width: 13px;
  height: 13px;
  margin: -6.5px 0 0 -6.5px;
  border-radius: 50%;
  background: var(--leaf, #A8F341);
  box-shadow: 0 2px 10px rgba(0, 0, 0, .55);
  pointer-events: none;
  transition: transform var(--dur-quick, .2s) var(--ease-out, ease);
}

/* Where a click would land (#1048, EF354 p4): above the pointer. The script
   sets `left` and the shift that keeps it inside the bar at either end. */
.hubp-scrub-hover {
  position: absolute;
  bottom: 18px;
  padding: 6px 10px;
  border-radius: 8px;
  background: var(--card, rgba(10, 14, 22, .92));
  box-shadow: inset 0 0 0 1px var(--line-2, rgba(255, 255, 255, .14));
  font-family: var(--display, system-ui, sans-serif);
  font-weight: 700;
  font-size: 12px;
  letter-spacing: .02em;
  color: var(--bone, #f1efe8);
  white-space: nowrap;
  pointer-events: none;
}

.hubp-scrub-hover[hidden] {
  display: none;
}

.hubp-scrub-track:hover .hubp-scrub-handle,
.hubp-scrub-track:focus-visible .hubp-scrub-handle {
  transform: scale(1.25);
}

.hubp-scrub-readout {
  flex: 0 0 auto;
  font-family: var(--display, system-ui, sans-serif);
  font-weight: 700;
  font-size: 12px;
  letter-spacing: .04em;
  color: var(--mist, #b9bcc7);
  font-feature-settings: "tnum";
  font-variant-numeric: tabular-nums;
}

/* Phones: the readout loses the total, which is the half a small screen can
   spare, and the targets grow. The token file's own phone breakpoint. */
@media (max-width: 560px) {
  .hubp-scrub { gap: 10px; }
  .hubp-scrub-track { height: 8px; }
  .hubp-menu-button, .hubp-cast { padding: 11px 16px; }
}

/* The site turns every animation and transition off under this query and the
   player does the same. A scrub handle that springs is a nuisance to anybody
   who asked for stillness. */
@media (prefers-reduced-motion: reduce) {
  .hubp-menu-button,
  .hubp-cast,
  .hubp-menu-choice,
  .hubp-scrub-handle,
  .hubp-play,
  .hubp-skip,
  .hubp-volume-button,
  .hubp-fullscreen,
  .hubp-pip,
  .hubp-share {
    transition: none;
  }
}

/* ── The transport controls (#163) ────────────────────────────────────────── */

.hubp-play,
.hubp-skip,
.hubp-volume,
.hubp-fullscreen,
.hubp-pip,
.hubp-share {
  font-family: var(--body, system-ui, sans-serif);
  color: var(--bone, #f5f3ee);
}

.hubp-fullscreen[hidden],
.hubp-pip[hidden],
.hubp-share[hidden] {
  display: none;
}

.hubp-play:focus-visible,
.hubp-skip:focus-visible,
.hubp-volume-button:focus-visible,
.hubp-volume-track:focus-visible,
.hubp-fullscreen:focus-visible,
.hubp-pip:focus-visible,
.hubp-share:focus-visible {
  outline: 3px solid var(--leaf, #A8F341);
  outline-offset: 3px;
}

.hubp-play,
.hubp-skip,
.hubp-volume-button,
.hubp-fullscreen,
.hubp-pip,
.hubp-share {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 0;
  cursor: pointer;
  background: transparent;
  color: inherit;
  font-family: var(--display, system-ui, sans-serif);
  font-weight: 700;
  font-size: 13px;
  letter-spacing: .04em;
  padding: 8px 12px;
  border-radius: var(--r-pill, 999px);
  transition: background var(--dur-quick, .2s) var(--ease-out, cubic-bezier(.22, .9, .3, 1));
}

.hubp-play:hover,
.hubp-skip:hover,
.hubp-volume-button:hover,
.hubp-fullscreen:hover,
.hubp-pip:hover,
.hubp-share:hover {
  background: var(--line, rgba(255, 255, 255, .08));
}

/* The one control that is always lit, because it is the one a viewer reaches
   for first and hunts for in a row of ghosts. */
.hubp-play[data-state="paused"],
.hubp-play[data-state="ended"] {
  color: var(--leaf, #A8F341);
}

.hubp-volume {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.hubp-volume-track {
  position: relative;
  width: 84px;
  height: 6px;
  border-radius: var(--r-pill, 999px);
  background: var(--line-2, rgba(255, 255, 255, .14));
  cursor: pointer;
}

/* The same hit area the scrub bar gives itself: six pixels is a line, not a
   target, and a pointer that misses reads as a dead control. */
.hubp-volume-track::before {
  content: "";
  position: absolute;
  inset: -11px 0;
}

.hubp-volume-level {
  position: absolute;
  inset: 0 auto 0 0;
  border-radius: inherit;
  background: var(--bone, #f5f3ee);
}

/* Muted is said in the word on the button and in the empty slider; the colour
   is the third telling and never the only one. */
.hubp-volume[data-muted="true"] .hubp-volume-level {
  background: var(--mist-2, #6f7689);
}

/* The slider is the mute button's detail, so on a phone the button stays and
   the slider goes: there is no pointer precision for an 84-pixel track, and
   the hardware keys do the job better. */
@media (max-width: 560px) {
  .hubp-volume-track { display: none; }
}

/* How much has loaded, behind the played range. Deliberately quiet: it is
   reassurance while something buffers, not a thing to read. */
.hubp-scrub-buffered {
  position: absolute;
  top: 0;
  bottom: 0;
  border-radius: inherit;
  background: var(--line-2, rgba(255, 255, 255, .14));
  filter: brightness(1.8);
}

/* The share button says what it did, and the sentence is announced by its own
   live region rather than by the button, so a screen reader is not told the
   resting label again when the word reverts. The region is read, not seen. */
.hubp-share[data-state="done"] {
  color: var(--leaf, #A8F341);
}

.hubp-share-said,
.hubp-share-field {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  border: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* ── The licence credit over the picture (#610, #613) ─────────────────────── */
/* A lower third inside the frame, never under the bar, so a partner's iframe
   keeps its size. Every line wraps and nothing is clipped or ellipsised: the
   wording is the licensor's and a cut line is a breach. It takes no pointer,
   so a click on the picture still reaches the film. */
.hubp-credit {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 2.5em 4% 4%;
  pointer-events: none;
  /* Dark enough under the words to read over a bright frame; the second
     declaration wins wherever color-mix is understood. */
  background: linear-gradient(to top, rgba(4, 5, 6, .88), rgba(4, 5, 6, .6) 65%, transparent);
  background: linear-gradient(to top,
    color-mix(in srgb, var(--ink, #040506) 88%, transparent),
    color-mix(in srgb, var(--ink, #040506) 60%, transparent) 65%, transparent);
  text-shadow: 0 1px 2px var(--ink, #040506);
  color: var(--bone, #f5f3ee);
  font-family: var(--body, system-ui, sans-serif);
  font-size: clamp(12px, 2.4vw, 20px);
  line-height: 1.35;
  overflow: visible;
  white-space: normal;
  overflow-wrap: anywhere;
}

.hubp-credit[hidden] {
  display: none;
}

.hubp-credit-line {
  margin: 0;
  max-width: 60ch;
}

.hubp-credit-line + .hubp-credit-line {
  margin-top: .3em;
}
