/* Player tools (SPEC 57): Mirror, the player settings menu, the A-B loop bar, the Skip intro / Skip outro buttons over the
   player, the moment chip, the Share dialog, and the Edit / Upload page's intro and outro fields. The site's tokens, so
   light mode follows the device like everything else; the player box is black in both themes. */

/* Mirror: the picture flips, its controls and captions don't (Chrome, Edge, Safari: their controls are pseudo-elements).
   In full screen browsers drop the element's transform (transform: none !important), so the scale property flips it.
   Only once the <video> shows the video (.has-frame, playertools.js): its poster is the creator's thumbnail, often with
   text, which would read backwards. */
.player video.is-mirrored.has-frame { transform: scaleX(-1); }
.player video.is-mirrored.has-frame::-webkit-media-controls { transform: scaleX(-1); }
.player video.is-mirrored.has-frame::-webkit-media-text-track-container { transform: scaleX(-1); }
video.is-mirrored.has-frame:fullscreen { scale: -1 1; }
video.is-mirrored.has-frame:-webkit-full-screen { scale: -1 1; }
/* A sponsor intro (SPEC 48) borrows the <video>: it always plays as the sponsor made it, never mirrored */
.player.has-sponsor-intro video.is-mirrored.has-frame,
.player.has-sponsor-intro video.is-mirrored.has-frame::-webkit-media-controls,
.player.has-sponsor-intro video.is-mirrored.has-frame::-webkit-media-text-track-container { transform: none; }
.player.has-sponsor-intro video.is-mirrored.has-frame:fullscreen,
.player.has-sponsor-intro video.is-mirrored.has-frame:-webkit-full-screen { scale: none; }

/* The player settings menu (the control row's Settings) -------------------------------------------------------- */

.menu.tools-menu > summary.btn { padding: 0 16px; border-radius: 999px; list-style: none; }
.menu.tools-menu > summary.btn::-webkit-details-marker { display: none; }
.menu.tools-menu[open] > summary.btn { background: var(--hover); }
.tools-pop { left: 0; right: auto; width: 280px; padding: 10px; }
.tools-pop.is-flipped { left: auto; right: 0; }
.tools-pop-title { padding: 2px 6px 6px; font-weight: 700; }
.tools-pop .tools-option { align-items: center; padding: 8px 6px; border-radius: 8px; }
.tools-pop .tools-option:hover { background: var(--surface-2); }
.tools-option > span { flex: 1; flex-wrap: nowrap; min-width: 0; }
.tools-option .icon, .tools-buttons .icon, .tools-frame-row .icon { flex: none; color: var(--text-2); }
.tools-key { margin-left: auto; flex: none; }
.tools-sub { padding: 4px 6px 2px; color: var(--text-2); font-size: 13px; font-weight: 700; }
.tools-loop-now { font-weight: 600; font-variant-numeric: tabular-nums; }
.tools-buttons { display: grid; gap: 2px; }
.menu-pop .tools-buttons button { padding: 9px 6px; }
.menu-pop .tools-buttons button[hidden] { display: none; }
.tools-frames[hidden] { display: none; }
.tools-frame-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; padding: 4px 0 2px; }
.menu-pop .tools-frame-row button {
  justify-content: center; gap: 6px; min-height: 44px; padding: 8px 6px; border: 1px solid var(--line); border-radius: 10px;
  font-size: 13.5px; font-weight: 600; text-align: center;
}
/* Touch screens have no keys to show */
@media (hover: none) and (pointer: coarse) {
  .tools-key { display: none; }
}

/* Right under the player: the moment chip and the A-B loop bar (templates/_playertools.html's under_player) ----------- */

.tools-under { min-width: 0; }
.tools-under[hidden] { display: none; }
/* Pages whose grid puts a chat replay (chat.css) or a playlist (lists.css) beside the player: while the row shows it
   gets a place of its own under the player, else 1100 px and narrower would put that panel between the two */
.watch-page.has-chat-replay.has-tools-row .tools-under,
.watch-page.has-list-panel.has-tools-row .tools-under { grid-area: tools; }
.watch-page.has-chat-replay.has-tools-row .tools-under > :first-child,
.watch-page.has-list-panel.has-tools-row .tools-under > :first-child { margin-top: 0; } /* the grid's gap is the space */
main.watch-page.has-chat-replay.has-tools-row { grid-template-areas: "player replay" "tools next" "info next"; grid-template-rows: auto auto 1fr; }
main.watch-page.has-list-panel.has-tools-row { grid-template-areas: "player panel" "tools next" "info next"; grid-template-rows: auto auto 1fr; }
main.watch-page.has-chat-replay.has-list-panel.has-tools-row {
  grid-template-areas: "player replay" "tools panel" "info panel" "info next"; grid-template-rows: auto auto auto 1fr;
}
@media (max-width: 1100px) {
  main.watch-page.has-chat-replay.has-tools-row { grid-template-areas: "player" "tools" "replay" "info" "next"; grid-template-rows: none; }
  main.watch-page.has-list-panel.has-tools-row { grid-template-areas: "player" "tools" "panel" "info" "next"; grid-template-rows: none; }
  main.watch-page.has-chat-replay.has-list-panel.has-tools-row {
    grid-template-areas: "player" "tools" "replay" "panel" "info" "next"; grid-template-rows: none;
  }
}

/* The A-B loop bar ---------------------------------------------------------------------------------------------------- */

.loop-bar { margin-top: 10px; }
.loop-bar[hidden] { display: none; }
.loop-track {
  position: relative; height: 6px; border-radius: 3px;
  background: color-mix(in srgb, var(--text) 30%, transparent); /* the whole video */
}
.loop-range {
  position: absolute; top: -3px; bottom: -3px; min-width: 3px; border-radius: 4px;
  background: var(--accent); box-shadow: 0 0 0 1px var(--bg);
}
.loop-range.is-open { width: 3px !important; } /* only A set: a mark where it starts */
.loop-head {
  position: absolute; top: 50%; width: 12px; height: 12px; border-radius: 50%;
  background: var(--text); box-shadow: 0 0 0 2px var(--bg); transform: translate(-50%, -50%); pointer-events: none;
}
.loop-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-width: 0; margin-top: 4px; }
.loop-text { display: inline-flex; align-items: center; gap: 6px; min-width: 0; font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums; }
.loop-text .icon { flex: none; color: var(--accent-text); }
.loop-clear { flex: none; height: 32px; padding: 0 10px; font-size: 13px; }

/* A shared moment ------------------------------------------------------------------------------------------------- */

.moment-chip {
  display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; margin-top: 10px; padding: 8px 12px;
  border-radius: 10px; background: var(--accent-soft); font-size: 14px;
}
.moment-chip[hidden] { display: none; }
.moment-chip .icon { flex: none; color: var(--accent-text); }
.moment-text { font-weight: 700; font-variant-numeric: tabular-nums; }
.moment-full { color: var(--accent-text); font-weight: 700; text-decoration: underline; text-underline-offset: 2px; }
.moment-full:hover { text-decoration-thickness: 2px; }

/* Skip intro / Skip outro, over the player (above the native controls, the Listen panel and the Up next card) ----- */

.skip-btn {
  position: absolute; right: 14px; bottom: 64px; z-index: 5;
  display: inline-flex; align-items: center; gap: 8px; height: 38px; padding: 0 14px;
  border: 1px solid rgba(255, 255, 255, 0.55); border-radius: 8px;
  background: rgba(15, 15, 16, 0.82); color: #fff; font: inherit; font-size: 14px; font-weight: 700; cursor: pointer;
}
.skip-btn:hover { background: rgba(0, 0, 0, 0.94); border-color: #fff; }
.skip-btn:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.player.has-sponsor-intro .skip-btn { display: none; }
.player.is-listening .skip-btn { top: 12px; bottom: auto; }

/* Share ------------------------------------------------------------------------------------------------------------ */

.share-dialog {
  width: min(480px, calc(100vw - 32px));
  max-height: calc(100vh - 32px); max-height: calc(100dvh - 32px); overflow-y: auto; overscroll-behavior: contain;
}
.share-body { gap: 14px; }
.share-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.share-head .dialog-title { padding-top: 6px; }
.share-close { flex: none; margin: -4px -6px 0 0; }
.share-link-row { display: flex; gap: 8px; min-width: 0; }
.share-link {
  flex: 1 1 auto; min-width: 0; height: 42px; padding: 0 12px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--bg); color: var(--text);
  font: inherit; font-size: 14px; text-overflow: ellipsis;
}
.share-link:focus { border-color: var(--focus); outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 25%, transparent); }
.share-copy { flex: none; height: 42px; min-width: 104px; justify-content: center; }
.share-native { justify-self: start; }
.share-native[hidden] { display: none; }
.share-moment-toggle { padding: 4px 0; font-weight: 600; }
.share-moment { display: grid; gap: 8px; min-width: 0; margin: 0; padding: 0; border: 0; }
.share-moment[hidden] { display: none; }
.share-times { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.share-times .field { margin: 0; min-width: 0; }
.share-times input { font-variant-numeric: tabular-nums; }
/* (as specific as style.css's .field input:not(...) rule, which would otherwise keep the usual border) */
.share-times .field input[aria-invalid="true"]:not([type="range"]):not([type="file"]):not([type="checkbox"]):not([type="radio"]) {
  border-color: var(--danger-text);
}
.share-moment .muted.small { margin: 0; line-height: 1.45; }
.share-error { margin: 0; }
.share-error[hidden] { display: none; }

/* Edit video and Upload: Intro ends at / Outro starts at ----------------------------------------------------------- */

.skip-fields { display: grid; gap: 2px; }
.skip-pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 16px; }
.skip-pair .field { margin: 0; min-width: 0; }
.skip-pair input { font-variant-numeric: tabular-nums; }
.skip-fields > .muted.small { margin-top: 6px; line-height: 1.45; }
.more-options { border-top: 1px solid var(--line); padding-top: 6px; }
.more-options-summary {
  display: inline-flex; align-items: center; gap: 6px; padding: 8px 2px; border-radius: 8px;
  font-weight: 700; cursor: pointer; list-style: none;
}
.more-options-summary::-webkit-details-marker { display: none; }
.more-options-summary .icon { flex: none; color: var(--text-2); transition: transform 0.15s; }
.more-options[open] > .more-options-summary .icon { transform: rotate(180deg); }
.more-options-summary:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.more-options > .skip-fields { margin: 6px 0 4px; }

/* Phones --------------------------------------------------------------------------------------------------------- */

@media (max-width: 720px) {
  /* Icon only here (like the row's others), and narrower, so a 390 px phone's control row keeps its two lines */
  .menu.tools-menu > summary.btn { padding: 0 8px; }
  .skip-btn { right: 10px; bottom: 54px; height: 34px; padding: 0 12px; font-size: 13px; }
  .player.is-listening .skip-btn { top: 8px; }
  .tools-under { padding: 0 16px; } /* like .watch-info's */
}
@media (max-width: 389px) {
  /* 360 and 375 px phones: a little less room around the row's icon buttons, so with the Settings button in it the
     control row keeps its two lines (Report isn't left alone on a third) */
  .watch-actions { column-gap: 6px; }
  .watch-actions > button.btn:not(.autoplay-toggle) { padding: 0 12px; }
}
@media (max-width: 480px) {
  /* The menu becomes a sheet along the bottom of the screen, like the Save menu, so it never runs off an edge (and
     playertools.js keeps it under the picture) */
  .tools-pop { position: fixed; left: 12px !important; right: 12px !important; top: auto; bottom: 12px; width: auto; max-height: 70vh; max-height: 70dvh; }
  body:has(.tools-menu[open]) .toast { top: 12px; bottom: auto; }
}
@media (max-width: 400px) {
  .share-link-row { flex-wrap: wrap; }
  .share-copy { flex: 1 1 100%; }
}
@media (max-width: 340px) {
  .skip-pair { grid-template-columns: minmax(0, 1fr); }
}
@media (forced-colors: active) {
  .loop-range { forced-color-adjust: none; background: Highlight; }
  .loop-head { forced-color-adjust: none; background: CanvasText; }
  .skip-btn { border-color: ButtonText; }
}
