/* ==========================================================================
   RC YOUTUBE PLAYLIST FEED v2.3 - COMPLETE CSS
   ========================================================================== */

.rc-youtube-widget {
  --rc-yw-visible: 4; /* quantidade de itens visíveis na sidebar (desktop) */
  --rc-yw-gap: 10px;
  --rc-yw-accent: #e50914;

  background-color: #0f0f0f;
  color: #ffffff;
  padding: 24px;
  border-radius: 16px;
  box-sizing: border-box;
  font-family: inherit;
}

.rc-youtube-widget * {
  box-sizing: border-box;
}

/* --- CONTAINER PRINCIPAL (DESKTOP) --- */
.rc-yw-container {
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  gap: 24px;
  align-items: stretch; /* a sidebar estica até a altura do player */
}

/* --- COLUNA DA ESQUERDA (TÍTULO + LISTA + BOTÃO) --- */
.rc-yw-sidebar-col {
  display: flex;
  flex-direction: column;
  gap: var(--rc-yw-gap);
  min-height: 0;
  contain: size; /* altura intrínseca = 0: quem define a altura da linha é o player */
}

.rc-yw-header {
  flex-shrink: 0;
  margin: 0 0 4px;
}

.rc-yw-section-title {
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1.2;
  color: #ffffff;
  margin: 0;
}

/* --- LISTA DE VÍDEOS COM SCROLL SNAP VERTICAL --- */
.rc-yw-list {
  flex: 1 1 0; /* ocupa todo o espaço disponível entre título e botão */
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: var(--rc-yw-gap);
  overflow-y: auto;
  scroll-snap-type: y mandatory;
  scroll-behavior: smooth;
  padding-right: 8px;

  /* Barra de rolagem fina (padrão; no Chrome 121+ ela substitui o ::-webkit-scrollbar) */
  scrollbar-width: thin;
  scrollbar-color: #333333 transparent;

  @media (width >= 1024px) {
    scrollbar-width: none; /* Firefox, Chrome 121+, Safari 18.2+ */
    -ms-overflow-style: none; /* Edge/IE antigos */
    padding-bottom: 30px;
  }
}

/* Fallback para navegadores WebKit mais antigos */
.rc-yw-list::-webkit-scrollbar {
  width: 5px;
  height: 5px;
  @media (width >= 1024px) {
    display: none;
  }
}
.rc-yw-list::-webkit-scrollbar-thumb {
  background: #333333;
  border-radius: 4px;
}

/* --- ITENS <details> (cada item = 1/N da altura da lista) --- */
.rc-yw-item {
  flex: 0 0
    calc(
      (100% - (var(--rc-yw-visible) - 1) * var(--rc-yw-gap)) /
        var(--rc-yw-visible)
    );
  background: transparent;
  border: 1px solid #2a2a2a;
  border-radius: 12px;
  padding: 8px;
  cursor: pointer;
  transition:
    background 0.2s ease,
    border-color 0.2s ease;
  scroll-snap-align: start;
  scroll-snap-stop: always;
  overflow: hidden;
}

.rc-yw-item:hover {
  background: #1a1a1a;
}

.rc-yw-item[open] {
  background: #222222;
  border-color: var(--rc-yw-accent);
}

.rc-yw-summary {
  display: flex;
  gap: 12px;
  align-items: center;
  height: 100%;
  list-style: none;
  cursor: pointer;
}

.rc-yw-summary::-webkit-details-marker,
.rc-yw-summary::marker {
  display: none;
  content: '';
}

/* Foco visível para navegação por teclado */
.rc-yw-summary:focus-visible {
  outline: 2px solid #ffffff;
  outline-offset: 2px;
  border-radius: 8px;
}

.rc-yw-thumb-wrap {
  position: relative;
  flex-shrink: 0;
  height: 100%;
  width: auto;
  max-width: 48%;
  aspect-ratio: 16 / 9;
  border-radius: 8px;
  overflow: hidden;
  background: #000000;
}

.rc-yw-thumb-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Duração no canto da thumb pequena */
.rc-yw-duration {
  position: absolute;
  right: 3px;
  bottom: 3px;
  padding: 1px 4px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.8);
  color: #ffffff;
  font-size: 0.65rem;
  font-weight: 600;
  line-height: 1.3;
  pointer-events: none;
}

.rc-yw-meta {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  overflow: hidden;
}

.rc-yw-item-title {
  font-size: 0.85rem;
  font-weight: 600;
  line-height: 1.25;
  color: #f1f1f1;
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.rc-yw-subinfo {
  font-size: 0.75rem;
  color: #aaaaaa;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* --- BOTÃO "TODOS OS VÍDEOS" --- */
.rc-yw-all-btn {
  flex-shrink: 0;
  background-color: var(--rc-yw-accent);
  color: #ffffff !important;
  font-weight: 700;
  font-size: 0.9rem;
  padding: 12px;
  border-radius: 999px;
  text-decoration: none !important;
  transition: background 0.2s ease;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  column-gap: 10px;
}

.rc-yw-all-btn:hover {
  background-color: #b20710;
}

.rc-yw-all-btn:focus-visible {
  outline: 2px solid #ffffff;
  outline-offset: 2px;
}
.rc-yw-all-btn-text {
}
.rc-yw-all-btn-icon {
  display: inline-block;
  width: 20px;
  height: 20px;
  margin-bottom: 1px;
  svg {
    fill: #fff;
  }
}
/* --- COLUNA DA DIREITA (PLAYER) --- */
.rc-yw-player-panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
  height: fit-content;
  min-width: 0;
}

.rc-yw-player-screen {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000000;
  border-radius: 14px;
  overflow: hidden;
}

/* Thumb clicável (facade) */
.rc-yw-play {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: #000000 !important;
  cursor: pointer;
  display: block;
  border: none !important;
}

.rc-yw-play:hover,
.rc-yw-play:focus {
  background: #000000;
}

.rc-yw-play:focus-visible {
  outline: 3px solid #ffffff;
  outline-offset: -3px;
}

.rc-yw-poster {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.rc-yw-play-icon {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 68px;
  height: 68px;
  border-radius: 50%;
  background: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  transform: translate(-50%, -50%);
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.45);
  transition: transform 0.2s ease;
}

.rc-yw-play-icon svg {
  width: 28px;
  height: 28px;
  fill: #0f0f0f;
  margin-left: 3px;
}

.rc-yw-play:hover .rc-yw-play-icon,
.rc-yw-play:focus-visible .rc-yw-play-icon {
  transform: translate(-50%, -50%) scale(1.1);
}

/* Duração no canto da thumb grande (como na referência) */
.rc-yw-duration-badge {
  position: absolute;
  top: 12px;
  right: 14px;
  z-index: 1;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.8);
  color: #ffffff;
  font-size: 0.8rem;
  font-weight: 600;
  line-height: 1.3;
  pointer-events: none;
}

.rc-yw-duration-badge:empty {
  display: none;
}

.rc-yw-player-screen.is-playing .rc-yw-play,
.rc-yw-player-screen.is-playing .rc-yw-duration-badge {
  display: none;
}

.rc-yw-player-screen iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

/* Info abaixo do player (altura reservada: 2 linhas de título) */
.rc-yw-player-info {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 4px 8px 0;
  text-align: center;
}

.rc-yw-main-title {
  font-size: clamp(1.1rem, 1.6vw, 1.5rem);
  font-weight: 700;
  line-height: 1.3;
  min-height: calc(2 * 1.3em);
  color: #ffffff;
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.rc-yw-main-author {
  font-size: 0.85rem;
  color: #aaaaaa;
}

/* ==========================================================================
   LAYOUT RESPONSIVO MOBILE / TABLET (< 1024px)
   ========================================================================== */
@media (max-width: 1023px) {
  .rc-youtube-widget {
    padding: 16px;
  }

  .rc-yw-container {
    display: flex;
    flex-direction: column;
    gap: 16px;
  }

  /* A sidebar "some" como caixa: título, lista e botão viram filhos diretos
     do container e são reordenados abaixo */
  .rc-yw-sidebar-col {
    display: contents;
    contain: none;
  }

  .rc-yw-header {
    order: 0;
    margin: 0;
  }

  .rc-yw-player-panel {
    order: 1;
    width: 100%;
    scroll-margin-top: 16px; /* folga ao rolar até o player (aumente se houver header fixo) */
  }

  .rc-yw-main-title {
    font-size: 1.05rem;
  }

  /* Carrossel horizontal com scroll snap */
  .rc-yw-list {
    order: 2;
    flex: 0 0 auto;
    min-height: auto;
    flex-direction: row;
    overflow-x: auto;
    overflow-y: hidden;
    gap: 12px;
    padding: 0 0 8px;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
  }

  .rc-yw-item {
    flex: 0 0 82%;
    max-width: 320px;
    scroll-snap-align: start;
    scroll-snap-stop: normal;
  }

  .rc-yw-summary {
    height: auto;
  }

  .rc-yw-thumb-wrap {
    width: 96px;
    height: 54px;
    max-width: none;
    aspect-ratio: auto;
  }

  .rc-yw-all-btn {
    order: 3;
    width: 100%;
  }
}

/* ==========================================================================
   MOVIMENTO REDUZIDO
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
  .rc-yw-list {
    scroll-behavior: auto;
  }

  .rc-yw-item,
  .rc-yw-all-btn,
  .rc-yw-play-icon {
    transition: none;
  }
}
