/* ============================================================
   SDG Section – All 17 Goals
   Layout: 3-row grid (6 / 6 / 5), flip animation on click
   ============================================================ */

/* ---- Section shell ---- */
.fnf-sdg-all-section {
    position: relative;
    width: 100%;
    min-height: 60vh;
    /* background-image: url('/assets/img/sdg-page21.png'); */
    background-color: rgb(242, 244, 255);
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    padding: 30vh clamp(24px, 5%, 64px) clamp(32px, 5vh, 60px);
    box-sizing: border-box;
    gap: clamp(20px, 3vh, 36px);
}


/* ---- Title image ---- */
.fnf-sdg-title-wrap {
    position: absolute;
    top: clamp(14px, 2.5vh, 28px);
    left: clamp(24px, 3%, 64px);
}

.fnf-sdg-title-img {
    width: clamp(180px, 30vw, 480px);
    height: auto;
}

/* ---- Grid ---- */
.fnf-sdg-all-grid {
    --sdg-gap: clamp(5px, 0.8vw, 10px);
    display: flex;
    flex-direction: column;
    gap: var(--sdg-gap);
    max-width: clamp(480px, 88%, 980px);
}

/* ---- Rows ---- */
.fnf-sdg-row {
    display: flex;
    gap: var(--sdg-gap);
    justify-content: flex-start;
}

.fnf-sdg-row--last {
    justify-content: flex-start;
}

/* Cards in last row match 1/6 of row width (same as 6-item rows) */
.fnf-sdg-row--last .fnf-sdg-flip-card {
    flex: 0 0 calc((100% - 5 * var(--sdg-gap)) / 6);
}

/* ---- Card shell ---- */
.fnf-sdg-flip-card {
    position: relative;
    flex: 1 1 0;
    aspect-ratio: 1 / 1;
    perspective: 700px;
    cursor: pointer;
    border: none;
    background: transparent;
    padding: 0;
    outline: none;
    border-radius: 8px;
    transition: transform 0.22s ease, filter 0.22s ease;
    will-change: transform;
}

/* ---- Top 200 badge ---- */
.fnf-sdg-top200-badge {
    position: absolute;
    top: 5px;
    right: 5px;
    background: #FFD700;
    color: #1a1a1a;
    font-family: 'Poppins', sans-serif;
    font-size: clamp(6px, 0.55vw, 9px);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 2px 5px;
    border-radius: 3px;
    z-index: 10;
    pointer-events: none;
    line-height: 1.2;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
}

.fnf-sdg-flip-card:hover {
    transform: scale(1.06) translateY(-2px);
    filter: drop-shadow(0 6px 18px rgba(255, 255, 255, 0.18));
    z-index: 2;
}

.fnf-sdg-flip-card:focus-visible {
    outline: 2px solid rgba(255, 255, 255, 0.7);
    outline-offset: 3px;
}

/* Hide badge on back view */
.fnf-sdg-flip-card.flipped .fnf-sdg-top200-badge {
    opacity: 0;
    pointer-events: none;
}

/* Pause hover scale during flip to avoid jitter */
.fnf-sdg-flip-card.flipped:hover {
    transform: scale(1.04) translateY(-2px);
}

/* ---- 3-D flip mechanism ---- */
.fnf-sdg-flip-inner {
    position: relative;
    width: 100%;
    height: 100%;
    transform-style: preserve-3d;
    transition: transform 0.55s cubic-bezier(0.4, 0.2, 0.2, 1);
    border-radius: 8px;
}

.fnf-sdg-flip-card.flipped .fnf-sdg-flip-inner {
    transform: rotateY(180deg);
}

/* ---- Faces ---- */
.fnf-sdg-face {
    position: absolute;
    inset: 0;
    border-radius: 8px;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    overflow: hidden;
}

/* -- Front: SDG image -- */
.fnf-sdg-face--front {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.45);
}

.fnf-sdg-face--front img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* -- Back: color + text -- */
.fnf-sdg-face--back {
    transform: rotateY(180deg);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: clamp(6px, 8%, 14px);
    text-align: center;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.45);
    gap: 4px;
}

.fnf-sdg-back-desc {
    font-family: 'Poppins', sans-serif;
    font-size: clamp(7px, 0.8vw, 11px);
    color: rgba(255, 255, 255, 0.92);
    margin: 0;
    line-height: 1.45;
    display: -webkit-box;
    -webkit-line-clamp: 4;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ============================================================
   Responsive
   ============================================================ */

/* Tablet */
@media (max-width: 1024px) {
    .fnf-sdg-all-section {
        min-height: 55vh;
    }

    .fnf-sdg-title-img {
        width: clamp(160px, 24vw, 320px);
    }

    .fnf-sdg-back-desc {
        display: none;
    }

    .fnf-sdg-face--back {
        justify-content: center;
        gap: 6px;
    }
}

/* Mobile landscape / small tablet */
@media (max-width: 768px) {
    .fnf-sdg-all-section {
        min-height: auto;
        padding: 16px 16px 28px;
        gap: 14px;
    }

    /* Pull title out of absolute flow so it stacks naturally above the grid */
    .fnf-sdg-title-wrap {
        position: static;
        display: flex;
        justify-content: flex-start;
    }

    .fnf-sdg-title-img {
        width: clamp(140px, 50vw, 220px);
    }

    .fnf-sdg-all-grid {
        --sdg-gap: 5px;
        max-width: 100%;
        width: 100%;
    }

    .fnf-sdg-row {
        gap: 5px;
    }

    .fnf-sdg-flip-card {
        border-radius: 6px;
    }

    .fnf-sdg-face {
        border-radius: 6px;
    }

    .fnf-sdg-flip-inner {
        border-radius: 6px;
    }
}

/* Mobile portrait */
@media (max-width: 480px) {
    .fnf-sdg-flip-card:hover {
        transform: none;
        filter: none;
    }

    .fnf-sdg-face--back {
        padding: 4px;
    }
}

/* Reduced motion preference */
@media (prefers-reduced-motion: reduce) {
    .fnf-sdg-flip-inner {
        transition: none;
    }

    .fnf-sdg-flip-card {
        transition: none;
    }

    .fnf-sdg-flip-card.flipped .fnf-sdg-face--front {
        opacity: 0;
    }

    .fnf-sdg-flip-card.flipped .fnf-sdg-face--back {
        opacity: 1;
    }
}