/* Bellota V2 — Historia (timeline zigzag + TOC lateral) */

.history-layout {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: var(--sp-10);
    align-items: start;
}

/* ---------------------------------------------------------------
   Introducción
   --------------------------------------------------------------- */
.history-intro {
    font-size: var(--fs-md);
    line-height: var(--lh-normal);
    color: var(--c-text-body);
    margin: 0 0 var(--sp-4);
}
.history-intro b { color: var(--c-text-strong); font-weight: var(--fw-semibold); }
.history-intro:last-of-type { margin-bottom: var(--sp-8); }

/* ---------------------------------------------------------------
   Timeline zigzag
   --------------------------------------------------------------- */
.history-timeline {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: var(--sp-4) 0;
}
/* Línea vertical central */
.history-timeline::before {
    content: "";
    position: absolute;
    left: 50%;
    top: 0;
    bottom: 0;
    width: 2px;
    background: repeating-linear-gradient(
        to bottom,
        var(--c-brand) 0 8px,
        transparent 8px 16px
    );
    transform: translateX(-50%);
    z-index: 0;
}

/* Badge del año (centrado sobre la línea) */
.history-year-marker {
    position: relative;
    display: flex;
    justify-content: center;
    z-index: 2;
    margin: var(--sp-4) 0 var(--sp-3);
    scroll-margin-top: 100px;
}
.history-year-marker span {
    background: var(--c-brand);
    color: #fff;
    padding: var(--sp-2) var(--sp-5);
    font-weight: var(--fw-bold);
    font-size: var(--fs-md);
    border-radius: var(--r-sm);
    box-shadow: var(--sh-sm);
}

/* Card hito — alternancia left/right */
.history-item {
    position: relative;
    z-index: 1;
    width: calc(50% - var(--sp-6));
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: var(--r-md);
    margin-bottom: var(--sp-4);
    overflow: hidden;
    transition: box-shadow var(--t-fast);
}
.history-item:hover { box-shadow: var(--sh-md); }
.history-item--left  { align-self: flex-start; }
.history-item--right { align-self: flex-end; }

/* Conector horizontal desde la línea central a la card */
.history-item::before {
    content: "";
    position: absolute;
    top: 40px;
    width: var(--sp-6);
    height: 2px;
    background: var(--c-brand);
    z-index: 0;
}
.history-item--left::before  { right: calc(-1 * var(--sp-6)); }
.history-item--right::before { left:  calc(-1 * var(--sp-6)); }

/* Summary (cabecera clickable) */
.history-item summary {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    padding: var(--sp-3);
    cursor: pointer;
    list-style: none;
    background: var(--c-surface);
    transition: background var(--t-fast);
}
.history-item summary::-webkit-details-marker { display: none; }
.history-item summary:hover { background: var(--c-brand-soft); }
.history-item[open] summary { background: var(--c-brand-soft); }

.history-item summary img {
    width: 80px;
    height: 60px;
    object-fit: cover;
    border-radius: var(--r-sm);
    flex-shrink: 0;
}
.history-item summary h3 {
    flex: 1;
    margin: 0;
    font-size: var(--fs-sm);
    font-weight: var(--fw-semibold);
    color: var(--c-text-strong);
    line-height: var(--lh-snug);
}
.history-item-chevron {
    flex-shrink: 0;
    color: var(--c-brand);
    transition: transform var(--t-fast);
}
.history-item[open] .history-item-chevron { transform: rotate(180deg); }

/* Body expandido */
.history-item-body {
    padding: var(--sp-4);
    border-top: 1px solid var(--c-border);
}
.history-item-body img {
    width: 100%;
    height: auto;
    border-radius: var(--r-sm);
    margin-bottom: var(--sp-3);
    display: block;
}
.history-item-body p {
    margin: 0;
    color: var(--c-text-body);
    font-size: var(--fs-sm);
    line-height: 1.6;
}

/* ---------------------------------------------------------------
   Compromiso final
   --------------------------------------------------------------- */
.history-commitment {
    margin-top: var(--sp-10);
    padding-top: var(--sp-8);
    border-top: 1px solid var(--c-border);
}
.history-commitment h2 {
    color: var(--c-brand);
    font-size: var(--fs-xl);
    font-weight: var(--fw-bold);
    margin: 0 0 var(--sp-3);
}
.history-commitment p {
    color: var(--c-text-body);
    font-size: var(--fs-md);
    line-height: var(--lh-normal);
    margin: 0;
    max-width: 720px;
}

/* ---------------------------------------------------------------
   TOC lateral (Índice histórico)
   --------------------------------------------------------------- */
.history-toc {
    background: var(--c-surface-alt);
    border: 1px solid var(--c-border);
    border-radius: var(--r-lg);
    padding: var(--sp-5) var(--sp-6) var(--sp-6);
    position: sticky;
    top: var(--sp-6);
}
.history-toc-title {
    color: var(--c-brand);
    font-weight: var(--fw-bold);
    font-size: var(--fs-md);
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin: 0 0 var(--sp-4);
    padding-bottom: var(--sp-3);
    border-bottom: 1px solid var(--c-border);
}
.history-toc ul {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: var(--sp-2);
    max-height: 60vh;
    overflow-y: auto;
}
.history-toc a {
    display: flex;
    align-items: flex-start;
    gap: var(--sp-2);
    text-decoration: none;
    color: var(--c-text-body);
    font-size: var(--fs-sm);
    padding: var(--sp-2);
    border-radius: var(--r-sm);
    transition: background var(--t-fast), color var(--t-fast);
    line-height: 1.4;
}
.history-toc a:hover { background: var(--c-brand-soft); color: var(--c-brand); }
.history-toc a strong { color: var(--c-brand); }
.history-toc-arrow {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--c-brand);
    width: 24px;
    height: 24px;
    border-radius: 2px;
    flex-shrink: 0;
    margin-top: 2px;
}

/* ---------------------------------------------------------------
   Responsive
   --------------------------------------------------------------- */
@media (max-width: 991px) {
    .history-layout { grid-template-columns: 1fr; }
    .history-toc { position: static; }
    .history-toc ul { max-height: none; }

    /* Timeline en 1 columna: línea a la izquierda, cards a la derecha */
    .history-timeline::before { left: 20px; }
    .history-year-marker { justify-content: flex-start; padding-left: 4px; }
    .history-item { width: calc(100% - 40px); align-self: flex-end !important; }
    .history-item::before {
        left: -20px !important;
        right: auto !important;
        width: 20px;
    }
}
