/*
 * web/landing/shells/MediaGallery.css - the generic media layer (web/landing/shells/MediaGallery.js
 * documents the markup). A section brings it in with
 *   @import url('/web/landing/shells/MediaGallery.css');
 * at the top of its own sheet.
 *
 * Generic only: the four layouts, the item and its canvas, the media element filling its
 * box at the clip's own aspect ratio, the circle mask in the composed view, the captions,
 * the transport (play, time, scrubber), the tabs and the download list. Where a composed
 * clip sits over a backdrop, how big the canvas is and what the figcaption looks like are
 * the section's, in sections/<id>.css. The gallery is a size container, so a layout
 * follows the gallery's width rather than the page's.
 *
 * Tokens are web/landing.css's: aubergine surfaces, the one violet accent on the
 * scrubber's fill and focus, mono for the time and the file names. Genuine media keep
 * their own colours: the key colour of a raw clip shows as it was rendered.
 */

.media-gallery {
  container: media-gallery / inline-size;
  display: grid;
  gap: 10px;
  min-width: 0;
}

/* ── Items ────────────────────────────────────────────────────────────── */

.media-gallery-stage {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 14px;
  min-width: 0;
}

.media-gallery-item {
  display: grid;
  gap: 8px;
  min-width: 0;
  margin: 0;
}

.media-gallery-canvas {
  position: relative;
  min-width: 0;
  overflow: hidden;
  border-radius: 10px;
  background: var(--stage, #0e0b14);
}

/* The media's own box keeps the clip's aspect ratio (the script's width and height), so a
   circle in percent of the element is the circle in the clip. */
.media-gallery-media {
  position: relative;
  aspect-ratio: var(--media-gallery-aspect, 16 / 9);
  min-width: 0;
}

.media-gallery-video,
.media-gallery-image {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: transparent;
}

.media-gallery-item[data-kind="video"] [data-gallery-media] { cursor: pointer; }

/* The composed view: the clip cut to the circle its script names. The key colour lies
   outside the circle, so nothing has to be keyed. */
.media-gallery-item[data-masked]:not([data-view="raw"]) .media-gallery-video {
  clip-path: var(--media-gallery-clip, circle(50% at 50% 50%));
}

.media-gallery-captions {
  position: absolute;
  left: 50%;
  bottom: 12px;
  transform: translateX(-50%);
  width: max-content;
  max-width: calc(100% - 24px);
  margin: 0;
  padding: 5px 10px;
  border-radius: 6px;
  background: rgba(14, 11, 20, .82);
  color: var(--text);
  font-size: 14px;
  line-height: 1.4;
  text-align: center;
  text-wrap: balance;
  pointer-events: none;
}

.media-gallery-captions[hidden] { display: none; }

.media-gallery-label {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 2px 10px;
  min-width: 0;
  font-size: 13px;
  color: var(--muted);
}

[data-gallery-platform] {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--muted);
  overflow-wrap: anywhere;
}

[data-gallery-platform]:empty { display: none; }

/* ── Layouts ──────────────────────────────────────────────────────────── */

/* player: the selected item only. */
.media-gallery[data-layout="player"] .media-gallery-item:not([data-selected]) { display: none; }

/* comparison: one at a time with the tabs; side by side once the gallery is wide. */
.media-gallery[data-layout="comparison"] .media-gallery-item:not([data-selected]) { display: none; }

@container media-gallery (min-width: 640px) {
  .media-gallery[data-layout="comparison"] .media-gallery-tabs { display: none; }
  .media-gallery[data-layout="comparison"] .media-gallery-stage {
    grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr);
    align-items: start;
  }
  .media-gallery[data-layout="comparison"] .media-gallery-item:not([data-selected]) { display: grid; }
}

/* contact-sheet: a grid, the selected one ringed. */
.media-gallery[data-layout="contact-sheet"] .media-gallery-stage {
  grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
  gap: 10px;
}

.media-gallery[data-layout="contact-sheet"] .media-gallery-canvas { outline: 1px solid var(--line); }
.media-gallery[data-layout="contact-sheet"] .media-gallery-item[data-selected] .media-gallery-canvas { outline: 2px solid var(--accent); }

/* devices: a row of devices, each under its platform label. */
.media-gallery[data-layout="devices"] .media-gallery-stage {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr));
  align-items: end;
}

/* ── Tabs ─────────────────────────────────────────────────────────────── */

.media-gallery-tabs {
  display: flex;
  gap: 4px;
  min-width: 0;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--ink);
  justify-self: start;
  max-width: 100%;
  overflow-x: auto;
  scrollbar-width: none;
}

.media-gallery-tabs[hidden] { display: none; }

.media-gallery-tabs [role="tab"] {
  flex: none;
  min-height: 32px;
  padding: 5px 14px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  transition: color .12s, background .12s;
}

.media-gallery-tabs [role="tab"]:hover { color: var(--text); }

.media-gallery-tabs [role="tab"][aria-selected="true"] {
  background: var(--panel-2);
  color: var(--text);
}

/* ── The transport ────────────────────────────────────────────────────── */

.media-gallery-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding: 6px 10px 6px 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--ink);
}

.media-gallery-controls[hidden] { display: none; }

.media-gallery-play {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--panel-2);
  color: var(--text);
  transition: background .12s;
}

.media-gallery-play:hover { background: var(--line); }
.media-gallery-play svg { width: 14px; height: 14px; }
.media-gallery-play svg[hidden] { display: none; }

.media-gallery-time {
  flex: none;
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.media-gallery-scrub {
  flex: 1 1 auto;
  min-width: 60px;
  height: 20px;
  margin: 0;
  background: transparent;
  accent-color: var(--accent);
  cursor: pointer;
}

/* ── Downloads ────────────────────────────────────────────────────────── */

.media-gallery-downloads {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  margin: 0;
  font-family: var(--mono);
  font-size: 12px;
}

.media-gallery-downloads:empty { display: none; }

.media-gallery-download {
  color: var(--muted);
  text-decoration: underline;
  text-decoration-color: var(--line);
  text-underline-offset: 3px;
}

.media-gallery-download:hover { color: var(--text); text-decoration-color: var(--muted); }

@media (prefers-reduced-motion: reduce) {
  .media-gallery-tabs [role="tab"],
  .media-gallery-play { transition: none; }
}
