/* The gallery of captures (js/capture-gallery/capture-gallery.js, js/capture/capture-gallery-viewer.js), over the
   whole screen. Frame, rail and page are the Store's (CommunityStore.css), so it looks the
   same under every skin; only what is the gallery's own lives here. The keys are its own
   too: .ui-btn would take each skin's look. */

/* The viewer and the editor are a dark room on every appearance: a picture is judged
   against black, and the keys around it must not change with the theme. */
.capg-viewer, .cann {
  --cst-well: rgba(255, 255, 255, 0.1);
  --cst-on: rgba(255, 255, 255, 0.18);
  --cst-sep: rgba(255, 255, 255, 0.12);
  --cst-text: #f2f4f3;
  --cst-muted: #a2a9ad;
  --cst-key: #6ee787;
  --cst-key-ink: #0b2412;
  --cst-danger: #ff7a6b;
  --cst-solid: rgb(16, 19, 26);
}

/* ── Keys ── */
.capg-key {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 44px; padding: 0 18px;
  border: 0; border-radius: 10px;
  font: inherit; font-size: 15px; font-weight: 600; text-decoration: none;
  color: var(--cst-text); background: var(--cst-well);
  cursor: pointer;
}
.capg-key:not(.is-main):hover { background: var(--cst-on); }
.capg-key.is-main { color: var(--cst-key-ink); background: var(--cst-key); }
.capg-key:disabled { opacity: 0.5; cursor: default; }
.capg-key:focus-visible { outline: 2px solid var(--cst-key); outline-offset: 2px; }
.capg-modal .cgal-iconbtn {
  width: 44px; height: 44px;
  border: 0; border-radius: 10px;
  color: var(--cst-text); background: var(--cst-well);
}
.capg-modal .cgal-iconbtn:hover { background: var(--cst-on); }
.capg-modal .cgal-iconbtn:focus-visible { outline: 2px solid var(--cst-key); outline-offset: 2px; }

/* ── The rail ── */
.capg-games { padding-top: 12px; border-top: 1px solid var(--cst-sep); }
.capg-games[hidden] { display: none; }
.capg-rail-used { margin-top: auto; padding: 10px; font-size: 13.5px; font-weight: 600; color: var(--cst-muted); }

/* ── The pictures, by day ── */
.capg-day + .capg-day { margin-top: 30px; }
.capg-day-title { margin: 0 0 12px; font-size: 20px; font-weight: 700; color: var(--cst-text); }
.capg-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(280px, 100%), 1fr)); gap: 20px 16px; }
.capg-tile {
  appearance: none; border: 0; background: none; padding: 0; margin: 0; cursor: pointer;
  font: inherit; color: inherit; text-align: left;
  display: flex; flex-direction: column; gap: 8px; min-width: 0; border-radius: 10px;
}
.capg-tile:focus-visible { outline: none; }
.capg-tile:focus-visible .capg-thumb { outline: 2px solid var(--cst-key); outline-offset: 2px; }
.capg-thumb {
  position: relative; display: grid; place-items: center; overflow: hidden;
  aspect-ratio: 16 / 9; border-radius: 10px;
  background: var(--cst-well);
}
.capg-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform 0.2s ease; }
.capg-tile:hover .capg-thumb img { transform: scale(1.03); }
.capg-thumb-ic { font-size: 30px; color: var(--cst-muted); }
.capg-len {
  position: absolute; right: 8px; bottom: 8px; padding: 2px 6px; border-radius: 4px;
  background: rgba(0, 0, 0, 0.72);
  font-size: 13px; font-weight: 700; color: #fff;
}
.capg-meta { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.capg-game, .capg-when { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.capg-game { font-size: 15px; font-weight: 600; color: var(--cst-text); }
.capg-when { font-size: 13.5px; color: var(--cst-muted); }
.capg-more { display: flex; margin: 24px auto 0; }
.cst .capg-status {
  display: grid; place-content: center; justify-items: center; gap: 16px;
  min-height: 100%; padding: 16px;
  text-align: center; color: var(--cst-muted);
}

/* ── Viewer: over the page, inside the same dialog, and over its close key ── */
.capg-viewer {
  position: absolute; inset: 0; z-index: 4;
  display: flex; flex-direction: column; min-height: 0;
  color: var(--cst-text); background: #000;
}
.capg-vtop { display: flex; align-items: center; gap: 12px; flex: none; padding: 12px 16px; }
.capg-vtitle { min-width: 0; }
.capg-vname, .capg-vsub { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.capg-vname { font-size: 18px; font-weight: 700; }
.capg-vsub { margin-top: 2px; font-size: 14px; color: var(--cst-muted); }
.capg-stage { position: relative; flex: 1; min-height: 0; display: grid; place-items: center; overflow: hidden; }
.capg-media { display: block; max-width: 100%; max-height: 100%; object-fit: contain; }
video.capg-media { width: 100%; height: 100%; }
.capg-modal .capg-nav { position: absolute; top: 50%; transform: translateY(-50%); color: #fff; background: rgba(0, 0, 0, 0.55); }
.capg-modal .capg-nav:hover { background: rgba(0, 0, 0, 0.75); }
/* No arrow where there is nowhere to go, and none while trimming (the arrows
   move the handles then). */
.capg-nav:disabled, .capg-viewer.is-trimming .capg-nav { visibility: hidden; }
.capg-nav-prev { left: 12px; }
.capg-nav-next { right: 12px; }
/* The video's moments (bookmarks and stutters): one row under the video that
   scrolls sideways inside itself when there are many. Hidden while trimming. */
.capg-marks {
  display: flex; gap: 8px; flex: none; padding: 10px 16px 0; overflow-x: auto;
  justify-content: safe center; scrollbar-width: thin;
}
.capg-marks[hidden], .capg-viewer.is-trimming .capg-marks { display: none; }
.capg-mark {
  display: inline-flex; align-items: center; gap: 6px; flex: none; min-height: 44px; padding: 0 12px;
  border: 0; border-radius: 10px;
  font: inherit; font-size: 14px; font-weight: 600;
  color: var(--cst-text); background: var(--cst-well); cursor: pointer;
}
.capg-mark:hover { background: var(--cst-on); }
.capg-mark:focus-visible { outline: 2px solid var(--cst-key); outline-offset: -2px; }
.capg-mark .cgal-ic { display: inline-flex; width: 16px; height: 16px; }
.capg-mark .cgal-ic svg { width: 100%; height: 100%; }
.capg-mark-stutter .cgal-ic { color: var(--amber, #f2b544); }
.capg-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; flex: none; padding: 12px 16px; }
.capg-key.capg-del { color: var(--cst-danger); }
.capg-say { flex: none; padding: 0 16px 12px; text-align: center; font-size: 14px; color: var(--cst-muted); }
.capg-say:empty { display: none; }
.capg-say.is-bad { color: var(--cst-danger); }
.capg-note { width: 100%; text-align: center; font-size: 14px; color: var(--cst-muted); }

/* ── Trim: two handles on the clip's bar ── */
.capg-actions.is-trim { flex-direction: column; align-items: stretch; gap: 10px; }
.capg-trimbar { position: relative; height: 48px; margin: 0 18px; cursor: pointer; touch-action: none; }
.capg-trimbar::before {
  content: ''; position: absolute; left: 0; right: 0; top: 50%; height: 8px; transform: translateY(-50%);
  border-radius: 4px; background: var(--cst-on);
}
.capg-kept { position: absolute; top: 50%; height: 8px; transform: translateY(-50%); border-radius: 4px; background: var(--cst-key); }
.capg-playhead { position: absolute; top: 8px; bottom: 8px; width: 2px; margin-left: -1px; background: var(--cst-text); pointer-events: none; }
.capg-handle {
  position: absolute; top: 50%; width: 16px; height: 36px; padding: 0; transform: translate(-50%, -50%);
  border: 0; border-radius: 6px; background: var(--cst-text); cursor: ew-resize; touch-action: none;
}
/* A finger-sized hit area around the narrow grip. */
.capg-handle::before { content: ''; position: absolute; inset: -6px -14px; }
.capg-handle:focus-visible { outline: 2px solid var(--cst-key); outline-offset: 2px; }
.capg-times { text-align: center; font-size: 15px; font-weight: 600; }
.capg-trim-row { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }

/* ── Export: a vertical, smaller or GIF copy (capture-export-view.js) ── */
.capg-exp-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 4px 10px; min-width: 0; }
.capg-exp-label { font-size: 14px; color: var(--cst-muted); }
.capg-exp-seg { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px; min-width: 0; }
.capg-exp-opt {
  appearance: none; min-height: 44px; min-width: 44px; padding: 0 14px;
  border: 0; border-radius: 10px;
  font: inherit; font-size: 15px; font-weight: 600;
  color: var(--cst-muted); background: none; cursor: pointer;
}
.capg-exp-opt:hover { color: var(--cst-text); background: var(--cst-well); }
.capg-exp-opt[aria-pressed="true"] { color: var(--cst-text); background: var(--cst-on); }
.capg-exp-opt:focus-visible { outline: 2px solid var(--cst-key); outline-offset: -2px; }
.capg-note.is-warn { color: var(--amber, #f2b544); }
.capg-exp-status:empty { display: none; }
.capg-exp-status.is-bad { color: var(--cst-danger); }
.capg-exp-bar { height: 8px; margin: 6px 18px 0; border-radius: 4px; background: var(--cst-on); overflow: hidden; }
.capg-exp-fill { width: 0; height: 100%; border-radius: 4px; background: var(--cst-key); transition: width 0.3s ease; }

/* ── Transcript: the video's words, beside it or under it (capture-transcript-view.js) ── */
.capg-key.capg-tx-btn[aria-pressed="true"] { background: var(--cst-on); }
.capg-tx {
  flex: 0 1 38%; min-height: 0; display: flex; flex-direction: column;
  border-top: 1px solid var(--cst-sep);
}
.capg-tx-status { flex: none; padding: 10px 16px 0; font-size: 14px; color: var(--cst-muted); }
.capg-tx-status:empty { display: none; }
.capg-tx-status.is-bad { color: var(--cst-danger); }
.capg-tx-body { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 6px 10px 8px; }
.capg-tx-summary { margin: 4px 6px 10px; font-size: 15px; line-height: 1.45; }
.capg-tx-label { margin: 4px 6px; font-size: 14px; font-weight: 700; color: var(--cst-muted); }
.capg-tx-chapters { margin-bottom: 8px; }
.capg-tx-chapter, .capg-tx-line {
  display: flex; gap: 10px; width: 100%; min-height: 40px; padding: 8px 6px; align-items: baseline;
  border: 0; border-radius: 6px; background: none; text-align: left; cursor: pointer;
  font: inherit; color: var(--cst-text);
}
.capg-tx-chapter { font-weight: 600; }
.capg-tx-chapter:hover, .capg-tx-line:hover { background: var(--cst-well); }
.capg-tx-chapter:focus-visible, .capg-tx-line:focus-visible { outline: 2px solid var(--cst-key); outline-offset: -2px; }
.capg-tx-line.is-now { background: var(--cst-on); }
.capg-tx-line.is-now .capg-tx-at { color: var(--cst-key); }
.capg-tx-at { flex: none; min-width: 3.2em; font-size: 13.5px; color: var(--cst-muted); }
.capg-tx-text { min-width: 0; font-size: 15px; line-height: 1.4; overflow-wrap: anywhere; }
.capg-tx-foot { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; flex: none; padding: 8px 16px 12px; }
.capg-tx-foot:empty { display: none; }

/* Wide enough, the words sit beside the video, which keeps its height. */
@media (min-width: 1100px) {
  .capg-viewer {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-rows: auto minmax(0, 1fr) auto auto auto;
  }
  .capg-vtop { grid-column: 1 / -1; }
  .capg-stage, .capg-marks, .capg-actions, .capg-say { grid-column: 1; }
  .capg-tx { grid-column: 2; grid-row: 2 / -1; width: 400px; border-top: 0; border-left: 1px solid var(--cst-sep); }
}

@media (max-width: 640px) {
  .capg-rail-used { display: none; }
  .capg-games { padding-top: 0; border-top: 0; }
  .capg-day + .capg-day { margin-top: 24px; }
  .capg-day-title { font-size: 18px; }
  .capg-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 14px 10px; }
  .capg-thumb, .capg-tile { border-radius: 6px; }
  .capg-vtop { padding: 10px 12px; }
  .capg-actions { padding: 10px 12px; }
  .capg-actions .capg-key, .capg-tx-foot .capg-key { flex: 1 1 calc(50% - 8px); padding: 0 10px; }
  .capg-trimbar { margin: 0 14px; }
  .capg-tx { flex-basis: 42%; }
}
@media (prefers-reduced-motion: reduce) {
  .capg-thumb img { transition: none; }
  .capg-tile:hover .capg-thumb img { transform: none; }
  .capg-exp-fill { transition: none; }
}
