:root {
  --card: #ffffff;
  --muted: #666;
  --radius-lg: 14px;
  --radius-sm: 10px;
  --transition-fast: 380ms;
}

.header {
  position: sticky !important;
}

/* --- Secciones superiores --- */
.page-top,
.page-bottom {
  max-width: 1440px;
  background: var(--card);
  border-radius: 12px;
}

.page-top h1 {
  margin: 0 0 8px 0;
}
.page-top p {
  margin: 0;
}

/* --- SECTION TIMELINE --- */
#timeline-section {
  position: relative;
  width: 100%;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}

#timeline-section svg {
  position: sticky;
  bottom: -35px;
  left: 0;
  width: 100%;
  height: auto;
  display: block;
  margin-top: auto;
  z-index: 0;
  pointer-events: none;
}

/* --- CONTENEDOR FIJO (ESCRITORIO) --- */
.timeline-fixed {
  position: sticky; /* Mantenido: Necesario para el efecto de scroll/anclaje */
  top: 0px;
  height: 100vh;
  /* CAMBIO: De GRID a FLEX */
  display: flex;
  justify-content: center;
  align-items: center;
  gap: clamp(16px, 5vw, 28px);
  width: min(95%, 1440px);
  margin: 0 auto;
  z-index: 5;
  pointer-events: none;
}

/* Columnas */
.left-col,
.center-col,
.right-col {
  position: relative; /* REQUERIDO: Todos los hijos son relative */
  pointer-events: auto;
}

.left-col,
.right-col {
  /* Sustituto de 1.2fr en GRID */
  flex: 1.2;
  min-width: 280px;
}

/* --- Columna central (fechas) --- */
.center-col {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  flex-direction: column;
  /* REQUERIDO: Ancho máximo */
  max-width: 200px;
  width: max-content;
  height: 100%;
}

.date-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  width: 100%;
  height: 100%;
}

.date-stack {
  position: relative;
  width: 100%;
  height: 100%;
  text-align: center;
  display: flex;
  flex-direction: column; /* Apilado vertical */
  align-items: center;
  justify-content: center;
}

/* --- FECHAS --- */
.date-text {
  position: relative; /* CLAVE: Para que el ancho de columna lo afecte */
  white-space: nowrap;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;

  font-weight: 700;
  font-family: var(--font-title);
  font-size: clamp(20px, 2vw, 36px);
  color: var(--color-light-green);
  border-radius: 10px;

  /* ESTADO BASE */
  opacity: 0;
  /* top, left, y translateY eliminados */
  transform: scale(0.8);
  margin: 6px 0; /* Espaciado entre fechas */

  transition: opacity 320ms ease, transform 320ms ease, margin 320ms ease;
  will-change: opacity, transform, margin;
  height: 1.3em;
}

/* --- Fecha activa (Centrada y Visible) --- */
.date-text.front {
  opacity: 1;
  transform: scale(1);
  /* Asegura que el texto se adapte al ancho de columna de 200px */
  font-size: clamp(12px, 3.5vw, 42px);
}

/* --- Fechas adyacentes (Anterior y Siguiente) --- */
.date-text.prev,
.date-text.next {
  opacity: 0.35;
  font-size: clamp(18px, 3vw, 28px);
  color: var(--muted);
  transition: opacity 350ms ease, transform 350ms ease;
  transform: scale(0.8);
}

/* --- Fechas que no se ven (Back) --- */
.date-text.back {
  opacity: 0;
  transform: scale(0.8);
  height: 0; /* Colapsa para no ocupar espacio vertical en el flujo */
  margin: 0;
}

/* --- TARJETA DE IMAGEN --- */
.image-card {
  background: var(--card);
  border-radius: var(--radius-lg);
  padding: clamp(8px, 1vw, 16px);
  box-shadow: 0 10px 28px rgba(20, 30, 20, 0.05);
  overflow: hidden;
  min-height: 600px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  position: relative; /* Contenedor de las capas absolutas */
}

.image-stack {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 600px;
  border-radius: var(--radius-sm);
  overflow: hidden;
}

/* Capas de fondo - Deben seguir siendo absolutos para el efecto de superposición (JS) */
.t-bg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-position: center;
  background-size: cover;
  background-repeat: no-repeat;
  border-radius: var(--radius-sm);
  opacity: 0;
  transform: scale(1.03);
  transition: opacity 420ms ease, transform 420ms ease;
  will-change: opacity, transform;
  background-color: #eef5ee;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

.t-bg.front {
  z-index: 3;
}
.t-bg.back {
  z-index: 2;
}

/* --- TARJETA DE TEXTO --- */
.text-card {
  border-radius: var(--radius-lg);
  padding: clamp(16px, 2vw, 24px);
  overflow: visible;
  min-height: 600px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  background-color: transparent;
  position: relative;
}

.text-stack {
  position: relative;
  /* Mantenemos grid aquí para la superposición de los bloques de texto con grid-area */
  display: grid;
}

/* --- BLOQUES DE TEXTO --- */
.text-block {
  grid-area: 1 / 1;
  padding: 6px 8px;
  opacity: 0;
  transition: opacity 320ms ease, transform 320ms ease;
  will-change: opacity, transform;
  position: relative;
}

.text-block.front {
  z-index: 3;
  opacity: 1;
  transform: none;
  position: relative;
}

.text-block.back {
  z-index: 2;
}

.text-block h2 {
  font-family: var(--font-title);
  font-size: clamp(16px, 3vw, 32px);
  color: var(--color-light-green);
  line-height: var(--font-lh-title);
  padding-bottom: 10px;
}

.text-block p {
  font-family: var(--font-paragraph);
  font-size: var(--font-size-paragraph);
  line-height: var(--font-lh-paragraph);
  color: var(--color-text-paragraph);
  margin: 0;
}

.text-block.visible {
  opacity: 1;
  transform: none;
  position: relative;
}

/* Triggers invisibles */
.triggers-root .trigger {
  height: 100vh;
  width: 100%;
}

/* -------------------------------------- */
/* --- RESPONSIVE --- */
/* -------------------------------------- */

/* Sección de 1200px (Ajuste menor) */
@media (max-width: 900px) {
  #timeline-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    width: 100%;
  }

  #timeline-section svg {
    display: none;
  }

  /* Se desactiva el modo fijo */
  .timeline-fixed,
  .triggers-root {
    display: none !important;
  }

  /* Contenedor móvil */
  .timeline-mobile {
    z-index: 1;
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 1000px;
    margin: 0 auto;
    gap: 40px;
    padding: 30px 16px;
  }

  /* Cada bloque de evento */
  .mobile-entry {
    display: flex;
    flex-direction: column;
    gap: 5px;
    border-radius: var(--radius-lg);
    background: var(--card);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.08);
    overflow: hidden;
  }

  .mobile-entry img {
    width: 100%;
    height: auto;
    border-bottom: 3px solid var(--color-light-green);
    object-fit: cover;
    max-height: 500px; /* ✅ altura máxima */
    min-height: 230px; /* ✅ altura mínima */
  }

  .mobile-entry .mobile-date {
    font-size: 1.4rem;
    font-weight: 700;
    font-family: var(--font-title);
    color: var(--color-green-title);
    text-align: center;
    margin-top: 10px;
  }

  .mobile-entry h2 {
    font-size: 1.2rem;
    font-family: var(--font-title);
    color: var(--color-green-title);
    line-height: var(--font-lh-title);
    text-align: center;
    margin: 0;
    padding: 0 10px;
  }

  .mobile-entry p {
    font-size: 1rem;
    font-family: var(--font-paragraph);
    line-height: var(--font-lh-paragraph);
    color: var(--color-text-paragraph);
    padding: 0 20px 20px;
    text-align: justify;
    hyphens: auto;
    word-spacing: -0.05em;
  }
}
