/* Stacking Cards Animation - Horizontal Fan Out */

/* Section Container */
.why-cards-section {
    position: relative;
    background: linear-gradient(135deg, #1a1f36 0%, #242635 100%);
    padding: 100px 0;
    min-height: 100vh;
    overflow: hidden;
}

.why-cards-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 24px;
}

/* Header */
.why-cards-header {
    text-align: center;
    margin-bottom: 80px;
}

.why-cards-subtitle {
    color: #336DFF;
    font-size: 16px;
    font-weight: 600;
    letter-spacing: 1px;
    text-transform: uppercase;
    margin-bottom: 16px;
}

.why-cards-title {
    color: #ffffff;
    font-size: clamp(28px, 4vw, 42px);
    font-weight: 700;
    line-height: 1.2;
    margin: 0;
}

/* Cards Stack Container - Stacking Animation */
.cards-stack {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 500px;
    perspective: 1500px;
}

/* Individual Card - Stacked by default (desktop) */
.stack-card {
    position: absolute;
    width: 380px;
    height: 420px;
    transition: transform 0.8s cubic-bezier(0.23, 1, 0.32, 1),
                box-shadow 0.3s ease,
                opacity 0.5s ease;
    perspective: 1000px;
    /* Start stacked in center */
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
}

/* Stacked state - cards slightly offset for depth effect */
.stack-card[data-index="0"] {
    transform: translate(-50%, -50%) rotate(-2deg);
    z-index: 3;
}
.stack-card[data-index="1"] {
    transform: translate(-50%, -50%) rotate(0deg) translateY(8px);
    z-index: 2;
}
.stack-card[data-index="2"] {
    transform: translate(-50%, -50%) rotate(2deg) translateY(16px);
    z-index: 1;
}

/* Fanned out state - spread horizontally */
.cards-stack.fanned .stack-card[data-index="0"] {
    transform: translate(-170%, -50%) rotate(0deg);
    z-index: 1;
}
.cards-stack.fanned .stack-card[data-index="1"] {
    transform: translate(-50%, -50%) rotate(0deg);
    z-index: 2;
}
.cards-stack.fanned .stack-card[data-index="2"] {
    transform: translate(70%, -50%) rotate(0deg);
    z-index: 3;
}

/* Card Flipper - 3D Container */
.card-flipper {
    position: relative;
    width: 100%;
    height: 100%;
    transform-style: preserve-3d;
    transition: transform 0.6s cubic-bezier(0.23, 1, 0.32, 1);
}

/* Flip on hover */
.stack-card:hover .card-flipper {
    transform: rotateY(180deg);
}

/* Card Faces - Front and Back */
.card-front,
.card-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    background: #ffffff;
    border-radius: 20px;
    padding: 48px 40px 40px; /* Increased padding - more top padding for accent line */
    box-shadow: 0 25px 80px rgba(0, 0, 0, 0.4);
    box-sizing: border-box;
}

/* Front Face */
.card-front {
    z-index: 2;
}

/* Back Face - Rotated */
.card-back {
    transform: rotateY(180deg);
    background: linear-gradient(135deg, #336DFF 0%, #1a4fd6 100%);
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 40px;
    overflow-y: auto; /* Allow scroll if content overflows */
}

.card-back .stack-card-inner {
    color: #ffffff;
    height: auto;
    max-height: 100%;
}

.card-back .stack-card-icon {
    background: rgba(255, 255, 255, 0.2);
    width: 56px;
    height: 56px;
    margin-bottom: 16px;
}

.card-back .stack-card-icon svg {
    width: 28px;
    height: 28px;
}

.card-back .stack-card-title {
    color: #ffffff;
    font-size: 22px;
    margin-bottom: 12px;
}

.card-back .stack-card-content {
    flex: 0 1 auto;
}

.card-back .stack-card-detail {
    color: rgba(255, 255, 255, 0.95);
    font-size: 14px;
    line-height: 1.7;
    margin: 0 0 20px;
    padding: 0 4px;
    max-height: none; /* Allow full content display */
}

/* Extended content section for back of card */
.card-back .stack-card-extended {
    color: rgba(255, 255, 255, 0.85);
    font-size: 13px;
    line-height: 1.65;
    margin: 0 0 20px;
    padding-top: 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.2);
}

.card-back .card-cta {
    display: inline-block;
    background: #ffffff;
    color: #336DFF;
    font-size: 14px;
    font-weight: 600;
    padding: 12px 28px;
    border-radius: 30px;
    text-decoration: none;
    transition: all 0.3s ease;
    margin-top: auto;
    flex-shrink: 0;
}

.card-back .card-cta:hover {
    background: #f0f4ff;
    transform: scale(1.05);
}

/* Flip Hint */
.flip-hint {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 12px;
    color: #999;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.stack-card:hover .flip-hint {
    opacity: 1;
}

/* Hover effect - lift card */
.stack-card:hover {
    transform: translateY(-8px);
    z-index: 10;
}

.stack-card:hover .card-front {
    box-shadow: 0 30px 60px rgba(0, 0, 0, 0.35);
}

/* Card Content Layout */
.stack-card-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    height: 100%;
}

.stack-card-icon {
    width: 64px;
    height: 64px;
    background: linear-gradient(135deg, #336DFF 0%, #1a4fd6 100%);
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 20px;
    flex-shrink: 0;
}

.stack-card-icon svg {
    width: 32px;
    height: 32px;
    color: #ffffff;
}

.stack-card-content {
    width: 100%;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.stack-card-label {
    display: inline-block;
    background: rgba(51, 109, 255, 0.1);
    color: #336DFF;
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    padding: 8px 20px;
    border-radius: 20px;
    margin-bottom: 20px;
}

.stack-card-title {
    color: #ffffff;
    font-size: 24px;
    font-weight: 700;
    margin: 0 0 16px;
    line-height: 1.25;
}

/* Hide duplicate title on front card */
.card-front .stack-card-title,
.card-front .stack-card-inner .stack-card-title {
    display: none !important;
}

.stack-card-text {
    color: #333333;
    font-size: 15px;
    line-height: 1.5;
    margin: 0;
    padding: 0;
    text-align: center;
    display: -webkit-box !important;
    -webkit-line-clamp: 3 !important;
    -webkit-box-orient: vertical !important;
    overflow: hidden !important;
    max-height: 4.5em !important; /* 3 lines × 1.5 line-height */
    text-overflow: ellipsis;
}

/* Bold text within card descriptions */
.stack-card-text strong {
    color: #222222;
    font-weight: 600;
}

/* Back card text stays white on blue background */
.card-back .stack-card-text {
    color: rgba(255, 255, 255, 0.95);
}

.card-back .stack-card-text strong {
    color: #ffffff;
}

/* Card Number Badge */
.stack-card-number {
    position: absolute;
    top: 24px;
    right: 28px;
    font-size: 48px;
    font-weight: 800;
    color: rgba(51, 109, 255, 0.08);
    line-height: 1;
    z-index: 1;
}

/* Card Accent Line - Front Face */
.card-front::before {
    content: '';
    position: absolute;
    top: 0;
    left: 24px;
    right: 24px;
    height: 4px;
    background: linear-gradient(90deg, #336DFF 0%, #1a4fd6 100%);
    border-radius: 2px 2px 0 0;
}

/* Card Accent Line - Back Face */
.card-back::before {
    content: '';
    position: absolute;
    top: 0;
    left: 24px;
    right: 24px;
    height: 4px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 2px 2px 0 0;
}

/* Decorative Background Element */
.why-cards-section::after {
    content: '';
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 200px;
    height: 400px;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 200'%3E%3Cpath d='M20 0 L100 0 L100 200 L20 200 Z' fill='none' stroke='%23336DFF' stroke-width='2' opacity='0.2'/%3E%3Cpath d='M40 20 L100 20 L100 180 L40 180 Z' fill='none' stroke='%23336DFF' stroke-width='2' opacity='0.15'/%3E%3Cpath d='M60 40 L100 40 L100 160 L60 160 Z' fill='none' stroke='%23336DFF' stroke-width='2' opacity='0.1'/%3E%3C/svg%3E") no-repeat;
    background-size: contain;
    pointer-events: none;
    opacity: 0.5;
}

/* Spacer */
.cards-stack-spacer {
    height: 100px;
}

/* Responsive - Tablet */
@media (max-width: 1200px) {
    .stack-card {
        width: 340px;
        height: 400px;
    }

    .card-front,
    .card-back {
        padding: 40px 32px 36px;
    }

    .stack-card-title {
        font-size: 22px;
    }

    .stack-card-text {
        font-size: 14px;
        line-height: 1.7;
    }

    .cards-stack {
        gap: 20px;
    }
}

/* ============================================
   MOBILE LAYOUT - COMPLETE RESET FROM SCRATCH
   Breakpoint: 900px and below
   ============================================ */
@media screen and (max-width: 900px) {

    /* Section reset */
    .why-cards-section {
        padding: 50px 0 60px !important;
        min-height: auto !important;
        overflow: visible !important;
    }

    .why-cards-section::after {
        display: none !important;
    }

    .why-cards-container {
        padding: 0 16px !important;
        max-width: 100% !important;
        width: 100% !important;
        display: block !important;
        text-align: center !important;
    }

    .why-cards-header {
        margin-bottom: 32px !important;
    }

    .why-cards-title {
        font-size: 24px !important;
        line-height: 1.3 !important;
    }

    /* CARDS CONTAINER - Centered block layout */
    .cards-stack {
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        justify-content: flex-start !important;
        position: relative !important;
        min-height: 0 !important;
        height: auto !important;
        perspective: none !important;
        transform: none !important;
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 auto !important;
        padding: 0 !important;
    }

    .cards-stack.fanned {
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        justify-content: flex-start !important;
        position: relative !important;
        min-height: 0 !important;
        height: auto !important;
        perspective: none !important;
        transform: none !important;
        width: 100% !important;
        max-width: 100% !important;
    }

    /* EACH CARD - Flex children, centered by parent */
    .stack-card {
        display: block !important;
        position: relative !important;
        width: calc(100% - 32px) !important;
        max-width: 340px !important;
        height: auto !important;
        min-height: 220px !important;
        margin: 0 auto 20px auto !important;
        padding: 0 !important;
        left: auto !important;
        right: auto !important;
        top: auto !important;
        bottom: auto !important;
        transform: none !important;
        -webkit-transform: none !important;
        perspective: 1000px !important;
        -webkit-perspective: 1000px !important;
        z-index: auto !important;
        transition: none !important;
        flex-shrink: 0 !important;
        cursor: pointer !important;
    }

    /* Override ALL data-index variations */
    .stack-card[data-index="0"],
    .stack-card[data-index="1"],
    .stack-card[data-index="2"],
    .stack-card[data-index="3"],
    .stack-card[data-index="4"] {
        display: block !important;
        position: relative !important;
        width: calc(100% - 32px) !important;
        max-width: 340px !important;
        height: auto !important;
        min-height: 220px !important;
        margin: 0 auto 20px auto !important;
        left: auto !important;
        right: auto !important;
        top: auto !important;
        bottom: auto !important;
        transform: none !important;
        -webkit-transform: none !important;
        perspective: 1000px !important;
        -webkit-perspective: 1000px !important;
        z-index: auto !important;
        flex-shrink: 0 !important;
        cursor: pointer !important;
    }

    /* Override fanned state completely */
    .cards-stack.fanned .stack-card,
    .cards-stack.fanned .stack-card[data-index="0"],
    .cards-stack.fanned .stack-card[data-index="1"],
    .cards-stack.fanned .stack-card[data-index="2"] {
        display: block !important;
        position: relative !important;
        width: calc(100% - 32px) !important;
        max-width: 340px !important;
        height: auto !important;
        min-height: 220px !important;
        margin: 0 auto 20px auto !important;
        left: auto !important;
        right: auto !important;
        top: auto !important;
        bottom: auto !important;
        transform: none !important;
        -webkit-transform: none !important;
        perspective: 1000px !important;
        -webkit-perspective: 1000px !important;
        z-index: auto !important;
        flex-shrink: 0 !important;
        cursor: pointer !important;
    }

    /* Last card - no bottom margin */
    .stack-card:last-child {
        margin-bottom: 0 !important;
    }

    /* CARD FLIPPER - Simple container (no 3D on mobile) */
    .card-flipper {
        display: block !important;
        position: relative !important;
        width: 100% !important;
        height: auto !important;
        min-height: 220px !important;
        /* NO 3D transforms - simple show/hide on mobile */
        transform: none !important;
        -webkit-transform: none !important;
        transform-style: flat !important;
        -webkit-transform-style: flat !important;
    }

    /* Disable hover flip on mobile */
    .stack-card:hover .card-flipper {
        transform: none !important;
        -webkit-transform: none !important;
    }

    /* FRONT CARD - Visible by default */
    .card-front {
        display: block !important;
        position: relative !important;
        width: 100% !important;
        height: auto !important;
        min-height: 220px !important;
        padding: 25px !important;
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15) !important;
        /* NO 3D transforms */
        transform: none !important;
        -webkit-transform: none !important;
        backface-visibility: visible !important;
        -webkit-backface-visibility: visible !important;
        pointer-events: auto !important;
        -webkit-tap-highlight-color: transparent !important;
        cursor: pointer !important;
    }

    /* BACK CARD - HIDDEN by default */
    .card-back {
        display: none !important;
        position: relative !important;
        width: 100% !important;
        height: auto !important;
        min-height: 220px !important;
        padding: 25px !important;
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15) !important;
        /* NO 3D transforms */
        transform: none !important;
        -webkit-transform: none !important;
        backface-visibility: visible !important;
        -webkit-backface-visibility: visible !important;
        pointer-events: auto !important;
        -webkit-tap-highlight-color: transparent !important;
        cursor: pointer !important;
    }

    /* FLIPPED STATE - When .stack-card has .is-flipped class */
    .stack-card.is-flipped .card-front {
        display: none !important;
    }

    .stack-card.is-flipped .card-back {
        display: block !important;
    }

    /* Card inner content */
    .stack-card-inner {
        height: auto !important;
        min-height: 0 !important;
    }

    .stack-card-text {
        font-size: 14px !important;
        line-height: 1.6 !important;
        -webkit-line-clamp: unset !important;
        max-height: none !important;
        overflow: visible !important;
        display: block !important;
    }

    /* HIDE flip hint completely on mobile - not relevant for tap */
    .flip-hint {
        display: none !important;
        visibility: hidden !important;
    }

    .stack-card-number {
        font-size: 40px !important;
        top: 12px !important;
        right: 16px !important;
    }

    .stack-card-label {
        font-size: 13px !important;
        padding: 6px 16px !important;
        margin-bottom: 12px !important;
    }

    .stack-card-icon {
        width: 52px !important;
        height: 52px !important;
        margin-bottom: 12px !important;
    }

    .stack-card-icon svg {
        width: 26px !important;
        height: 26px !important;
    }

    .cards-stack-spacer {
        display: none !important;
        height: 0 !important;
    }

    /* Disable hover effects on mobile */
    .stack-card:hover {
        transform: none !important;
        -webkit-transform: none !important;
        z-index: auto !important;
    }

    .stack-card:hover .card-front {
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15) !important;
    }
}
