/**
 * Section: history-timeline
 *
 * Extracted from template-parts/history_timeline.php.
 * Loaded via trunorth_enqueue_section('history-timeline').
 */

.ht-wrap {
        padding: calc(var(--vw) * 5) calc(var(--vw) * 8);
        background-color: #ffffff;
        font-family: 'Montserrat', sans-serif;

        .ht-heading {
            font-size: var(--font-h3);
            font-weight: 400;
            color: #C22127;
            margin: 0 0 calc(var(--vw) * 4) 0;
            line-height: 1.2;
        }

        /* --- Timeline container + center line --- */
        .ht-timeline {
            position: relative;
            display: flex;
            flex-direction: column;
            gap: calc(var(--vw) * 4);
        }

        .ht-line {
            position: absolute;
            left: 50%;
            top: 0;
            bottom: 0;
            width: 4px;
            background-color: #D9D9D9;
            transform: translateX(-50%);
            z-index: 0;

            &::before,
            &::after {
                content: '';
                position: absolute;
                left: 50%;
                transform: translateX(-50%);
                width: 12px;
                height: 12px;
                border-radius: 50%;
                background-color: #D9D9D9;
            }

            &::before { top: 0; }
            &::after  { bottom: 0; }
        }

        /* --- Story row: two equal halves + dot pinned between them --- */
        .ht-story {
            display: flex;
            align-items: center;
            position: relative;
            z-index: 1;
        }

        .ht-half {
            flex: 1;
            display: flex;
            align-items: center;
            min-height: calc(var(--vw) * 4);
        }

        /* Left half: content pushed to the right (toward center) */
        .ht-half-left  { justify-content: flex-end; }
        /* Right half: content pushed to the left (toward center) */
        .ht-half-right { justify-content: flex-start; }

        /* --- Dot: sits exactly at the 50% junction --- */
        .ht-dot {
            width: 14px;
            height: 14px;
            border-radius: 50%;
            background-color: #C22127;
            flex-shrink: 0;
            position: relative;
            z-index: 2;
            box-shadow: 0 0 0 4px #D9D9D9;
        }

        /* --- Year label --- */
        .ht-year {
            font-size: clamp(0.9rem, calc(var(--vw) * 1.1), calc(var(--vw) * 1.1));
            font-weight: 700;
            color: #111111;
        }

        .ht-story-right .ht-year { padding-right: calc(var(--vw) * 1.5); }
        .ht-story-left  .ht-year { padding-left: calc(var(--vw) * 1.5); }

        /* --- Arrow connector (rotated square, TWAE-style) --- */
        .ht-bracket {
            width: 10px;
            height: 10px;
            transform: rotate(-45deg);
            flex-shrink: 0;
            background-color: #ffffff;
            position: relative;
            z-index: 3;
        }

        /* Right-side: tip points LEFT toward dot — show top + left borders */
        .ht-story-right .ht-bracket {
            border-top:  0.25rem solid #C22127;
            border-left: 0.25rem solid #C22127;
            margin-left:  calc(var(--vw) * 1.5);
            margin-right: -6px;
        }

        /* Left-side: tip points RIGHT toward dot — show bottom + right borders */
        .ht-story-left .ht-bracket {
            border-bottom: 0.25rem solid #C22127;
            border-right:  0.25rem solid #C22127;
            margin-left:  -6px;
            margin-right: calc(var(--vw) * 1.5);
        }

        /* --- Card --- */
        .ht-card {
            background: #ffffff;
            box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
            border-radius: 6px;
            padding: calc(var(--vw) * 1) calc(var(--vw) * 1.25);
            max-width: calc(var(--vw) * 30);

            p {
                margin: 0;
                font-size: clamp(0.75rem, calc(var(--vw) * 0.9), calc(var(--vw) * 0.9));
                font-weight: 400;
                color: #333333;
                line-height: 1.5;
            }
        }

        /* Right-side card: border on the left (facing center) */
        .ht-story-right .ht-card { border-left: 0.25rem solid #C22127; }
        /* Left-side card: border on the right (facing center) */
        .ht-story-left .ht-card  { border-right: 0.25rem solid #C22127; }

        /* Card wrap: column container so year sits above card */
        .ht-card-wrap {
            display: flex;
            flex-direction: column;
            align-items: flex-start;
        }

        /* Year label hidden on desktop — shown above card on mobile */
        .ht-card-year { display: none; }

        /* --- Mobile: all items stack from a left-side line --- */
        @media (max-width: 768px) {
            & {
                padding: calc(var(--vw) * 8) calc(var(--vw) * 5);
            }

            .ht-heading {
                margin-bottom: calc(var(--vw) * 8);
            }

            .ht-timeline { gap: calc(var(--vw) * 8); }
            .ht-line { left: 7px; }

            .ht-story { flex-direction: row; align-items: flex-start; gap: 0; }

            /* Hide year on all items */
            .ht-year { display: none; }

            /* --- Right stories: already correct — dot | bracket | card --- */
            .ht-story-right .ht-half-left { display: none; }
            .ht-story-right .ht-half-right {
                flex: 1;
                justify-content: flex-start;
            }
            .ht-story-right .ht-dot { flex-shrink: 0; margin-top: 4px; }

            /* --- Left stories: reorder so dot comes first, then card half --- */
            .ht-story-left .ht-half-right { display: none; }
            .ht-story-left .ht-half-left  { flex: 1; justify-content: flex-start; }

            /* Push dot before half-left using order */
            .ht-story-left .ht-dot       { order: 1; flex-shrink: 0; margin-top: 4px; }
            .ht-story-left .ht-half-left { order: 2; }

            /* Override left-story bracket to point left (same as right-story) */
            .ht-story-left .ht-bracket {
                order:         -1;
                border-top:    0.25rem solid #C22127;
                border-left:   0.25rem solid #C22127;
                border-bottom: none;
                border-right:  none;
                margin-left:   calc(var(--vw) * 1.5);
                margin-right:  -6px;
            }

            /* Override left-story card border to left side */
            .ht-story-left .ht-card {
                border-right: none;
                border-left:  0.25rem solid #C22127;
            }

            /* Show year above card — bold label */
            .ht-card-year {
                display: block;
                font-weight: 700;
                font-size: clamp(0.9rem, calc(var(--vw) * 3.5), calc(var(--vw) * 3.5));
                color: #111111;
                margin-bottom: calc(var(--vw) * 1.5);
            }

            .ht-card {
                max-width: 100%;
                box-shadow: 0 1px 6px rgba(0,0,0,0.1);
                padding: calc(var(--vw) * 3) calc(var(--vw) * 4);

                p {
                    font-size: clamp(0.85rem, calc(var(--vw) * 3.5), calc(var(--vw) * 3.5));
                }
            }
        }
    }
