/* ==========================================================================
   STORIES - LA TARJETA DE TEXTO
   --------------------------------------------------------------------------
   El visor, el progreso y las stories de video e imagen siguen en
   css/styles.css: ese diseno no cambia.

   Lo que se rehace aqui es la story de TEXTO, que era una caja translucida
   con un titulo y un parrafo, igual para todas. Con la mitad de las stories
   siendo de ese tipo, la sensacion era de plantilla sin terminar.

   Ahora cada una trae etiqueta, icono y acento de color, tiene fondo propio
   y su contenido entra escalonado. Los tres campos son opcionales: una story
   antigua sin ellos se sigue pintando, solo que mas sobria.
   ========================================================================== */

.story-content-texto {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: linear-gradient(150deg, #0b1e3b 0%, #12335f 55%, #16406f 100%);
}

/* ---------- Acentos ---------- */

.story-content-texto[data-acento="lima"] {
  --st-acento: #8dc63f;
  --st-acento-hondo: #79b12f;
}

.story-content-texto[data-acento="azul"] {
  --st-acento: #4da3ff;
  --st-acento-hondo: #2b7fd4;
}

.story-content-texto[data-acento="ambar"] {
  --st-acento: #f0b429;
  --st-acento-hondo: #d19a13;
}

/* ---------- Trama de rombos, la de la marca ---------- */

.story-trama {
  position: absolute;
  inset: 0;
  opacity: 0.6;
  /* Muy tenue y con la celda grande: tiene que dar textura, no dibujar un
     tablero de ajedrez por encima del texto. */
  background-image:
    linear-gradient(45deg, rgba(255, 255, 255, 0.018) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(255, 255, 255, 0.018) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, rgba(255, 255, 255, 0.018) 75%),
    linear-gradient(-45deg, transparent 75%, rgba(255, 255, 255, 0.018) 75%);
  background-size: 64px 64px;
  background-position: 0 0, 0 32px, 32px -32px, -32px 0;
  /* Se desplaza muy despacio: da vida sin pedir atencion */
  animation: stTrama 26s linear infinite;
}

@keyframes stTrama {
  to {
    background-position: 64px 64px, 64px 96px, 96px 32px, 32px 64px;
  }
}

/* ---------- El icono grande del fondo ---------- */

/* Ocupa la esquina y se sale del encuadre a proposito: da profundidad y
   dice de que va la story antes de leer una palabra. */
.story-glifo {
  position: absolute;
  right: -14%;
  bottom: -8%;
  font-size: clamp(11rem, 34vw, 17rem);
  line-height: 1;
  color: var(--st-acento, #8dc63f);
  opacity: 0.11;
  transform: rotate(-12deg);
  pointer-events: none;
}

/* ---------- El halo de color ---------- */

.story-content-texto::before {
  content: "";
  position: absolute;
  top: -22%;
  left: -18%;
  width: 68%;
  height: 68%;
  border-radius: 50%;
  background: radial-gradient(
    circle,
    var(--st-acento, #8dc63f) 0%,
    transparent 68%
  );
  opacity: 0.22;
  pointer-events: none;
}

/* ---------- El contenido ---------- */

.story-texto {
  position: relative;
  z-index: 2;
  width: 100%;
  /* 3.4rem a cada lado: las flechas de navegacion van a media altura y
     pegadas a los bordes. Sin este hueco se comian el parrafo. */
  padding: 0 3.4rem;
  max-width: 460px;
  color: #ffffff;
  text-align: left;
}

.story-etiqueta {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  margin-bottom: 1.1rem;
  padding: 0.4rem 0.9rem;
  border: 1px solid var(--st-acento, #8dc63f);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--st-acento, #8dc63f);
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.story-content-texto .story-title {
  margin: 0 0 0.9rem;
  color: #ffffff;
  font-size: clamp(1.5rem, 6.2vw, 2.05rem);
  font-weight: 700;
  line-height: 1.18;
  letter-spacing: -0.01em;
}

.story-content-texto .story-description {
  margin: 0 0 1.6rem;
  color: rgba(226, 234, 244, 0.88);
  font-size: clamp(0.92rem, 3.6vw, 1.02rem);
  line-height: 1.6;
}

.story-content-texto .story-cta {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.85rem 1.5rem;
  border-radius: 12px;
  background: linear-gradient(
    135deg,
    var(--st-acento, #8dc63f),
    var(--st-acento-hondo, #79b12f)
  );
  color: #0b1e3b;
  font-size: 0.95rem;
  font-weight: 700;
  text-decoration: none;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.3);
  transition: transform 0.22s ease, box-shadow 0.22s ease, gap 0.22s ease;
}

.story-content-texto .story-cta:hover {
  gap: 0.85rem;
  transform: translateY(-2px);
  box-shadow: 0 16px 34px rgba(0, 0, 0, 0.38);
}

/* ---------- La entrada, escalonada ---------- */

/* Solo se anima la story que se esta viendo. Animar todas a la vez al
   cargar significaria que la tercera termina su entrada antes de que a
   nadie le de tiempo a llegar. */
.story-slide.active .story-content-texto .story-etiqueta {
  animation: stEntra 520ms cubic-bezier(0.16, 0.86, 0.26, 1) 100ms both;
}
.story-slide.active .story-content-texto .story-title {
  animation: stEntra 560ms cubic-bezier(0.16, 0.86, 0.26, 1) 200ms both;
}
.story-slide.active .story-content-texto .story-description {
  animation: stEntra 560ms cubic-bezier(0.16, 0.86, 0.26, 1) 320ms both;
}
.story-slide.active .story-content-texto .story-cta {
  animation: stEntra 520ms cubic-bezier(0.16, 0.86, 0.26, 1) 450ms both;
}
.story-slide.active .story-content-texto .story-glifo {
  animation: stGlifo 900ms cubic-bezier(0.16, 0.86, 0.26, 1) both;
}

@keyframes stEntra {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes stGlifo {
  from {
    opacity: 0;
    transform: rotate(-24deg) scale(0.82);
  }
  to {
    opacity: 0.11;
    transform: rotate(-12deg) scale(1);
  }
}

/* ---------- Movil ---------- */

@media (max-width: 480px) {
  .story-texto {
    padding: 0 2.8rem;
  }

  .story-glifo {
    right: -20%;
    bottom: -6%;
  }
}

@media (prefers-reduced-motion: reduce) {
  .story-trama {
    animation: none;
  }

  .story-slide.active .story-content-texto .story-etiqueta,
  .story-slide.active .story-content-texto .story-title,
  .story-slide.active .story-content-texto .story-description,
  .story-slide.active .story-content-texto .story-cta,
  .story-slide.active .story-content-texto .story-glifo {
    animation: none;
  }

  .story-content-texto .story-cta {
    transition: none;
  }

  .story-content-texto .story-cta:hover {
    transform: none;
  }
}

/* ==================================================================
   ANILLO DEGRADADO DEL LOGO
   ------------------------------------------------------------------
   Con stories sin ver: anillo lima con degradado que gira despacio.
   Ya vistas todas: una linea blanca muy fina, sin relleno. Antes, al
   verlas, el anillo se rellenaba de gris y dejaba un disco apagado
   detras del logo.

   El protagonista es el logo: el anillo es fino y va pegado por fuera.
   Los !important pisan las reglas viejas de .stories-ring que siguen en
   styles.css y paginas.css (borde, pulso y relleno gris).
   ================================================================== */

.stories-indicator .stories-ring {
  inset: -4px !important;
  border: 0 !important;
  border-radius: 50%;
  opacity: 0 !important;
  background: none !important;
  animation: none !important;
  pointer-events: none;
}

/* Medidas copiadas de la maqueta aprobada: anillo de 3px pegado al logo,
   4px por fuera del indicador. */
.stories-indicator.has-stories:not(.stories-seen) .stories-ring {
  opacity: 1 !important;
  background: conic-gradient(#8dc63f, #d4f28a, #3fa36b, #8dc63f) !important;
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 3px), #000 calc(100% - 2.5px));
  mask: radial-gradient(farthest-side, transparent calc(100% - 3px), #000 calc(100% - 2.5px));
  animation: storiesAnilloGira 3s linear infinite !important;
}

.stories-indicator.stories-seen .stories-ring {
  opacity: 1 !important;
  box-shadow: inset 0 0 0 1.5px rgba(255, 255, 255, 0.22);
}

@keyframes storiesAnilloGira {
  to {
    transform: rotate(360deg);
  }
}

/* El logo, como en la maqueta: recortado en circulo, 4px menos que el
   indicador (2px de aire por cada lado hasta el anillo). */
.stories-indicator .stories-logo {
  width: calc(100% - 4px) !important;
  height: calc(100% - 4px) !important;
  border: 0;
  border-radius: 50%;
  object-fit: cover;
  transform: none;
}

.stories-indicator:hover .stories-logo {
  transform: scale(1.05);
}

@media (prefers-reduced-motion: reduce) {
  .stories-indicator.has-stories:not(.stories-seen) .stories-ring {
    animation: none !important;
  }
}

/* ==================================================================
   AVISO "TOCA EL LOGO"
   ------------------------------------------------------------------
   Cuando sale y cuando se va lo decide js/stories.js (programarAviso).
   ================================================================== */

.stories-aviso {
  position: absolute;
  top: calc(100% + 16px);
  left: -6px;
  z-index: 1100;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px 12px;
  border-radius: 12px;
  background: #fff;
  color: #0f2140;
  border: 1px solid #e3e9f0;
  box-shadow: 0 16px 36px -12px rgba(11, 30, 59, 0.45);
  white-space: nowrap;
  font-family: "Poppins", system-ui, sans-serif;
  text-align: left;
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-6px) scale(0.96);
  transform-origin: 26px 0;
  transition: opacity 0.3s ease, transform 0.3s ease, visibility 0.3s;
  pointer-events: none;
}

.stories-aviso.visible {
  opacity: 1;
  visibility: visible;
  transform: none;
  pointer-events: auto;
}

/* Piquito apuntando al logo */
.stories-aviso::before {
  content: "";
  position: absolute;
  top: -7px;
  left: 25px;
  width: 12px;
  height: 12px;
  background: #fff;
  border-left: 1px solid #e3e9f0;
  border-top: 1px solid #e3e9f0;
  transform: rotate(45deg);
}

.stories-aviso__flecha {
  flex: none;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: #8dc63f;
  color: #1b2a07;
  display: grid;
  place-items: center;
  animation: storiesAvisoEmpuja 1s ease-in-out infinite;
}

.stories-aviso__flecha svg {
  width: 16px;
  height: 16px;
}

.stories-aviso__texto b {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  line-height: 1.3;
}

.stories-aviso__texto small {
  display: block;
  font-size: 0.75rem;
  color: #5a6b83;
  line-height: 1.3;
}

.stories-aviso__cerrar {
  margin-left: 4px;
  padding: 2px 4px;
  border: 0;
  background: none;
  color: #5a6b83;
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  border-radius: 6px;
}

.stories-aviso__cerrar:hover {
  color: #0f2140;
  background: #f1f6ec;
}

/* Barrita que se vacia mientras el aviso esta a la vista */
.stories-aviso__barra {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 5px;
  height: 2px;
  border-radius: 2px;
  background: #eef3f9;
  overflow: hidden;
}

.stories-aviso__barra i {
  display: block;
  width: 100%;
  height: 100%;
  background: #8dc63f;
  transform-origin: left;
}

.stories-aviso.visible .stories-aviso__barra i {
  animation: storiesAvisoVacia var(--aviso-dura, 6s) linear forwards;
}

/* Mientras sale el aviso, el tooltip de hover sobra. */
.logo:has(.stories-aviso.visible) .stories-tooltip {
  opacity: 0 !important;
  visibility: hidden !important;
}

@keyframes storiesAvisoEmpuja {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-3px); }
}

@keyframes storiesAvisoVacia {
  from { transform: scaleX(1); }
  to { transform: scaleX(0); }
}

@media (prefers-reduced-motion: reduce) {
  .stories-aviso {
    transition: none;
  }
  .stories-aviso__flecha {
    animation: none;
  }
}
