/* =========================================
   FLIP CARDS
========================================= */

.cards {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 30px;
}

/* =========================================
   CARD OUTER CONTAINER
========================================= */

.card {
    position: relative;
    height: 360px;

    cursor: pointer;
    perspective: 1200px;

    /* Keeps hover movement separate from 3D rotation */
    transition: transform 0.3s ease;

    /* Helps prevent mobile rendering glitches */
    -webkit-tap-highlight-color: transparent;
}

.card:hover {
    transform: translateY(-4px);
}

/* =========================================
   CARD INNER
========================================= */

.card-inner {
    position: relative;

    width: 100%;
    height: 100%;

    transform-style: preserve-3d;
    -webkit-transform-style: preserve-3d;

    transition: transform 0.7s ease;

    will-change: transform;
}

/* Flip */
.card.flipped .card-inner {
    transform: rotateY(180deg);
    -webkit-transform: rotateY(180deg);
}

/* =========================================
   FRONT + BACK
========================================= */

.card-front,
.card-back {
    position: absolute;
    inset: 0;

    width: 100%;
    height: 100%;

    padding: 40px 30px;

    display: flex;
    align-items: center;
    justify-content: center;

    text-align: center;

    border-radius: 18px;

    /*
       Use the site's existing color system.
       This keeps desktop and mobile identical.
    */
    box-shadow: var(--shadow-md);

    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;

    /*
       Prevents some mobile browsers from showing
       the wrong face during the animation.
    */
    transform-style: preserve-3d;
    -webkit-transform-style: preserve-3d;
}

/* =========================================
   FRONT
========================================= */

.card-front {
    background: var(--section-alt);
    color: var(--dark);
}

/* =========================================
   BACK
========================================= */

.card-back {
    background: var(--section-alt);
    color: var(--dark);

    transform: rotateY(180deg);
    -webkit-transform: rotateY(180deg);
}

/* =========================================
   CARD CONTENT
========================================= */

.card-front > div,
.card-back > div {
    width: 100%;
}

/* Icon */
.card .detail-icon {
    display: block;

    margin-bottom: 18px;

    color: var(--accent);

    font-size: 32px;
    line-height: 1;
}

/* Heading */
.card h3 {
    margin-bottom: 15px;

    font-family: "Cormorant Garamond", serif;
    font-size: 36px;
    font-weight: 500;
    line-height: 1.1;

    color: var(--dark);
}

/* Paragraph */
.card p {
    margin: 10px 0;

    color: var(--muted);

    font-size: 13px;
    line-height: 1.7;
}

/* Time */
.card .time {
    margin: 15px 0;

    color: var(--accent-dark);

    font-size: 12px;
    letter-spacing: 1.5px;
}

/* Accent */
.card .accent {
    color: var(--accent);
}

/* Flip hint */
.card-hint {
    display: inline-block;

    margin-top: 18px;

    color: var(--accent-dark);

    font-size: 9px;
    font-weight: 600;
    letter-spacing: 2px;
    text-transform: uppercase;
}

/* Note */
.card-note {
    margin-top: 20px !important;

    color: var(--accent-dark) !important;

    font-size: 11px !important;
    letter-spacing: 1px;
}

/* =========================================
   TABLET
========================================= */

@media (max-width: 900px) {
    .cards {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

/* =========================================
   MOBILE
========================================= */

@media (max-width: 600px) {
    .cards {
        grid-template-columns: 1fr;
        gap: 25px;
    }

    .card {
        height: 340px;
    }

    /*
       Explicitly preserve the same colors on mobile.
       This prevents browser/default/inherited styling
       from changing the card appearance.
    */
    .card-front {
        background: var(--section-alt);
        color: var(--dark);
    }

    .card-back {
        background: var(--ivory);
        color: var(--dark);
    }

    .card h3 {
        font-size: 32px;
    }

    .card p {
        font-size: 13px;
    }
}

/* =========================================
   VERY SMALL MOBILE
========================================= */

@media (max-width: 380px) {
    .card {
        height: 330px;
    }

    .card-front,
    .card-back {
        padding: 30px 22px;
    }

    .card h3 {
        font-size: 29px;
    }
}

/* =========================================
   REDUCED MOTION
========================================= */

@media (prefers-reduced-motion: reduce) {
    .card,
    .card-inner {
        transition-duration: 0.01ms;
    }
}
