/* =============================================================================
   Firebrand Expanding Panels — fep-style.css
   ============================================================================= */

/* ── Wrapper ────────────────────────────────────────────────────────────── */
.fep-wrapper {
    display: flex;
    gap: var(--fep-gap, 16px);
    align-items: stretch;
    width: 100%;
}

/* ── Panel ──────────────────────────────────────────────────────────────── */
.fep-panel {
    flex: 1;
    background: var(--fep-panel-bg, #f4f1ed);
    color: var(--fep-text-color, #1a1a1a); /* explicit dark text — prevents inheriting white from dark sections */
    border-radius: var(--fep-radius, 12px);
    padding: 32px;
    display: flex;
    flex-direction: column;
    transition: flex 0.45s ease, background-color 0.3s ease;
    overflow: hidden;
    min-width: 0; /* prevent flex blowout on narrow text */
}

.fep-panel.is-active {
    flex: var(--fep-active-flex, 1.2);
    background: var(--fep-panel-active-bg, #ffe5c7);
}

/* ── Panel header ───────────────────────────────────────────────────────── */
.fep-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

/* Arrow: hidden on desktop, shown on mobile */
.fep-arrow-icon {
    display: none;
}

/* ── Title ──────────────────────────────────────────────────────────────── */
.fep-panel-title {
    margin: 0 0 6px 0;
    font-size: 20px;
    font-weight: 700;
    line-height: 1.3;
}

/* ── Collapsible (plain flex container on desktop) ──────────────────────── */
.fep-panel-collapsible {
    display: flex;
    flex-direction: column;
    flex: 1;
}

/* ── Image ──────────────────────────────────────────────────────────────── */
.fep-panel-image {
    margin-bottom: 16px;
}

.fep-panel-image img {
    max-width: 100%;
    height: auto;
    display: block;
    border-radius: 6px;
}

/* ── Body ───────────────────────────────────────────────────────────────── */
.fep-panel-body {
    flex: 1;
}

.fep-panel-body p {
    margin: 0 0 8px;
    line-height: 1.6;
}

.fep-panel-body p:last-child {
    margin-bottom: 0;
}

/* ── Button ─────────────────────────────────────────────────────────────── */
.fep-panel-btn-wrap {
    margin-top: 20px;
}

.fep-btn {
    display: inline-block;
    padding: 10px 24px;
    border: 2px solid var(--fep-btn-color, #ff5500);
    border-radius: 9999px;
    color: var(--fep-btn-color, #ff5500) !important;
    background: transparent;
    text-decoration: none !important;
    font-weight: 600;
    font-size: 14px;
    line-height: 1;
    transition: background-color 0.2s ease, color 0.2s ease;
    white-space: nowrap;
    cursor: pointer;
}

.fep-btn:hover {
    background: var(--fep-btn-hover-bg, #ff5500);
    color: var(--fep-btn-hover-text, #ffffff) !important;
}

/* ── Empty state ────────────────────────────────────────────────────────── */
.fep-empty {
    text-align: center;
    color: #999;
    padding: 40px;
}

/* =============================================================================
   Version B — Width & Height expansion  (.fep-wrapper--expand-both)
   Only activates when 3+ panels are present (CSS :has selector).
   ScaleY is a visual transform; layout height stays the same so other
   panels don't shift — the active card "pops out" above and below.
   ============================================================================= */

.fep-wrapper--expand-both {
    overflow: visible; /* allow scaled card to extend beyond wrapper bounds */
}

.fep-wrapper--expand-both .fep-panel {
    transition: background-color 0.3s ease, transform 0.45s ease;
    transform-origin: center center;
}

/* Cancel the flex-grow width expansion — scale() handles both axes */
.fep-wrapper--expand-both .fep-panel.is-active {
    flex: 1;
}

/* Uniform scale: card grows 20% in both dimensions, content stays proportional.
   Only activates when 3 or more panels are present. */
.fep-wrapper--expand-both:has(.fep-panel:nth-child(3)) .fep-panel.is-active {
    transform: scale(var(--fep-v-scale, 1.2));
    z-index: 1;
}

/* =============================================================================
   Mobile accordion  (< 768px — Divi mobile breakpoint)
   ============================================================================= */
@media (max-width: 767px) {

    .fep-wrapper {
        flex-direction: column;
    }

    /* Reset desktop active state; mobile uses .is-open instead */
    .fep-panel,
    .fep-panel.is-active {
        flex: none;
        background: var(--fep-panel-bg, #f4f1ed);
        color: var(--fep-text-color, #1a1a1a); /* explicit dark text — prevents inheriting white from dark sections */
        padding: 20px 24px;
        transform: none; /* cancel any Version B scale() */
    }

    .fep-panel.is-open {
        background: var(--fep-panel-active-bg, #ffe5c7);
    }

    /* Header becomes a clickable row */
    .fep-panel-header {
        align-items: center;
        cursor: pointer;
        user-select: none;
    }

    /* Show arrow on mobile */
    .fep-arrow-icon {
        display: flex;
        align-items: center;
        justify-content: center;
        flex-shrink: 0;
        margin-left: 12px;
        width: 28px;
        height: 28px;
        transition: transform 0.3s ease;
    }

    .fep-arrow-icon::before {
        content: '\203A'; /* › right chevron */
        font-size: 26px;
        font-weight: 300;
        line-height: 1;
        color: inherit;
    }

    .fep-panel.is-open .fep-arrow-icon {
        transform: rotate(90deg);
    }

    /* Remove title bottom margin when collapsed (nothing visible below it) */
    .fep-panel-title {
        margin-bottom: 0;
        flex: 1;
    }

    /* Animate content open/close */
    .fep-panel-collapsible {
        max-height: 0;
        overflow: hidden;
        transition: max-height 0.35s ease;
    }

    .fep-panel.is-open .fep-panel-collapsible {
        max-height: 900px; /* generous upper bound */
    }

    /* Restore spacing inside collapsible once open */
    .fep-panel.is-open .fep-panel-collapsible > *:first-child {
        margin-top: 16px;
    }
}
