/* ── Gallery page shell ─────────────────────────────────────── */
[data-page="gallery"].gallery-page {
  min-width: 0;
}

.gallery-body {
  position: relative; /* slider is an absolutely-positioned child */
}

/* ── Album grid ─────────────────────────────────────────────── */
.gallery-grid {
  flex: 1;
  overflow-y: auto;
  padding: 18px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
  align-content: start;
}

.gallery-card {
  display: flex;
  flex-direction: column;
  padding: 0;
  background: var(--surface-1);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-card);
  overflow: hidden;
  cursor: pointer;
  text-align: left;
  transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
  color: var(--text);
  font-family: inherit;
}

.gallery-card:hover,
.gallery-card:focus-visible {
  transform: translateY(-2px);
  border-color: rgba(var(--accent-rgb), 0.45);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.18);
  outline: none;
}

.gallery-card__cover {
  aspect-ratio: 16 / 10;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(circle at 30% 20%, rgba(var(--accent-rgb), 0.22), transparent 55%),
    linear-gradient(135deg, var(--surface-2), var(--surface-1));
  border-bottom: 1px solid var(--glass-border);
}

.gallery-card__glyph {
  font-size: 48px;
  opacity: 0.75;
  filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.25));
}

.gallery-card__meta {
  padding: 12px 14px 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

.gallery-card__title {
  font-size: 14px;
  font-weight: 800;
  letter-spacing: -0.01em;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.gallery-card__sub {
  font-size: 11px;
  color: var(--text-subtle);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.gallery-card__cta {
  padding: 10px 14px 12px;
  font-size: 11px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* ── Slider ─────────────────────────────────────────────────── */
/* The slider lives INSIDE .gallery-body (which is position:relative),
   so inset:0 pins it to that section rather than the whole viewport.
   TV mode escapes this box via Fullscreen API on the same element. */
.gallery-slider {
  position: absolute;
  inset: 0;
  background: #050506;
  border-radius: var(--radius-panel);
  display: flex;
  overflow: hidden;
  user-select: none;
}

/* When the slider goes into browser fullscreen (TV mode), it's
   re-parented to the :fullscreen layer and needs to fill the screen.
   The radius and inset adjustments below undo the in-body styling. */
.gallery-slider:fullscreen,
.gallery-slider:-webkit-full-screen {
  border-radius: 0;
  width: 100vw;
  height: 100vh;
}

.gallery-slider__stage {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.gallery-slider__img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  animation: gallery-slider-fade 0.55s ease;
  will-change: opacity;
}

@keyframes gallery-slider-fade {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.gallery-slider__loading,
.gallery-slider__error {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: #e8e8ec;
  text-align: center;
  padding: 24px;
}

.gallery-slider__loading-title {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #f5f5f7;
}

.gallery-slider__loading-msg {
  font-size: 12px;
  color: #9a9aa0;
  min-height: 1.2em;
}

.gallery-slider__progress {
  width: min(360px, 70vw);
  height: 4px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.gallery-slider__progress-fill {
  height: 100%;
  background: linear-gradient(90deg, rgba(var(--accent-rgb), 0.7), rgba(var(--accent-rgb), 1));
  transition: width 0.28s ease;
}

/* ── Close (top-right, always visible) ──────────────────────── */
.gallery-slider__close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(6px);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.12);
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.18s ease, transform 0.18s ease, opacity 0.25s ease;
  z-index: 3;
}

.gallery-slider__close:hover {
  background: rgba(0, 0, 0, 0.8);
  transform: scale(1.05);
}

/* ── Chrome (caption + control bar) ─────────────────────────── */
.gallery-slider__chrome {
  position: absolute;
  inset: auto 0 0 0;
  padding: 18px 18px 22px;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  color: #f5f5f7;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.72) 0%, rgba(0, 0, 0, 0) 100%);
  transition: opacity 0.3s ease, transform 0.3s ease;
  z-index: 2;
}

.gallery-slider__caption {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  max-width: 55%;
}

.gallery-slider__album {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: rgba(255, 255, 255, 0.6);
}

.gallery-slider__title {
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.01em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.gallery-slider__date {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.6);
}

.gallery-slider__controls {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: rgba(20, 20, 24, 0.68);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  color: #f5f5f7;
}

.gallery-slider__btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: #f5f5f7;
  cursor: pointer;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease, transform 0.15s ease;
}

.gallery-slider__btn:hover {
  background: rgba(255, 255, 255, 0.1);
  transform: scale(1.05);
}

.gallery-slider__btn--play {
  background: rgba(var(--accent-rgb), 0.2);
}

.gallery-slider__btn--play:hover {
  background: rgba(var(--accent-rgb), 0.35);
}

.gallery-slider__divider {
  width: 1px;
  height: 22px;
  background: rgba(255, 255, 255, 0.14);
  margin: 0 2px;
}

.gallery-slider__interval {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.75);
  padding: 0 4px;
}

.gallery-slider__interval select {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
}

.gallery-slider__counter {
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  color: rgba(255, 255, 255, 0.72);
  padding: 0 6px;
  min-width: 54px;
  text-align: center;
}

/* ── TV mode (fullscreen, chrome auto-hides) ────────────────── */
.gallery-slider.is-tv {
  background: #000;
}

.gallery-slider.is-tv .gallery-slider__caption {
  font-size: larger; /* caption scales up slightly for across-the-room reading */
}

.gallery-slider.is-tv .gallery-slider__title {
  font-size: 22px;
}

.gallery-slider.is-tv.chrome-hidden .gallery-slider__chrome,
.gallery-slider.is-tv.chrome-hidden .gallery-slider__close {
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
}

.gallery-slider.is-tv {
  cursor: none;
}

.gallery-slider.is-tv:not(.chrome-hidden) {
  cursor: default;
}

/* Responsive: narrow screens stack chrome vertically */
@media (max-width: 560px) {
  .gallery-slider__chrome {
    flex-direction: column;
    align-items: stretch;
  }
  .gallery-slider__caption {
    max-width: 100%;
  }
  .gallery-slider__controls {
    align-self: center;
  }
}
