/* ===== ESTILOS GERAIS PADRÃO ===== */
:root {
  /* Variáveis padrão que serão sobrescritas por cada história */
  --audio-color1: #d6a8ff;
  --audio-color2: #a5b8ff;
  --audio-color3: #a5ffd6;
  --audio-text-color: #5a4b81;
  --btn-color1: #9b59b6;
  --btn-color2: #3498db;
  --progress-color1: #9b59b6;
  --progress-color2: #3498db;
  --text-color: #333;
  --bg-gradient-start: #f5f5f5;
  --bg-gradient-end: #e8f4f8;
  --header-gradient: linear-gradient(90deg, #9b59b6, #3498db);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: 'Baloo 2', cursive;
  background: linear-gradient(180deg, var(--bg-gradient-start), var(--bg-gradient-end));
  background-attachment: fixed;
  min-height: 100vh;
  color: var(--text-color);
  line-height: 1.8;
}

/* ===== HEADER ===== */
header {
  background: var(--header-gradient);
  color: #fff;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  position: relative;
  overflow: hidden;
  padding: 1.5rem;
  text-align: center;
}

header::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: url("data:image/svg+xml,%3Csvg width='100' height='100' viewBox='0 0 100 100' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M11 18c3.866 0 7-3.134 7-7s-3.134-7-7-7-7 3.134-7 7 3.134 7 7 7zm48 25c3.866 0 7-3.134 7-7s-3.134-7-7-7-7 3.134-7 7 3.134 7 7 7zm-43-7c1.657 0 3-1.343 3-3s-1.343-3-3-3-3 1.343-3 3 1.343 3 3 3zm63 31c1.657 0 3-1.343 3-3s-1.343-3-3-3-3 1.343-3 3 1.343 3 3 3zM34 90c1.657 0 3-1.343 3-3s-1.343-3-3-3-3 1.343-3 3 1.343 3 3 3zm56-76c1.657 0 3-1.343 3-3s-1.343-3-3-3-3 1.343-3 3 1.343 3 3 3zM12 86c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm28-65c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm23-11c2.76 0 5-2.24 5-5s-2.24-5-5-5-5 2.24-5 5 2.24 5 5 5zm-6 60c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm29 22c2.76 0 5-2.24 5-5s-2.24-5-5-5-5 2.24-5 5 2.24 5 5 5zM32 63c2.76 0 5-2.24 5-5s-2.24-5-5-5-5 2.24-5 5 2.24 5 5 5zm57-13c2.76 0 5-2.24 5-5s-2.24-5-5-5-5 2.24-5 5 2.24 5 5 5zm-9-21c1.105 0 2-.895 2-2s-.895-2-2-2-2 .895-2 2 .895 2 2 2zM60 91c1.105 0 2-.895 2-2s-.895-2-2-2-2 .895-2 2 .895 2 2 2zM35 41c1.105 0 2-.895 2-2s-.895-2-2-2-2 .895-2 2 .895 2 2 2zM12 60c1.105 0 2-.895 2-2s-.895-2-2-2-2 .895-2 2 .895 2 2 2z' fill='%23ffffff' fill-opacity='0.1' fill-rule='evenodd'/%3E%3C/svg%3E");
  opacity: 0.1;
  z-index: 0;
}

header h1 {
  position: relative;
  z-index: 1;
  margin: 0;
  font-size: 2.5rem;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

/* ===== CONTAINER PRINCIPAL ===== */
.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

/* ===== IMAGEM DA HISTÓRIA ===== */
.imagem {
  margin: 2rem auto;
  max-width: 1100px;
  border-radius: 20px;
  overflow: hidden;
  box-shadow: 0 15px 40px rgba(0, 0, 0, 0.2);
  border: 6px solid white;
  transition: all 0.4s ease;
  opacity: 0;
  transform: translateY(30px);
  animation: aparecer 0.8s ease-out 0.1s forwards;
}

.imagem:hover {
  transform: translateY(-5px);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
}

.imagem img {
  width: 100%;
  height: auto;
  display: block;
  transition: transform 0.7s ease, filter 0.7s ease;
}

.imagem:hover img {
  transform: scale(1.02);
  filter: brightness(1.05);
}

/* ===== TEXTO DA HISTÓRIA ===== */
.historia {
  background: rgba(255, 255, 255, 0.95);
  padding: 3rem;
  border-radius: 20px;
  margin: 2rem 0;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.1);
  border-left: 8px solid var(--btn-color1);
  border-right: 8px solid var(--btn-color2);
  hyphens: auto;
  text-align: justify;
  opacity: 0;
  transform: translateY(30px);
  animation: aparecer 0.8s ease-out 0.3s forwards;
}

.historia p {
  margin-bottom: 1.8rem;
  font-size: 1.15rem;
  line-height: 1.9;
  color: #5D4037;
  text-indent: 2rem;
}

.historia p:first-of-type {
  text-indent: 0;
}

.historia p:first-of-type::first-letter {
  initial-letter: 3;
  font-weight: bold;
  color: var(--btn-color1);
  background: linear-gradient(135deg, var(--btn-color1), var(--btn-color2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-right: 8px;
  float: left;
  line-height: 1;
  font-size: 4rem;
  padding-right: 8px;
  padding-top: 8px;
}

/* ===== PLAYER DE ÁUDIO ===== */
.audio-player {
  background: linear-gradient(135deg, var(--audio-color1), var(--audio-color2), var(--audio-color3));
  border-radius: 20px;
  padding: 2.5rem;
  margin: 3rem auto;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15);
  border: 3px solid rgba(0, 0, 0, 0.08);
  max-width: 1100px;
  opacity: 0;
  transform: translateY(30px);
  animation: aparecer 0.8s ease-out 0.5s forwards;
  animation-fill-mode: forwards;
}

.audio-player.playing {
  opacity: 1 !important;
  transform: translateY(0) !important;
}

.audio-header {
  font-size: 1.5rem;
  font-weight: bold;
  color: var(--audio-text-color);
  margin-bottom: 1.5rem;
  text-align: center;
  padding-bottom: 1rem;
  border-bottom: 2px solid rgba(0, 0, 0, 0.1);
}

/* CONTROLES DO PLAYER */
.controls {
  text-align: left;
}

.control-row {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.control-btn {
  background: linear-gradient(135deg, var(--btn-color1), var(--btn-color2));
  border: none;
  color: white;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
  font-size: 1rem;
}

.control-btn:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
}

.control-btn:focus-visible {
  outline: 3px solid var(--btn-color1);
  outline-offset: 3px;
}

.time-display {
  font-size: 1.1rem;
  color: var(--audio-text-color);
  font-weight: 500;
  min-width: 120px;
}

/* BARRA DE PROGRESSO - SOLUÇÃO SIMPLIFICADA E FUNCIONAL */
.progress-container {
  flex: 1;
  min-width: 200px;
  height: 14px;
  background: rgba(0, 0, 0, 0.1);
  border-radius: 14px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  border-radius: 14px;
  /* Fallback sólido + gradient com variáveis */
  background: #e74c3c; /* cor primária fallback */
  background: linear-gradient(90deg, var(--progress-color1, #e74c3c), var(--progress-color2, #f39c12));
  width: 0%;
  transition: width 0.1s linear;
  min-width: 0;
}

/* Garante área de toque mínima */
.progress-slider {
  position: absolute;
  top: -10px;
  left: 0;
  width: 100%;
  height: 36px; /* Padrão de acessibilidade: mínimo 36px de altura */
  margin: 0;
  padding: 0;
  opacity: 0;
  cursor: pointer;
  z-index: 10;
  -webkit-appearance: none;
  appearance: none;
}

/* Estilo para o input range quando focado */
.progress-slider:focus-visible {
  outline: 2px solid var(--btn-color1);
  outline-offset: 2px;
  border-radius: 14px;
}

/* CONTROLES DE VELOCIDADE */
.speed-controls {
  display: flex;
  gap: 0.8rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  justify-content: center;
}

.speed-btn {
  padding: 0.8rem 1.5rem;
  background: white;
  border: 2px solid rgba(0, 0, 0, 0.1);
  border-radius: 50px;
  color: var(--audio-text-color);
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s ease;
  font-size: 0.9rem;
}

.speed-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.speed-btn.active {
  background: linear-gradient(135deg, var(--btn-color1), var(--btn-color2));
  color: white;
  border-color: transparent;
}

/* CONTROLE DE VOLUME */
.volume-control {
  display: flex;
  align-items: center;
  gap: 1rem;
  max-width: 300px;
  margin: 0 auto;
  justify-content: center;
}

.volume-control svg {
  color: var(--audio-text-color);
}

.volume-slider {
  flex: 1;
  height: 8px;
  -webkit-appearance: none;
  appearance: none;
  background: rgba(0, 0, 0, 0.1);
  border-radius: 10px;
  outline: none;
  max-width: 200px;
}

.volume-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  background: var(--btn-color1);
  border-radius: 50%;
  cursor: pointer;
  border: 3px solid white;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.volume-slider::-moz-range-thumb {
  width: 20px;
  height: 20px;
  background: var(--btn-color1);
  border-radius: 50%;
  cursor: pointer;
  border: 3px solid white;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

/* BOTÃO VOLTAR */
.voltar {
  margin-top: 3rem;
  text-align: center;
}

.voltar a {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  background: white;
  border: 2px solid rgba(0, 0, 0, 0.15);
  border-radius: 50px;
  color: var(--audio-text-color);
  font-weight: 500;
  font-size: 0.95rem;
  text-decoration: none;
  transition: all 0.3s ease;
}

.voltar a:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  background: linear-gradient(135deg, var(--btn-color1), var(--btn-color2));
  color: white;
  border-color: transparent;
}

.voltar a:active {
  transform: translateY(-1px);
}

/* ===== ANIMAÇÕES ===== */
@keyframes aparecer {
  0% {
    opacity: 0;
    transform: translateY(30px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ===== ACESSIBILIDADE ===== */
:focus-visible {
  outline: 3px solid var(--btn-color1);
  outline-offset: 3px;
  border-radius: 4px;
}

/* ===== ELEMENTOS DECORATIVOS ===== */
.decoracao {
  position: fixed;
  width: 80px;
  height: 80px;
  z-index: -1;
  pointer-events: none;
  opacity: 0;
  animation: aparecer 1s ease-out forwards;
}

/* ===== GARANTIAS DE VISIBILIDADE ===== */
.imagem,
.audio-player,
.historia {
  visibility: visible !important;
  opacity: 1 !important;
  display: block !important;
}

/* ===== RESPONSIVIDADE ===== */
@media (max-width: 1200px) {
  .container {
    max-width: 900px;
  }
}

@media (max-width: 992px) {
  .container {
    padding: 1.5rem 1rem;
  }
  
  .historia {
    padding: 2rem;
  }
  
  header h1 {
    font-size: 2rem;
  }
  
  .historia p:first-of-type::first-letter {
    font-size: 3rem;
  }
}

@media (max-width: 768px) {
  .historia {
    padding: 1.5rem;
    text-align: left;
  }
  
  .historia p {
    font-size: 1.05rem;
    line-height: 1.7;
  }
  
  .audio-player {
    padding: 1.5rem;
  }
  
  .speed-controls {
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
  }
  
  .speed-btn {
    flex: 1 0 calc(50% - 10px);
    min-width: 140px;
    padding: 10px;
    font-size: 0.9rem;
  }
  
  .control-row {
    flex-direction: column;
    align-items: center;
    gap: 15px;
  }

  .progress-container {
    height: 18px; /* já tem, ok */
    min-height: 18px;
    background: rgba(0,0,0,0.1) !important; /* fundo visível */
  }

  .progress-bar {
    height: 100% !important;
    min-height: 18px; /* crucial para mobile */
  }
}
  
  .progress-slider {
    height: 30px; /* Área de toque maior */
    top: -7px; /* Centralizar verticalmente */
  }
  
  .time-display {
    font-size: 0.9rem;
  }
  
  .control-btn {
    width: 50px;
    height: 50px;
  }
  
  .volume-control {
    max-width: 250px;
  }
  
  .volume-slider {
    max-width: 180px;
  }
}

@media (max-width: 480px) {
  header h1 {
    font-size: 1.8rem;
  }
  
  .container {
    padding: 1rem 0.8rem;
  }
  
  .historia {
    padding: 1.2rem;
    border-radius: 12px;
  }
  
  .imagem {
    margin: 1.5rem auto;
    border-radius: 12px;
  }
  
  .speed-btn {
    flex: 1 0 100%;
  }
  
  .voltar a {
    font-size: 0.9rem;
    padding: 10px 16px;
  }
  
  /* Área de toque ainda maior em celulares pequenos */
  .progress-container {
    height: 18px;
  }
  
  .progress-slider {
    height: 40px;
    top: -11px;
  }
}

.imagem video {
  width: 100%;
  height: auto;
  display: block;
  object-fit: contain; /* ou "cover" se quiser preencher sem bordas */
  background: #000; /* opcional: evita fundo branco se houver bordas */
}

/* Garante que a barra de progresso seja visível mesmo se vazia */
.progress-container {
  min-height: 16px;
  background: rgba(0,0,0,0.08) !important;
}

.progress-bar {
  min-width: 4px; /* Evita sumir quando no início */
}