/* --- Global Setup --- */
body {
  display: flex;
  justify-content: center;
  padding: 100px 24px 60px;
}

/* --- Layout --- */
.container {
  width: 100%;
  max-width: var(--max-width);
}

h1 {
  font-size: 2rem;
  font-weight: 600;
  margin-bottom: 40px;
  text-align: center;
}

/* --- Video Grid --- */
.video-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: var(--gap);
}

/* --- Video Card --- */
.video-card {
  background: transparent;
  border: none;
  padding: 0;
  text-align: center;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  cursor: pointer;
  border-radius: var(--radius);
  position: relative;
  font-family: inherit;

  /* Focus visible */
  &:focus-visible {
    outline: 2px solid var(--md-sys-color-primary);
    outline-offset: 2px;
    border-radius: var(--radius);
  }
}

.video-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--card-hover-elevation);
}

/* Video thumbnail */
.video-card img {
  width: 90%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: var(--radius);
  display: block;
  position: relative;
}

.video-card img.img-broken {
  opacity: 0.5;
  background: var(--muted);
}

/* Play icon overlay */
.video-card::before {
  content: '▶';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 3rem;
  color: rgba(255, 255, 255, 0.9);
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  opacity: 0.6;
  transition: opacity 0.15s ease, transform 0.15s ease;
  pointer-events: none;
  border-radius: 50%;
  width: 60px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle, rgba(0, 0, 0, 0.2), rgba(0, 0, 0, 0) 70%);
}

.video-card:hover::before {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1.1);
}

/* Category label */
.video-card__category {
  display: block;
  font-size: 0.875rem;
  color: var(--muted);
  margin-top: 12px;
  font-weight: 400;
}

/* Video title */
.video-card__title {
  font-size: 1rem;
  font-weight: 500;
  color: var(--fg);
  margin-top: 4px;
  line-height: 1.4;
  text-overflow: ellipsis;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
}

/* --- Video Player Modal --- */
.video-player {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  z-index: 999;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  opacity: 0;
  transition: opacity 0.15s ease;
  padding: 20px;
}

.video-player.open {
  display: flex;
  opacity: 1;
}

/* Video element */
.video-player video {
  max-width: min(90vw, 1000px);
  max-height: 90vh;
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
  border-radius: var(--radius);
  background: #000;
  object-fit: contain;
}

/* Close button */
.video-player__close {
  position: absolute;
  top: 24px;
  right: 24px;
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: #fff;
  font-size: 2rem;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease;
  z-index: 1000;

  &:hover {
    background: rgba(255, 255, 255, 0.3);
  }

  &:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 2px;
  }
}

/* --- Empty State --- */
.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 60px 20px;
  font-size: 1.125rem;
  color: var(--muted);
}

/* --- Error State --- */
.error-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 60px 20px;
  background: rgba(255, 0, 0, 0.05);
  border-radius: var(--radius);
  border: 1px solid rgba(255, 0, 0, 0.1);
}

.error-state p {
  color: var(--fg);
  margin-bottom: 20px;
  font-size: 1rem;
}

.retry-button {
  background: var(--fg);
  color: var(--bg);
  border: none;
  padding: 12px 24px;
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: opacity 0.15s ease;
}

.retry-button:hover {
  opacity: 0.8;
}

.retry-button:focus-visible {
  outline: 2px solid var(--fg);
  outline-offset: 2px;
}

/* --- Responsive Design --- */
@media (max-width: 599px) {
  body {
    padding: 96px 16px 40px;
  }

  h1 {
    font-size: 1.5rem;
    margin-bottom: 32px;
  }

  .video-grid {
    gap: 24px;
  }

  .video-player {
    padding: 16px;
  }

  .video-player video {
    max-width: min(95vw, 600px);
  }

  .video-player__close {
    top: 16px;
    right: 16px;
    width: 40px;
    height: 40px;
    font-size: 1.5rem;
  }
}

@media (max-width: 899px) {
  /* Tablet adjustments if needed */
}

/* --- Reduced Motion Support --- */
@media (prefers-reduced-motion: reduce) {
  .video-card,
  .video-card::before,
  .video-player,
  .retry-button,
  .video-player__close {
    transition: none !important;
    animation-duration: 0.01ms !important;
  }
}

/* --- Dark Mode Support (inherited from theme) --- */
/* Colors auto-adjust via CSS variables from main style.css */
