/* ============================================================================
   Reels · Rico aos Poucos
   - .reels-player-body  → /reels/{slug}/ tela cheia, scroll vertical estilo TikTok
   - .reels-list-body    → /reels/ grade
   - .home-reels-carousel→ bloco horizontal na home
   ============================================================================ */

/* ----- PLAYER TELA CHEIA --------------------------------------------------- */

.reels-player-body {
  margin: 0;
  background: #000;
  color: #fff;
  font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
  overflow: hidden;
  height: 100dvh;
  width: 100vw;
}

/* Força avatar/login pro lado direito do topbar padrão. O elemento é
   inserido pelo auth-ui.js entre o brand (flex:1) e o botão de busca,
   mas margin-left:auto garante que fique colado à direita mesmo se a
   ordem do flex variar. */
.article-topbar #rap-auth { margin-left: auto; }

/* Topbar mínimo do player: só botão voltar à esquerda + avatar/login à direita
   (avatar é injetado pelo auth-ui.js automaticamente) */
.reels-topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  background: linear-gradient(to bottom, rgba(0,0,0,.55), rgba(0,0,0,0));
  pointer-events: none;
}

.reels-topbar-back,
.reels-topbar-home {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px; height: 40px;
  border-radius: 50%;
  background: rgba(0,0,0,.55);
  color: #fff;
  text-decoration: none;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: background .15s, transform .1s;
  pointer-events: auto;
}
.reels-topbar-back:hover,
.reels-topbar-home:hover { background: rgba(0,0,0,.78); }
.reels-topbar-back:active,
.reels-topbar-home:active { transform: scale(.92); }

.reels-topbar-title {
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: .5px;
  color: #fff;
  text-shadow: 0 1px 4px rgba(0,0,0,.6);
  pointer-events: none;
}

/* Força o auth-ui (avatar/login) pra direita absoluta na topbar do player */
.reels-topbar #rap-auth {
  position: absolute;
  top: 12px;
  right: 18px;
  z-index: 51;
  pointer-events: auto;
}

.reels-topbar-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px; height: 40px;
  border: 0;
  border-radius: 50%;
  background: rgba(0,0,0,.55);
  color: #fff;
  cursor: pointer;
  text-decoration: none;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: background .15s, transform .1s;
  pointer-events: auto;
}

.reels-topbar-btn:hover { background: rgba(0,0,0,.78); }
.reels-topbar-btn:active { transform: scale(.92); }

.reels-stack {
  height: 100dvh;
  width: 100vw;
  overflow-y: scroll;
  overflow-x: hidden;
  scroll-snap-type: y mandatory;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}

.reels-stack::-webkit-scrollbar { display: none; }

.reel-stage {
  position: relative;
  height: 100dvh;
  width: 100vw;
  scroll-snap-align: start;
  scroll-snap-stop: always;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
}

.reel-player {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
  /* Crop das bordas onde o YT renderiza controles/título/share mesmo
     com controls=0. O iframe é escalado pra ficar maior que o container,
     e overflow:hidden corta as bordas com os elementos indesejados. */
  overflow: hidden;
}

.reel-video,
.reel-iframe {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border: 0;
  background: #000;
}

/* Iframe YT: pointer-events:none (user nunca interage direto com o
   iframe — quem captura o click é o .reel-tap-target acima).

   ATENÇÃO: NÃO usar transform:scale aqui pra esconder a UI do YT.
   scale uniforme corta laterais à toa (incidente 2026-05-19, user
   reclamou de corte horizontal). A UI do YT só aparece em topo
   (título) e base (progress/share) — usamos máscaras pretas finas
   sobrepostas (.reel-yt-mask-top/.reel-yt-mask-bottom) pra cobrir
   só essas faixas, mantendo o vídeo inteiro visível. */
.reel-iframe {
  pointer-events: none;
}

/* Máscaras pretas que cobrem as faixas onde o YT desenha UI nativa
   (título no topo, progress + share no fundo). Z-index 4 = acima do
   iframe (default z:auto) e abaixo do tap-target (6). Injetadas
   dinamicamente pelo reels-player.js só em stages com iframe YT. */
.reel-yt-mask-top,
.reel-yt-mask-bottom {
  position: absolute;
  left: 0;
  right: 0;
  background: #000;
  pointer-events: none;
  z-index: 4;
}
.reel-yt-mask-top    { top: 0;    height: 60px; }
.reel-yt-mask-bottom { bottom: 0; height: 64px; }

/* Poster: thumbnail estática que cobre o player até o vídeo entrar em
   estado PLAYING de verdade. Esconde o "big play button" central que o
   YT renderiza quando o player está em CUED/PAUSED. Sumiço com fade
   curto quando o playStage dispara. */
.reel-poster {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #000;
  z-index: 5;
  opacity: 1;
  transition: opacity .25s ease;
  pointer-events: none;
}
.reel-poster.is-hidden {
  opacity: 0;
}

@media (min-aspect-ratio: 9/16) {
  .reel-video,
  .reel-iframe {
    width: auto;
    height: 100dvh;
    aspect-ratio: 9 / 16;
  }
}

/* Tap target — div sobre o player que captura click pra toggle mute.
   Cobre TODA a área do vídeo (zindex acima do iframe/video). Iframes
   normalmente bloqueiam cliques externos, então esse div é a única
   forma de o user interagir com o player. */
.reel-tap-target {
  position: absolute;
  inset: 0;
  z-index: 6;
  background: transparent;
  border: 0;
  padding: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

/* Indicador visual de mute/unmute — pulsa no centro e some */
.reel-mute-pulse {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 8;
  pointer-events: none;
  opacity: 0;
  background: rgba(0,0,0,.55);
  border-radius: 50%;
  padding: 22px;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

/* Controla qual ícone aparece via data-state (evita conflitos com [hidden]
   em SVG dentro de container flex). */
.reel-mute-pulse[data-state="muted"]   .icon-unmuted { display: none; }
.reel-mute-pulse[data-state="unmuted"] .icon-muted   { display: none; }

.reel-mute-pulse.show {
  animation: reel-mute-pulse-anim .9s ease-out forwards;
}

@keyframes reel-mute-pulse-anim {
  0%   { opacity: 0;   transform: translate(-50%, -50%) scale(.6); }
  30%  { opacity: 1;   transform: translate(-50%, -50%) scale(1.0); }
  70%  { opacity: .85; transform: translate(-50%, -50%) scale(1.05); }
  100% { opacity: 0;   transform: translate(-50%, -50%) scale(1.25); }
}

/* Botão persistente de mute/unmute — lateral direita, ~30% bottom
   (onde TikTok/Instagram colocam likes). Único elemento de UI que
   sinaliza ao user como ativar/cortar áudio sem precisar adivinhar. */
.reel-mute-btn {
  position: absolute;
  right: 14px;
  bottom: 30%;
  z-index: 9;          /* acima do tap-target (6) e mute-pulse (8) */
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(0,0,0,.55);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1.5px solid rgba(255,255,255,.22);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  transition: transform .15s ease, background .15s ease;
  -webkit-tap-highlight-color: transparent;
}

.reel-mute-btn:hover  { background: rgba(0,0,0,.78); transform: scale(1.06); }
.reel-mute-btn:active { transform: scale(.94); }

/* Pulso de atenção quando mutado, pra fisgar o olhar nos primeiros segundos */
.reel-mute-btn[data-state="muted"] {
  animation: reel-mute-btn-attention 2.4s ease-out 1.2s 2;
}

@keyframes reel-mute-btn-attention {
  0%   { box-shadow: 0 0 0 0   rgba(255,255,255,.45); }
  60%  { box-shadow: 0 0 0 14px rgba(255,255,255,0);   }
  100% { box-shadow: 0 0 0 0   rgba(255,255,255,0);   }
}

/* Barra de progresso visual (não interativa) — topo abaixo da topbar */
.reel-progress {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  z-index: 7;
  background: rgba(255,255,255,.15);
  pointer-events: none;
}

.reel-progress-fill {
  height: 100%;
  width: 0;
  background: linear-gradient(to right, #2d8a6e, #4ec79b);
  transition: width .25s linear;
}

/* ----- LISTAGEM /reels/ ---------------------------------------------------- */
/* Usa o header padrão do site (site-header.js) — não duplica navegação. */

.reels-list-body {
  background: #0d1117;
  color: #f0f6fc;
  font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
  min-height: 100vh;
}

.reels-list-intro {
  max-width: 1280px;
  margin: 24px auto 12px;
  padding: 0 20px;
  text-align: center;
}

/* Header da grade /reels/ — botão voltar à esquerda, título+subtítulo colados ao lado.
   Não centraliza mais; subtítulo curto evita quebra em 2 linhas no mobile. */
.reels-list-header {
  max-width: 1200px;
  margin: 0 auto;
  padding: 18px 20px 12px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.reels-list-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .06);
  color: #c9d1d9;
  text-decoration: none;
  font-size: .9rem;
  font-weight: 500;
  transition: background .15s;
  white-space: nowrap;
  flex-shrink: 0;
}
.reels-list-back:hover { background: rgba(255, 255, 255, .12); }
.reels-list-back svg { flex-shrink: 0; }

.reels-list-title-wrap {
  flex: 1 1 auto;
  text-align: left;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.reels-list-title {
  font-size: 1.75rem;
  font-weight: 700;
  margin: 0;
  line-height: 1.1;
  letter-spacing: .3px;
}

.reels-list-sub {
  font-size: .92rem;
  color: #8b949e;
  margin: 0;
  line-height: 1.25;
}

@media (max-width: 600px) {
  .reels-list-intro { margin: 18px auto 8px; }
  .reels-list-header { padding: 12px 14px 8px; gap: 10px; }
  .reels-list-back span { display: none; }
  .reels-list-back { padding: 8px 10px; }
  .reels-list-title { font-size: 1.25rem; line-height: 1.05; }
  .reels-list-sub { font-size: .78rem; line-height: 1.2; }
}

/* ----- TABS DE CATEGORIA -------------------------------------------------- */
/* Container externo (sticky + background) ocupa 100% da viewport;
   o conteúdo interno é centralizado em max-width 1200px (mesmo do topbar). */
.reels-tabs-wrap {
  position: sticky;
  top: var(--topbar-h, 56px);
  z-index: 20;
  background: rgba(13, 17, 23, .92);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.reels-tabs {
  max-width: 1200px;
  margin: 0 auto;
  padding: 12px 14px;
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
}

.reels-tabs::-webkit-scrollbar { display: none; }

.reels-tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  height: 36px;            /* altura fixa pra alinhar todas */
  border-radius: 999px;
  background: transparent;
  border: 1px solid #30363d;
  color: #8b949e;
  font-family: inherit;
  font-size: .88rem;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s, border-color .15s, color .15s, transform .1s;
  flex-shrink: 0;
  box-sizing: border-box;
}

.reels-tab:hover {
  border-color: #2d8a6e;
  color: #f0f6fc;
  background: rgba(45, 138, 110, .08);
}

.reels-tab.is-active {
  background: linear-gradient(135deg, #1a5f4a, #2d8a6e);
  border-color: #2d8a6e;
  color: #fff;
  box-shadow: 0 2px 12px rgba(45, 138, 110, .35);
}

/* Todos os filhos sem extra vertical-align quirks */
.reels-tab > * {
  display: inline-flex;
  align-items: center;
  line-height: 1;
}

.reels-tab-icon { font-size: 1rem; }
.reels-tab-label { letter-spacing: .2px; }

.reels-tab-count {
  justify-content: center;
  min-width: 22px;
  height: 20px;
  padding: 0 6px;
  border-radius: 10px;
  background: rgba(255, 255, 255, .08);
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .3px;
}

.reels-tab.is-active .reels-tab-count {
  background: rgba(255, 255, 255, .25);
}

@media (max-width: 480px) {
  .reels-tabs { padding: 10px 14px; gap: 4px; }
  .reels-tab  { padding: 6px 10px; font-size: .82rem; height: 32px; }
  .reels-tab-label { display: none; }
  .reels-tab-icon  { font-size: 1.15rem; }
  .reels-tab.is-active .reels-tab-label { display: inline-flex; }
}

.reels-grid-wrap {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px 14px 64px;
}

.reels-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
}

@media (min-width: 768px) {
  .reels-grid {
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 20px;
  }
}

.reels-empty {
  text-align: center;
  color: #8b949e;
  padding: 48px 16px;
  font-size: 1rem;
}

/* ----- CARD 9:16 (reutilizado em listagem e carrossel) -------------------- */

.reel-card {
  display: flex;
  flex-direction: column;
  text-decoration: none;
  color: inherit;
  border-radius: 14px;
  overflow: hidden;
  background: #161b22;
  border: 1px solid #21262d;
  transition: transform .18s, box-shadow .18s, border-color .18s;
}

.reel-card:hover {
  transform: translateY(-3px);
  border-color: #2d8a6e;
  box-shadow: 0 8px 24px rgba(45, 138, 110, .15);
}

.reel-card-thumb {
  position: relative;
  aspect-ratio: 9 / 16;
  overflow: hidden;
  background: #0d1117;
}

.reel-card-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform .25s;
}

.reel-card:hover .reel-card-thumb img { transform: scale(1.04); }

.reel-card-play {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(to bottom, rgba(0,0,0,0) 50%, rgba(0,0,0,.45));
  color: #fff;
  opacity: 0;
  transition: opacity .18s;
}

.reel-card:hover .reel-card-play { opacity: 1; }

.reel-card-play svg {
  background: rgba(255,255,255,.18);
  border-radius: 50%;
  padding: 12px;
  width: 44px;
  height: 44px;
  backdrop-filter: blur(4px);
}

.reel-card-dur {
  position: absolute;
  top: 10px;
  right: 10px;
  background: rgba(0,0,0,.65);
  color: #fff;
  font-size: .75rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 6px;
  letter-spacing: .3px;
}

.reel-card-body {
  padding: 12px 14px 16px;
}

.reel-card-title {
  font-size: .92rem;
  font-weight: 600;
  margin: 0;
  line-height: 1.35;
  color: #f0f6fc;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ----- CARROSSEL HORIZONTAL NA HOME --------------------------------------- */
/* Alinhado com .tools-card pra herdar a largura do .app-container (max 600px) */
.home-reels {
  margin-top: 24px;
  padding: 22px;
  background: linear-gradient(150deg, rgba(28, 33, 40, 0.55) 0%, rgba(13, 17, 23, 0.85) 100%);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 20px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.home-reels-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.home-reels-eyebrow {
  display: inline-block;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: #2d8a6e;
  margin-bottom: 6px;
}

.home-reels-title {
  font-size: 1.55rem;
  font-weight: 700;
  margin: 0;
  color: #f0f6fc;
}

.home-reels-sub {
  font-size: .9rem;
  color: #8b949e;
  margin: 4px 0 0;
}

.home-reels-all {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #2d8a6e;
  text-decoration: none;
  font-weight: 600;
  font-size: .92rem;
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid rgba(45, 138, 110, .35);
  transition: background .15s, border-color .15s;
}

.home-reels-all:hover {
  background: rgba(45, 138, 110, .12);
  border-color: #2d8a6e;
}

.home-reels-all svg { width: 14px; height: 14px; }

.home-reels-scroller {
  display: flex;
  gap: 14px;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 12px;
  /* permite que cards "vazem" um pouco das laterais do card pai */
  margin: 0 -8px;
  padding-left: 8px;
  padding-right: 8px;
  scrollbar-width: thin;
  scrollbar-color: #2d8a6e transparent;
}

.home-reels-scroller::-webkit-scrollbar { height: 6px; }
.home-reels-scroller::-webkit-scrollbar-track { background: transparent; }
.home-reels-scroller::-webkit-scrollbar-thumb { background: #30363d; border-radius: 3px; }
.home-reels-scroller::-webkit-scrollbar-thumb:hover { background: #2d8a6e; }

.reel-card--carousel {
  flex: 0 0 168px;
  scroll-snap-align: start;
}

@media (min-width: 768px) {
  .reel-card--carousel { flex-basis: 200px; }
  .home-reels-title    { font-size: 1.75rem; }
}

.home-reels-empty {
  flex: 1;
  padding: 32px;
  text-align: center;
  color: #8b949e;
  border: 1px dashed #30363d;
  border-radius: 12px;
}

/* ----- MOBILE FINE-TUNING ------------------------------------------------- */

@media (max-width: 480px) {
  .reels-list-header { padding: 14px 14px 8px; gap: 8px; }
  .reels-list-back span { display: none; }
  .reels-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .reel-card-body { padding: 10px 12px 14px; }
  .reel-card-title { font-size: .85rem; }
  .home-reels-head { flex-direction: column; align-items: flex-start; }
}
