:root{
  --bg: #e9f6f6;
  --primary: #2aa6a6;
  --muted: #5d6a6a;
  --line: #c7d6d6;
  --dot: #6f7b7b;
  --arrow-color: #0b6b66;
  --year-opacity: 0.92;
  --radius: 12px;
  --transition: 220ms;
}

/* Container */
.timeline-container{
  width: 100%;
  background: transparent;
  padding: clamp(18px, 4vw, 48px);
  box-sizing: border-box;
  color: #222;
}

/* Top area */
.content-area{
  display: grid;
  gap: clamp(18px, 3vw, 48px);
  align-items: center;
  margin-bottom: clamp(20px, 4vw, 64px);

  /* ✅ FIX: niente 580px fisso (spacca il responsive) */
  grid-template-columns:
    minmax(140px, 26%)
    clamp(12px, 4vw, 56px)
    minmax(0, 1fr);
}

/* Large year */
#timeline-year{
  font-weight: 300;
  color: color-mix(in srgb, var(--primary) var(--year-opacity), transparent 20%);
  margin: 0;
  line-height: 0.95;
  font-size: clamp(3.2rem, 11.5vw, 8.5rem);
  display: flex;
  align-items: center;
  justify-content: flex-start;
  padding-left: 4px;

  /* ✅ evita micro overflow */
  min-width: 0;
}

/* Title & Description */
.text-block{
  padding-left: 24px;
  border-left: 4px solid var(--primary);
  box-sizing: border-box;
  min-width: 0;
}

#timeline-title{
  margin: 0 0 8px 0;
  color: var(--primary);
  font-weight: 700;
  font-size: clamp(1.1rem, 2.8vw, 1.9rem);
}

#timeline-description{
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
  font-size: clamp(0.98rem, 1.6vw, 1.06rem);

  max-width: 140ch;
  white-space: normal;
  word-break: normal;
  overflow-wrap: normal;
  hyphens: none;
}

/* Bottom area */
.timeline-wrapper{
  margin-top: 8px;
  padding-top: 18px;
  position: relative;
  display:flex;
  align-items:center;
  gap: 12px;
}

/* Arrows */
.nav-arrow{
  --size:44px;
  width:44px;
  height:44px;
  display:inline-grid;
  place-items:center;
  background:transparent;
  border:none;
  color: var(--arrow-color);
  cursor:pointer;
  opacity:0;
  transform: translateY(0) scale(0.98);
  transition: all var(--transition) ease;
  pointer-events:none;
}

.nav-arrow:disabled{
  opacity: 0.28;
  cursor:default;
  pointer-events:none;
}

.timeline-wrapper.show-arrows .nav-arrow,
.timeline-wrapper:hover .nav-arrow,
.timeline-wrapper:focus-within .nav-arrow{
  opacity:1;
  transform: translateY(0) scale(1);
  pointer-events:auto;
}

/* Track */
.timeline-track{
  display:flex;
  align-items:center;
  justify-content: space-between;
  width: 100%;
  padding: 18px 6px 6px 6px;
  box-sizing: border-box;
  position: relative;
  overflow: hidden;
  scroll-behavior: smooth;
}

/* Baseline */
.timeline-line{
  position: absolute;
  height: 2px;
  background: var(--line);
  left: 0;
  top: 0;
  width: 0;
  z-index: 1;
  border-radius: 2px;
  pointer-events: none;
}

/* Item */
.timeline-item{
  display:flex;
  flex-direction: column;
  align-items:center;
  justify-content:center;
  background: transparent;
  border:none;
  padding: 0;
  margin: 0;
  z-index: 3;
  cursor: pointer;
  flex: 1 1 0;
  min-width: 0;
}

/* Dot */
.dot{
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--dot);
  z-index: 4;
  transition: transform var(--transition) ease, background-color var(--transition) ease, box-shadow var(--transition) ease;
  transform-origin: center center;
}

.timeline-item.active .dot{
  width: 10px;
  height: 10px;
  background: var(--primary);
  box-shadow: 0 6px 18px rgba(42,166,166,0.12), 0 0 0 6px rgba(42,166,166,0.04);
  transform: scale(1.15);
}

/* Label */
.timeline-year-label{
  margin-top: 12px;
  color: #3f4a4a;
  font-size: 0.95rem;
  white-space: nowrap;
  z-index: 4;
}

.timeline-item.active .timeline-year-label{
  color: var(--primary);
  font-weight: 700;
}

/* Focus */
.timeline-item:focus{
  outline:none;
  box-shadow: 0 0 0 6px rgba(42,166,166,0.06);
  border-radius:6px;
}

/* ✅ Breakpoint intermedio: evita layout “strano” su tablet/desktop stretti */
@media (max-width: 1180px){
  .content-area{
    grid-template-columns:
      minmax(130px, 24%)
      clamp(10px, 3vw, 40px)
      minmax(0, 1fr);
    gap: clamp(14px, 2.5vw, 28px);
  }

  #timeline-description{
    max-width: 90ch;
  }
}

/* Responsive: stack + track scrollabile */
@media (max-width:980px){
  .content-area{
    grid-template-columns: 1fr;
    gap: 14px;
  }

  #timeline-year{
    font-size: clamp(2.6rem, 12vw, 4.5rem);
    justify-content: flex-start;
  }

  .text-block{
    padding-left:12px;
    border-left-width:3px;
    max-width:100%;
  }

  .timeline-track{
    justify-content:flex-start;
    gap: clamp(18px, 8vw, 28px);

    overflow-x:auto;
    overflow-y:hidden;
    padding: 14px 6px 6px 6px;

    /* ✅ più stabile su iOS */
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x mandatory;
  }

  .timeline-item{
    flex: 0 0 auto;
    min-width: 92px;
    padding: 0 8px;

    /* ✅ snap “pulito” */
    scroll-snap-align: center;
  }

  .nav-arrow{ display:none; }
}

/* Very small */
@media (max-width:420px){
  #timeline-year{ font-size: clamp(1.8rem, 22vw, 3.6rem); }
  #timeline-title{ font-size: 1.05rem; }
  .timeline-year-label{ font-size: 0.8rem; }
}
