/* ==========================================================================
   Zyra product media — manager + gallery
   Tokens: --zyra-* only (zyra-design-system.css). No fixed white/black for
   neutral UI; the only fixed colours are the photo scrim + its white glyphs
   (theme-independent, always over imagery) and DS-style #fff on ink buttons
   is avoided in favour of var(--zyra-paper) on var(--zyra-ink).
   Theme flips via [data-bs-theme="dark"] token overrides in the DS itself.
   ========================================================================== */

/* ---------------------------------------------------------------- manager */
.zyra-media-manager {
  background: var(--zyra-paper);
  color: var(--zyra-ink);
  border: 1px solid var(--zyra-border);
  border-radius: var(--zyra-radius-card);
  padding: 16px;
  box-sizing: border-box;
  max-width: 100%;
}
.zyra-media-manager *, .zyra-media-manager *::before, .zyra-media-manager *::after {
  box-sizing: border-box;
}

.zyra-media-head {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px;
  margin: 0 0 4px;
}
.zyra-media-counter {
  font-size: 15px; font-weight: 700; line-height: 1.35; color: var(--zyra-ink);
  margin: 0;
}
.zyra-media-tier {
  display: inline-flex; align-items: center; gap: 6px;
  padding: .25rem .625rem; border-radius: var(--zyra-radius-pill);
  background: var(--zyra-brand-subtle); color: var(--zyra-ink);
  font-size: 12px; font-weight: 700; line-height: 1.3; white-space: nowrap;
}
.zyra-media-limitcopy {
  font-size: 13px; line-height: 1.45; color: var(--zyra-muted); margin: 0 0 12px;
}
.zyra-media-hint {
  font-size: 13px; line-height: 1.45; color: var(--zyra-muted); margin: 0 0 10px;
}

/* grid: 3 columns on phones, tiles stay >= 72px at 320px wide */
.zyra-media-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px;
  margin: 0 0 12px; padding: 0; list-style: none;
}
@media (min-width: 640px) {
  .zyra-media-grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
}
.zyra-media-empty {
  grid-column: 1 / -1;
  border: 1px dashed var(--zyra-border); border-radius: var(--zyra-radius-well);
  background: var(--zyra-surface); color: var(--zyra-ink);
  font-size: 14px; line-height: 1.45; padding: 18px 14px; text-align: center;
}

.zyra-media-tile {
  position: relative; margin: 0; padding: 0; border: 0; background: none;
  cursor: pointer; text-align: left; font: inherit; color: inherit;
  border-radius: var(--zyra-radius-well); min-height: 44px;
  -webkit-tap-highlight-color: transparent;
}
.zyra-media-tile:focus-visible { outline: 3px solid var(--zyra-brand); outline-offset: 2px; }
.zyra-media-thumb {
  position: relative; display: block; width: 100%; aspect-ratio: 1 / 1;
  border-radius: var(--zyra-radius-well); overflow: hidden;
  background: var(--zyra-surface); border: 1px solid var(--zyra-border);
}
.zyra-media-tile.is-selected .zyra-media-thumb {
  border-color: var(--zyra-brand-dark);
  box-shadow: 0 0 0 2px var(--zyra-brand-dark);
}
[data-bs-theme="dark"] .zyra-media-tile.is-selected .zyra-media-thumb {
  border-color: var(--zyra-ink); box-shadow: 0 0 0 2px var(--zyra-ink);
}
.zyra-media-thumb img {
  width: 100%; height: 100%; object-fit: cover; display: block;
}
.zyra-media-thumb-fallback {
  width: 100%; height: 100%; display: flex; align-items: center; justify-content: center;
  font-size: 30px; color: var(--zyra-muted);
}

/* cover badge: ink pill, paper text (17.74:1 light / 14.05:1 dark) */
.zyra-media-cover-badge {
  position: absolute; top: 6px; left: 6px; z-index: 2;
  display: inline-flex; align-items: center; gap: 4px;
  padding: .2rem .5rem; border-radius: var(--zyra-radius-pill);
  background: var(--zyra-ink); color: var(--zyra-paper);
  font-size: 11px; font-weight: 700; line-height: 1.3;
}
/* video play badge + duration: fixed dark scrim over imagery, white glyphs */
.zyra-media-play {
  position: absolute; inset: 0; z-index: 1;
  display: flex; align-items: center; justify-content: center;
  background: rgba(17, 24, 39, .28); color: #fff; font-size: 34px;
  pointer-events: none;
}
.zyra-media-duration {
  position: absolute; right: 6px; bottom: 6px; z-index: 2;
  padding: .15rem .45rem; border-radius: 6px;
  background: rgba(17, 24, 39, .78); color: #fff;
  font-size: 11px; font-weight: 700; line-height: 1.3;
  font-variant-numeric: tabular-nums;
}
.zyra-media-pending-tag {
  position: absolute; top: 6px; right: 6px; z-index: 2;
  padding: .2rem .5rem; border-radius: var(--zyra-radius-pill);
  background: var(--zyra-brand-subtle); color: var(--zyra-ink);
  font-size: 11px; font-weight: 700; line-height: 1.3;
}

/* uploading tile */
.zyra-media-uploading .zyra-media-thumb {
  display: flex; flex-direction: column; align-items: stretch; justify-content: center;
  gap: 6px; padding: 10px;
}
.zyra-media-upload-name {
  font-size: 12px; font-weight: 600; line-height: 1.35; color: var(--zyra-ink);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.zyra-media-upload-pct {
  font-size: 12px; line-height: 1.35; color: var(--zyra-muted);
  font-variant-numeric: tabular-nums;
}
.zyra-media-progress {
  height: 8px; border-radius: var(--zyra-radius-pill);
  background: var(--zyra-surface); border: 1px solid var(--zyra-border);
  overflow: hidden;
}
.zyra-media-progress-bar {
  height: 100%; width: 0%; border-radius: var(--zyra-radius-pill);
  background: var(--zyra-brand-dark); transition: width .2s ease;
}
[data-bs-theme="dark"] .zyra-media-progress-bar { background: var(--zyra-ink); }

/* selected-tile action bar: every target >= 44px */
.zyra-media-actions {
  display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 14px;
}
.zyra-media-actions[hidden] { display: none; }
.zyra-media-action-btn {
  flex: 1 1 auto; min-height: 44px; min-width: 44px;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: .5rem .75rem; border-radius: var(--zyra-radius-pill);
  border: 1px solid var(--zyra-border); background: var(--zyra-paper);
  color: var(--zyra-ink); font-size: 13px; font-weight: 600; line-height: 1.2;
  cursor: pointer; white-space: nowrap;
}
.zyra-media-action-btn i { font-size: 16px; }
.zyra-media-action-btn:hover { border-color: var(--zyra-ink); }
.zyra-media-action-btn:focus-visible { outline: 3px solid var(--zyra-brand); outline-offset: 2px; }
.zyra-media-action-btn:disabled { opacity: .5; pointer-events: none; }
.zyra-media-action-btn.is-danger { color: var(--zyra-ink); border-color: var(--zyra-danger); }
.zyra-media-action-btn.is-danger i { color: var(--zyra-danger); }

/* add buttons + visible disabled reasons */
.zyra-media-add { display: flex; flex-direction: column; gap: 10px; }
.zyra-media-add-row { display: flex; flex-direction: column; gap: 6px; }
.zyra-media-add .zyra-btn { width: 100%; }
@media (min-width: 640px) {
  .zyra-media-add { flex-direction: row; }
  .zyra-media-add-row { flex: 1 1 0; }
}
.zyra-media-reason {
  font-size: 13px; line-height: 1.45; color: var(--zyra-muted); margin: 0;
}
.zyra-media-reason[hidden] { display: none; }
.zyra-media-reason a { color: var(--zyra-brand-dark); font-weight: 700; }
[data-bs-theme="dark"] .zyra-media-reason a { color: var(--zyra-ink); text-decoration: underline; }

.zyra-media-status {
  font-size: 13px; line-height: 1.45; color: var(--zyra-muted);
  margin: 10px 0 0; min-height: 1.45em;
}
.zyra-media-status[hidden] { display: none; }
.zyra-media-error {
  display: flex; gap: 8px; align-items: flex-start;
  border: 1px solid var(--zyra-danger); border-left-width: 4px;
  border-radius: var(--zyra-radius-well);
  background: var(--zyra-paper); color: var(--zyra-ink);
  font-size: 13px; line-height: 1.45; padding: 10px 12px; margin: 10px 0 0;
}
.zyra-media-error[hidden] { display: none; }
.zyra-media-error i { color: var(--zyra-danger); font-size: 17px; flex-shrink: 0; margin-top: 1px; }
.zyra-media-file-input { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; }

/* --------------------------------------------------------------- gallery */
/* Stage keeps the existing .zyra-detail-gallery 1:1 well behaviour. */
.zyra-media-stage { touch-action: pan-y; height: 100%; }
.zyra-media-stage-media { width: 100%; height: 100%; display: block; }
.zyra-media-stage img.zyra-media-stage-media { object-fit: cover; }
.zyra-media-stage video.zyra-media-stage-media { object-fit: contain; background: var(--zyra-surface); }
.zyra-media-stage:focus-visible { outline: 3px solid var(--zyra-brand); outline-offset: 2px; }
.zyra-media-stage-count {
  position: absolute; right: 12px; bottom: 12px; z-index: 2;
  padding: .2rem .55rem; border-radius: var(--zyra-radius-pill);
  background: rgba(17, 24, 39, .78); color: #fff;
  font-size: 12px; font-weight: 700; line-height: 1.3;
  font-variant-numeric: tabular-nums; pointer-events: none;
}
.zyra-media-stage-play {
  position: absolute; inset: 0; z-index: 1;
  display: flex; align-items: center; justify-content: center;
  background: rgba(17, 24, 39, .28); color: #fff; font-size: 56px;
  pointer-events: none;
}
.zyra-media-stage-play[hidden] { display: none; }

/* thumbs: horizontal scroll-snap strip, 64px thumbs, 44px+ targets */
.zyra-media-thumbs {
  display: flex; gap: 8px; overflow-x: auto; padding: 10px 2px 6px;
  scroll-snap-type: x mandatory; -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.zyra-media-thumbs::-webkit-scrollbar { display: none; }
.zyra-media-thumb-btn {
  position: relative; flex: 0 0 auto; width: 64px; height: 64px;
  padding: 0; border: 1px solid var(--zyra-border);
  border-radius: var(--zyra-radius-well); overflow: hidden;
  background: var(--zyra-surface); cursor: pointer; scroll-snap-align: start;
  -webkit-tap-highlight-color: transparent;
}
.zyra-media-thumb-btn img { width: 100%; height: 100%; object-fit: cover; display: block; }
.zyra-media-thumb-btn:focus-visible { outline: 3px solid var(--zyra-brand); outline-offset: 2px; }
.zyra-media-thumb-btn.is-active {
  border-color: var(--zyra-brand-dark); box-shadow: 0 0 0 2px var(--zyra-brand-dark);
}
[data-bs-theme="dark"] .zyra-media-thumb-btn.is-active {
  border-color: var(--zyra-ink); box-shadow: 0 0 0 2px var(--zyra-ink);
}
.zyra-media-thumb-btn .zyra-media-play { font-size: 20px; }
.zyra-media-thumb-btn .zyra-media-duration { right: 4px; bottom: 4px; font-size: 10px; }

/* Server-rendered product-page thumbs (class zyra-media-thumb + badge). */
.zyra-media-thumbs .zyra-media-thumb {
  position: relative; flex: 0 0 auto; width: 64px; height: 64px;
  padding: 0; border: 1px solid var(--zyra-border);
  border-radius: var(--zyra-radius-well); overflow: hidden;
  background: var(--zyra-surface); cursor: pointer; scroll-snap-align: start;
  -webkit-tap-highlight-color: transparent;
}
.zyra-media-thumbs .zyra-media-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.zyra-media-thumbs .zyra-media-thumb:focus-visible { outline: 3px solid var(--zyra-brand); outline-offset: 2px; }
.zyra-media-thumbs .zyra-media-thumb.is-active {
  border-color: var(--zyra-brand-dark); box-shadow: 0 0 0 2px var(--zyra-brand-dark);
}
[data-bs-theme="dark"] .zyra-media-thumbs .zyra-media-thumb.is-active {
  border-color: var(--zyra-ink); box-shadow: 0 0 0 2px var(--zyra-ink);
}
.zyra-media-badge {
  position: absolute; right: 4px; bottom: 4px;
  display: inline-flex; align-items: center; gap: 3px;
  padding: 2px 6px; border-radius: var(--zyra-radius-pill);
  background: rgba(17, 24, 39, 0.82); color: #fff;
  font-size: 10px; font-weight: 600; line-height: 1.4;
}
.zyra-media-badge i { font-size: 11px; }

/* dots: DS visuals, enlarged 44px-tall hit area for touch */
.zyra-media-dots { display: flex; justify-content: center; gap: 2px; padding: 2px 0 4px; }
.zyra-media-dots .zyra-gallery-dot {
  width: 28px; height: 44px; padding: 0; border: 0; border-radius: 0;
  background: transparent; cursor: pointer; position: relative;
}
.zyra-media-dots .zyra-gallery-dot::after {
  content: ""; position: absolute; left: 50%; top: 50%;
  width: 8px; height: 8px; border-radius: var(--zyra-radius-pill);
  background: var(--zyra-border); transform: translate(-50%, -50%);
}
.zyra-media-dots .zyra-gallery-dot.is-active { width: 36px; background: transparent; }
.zyra-media-dots .zyra-gallery-dot.is-active::after { width: 20px; background: var(--zyra-ink); }
.zyra-media-dots .zyra-gallery-dot:focus-visible { outline: 3px solid var(--zyra-brand); outline-offset: -3px; }
