/* ================================================================== */
/* The control bar over the bottom of the watch page's picture.        */
/*                                                                      */
/* Loaded last on watch.html and the only file that styles .player-bar, */
/* so the look is decided in one place. It used to be spread across     */
/* watch.css, live-v2.css, experience.css, live-hud.css and glass.css,  */
/* each undoing part of the one before. live.css's page-wide button     */
/* rule exempts everything inside .player-bar for the same reason.      */
/* ================================================================== */

.player-frame { --player-accent: #3b6cf6; }

.player-bar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 48px;
  padding: 0 12px;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  gap: 4px;
  color: var(--ink);
  opacity: 0;
  transform: translateY(6px);
  pointer-events: none;
  transition: opacity .18s ease, transform .18s ease;
  /* Playback and room tools fade as one row. */
  z-index: 27;
}

/* The fade into the picture is twice the row's height and never a hit
   target: the video underneath keeps its taps and the row alone counts as
   "over the bar" for the auto-hide. */
.player-bar::before {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 96px;
  background: linear-gradient(to top, rgba(0, 0, 0, .82) 0, rgba(0, 0, 0, .5) 48px, rgba(0, 0, 0, 0));
  pointer-events: none;
  z-index: -1;
}

.player-bar.is-visible {
  opacity: 1;
  transform: none;
  pointer-events: auto;
}

/* Keyboard focus shows the bar without JS. Its own rule, not a comma in the
   one above: an engine without :has() would otherwise drop the whole rule and
   the bar would never appear at all. */
.player-bar:has(:focus-visible) {
  opacity: 1;
  transform: none;
  pointer-events: auto;
}

/* Room tools live in the playback row, without a separate floating frame.
   The ID also wins over the former desktop, phone and focus-mode anchors. */
body.hud-watch #player-bar .hud-utilities {
  position: relative !important; position-anchor: none !important;
  inset: auto !important; z-index: auto; flex: none; order: 0;
  width: auto !important; height: 36px !important; padding: 0 !important;
  gap: 2px !important; border: 0 !important; border-radius: 0 !important;
  background: transparent !important; box-shadow: none !important;
  transform: none !important; transition: none;
}
body.hud-watch #player-bar .hud-utilities > :not(.gl-wheel) { flex: none; }
body.hud-watch #player-bar .hud-utilities button:focus-visible { outline: 2px solid var(--player-accent); outline-offset: -2px; }
body.hud-watch #player-bar .hud-utilities .gl-wheel {
  left: auto !important; right: 0; top: auto; bottom: calc(100% + 12px);
  transform: translateY(6px);
}
body.hud-watch #player-bar .hud-utilities .gl-wheel.is-on { transform: none; }
body.hud-watch #player-bar .hud-utilities .gl-wheel[popover] {
  position: fixed; margin: 0 !important;
  inset: auto var(--emote-right) var(--emote-bottom) auto !important;
  color: var(--pa-ink);
}

/* ---- buttons ---- */

.player-bar .ctl {
  height: 34px;
  min-width: 34px;
  padding: 0 8px;
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
}
.player-bar .ctl svg { width: 20px; height: 20px; flex: none; }
.player-bar .ctl:hover { background: rgba(255, 255, 255, .12); }
.player-bar .ctl:focus-visible { outline: 2px solid var(--player-accent); outline-offset: -2px; }
.player-bar .ctl.wide { padding: 0 10px; }

.player-bar .spacer { flex: 1; }
.player-bar .stat { margin-right: 8px; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.player-bar .bar-sep { flex: none; width: 1px; height: 20px; margin: 0 6px; background: rgba(255, 255, 255, .18); }

/* ---- volume ---- */

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

.player-bar .volume-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 90px;
  height: 4px;
  margin: 0 10px 0 4px;
  border-radius: 2px;
  /* watch.js sets --fill to the current level so the track reads as a meter. */
  background: linear-gradient(to right, var(--player-accent) var(--fill, 100%), rgba(255, 255, 255, .28) var(--fill, 100%));
  cursor: pointer;
}
.player-bar .volume-slider::-webkit-slider-thumb { -webkit-appearance: none; width: 14px; height: 14px; border-radius: 50%; border: 0; background: #fff; }
.player-bar .volume-slider::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; border: 0; background: #fff; }
.player-bar .volume-slider::-moz-range-track { background: transparent; }
.player-bar .volume-slider:focus-visible { outline: 2px solid var(--player-accent); outline-offset: 4px; }

/* ---- the live badge ----
   Red and filled at the live edge, grey and hollow when behind it, so the
   click has an obvious purpose. watch.js toggles .at-live every second. */

/* The word is spelled LIVE in the markup: game-ui.css forbids text-transform,
   so the casing has to come from the source text. */
.player-bar .live-badge { font-size: 12px; font-weight: 700; letter-spacing: .04em; color: var(--muted); }
.player-bar .live-badge i { width: 8px; height: 8px; border-radius: 50%; border: 2px solid currentColor; box-sizing: border-box; }
.player-bar .live-badge.at-live { color: var(--ink); }
.player-bar .live-badge.at-live i { border-color: var(--live); background: var(--live); }

/* ---- menus ----
   Open upward, because a menu that dropped down would open off the end of
   the video. Positioned against their own wrapper, not the 96px bar. */

.player-bar .quality, .player-bar .settings { position: relative; }

.player-bar .quality-menu,
.player-bar .settings-menu {
  position: absolute;
  bottom: calc(100% + 10px);
  right: 0;
  z-index: 8;
  min-width: 170px;
  padding: 6px;
  border-radius: var(--r-md);
  background: rgba(10, 10, 12, .94);
  backdrop-filter: blur(14px);
  box-shadow: 0 10px 30px rgba(0, 0, 0, .5);
}
.player-bar .settings-menu { min-width: 210px; }

/* A long ladder of renditions must not run off the top of the picture. */
.player-bar .quality-menu,
.player-bar .settings-menu { max-height: min(240px, 60vh); overflow-y: auto; }

.player-bar .quality-menu button,
.player-bar .settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  padding: 9px 11px;
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
  box-sizing: border-box;
}
.player-bar .quality-menu button:hover, .player-bar .settings-row:hover { background: rgba(255, 255, 255, .1); }
.player-bar .quality-menu button.on { color: var(--player-accent); font-weight: 700; }
/* a row the markup has put away — the menu's own rules would draw it anyway */
.player-bar .settings-row[hidden] { display: none; }
.player-bar .settings-row:disabled { cursor: default; }
.player-bar .settings-row:disabled:hover { background: transparent; }
.player-bar .settings-row b { font-weight: 600; color: var(--muted); }
.player-bar .settings-row input { accent-color: var(--player-accent); margin: 0; }

/* What the choice actually costs, said plainly, because a viewer on a metered
   connection is choosing bandwidth rather than choosing prettiness. */
.player-bar .quality-menu i { font-style: normal; font-size: 11px; color: var(--muted); }
.player-bar .quality-menu button.on i { color: var(--player-accent); opacity: .8; }

/* Phones: a 16:9 frame at 375px is about 210px tall, so the row slims down
   and the things a thumb does not need (the slider: phones have volume keys;
   Clip; the hairlines) step aside so fullscreen stays reachable. */
@media (max-width: 900px) {
  .player-bar { padding: 0 6px; gap: 2px; }
  .player-bar::before { height: 72px; }
  .player-bar .ctl { min-width: 30px; height: 30px; padding: 0 6px; }
  .player-bar .volume-slider,
  .player-bar .bar-sep,
  .player-bar #clip { display: none; }
  body.hud-watch #player-bar .hud-utilities .gl-wheel { grid-template-columns: repeat(4, 38px); }
}
@media (max-width: 600px) {
  .player-bar .ctl { min-width: 28px; height: 40px; padding: 0 4px; }
  .player-bar .ctl.wide { padding: 0 4px; }
  .player-bar #theater { display: none; }
  body.hud-watch #player-bar .hud-utilities { height: 40px !important; }
  body.hud-watch #player-bar .hud-utilities > :not(.gl-wheel) { width: 30px !important; height: 40px !important; }
}

@media (prefers-reduced-motion: reduce) {
  .player-bar,
  .ix-watch-layout .gl-vote,
  .ix-watch-layout .hud-utilities { transition: none; }
}
