/**
 * Eighth Section Block
 *
 * Full-width white section: title, a grid (three per row) of flip cards
 * (front: background image + title box; back on hover/title-click: pale panel
 * with title + description), then a button and a bottom description.
 * Matches child-theme-sections-screenshots/eighth-section.png
 */

:root {
    --color-navy: #385d8c;
    --color-pale: #eef3f8;
    --color-teal: #93cddc;
    --color-sky:  #d2eaf0;
    --color-text: #787878;
    --color-white: #ffffff;
}

.eighth-section {
    background-color: var(--color-white);
    font-family: 'Roboto', sans-serif;
    padding: 60px 0;
}

.eighth-section__container {
    max-width: var(--theme-normal-container-max-width, 1290px);
    width: var(--theme-container-width, 100%);
    margin: 0 auto;
    padding: 0 20px;
}

.eighth-section__title {
    color: var(--color-navy);
    font-weight: 700;
    font-size: 30px;
    line-height: 1.3;
    text-align: center;
    margin: 0 0 40px;
}

/* ---- Grid ----
   Flexbox (not CSS grid) so a partial last row centres instead of
   left-aligning to the column tracks. */
.eighth-section__grid {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: stretch;
    gap: 30px;
}

/* ---- Flip card ---- */
.eighth-section__card {
    flex: 0 1 calc((100% - 60px) / 3);
    height: 380px;
    border-radius: 16px;
    perspective: 1400px;
}

.eighth-section__card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    transition: transform 0.6s ease;
    transform-style: preserve-3d;
}

/* Flip on hover or when toggled open via the title */
.eighth-section__card.has-back:hover .eighth-section__card-inner,
.eighth-section__card.has-back.is-flipped .eighth-section__card-inner {
    transform: rotateY(180deg);
}

.eighth-section__face {
    position: absolute;
    inset: 0;
    border-radius: 16px;
    overflow: hidden;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    box-shadow: 0 10px 26px rgba(0, 0, 0, 0.10);
}

/* Front — background image + title box */
.eighth-section__face--front {
    background-color: #e9e9e9;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.eighth-section__image-box {
    width: 100%;
    background-color: rgba(255, 255, 255, 0.82);
    border-radius: 10px;
    padding: 22px 24px;
}

.eighth-section__image-title {
    display: block;
    color: var(--color-navy);
    font-weight: 700;
    font-size: 22px;
    line-height: 1.3;
    text-align: center;
    margin: 0;
}

/* The title on a flippable card is a button (click / keyboard accessible) */
.eighth-section__flip-trigger {
    display: block;
    width: 100%;
    margin: 0;
    padding: 0;
    background: none;
    border: none;
    cursor: pointer;
    font-family: inherit;
}

/* Back — pale panel with title + description */
.eighth-section__face--back {
    transform: rotateY(180deg);
    background-color: var(--color-pale);
    display: flex;
    flex-direction: column;
    justify-content: center;
    text-align: center;
    padding: 32px 34px;
    overflow-y: auto;
}

.eighth-section__back-title {
    color: var(--color-navy);
    font-weight: 700;
    font-size: 22px;
    line-height: 1.3;
    margin: 0 0 16px;
}

.eighth-section__back-text {
    color: var(--color-text);
    font-size: 16px;
    line-height: 1.6;
}

.eighth-section__back-text p {
    color: inherit;
    margin: 0 0 1em;
}

.eighth-section__back-text p:last-child {
    margin-bottom: 0;
}

/* ---- Button + outro ---- */
.eighth-section__button-wrap {
    text-align: center;
    margin-top: 40px;
}

.eighth-section__outro {
    color: var(--color-text);
    font-size: 16px;
    font-style: italic;
    line-height: 1.6;
    max-width: 1100px;
    margin: 34px auto 0;
}

.eighth-section__outro p {
    color: inherit;
    margin: 0 0 1em;
}

.eighth-section__outro p:last-child {
    margin-bottom: 0;
}

/* ---- Button (teal secondary, per style guide) ---- */
.eighth-section .btn {
    display: inline-block;
    padding: 14px 30px;
    font-family: 'Roboto', sans-serif;
    font-size: 16px;
    font-weight: 600;
    text-align: center;
    text-decoration: none;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.3s ease, color 0.3s ease;
}

.eighth-section .btn-secondary {
    background-color: var(--color-teal);
    color: var(--color-navy);
}

.eighth-section .btn-secondary:hover,
.eighth-section .btn-secondary:focus {
    background-color: var(--color-navy);
    color: var(--color-white);
}

/* Tablet */
@media (min-width: 769px) and (max-width: 1023px) {
    .eighth-section__title {
        font-size: 26px;
    }

    .eighth-section__grid {
        gap: 26px;
    }

    .eighth-section__card {
        flex-basis: calc((100% - 26px) / 2);
        height: 340px;
    }
}

/* Mobile */
@media (max-width: 768px) {
    .eighth-section {
        padding: 40px 0;
    }

    .eighth-section__title {
        font-size: 24px;
        margin-bottom: 30px;
    }

    .eighth-section__grid {
        gap: 22px;
    }

    .eighth-section__card {
        flex-basis: 100%;
        height: 320px;
    }

    .eighth-section__image-title,
    .eighth-section__back-title {
        font-size: 20px;
    }
}
