/*
 * YouTube Hub — Estilos del módulo frontend
 * Autor: Bruno Invernizzi <bruno_invernizzi@hotmail.com>
 * Versión: 1.0.0
 * Sin dependencias. Vanilla CSS puro.
 * ─────────────────────────────────────────────────────────────────────
 */

/* ═══════════════════════════════════════════════════════════════════════
   1. VARIABLES CSS (Tema claro — valores por defecto)
   ═══════════════════════════════════════════════════════════════════════ */
.mod-youtubehub {
  --yh-accent:       #ff0000;
  --yh-radius:       8px;
  --yh-gap:          20px;
  --yh-transition:   200ms cubic-bezier(.4, 0, .2, 1);

  /* Colores tema claro */
  --yh-bg:           #f9f9f9;
  --yh-surface:      #ffffff;
  --yh-surface-2:    #f0f0f0;
  --yh-border:       #e0e0e0;
  --yh-text:         #0f0f0f;
  --yh-text-2:       #606060;
  --yh-overlay-bg:   rgba(0,0,0,.52);
  --yh-shadow:       0 1px 4px rgba(0,0,0,.12), 0 1px 2px rgba(0,0,0,.08);
  --yh-shadow-hover: 0 4px 16px rgba(0,0,0,.16), 0 2px 6px rgba(0,0,0,.1);
  --yh-play-bg:      var(--yh-accent);
  --yh-play-arrow:   #ffffff;
  --yh-skeleton:     #e4e4e4;
  --yh-skeleton-2:   #f0f0f0;

  /* Layout */
  --yh-columns:      3;
  --yh-sidebar-ratio: 2fr 1fr;
}

/* Tema oscuro explícito */
.mod-youtubehub.yh-theme--dark {
  --yh-bg:           #0f0f0f;
  --yh-surface:      #1a1a1a;
  --yh-surface-2:    #272727;
  --yh-border:       #3f3f3f;
  --yh-text:         #f1f1f1;
  --yh-text-2:       #aaaaaa;
  --yh-overlay-bg:   rgba(0,0,0,.65);
  --yh-shadow:       0 2px 8px rgba(0,0,0,.4);
  --yh-shadow-hover: 0 6px 24px rgba(0,0,0,.5);
  --yh-skeleton:     #272727;
  --yh-skeleton-2:   #1a1a1a;
}

/* Tema automático (sigue la preferencia del SO) */
@media (prefers-color-scheme: dark) {
  .mod-youtubehub.yh-theme--auto {
    --yh-bg:           #0f0f0f;
    --yh-surface:      #1a1a1a;
    --yh-surface-2:    #272727;
    --yh-border:       #3f3f3f;
    --yh-text:         #f1f1f1;
    --yh-text-2:       #aaaaaa;
    --yh-overlay-bg:   rgba(0,0,0,.65);
    --yh-shadow:       0 2px 8px rgba(0,0,0,.4);
    --yh-shadow-hover: 0 6px 24px rgba(0,0,0,.5);
    --yh-skeleton:     #272727;
    --yh-skeleton-2:   #1a1a1a;
  }
}

/* ═══════════════════════════════════════════════════════════════════════
   2. CONTENEDOR RAÍZ
   ═══════════════════════════════════════════════════════════════════════ */
.mod-youtubehub {
  background: var(--yh-bg);
  color:      var(--yh-text);
  font-family: inherit;
  box-sizing: border-box;
  padding:    clamp(16px, 3vw, 32px);
  border-radius: var(--yh-radius);
  container-type: inline-size;
}

.mod-youtubehub *,
.mod-youtubehub *::before,
.mod-youtubehub *::after {
  box-sizing: inherit;
}

.yh-empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--yh-text-2);
}

/* ═══════════════════════════════════════════════════════════════════════
   3. FILTROS DE CATEGORÍA
   ═══════════════════════════════════════════════════════════════════════ */
.yh-filters {
  display:   flex;
  flex-wrap: wrap;
  gap:       8px;
  margin-bottom: calc(var(--yh-gap) * 1.25);
}

.yh-filter-btn {
  padding:          6px 16px;
  border:           1.5px solid var(--yh-border);
  border-radius:    100px;
  background:       transparent;
  color:            var(--yh-text-2);
  font-size:        .85rem;
  font-weight:      500;
  cursor:           pointer;
  transition:       background var(--yh-transition), color var(--yh-transition),
                    border-color var(--yh-transition);
  white-space: nowrap;
}

.yh-filter-btn:hover {
  border-color: var(--yh-accent);
  color:        var(--yh-accent);
}

.yh-filter-btn.is-active {
  background:   var(--yh-accent);
  border-color: var(--yh-accent);
  color:        #fff;
}

.yh-filter-btn:focus-visible {
  outline: 2px solid var(--yh-accent);
  outline-offset: 2px;
}

/* ═══════════════════════════════════════════════════════════════════════
   4. TARJETA DE VIDEO (compartida entre todos los diseños)
   ═══════════════════════════════════════════════════════════════════════ */
.yh-card {
  background:    var(--yh-surface);
  border-radius: var(--yh-radius);
  overflow:      hidden;
  cursor:        pointer;
  border:        1px solid var(--yh-border);
  transition:    transform var(--yh-transition), box-shadow var(--yh-transition);
  display:       flex;
  flex-direction: column;
}

.yh-has-shadow .yh-card { box-shadow: var(--yh-shadow); }

.yh-card:hover,
.yh-card:focus-visible {
  outline: none;
}

.yh-has-shadow .yh-card:hover { box-shadow: var(--yh-shadow-hover); }
.yh-card:hover { transform: translateY(-2px); }

.yh-card.is-active {
  border-color: var(--yh-accent);
  box-shadow: 0 0 0 2px var(--yh-accent);
}

.yh-card:focus-visible {
  outline: 2px solid var(--yh-accent);
  outline-offset: 2px;
}

/* Miniatura de tarjeta */
.yh-card__thumb {
  position:    relative;
  overflow:    hidden;
  aspect-ratio: 16 / 9;
  background:  var(--yh-surface-2);
  flex-shrink: 0;
}

/* Soporte para relaciones de aspecto variables */
.yh-layout--grid.yh-aspect--4-3  .yh-card__thumb,
.yh-layout--carousel.yh-aspect--4-3 .yh-card__thumb   { aspect-ratio: 4 / 3; }
.yh-layout--grid.yh-aspect--1-1  .yh-card__thumb,
.yh-layout--carousel.yh-aspect--1-1 .yh-card__thumb   { aspect-ratio: 1 / 1; }
.yh-layout--grid.yh-aspect--9-16 .yh-card__thumb,
.yh-layout--carousel.yh-aspect--9-16 .yh-card__thumb  { aspect-ratio: 9 / 16; }

.yh-card__img {
  width:      100%;
  height:     100%;
  object-fit: cover;
  display:    block;
  transition: transform calc(var(--yh-transition) * 2);
}

.yh-has-zoom .yh-card:hover .yh-card__img {
  transform: scale(1.06);
}

/* Overlay del botón de play */
.yh-card__overlay {
  position: absolute;
  inset:    0;
  display:  flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,.0);
  transition: background var(--yh-transition);
}

.yh-card:hover .yh-card__overlay,
.yh-card.is-active .yh-card__overlay {
  background: rgba(0,0,0,.28);
}

.yh-play-icon {
  width:   48px;
  height:  34px;
  opacity: 0;
  transform: scale(.85);
  transition: opacity var(--yh-transition), transform var(--yh-transition);
}

.yh-card:hover .yh-play-icon,
.yh-card.is-active .yh-play-icon {
  opacity: 1;
  transform: scale(1);
}

.yh-play-shape { fill: var(--yh-play-bg); }
.yh-play-arrow { fill: var(--yh-play-arrow); }

/* Badge "Short" */
.yh-badge {
  position:      absolute;
  bottom:        8px;
  left:          8px;
  padding:       2px 8px;
  border-radius: 4px;
  font-size:     .7rem;
  font-weight:   700;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.yh-badge--short {
  background: #1a1a1a;
  color:      #fff;
}

/* Meta info de la tarjeta */
.yh-card__meta {
  padding: 10px 12px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex-grow: 1;
}

.yh-card__title {
  font-size:   .9rem;
  font-weight: 600;
  line-height: 1.35;
  color:       var(--yh-text);
  margin:      0;
  display:     -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow:    hidden;
}

.yh-card__date {
  font-size: .78rem;
  color:     var(--yh-text-2);
}

.yh-card__desc {
  font-size:   .82rem;
  color:       var(--yh-text-2);
  margin:      0;
  line-height: 1.4;
  display:     -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow:    hidden;
}

/* ═══════════════════════════════════════════════════════════════════════
   5. REPRODUCTOR PRINCIPAL (usado en Sidebar y Destacado)
   ═══════════════════════════════════════════════════════════════════════ */
.yh-player-stage {
  position:     relative;
  border-radius: var(--yh-radius);
  overflow:     hidden;
  background:   #000;
  aspect-ratio: 16 / 9;
  width:        100%;
}

.yh-thumb-overlay {
  position: absolute;
  inset:    0;
  display:  flex;
  align-items: center;
  justify-content: center;
}

.yh-thumb-overlay.is-hidden { display: none; }

.yh-main-thumb {
  position:   absolute;
  inset:      0;
  width:      100%;
  height:     100%;
  object-fit: cover;
}

/* Botón de play del reproductor principal */
.yh-play-main {
  position:      relative;
  z-index:       2;
  background:    transparent;
  border:        none;
  cursor:        pointer;
  padding:       0;
  width:         80px;
  height:        80px;
  transition:    transform var(--yh-transition), opacity var(--yh-transition);
  filter: drop-shadow(0 4px 12px rgba(0,0,0,.5));
}

.yh-play-main:hover { transform: scale(1.1); }
.yh-play-main:focus-visible { outline: 2px solid #fff; border-radius: 50%; }

.yh-main-play-circle { fill: var(--yh-accent); opacity: .9; }
.yh-main-play-tri    { fill: #fff; }

/* Slot del iframe */
.yh-iframe-slot {
  position: absolute;
  inset:    0;
}

.yh-iframe-slot iframe {
  width:  100%;
  height: 100%;
  border: none;
  display: block;
}

/* Meta info del reproductor principal */
.yh-main-meta {
  padding: 14px 4px 8px;
}

.yh-main-title {
  font-size:   1.1rem;
  font-weight: 700;
  color:       var(--yh-text);
  margin:      0 0 6px;
  line-height: 1.3;
}

.yh-main-date {
  font-size: .82rem;
  color:     var(--yh-text-2);
  display:   block;
  margin-bottom: 8px;
}

.yh-main-desc {
  font-size:   .88rem;
  color:       var(--yh-text-2);
  margin:      0;
  line-height: 1.5;
  display:     -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow:    hidden;
}

/* ═══════════════════════════════════════════════════════════════════════
   6. DISEÑO: BARRA LATERAL
   ═══════════════════════════════════════════════════════════════════════ */
.yh-sidebar {
  display: grid;
  grid-template-columns: var(--yh-sidebar-ratio);
  gap:     var(--yh-gap);
  align-items: start;
}

/* Lista lateral */
.yh-sidebar__list {
  display:        flex;
  flex-direction: column;
  gap:            calc(var(--yh-gap) * .6);
  max-height:     520px;
  overflow-y:     auto;
  scrollbar-width: thin;
  scrollbar-color: var(--yh-border) transparent;
  padding-right:  4px;
}

.yh-sidebar__list .yh-card {
  flex-direction: row;
  min-height:     0;
}

.yh-sidebar__list .yh-card__thumb {
  width:       120px;
  flex-shrink: 0;
  aspect-ratio: 16 / 9;
}

.yh-sidebar__list .yh-card__meta {
  padding: 8px 10px;
}

.yh-sidebar__list .yh-card__title {
  font-size: .82rem;
  -webkit-line-clamp: 2;
}

/* Responsive barra lateral */
@container (max-width: 600px) {
  .yh-sidebar {
    grid-template-columns: 1fr;
  }
  .yh-sidebar__list {
    max-height: none;
  }
}

/* ═══════════════════════════════════════════════════════════════════════
   7. DISEÑO: CUADRÍCULA
   ═══════════════════════════════════════════════════════════════════════ */
.yh-grid {
  display:               grid;
  grid-template-columns: repeat(var(--yh-columns), 1fr);
  gap:                   var(--yh-gap);
}

@container (max-width: 700px) {
  .yh-grid { grid-template-columns: repeat(2, 1fr); }
}

@container (max-width: 440px) {
  .yh-grid { grid-template-columns: 1fr; }
}

/* ═══════════════════════════════════════════════════════════════════════
   8. DISEÑO: CARRUSEL
   ═══════════════════════════════════════════════════════════════════════ */
.yh-carousel {
  position: relative;
  padding:  0 44px;
}

.yh-carousel__viewport {
  overflow: hidden;
  border-radius: var(--yh-radius);
}

.yh-carousel__track {
  display:    flex;
  gap:        var(--yh-gap);
  transition: transform 360ms cubic-bezier(.4, 0, .2, 1);
  will-change: transform;
}

.yh-carousel__track .yh-card {
  flex:      0 0 calc(33.333% - var(--yh-gap) * 2 / 3);
  min-width: 0;
}

@container (max-width: 600px) {
  .yh-carousel { padding: 0 36px; }
  .yh-carousel__track .yh-card { flex-basis: calc(50% - var(--yh-gap) / 2); }
}

@container (max-width: 380px) {
  .yh-carousel__track .yh-card { flex-basis: 85%; }
}

/* Botones del carrusel */
.yh-carousel-btn {
  position:   absolute;
  top:        50%;
  transform:  translateY(-50%);
  z-index:    5;
  width:      36px;
  height:     36px;
  border:     1.5px solid var(--yh-border);
  border-radius: 50%;
  background: var(--yh-surface);
  color:      var(--yh-text);
  cursor:     pointer;
  display:    flex;
  align-items: center;
  justify-content: center;
  padding:    0;
  transition: background var(--yh-transition), border-color var(--yh-transition);
}

.yh-carousel-btn--prev { left:  4px; }
.yh-carousel-btn--next { right: 4px; }

.yh-carousel-btn:hover {
  background:   var(--yh-accent);
  border-color: var(--yh-accent);
  color:        #fff;
}

.yh-carousel-btn:disabled { opacity: .35; pointer-events: none; }
.yh-carousel-btn svg { width: 16px; height: 16px; }

/* Puntos de navegación */
.yh-carousel__dots {
  display:         flex;
  justify-content: center;
  gap:             6px;
  margin-top:      14px;
}

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

.yh-dot.is-active {
  background: var(--yh-accent);
  transform:  scale(1.3);
}

/* ═══════════════════════════════════════════════════════════════════════
   9. DISEÑO: DESTACADO
   ═══════════════════════════════════════════════════════════════════════ */
.yh-featured__hero {
  margin-bottom: var(--yh-gap);
}

.yh-featured__secondary {
  margin-top: var(--yh-gap);
}

/* ═══════════════════════════════════════════════════════════════════════
   10. MODAL
   ═══════════════════════════════════════════════════════════════════════ */
.yh-modal {
  position: fixed;
  inset:    0;
  z-index:  9990;
  display:  flex;
  align-items: center;
  justify-content: center;
  padding:  16px;
}

.yh-modal[hidden] { display: none !important; }

.yh-modal__backdrop {
  position:   fixed;
  inset:      0;
  background: rgba(0,0,0,.85);
  backdrop-filter: blur(4px);
  animation: yhFadeIn 200ms ease;
}

.yh-modal__box {
  position:      relative;
  z-index:       1;
  width:         min(960px, 100%);
  background:    #000;
  border-radius: calc(var(--yh-radius) + 4px);
  overflow:      hidden;
  box-shadow:    0 24px 64px rgba(0,0,0,.6);
  animation:     yhSlideUp 260ms cubic-bezier(.34, 1.56, .64, 1);
}

.yh-modal__header {
  display:         flex;
  align-items:     center;
  justify-content: space-between;
  padding:         10px 14px;
  background:      #111;
}

.yh-modal__title {
  color:       #f1f1f1;
  font-size:   .95rem;
  font-weight: 600;
  margin:      0;
  white-space: nowrap;
  overflow:    hidden;
  text-overflow: ellipsis;
  max-width:   85%;
}

.yh-modal__close {
  background:    transparent;
  border:        none;
  color:         #aaa;
  cursor:        pointer;
  padding:       4px;
  border-radius: 4px;
  display:       flex;
  transition:    color var(--yh-transition);
  flex-shrink:   0;
}

.yh-modal__close:hover { color: #fff; }
.yh-modal__close svg { width: 20px; height: 20px; }

.yh-modal__stage {
  position:     relative;
  aspect-ratio: 16 / 9;
  background:   #000;
}

.yh-modal__stage .yh-iframe-slot { position: static; width: 100%; height: 100%; }

/* ═══════════════════════════════════════════════════════════════════════
   11. ANIMACIONES
   ═══════════════════════════════════════════════════════════════════════ */
@keyframes yhFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes yhSlideUp {
  from { opacity: 0; transform: translateY(24px) scale(.96); }
  to   { opacity: 1; transform: translateY(0)    scale(1);   }
}

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

/* ═══════════════════════════════════════════════════════════════════════
   12. ESTADO VACÍO Y ERRORES
   ═══════════════════════════════════════════════════════════════════════ */
.yh-card.yh-card--hidden {
  display: none;
}

/* Accesibilidad: focus visible en toda la galería */
.mod-youtubehub :focus-visible {
  outline:        2px solid var(--yh-accent);
  outline-offset: 2px;
}

/* Respetar preferencia de movimiento reducido */
@media (prefers-reduced-motion: reduce) {
  .mod-youtubehub *,
  .mod-youtubehub *::before,
  .mod-youtubehub *::after {
    animation-duration:   0.01ms !important;
    transition-duration:  0.01ms !important;
  }
}
