/* Card Container - Absolute Positioning Strategy */
.module_column.reference-card {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    border-radius: 0 !important;

    /* Physical layout anchor - creates permanent space for the title without pushing */
    /* padding-bottom: 100px !important; */

    position: relative !important;
    isolation: isolate;
    /* Traps the seamless background */
    transition: transform var(--reference-reveal-speed) var(--reference-reveal-easing) !important;
}

/* Desktop-Only Hover Interactions */
@media (min-width: 1025px) {
    .module_column.reference-card:hover {
        transform: translateY(-8px) !important;
        z-index: 50 !important;
    }
}

/* Image Module */
.reference-card-image {
    margin: 0 !important;
    overflow: hidden !important;
    border-radius: var(--reference-radius-top) var(--reference-radius-top) 0 0 !important;
    position: relative;
    z-index: 1;
    /* Sits cleanly above the text shadow */
}

.module_column.reference-card .reference-card-image img {
    width: 100% !important;
    height: var(--reference-card-height) !important;
    object-fit: cover !important;
    transition: transform var(--reference-reveal-speed) var(--reference-reveal-easing),
        filter var(--reference-reveal-speed) var(--reference-reveal-easing) !important;
    display: block !important;
    pointer-events: none !important;
    transform: scale(1.0);
    /* Start slightly zoomed in */
}

@media (min-width: 1025px) {
    .module_column.reference-card:hover .reference-card-image img {
        transform: scale(1.1) !important;
        filter: brightness(1);
    }

    .module_column.reference-card-featured:hover .reference-card-image img {
        filter: saturate(1.1) brightness(1.05) !important;
    }
}

/* Text Module / Content - The Absolute Layer */
.module_column.reference-card .module-text.reference-card-subtext {
    position: absolute !important;
    top: var(--reference-card-height) !important;
    left: 0;
    right: 0;
    padding: 0 32px !important;
    /* Unified horizontal alignment zone */
    z-index: auto !important;
}

/* The Magic Seamless Background Wrapper */
.module_column.reference-card .module-text.reference-card-subtext::before {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    /* Hugs the expanding text and stretches UP exactly enough to cover the image */
    height: calc(100% + var(--reference-card-height));
    background: var(--reference-bg);
    border: 1px solid var(--reference-outline);
    border-radius: var(--reference-radius-top) var(--reference-radius-top) var(--reference-radius-bottom) var(--reference-radius-bottom);
    box-shadow: var(--reference-shadow);
    z-index: -1;
    transition: box-shadow var(--reference-reveal-speed) var(--reference-reveal-easing);
    pointer-events: none;
}

@media (min-width: 1025px) {
    .module_column.reference-card:hover .module-text.reference-card-subtext::before {
        box-shadow: var(--reference-shadow-hover);
    }
}

.reference-card-subtext .tb_text_wrap {
    padding: 0 !important;
}

/* Internal elements - High Specificity Base States */
.module_column.reference-card .module-text.reference-card-subtext h3 {
    font-family: var(--reference-font-heading) !important;
    font-size: var(--reference-font-size-title) !important;
    font-weight: 700 !important;
    color: var(--reference-text) !important;
    margin: 0 !important;
    padding: 32px 0 24px 0 !important;
    /* Horizontal handled by parent */
    transition: all var(--reference-reveal-speed) var(--reference-reveal-easing) !important;
}

/* Hide subtext by default */
.module_column.reference-card .module-text.reference-card-subtext p,
.module_column.reference-card .module-text.reference-card-subtext .reference-btn {
    max-height: 0 !important;
    opacity: 0 !important;
    overflow: hidden !important;
    margin: 0 !important;
    padding: 0 !important;
    /* Horizontal handled by parent */
    transition: all var(--reference-reveal-speed) var(--reference-reveal-easing) !important;
    display: block !important;
}

/* Reveal on hover - Scoped strictly to the hovered card (Desktop Only) */
@media (min-width: 1025px) {
    .module_column.reference-card:hover .module-text.reference-card-subtext h3 {
        padding-bottom: 12px !important;
        transition: padding var(--reference-reveal-speed) var(--reference-reveal-easing) !important;
    }

    .module_column.reference-card:hover .module-text.reference-card-subtext p {
        max-height: 150px !important;
        opacity: 1 !important;
        margin-bottom: 16px !important;
        transition: all var(--reference-reveal-speed) var(--reference-reveal-easing) !important;
    }

    .module_column.reference-card:hover .module-text.reference-card-subtext .reference-btn {
        max-height: 100px !important;
        opacity: 1 !important;
        padding-bottom: 32px !important;
        overflow: visible !important;
        transition: all var(--reference-reveal-speed) var(--reference-reveal-easing) !important;
    }
}

/* THE OVERLAP TRICK: Replaced by Absolute Architecture! */

/* Link Styling Fine-tuning */
.module_column.reference-card .module-text.reference-card-subtext .reference-btn {
    color: var(--reference-primary) !important;
    font-weight: 600 !important;
    text-decoration: none !important;
    display: inline-flex !important;
    align-items: center !important;
    transition: color 0.3s ease, max-height var(--reference-reveal-speed), opacity var(--reference-reveal-speed), padding var(--reference-reveal-speed) !important;
}

.module_column.reference-card .module-text.reference-card-subtext .reference-btn:hover {
    color: var(--reference-primary-light) !important;
}

.module_column.reference-card .module-text.reference-card-subtext .reference-btn span {
    margin-left: 8px;
    transition: transform 0.3s ease !important;
}

.reference-card-subtext .reference-btn:hover span {
    transform: translateX(5px);
}

/* =========================================
   Featured Card Variant
   ========================================= */

/* Badge logic for Featured Card */
.reference-card-featured .reference-card-image {
    position: relative !important;
}

.reference-card-featured .reference-card-image::after {
    content: 'FEATURED';
    position: absolute;
    top: 24px;
    left: 24px;
    z-index: 10;
    background-color: var(--reference-primary) !important;
    color: #ffffff !important;
    font-family: var(--reference-font-body) !important;
    font-size: 12px !important;
    font-weight: 700 !important;
    padding: 6px 14px !important;
    border-radius: 100px !important;
    letter-spacing: 0.05em !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15) !important;
    pointer-events: none !important;
}

/* Height adjustments for featured cards (inherited from base) */
.reference-card-featured .reference-card-image img {
    object-fit: cover !important;
    object-position: center 40% !important;
}

/* =========================================
   Mobile & Tablet View (Touch Devices)
   Disables hover reveals and shows all content
   ========================================= */
@media (max-width: 1024px) {
    .module_column.reference-card {
        padding-bottom: 0 !important;
        transform: none !important;
        background: var(--reference-bg) !important;
        border: 1px solid var(--reference-outline) !important;
        border-radius: var(--reference-radius-top) var(--reference-radius-top) var(--reference-radius-bottom) var(--reference-radius-bottom) !important;
        box-shadow: var(--reference-shadow) !important;
        overflow: hidden !important;
        margin-bottom: 24px !important;
        isolation: auto !important;
    }

    .module_column.reference-card .module-text.reference-card-subtext {
        position: relative !important;
        top: 0 !important;
        padding: 0 24px 32px 24px !important;
    }

    /* Force visibility of all elements */
    .module_column.reference-card .module-text.reference-card-subtext p,
    .module_column.reference-card .module-text.reference-card-subtext .reference-btn {
        max-height: none !important;
        opacity: 1 !important;
        padding: 0 !important;
        margin-top: 16px !important;
        overflow: visible !important;
    }

    .module_column.reference-card .module-text.reference-card-subtext h3 {
        padding: 24px 0 0 0 !important;
    }

    /* Disable Image zoom/scaling on mobile */
    .module_column.reference-card .reference-card-image img {
        transform: none !important;
        height: auto !important;
        min-height: 220px !important;
    }

    /* Hide the desktop-only magic background */
    .module_column.reference-card .module-text.reference-card-subtext::before {
        display: none !important;
    }
}

/* =========================================
   Builder Accessibility Patch
   Ensures you can still click and edit in Themify
   ========================================= */
.themify_builder_active .module_column.reference-card {
    padding-bottom: 0 !important;
    transform: none !important;
    isolation: auto !important;
}

.themify_builder_active .module_column.reference-card .module-text.reference-card-subtext {
    position: relative !important;
    top: 0 !important;
    opacity: 1 !important;
    max-height: none !important;
    padding: 0 32px !important;
}

.themify_builder_active .module_column.reference-card .module-text.reference-card-subtext p,
.themify_builder_active .module_column.reference-card .module-text.reference-card-subtext .reference-btn {
    max-height: none !important;
    opacity: 1 !important;
    padding: 10px 0 !important;
}

.themify_builder_active .module_column.reference-card .module-text.reference-card-subtext::before {
    display: none !important;
}