/* ============================================================
   NxtAtlas video player — see js/nx-player.js.

   Gold is the studio's own: --brass and --brass-lit on nxtatlas.com, the same
   values as the assistant's dark --accent pair. The bar is always dark glass
   because it always sits on a film, whatever the page's theme.

   Two identical copies, one per web root; scripts/protocol-contract.mjs keeps
   them identical.
   ============================================================ */

.nxp {
  --nxp-gold: var(--brass, #d1a05a);
  --nxp-gold-lit: var(--brass-lit, #e0b473);
  --nxp-ink: #14100a;
  --nxp-paper: #f6f0e6;
  --nxp-dim: rgba(246, 240, 230, 0.72);
  --nxp-glass: rgba(14, 12, 9, 0.62);
  --nxp-line: rgba(255, 255, 255, 0.10);
  --nxp-ease: cubic-bezier(0.22, 1, 0.36, 1);

  position: relative;
  display: block;
  background: #000;
  overflow: hidden;
  isolation: isolate;
  border-radius: inherit;
  color: var(--nxp-paper);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  line-height: 1;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  outline: none;
}
.nxp:focus-visible { box-shadow: inset 0 0 0 2px var(--nxp-gold-lit); }
.nxp > video { display: block; }
/* Until the clip says what size it is, hold the shape of a film instead of the
   browser's 2:1 default — that box was short enough for the bar to land on the
   play button. `auto` gives way to the real ratio as soon as it is known. */
.nxp > video { aspect-ratio: auto 16 / 9; }

/* ---------- full screen: the wrapper goes, the picture is letterboxed ----------
   Separate rules on purpose: a selector list holding a pseudo-class one browser
   does not know is dropped by that browser entirely. */
.nxp:fullscreen { width: 100vw; height: 100vh; border-radius: 0; background: #000; }
.nxp:-webkit-full-screen { width: 100vw; height: 100vh; border-radius: 0; background: #000; }
.nxp:fullscreen > video {
  position: absolute; inset: 0; width: 100%; height: 100%;
  max-width: none; max-height: none; object-fit: contain; background: #000;
}
.nxp:-webkit-full-screen > video {
  position: absolute; inset: 0; width: 100%; height: 100%;
  max-width: none; max-height: none; object-fit: contain; background: #000;
}
.nxp::backdrop { background: #000; }

/* ---------- overlay layers ---------- */
.nxp-ui { position: absolute; inset: 0; z-index: 1; }
.nxp-surface { position: absolute; inset: 0; cursor: pointer; }
.nxp--idle .nxp-surface { cursor: none; }

.nxp-shade {
  position: absolute; left: 0; right: 0; bottom: 0; height: 46%;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 0.55) 100%);
  pointer-events: none;
  transition: opacity 0.35s var(--nxp-ease);
}

/* The big button: gold, centred, only while the film is still. */
.nxp-big {
  position: absolute; left: 50%; top: 50%;
  width: 74px; height: 74px; margin: -37px 0 0 -37px;
  display: grid; place-items: center;
  border: 0; border-radius: 50%; padding: 0; cursor: pointer;
  color: var(--nxp-ink);
  background: radial-gradient(circle at 35% 30%, var(--nxp-gold-lit), var(--nxp-gold) 70%);
  box-shadow: 0 14px 44px rgba(209, 160, 90, 0.42), 0 0 0 7px rgba(209, 160, 90, 0.16);
  transition: transform 0.25s var(--nxp-ease), opacity 0.25s var(--nxp-ease), box-shadow 0.25s var(--nxp-ease);
}
.nxp-big svg { width: 30px; height: 30px; }
.nxp-big svg path[fill] { transform: translateX(1.5px); }
.nxp-big:hover { transform: scale(1.07); box-shadow: 0 16px 52px rgba(224, 180, 115, 0.55), 0 0 0 9px rgba(209, 160, 90, 0.2); }
.nxp-big:active { transform: scale(0.96); }
.nxp-big:focus-visible { outline: 2px solid var(--nxp-paper); outline-offset: 4px; }
.nxp:not(.nxp--paused) .nxp-big,
.nxp--error .nxp-big,
.nxp--wait .nxp-big { opacity: 0; transform: scale(0.85); pointer-events: none; }

/* Buffering. */
.nxp-spin {
  position: absolute; left: 50%; top: 50%;
  width: 46px; height: 46px; margin: -23px 0 0 -23px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.16);
  border-top-color: var(--nxp-gold);
  opacity: 0; pointer-events: none;
  transition: opacity 0.2s ease;
}
.nxp--wait .nxp-spin { opacity: 1; animation: nxp-spin 0.8s linear infinite; }
@keyframes nxp-spin { to { transform: rotate(360deg); } }

/* Seek and volume notes: a double tap or a key press says what it did. */
.nxp-osd {
  position: absolute; top: 50%; display: flex; align-items: center; gap: 6px;
  padding: 10px 14px; margin-top: -22px; border-radius: 999px;
  background: var(--nxp-glass); color: var(--nxp-gold-lit);
  font-weight: 600; font-size: 14px; font-variant-numeric: tabular-nums;
  opacity: 0; pointer-events: none;
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
}
.nxp-osd svg { width: 18px; height: 18px; }
.nxp-osd--back { left: 9%; }
.nxp-osd--fwd { right: 9%; }
.nxp-osd--note { left: 50%; transform: translateX(-50%); }
.nxp-osd.is-on { animation: nxp-osd 0.65s var(--nxp-ease) both; }
.nxp-osd--note.is-on { animation-name: nxp-osd-c; }
@keyframes nxp-osd { 0% { opacity: 0; transform: scale(0.9); } 18% { opacity: 1; transform: none; } 70% { opacity: 1; } 100% { opacity: 0; } }
@keyframes nxp-osd-c { 0% { opacity: 0; transform: translateX(-50%) scale(0.9); } 18% { opacity: 1; transform: translateX(-50%); } 70% { opacity: 1; } 100% { opacity: 0; transform: translateX(-50%); } }

/* Failure, with a way back. */
.nxp-err {
  position: absolute; inset: 0; z-index: 3;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  padding: 20px; text-align: center; background: rgba(0, 0, 0, 0.78);
}
.nxp-err[hidden] { display: none; }
.nxp-err-msg { margin: 0; font-size: 14px; line-height: 1.4; color: var(--nxp-dim); }
.nxp-retry {
  border: 0; border-radius: 999px; padding: 10px 18px; cursor: pointer;
  font: inherit; font-weight: 600; color: var(--nxp-ink); background: var(--nxp-gold);
}
.nxp-retry:hover { background: var(--nxp-gold-lit); }
.nxp-retry:focus-visible { outline: 2px solid var(--nxp-paper); outline-offset: 3px; }

/* ---------- the bar ---------- */
.nxp-bar {
  position: absolute; left: 10px; right: 10px; bottom: 10px; z-index: 2;
  padding: 4px 10px 6px;
  border-radius: 16px;
  background: var(--nxp-glass);
  border: 1px solid var(--nxp-line);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  backdrop-filter: blur(14px) saturate(140%);
  box-shadow: 0 10px 34px rgba(0, 0, 0, 0.35);
  transition: opacity 0.3s var(--nxp-ease), transform 0.3s var(--nxp-ease);
}
.nxp--idle .nxp-bar,
.nxp--idle .nxp-shade { opacity: 0; }
.nxp--idle .nxp-bar { transform: translateY(10px); pointer-events: none; }
.nxp--fs .nxp-bar { left: 50%; right: auto; width: min(960px, calc(100% - 32px)); transform: translateX(-50%); bottom: 22px; }
.nxp--fs.nxp--idle .nxp-bar { transform: translate(-50%, 10px); }

/* Scrubber: a thin gold line that thickens under the pointer. */
.nxp-scrub {
  --nxp-p: 0; --nxp-b: 0;
  position: relative; height: 22px; cursor: pointer;
  touch-action: none; outline: none;
}
.nxp--nodur .nxp-scrub { cursor: default; }
.nxp-track {
  position: absolute; left: 0; right: 0; top: 50%; height: 4px; margin-top: -2px;
  border-radius: 999px; overflow: hidden; background: rgba(255, 255, 255, 0.18);
  transition: height 0.18s var(--nxp-ease), margin 0.18s var(--nxp-ease);
}
.nxp-buf, .nxp-fill {
  position: absolute; inset: 0; transform-origin: 0 50%; border-radius: inherit;
}
.nxp-buf { background: rgba(255, 255, 255, 0.28); transform: scaleX(var(--nxp-b)); }
.nxp-fill {
  background: linear-gradient(90deg, var(--nxp-gold), var(--nxp-gold-lit));
  transform: scaleX(var(--nxp-p));
}
.nxp-knob-rail {
  position: absolute; left: 0; right: 0; top: 50%; height: 0; pointer-events: none;
  transform: translateX(calc(var(--nxp-p) * 100%));
}
.nxp-knob {
  position: absolute; left: -7px; top: -7px; width: 14px; height: 14px; border-radius: 50%;
  background: var(--nxp-gold-lit);
  box-shadow: 0 0 0 4px rgba(224, 180, 115, 0.22), 0 0 16px rgba(224, 180, 115, 0.6);
  transform: scale(0); transition: transform 0.18s var(--nxp-ease);
}
.nxp-scrub:hover .nxp-track, .nxp--drag .nxp-track, .nxp-scrub:focus-visible .nxp-track { height: 6px; margin-top: -3px; }
.nxp-scrub:hover .nxp-knob, .nxp--drag .nxp-knob, .nxp-scrub:focus-visible .nxp-knob { transform: scale(1); }
.nxp--drag .nxp-knob { transform: scale(1.2); }
.nxp-scrub:focus-visible { box-shadow: 0 0 0 2px rgba(224, 180, 115, 0.55); border-radius: 8px; }
@media (hover: none) { .nxp-knob { transform: scale(0.85); } }

.nxp-tip {
  position: absolute; left: 0; bottom: 24px;
  padding: 6px 9px; border-radius: 8px;
  background: rgba(10, 9, 7, 0.9); border: 1px solid rgba(209, 160, 90, 0.35);
  color: var(--nxp-gold-lit); font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums;
  white-space: nowrap; pointer-events: none;
  opacity: 0; transition: opacity 0.15s ease;
}
.nxp--tip .nxp-tip { opacity: 1; }

/* The row of buttons. */
.nxp-row { display: flex; align-items: center; gap: 2px; min-height: 38px; }
.nxp-gap { flex: 1 1 auto; }
.nxp-btn {
  flex: none; display: grid; place-items: center;
  width: 38px; height: 38px; padding: 0; border: 0; border-radius: 10px;
  background: transparent; color: var(--nxp-paper); cursor: pointer;
  transition: color 0.15s ease, background-color 0.15s ease, transform 0.15s var(--nxp-ease);
}
.nxp-btn[hidden] { display: none; }
.nxp-btn:hover { color: var(--nxp-gold-lit); background: rgba(255, 255, 255, 0.06); }
.nxp-btn:active { transform: scale(0.92); }
.nxp-btn:focus-visible { outline: 2px solid var(--nxp-gold-lit); outline-offset: -2px; }
.nxp-play { color: var(--nxp-gold-lit); }
.nxp-rate { width: auto; min-width: 38px; padding: 0 8px; font: inherit; font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums; }

.nxp-time {
  flex: none; padding: 0 8px; font-size: 12.5px; font-variant-numeric: tabular-nums;
  color: var(--nxp-paper); white-space: nowrap;
}
.nxp-sep, .nxp-dur { color: var(--nxp-dim); }

/* Volume: the slider opens beside its button on a desktop. */
.nxp-vol { display: flex; align-items: center; }
.nxp-volume {
  --nxp-v: 1;
  -webkit-appearance: none; appearance: none;
  width: 0; height: 22px; margin: 0; padding: 0; opacity: 0;
  background: transparent; cursor: pointer;
  transition: width 0.22s var(--nxp-ease), opacity 0.22s var(--nxp-ease), margin 0.22s var(--nxp-ease);
}
.nxp-vol:hover .nxp-volume,
.nxp-vol:focus-within .nxp-volume { width: 76px; opacity: 1; margin: 0 6px 0 2px; }
.nxp-volume::-webkit-slider-runnable-track {
  height: 4px; border-radius: 999px;
  background: linear-gradient(90deg, var(--nxp-gold-lit) calc(var(--nxp-v) * 100%), rgba(255, 255, 255, 0.22) 0);
}
.nxp-volume::-moz-range-track { height: 4px; border-radius: 999px; background: rgba(255, 255, 255, 0.22); }
.nxp-volume::-moz-range-progress { height: 4px; border-radius: 999px; background: var(--nxp-gold-lit); }
.nxp-volume::-webkit-slider-thumb {
  -webkit-appearance: none; width: 12px; height: 12px; margin-top: -4px; border: 0; border-radius: 50%;
  background: var(--nxp-gold-lit); box-shadow: 0 0 10px rgba(224, 180, 115, 0.6);
}
.nxp-volume::-moz-range-thumb {
  width: 12px; height: 12px; border: 0; border-radius: 50%;
  background: var(--nxp-gold-lit); box-shadow: 0 0 10px rgba(224, 180, 115, 0.6);
}
.nxp-volume:focus-visible { outline: 2px solid var(--nxp-gold-lit); outline-offset: 2px; border-radius: 6px; }
.nxp--novol .nxp-volume { display: none; }

/* Speed menu. */
.nxp-speed { position: relative; flex: none; }
.nxp-menu {
  position: absolute; right: 0; bottom: calc(100% + 10px); z-index: 4;
  min-width: 128px; padding: 6px; border-radius: 14px;
  background: rgba(14, 12, 9, 0.92); border: 1px solid var(--nxp-line);
  -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5);
  display: grid; gap: 2px;
}
.nxp-menu[hidden] { display: none; }
.nxp-menu button {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 9px 12px; border: 0; border-radius: 9px; background: transparent;
  color: var(--nxp-paper); font: inherit; font-size: 13px; text-align: left; cursor: pointer;
}
.nxp-menu button:hover, .nxp-menu button:focus-visible { background: rgba(255, 255, 255, 0.07); outline: none; }
.nxp-menu button[aria-checked="true"] { color: var(--nxp-gold-lit); font-weight: 700; }
.nxp-menu button[aria-checked="true"]::after { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--nxp-gold-lit); }

/* ---------- narrow players: a phone, a 9:16 frame on the site ---------- */
.nxp--narrow .nxp-bar { left: 8px; right: 8px; bottom: 8px; padding: 2px 6px 4px; border-radius: 14px; }
.nxp--narrow .nxp-volume,
.nxp--narrow .nxp-pip { display: none; }
.nxp--narrow .nxp-time { padding: 0 4px; font-size: 12px; }
.nxp--narrow .nxp-btn { width: 34px; height: 34px; }
/* Centred in the picture above the bar, not in the whole box: in a short 16:9
   clip on a phone the bar is a third of the height. */
.nxp--narrow .nxp-big { width: 58px; height: 58px; margin: -29px 0 0 -29px; top: calc(50% - 26px); }
.nxp--narrow .nxp-big svg { width: 24px; height: 24px; }
.nxp--tiny .nxp-dl,
.nxp--tiny .nxp-sep,
.nxp--tiny .nxp-dur { display: none; }

/* ---------- before the first play: one control ----------
   A film nobody has started shows the big button and nothing else. With the bar
   under it too, a small player was mostly bar and the two overlapped. The bar
   still comes up for anyone who tabs into it from the keyboard. */
.nxp--fresh .nxp-bar,
.nxp--fresh .nxp-shade { opacity: 0; transform: translateY(10px); pointer-events: none; }
.nxp--fresh .nxp-bar:focus-within { opacity: 1; transform: none; pointer-events: auto; }
.nxp--fresh .nxp-big { top: 50%; }

/* ---------- short players: one row ----------
   Under 300px tall — a 16:9 clip in the chat column, the admin's thumbnails —
   the two-row bar covered most of the picture. The scrubber joins the buttons in
   a single row, and after the first play the big button stands down: the bar's
   own play button is right there, and the two no longer collide. */
.nxp--short .nxp-bar {
  display: flex; align-items: center; gap: 2px;
  left: 6px; right: 6px; bottom: 6px; padding: 2px 4px; border-radius: 12px;
}
.nxp--short .nxp-row { display: contents; }
.nxp--short .nxp-play { order: 1; }
.nxp--short .nxp-vol { order: 2; }
.nxp--short .nxp-scrub { order: 3; flex: 1 1 auto; min-width: 36px; height: 30px; margin: 0 6px; }
.nxp--short .nxp-time { order: 4; }
.nxp--short .nxp-gap { display: none; }
.nxp--short .nxp-speed { order: 5; }
.nxp--short .nxp-dl { order: 6; }
.nxp--short .nxp-pip { order: 7; }
.nxp--short .nxp-fs { order: 8; }
.nxp--short .nxp-btn { width: 32px; height: 32px; }
.nxp--short .nxp-tip { bottom: 28px; }
.nxp--short:not(.nxp--fresh) .nxp-big { opacity: 0; transform: scale(0.85); pointer-events: none; }
/* A thumbnail keeps play, the scrubber, the time and full screen. */
.nxp--tiny .nxp-vol,
.nxp--tiny .nxp-speed { display: none; }
.nxp--tiny.nxp--fresh .nxp-big { width: 50px; height: 50px; margin: -25px 0 0 -25px; }
.nxp--tiny.nxp--fresh .nxp-big svg { width: 22px; height: 22px; }

@media (prefers-reduced-motion: reduce) {
  .nxp *, .nxp *::before, .nxp *::after { transition: none !important; }
  .nxp-osd.is-on { animation: none; opacity: 1; }
  .nxp--wait .nxp-spin { animation-duration: 1.6s; }
}
