:root {
    --bg: #fbf8f0;
    --brown: #4a2417;
    --text: #4a2c20;
    --orange: #e8963a;
    --circle: 84px;
    --line: 3px;
    --gutter: 24px; /* margine laterale della timeline */
}

.history {
    max-width: 1500px;
    margin: 0 auto;
    padding: 64px 24px 80px;
}

.history__title {
    margin: 0 0 56px;
    text-align: center;
    font-size: clamp(2rem, 4.6vw, 3.4rem);
    font-weight: 700;
    line-height: 1.1;
    color: var(--brown);
}

/* ---------- Timeline: sempre su una riga, scorrevole ---------- */
:root { --visible: 4; } /* quanti elementi si vedono insieme */

.timeline {
    list-style: none;
    margin: 0 var(--gutter);
    padding: 0;
    display: flex;
    overflow-x: auto;
    scroll-snap-type: x proximity;
    scrollbar-width: none;            /* Firefox */
    -webkit-overflow-scrolling: touch;
}
.timeline::-webkit-scrollbar { display: none; }

.timeline__item {
    position: relative;
    z-index: 1;
    flex: 0 0 calc(100% / var(--visible));
    scroll-snap-align: start;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 0 12px;
}

/* ogni elemento disegna la sua metà di linea, così la linea scorre con il contenuto */
.timeline__item::before,
.timeline__item::after {
    content: "";
    position: absolute;
    z-index: -1;
    top: calc(var(--circle) / 2 - var(--line) / 2);
    height: var(--line);
    background: var(--brown);
}
.timeline__item::before { left: 0; right: 50%; }
.timeline__item::after  { left: 50%; right: 0; }

/* pallino iniziale sul primo elemento */
.timeline__item:first-child::before {
    top: calc(var(--circle) / 2 - 6px);
    height: 12px;
    background:
            radial-gradient(circle at 6px 6px, var(--brown) 6px, transparent 6.5px) 0 0 / 12px 12px no-repeat,
            linear-gradient(var(--brown), var(--brown)) 0 50% / 100% var(--line) no-repeat;
}

/* tratteggio finale */
.timeline__end {
    flex: 0 0 56px;
    height: 3px;
    margin-top: calc(var(--circle) / 2 - 1.5px);
    background: radial-gradient(circle, var(--brown) 1.4px, transparent 1.8px) 0 50% / 9px 3px repeat-x;
}

.timeline__marker {
    flex: none;
    display: grid;
    place-items: center;
    width: var(--circle);
    height: var(--circle);
    border: var(--line) solid var(--brown);
    border-radius: 50%;
    background: var(--bg);
    color: var(--brown);
    font-weight: 700;
    font-size: 1.05rem;
    line-height: 1.05;
    text-align: center;
}
.timeline__item--filled .timeline__marker { background: var(--brown); color: #fff; }

.timeline__content { margin-top: 32px; }
.timeline__heading {
    margin: 0 0 14px;
    font-size: 1.15rem;
    font-weight: 700;
    line-height: 1.2;
    color: var(--orange);
}
.timeline__content p { margin: 0; font-size: 0.9rem; line-height: 24px; }
.timeline__content p + p { margin-top: 1.2em; }
.timeline__content strong { font-weight: 700; }

/* ---------- Responsive: cambia solo quanti elementi si vedono ---------- */
@media (max-width: 1100px) {
    :root { --visible: 3; --circle: 72px; }
    .timeline__marker { font-size: 0.95rem; }
    .timeline__heading { font-size: 1.02rem; }
    .timeline__content p { font-size: 0.82rem; }
}
@media (max-width: 767px) {
    :root { --visible: 1.4; --gutter: 0px; }
    .history { padding: 44px 20px 64px; }
    .history__title { margin-bottom: 40px; }
    .timeline__content p { font-size: 0.95rem; }
}
@media (max-width: 380px) {
    :root { --circle: 64px; }
    .timeline__marker { font-size: 0.85rem; }
}