/* ============================================
   Leisure Centre Flip Card Styles
   Add to: child theme's style.css or via
   Appearance > Customize > Additional CSS
   ============================================ */

/* Card container — sets the 3D perspective */
.wpex-leisure-card {
    perspective: 1200px;
    -webkit-perspective: 1200px;
    width: 100%;
    max-width: 340px;
    height: 520px; /* Adjust to suit your content */
    margin: 0 auto;
    /* Isolate the card's stacking context so carousel transforms don't interfere */
    isolation: isolate;
}

/* Inner wrapper — this is what physically rotates */
.wpex-leisure-card .wpex-card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    transition: transform 0.7s cubic-bezier(0.4, 0.2, 0.2, 1);
    -webkit-transition: -webkit-transform 0.7s cubic-bezier(0.4, 0.2, 0.2, 1);
    transform-style: preserve-3d;
    -webkit-transform-style: preserve-3d;
    /* border-radius removed: triggers iOS Safari compositing bugs with preserve-3d */
    will-change: transform;
}

/* Flipped state — toggled by JS */
.wpex-leisure-card.is-flipped .wpex-card-inner {
    transform: rotateY(180deg);
}

/* Shared front/back styles */
.wpex-leisure-card .wpex-card-front,
.wpex-leisure-card .wpex-card-back {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    border-radius: 12px;
    /* overflow:hidden on a preserve-3d child crashes iOS Safari GPU compositor.
       Clipping is handled by the card container's perspective context instead. */
    overflow: hidden;
    -webkit-transform: translateZ(0); /* force GPU layer on iOS */
}

/* =====================
   FRONT
   ===================== */
.wpex-leisure-card .wpex-card-front {
    background-color: #3b1a5a;
    display: flex;
    flex-direction: column;
}

/* Feature image — top portion */
.wpex-leisure-card .wpex-leisure-photo {
    width: 100%;
    flex-shrink: 0;
    height: 55%;
    overflow: hidden;
}

.wpex-leisure-card .wpex-leisure-photo-img,
.wpex-leisure-card .wpex-leisure-photo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* Text area below image */
.wpex-leisure-card .wpex-card-front-content {
    background-color: #3b1a5a;
    padding: 20px 20px 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    flex: 1;
    gap: 10px;
}

/* Page title */
.wpex-leisure-card .wpex-leisure-title,
.wpex-leisure-card .wpex-leisure-title a {
    color: #ffffff;
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1.25;
    margin: 0;
    text-decoration: none;
}

/* Excerpt */
.wpex-leisure-card .wpex-leisure-excerpt,
.wpex-leisure-card .wpex-leisure-excerpt p {
    color: #e0d4f0;
    font-size: 0.9rem;
    line-height: 1.5;
    margin: 0;
}

/* =====================
   BACK
   ===================== */
.wpex-leisure-card .wpex-card-back {
    background-color: #3b1a5a;
    transform: rotateY(180deg);
    display: flex;
    flex-direction: column;
}

.wpex-leisure-card .wpex-card-back-content {
    padding: 28px 24px;
    display: flex;
    flex-direction: column;
    height: 100%;
    gap: 12px;
    overflow-y: auto;
}

/* Back title */
.wpex-leisure-card .wpex-back-title {
    color: #ffffff;
    font-size: 1.2rem;
    font-weight: 700;
    margin: 0;
    text-align: center;
}

/* Activities list */
.wpex-leisure-card .wpex-activities-list {
    list-style: none;
    margin: 0;
    padding: 0;
    flex: 1;
}

.wpex-leisure-card .wpex-activity-item {
    color: #e0d4f0;
    font-size: 0.875rem;
    padding: 6px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    line-height: 1.4;
}

.wpex-leisure-card .wpex-activity-item:last-child {
    border-bottom: none;
}

.wpex-leisure-card .wpex-no-activities {
    color: #c0a8d8;
    font-style: italic;
    font-size: 0.875rem;
}

/* =====================
   BUTTONS
   ===================== */

/* Learn More (front) */
.wpex-leisure-card .wpex-learn-more-btn {
    display: inline-block;
    background-color: transparent;
    border: 2px solid #7c3aed;
    color: #ffffff;
    padding: 12px 28px;
    margin-top: auto;
    width: 100%;
    max-width: 200px;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.wpex-leisure-card .wpex-learn-more-btn:hover,
.wpex-leisure-card .wpex-learn-more-btn:focus {
    background-color: #7c3aed;
    outline: none;
}

/* Visit Page button (back) */
.wpex-leisure-card .wpex-page-btn {
    display: block;
    background-color: #7c3aed;
    border: 2px solid #7c3aed;
    color: #ffffff;
    padding: 12px 28px;
    width: 100%;
    text-align: center;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    text-decoration: none;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.wpex-leisure-card .wpex-page-btn:hover,
.wpex-leisure-card .wpex-page-btn:focus {
    background-color: #6d28d9;
    border-color: #6d28d9;
    color: #ffffff;
    outline: none;
}

/* Back arrow button (back) */
.wpex-leisure-card .wpex-back-btn {
    background: none;
    border: none;
    color: #c0a8d8;
    padding: 4px 0;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    cursor: pointer;
    text-align: left;
    margin-top: auto;
    transition: color 0.2s ease;
}

.wpex-leisure-card .wpex-back-btn:hover,
.wpex-leisure-card .wpex-back-btn:focus {
    color: #ffffff;
    outline: none;
}

/* =====================
   TIMETABLE MODAL
   ===================== */

/* Prevent body scroll when modal is open */
body.wpex-modal-open {
    overflow: hidden;
}

/* Full-screen overlay — display toggled via inline style by JS */
.wpex-timetable-modal {
    position: fixed;
    inset: 0;
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

/* Semi-transparent background */
.wpex-timetable-modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    cursor: pointer;
}

/* Modal box */
.wpex-timetable-modal-box {
    position: relative;
    background: #ffffff;
    border-radius: 12px;
    width: 100%;
    max-width: 900px;
    max-height: 90vh;
    overflow-y: auto;
    padding: 40px 32px 32px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
}

/* Close button (×) */
.wpex-timetable-modal-close-btn {
    position: absolute;
    top: 14px;
    right: 16px;
    background: none;
    border: none;
    font-size: 1.8rem;
    line-height: 1;
    color: #3b1a5a;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: background-color 0.2s ease;
}

.wpex-timetable-modal-close-btn:hover,
.wpex-timetable-modal-close-btn:focus {
    background-color: rgba(59, 26, 90, 0.1);
    outline: none;
}

/* Modal heading */
.wpex-timetable-modal-title {
    color: #3b1a5a;
    font-size: 1.4rem;
    font-weight: 700;
    margin: 0 0 20px;
}

/* Timetable content area */
.wpex-timetable-modal-content {
    width: 100%;
    overflow-x: auto;
}

/* =====================
   MOBILE / CAROUSEL FIXES
   ===================== */

/* Disable pointer events on non-active carousel slides so auto-slide
   can't ghost-click buttons on off-screen cards. Works with Swiper,
   Splide, and Total theme's built-in carousel (they all add these classes). */
.swiper-slide:not(.swiper-slide-active) .wpex-leisure-card,
.splide__slide:not(.is-active) .wpex-leisure-card,
[data-vcex-carousel] .vc_item:not(.active) .wpex-leisure-card {
    pointer-events: none;
}

/* iOS Safari: reduce motion on mobile to avoid GPU compositor overload
   that causes the "can't open this page" crash on older iPhones */
@media (max-width: 767px) {
    .wpex-leisure-card .wpex-card-inner {
        transition-duration: 0.4s;
    }
}

/* Respect reduced-motion preference */
@media (prefers-reduced-motion: reduce) {
    .wpex-leisure-card .wpex-card-inner {
        transition: none;
    }
}
