/**
 * Expandable Hover Cards - Stylesheet
 * 
 * Production-ready responsive styles for Desktop (Hover Flex), Tablet (3-Col Grid), and Mobile (1-Col Stack).
 *
 * @package ExpandableHoverCards
 * @version 1.0.0
 */

/* ==========================================================================
   1. CSS Custom Properties / Design Tokens Defaults
   ========================================================================== */
:root {
    --ehc-duration: 500ms;
    --ehc-easing: cubic-bezier(0.25, 1, 0.5, 1);
    --ehc-expanded-flex: 2.2;
    --ehc-collapsed-flex: 1;
    --ehc-zoom: 1.06;
    --ehc-height: 520px;
    --ehc-tablet-height: 420px;
    --ehc-mobile-height: 380px;
    --ehc-gap: 12px;
    --ehc-tablet-gap: 16px;
    --ehc-mobile-gap: 14px;
    --ehc-border-radius: 16px;
    --ehc-card-padding: 24px;
    --ehc-overlay-normal: rgba(15, 28, 44, 0.45);
    --ehc-overlay-expanded: rgba(15, 28, 44, 0.55);
    --ehc-overlay-hover: rgba(15, 28, 44, 0.50);
    --ehc-title-color: #ffffff;
    --ehc-desc-color: rgba(255, 255, 255, 0.88);
    --ehc-num-color: rgba(255, 255, 255, 0.75);
    --ehc-num-active-color: #ffffff;
    --ehc-num-top: 24px;
    --ehc-num-right: 24px;
    --ehc-num-bottom: 24px;
    --ehc-num-left: 24px;
    --ehc-link-color: #ffffff;
    --ehc-link-hover-color: #ffffff;
    --ehc-link-border: rgba(255, 255, 255, 0.45);
    --ehc-link-hover-border: #ffffff;
}

/* ==========================================================================
   2. Base Wrapper & Desktop Flexbox Grid
   ========================================================================== */
.ehc-wrapper {
    position: relative;
    width: 100%;
    box-sizing: border-box;
}

.ehc-grid {
    display: flex;
    flex-direction: row;
    align-items: stretch;
    width: 100%;
    height: var(--ehc-height, 520px);
    gap: var(--ehc-gap, 12px);
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    list-style: none;
}

/* ==========================================================================
   3. Card Component Structure & States
   ========================================================================== */
.ehc-card {
    position: relative;
    flex: var(--ehc-collapsed-flex, 1) 1 0%;
    min-width: 0;
    height: 100%;
    border-radius: var(--ehc-border-radius, 16px);
    overflow: hidden;
    box-sizing: border-box;
    cursor: pointer;
    background-color: #1a2332;
    transform: translateZ(0);
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    transition:
        flex-grow var(--ehc-duration, 500ms) var(--ehc-easing, cubic-bezier(0.25, 1, 0.5, 1)),
        flex-basis var(--ehc-duration, 500ms) var(--ehc-easing, cubic-bezier(0.25, 1, 0.5, 1)),
        transform var(--ehc-duration, 500ms) var(--ehc-easing, cubic-bezier(0.25, 1, 0.5, 1)),
        box-shadow var(--ehc-duration, 500ms) var(--ehc-easing, cubic-bezier(0.25, 1, 0.5, 1)),
        border-color var(--ehc-duration, 500ms) var(--ehc-easing, cubic-bezier(0.25, 1, 0.5, 1));
}

/* Expanded Card State */
.ehc-card.ehc-card--expanded {
    flex-grow: var(--ehc-expanded-flex, 2.2);
    cursor: default;
}

/* Focus state for keyboard accessibility */
.ehc-card:focus-visible,
.ehc-card:focus-within {
    outline: 2px solid #ffffff;
    outline-offset: 3px;
}

/* ==========================================================================
   4. Background Image Layer
   ========================================================================== */
.ehc-card-bg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center center;
    background-repeat: no-repeat;
    z-index: 1;
    pointer-events: none;
    transform: scale(1.0001);
    transform-origin: center center;
    transition:
        transform var(--ehc-duration, 500ms) var(--ehc-easing, cubic-bezier(0.25, 1, 0.5, 1)),
        filter var(--ehc-duration, 500ms) ease;
    will-change: transform;
}

/* Zoom effect on active / hover */
.ehc-card.ehc-card--expanded .ehc-card-bg,
.ehc-card:hover .ehc-card-bg {
    transform: scale(var(--ehc-zoom, 1.06));
}

/* ==========================================================================
   5. Overlay Layer
   ========================================================================== */
.ehc-card-overlay {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    background: var(--ehc-overlay-normal, rgba(15, 28, 44, 0.45));
    z-index: 2;
    pointer-events: none;
    transition:
        background-color var(--ehc-duration, 500ms) ease,
        opacity var(--ehc-duration, 500ms) ease;
}

.ehc-card:hover .ehc-card-overlay {
    background: var(--ehc-overlay-hover, rgba(15, 28, 44, 0.50));
}

.ehc-card.ehc-card--expanded .ehc-card-overlay {
    background: var(--ehc-overlay-expanded, rgba(15, 28, 44, 0.55));
}

/* ==========================================================================
   6. Number Badge (Bottom on Collapsed -> Top-Right on Active/Expanded)
   ========================================================================== */
.ehc-card-number {
    position: absolute;
    z-index: 5;
    font-family: inherit;
    font-size: var(--ehc-num-size, 14px);
    font-weight: 500;
    line-height: 1;
    letter-spacing: 0.05em;
    color: var(--ehc-num-color, rgba(255, 255, 255, 0.75));
    pointer-events: none;
    white-space: nowrap;
    transition:
        color var(--ehc-duration, 500ms) ease,
        opacity var(--ehc-duration, 500ms) ease,
        transform var(--ehc-duration, 500ms) var(--ehc-easing, cubic-bezier(0.25, 1, 0.5, 1)),
        top var(--ehc-duration, 500ms) var(--ehc-easing, cubic-bezier(0.25, 1, 0.5, 1)),
        bottom var(--ehc-duration, 500ms) var(--ehc-easing, cubic-bezier(0.25, 1, 0.5, 1)),
        left var(--ehc-duration, 500ms) var(--ehc-easing, cubic-bezier(0.25, 1, 0.5, 1)),
        right var(--ehc-duration, 500ms) var(--ehc-easing, cubic-bezier(0.25, 1, 0.5, 1));
}

/* Default Collapsed State: Number sits at the BOTTOM (Reference Style) */
.ehc-card:not(.ehc-card--expanded) .ehc-card-number,
.ehc-card .ehc-card-number {
    top: auto;
    bottom: var(--ehc-num-bottom, 24px);
    left: var(--ehc-num-left, 24px);
    right: auto;
}

/* Optional user placements for Collapsed State */
.ehc-num-collapsed-bottom_right .ehc-card:not(.ehc-card--expanded) .ehc-card-number {
    top: auto;
    bottom: var(--ehc-num-bottom, 24px);
    left: auto;
    right: var(--ehc-num-right, 24px);
}

.ehc-num-collapsed-top_right .ehc-card:not(.ehc-card--expanded) .ehc-card-number {
    top: var(--ehc-num-top, 24px);
    bottom: auto;
    left: auto;
    right: var(--ehc-num-right, 24px);
}

.ehc-num-collapsed-top_left .ehc-card:not(.ehc-card--expanded) .ehc-card-number {
    top: var(--ehc-num-top, 24px);
    bottom: auto;
    left: var(--ehc-num-left, 24px);
    right: auto;
}

/* Active / Hover Expanded State: Number moves to TOP-RIGHT! */
.ehc-card.ehc-card--expanded .ehc-card-number {
    top: var(--ehc-num-top, 24px);
    right: var(--ehc-num-right, 24px);
    bottom: auto;
    left: auto;
    color: var(--ehc-num-active-color, #ffffff);
}

/* Optional user placements for Active / Expanded State */
.ehc-num-expanded-top_left .ehc-card.ehc-card--expanded .ehc-card-number {
    top: var(--ehc-num-top, 24px);
    left: var(--ehc-num-left, 24px);
    bottom: auto;
    right: auto;
}

.ehc-num-expanded-bottom_right .ehc-card.ehc-card--expanded .ehc-card-number {
    top: auto;
    bottom: var(--ehc-num-bottom, 24px);
    right: var(--ehc-num-right, 24px);
    left: auto;
}

.ehc-num-expanded-bottom_left .ehc-card.ehc-card--expanded .ehc-card-number {
    top: auto;
    bottom: var(--ehc-num-bottom, 24px);
    left: var(--ehc-num-left, 24px);
    right: auto;
}

/* ==========================================================================
   7. Card Content Hierarchy
   ========================================================================== */
.ehc-card-content {
    position: relative;
    z-index: 4;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    width: 100%;
    height: 100%;
    padding: var(--ehc-card-padding, 24px);
    box-sizing: border-box;
}

/* Optimize padding on collapsed cards for maximum text breathing room */
.ehc-card:not(.ehc-card--expanded) .ehc-card-content {
    padding-left: clamp(14px, 1.2vw, 20px);
    padding-right: clamp(14px, 1.2vw, 20px);
}

.ehc-card-title-wrap {
    display: flex;
    flex-direction: column;
    width: 100%;
    padding-right: 0;
    box-sizing: border-box;
}

/* Expanded card gets right padding for top-right number */
.ehc-card.ehc-card--expanded .ehc-card-title-wrap {
    padding-right: 44px;
}

.ehc-card-title {
    margin: 0;
    padding: 0;
    font-family: inherit;
    font-size: var(--ehc-title-size, 22px);
    font-weight: 700;
    line-height: 1.22;
    color: var(--ehc-title-color, #ffffff);
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
    overflow-wrap: break-word;
    word-break: normal;
    hyphens: manual;
    max-width: 100%;
    transition:
        color var(--ehc-duration, 500ms) ease,
        font-size var(--ehc-duration, 500ms) ease;
}

/* On collapsed cards: scale font naturally to fit words seamlessly without breaking letters */
.ehc-card:not(.ehc-card--expanded) .ehc-card-title {
    font-size: clamp(15px, 1.15vw, 19px);
    line-height: 1.24;
}

.ehc-card.ehc-card--expanded .ehc-card-title {
    color: var(--ehc-title-active-color, #ffffff);
}

/* ==========================================================================
   8. Bottom Area: Description & Action Link
   ========================================================================== */
.ehc-card-bottom {
    margin-top: auto;
    display: flex;
    flex-direction: column;
    gap: 14px;
    width: 100%;
    box-sizing: border-box;
}

.ehc-card-description {
    font-family: inherit;
    font-size: var(--ehc-desc-size, 14.5px);
    font-weight: 400;
    line-height: 1.5;
    color: var(--ehc-desc-color, rgba(255, 255, 255, 0.88));
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
    opacity: 0;
    max-height: 0;
    overflow: hidden;
    transform: translateY(14px);
    pointer-events: none;
    transition:
        opacity var(--ehc-duration, 500ms) var(--ehc-easing, cubic-bezier(0.25, 1, 0.5, 1)),
        transform var(--ehc-duration, 500ms) var(--ehc-easing, cubic-bezier(0.25, 1, 0.5, 1)),
        max-height var(--ehc-duration, 500ms) var(--ehc-easing, cubic-bezier(0.25, 1, 0.5, 1));
}

.ehc-card-description p {
    margin: 0;
    padding: 0;
}

.ehc-card.ehc-card--expanded .ehc-card-description {
    opacity: 1;
    max-height: 250px;
    transform: translateY(0);
    pointer-events: auto;
}

/* Show description on collapsed cards setting */
.ehc-show-desc-collapsed .ehc-card .ehc-card-description {
    opacity: 0.85;
    max-height: 100px;
    transform: translateY(0);
}

/* Action Link */
.ehc-card-link {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    width: fit-content;
    font-family: inherit;
    font-size: var(--ehc-link-size, 14.5px);
    font-weight: 500;
    line-height: 1.4;
    color: var(--ehc-link-color, #ffffff);
    text-decoration: none;
    padding-bottom: 3px;
    border-bottom: 1px solid var(--ehc-link-border, rgba(255, 255, 255, 0.45));
    opacity: 0;
    transform: translateY(10px);
    pointer-events: none;
    box-sizing: border-box;
    transition:
        opacity var(--ehc-duration, 500ms) var(--ehc-easing, cubic-bezier(0.25, 1, 0.5, 1)),
        transform var(--ehc-duration, 500ms) var(--ehc-easing, cubic-bezier(0.25, 1, 0.5, 1)),
        color 0.25s ease,
        border-color 0.25s ease;
}

.ehc-card.ehc-card--expanded .ehc-card-link {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.ehc-card-link:hover,
.ehc-card-link:focus {
    color: var(--ehc-link-hover-color, #ffffff);
    border-bottom-color: var(--ehc-link-hover-border, #ffffff);
}

.ehc-card-link-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.05em;
    line-height: 1;
    transition: transform 0.25s ease;
}

.ehc-card-link:hover .ehc-card-link-icon {
    transform: translate(3px, -3px);
}

/* Whole card clickable helper */
.ehc-card-full-link {
    position: absolute;
    inset: 0;
    z-index: 6;
    opacity: 0;
    text-indent: -9999px;
}

/* ==========================================================================
   9. Tablet Responsive Grid (Max-Width: 1024px)
   ========================================================================== */
@media (max-width: 1024px) {
    .ehc-grid {
        display: grid;
        grid-template-columns: repeat(var(--ehc-tablet-cols, 3), minmax(0, 1fr));
        height: auto;
        min-height: auto;
        gap: var(--ehc-tablet-gap, 16px);
    }

    .ehc-card {
        flex: none !important;
        width: 100%;
        height: var(--ehc-tablet-height, 420px);
        cursor: pointer;
    }

    .ehc-card.ehc-card--expanded {
        flex-grow: 1 !important;
    }

    /* Tablet Hover Effects */
    .ehc-tablet-effect-card_lift .ehc-card:hover {
        transform: translateY(-6px);
        box-shadow: 0 16px 32px rgba(0, 0, 0, 0.25);
    }

    .ehc-tablet-effect-image_zoom .ehc-card:hover .ehc-card-bg {
        transform: scale(1.08);
    }

    /* Tablet Content Visibility */
    .ehc-card .ehc-card-description {
        opacity: 0.9;
        max-height: 150px;
        transform: translateY(0);
        pointer-events: auto;
    }

    .ehc-card .ehc-card-link {
        opacity: 1;
        transform: translateY(0);
        pointer-events: auto;
    }
}

/* Tablet 2 columns fallback if configured */
@media (max-width: 880px) and (min-width: 768px) {
    .ehc-tablet-cols-2 .ehc-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

/* ==========================================================================
   10. Mobile Responsive Stacked (Max-Width: 767px)
   ========================================================================== */
@media (max-width: 767px) {
    .ehc-grid {
        display: grid;
        grid-template-columns: repeat(var(--ehc-mobile-cols, 1), minmax(0, 1fr));
        height: auto;
        min-height: auto;
        gap: var(--ehc-mobile-gap, 14px);
    }

    .ehc-card {
        flex: none !important;
        width: 100%;
        height: var(--ehc-mobile-height, 380px);
        cursor: default;
        border-radius: calc(var(--ehc-border-radius, 16px) * 0.9);
    }

    .ehc-card-content {
        padding: 20px;
    }

    .ehc-card-title-wrap {
        padding-right: 32px;
    }

    .ehc-card-title {
        font-size: 20px;
    }

    .ehc-card-number {
        top: 20px;
        right: 20px;
        font-size: 13px;
    }

    /* Mobile Content Visibility System */
    .ehc-mobile-content-always_show .ehc-card .ehc-card-description,
    .ehc-card .ehc-card-description {
        opacity: 1;
        max-height: 200px;
        transform: translateY(0);
        pointer-events: auto;
        font-size: 14px;
    }

    .ehc-mobile-content-always_show .ehc-card .ehc-card-link,
    .ehc-card .ehc-card-link {
        opacity: 1;
        transform: translateY(0);
        pointer-events: auto;
        font-size: 14px;
    }

    .ehc-mobile-content-hide_desc .ehc-card .ehc-card-description {
        display: none;
    }
}

/* ==========================================================================
   11. Reduced Motion Preference
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
    .ehc-card,
    .ehc-card-bg,
    .ehc-card-overlay,
    .ehc-card-content,
    .ehc-card-title,
    .ehc-card-number,
    .ehc-card-description,
    .ehc-card-link,
    .ehc-card-link-icon {
        transition: none !important;
        animation: none !important;
    }
}
