/* ==========================================================================
   Anchor Video Gallery - Frontend Styles
   ========================================================================== */

/* CSS Custom Properties */
.anchor-video-gallery {
  --avg-gap: 16px;
  --avg-radius: 12px;
  --avg-cols-desktop: 4;
  --avg-cols-tablet: 3;
  --avg-cols-mobile: 1;

  /* Theme colors - Dark (default) */
  --avg-bg: #0f172a;
  --avg-bg-hover: #1e293b;
  --avg-text: #f1f5f9;
  --avg-text-muted: #94a3b8;
  --avg-border: #334155;
  --avg-overlay: rgba(0, 0, 0, 0.6);
  --avg-play-bg: rgba(255, 255, 255, 0.9);
  --avg-play-color: #0f172a;

  position: relative;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* Theme: Light */
.avg-theme-light {
  --avg-bg: #ffffff;
  --avg-bg-hover: #f8fafc;
  --avg-text: #1e293b;
  --avg-text-muted: #64748b;
  --avg-border: #e2e8f0;
  --avg-overlay: rgba(0, 0, 0, 0.4);
  --avg-play-bg: rgba(15, 23, 42, 0.85);
  --avg-play-color: #ffffff;
}

/* Theme: Auto (respects system preference) */
@media (prefers-color-scheme: light) {
  .avg-theme-auto {
    --avg-bg: #ffffff;
    --avg-bg-hover: #f8fafc;
    --avg-text: #1e293b;
    --avg-text-muted: #64748b;
    --avg-border: #e2e8f0;
    --avg-overlay: rgba(0, 0, 0, 0.4);
    --avg-play-bg: rgba(15, 23, 42, 0.85);
    --avg-play-color: #ffffff;
  }
}

/* ==========================================================================
   Base Track & Tile Styles
   ========================================================================== */

.avg-track {
  display: flex;
  gap: var(--avg-gap);
}

.avg-tile {
  cursor: pointer;
  outline: none;
  -webkit-tap-highlight-color: transparent;
}

.avg-tile.avg-hidden {
  display: none;
}

.avg-tile-inner {
  background: var(--avg-bg);
  border-radius: var(--avg-radius);
  overflow: hidden;
  height: 100%;
  display: flex;
  flex-direction: column;
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.avg-thumb {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: linear-gradient(135deg, var(--avg-bg), var(--avg-border));
  background-size: cover;
  background-position: center;
  overflow: hidden;
}

.avg-meta {
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.avg-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--avg-text);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.avg-channel {
  font-size: 12px;
  color: var(--avg-text-muted);
}

.avg-duration {
  position: absolute;
  bottom: 8px;
  right: 8px;
  background: rgba(0, 0, 0, 0.8);
  color: #fff;
  font-size: 12px;
  font-weight: 500;
  padding: 2px 6px;
  border-radius: 4px;
  letter-spacing: 0.02em;
}

/* ==========================================================================
   Play Button Styles
   ========================================================================== */

.avg-play {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.9;
  transition: opacity 0.2s, transform 0.2s;
}

.avg-tile:hover .avg-play,
.avg-tile:focus .avg-play {
  opacity: 1;
  transform: scale(1.1);
}

.avg-play svg {
  width: 60px;
  height: 60px;
  filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.4));
}

/* Play style: Circle */
.avg-play-circle .avg-play svg {
  color: var(--avg-play-bg);
}

/* Play style: YouTube */
.avg-play-youtube .avg-play svg {
  width: 68px;
  height: 48px;
}

/* Play style: Minimal */
.avg-play-minimal .avg-play svg {
  width: 48px;
  height: 48px;
  color: rgba(255, 255, 255, 0.95);
}

/* Play style: Square */
.avg-play-square .avg-play svg {
  width: 50px;
  height: 50px;
  color: var(--avg-play-bg);
}

/* ==========================================================================
   Hover Effects
   ========================================================================== */

/* Hover: Lift */
.avg-hover-lift .avg-tile:hover .avg-tile-inner,
.avg-hover-lift .avg-tile:focus .avg-tile-inner {
  transform: translateY(-6px);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.25);
}

/* Hover: Zoom */
.avg-hover-zoom .avg-tile:hover .avg-thumb,
.avg-hover-zoom .avg-tile:focus .avg-thumb {
  transform: scale(1.05);
}

.avg-hover-zoom .avg-thumb {
  transition: transform 0.3s ease;
}

/* Hover: Glow */
.avg-hover-glow .avg-tile:hover .avg-tile-inner,
.avg-hover-glow .avg-tile:focus .avg-tile-inner {
  box-shadow: 0 0 0 3px var(--avg-border), 0 8px 25px rgba(0, 0, 0, 0.3);
}

/* ==========================================================================
   Tile Styles
   ========================================================================== */

/* Style: Card (default) - already styled above */

/* Style: Minimal */
.avg-tiles-minimal .avg-tile-inner {
  background: transparent;
}

.avg-tiles-minimal .avg-thumb {
  border-radius: var(--avg-radius);
}

.avg-tiles-minimal .avg-meta {
  padding: 10px 4px;
}

/* Style: Overlay */
.avg-tiles-overlay .avg-tile-inner {
  position: relative;
}

.avg-tiles-overlay .avg-meta {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 40px 14px 14px;
  background: linear-gradient(to top, rgba(0,0,0,0.85) 0%, transparent 100%);
  z-index: 1;
}

.avg-tiles-overlay .avg-title,
.avg-tiles-overlay .avg-channel {
  color: #fff;
}

.avg-tiles-overlay .avg-channel {
  color: rgba(255,255,255,0.75);
}

/* Style: Cinematic */
.avg-tiles-cinematic .avg-thumb {
  aspect-ratio: 2.35 / 1;
}

.avg-tiles-cinematic .avg-tile-inner {
  background: #000;
}

.avg-tiles-cinematic .avg-meta {
  background: #000;
}

.avg-tiles-cinematic .avg-title {
  color: #fff;
}

.avg-tiles-cinematic .avg-channel {
  color: rgba(255,255,255,0.6);
}

/* ==========================================================================
   Layout: Slider
   ========================================================================== */

.avg-layout-slider {
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  padding: 8px 0;
  scrollbar-width: thin;
}

.avg-layout-slider .avg-track {
  scroll-snap-type: x mandatory;
  padding-bottom: 4px;
}

.avg-layout-slider .avg-tile {
  flex: 0 0 auto;
  width: clamp(260px, 70vw, 320px);
  scroll-snap-align: start;
}

@media (min-width: 768px) {
  .avg-layout-slider .avg-tile {
    width: 300px;
  }
}

/* Slider Navigation */
.avg-layout-slider .avg-nav,
.avg-layout-carousel .avg-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 50%;
  background: var(--avg-play-bg);
  color: var(--avg-play-color);
  cursor: pointer;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
  transition: transform 0.15s, opacity 0.15s;
  opacity: 0;
}

.avg-layout-slider:hover .avg-nav,
.avg-layout-carousel:hover .avg-nav {
  opacity: 1;
}

.avg-nav:hover {
  transform: translateY(-50%) scale(1.1);
}

.avg-nav:disabled {
  opacity: 0.3;
  cursor: default;
}

.avg-nav svg {
  width: 24px;
  height: 24px;
}

.avg-nav-prev {
  left: 8px;
}

.avg-nav-next {
  right: 8px;
}

/* Dots Navigation */
.avg-dots {
  display: flex;
  justify-content: center;
  gap: 8px;
  padding: 16px 0 8px;
}

.avg-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--avg-border);
  border: none;
  cursor: pointer;
  padding: 0;
  transition: background 0.2s, transform 0.2s;
}

.avg-dot:hover {
  background: var(--avg-text-muted);
}

.avg-dot.active {
  background: var(--avg-text);
  transform: scale(1.2);
}

/* ==========================================================================
   Layout: Carousel
   ========================================================================== */

.avg-layout-carousel {
  overflow: hidden;
  padding: 8px 0;
}

.avg-layout-carousel .avg-track {
  transition: transform 0.4s ease;
}

.avg-layout-carousel .avg-tile {
  flex: 0 0 auto;
  width: calc((100% - var(--avg-gap) * 2) / 3);
  opacity: 0.6;
  transform: scale(0.95);
  transition: opacity 0.3s, transform 0.3s;
}

.avg-layout-carousel .avg-tile.active {
  opacity: 1;
  transform: scale(1);
}

.avg-layout-carousel[data-center="1"] .avg-track {
  justify-content: center;
}

@media (max-width: 768px) {
  .avg-layout-carousel .avg-tile {
    width: calc(100% - var(--avg-gap));
  }
}

/* ==========================================================================
   Layout: Grid
   ========================================================================== */

.avg-layout-grid .avg-track {
  display: grid;
  grid-template-columns: repeat(var(--avg-cols-desktop), 1fr);
}

@media (max-width: 1024px) {
  .avg-layout-grid .avg-track {
    grid-template-columns: repeat(var(--avg-cols-tablet), 1fr);
  }
}

@media (max-width: 640px) {
  .avg-layout-grid .avg-track {
    grid-template-columns: repeat(var(--avg-cols-mobile), 1fr);
  }
}

/* ==========================================================================
   Layout: Masonry
   ========================================================================== */

.avg-layout-masonry .avg-track {
  display: block;
  column-count: var(--avg-cols-desktop);
  column-gap: var(--avg-gap);
}

.avg-layout-masonry .avg-tile {
  break-inside: avoid;
  margin-bottom: var(--avg-gap);
}

.avg-layout-masonry .avg-thumb {
  min-height: 120px;
}

@media (max-width: 1024px) {
  .avg-layout-masonry .avg-track {
    column-count: var(--avg-cols-tablet);
  }
}

@media (max-width: 640px) {
  .avg-layout-masonry .avg-track {
    column-count: var(--avg-cols-mobile);
  }
}

/* ==========================================================================
   Pagination
   ========================================================================== */

.avg-pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  padding: 24px 0 8px;
}

.avg-pagination-numbers {
  display: flex;
  gap: 6px;
}

.avg-page-btn {
  min-width: 36px;
  height: 36px;
  padding: 0 12px;
  border: 1px solid var(--avg-border);
  background: var(--avg-bg);
  color: var(--avg-text);
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.15s;
}

.avg-page-btn:hover {
  background: var(--avg-bg-hover);
  border-color: var(--avg-text-muted);
}

.avg-page-btn.active {
  background: var(--avg-text);
  color: var(--avg-bg);
  border-color: var(--avg-text);
}

.avg-page-btn:disabled {
  opacity: 0.4;
  cursor: default;
}

.avg-load-more {
  padding: 12px 32px;
  background: var(--avg-text);
  color: var(--avg-bg);
  border: none;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s, opacity 0.15s;
}

.avg-load-more:hover {
  transform: scale(1.02);
  opacity: 0.9;
}

.avg-load-more:disabled {
  opacity: 0.5;
  cursor: default;
  transform: none;
}

/* ==========================================================================
   Popup: Lightbox (Modal)
   ========================================================================== */

.avg-modal {
  position: fixed;
  inset: 0;
  z-index: 999999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.avg-modal[hidden] {
  display: none;
}

.avg-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.88);
  animation: avgFadeIn 0.2s ease;
}

@keyframes avgFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.avg-modal-dialog {
  position: relative;
  width: min(960px, 92vw);
  max-height: 90vh;
  background: #000;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.5);
  animation: avgSlideUp 0.3s ease;
}

@keyframes avgSlideUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.avg-modal-frame {
  aspect-ratio: 16 / 9;
  background: #000;
}

.avg-modal-frame iframe {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
}

.avg-modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  font-size: 24px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  transition: background 0.15s;
}

.avg-modal-close:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* ==========================================================================
   Popup: Theater Mode
   ========================================================================== */

.avg-theater {
  position: fixed;
  inset: 0;
  z-index: 999999;
  background: #000;
  display: flex;
  flex-direction: column;
}

.avg-theater[hidden] {
  display: none;
}

.avg-theater-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  background: rgba(255, 255, 255, 0.05);
}

.avg-theater-title {
  color: #fff;
  font-size: 16px;
  font-weight: 500;
}

.avg-theater-close {
  background: none;
  border: none;
  color: #fff;
  font-size: 28px;
  cursor: pointer;
  padding: 4px 8px;
  opacity: 0.7;
  transition: opacity 0.15s;
}

.avg-theater-close:hover {
  opacity: 1;
}

.avg-theater-frame {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.avg-theater-frame iframe {
  width: 100%;
  max-width: 1600px;
  aspect-ratio: 16 / 9;
  border: 0;
}

/* ==========================================================================
   Popup: Side Panel
   ========================================================================== */

.avg-side-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(560px, 90vw);
  z-index: 999999;
  background: #0f172a;
  box-shadow: -10px 0 40px rgba(0, 0, 0, 0.4);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.35s ease;
}

.avg-side-panel.open {
  transform: translateX(0);
}

.avg-side-panel[hidden] {
  display: none;
}

.avg-side-panel-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 999998;
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
}

.avg-side-panel-backdrop.visible {
  opacity: 1;
  pointer-events: auto;
}

.avg-side-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid #334155;
}

.avg-side-panel-title {
  color: #fff;
  font-size: 15px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  margin-right: 12px;
}

.avg-side-panel-close {
  background: none;
  border: none;
  color: #94a3b8;
  font-size: 24px;
  cursor: pointer;
  padding: 4px;
  transition: color 0.15s;
}

.avg-side-panel-close:hover {
  color: #fff;
}

.avg-side-panel-frame {
  aspect-ratio: 16 / 9;
  background: #000;
}

.avg-side-panel-frame iframe {
  width: 100%;
  height: 100%;
  border: 0;
}

.avg-side-panel-content {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
  color: #e2e8f0;
}

/* ==========================================================================
   Popup: Inline Expand
   ========================================================================== */

.avg-tile.avg-inline-expanded {
  grid-column: 1 / -1;
}

.avg-layout-grid .avg-inline-player {
  grid-column: 1 / -1;
}

.avg-inline-player {
  aspect-ratio: 16 / 9;
  background: #000;
  border-radius: var(--avg-radius);
  overflow: hidden;
  margin-bottom: var(--avg-gap);
  position: relative;
}

.avg-inline-player iframe {
  width: 100%;
  height: 100%;
  border: 0;
}

.avg-inline-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  border: none;
  cursor: pointer;
  font-size: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 5;
  transition: background 0.15s;
}

.avg-inline-close:hover {
  background: rgba(0, 0, 0, 0.8);
}

/* ==========================================================================
   Accessibility
   ========================================================================== */

.avg-tile:focus-visible .avg-tile-inner {
  outline: 3px solid #3b82f6;
  outline-offset: 2px;
}

/* Screen reader text */
.avg-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ==========================================================================
   Legacy Support (for old shortcode)
   ========================================================================== */

/* Old class names from original slider */
.anchor-video-slider {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding: 8px 0;
}

.anchor-video-track {
  display: flex;
  gap: 16px;
  scroll-snap-type: x mandatory;
}

.anchor-video-tile {
  position: relative;
  border: 0;
  padding: 0;
  background: #0f172a;
  color: #fff;
  border-radius: 12px;
  overflow: hidden;
  min-width: 260px;
  max-width: 320px;
  width: 70vw;
  scroll-snap-align: start;
  cursor: pointer;
}

.anchor-video-thumb {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: linear-gradient(135deg, #0f172a, #1f2937);
  background-size: cover;
  background-position: center;
}

.anchor-video-play {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 40px;
  color: #fff;
  text-shadow: 0 6px 18px rgba(0,0,0,0.5);
}

.anchor-video-label {
  display: block;
  padding: 8px 12px 12px;
  font-size: 13px;
  letter-spacing: 0.02em;
  color: #e2e8f0;
}

@media (min-width: 900px) {
  .anchor-video-tile {
    width: 280px;
  }
}

/* Legacy modal support */
.anchor-video-modal {
  position: fixed;
  inset: 0;
  z-index: 999999;
}

.anchor-video-modal[hidden] {
  display: none;
}

.anchor-video-modal .up-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.8);
}

.anchor-video-modal .up-modal__dialog {
  position: relative;
  display: flex;
  flex-direction: column;
  width: min(960px, 92vw);
  max-height: min(90vh, 860px);
  margin: auto;
  top: 50%;
  transform: translateY(-50%);
  background: #000;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 20px 50px rgba(0,0,0,0.45);
}

.anchor-video-modal .up-modal__frame {
  aspect-ratio: 16 / 9;
  flex: 0 0 auto;
  background: #000;
}

.anchor-video-modal .up-modal__frame,
.anchor-video-modal .up-modal__frame iframe {
  width: 100%;
  height: 100%;
  display: block;
  border: 0;
}

.anchor-video-modal .up-modal__close {
  position: absolute;
  top: 8px;
  right: 10px;
  font-size: 34px;
  line-height: 1;
  color: #fff;
  background: transparent;
  border: 0;
  cursor: pointer;
  z-index: 10;
  text-shadow: 0 2px 10px rgba(0,0,0,0.6);
}
