/*
  The interview review player.

  Hand-authored, like status.css and dataviz.css: workspace.css is a Tailwind
  BUILD OUTPUT and this markup is created at runtime by JavaScript, so utility
  classes here would be purged.

  LIGHT CHROME. The player wears the same clothes as the rest of the workspace --
  white surfaces, slate hairlines, blue-600 for the one thing that is "live".
  It reads as another card on the page rather than a widget from a different
  application. The only dark surface is the stage itself, which is the video's
  own backing, not chrome: letterbox bars are black in every player because a
  light surround washes out dark footage.

  THE TIMELINE IS THE POINT. A reviewer is not watching this interview for
  pleasure; they are hunting for two things -- where the agent asked something,
  and where the integrity monitor fired. Those live ON the scrub track as small
  ticks rather than in a list beside it, so "when did that happen" is answered by
  position instead of by reading timestamps.
*/

.rp {
  --rp-surface: #ffffff;
  --rp-ink: #020617; /* slate-950, the workspace's body colour */
  --rp-muted: #475569; /* slate-600, 7.4:1 on white */
  --rp-line: #e2e8f0; /* slate-200, the workspace hairline */
  --rp-hover: rgba(2, 6, 23, 0.06);
  --rp-track: #e2e8f0;
  --rp-buffered: #cbd5e1; /* slate-300 */
  --rp-played: #2563eb; /* blue-600, the workspace primary */
  /* Dark enough to hold 4.5:1 against the grey track. Over the blue played bar
     they rely on the white ring below rather than on hue alone, and every marker
     also carries an icon in its tooltip. */
  --rp-mark-question: #047857; /* emerald-700 */
  --rp-mark-integrity: #be123c; /* rose-700 */
  --rp-mark-tab-switch: #d97706; /* amber-600 */
  --rp-mark-multiple-faces: #dc2626; /* red-600 */
  --rp-mark-gaze-aversion: #7c3aed; /* violet-600 */

  position: relative;
  overflow: hidden;
  border: 1px solid var(--rp-line);
  border-radius: 0.625rem;
  background: var(--rp-surface);
  color: var(--rp-ink);
  font-family: inherit;
}

/* The player carries its own box model rather than inheriting the host page's.
   Every width below -- the tooltip's 17rem ceiling especially -- is a rendered
   width, not a content width, so the component measures the same wherever it is
   mounted. */
.rp,
.rp *,
.rp *::before,
.rp *::after {
  box-sizing: border-box;
}

/* ------------------------------------------------------------------ stage */

/*
  Big, but not so big the controls fall off the screen: on a tall monitor a
  full-width 16:9 stage pushes the transport and the marker timeline below the
  fold, and the timeline is the entire point of this player.

  The ceiling is expressed as a max-WIDTH rather than a max-height on purpose.
  Capping the height while holding `aspect-ratio: 16/9` makes `object-fit:
  contain` pillarbox the video, and wide black bars either side of the picture
  read as a rendering fault against white chrome. Capping the width keeps the
  box exactly 16:9 -- so a 16:9 recording fills it edge to edge -- and the space
  left over is white player instead.
*/
.rp__stage {
  position: relative;
  width: 100%;
  max-width: calc(min(62vh, 40rem) * 16 / 9);
  margin-inline: auto;
  aspect-ratio: 16 / 9;
  background: #000;
}

.rp__video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
}

/* Click the picture to play/pause, the way every player behaves. */
.rp__surface {
  position: absolute;
  inset: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
}

.rp__center-play {
  position: absolute;
  top: 50%;
  left: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 4rem;
  height: 4rem;
  transform: translate(-50%, -50%);
  border: 0;
  border-radius: 9999px;
  background: rgba(255, 255, 255, 0.94);
  color: var(--rp-ink);
  box-shadow: 0 8px 24px -8px rgba(2, 6, 23, 0.55);
  cursor: pointer;
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.rp__center-play svg {
  width: 1.75rem;
  height: 1.75rem;
  margin-left: 0.125rem;
}

.rp__center-play[hidden] {
  display: none;
}

/*
  Audio-only source. There is no picture to letterbox, so there is no black 16:9
  box: a black stage with sound was a reported bug -- the dashboard played the
  audio-only track in the video frame while the video was still being assembled.
  The <video> element stays in the DOM, because it is what plays the sound.
*/
.rp--audio .rp__stage {
  aspect-ratio: auto;
  height: 6.5rem;
  max-width: none;
  background: var(--rp-surface);
  border-bottom: 1px solid var(--rp-line);
}

.rp--audio .rp__video {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.rp--audio .rp__surface,
.rp--audio .rp__center-play,
.rp--audio [data-rp-fullscreen] {
  display: none;
}

.rp__audio-notice {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  padding: 0 1.5rem;
  text-align: center;
  color: var(--rp-muted);
  font-size: 0.8125rem;
}

.rp__audio-notice strong {
  color: var(--rp-ink);
  font-size: 0.875rem;
  font-weight: 600;
}

.rp__center-play:hover {
  transform: translate(-50%, -50%) scale(1.04);
}

.rp__skeleton {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--rp-surface);
  color: var(--rp-muted);
  font-size: 0.8125rem;
}

.rp__skeleton[hidden],
.rp__error[hidden] {
  display: none;
}

.rp__error {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: var(--rp-surface);
  color: var(--rp-muted);
  font-size: 0.8125rem;
  text-align: center;
}

/* --------------------------------------------------------------- controls */

.rp__controls {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0.625rem 0.75rem 0.75rem;
  background: var(--rp-surface);
}

/* Wraps rather than overflows. On a phone the transport keeps the first line and
   the marker toggles, speed and volume fall to a second one; without this the
   row scrolls sideways and the fullscreen button is unreachable. */
.rp__row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.rp__spacer {
  flex: 1 1 auto;
}

.rp__btn {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  height: 2rem;
  min-width: 2rem;
  padding: 0 0.5rem;
  border: 1px solid transparent;
  border-radius: 0.375rem;
  background: transparent;
  color: var(--rp-ink);
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
}

.rp__btn svg {
  width: 1.0625rem;
  height: 1.0625rem;
}

.rp__btn:hover {
  background: var(--rp-hover);
}

.rp__btn:focus-visible,
.rp__toggle:focus-visible,
.rp__select-btn:focus-visible {
  outline: 2px solid var(--rp-played);
  outline-offset: 1px;
}

.rp__time {
  flex: 0 0 auto;
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
  color: var(--rp-muted);
  white-space: nowrap;
}

.rp__time strong {
  color: var(--rp-ink);
  font-weight: 600;
}

/* A layer toggle reads as on/off at a glance: the swatch is the layer's own
   colour, and "off" drains it rather than hiding the control. */
.rp__toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  height: 1.75rem;
  padding: 0 0.5rem;
  border: 1px solid var(--rp-line);
  border-radius: 0.375rem;
  background: var(--rp-surface);
  color: var(--rp-muted);
  font-size: 0.6875rem;
  font-weight: 600;
  cursor: pointer;
}

.rp__toggle:hover {
  border-color: #cbd5e1;
  color: var(--rp-ink);
}

.rp__toggle[aria-pressed="true"] {
  color: var(--rp-ink);
  border-color: #cbd5e1;
  background: #f1f5f9;
}

.rp__swatch {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 2px;
  background: #94a3b8;
}

.rp__toggle[aria-pressed="true"] .rp__swatch--question {
  background: var(--rp-mark-question);
}

.rp__toggle[aria-pressed="true"] .rp__swatch--integrity {
  background: var(--rp-mark-integrity);
}

.rp__count {
  font-variant-numeric: tabular-nums;
  color: var(--rp-muted);
}

/* ----------------------------------------------------------- speed select */

/*
  A hand-built listbox rather than a native <select>. The native control renders
  as an OS widget -- grey on Windows, rounded on macOS -- so it was the one part
  of the player that refused to match the rest of the workspace, and it could not
  carry the check mark that shows which rate is live.

  The menu opens UPWARD because this control sits at the bottom edge of the
  player, and `.rp` clips its overflow: a downward menu would be cut off.
*/
.rp__select {
  position: relative;
  flex: 0 0 auto;
}

.rp__select-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  height: 1.75rem;
  padding: 0 0.375rem 0 0.5rem;
  border: 1px solid var(--rp-line);
  border-radius: 0.375rem;
  background: var(--rp-surface);
  color: var(--rp-ink);
  font-size: 0.6875rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
}

.rp__select-btn:hover {
  border-color: #cbd5e1;
  background: #f8fafc;
}

.rp__select-btn svg {
  width: 0.75rem;
  height: 0.75rem;
  color: var(--rp-muted);
  transition: transform 0.12s ease;
}

.rp__select-btn[aria-expanded="true"] {
  border-color: #cbd5e1;
  background: #f1f5f9;
}

.rp__select-btn[aria-expanded="true"] svg {
  transform: rotate(180deg);
}

.rp__select-menu {
  position: absolute;
  bottom: calc(100% + 0.375rem);
  right: 0;
  z-index: 30;
  display: flex;
  flex-direction: column;
  min-width: 5rem;
  padding: 0.25rem;
  border: 1px solid var(--rp-line);
  border-radius: 0.5rem;
  background: var(--rp-surface);
  box-shadow: 0 12px 28px -12px rgba(2, 6, 23, 0.35);
}

.rp__select-menu[hidden] {
  display: none;
}

.rp__select-opt {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.3125rem 0.5rem;
  border: 0;
  border-radius: 0.3125rem;
  background: transparent;
  color: var(--rp-ink);
  font-size: 0.6875rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  text-align: left;
  cursor: pointer;
}

.rp__select-opt:hover,
.rp__select-opt:focus-visible {
  background: #f1f5f9;
  outline: none;
}

.rp__select-opt[aria-selected="true"] {
  color: var(--rp-played);
}

/* A fixed-width slot so the labels stay in one column whether or not a row
   carries the tick. */
.rp__select-tick {
  display: inline-flex;
  width: 0.75rem;
  flex: 0 0 auto;
  color: var(--rp-played);
}

.rp__select-tick svg {
  width: 0.75rem;
  height: 0.75rem;
}

.rp__select-opt[aria-selected="false"] .rp__select-tick {
  visibility: hidden;
}

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

/*
  Thin. A 3px rail with a small handle, matching the seek track's weight -- the
  browser default is a chunky OS slider that out-shouts the timeline it sits
  next to. The fill is a gradient driven by --rp-vol, which the player updates on
  input, because a range input has no cross-browser "filled portion".
*/
.rp__volume {
  -webkit-appearance: none;
  appearance: none;
  width: 4.5rem;
  height: 1rem; /* pointer target; the visible rail is 3px */
  margin: 0;
  background: transparent;
  cursor: pointer;
}

.rp__volume::-webkit-slider-runnable-track {
  height: 3px;
  border-radius: 9999px;
  background: linear-gradient(
    to right,
    var(--rp-played) 0 calc(var(--rp-vol, 1) * 100%),
    var(--rp-track) calc(var(--rp-vol, 1) * 100%) 100%
  );
}

.rp__volume::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 0.625rem;
  height: 0.625rem;
  margin-top: -3.5px;
  border: 0;
  border-radius: 9999px;
  background: var(--rp-played);
}

.rp__volume::-moz-range-track {
  height: 3px;
  border-radius: 9999px;
  background: var(--rp-track);
}

.rp__volume::-moz-range-progress {
  height: 3px;
  border-radius: 9999px;
  background: var(--rp-played);
}

.rp__volume::-moz-range-thumb {
  width: 0.625rem;
  height: 0.625rem;
  border: 0;
  border-radius: 9999px;
  background: var(--rp-played);
}

.rp__volume:focus-visible {
  outline: 2px solid var(--rp-played);
  outline-offset: 2px;
  border-radius: 9999px;
}

/* --------------------------------------------------------------- timeline */

.rp__timeline {
  position: relative;
  height: 1.25rem;
  display: flex;
  align-items: center;
  cursor: pointer;
  touch-action: none;
}

.rp__track {
  position: relative;
  width: 100%;
  height: 4px;
  border-radius: 9999px;
  background: var(--rp-track);
  transition: height 0.12s ease;
}

.rp__timeline:hover .rp__track,
.rp__timeline:focus-visible .rp__track {
  height: 6px;
}

.rp__timeline:focus-visible {
  outline: 2px solid var(--rp-played);
  outline-offset: 3px;
  border-radius: 9999px;
}

.rp__buffered,
.rp__played {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  border-radius: 9999px;
}

.rp__buffered {
  background: var(--rp-buffered);
}

.rp__played {
  background: var(--rp-played);
}

.rp__head {
  position: absolute;
  top: 50%;
  width: 0.75rem;
  height: 0.75rem;
  margin-left: -0.375rem;
  transform: translateY(-50%) scale(0);
  border-radius: 9999px;
  background: var(--rp-played);
  box-shadow: 0 0 0 2px var(--rp-surface), 0 1px 3px rgba(2, 6, 23, 0.35);
  transition: transform 0.12s ease;
}

.rp__timeline:hover .rp__head,
.rp__timeline:focus-visible .rp__head {
  transform: translateY(-50%) scale(1);
}

/*
  Markers. Deliberately small -- 3px of colour on the track, with a 13px
  invisible hit area so they can still be pointed at. Anything larger turns a
  20-event interview into a striped bar and stops reading as a timeline.
*/
.rp__marks {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.rp__mark {
  position: absolute;
  top: 50%;
  width: 13px;
  height: 1.25rem;
  margin-left: -6.5px;
  transform: translateY(-50%);
  padding: 0;
  border: 0;
  background: transparent;
  pointer-events: auto;
  cursor: pointer;
}

/*
  The white ring is load-bearing, not decoration. A dark tick has 4.5:1 against
  the grey track but almost none against the blue played bar; the ring separates
  it from whatever it happens to sit on, and the 3px core still shows its hue.
*/
.rp__mark::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 3px;
  height: 11px;
  transform: translate(-50%, -50%);
  border-radius: 1px;
  background: var(--rp-mark-question);
  box-shadow: 0 0 0 1px var(--rp-surface);
  transition: height 0.12s ease, width 0.12s ease;
}

.rp__mark--integrity::after {
  background: var(--rp-mark-integrity);
}

.rp__mark--tab-switch::after {
  background: var(--rp-mark-tab-switch);
}

.rp__mark--multiple-faces::after {
  background: var(--rp-mark-multiple-faces);
}

.rp__mark--gaze-aversion::after {
  background: var(--rp-mark-gaze-aversion);
}

.rp__mark:hover::after,
.rp__mark:focus-visible::after {
  width: 5px;
  height: 15px;
}

.rp__mark:focus-visible {
  outline: none;
}

.rp__marks[data-hide-question="true"] .rp__mark--question,
.rp__marks[data-hide-integrity="true"] .rp__mark--integrity {
  display: none;
}

/* ------------------------------------------------------------- trust badge */

.rp__trust {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.125rem 0.5rem;
  border-radius: 9999px;
  font-size: 0.6875rem;
  font-weight: 500;
  line-height: 1.5;
  border: 1px solid var(--rp-line);
}

.rp__trust-label {
  color: var(--rp-muted);
  font-size: 0.625rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.rp__trust--high {
  background: #f0fdf4;
  color: #166534;
  border-color: #bbf7d0;
}

.rp__trust--high .rp__trust-dot {
  background: #16a34a;
}

.rp__trust--medium {
  background: #fffbeb;
  color: #92400e;
  border-color: #fde68a;
}

.rp__trust--medium .rp__trust-dot {
  background: #d97706;
}

.rp__trust--low {
  background: #fef2f2;
  color: #991b1b;
  border-color: #fecaca;
}

.rp__trust--low .rp__trust-dot {
  background: #dc2626;
}

.rp__trust-dot {
  width: 0.375rem;
  height: 0.375rem;
  border-radius: 9999px;
}

/* ---------------------------------------------------------------- tooltip */

/*
  Small on purpose. The brief is "show it in small size, not big one": this is a
  glance target while scrubbing, not a reading pane. The question is clamped to
  two lines and the answer to two more; the full text lives in the Transcript
  tab, which is one click away.
*/
.rp__tip {
  position: absolute;
  bottom: 1.5rem;
  z-index: 20;
  width: max-content;
  max-width: 17rem;
  padding: 0.5rem 0.625rem;
  border: 1px solid var(--rp-line);
  border-radius: 0.4375rem;
  background: var(--rp-surface);
  box-shadow: 0 12px 28px -12px rgba(2, 6, 23, 0.4);
  pointer-events: none;
  transform: translateX(-50%);
}

.rp__tip[hidden] {
  display: none;
}

.rp__tip-head {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--rp-ink);
}

.rp__tip-head svg {
  width: 0.8125rem;
  height: 0.8125rem;
  flex: 0 0 auto;
}

.rp__tip--question .rp__tip-head svg {
  color: var(--rp-mark-question);
}

.rp__tip--integrity .rp__tip-head svg {
  color: var(--rp-mark-integrity);
}

.rp__tip-at {
  margin-left: auto;
  font-variant-numeric: tabular-nums;
  font-weight: 500;
  color: var(--rp-muted);
}

.rp__tip-badge {
  display: inline-block;
  padding: 0.0625rem 0.3125rem;
  font-size: 0.5625rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-radius: 0.25rem;
  line-height: 1.4;
}

.rp__tip-badge--tab-switch {
  background: #fef3c7;
  color: #92400e;
}

.rp__tip-badge--multiple-faces {
  background: #fee2e2;
  color: #991b1b;
}

.rp__tip-badge--gaze-aversion {
  background: #f3e8ff;
  color: #6b21a8;
}

.rp__tip-body {
  margin: 0.3125rem 0 0;
  font-size: 0.75rem;
  line-height: 1.4;
  color: var(--rp-ink);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.rp__tip-answer {
  margin: 0.25rem 0 0;
  font-size: 0.6875rem;
  line-height: 1.4;
  color: var(--rp-muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ------------------------------------------------------------------ meta */

.rp__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
  padding: 0.625rem 0.75rem;
  border-top: 1px solid var(--rp-line);
  font-size: 0.6875rem;
  color: var(--rp-muted);
}

.rp__meta a {
  color: var(--rp-ink);
  font-weight: 600;
  text-decoration: none;
  border-bottom: 1px solid #cbd5e1;
}

.rp__meta a:hover {
  border-bottom-color: var(--rp-played);
}

/* ------------------------------------------------------------- fullscreen */

/*
  In fullscreen the stage must FILL what is left after the controls, not keep its
  16:9 box and 62vh ceiling. Holding those turned the bottom of the screen into a
  dead slab of background -- the video stopped at 62% of the height and nothing
  was drawn below it.

  `:fullscreen` and `:-webkit-full-screen` are written as separate rules on
  purpose: a selector list is discarded whole by any browser that does not
  recognise one of its parts, which would silently drop the fix.
*/
.rp:fullscreen {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  border: 0;
  border-radius: 0;
  background: #000;
}

.rp:-webkit-full-screen {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  border: 0;
  border-radius: 0;
  background: #000;
}

.rp:fullscreen .rp__stage {
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  max-width: none;
  aspect-ratio: auto;
}

.rp:-webkit-full-screen .rp__stage {
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  max-width: none;
  aspect-ratio: auto;
}

.rp:fullscreen .rp__controls,
.rp:-webkit-full-screen .rp__controls {
  flex: 0 0 auto;
}

/* Download links are a page concern, not a fullscreen one. */
.rp:fullscreen .rp__meta,
.rp:-webkit-full-screen .rp__meta {
  display: none;
}

@media (prefers-reduced-motion: reduce) {
  .rp__track,
  .rp__head,
  .rp__mark::after,
  .rp__center-play,
  .rp__select-btn svg {
    transition: none;
  }
}

@media (max-width: 640px) {
  /*
    Clipped, not `display: none`. The toggles carry no other label, so hiding the
    text outright would leave their accessible name as the bare count -- "6,
    toggle button, pressed" tells a screen-reader user nothing about what it
    toggles. Clipping keeps the name intact at every width without a second
    aria-label to drift out of sync with the visible one.
  */
  .rp__label-text {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }
  /* Volume goes entirely: the phone has hardware keys, and mute stays. */
  .rp__volume {
    display: none;
  }
}
