/* =========================================================
   Historia en viñetas — visor a pantalla completa.
   En el teléfono ocupa toda la pantalla; en el computador
   se muestra como una historia vertical centrada.
   ========================================================= */

html.historia-abierta,
html.historia-abierta body { overflow: hidden; }

.historia {
  position: fixed;
  inset: 0;
  z-index: 300;
  overflow: hidden;
  background: #050403;
  color: var(--marfil);
  opacity: 0;
  transition: opacity .3s ease;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}

.historia.is-visible { opacity: 1; }

@media (min-width: 700px) {
  .historia {
    left: 50%;
    width: min(100vw, calc(100vh * 9 / 16));
    transform: translateX(-50%);
    box-shadow: 0 0 0 100vmax rgba(5, 4, 3, .97);
  }
}

/* ---------- Barra de progreso por segmentos ---------- */

.historia__progreso {
  position: absolute;
  top: calc(10px + env(safe-area-inset-top, 0px));
  left: 12px;
  right: 12px;
  z-index: 5;
  display: flex;
  gap: 4px;
  transition: opacity .2s ease;
}

.historia__segmento {
  flex: 1;
  height: 3px;
  overflow: hidden;
  border-radius: 2px;
  background: rgba(238, 230, 212, .28);
}

.historia__segmento > span {
  display: block;
  height: 100%;
  background: var(--marfil);
  transform: scaleX(0);
  transform-origin: left center;
}

/* ---------- Cabecera ---------- */

.historia__cabecera {
  position: absolute;
  top: calc(20px + env(safe-area-inset-top, 0px));
  left: 12px;
  right: 6px;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: opacity .2s ease;
}

.historia__marca {
  width: 30px;
  height: auto;
}

.historia__titulo {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .04em;
  white-space: nowrap;
  text-overflow: ellipsis;
  text-shadow: 0 1px 6px rgba(0, 0, 0, .7);
}

.historia__boton {
  width: 40px;
  height: 40px;
  border: 0;
  background: none;
  font-size: 15px;
  line-height: 1;
  color: var(--marfil);
  cursor: pointer;
  text-shadow: 0 1px 6px rgba(0, 0, 0, .7);
}

.historia__cerrar { font-size: 30px; }

.historia.is-sostenido .historia__cabecera,
.historia.is-sostenido .historia__progreso { opacity: 0; }

.historia.is-final .historia__pausa { visibility: hidden; }

/* ---------- Zonas táctiles ---------- */

.historia__zonas {
  position: absolute;
  inset: 72px 0 0;
  z-index: 3;
  display: flex;
}

.historia__zona {
  height: 100%;
  border: 0;
  background: none;
  cursor: pointer;
}

.historia__zona--atras { width: 30%; }
.historia__zona--adelante { width: 70%; }

.historia__zona:focus-visible {
  outline: 2px solid var(--bronce-claro);
  outline-offset: -8px;
}

.historia.is-final .historia__zonas { display: none; }

/* ---------- Viñetas ---------- */

.historia__escenario {
  position: absolute;
  inset: 0;
}

.vineta {
  position: absolute;
  inset: 0;
  z-index: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 0 26px calc(56px + env(safe-area-inset-bottom, 0px));
  opacity: 0;
  visibility: hidden;
  transition: opacity .4s ease, visibility 0s linear .4s;
}

.vineta.is-activa {
  z-index: 1;
  opacity: 1;
  visibility: visible;
  transition: opacity .4s ease, visibility 0s;
}

/* Imagen de fondo con oscurecimiento inferior para que el texto se lea */
.vineta__fondo {
  position: absolute;
  inset: 0;
  z-index: -2;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.vineta[data-fondo]::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: linear-gradient(to bottom, rgba(5, 4, 3, .55) 0%, rgba(5, 4, 3, 0) 22%, rgba(5, 4, 3, 0) 42%, rgba(5, 4, 3, .88) 78%, #050403 100%);
}

.vineta__texto {
  margin: 0;
  max-width: 24ch;
  font-family: var(--serif);
  font-size: clamp(24px, 6.8vw, 30px);
  line-height: 1.28;
  color: var(--marfil);
  text-shadow: 0 2px 12px rgba(0, 0, 0, .6);
}

.vineta__texto em {
  font-style: italic;
  color: var(--bronce-claro);
}

.vineta__nota {
  margin: 14px 0 0;
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: .04em;
  color: var(--marfil-tenue);
}

.vineta__credito {
  position: absolute;
  top: calc(70px + env(safe-area-inset-top, 0px));
  right: 14px;
  font-family: var(--sans);
  font-size: 9.5px;
  letter-spacing: .06em;
  color: rgba(238, 230, 212, .55);
}

/* Cifra gigante */
.vineta--cifra { justify-content: center; }

.vineta__cifra {
  margin: 0 0 12px;
  font-family: var(--serif);
  font-size: clamp(90px, 28vw, 150px);
  font-weight: 500;
  line-height: .9;
  color: var(--bronce-claro);
}

/* Escena negra: una sola estrella */
.vineta__estrella {
  position: absolute;
  top: 42%;
  left: 50%;
  width: 6px;
  height: 6px;
  margin: -3px 0 0 -3px;
  border-radius: 50%;
  background: #FFF3DC;
  box-shadow: 0 0 14px 4px rgba(255, 236, 200, .55), 0 0 60px 18px rgba(205, 170, 114, .18);
}

/* Círculo bronce sobre la foto (punto rojo) */
.vineta__circulo {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 76px;
  height: 76px;
  margin: -38px 0 0 -38px;
  border: 1.5px solid var(--bronce-claro);
  border-radius: 50%;
  box-shadow: 0 0 18px rgba(205, 170, 114, .45);
}

/* Órbitas: un planeta sale disparado */
.vineta__orbitas {
  position: absolute;
  top: 40%;
  left: 50%;
  width: 0;
  height: 0;
}

.vineta__orbitas .sol {
  position: absolute;
  width: 20px;
  height: 20px;
  margin: -10px 0 0 -10px;
  border-radius: 50%;
  background: #FFF3DC;
  box-shadow: 0 0 30px 10px rgba(255, 220, 160, .45);
}

.vineta__orbitas .orbita {
  position: absolute;
  border: 1px dashed rgba(238, 230, 212, .18);
  border-radius: 50%;
}

.vineta__orbitas .orbita--1 { width: 150px; height: 150px; margin: -75px 0 0 -75px; }
.vineta__orbitas .orbita--2 { width: 250px; height: 250px; margin: -125px 0 0 -125px; }

.vineta__orbitas .giro {
  position: absolute;
  width: 0;
  height: 0;
}

.vineta__orbitas .planeta {
  position: absolute;
  width: 12px;
  height: 12px;
  margin: -6px 0 0 -6px;
  border-radius: 50%;
}

.vineta__orbitas .giro--1 .planeta { transform: translateX(75px); background: var(--marfil); }
.vineta__orbitas .giro--2 .planeta { transform: translateX(125px); background: var(--bronce-claro); }

/* Microlente: el planeta oscuro cruza y la estrella brilla */
.vineta__lente {
  position: absolute;
  top: 40%;
  left: 0;
  right: 0;
  height: 0;
}

.vineta__lente .estrella {
  position: absolute;
  left: 50%;
  width: 6px;
  height: 6px;
  margin: -3px 0 0 -3px;
  border-radius: 50%;
  background: #FFF3DC;
  box-shadow: 0 0 10px 3px rgba(255, 236, 200, .5);
}

.vineta__lente .oscuro {
  position: absolute;
  top: -22px;
  left: 10%;
  width: 18px;
  height: 18px;
  margin-left: -9px;
  border: 1px dashed rgba(205, 170, 114, .8);
  border-radius: 50%;
  background: #050403;
}

/* ---------- Viñeta final ---------- */

.vineta--final {
  justify-content: center;
  align-items: center;
  text-align: center;
}

.vineta--final .vineta__texto { max-width: 20ch; }

.vineta__aibu {
  width: 88px;
  height: auto;
  margin: 0 auto 20px;
}

.vineta__acciones {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: min(300px, 100%);
  margin-top: 30px;
}

.vineta__accion {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 52px;
  padding: 8px 18px;
  border: 1px solid rgba(205, 170, 114, .55);
  border-radius: 999px;
  background: rgba(5, 4, 3, .6);
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .16em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--bronce-claro);
  cursor: pointer;
}

.vineta__accion--principal {
  border-color: var(--bronce-claro);
  background: var(--bronce);
  color: #120D09;
}

.vineta__accion small {
  margin-top: 2px;
  font-family: var(--serif);
  font-size: 13px;
  font-style: italic;
  font-weight: 400;
  letter-spacing: 0;
  text-transform: none;
  color: var(--marfil-tenue);
}

.vineta__accion[hidden] { display: none; }

.historia__aviso {
  position: absolute;
  bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  left: 50%;
  z-index: 6;
  margin: 0;
  padding: 10px 18px;
  transform: translateX(-50%);
  border-radius: 999px;
  background: var(--marfil);
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 600;
  color: #120D09;
}

/* ---------- Movimiento ---------- */

@media (prefers-reduced-motion: no-preference) {
  .vineta.is-animando .vineta__fondo { animation: acercar 9s ease-out both; }
  .vineta.is-animando .vineta__texto,
  .vineta.is-animando .vineta__cifra { animation: subir .7s .15s cubic-bezier(.2, .7, .2, 1) both; }
  .vineta.is-animando .vineta__nota { animation: subir .7s .45s cubic-bezier(.2, .7, .2, 1) both; }
  .vineta.is-animando .vineta__circulo { animation: aparecer-circulo 1.2s 1s ease-out both; }
  .vineta.is-animando .vineta__estrella { animation: latir 2.4s ease-in-out infinite; }

  .vineta.is-animando .giro--1 { animation: girar 2.4s linear infinite; }
  .vineta.is-animando .giro--2 { animation: girar 4s linear infinite; }
  .vineta.is-animando .giro--1 .planeta { animation: escapar 6s 2.4s cubic-bezier(.5, 0, .9, .4) both; }

  .vineta.is-animando .vineta__lente .oscuro { animation: cruzar 5.5s .4s linear both; }
  .vineta.is-animando .vineta__lente .estrella { animation: brillar 5.5s .4s linear both; }
}

@keyframes acercar { from { transform: scale(1.12); } to { transform: scale(1); } }
@keyframes subir { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }
@keyframes aparecer-circulo { from { opacity: 0; transform: scale(2); } to { opacity: 1; transform: scale(1); } }
@keyframes latir { 50% { transform: scale(1.5); opacity: .8; } }
@keyframes girar { to { transform: rotate(-360deg); } }
@keyframes escapar {
  from { transform: translateX(75px); opacity: 1; }
  to { transform: translateX(520px); opacity: 0; }
}
@keyframes cruzar { from { left: 10%; } to { left: 90%; } }
@keyframes brillar {
  0%, 38% { transform: scale(1); box-shadow: 0 0 10px 3px rgba(255, 236, 200, .5); }
  50% { transform: scale(2.4); box-shadow: 0 0 40px 18px rgba(255, 236, 200, .8); }
  62%, 100% { transform: scale(1); box-shadow: 0 0 10px 3px rgba(255, 236, 200, .5); }
}

/* ---------- Viñeta con barras (ej.: participación de China) ---------- */

.vineta__barras {
  display: grid;
  gap: 16px;
  margin: 0 0 30px;
  padding: 0;
  list-style: none;
}

.vineta__barras li {
  display: grid;
  grid-template-columns: 92px 1fr 52px;
  align-items: center;
  gap: 12px;
}

.vineta__barras .nombre {
  font-family: var(--serif);
  font-size: 20px;
  color: var(--marfil);
}

.vineta__barras .barra {
  position: relative;
  height: 12px;
  overflow: hidden;
  border-radius: 6px;
  background: rgba(238, 230, 212, .12);
}

.vineta__barras .barra span {
  position: absolute;
  inset: 0 auto 0 0;
  width: calc(var(--valor) * 1%);
  border-radius: 6px;
  background: linear-gradient(90deg, var(--bronce), var(--bronce-claro));
}

.vineta__barras .valor {
  font-family: var(--sans);
  font-size: 16px;
  font-weight: 600;
  text-align: right;
  color: var(--bronce-claro);
}

.vineta__barras-titulo {
  margin: 0 0 18px;
  font-family: var(--sans);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--bronce);
}

.vineta--centro { justify-content: center; }

@media (prefers-reduced-motion: no-preference) {
  .vineta.is-animando .vineta__barras .barra span { animation: llenar 1.4s .3s cubic-bezier(.2, .7, .2, 1) both; }
  .vineta.is-animando .vineta__barras li:nth-child(2) .barra span { animation-delay: .6s; }
  .vineta.is-animando .vineta__barras li:nth-child(3) .barra span { animation-delay: .9s; }
}

@keyframes llenar { from { width: 0; } }

/* Viñetas de solo texto: un resplandor cálido muy suave */
.vineta[data-tipo="texto"],
.vineta[data-tipo="cifra"],
.vineta[data-tipo="barras"] {
  background: radial-gradient(120% 70% at 50% 35%, rgba(176, 138, 82, .16), rgba(5, 4, 3, 0) 60%), #050403;
}
