/* =========================================================================
   PubArx Pitch: the player (public/js/pitch-player.js), the section on paper
   pages, the gallery (/pitches) and the plays box. Colours come from the
   tokens in pubarx.css, so dark mode follows them; the picture area is black
   in both themes. Every selector starts with .pitch- (PitchFrontEndTest).
   ========================================================================= */

/* ------------------------------------------------------------------ paper page section */

.pitch-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 12px; margin-bottom: 6px; }
.pitch-head h2 { margin: 0; }
.pitch-length { font-size: 0.9rem; font-variant-numeric: tabular-nums; color: var(--text-3); }
.pitch-lede { margin: 0 0 12px; font-size: 0.95rem; color: var(--text-2); }
.pitch-foot { margin: 10px 0 0; }
.pitch-moderate { margin-top: 8px; }
.pitch-moderate .reply-form .input { width: 100%; }
.pitch-metric { grid-column: 1 / -1; }

@media print {
  .pitch-section { display: none; }
}

/* ------------------------------------------------------------------ player */

.pitch-player { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--surface-2); }
/* Everything the script reveals stays out of view until then (author display rules would override the UA rule). */
.pitch-player [hidden] { display: none; }

.pitch-stage { position: relative; background: #000; }
.pitch-stage:focus-visible { outline: 3px solid var(--focus); outline-offset: -3px; border-radius: 0; }
/* The width and height attributes give the box its ratio before the video loads; portrait videos get side bars. */
.pitch-video { display: block; width: 100%; height: auto; max-height: min(78vh, 760px); object-fit: contain; background: #000; }
.pitch-video::cue { font-family: var(--font-sans); font-size: 1.05em; line-height: 1.35; color: #fff; background: rgb(0 0 0 / 0.78); }

.pitch-bigplay {
  position: absolute; left: 50%; top: 50%; display: flex; align-items: center; justify-content: center;
  width: 72px; height: 72px; margin: -36px 0 0 -36px; padding: 0;
  border: 0; border-radius: 50%; background: rgb(0 0 0 / 0.6); color: #fff; cursor: pointer;
}
.pitch-bigplay:hover { background: rgb(0 0 0 / 0.75); }
.pitch-bigplay:focus-visible { outline: 3px solid #fff; outline-offset: 2px; border-radius: 50%; }
.pitch-bigplay svg { width: 32px; height: 32px; margin-left: 4px; }

.pitch-spinner {
  position: absolute; left: 50%; top: 50%; width: 44px; height: 44px; margin: -22px 0 0 -22px;
  border: 4px solid rgb(255 255 255 / 0.3); border-top-color: #fff; border-radius: 50%;
  animation: pitch-spin 0.9s linear infinite; pointer-events: none;
}
@keyframes pitch-spin {
  to { transform: rotate(360deg); }
}

.pitch-error { position: absolute; left: 0; right: 0; bottom: 0; padding: 12px 16px; background: rgb(0 0 0 / 0.8); color: #fff; font-size: 0.9rem; }
.pitch-error p { margin: 0 0 4px; }
.pitch-error a { color: #fff; text-decoration: underline; }

/* Below the picture and always visible: they never cover captions, and nothing hides while the pointer rests. */
.pitch-controls { position: relative; padding: 6px 8px 8px; background: var(--surface-2); border-top: 1px solid var(--border); }

.pitch-seekbar { position: relative; height: 24px; }
.pitch-track {
  position: absolute; left: 0; right: 0; top: 10px; height: 4px; overflow: hidden;
  border-radius: 2px; background: var(--surface-3); pointer-events: none;
}
.pitch-buffered { position: absolute; inset: 0; }
.pitch-buffered span { position: absolute; top: 0; bottom: 0; background: var(--border-strong); }
.pitch-played { position: absolute; left: 0; top: 0; bottom: 0; width: 0; background: var(--brand); }
.pitch-seek {
  position: absolute; inset: 0; width: 100%; height: 24px; margin: 0; padding: 0;
  background: transparent; cursor: pointer; -webkit-appearance: none; appearance: none;
}
.pitch-seek::-webkit-slider-runnable-track { height: 24px; background: transparent; border: 0; }
.pitch-seek::-moz-range-track { height: 24px; background: transparent; border: 0; }
.pitch-seek::-moz-range-progress { background: transparent; }
.pitch-seek::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none; width: 14px; height: 14px; margin-top: 5px;
  border: 0; border-radius: 50%; background: var(--brand); box-shadow: 0 0 0 2px var(--surface);
}
.pitch-seek::-moz-range-thumb { width: 14px; height: 14px; border: 0; border-radius: 50%; background: var(--brand); box-shadow: 0 0 0 2px var(--surface); }
.pitch-seek:focus-visible { outline: 2px solid var(--focus); outline-offset: 0; border-radius: var(--radius-sm); }
.pitch-tooltip {
  position: absolute; bottom: calc(100% + 2px); left: 0; z-index: 2; transform: translateX(-50%);
  padding: 2px 6px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--bg); color: var(--text);
  font-size: 0.76rem; font-variant-numeric: tabular-nums; line-height: 1.4; white-space: nowrap; pointer-events: none;
}

.pitch-bar { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 2px 8px; }
.pitch-group { display: flex; align-items: center; gap: 2px; min-width: 0; }
.pitch-btn {
  display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; padding: 0;
  border: 1px solid transparent; border-radius: var(--radius-sm); background: transparent; color: var(--text-2); cursor: pointer;
}
.pitch-btn:hover { background: var(--surface-3); color: var(--text); }
.pitch-btn:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
.pitch-btn svg { width: 18px; height: 18px; }
.pitch-volume { width: 80px; margin: 0 4px; accent-color: var(--brand); cursor: pointer; }
.pitch-time { margin-left: 6px; font-size: 0.84rem; font-variant-numeric: tabular-nums; white-space: nowrap; color: var(--text-2); }

/* Icon states: the play, sound and full-screen buttons show the icon of what they do next. */
.pitch-player .pitch-when-playing, .pitch-player .pitch-when-muted, .pitch-player .pitch-when-full { display: none; }
.pitch-player.is-playing .pitch-when-paused, .pitch-player.is-muted .pitch-when-sound, .pitch-player.is-fullscreen .pitch-when-window { display: none; }
.pitch-player.is-playing .pitch-when-playing, .pitch-player.is-muted .pitch-when-muted, .pitch-player.is-fullscreen .pitch-when-full { display: block; }
/* While captions are shown, their button is marked (its label says "Hide captions"). */
.pitch-player.is-captioned [data-pitch-cc] { color: var(--brand); box-shadow: inset 0 -2px 0 var(--brand); }

/* Settings: opens upwards over the picture, never past its top (the script sets --pitch-menu-max). */
.pitch-menu {
  position: absolute; right: 8px; bottom: calc(100% + 4px); z-index: 2;
  min-width: 180px; max-width: calc(100% - 16px); max-height: min(60vh, var(--pitch-menu-max, 60vh)); overflow: auto;
  padding: 4px 0; background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius); box-shadow: var(--shadow-lg);
}
.pitch-menu-group { min-width: 0; margin: 0; padding: 4px 0; border: 0; }
.pitch-menu-group + .pitch-menu-group { border-top: 1px solid var(--border); }
.pitch-menu-group legend { padding: 2px 14px; font-size: 0.76rem; color: var(--text-3); }
.pitch-option { display: flex; align-items: center; gap: 8px; padding: 5px 14px; font-size: 0.88rem; line-height: 1.4; color: var(--text); cursor: pointer; }
.pitch-option:hover { background: var(--surface-2); }
.pitch-option input { margin: 0; accent-color: var(--brand); }

/* Full screen: the controls stay on the screen and the picture is never cropped (min-height: 0 lets the stage shrink). */
.pitch-player:fullscreen { display: flex; flex-direction: column; width: 100%; height: 100%; border: 0; border-radius: 0; background: #000; }
.pitch-player:fullscreen .pitch-stage { display: flex; flex: 1 1 auto; min-height: 0; }
.pitch-player:fullscreen .pitch-video { width: 100%; height: 100%; max-height: none; object-fit: contain; }
.pitch-player:fullscreen .pitch-controls { flex: none; }
.pitch-player:-webkit-full-screen { display: flex; flex-direction: column; width: 100%; height: 100%; border: 0; border-radius: 0; background: #000; }
.pitch-player:-webkit-full-screen .pitch-stage { display: flex; flex: 1 1 auto; min-height: 0; }
.pitch-player:-webkit-full-screen .pitch-video { width: 100%; height: 100%; max-height: none; object-fit: contain; }
.pitch-player:-webkit-full-screen .pitch-controls { flex: none; }

/* Phones: play, sound, time, captions, settings and full screen fit in one row at 390px. */
@media (max-width: 480px) {
  .pitch-skip, .pitch-volume, .pitch-pip { display: none; }
}
@media (pointer: coarse) {
  .pitch-btn { width: 40px; height: 40px; }
  .pitch-volume { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .pitch-spinner { animation: none; }
}
@media (forced-colors: active) {
  .pitch-btn { border: 1px solid ButtonText; }
  .pitch-track { background: Canvas; border: 1px solid CanvasText; }
  .pitch-played { forced-color-adjust: none; background: Highlight; }
  .pitch-buffered span { forced-color-adjust: none; background: GrayText; }
  .pitch-seek::-webkit-slider-thumb { background: ButtonText; box-shadow: none; }
  .pitch-seek::-moz-range-thumb { background: ButtonText; box-shadow: none; }
  .pitch-bigplay { background: ButtonFace; color: ButtonText; border: 2px solid ButtonText; }
  .pitch-tooltip { background: Canvas; color: CanvasText; }
  .pitch-player.is-captioned [data-pitch-cc] { color: Highlight; box-shadow: none; border-color: Highlight; }
}

/* ------------------------------------------------------------------ gallery */

.pitch-gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr)); gap: 20px; margin: 0 0 24px; padding: 0; list-style: none; }
.pitch-card { min-width: 0; }
/* The thumbnail's size is not stored: the 16:9 box sizes it, and portrait pictures get side bars. */
.pitch-card-media { position: relative; display: block; aspect-ratio: 16 / 9; overflow: hidden; border-radius: var(--radius-sm); background: #000; }
.pitch-card-media img { width: 100%; height: 100%; object-fit: contain; }
.pitch-card-length {
  position: absolute; right: 6px; bottom: 6px; padding: 1px 6px; border-radius: 2px;
  background: rgb(0 0 0 / 0.75); color: #fff; font-size: 0.76rem; font-variant-numeric: tabular-nums; line-height: 1.4;
}
.pitch-card-title { margin: 10px 0 4px; font-family: var(--font-serif); font-size: 1rem; line-height: 1.35; overflow-wrap: anywhere; }
.pitch-card-title a { color: var(--text); }
.pitch-card-title a:hover { color: var(--link); }
.pitch-card-authors { margin: 0 0 2px; font-size: 0.86rem; color: var(--text-2); overflow-wrap: anywhere; }
.pitch-card-meta { margin: 0; font-size: 0.8rem; color: var(--text-3); }
