/*
 * Expanding panels (parts/components/expanding-panels.php, behaviour in
 * assets/js/expanding-panels.js). Plain CSS rather than Tailwind so no main.css
 * rebuild is needed.
 *
 * Small screens: strips stacked vertically; the open one grows to fit its
 * text (grid row 0fr -> 1fr, so any length fits). From 1024px: a row of
 * strips; the open one takes five shares of the width.
 */

.expanding-panels__heading {
    margin-bottom: 2rem;
}

.expanding-panels__row {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.expanding-panels__panel {
    position: relative;
    display: grid;
    grid-template-rows: 0fr;
    min-height: 80px;
    border-radius: 24px;
    overflow: hidden;
    color: #fff;
    background: var(--color-brand);
    cursor: pointer;
    outline: none;
    transition: grid-template-rows 700ms cubic-bezier(0.65, 0, 0.35, 1),
                padding-top 700ms cubic-bezier(0.65, 0, 0.35, 1),
                flex-grow 700ms cubic-bezier(0.65, 0, 0.35, 1);
}

.expanding-panels__panel--plain:nth-child(even) {
    background: var(--color-brand-dark);
}

.expanding-panels__panel.is-active {
    grid-template-rows: 1fr;
    padding-top: 6rem;
    cursor: default;
}

.expanding-panels__panel--plain.is-active {
    padding-top: 3rem;
}

.expanding-panels__panel:focus-visible {
    box-shadow: 0 0 0 3px var(--color-brand-light);
}

.expanding-panels__panel img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 1200ms cubic-bezier(0.21, 0.45, 0.32, 0.9);
}

/* Photos get a dark gradient so their text reads; closed strips are a little
   darker at the top as well. */
.expanding-panels__panel:not(.expanding-panels__panel--plain)::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, rgba(0, 0, 0, 0.4) 0%, rgba(0, 0, 0, 0.6) 40%, rgba(0, 0, 0, 0.9) 100%);
}

.expanding-panels__panel.is-active:not(.expanding-panels__panel--plain)::after {
    background: linear-gradient(180deg, rgba(0, 0, 0, 0.15) 0%, rgba(0, 0, 0, 0.55) 40%, rgba(0, 0, 0, 0.9) 100%);
}

.expanding-panels__panel:not(.is-active):hover img {
    transform: scale(1.08);
}

/* Label on a closed strip. */
.expanding-panels__tag {
    position: absolute;
    left: 1.5rem;
    top: 40px;
    z-index: 1;
    font-size: 1.25rem;
    line-height: 1;
    font-weight: 600;
    white-space: nowrap;
    transform: translateY(-50%);
    transition: opacity 300ms ease;
}

.is-active .expanding-panels__tag {
    opacity: 0;
}

.expanding-panels__content {
    position: relative;
    z-index: 1;
    min-height: 0;
    overflow: hidden;
    padding: 0 1.5rem;
    opacity: 0;
    transition: opacity 300ms ease, padding 700ms cubic-bezier(0.65, 0, 0.35, 1);
}

.is-active .expanding-panels__content {
    padding-bottom: 1.5rem;
    opacity: 1;
    transition: opacity 500ms ease 350ms, padding 700ms cubic-bezier(0.65, 0, 0.35, 1);
}

.expanding-panels__title {
    font-size: 1.375rem;
    line-height: 1.1;
    font-weight: 600;
}

.expanding-panels__content p {
    margin-top: 0.625rem;
    font-size: 0.8125rem;
    line-height: 1.45;
    color: rgba(255, 255, 255, 0.92);
}

.expanding-panels__title,
.expanding-panels__content p {
    transform: translateY(12px);
    transition: transform 500ms ease;
}

.is-active .expanding-panels__title,
.is-active .expanding-panels__content p {
    transform: none;
    transition-delay: 350ms;
}

@media (min-width: 768px) {
    .expanding-panels__heading {
        margin-bottom: 3rem;
    }

    /* Tablet and up: phone sizes above are slightly smaller. */
    .expanding-panels__title {
        font-size: 1.5rem;
    }

    .expanding-panels__content p {
        font-size: 0.875rem;
        line-height: 1.55;
    }

    /* Tablet keeps the stacked layout with taller cards; desktop overrides
       these below. */
    .expanding-panels__panel {
        min-height: 92px;
    }

    .expanding-panels__panel.is-active {
        padding-top: 10rem;
    }

    .expanding-panels__panel--plain.is-active {
        padding-top: 4rem;
    }
}

@media (min-width: 1024px) {
    .expanding-panels__row {
        flex-direction: row;
        height: 400px;
    }

    .expanding-panels__panel,
    .expanding-panels__panel.is-active {
        display: block;
        flex: 1 1 0;
        min-width: 0;
        min-height: 0;
        padding-top: 0;
    }

    .expanding-panels__panel.is-active {
        flex-grow: 5;
    }

    /* Closed strips are narrow, so their label runs up the strip. */
    .expanding-panels__tag {
        top: auto;
        bottom: 1.75rem;
        left: 50%;
        writing-mode: vertical-rl;
        transform: translateX(-50%) rotate(180deg);
    }

    /* Fixed width so the text doesn't reflow while the panel opens; the
       closed strips simply clip it. */
    .expanding-panels__content,
    .is-active .expanding-panels__content {
        position: absolute;
        left: 0;
        bottom: 0;
        width: 26rem;
        padding: 2rem;
    }

    .expanding-panels__title {
        font-size: 1.875rem;
    }
}

@media (min-width: 1280px) {
    .expanding-panels__content,
    .is-active .expanding-panels__content {
        width: 32rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    .expanding-panels__panel,
    .expanding-panels__panel img,
    .expanding-panels__content,
    .expanding-panels__title,
    .expanding-panels__content p {
        transition: none;
    }
}
