/* media-viewer.css — styles for public/media-viewer.js.
 * Every selector is namespaced `mv-`; nothing here touches the chat chrome.
 *
 * Layout contract:
 *  · the root is a fixed overlay. A single track holds the current card,
 *    the messages above and below it, and the album items to either side;
 *  · the active caption and controls sit above the track. The bottom bar is a
 *    flow column, so the caption/media area above it is never overlapped:
 *    caption → scrollable pill row → (video only) full-width seek → controls;
 *  · the controls row is a 1fr/auto/1fr grid: the clock keeps the left edge,
 *    the outline play/pause sits dead centre (and cannot drift when the clock
 *    digits change) and mute/speed/PiP/fullscreen keep the right edge;
 *  · there is deliberately NO gradient scrim, no border, no shadow and no text
 *    shadow anywhere in the chrome: only a subtle translucent frosted fill plus
 *    blur, and an outline for keyboard focus only (accessibility).
 */

.mv-root {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: block;
  overflow: hidden;
  background: #000;
  color: #fff;
  isolation: isolate;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
  overscroll-behavior: none;
  outline: none;
  --mv-safe-t: env(safe-area-inset-top, 0px);
  --mv-safe-b: env(safe-area-inset-bottom, 0px);
  --mv-safe-l: env(safe-area-inset-left, 0px);
  --mv-safe-r: env(safe-area-inset-right, 0px);
  --mv-pad-l: max(12px, var(--mv-safe-l));
  --mv-pad-r: max(12px, var(--mv-safe-r));
  --mv-bottom: max(10px, var(--mv-safe-b));
  --mv-pill-h: 36px;
  --mv-ctl: 34px;
  /* One icon size, one stroke, one family: every glyph is drawn on the same
     24-unit grid at the same rendered size. */
  --mv-icon: var(--control-icon, 20px);
  --mv-font: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  /* Shared frosted-glass recipe: subtle translucent neutral fill plus blur and
     nothing else — no border, no highlight, no drop shadow. Only small chrome
     surfaces use it — never the track, a unit, the stage, the album or the
     video/picture layer. */
  --mv-glass-fill: rgba(24, 30, 29, .34);
  --mv-glass-fill-strong: rgba(20, 26, 25, .55);
  --mv-glass-blur: var(--control-blur, blur(12px));
}

.mv-root.hidden { display: none; }
.mv-root.mv-closing { pointer-events: none; animation: mv-fade-out 180ms ease-in both; }
.mv-root.mv-reply-closing { animation: mv-reply-out 180ms cubic-bezier(.4,0,.6,1) both; }
.mv-root.mv-dismissing { background: transparent; }
.mv-root.mv-dismissing .mv-ui,
.mv-root.mv-dismissing .mv-close,
.mv-root.mv-dismissing .mv-status {
  opacity: clamp(0, calc(1 - var(--mv-dismiss, 0) * 4), 1);
  transition: none;
  pointer-events: none;
}

@keyframes mv-fade-out { to { opacity: 0; } }
@keyframes mv-reply-out { to { opacity: 0; transform: scale(.97); } }

/* ── track and slides ─────────────────────────────────────────────────── */
.mv-viewport { position: absolute; inset: 0; overflow: hidden; }

.mv-track {
  position: absolute;
  inset: 0;
  will-change: transform;
  transition: none;
}

.mv-media-track,
.mv-chrome {
  position: absolute;
  inset: 0;
}
.mv-media-track { will-change: transform; }
.mv-chrome { z-index: 3; pointer-events: none; }

.mv-slide {
  position: absolute;
  top: 100%;
  left: 0;
  width: 100%;
  height: 100%;
  min-height: 0;
  overflow: hidden;
  background: #000;
}

.mv-slide[data-mv-slot="0"] { top: 0; }
.mv-slide[data-mv-slot="2"] { top: 200%; }
.mv-slide[data-mv-slot="3"] { left: calc(-100% - var(--mv-album-gap)); }
.mv-slide[data-mv-slot="4"] { left: calc(100% + var(--mv-album-gap)); }

.mv-slide-stage {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transform-origin: 50% 50%;
  will-change: transform;
}

.mv-slide[data-mv-live="true"] .mv-slide-stage { cursor: default; }
.mv-root.mv-zoomed .mv-slide[data-mv-live="true"] .mv-slide-stage { cursor: grab; }
.mv-root.mv-zoomed .mv-slide[data-mv-live="true"] .mv-slide-stage:active { cursor: grabbing; }

.mv-poster,
.mv-photo,
.mv-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  object-fit: contain;
  pointer-events: none;
  -webkit-user-drag: none;
  user-select: none;
  -webkit-user-select: none;
}

.mv-photo,
.mv-video { background: transparent; }
.mv-video { z-index: 2; }
.mv-video.mv-video-pending { opacity: 0; }

.mv-off { display: none !important; }

.mv-file {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 2;
}

/* ── per-slide chrome ─────────────────────────────────────────────────── */
.mv-ui {
  position: absolute;
  inset: 100% 0 auto;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  pointer-events: none;
  transition: opacity 220ms ease;
}
.mv-ui[data-mv-slot="0"] { top: 0; }
.mv-ui[data-mv-slot="2"] { top: 200%; }

.mv-root.mv-clean .mv-ui,
.mv-root.mv-clean .mv-close,
.mv-root.mv-clean .mv-status { opacity: 0; pointer-events: none; }

.mv-ui[data-mv-live="true"] .mv-actions,
.mv-ui[data-mv-live="true"] .mv-caption,
.mv-ui[data-mv-live="true"] .mv-playback { pointer-events: auto; }

.mv-head {
  position: absolute;
  top: calc(max(12px, var(--mv-safe-t)) + 4px);
  left: calc(var(--mv-pad-l) + 44px);
  right: calc(var(--mv-pad-r) + 44px);
  pointer-events: none;
}

.mv-position {
  font: 500 12px/1.3 Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  letter-spacing: .01em;
  color: rgba(255, 255, 255, .86);
  font-variant-numeric: tabular-nums;
}

/* ── bottom bar: caption, pill row, transport ─────────────────────────── */
.mv-bottom {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 0 var(--mv-pad-r) var(--mv-bottom) var(--mv-pad-l);
  min-width: 0;
}

.mv-caption {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.mv-author {
  font: 600 15px/1.3 Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  color: #fff;
}

.mv-name {
  font: 400 12px/1.45 Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  color: rgba(236, 245, 240, .92);
  max-height: 22vh;
  overflow: auto;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
  user-select: text;
  -webkit-user-select: text;
}

/* The action row is horizontal and scrollable: reactions are unbounded, so
   the rail can never be fixed-width. Reply/Download lead, the "+" is pinned. */
.mv-actions {
  position: relative;
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.mv-pills {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
  touch-action: pan-x;
  scrollbar-width: none;
}

.mv-pills::-webkit-scrollbar { width: 0; height: 0; }

.mv-pills-reactions { display: flex; align-items: center; gap: 6px; flex: 0 0 auto; }

.mv-pill {
  appearance: none;
  -webkit-appearance: none;
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex: 0 0 auto;
  height: var(--mv-pill-h);
  min-width: var(--mv-pill-h);
  padding: 0 12px;
  border: 0;
  border-radius: 999px;
  background: var(--mv-glass-fill);
  -webkit-backdrop-filter: var(--mv-glass-blur);
  backdrop-filter: var(--mv-glass-blur);
  box-shadow: none;
  color: #fff;
  font: 500 12px/1 var(--mv-font);
  white-space: nowrap;
  cursor: pointer;
  transition: background 160ms ease, color 160ms ease, transform 120ms ease, opacity 160ms ease;
}

.mv-pill svg { width: var(--mv-icon); height: var(--mv-icon); flex-shrink: 0; }
.mv-pill .mv-label { font: 500 12px/1 var(--mv-font); color: rgba(255, 255, 255, .92); }
.mv-pill:hover { background: rgba(38, 46, 44, .46); }
.mv-pill:active { transform: scale(.94); }
.mv-pill:disabled { opacity: .4; cursor: default; background: rgba(255, 255, 255, .08); }
.mv-pill:focus-visible { outline: 2px solid #6ee7b7; outline-offset: 2px; }

.mv-pill-reaction { padding: 0 11px; gap: 5px; }
.mv-pill-emoji { font-size: 14px; line-height: 1; }
.mv-pill-count { font: 500 12px/1 var(--mv-font); font-variant-numeric: tabular-nums; color: rgba(255, 255, 255, .9); }
.mv-pill-reaction.mv-active { background: rgba(52, 211, 153, .26); color: #b5f6db; }
.mv-pill-reaction.mv-active .mv-pill-count { color: #d6fbec; }

/* The "+" is a normal member of the row: it scrolls with Reply, Download and
   the reactions instead of floating outside the scroller. */
.mv-pill-more { width: var(--mv-pill-h); padding: 0; }

/* ── reaction picker (data-driven catalogue) ──────────────────────────── */
.mv-picker {
  position: absolute;
  right: 0;
  bottom: calc(100% + 8px);
  z-index: 4;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  gap: 2px;
  max-width: calc(100vw - 28px);
  overflow-x: auto;
  scrollbar-width: none;
  padding: 4px 6px;
  border: 0;
  border-radius: 999px;
  background: var(--mv-glass-fill-strong);
  -webkit-backdrop-filter: var(--mv-glass-blur);
  backdrop-filter: var(--mv-glass-blur);
  box-shadow: none;
}

.mv-picker::-webkit-scrollbar { width: 0; height: 0; }

.mv-choice {
  appearance: none;
  -webkit-appearance: none;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: #fff;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  transition: background 140ms ease, transform 120ms ease;
}

.mv-choice:hover { background: rgba(255, 255, 255, .12); }
.mv-choice:active { transform: scale(.9); }
.mv-choice:focus-visible { outline: 2px solid #6ee7b7; outline-offset: 1px; }

/* ── video transport: full-width seek, then time / play / extras ──────── */
.mv-playback {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

/* 32px of vertical touch area around a 2px line across the full width. */
.mv-seek-wrap {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
  height: 32px;
  min-height: 32px;
}

.mv-seek-line,
.mv-seek-fill {
  position: absolute;
  top: calc(50% - 1px);
  left: 0;
  height: 2px;
  border-radius: 2px;
  pointer-events: none;
}

.mv-seek-line { right: 0; background: rgba(255, 255, 255, .32); }
.mv-seek-fill { width: 0; background: #fff; }

.mv-seek {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 32px;
  margin: 0;
  padding: 0;
  appearance: none;
  -webkit-appearance: none;
  background: transparent;
  cursor: pointer;
  touch-action: none;
}

.mv-seek::-webkit-slider-runnable-track { height: 2px; background: transparent; }
.mv-seek::-moz-range-track { height: 2px; background: transparent; }

.mv-seek::-webkit-slider-thumb {
  appearance: none;
  -webkit-appearance: none;
  width: 11px;
  height: 11px;
  margin-top: -4.5px;
  border: 0;
  border-radius: 50%;
  background: #fff;
}

.mv-seek::-moz-range-thumb {
  width: 11px;
  height: 11px;
  border: 0;
  border-radius: 50%;
  background: #fff;
}

.mv-seek:disabled { opacity: .45; cursor: default; }

/* 1fr / auto / 1fr: the centre column is centred no matter how wide the
   elapsed-time digits become. */
.mv-controls {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 4px;
  min-height: var(--mv-ctl);
}

.mv-controls-right {
  position: relative;
  grid-column: 3;
  justify-self: end;
  display: flex;
  align-items: center;
  gap: 2px;
  min-width: 0;
}

.mv-clock {
  grid-column: 1;
  justify-self: start;
  font: 500 12px/1 var(--mv-font);
  color: rgba(255, 255, 255, .82);
  font-variant-numeric: tabular-nums;
  letter-spacing: .01em;
  white-space: nowrap;
}

.mv-ctl {
  appearance: none;
  -webkit-appearance: none;
  display: flex;
  align-items: center;
  justify-content: center;
  width: var(--mv-ctl);
  height: var(--mv-ctl);
  min-width: var(--mv-ctl);
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: #fff;
  cursor: pointer;
  transition: color 160ms ease, opacity 160ms ease, transform 120ms ease;
}

/* Every glyph is the same 24-grid outline at the same rendered size: no icon is
   bolder or bigger than its neighbours. */
.mv-ctl svg { width: var(--mv-icon); height: var(--mv-icon); }
.mv-ctl-play { grid-column: 2; justify-self: center; }
.mv-ctl-speed { font: 600 12px/1 var(--mv-font); }
.mv-ctl-speed .mv-rate { font-variant-numeric: tabular-nums; color: rgba(255, 255, 255, .92); }
.mv-ctl:hover { color: #b5f6db; }
.mv-ctl:active { transform: scale(.92); }
.mv-ctl:focus-visible { outline: 2px solid #6ee7b7; outline-offset: 2px; }
.mv-ctl[aria-pressed="true"] { color: #b5f6db; }

/* The wrapper is the positioning parent, so the menu hangs directly above the
   speed button (not above the whole right-hand cluster); the runtime clamps the
   left edge to the viewport when it opens. */
.mv-speed-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.mv-speed-menu {
  position: absolute;
  left: 50%;
  margin-left: -35px;
  bottom: calc(100% + 6px);
  z-index: 4;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 6px;
  border: 0;
  border-radius: 14px;
  background: var(--mv-glass-fill-strong);
  -webkit-backdrop-filter: var(--mv-glass-blur);
  backdrop-filter: var(--mv-glass-blur);
  box-shadow: none;
}

.mv-rate-option {
  width: 58px;
  height: 34px;
  border-radius: 10px;
  justify-content: flex-start;
  padding: 0 10px;
  font: 500 12px/1 var(--mv-font);
}

/* ── anchored overlay controls ────────────────────────────────────────── */
.mv-close {
  position: absolute;
  top: calc(var(--mv-safe-t) + 8px);
  right: calc(var(--mv-safe-r) + 8px);
  z-index: 6;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: var(--control-radius, 14px);
  background: var(--mv-glass-fill);
  -webkit-backdrop-filter: var(--mv-glass-blur);
  backdrop-filter: var(--mv-glass-blur);
  color: #fff;
  cursor: pointer;
  filter: none;
  transition: opacity 220ms ease, color 160ms ease, transform 120ms ease;
}

.mv-close svg { width: var(--mv-icon); height: var(--mv-icon); }
.mv-close:hover { color: #b5f6db; }
.mv-close:active { transform: scale(.92); }
.mv-close:focus-visible { outline: 2px solid #6ee7b7; outline-offset: 2px; }

/* ── album dots: part of each vertical media card, outside its album Swiper ─ */
.mv-dots {
  position: absolute;
  left: 50%;
  bottom: calc(var(--mv-dots-offset, 120px) + 10px);
  z-index: 5;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  max-width: min(86vw, 460px);
  padding: 4px 8px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
  box-shadow: none;
  transform: translateX(-50%);
  transition: opacity 220ms ease;
}

.mv-dot {
  appearance: none;
  -webkit-appearance: none;
  display: grid;
  place-items: center;
  width: 16px;
  height: 16px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
}

.mv-dot::before {
  content: '';
  display: block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .38);
  transition: background 160ms ease, transform 160ms ease;
}

.mv-dot-active::before { background: #fff; transform: scale(1.35); }
.mv-dot:focus-visible { outline: 2px solid #6ee7b7; outline-offset: 0; }

.mv-root.mv-clean .mv-dots { opacity: 0; pointer-events: none; }

.mv-status {
  position: absolute;
  left: 50%;
  bottom: calc(var(--mv-bottom) + 168px);
  transform: translateX(-50%);
  max-width: min(84vw, 420px);
  z-index: 5;
  padding: 8px 14px;
  border-radius: 14px;
  background: rgba(6, 12, 11, .82);
  color: #d8e7df;
  font: 400 13px/1.4 Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  text-align: center;
  pointer-events: none;
}

/* ── file / audio card (rendered by the caller) ───────────────────────── */
.mv-file-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  width: min(74vw, 420px);
  padding: 24px;
  text-align: center;
  color: #fff;
}

.mv-file-icon { display: grid; place-items: center; width: 84px; height: 84px; border-radius: 22px; background: rgba(255, 255, 255, .08); }
.mv-file-icon svg { width: 44px; height: 44px; }
.mv-file-card strong { max-width: 100%; font-size: 17px; overflow-wrap: anywhere; }
.mv-file-meta { color: #a8b4ae; font-size: 13px; }
.mv-file-action {
  box-sizing: border-box;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  padding: 12px 20px;
  border: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, .12);
  color: #fff;
  font: inherit;
  white-space: nowrap;
  cursor: pointer;
  overflow: hidden;
  transition: width 260ms cubic-bezier(.2,.8,.2,1), height 260ms cubic-bezier(.2,.8,.2,1), gap 260ms ease, padding 260ms ease, margin 260ms ease, border-radius 260ms ease, opacity 180ms ease, transform 180ms ease;
}
.mv-file-action svg { width: 20px; height: 20px; }
/* ── narrow phones: keep the transport on one line at 360px ───────────── */
@media (max-width: 380px) {
  .mv-root { --mv-ctl: 32px; --mv-pill-h: 34px; --mv-pad-l: max(10px, var(--mv-safe-l)); --mv-pad-r: max(10px, var(--mv-safe-r)); }
  .mv-controls-right { gap: 0; }
  .mv-pill { padding: 0 10px; }
}

/* ── wide viewports: keep the picture away from the controls ──────────── */
@media (min-width: 900px) {
  .mv-root { --mv-pad-l: max(28px, var(--mv-safe-l)); --mv-pad-r: max(28px, var(--mv-safe-r)); --mv-ctl: 38px; --mv-pill-h: 38px; }
  .mv-caption { max-width: min(60ch, 68vw); }
  .mv-actions { max-width: min(72ch, 78vw); }
}

@media (prefers-reduced-motion: reduce) {
  .mv-root.mv-closing { animation: none; }
  .mv-ui, .mv-close, .mv-status, .mv-pill, .mv-ctl, .mv-choice, .mv-dots, .mv-dot::before { transition: none; }
}

/* Leave a gutter around the scrolling pills and settle on whole buttons. */
.mv-pills { padding: 3px 8px 3px 3px; scroll-padding-inline: 3px 8px; scroll-snap-type: x proximity; }
.mv-pills > .mv-pill, .mv-pills-reactions > .mv-pill { scroll-snap-align: start; scroll-snap-stop: normal; }
