/* =========================================================================
   Expanding Panels widget
   Resting state: equal cards, each with a number, a vertical label and a
   darkened image (no card is expanded).
   Active (hover / keyboard focus / tap): the card grows, the image reveals in
   colour and the horizontal title + text + arrow fade in.

   The "expanded" look is driven by three selectors that mean the same thing:
     :hover          -> mouse
     :focus-within   -> keyboard (focusing the card or its link)
     .is-active      -> tap (added by JS on touch devices)
   ========================================================================= */

.expanding-panels {
    --ep-gap: 12px;
    --ep-radius: 8px;
    width: 100%;
}

/* --- Intro (title + lead) ----------------------------------------------- */
.expanding-panels__intro {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 48px;
    margin-bottom: 48px;
}

.expanding-panels__title {
    margin: 0;
    flex: 1 1 auto;
    max-width: 640px;
    font-family: var(--primary-font, "Klavika", sans-serif);
    font-weight: 400;
    font-size: clamp(1.75rem, 3vw, 2.5rem);
    line-height: 1.2;
    color: #1C2945;
}

/* Serif accent words (kept inline; the theme forces heading spans to block). */
.expanding-panels__title span,
.expanding-panels__title em,
.expanding-panels__title i {
    display: inline;
    margin: 0;
    font-family: var(--secondary-font, "Kepler", serif);
    font-style: italic;
    font-weight: 500;
    color: inherit;
}

.expanding-panels__lead {
    margin: 0;
    flex: 0 1 470px;
    max-width: 470px;
    color: #09122B;
    font-family: var(--primary-font, "Klavika", sans-serif);
    font-size: 1.125rem;
    font-style: normal;
    font-weight: 400;
    line-height: 120%; /* 1.35rem */
}

/* --- Grid --------------------------------------------------------------- */
.expanding-panels__grid {
    --ep-panel-height: 700px;
    position: relative;
    display: flex;
    gap: var(--ep-gap);
    width: 100%;
}

/* --- Panel -------------------------------------------------------------- */
.expanding-panels__panel {
    --ep-overlay-color: #1C2945;
    --ep-overlay-opacity: 0.78;
    position: relative;
    flex: 1 1 0%;
    min-width: 0;
    height: var(--ep-panel-height);
    border-radius: var(--ep-radius);
    overflow: hidden;
    cursor: pointer;
    isolation: isolate;
    transition: flex-grow 0.85s cubic-bezier(0.22, 1, 0.36, 1);
}

.expanding-panels__panel:hover,
.expanding-panels__panel:focus-within,
.expanding-panels__panel.is-active {
    flex-grow: 5;
}

/* Visible keyboard focus (works on the dark image). */
.expanding-panels__panel:focus-visible {
    outline: 3px solid #fff;
    outline-offset: -3px;
}

/* --- Media layers ------------------------------------------------------- */
.expanding-panels__media {
    position: absolute;
    inset: 0;
    z-index: 0;
    background-color: var(--ep-overlay-color);
}

.expanding-panels__panel .expanding-panels__image {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100% !important; /* beat Elementor's global img { height: auto } */
    object-fit: cover;
    display: block;
}

/* Solid veil: strong when collapsed, almost gone when active. */
.expanding-panels__veil {
    position: absolute;
    inset: 0;
    background-color: var(--ep-overlay-color);
    opacity: var(--ep-overlay-opacity);
    transition: opacity 0.85s ease;
    pointer-events: none;
}

/* Gradient scrim: dark on the left for text legibility, only when active. */
.expanding-panels__scrim {
    position: absolute;
    inset: 0;
    opacity: 0;
    transition: opacity 0.85s ease;
    pointer-events: none;
    background: linear-gradient(
        102deg,
        rgba(28, 41, 69, 0.88) 0%,
        rgba(28, 41, 69, 0.45) 28%,
        rgba(28, 41, 69, 0) 58%
    );
}

.expanding-panels__panel:hover .expanding-panels__veil,
.expanding-panels__panel:focus-within .expanding-panels__veil,
.expanding-panels__panel.is-active .expanding-panels__veil {
    opacity: 0.12;
}

.expanding-panels__panel:hover .expanding-panels__scrim,
.expanding-panels__panel:focus-within .expanding-panels__scrim,
.expanding-panels__panel.is-active .expanding-panels__scrim {
    opacity: 1;
}

/* --- Number ------------------------------------------------------------- */
.expanding-panels__number {
    position: absolute;
    top: 1.5rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 2;
    font-family: var(--primary-font, "Klavika", sans-serif);
    font-size: 1.5rem;
    font-style: normal;
    font-weight: 300;
    line-height: 120%; /* 1.8rem */
    color: rgba(255, 255, 255, 0.9);
    transition: left 0.85s cubic-bezier(0.22, 1, 0.36, 1), transform 0.85s cubic-bezier(0.22, 1, 0.36, 1);
    white-space: nowrap;
}

.expanding-panels__panel:hover .expanding-panels__number,
.expanding-panels__panel:focus-within .expanding-panels__number,
.expanding-panels__panel.is-active .expanding-panels__number {
    left: 1.5rem;
    transform: translateX(0);
}

/* --- Vertical label (resting state only) -------------------------------- */
.expanding-panels__label {
    position: absolute;
    top: 4.75rem;
    left: 50%;
    transform: translateX(-50%) rotate(180deg);
    writing-mode: vertical-rl;
    z-index: 2;
    color: var(--S---Light-grey-4, #F7F8F8);
    font-family: var(--primary-font, "Klavika", sans-serif);
    font-size: 1.5rem;
    font-style: normal;
    font-weight: 300;
    line-height: 120%; /* 1.8rem */
    letter-spacing: -0.045rem;
    white-space: nowrap;
    opacity: 1;
    transition: opacity 0.6s ease;
    pointer-events: none;
}

.expanding-panels__panel:hover .expanding-panels__label,
.expanding-panels__panel:focus-within .expanding-panels__label,
.expanding-panels__panel.is-active .expanding-panels__label {
    opacity: 0;
}

/* --- Active content ----------------------------------------------------- */
.expanding-panels__content {
    position: absolute;
    top: 4.75rem;
    left: 1.5rem;
    right: 1.5rem;
    bottom: 1.5rem;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    opacity: 0;
    transform: translateY(12px);
    transition: opacity 0.7s ease, transform 0.7s ease;
    pointer-events: none;
}

.expanding-panels__panel:hover .expanding-panels__content,
.expanding-panels__panel:focus-within .expanding-panels__content,
.expanding-panels__panel.is-active .expanding-panels__content {
    opacity: 1;
    transform: translateY(0);
    transition-delay: 0.25s;
    pointer-events: auto;
}

.expanding-panels__content-title {
    font-family: var(--primary-font, "Klavika", sans-serif);
    font-size: clamp(1.5rem, 2vw, 2rem);
    font-weight: 400;
    line-height: 1.15;
    color: #fff;
    margin-bottom: 20px;
}

.expanding-panels__content-text {
    max-width: 18.75rem;
    font-family: var(--primary-font, "Klavika", sans-serif);
    font-size: 16px;
    line-height: 1.6;
    color: rgba(255, 255, 255, 0.92);
}

.expanding-panels__content-text p {
    margin: 0 0 12px;
}

.expanding-panels__content-text p:last-child {
    margin-bottom: 0;
}

/* --- Per-panel arrow button --------------------------------------------- */
.expanding-panels__arrow {
    display: flex;
    padding: 0.75rem;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    margin-top: auto; /* push to the bottom of the content column */
    background: #fff;
    border-radius: 4px;
    color: var(--magenta-color, #A52A87);
    flex-shrink: 0;
    transition: transform 0.3s ease;
}

.expanding-panels__arrow .ep-arrow-icon {
    width: 1rem;
    height: 1rem;
}

.expanding-panels__arrow:hover,
.expanding-panels__arrow:focus-visible {
    transform: translateX(4px);
}

/* --- Global CTA (bottom-right) ------------------------------------------ */
.expanding-panels__cta {
    position: absolute;
    right: 0;
    bottom: 32px;
    z-index: 5;
    display: inline-flex;
    align-items: center;
    gap: 14px;
    padding: 20px 32px;
    background: var(--magenta-color, #A52A87);
    color: #fff;
    font-family: var(--primary-font, "Klavika", sans-serif);
    font-size: 18px;
    font-weight: 600;
    line-height: 1;
    text-decoration: none;
    transition: filter 0.25s ease;
}

.expanding-panels__cta:hover,
.expanding-panels__cta:focus-visible {
    filter: brightness(0.92);
    color: #fff;
}

/* --- Arrow icon (mask so it follows currentColor) ----------------------- */
.ep-arrow-icon {
    display: inline-block;
    width: 22px;
    height: 22px;
    background-color: currentColor;
    -webkit-mask-repeat: no-repeat;
    mask-repeat: no-repeat;
    -webkit-mask-position: center;
    mask-position: center;
    -webkit-mask-size: contain;
    mask-size: contain;
    flex-shrink: 0;
}

.expanding-panels__cta .ep-arrow-icon {
    color: #fff;
    transition: transform 0.3s ease;
}

.expanding-panels__cta:hover .ep-arrow-icon {
    transform: translateX(4px);
}

/* --- Responsive --------------------------------------------------------- */
@media (max-width: 1024px) {
    .expanding-panels__intro {
        flex-direction: column;
        gap: 24px;
    }

    .expanding-panels__lead {
        flex-basis: auto;
        max-width: 640px;
    }
}

@media (max-width: 767px) {
    /* Stack the panels vertically; the active one grows in height instead. */
    .expanding-panels__grid {
        --ep-panel-height: auto;
        flex-direction: column;
    }

    .expanding-panels__panel {
        height: 96px;
        transition: flex-grow 0.85s cubic-bezier(0.22, 1, 0.36, 1), height 0.85s cubic-bezier(0.22, 1, 0.36, 1);
    }

    .expanding-panels__panel:hover,
    .expanding-panels__panel:focus-within,
    .expanding-panels__panel.is-active {
        height: 460px;
    }

    /* On the stacked layout the vertical label reads awkwardly — lay it flat. */
    .expanding-panels__label {
        writing-mode: horizontal-tb;
        top: 34px;
        transform: translateX(-50%);
    }

    .expanding-panels__content {
        top: 76px;
    }

    .expanding-panels__cta {
        position: static;
        margin-top: 16px;
        justify-content: center;
        width: 100%;
    }
}

/* --- Reduced motion ----------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
    .expanding-panels__panel,
    .expanding-panels__veil,
    .expanding-panels__scrim,
    .expanding-panels__number,
    .expanding-panels__label,
    .expanding-panels__content,
    .expanding-panels__arrow,
    .expanding-panels__cta,
    .ep-arrow-icon {
        transition: none;
    }
}
