/* =============================================================================== 
 *  https:// millers.com.br
 *  07/09/2025
 *  ------------------------------------------------------------------------------
 *
 *  TOC:
 *  01 -> Variáveis Globais e Estilos Base (OK)
 *  02 -> 
 *  03 -> Componentes (Cards, Painéis, Badges, Botões)
 *  04 -> Formulários
 *  05 -> Botão de Envio Moderno (com Progresso)
 *  06 -> Listagem de mídias (grid/cards)
 *  07 -> Alerts utilitários
 *  08 -> 
 *  09 -> Player de Áudio Customizado
 *  10 -> Preloader e Botão Voltar ao Topo
 *  11 -> Loader CSS - Tape Deck (OK)
 *  12 -> Animação no Fim das Postagens em Mobile
 *  49 -> Layout Desktop: Grade (OK)
 *  50 -> Layout Mobile (OK)
 *
 * =============================================================================== */

/* ===============================================================================
 * 01 -> Variáveis Globais e Estilos Base
 * =============================================================================== */

* {
  box-sizing: border-box;
}

html,
body {
  background-color: var(--bg);
  color: white;
}

/* --- Estrutura do Card --- */
.media-card {
  background-color: #222;
  border-radius: 8px;
  overflow: hidden;
  position: relative;
  border: 1px solid #333;
  display: flex;
  flex-direction: column;
}

.card-image-wrapper {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  background-color: #333;
}

.media-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.card-content {
  padding: 1rem;
  display: flex;
  flex-direction: column;
  flex-grow: 1; /* Permite que esta área cresça para preencher o espaço */
}

.card-title {
  font-weight: bold;
  font-size: 1.2rem;
  color: #c9c8ce;
}

.card-description {
  font-size: 0.9rem;
  color: #ccc;
  padding: 5px 0 0 0;
  margin: 0;
  color: #adacb1;
}

.card-post-date {
  font-size: 0.7rem;
  color: #8a8585;
  padding-top: 2px;
  margin-top: 2px;
  margin-bottom: 0.75rem; /* Reduzido para um espaçamento mais consistente */
  padding-bottom: 0; /* Removido para evitar altura extra desnecessária */
}

/* --- Categorias nos Cards --- */
.card-categories {
  /* margin-top: 0.5rem; */
  /* margin-bottom: 0.75rem; */
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
}

.card-categories .badge {
  font-size: 0.7rem;
  transition: background-color 0.2s ease;
  cursor: pointer;
}

.card-categories .badge.active,
.card-categories .badge:hover {
  background-color: var(--bs-primary) !important;
  color: white !important;
}

/* --- Overlays e Badges nos Cantos (APENAS DESKTOP) --- */
.corner-badge {
  position: absolute;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(5px);
  color: white;
  padding: 5px 10px;
  border-radius: 4px;
  font-size: 0.8rem;
  z-index: 10;
}

.corner-badge.top-left {
  top: 10px;
  left: 10px;
}
.corner-badge.top-right {
  top: 10px;
  right: 10px;
}

/* Botão Play - APENAS para desktop */
.card-image-wrapper > .teaser-play-button.d-md-flex {
  position: absolute;
  bottom: 10px;
  left: 10px;
  z-index: 10;
}

/* Rating - APENAS para desktop */
.stars-overlay-container {
  position: absolute;
  bottom: 10px;
  right: 10px;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(5px);
  color: white;
  padding: 5px 10px;
  border-radius: 4px;
  font-size: 0.8rem;
  z-index: 10;
  pointer-events: auto; /* Garante que o container seja clicável */
  display: flex;
  align-items: center;
  gap: 5px;
}

/* Estrelas */
.rating-stars input {
  display: none;
}

.rating-stars {
  display: flex;
  gap: 0 0.4em;
  transform: rotateY(180deg);
}

.rating-stars label {
  width: 20px;
  aspect-ratio: 1;
  cursor: pointer;
  transform: rotateY(180deg);
  position: relative; /* Necessário para o z-index funcionar */
  transition: transform 0.2s ease, filter 0.2s ease;
}

.rating-stars label:hover {
  transform: rotateY(180deg) scale(1.2);
  filter: blur(1px);
  z-index: 1; /* Garante que a estrela com hover fique sobre as outras */
}

.rating-stars .star-stroke {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  background: #6c757d; /* Cor da estrela "vazia" */
  clip-path: polygon(
    50% 0%,
    61% 35%,
    98% 35%,
    68% 57%,
    79% 91%,
    50% 70%,
    21% 91%,
    32% 57%,
    2% 35%,
    39% 35%
  );
  transition: background 0.2s;
}

.rating-stars .star-stroke .star-fill {
  width: 70%;
  aspect-ratio: 1;
  background: #222; /* Cor do "buraco" da estrela, combinando com o fundo do card */
  clip-path: polygon(
    50% 0%,
    61% 35%,
    98% 35%,
    68% 57%,
    79% 91%,
    50% 70%,
    21% 91%,
    32% 57%,
    2% 35%,
    39% 35%
  );
  transition: background 0.2s;
}

/* --- Lógica de Interação --- */

/* 1. ESTADO CHECKED (AVALIAÇÃO ATUAL) */
/* As estrelas até a selecionada (e as anteriores, devido ao rotateY) ficam amarelas. */
.rating-stars input:checked ~ label .star-stroke {
  background: var(--stars-border);
}
.rating-stars input:checked ~ label .star-stroke .star-fill {
  background: var(--stars); /* Cor do interior da estrela */
}

/* 2. ESTADO HOVER (INTERATIVO) */
/* Ao passar o mouse em uma estrela, ela e as anteriores (visualmente) se acendem em amarelo */
.rating-stars label:hover ~ label .star-stroke,
.rating-stars label:hover .star-stroke {
  background: var(--stars-border);
}
/* A estrela específica sob o cursor ganha a cor de destaque laranja */
.rating-stars label:hover .star-stroke {
  background: var(--stars-inner); /* Cor da borda do hover na estrela vazia */
}

.stars-overlay-container .vote-count {
  color: #ddd;
  font-size: 0.8rem;
  line-height: 1;
}

/* Seção downloads (desktop mantém botões padrão Bootstrap) */
.download-section {
  display: flex;
  flex-direction: column;
  margin-top: auto; /* Empurra a seção de download para o final do card */
  gap: 0.75rem; /* Espaço entre as categorias e a fileira de botões */
}

/* Mantém o estilo retangular em desktop (classe preexistente) */
.download-button-animated {
  flex-grow: 1;
  display: flex;
  flex-direction: row;
  overflow: hidden;
  align-items: center;
  justify-content: center;
  min-width: 100px;
  max-width: 100px;
  flex-shrink: 0;
  padding: 6px 10px;
  font-size: 0.85rem;
  border-radius: 8px;
}

/* ===============================================================================
 * 10 -> Preloader e Botão Voltar ao Topo
 * =============================================================================== */
#go-top {
  position: fixed;
  right: max(16px, env(safe-area-inset-right));
  bottom: max(16px, env(safe-area-inset-bottom));
  z-index: 1050; /* acima do conteúdo */
  opacity: 0;
  visibility: hidden;
  pointer-events: none; /* não clica quando oculto */
  transition: opacity 0.2s ease, visibility 0.2s ease;
}
#go-top.show {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}
#go-top a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(71, 52, 0, 0.7);
  color: #fff;
  border: 1px solid rgba(71, 52, 0, 0.7);
  text-decoration: none;
}
#go-top a:hover {
  background: rgba(165, 122, 2, 0.7);
}

/* ===============================================================================
 * 11 -> Loader CSS - Tape Deck com Capa
 * =============================================================================== */

.loader {
  margin: auto;
  width: 100px;
  height: 30px;
  overflow: hidden;
  position: relative;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 5px;
  box-shadow: 0px 35px 0 -5px #aaa, 0 -5px 0 0px #ddd, 0 -25px 0 -5px #fff,
    -25px -30px 0 0px #ddd, -25px 30px 0 0px #ddd, 25px -30px 0 0px #ddd,
    25px 30px 0 0px #ddd, 20px 10px 0 5px #ddd, 20px -10px 0 5px #ddd,
    -20px -10px 0 5px #ddd, -20px 10px 0 5px #ddd;
}
.loader:after,
.loader:before {
  content: "";
  border-radius: 100%;
  width: 35px;
  height: 35px;
  display: block;
  position: absolute;
  border: 4px dashed #fff;
  bottom: -4px;
  transform: rotate(0deg);
  box-sizing: border-box;
  animation: tape 4s linear infinite;
}
.loader:before {
  right: 0;
  box-shadow: 0 0 0 4px #fff, 0 0 0 34px #000;
}
.loader:after {
  left: 0;
  box-shadow: 0 0 0 4px #fff, 0 0 0 65px #000;
}

@keyframes tape {
  0% {
    transform: rotate(0deg) scale(0.4);
  }
  100% {
    transform: rotate(-360deg) scale(0.4);
  }
}

/* ===============================================================================
 * 12 -> Animação no Fim das Postagens em Mobile
 * =============================================================================== */

.tape-end {
  margin-top: 0; /* Removido para alinhar com os outros elementos. O espaçamento agora é controlado pelo 'gap' do container pai '.end-card-inner'. */
  width: 100px;
  height: 30px;
  overflow: hidden;
  position: relative;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 5px;
  box-shadow: 0px 35px 0 -5px #aaa, 0 -5px 0 0px #ddd, 0 -25px 0 -5px #fff,
    -25px -30px 0 0px #ddd, -25px 30px 0 0px #ddd, 25px -30px 0 0px #ddd,
    25px 30px 0 0px #ddd, 20px 10px 0 5px #ddd, 20px -10px 0 5px #ddd,
    -20px -10px 0 5px #ddd, -20px 10px 0 5px #ddd;
}

.tape-end:after,
.tape-end:before {
  content: "";
  border-radius: 100%;
  width: 35px;
  height: 35px;
  display: block;
  position: absolute;
  border: 4px dashed #fff;
  bottom: -4px;
  transform: rotate(0deg);
  box-sizing: border-box;
  animation: tape 4s linear infinite;
}

.tape-end:before {
  right: 0;
  box-shadow: 0 0 0 4px #fff, 0 0 0 34px #000;
}

.tape-end:after {
  left: 0;
  box-shadow: 0 0 0 4px #fff, 0 0 0 65px #000;
}

@keyframes tape {
  0% {
    transform: rotate(0deg) scale(0.4);
  }

  100% {
    transform: rotate(-360deg) scale(0.4);
  }
}

/* ===============================================================================
 * 49 -> Layout Desktop: Grade
 * =============================================================================== */

@media (min-width: 768px) {
  .gallery-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
    padding: 2rem;
    max-width: 1900px;
    margin-left: auto;
    margin-right: auto;
  }
}

/* ===============================================================================
 * 50 -> Layout Mobile
 * =============================================================================== */

@media (max-width: 767.98px) {
  /* Evitar duplo scroll e ajustar viewport dinâmica */
  html,
  body {
    height: 100dvh;
    margin: 0;
    padding: 0;
    overflow: hidden; /* o scroll fica só no contêiner da galeria */
  }

  /* Opcional: ocultar navbar para tela cheia */
  .navbar {
    display: none !important;
  }

  /* Contêiner vira scroller de tela inteira com CSS Scroll Snap */
  .gallery-container {
    display: block;
    height: 100dvh;
    overflow-y: auto;
    scroll-snap-type: y mandatory;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    scrollbar-width: none;
  }
  .gallery-container::-webkit-scrollbar {
    display: none;
  }

  /* Cada card ocupa a tela e "encaixa" */
  .media-card {
    min-height: 100svh;
    height: 100dvh;
    scroll-snap-align: start;
    scroll-snap-stop: always;
    margin: 0;
    border-radius: 0;
    border-left: 0;
    border-right: 0;
    display: flex;
    flex-direction: column;
    position: relative;
    z-index: 0;
  }

  /* A imagem preenche e recebe gradiente no rodapé p/ leitura do texto */
  .card-image-wrapper {
    position: relative;
    width: 100%;
    aspect-ratio: auto;
    flex: 1 1 auto;
    height: auto;
    z-index: 0;
  }
  .card-image-wrapper::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 45%;
    background: linear-gradient(
      180deg,
      rgba(0, 0, 0, 0) 0%,
      rgba(17, 17, 17, 0.75) 55%,
      rgba(17, 17, 17, 0.95) 100%
    );
    z-index: 1;
    pointer-events: none;
  }

  /* Título e descrição no rodapé da imagem, alinhados à esquerda */
  .card-content {
    position: absolute;
    left: 12px;
    right: 12px;
    bottom: max(12px, env(safe-area-inset-bottom));
    z-index: 10;
    background: rgba(0, 0, 0, 0.35);
    backdrop-filter: blur(4px);
    border-radius: 10px;
    padding: 12px 14px;
  }
  .card-title {
    margin: 0 0 6px 0;
    font-size: 1.1rem;
    line-height: 1.2;
    color: #c9c8ce;
  }
  .card-description {
    font-size: 0.9rem;
    color: #adacb1;
    padding: 0;
    margin: 0;
  }

  /* Badges superiores no mobile */
  .mobile-top-section {
    position: absolute;
    top: 8px;
    left: 8px;
    right: 8px;
    display: flex !important;
    justify-content: space-between;
    gap: 8px;
    z-index: 20;
  }
  .mobile-top-section .corner-badge {
    position: static;
    background: rgba(0, 0, 0, 0.55);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    border-radius: 8px;
  }

  /* Player 44x44 no mobile */
  .mobile-controls-row .teaser-play-button {
    /* Mantém o estilo base do componente .circular-progress-play-button,
       apenas sobrescreve a cor de fundo se desejado. */
    flex-shrink: 0; /* Impede que o botão seja espremido pelo flex container */
    background-color: #613966;
    border-color: #613966;
  }

  /* Botões de download: redondos apenas no mobile, mantendo as cores do Bootstrap */
  .mobile-controls-row a.btn {
    width: 44px;
    height: 44px;
    padding: 0 !important; /* remove padding do .btn */
    border-radius: 50% !important; /* círculo */
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
  }
  .mobile-controls-row a.btn i {
    font-size: 22px;
  }

  /* Estrelas no mobile dentro do fluxo */
  .mobile-controls-row .stars-overlay-container {
    position: static;
    background: rgba(0, 0, 0, 0.55);
    border-radius: 8px;
    padding: 6px 10px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
  }

  .media-card {
    min-height: 100%;
  }

  /* Card final (mobile e desktop, se quiser) */
  /* Card final: centralização e altura do viewport do scroller */
  .media-card.end-card {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%; /* ocupa exatamente a viewport do scroller */
    min-height: 100%; /* segurança extra */
    scroll-snap-align: center; /* opcional: “encaixa” ao centro do scroller */
    text-align: center;
  }

  .end-card-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2rem; /* Aumentado para evitar que a sombra do .tape-end sobreponha o texto. */
    width: 100%;
    height: 100%;
    margin: 0;
  }

  .end-card-inner img {
    width: 60vw;
    max-width: 100%;
    height: auto;
    display: block;
    margin: 0;
  }

  .end-card-logo {
    order: -1; /* Garante que a logo fique sempre no topo. */
    margin: 0;
  }

  .end-card-text {
    color: var(--success);
    font-size: 1.6rem;
    line-height: 1.6;
  }

  /* Ajuste para o botão Voltar ao Topo não sobrepor os controles */
  #go-top {
    bottom: calc(80px + env(safe-area-inset-bottom));
  }
}
