/**
 * Media Gallery screen styles (v5-mini-app-5-2)
 *
 * All colors use CSS custom properties set from Telegram themeParams by app.js.
 */

/* ── Layout ──────────────────────────────────────────────────────────────── */

.media-screen {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding-bottom: 72px; /* clear tab bar */
}

/* ── Filter chips ────────────────────────────────────────────────────────── */

.filter-bar {
  display: flex;
  gap: 8px;
  padding: 10px 16px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  flex-shrink: 0;
}

.filter-bar::-webkit-scrollbar { display: none; }

.chip {
  display: inline-flex;
  align-items: center;
  padding: 6px 14px;
  border-radius: 16px;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  border: 1.5px solid var(--cl-link);
  min-height: 32px;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.1s, color 0.1s;
}

.chip--active {
  background: var(--cl-link);
  color: #fff;
}

.chip--inactive {
  background: transparent;
  color: var(--cl-link);
}

/* ── Media grid (photos) ─────────────────────────────────────────────────── */

.media-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2px;
  padding: 0;
}

.media-grid__item {
  aspect-ratio: 1;
  overflow: hidden;
  background: var(--cl-secondary-bg);
  cursor: pointer;
  position: relative;
}

.media-grid__img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* ── Voice cards ─────────────────────────────────────────────────────────── */

.media-list {
  display: flex;
  flex-direction: column;
}

.voice-card,
.doc-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--cl-bg);
  border-bottom: 1px solid rgba(128, 128, 128, 0.12);
}

.voice-card__play {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--cl-link);
  color: #fff;
  border: none;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.voice-card__waveform {
  display: flex;
  align-items: center;
  gap: 2px;
  flex: 1;
  height: 32px;
}

.waveform-bar {
  width: 3px;
  background: var(--cl-hint);
  border-radius: 2px;
  min-height: 4px;
}

.waveform-bar--playing {
  background: var(--cl-link);
}

.voice-card__meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1;
}

.voice-card__transcript {
  font-size: 13px;
  color: var(--cl-hint);
  margin-top: 4px;
  line-height: 1.4;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.voice-card__duration {
  font-size: 12px;
  color: var(--cl-hint);
  margin-top: 2px;
}

.voice-card__transcript--loading {
  color: var(--cl-hint);
}

/* ── Document cards ──────────────────────────────────────────────────────── */

.doc-card__icon {
  font-size: 32px;
  flex-shrink: 0;
}

.doc-card__name {
  font-size: 14px;
  color: var(--cl-text);
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.doc-card__size {
  font-size: 12px;
  color: var(--cl-hint);
}

/* ── See event link ──────────────────────────────────────────────────────── */

.see-event-link {
  font-size: 12px;
  color: var(--cl-link);
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  text-decoration: underline;
  -webkit-tap-highlight-color: transparent;
  flex-shrink: 0;
}

/* ── Photo lightbox ──────────────────────────────────────────────────────── */

.lightbox-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.92);
  z-index: 300;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.lightbox-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 44px;
  height: 44px;
  background: rgba(255, 255, 255, 0.15);
  border: none;
  border-radius: 50%;
  color: #fff;
  font-size: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.lightbox-img {
  max-width: 100%;
  max-height: 80vh;
  object-fit: contain;
}

.lightbox-actions {
  position: absolute;
  bottom: 80px;
  display: flex;
  gap: 16px;
}

/* L3 fix: lightbox "See event" uses theme-aware text color, not hardcoded #fff */
.lightbox-see-event {
  font-size: 14px;
  color: var(--cl-btn-text);
}

/* ── Skeleton loading ────────────────────────────────────────────────────── */

@keyframes skeleton-shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.skeleton-cell {
  background: linear-gradient(
    90deg,
    var(--cl-secondary-bg) 25%,
    rgba(128, 128, 128, 0.08) 50%,
    var(--cl-secondary-bg) 75%
  );
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s infinite;
}

.skeleton-card-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid rgba(128, 128, 128, 0.12);
}

.skeleton-circle {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  flex-shrink: 0;
}

.skeleton-lines {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.skeleton-line {
  height: 12px;
  border-radius: 4px;
}

.skeleton-line--short { width: 45%; }
.skeleton-line--long  { width: 70%; }

/* ── Retry button ────────────────────────────────────────────────────────── */

.media-retry-btn {
  margin-top: 12px;
  padding: 8px 16px;
  background: var(--cl-btn);
  color: var(--cl-btn-text);
  border: none;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
}

/* ── Error / empty states ────────────────────────────────────────────────── */

.media-error,
.media-empty {
  padding: 40px 16px;
  text-align: center;
  color: var(--cl-hint);
  font-size: 14px;
}

.media-empty__icon {
  font-size: 40px;
  margin-bottom: 12px;
}

/* ── Load more indicator ─────────────────────────────────────────────────── */

.load-more-sentinel {
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--cl-secondary-bg);
  border-top-color: var(--cl-link);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }
