/* MessageDeck Cards - Enhanced CSS with Hover Flip and Deselect */
/* Add this to your global stylesheet */

.deck-container {
    max-width: 1200px;
    margin: 0 auto;
}

.category-section {
    margin-bottom: 60px;
}

.category-title {
    text-align: center;
    color: #333;
    font-size: 2.5rem;
    font-weight: 300;
    margin-bottom: 40px;
}

.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 30px;
    justify-items: center;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Desktop and Tablet: Prefer 3 columns but allow flexibility */
@media (min-width: 769px) {
    .cards-grid {
        grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
        max-width: 1200px;
        margin: 0 auto;
        padding: 0 40px;
    }
    
    /* Ensure cards don't get too wide when there are fewer than 3 */
    .card {
        max-width: 360px;
    }
}

/* Card Container */
.card {
    width: 320px;
    height: 240px;
    perspective: 1000px;
    cursor: pointer;
    transition: transform 0.3s ease;
}

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

.card.selected {
    transform: translateY(-10px) scale(1.05);
}

/* NEW: Hover flip behavior - only applies to cards with hover-flip class */
.card.hover-flip:hover:not(.selected) {
    transform: translateY(-10px);
}

/* Card Inner Container - Critical for flipping */
.card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    transition: transform 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.3s ease;
    transform-style: preserve-3d !important;
    border-radius: 16px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    transform: rotateY(0deg);
    z-index: 1; /* Ensure card content is above shadows */
}

/* Flipped state - force the transform */
.card.flipped .card-inner {
    transform: rotateY(180deg) !important;
}

/* NEW: Hover flipped state - only when hovering and not selected */
.card.hover-flip.hover-flipped:not(.selected) .card-inner {
    transform: rotateY(180deg) !important;
}

/* NEW: Selected cards with hover-flip should stay flipped even on hover out */
.card.hover-flip.selected .card-inner {
    transform: rotateY(180deg) !important;
}

/* Card Faces */
.card-face {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden !important;
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    padding: clamp(15px, 4vw, 30px);
    color: white;
    overflow: hidden;
    box-sizing: border-box;
}

.card-front {
    background: white;
    color: black;
    border: 10px solid #824C71; /* Default color, will be overridden */
    transform: rotateY(180deg) !important;
}

.card-back {
    border: 3px solid rgba(255,255,255,0.2);
    transform: rotateY(0deg) !important;
    position: relative;
}

/* Thin white inset border on card backs */
.card-back::before {
    content: '';
    position: absolute;
    top: 10px;
    left: 10px;
    right: 10px;
    bottom: 10px;
    border: 5px solid rgba(255,255,255,0.6); /* Increased opacity from 0.3 to 0.6 */
    border-radius: 6px; /* Matches the card corner radius minus the inset */
    pointer-events: none;
    z-index: 2; /* Ensure it appears above the background gradient */
}

/* Black elements for light-colored card backs (Focus, Mantras, Proof Points) */
.category-focus .card-back .card-title,
.category-mantras .card-back .card-title,
.category-proofpoints .card-back .card-title {
    color: black;
    z-index: 3; /* Ensure text appears above the border */
    position: relative;
}

.category-focus .card-back .card-logo,
.category-mantras .card-back .card-logo,
.category-proofpoints .card-back .card-logo {
    color: black;
    z-index: 3; /* Ensure logo appears above the border */
    position: relative;
}

.category-focus .card-back .card-logo svg,
.category-mantras .card-back .card-logo svg,
.category-proofpoints .card-back .card-logo svg {
    fill: black !important; /* Force black fill even if SVG has inline fill attributes */
}

.category-focus .card-back .card-logo svg path,
.category-mantras .card-back .card-logo svg path,
.category-proofpoints .card-back .card-logo svg path {
    fill: black !important; /* Target individual path elements within the SVG */
}

.category-focus .card-back .card-logo svg g,
.category-mantras .card-back .card-logo svg g,
.category-proofpoints .card-back .card-logo svg g {
    fill: black !important; /* Target group elements within the SVG */
}

.category-focus .card-back::before,
.category-mantras .card-back::before,
.category-proofpoints .card-back::before {
    border-color: rgba(0,0,0,0.6); /* Increased opacity from 0.3 to 0.6 */
    z-index: 2;
}

/* Category-specific colors for borders and backgrounds */
.category-ideas .card-front {
    border-color: #824C71;
}
.category-ideas .card-back {
    background: linear-gradient(135deg, #824C71 0%, #9d5c86 100%);
}

.category-stories .card-front {
    border-color: #124E78;
}
.category-stories .card-back {
    background: linear-gradient(135deg, #124E78 0%, #1a6298 100%);
}

.category-values .card-front {
    border-color: #55BA55;
}
.category-values .card-back {
    background: linear-gradient(135deg, #55BA55 0%, #6bc46b 100%);
}

.category-mantras .card-front {
    border-color: #F3C969;
}
.category-mantras .card-back {
    background: linear-gradient(135deg, #F3C969 0%, #f5d389 100%);
}

.category-proofpoints .card-front {
    border-color: #F08838;
}
.category-proofpoints .card-back {
    background: linear-gradient(135deg, #F08838 0%, #f29c58 100%);
}

.category-technicals .card-front {
    border-color: #EF6461;
}
.category-technicals .card-back {
    background: linear-gradient(135deg, #EF6461 0%, #f28481 100%);
}

/* NEW: Focus category colors - corrected to cream/beige */
.category-focus .card-front {
    border-color: #E0DFD5;
}
.category-focus .card-back {
    background: linear-gradient(135deg, #E0DFD5 0%, #E8E7DD 100%);
}

/* Card Content */
.card-title {
    font-family: 'Work Sans', sans-serif;
    font-size: clamp(1.2rem, 4vw, 1.8rem);
    font-weight: 600;
    margin-bottom: 15px;
    text-shadow: 0 2px 4px rgba(0,0,0,0.3);
    line-height: 1.2;
    word-wrap: break-word;
    hyphens: auto;
}

/* Remove text shadow from card back titles */
.card-back .card-title {
    text-shadow: none;
}

.card-question {
    font-family: 'Work Sans', sans-serif;
    font-weight: 500;
    font-size: clamp(0.8rem, 2.5vw, 1rem);
    line-height: 1.3;
    color: black;
    word-wrap: break-word;
    hyphens: auto;
    overflow-wrap: break-word;
}

.card-front .card-title {
    color: black;
    text-shadow: none;
    margin-bottom: 15px;
    text-align: center;
}

.card-objectives {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-bottom: 20px;
}

.objective-icon {
    width: 24px;
    height: 24px;
    transition: opacity 0.3s ease;
}

/* Logo styling for card backs */
.card-logo {
    position: absolute;
    bottom: 20px; /* 10px from card edge + 10px inset = 20px from bottom */
    left: 50%;
    transform: translateX(-50%);
    opacity: 0.8;
    z-index: 3;
}

/* Ensure Focus, Mantras, and Proof Points cards use the same logo positioning and hide any other logos */
.category-focus .card-back .card-logo,
.category-mantras .card-back .card-logo,
.category-proofpoints .card-back .card-logo {
    position: absolute !important;
    bottom: 20px !important;
    left: 50% !important;
    right: auto !important;
    top: auto !important;
    transform: translateX(-50%) !important;
    opacity: 0.8;
    z-index: 3;
}

/* Hide any other logo elements that might appear on these card backs */
.category-focus .card-back .objective-icon,
.category-focus .card-back .card-objectives,
.category-mantras .card-back .objective-icon,
.category-mantras .card-back .card-objectives,
.category-proofpoints .card-back .objective-icon,
.category-proofpoints .card-back .card-objectives {
    display: none !important;
}

/* Ensure the MessageSpecs logo is visible on these cards */
.category-focus .card-back .card-logo svg,
.category-mantras .card-back .card-logo svg,
.category-proofpoints .card-back .card-logo svg {
    display: block !important;
    max-width: 100px;
    height: auto;
}

.card-logo svg {
    max-width: 100px;
    height: auto;
}

/* Selection indicator */
.card.selected .card-inner::after {
    content: '';
    position: absolute;
    top: -5px;
    left: -5px;
    right: -5px;
    bottom: -5px;
    border: 3px solid #ffd700;
    border-radius: 20px;
    pointer-events: none;
    animation: pulse 2s infinite;
    z-index: 10;
}

@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(255, 215, 0, 0.7); }
    70% { box-shadow: 0 0 0 10px rgba(255, 215, 0, 0); }
    100% { box-shadow: 0 0 0 0 rgba(255, 215, 0, 0); }
}

/* NEW: Visual indicator for deselectable cards */
.card.selected.deselectable {
    position: relative;
}

.card.selected.deselectable::before {
    content: '✕';
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(255, 0, 0, 0.8);
    color: white;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: bold;
    z-index: 15;
    transition: background 0.3s ease;
}

.card.selected.deselectable:hover::before {
    background: rgba(255, 0, 0, 1);
}

/* NEW: Hover feedback for hover-flip cards */
.card.hover-flip:not(.selected) {
    transition: transform 0.3s ease;
    position: relative;
    z-index: 0; /* Keep card container at base level */
}

.card.hover-flip:hover:not(.selected) {
    /* Remove box-shadow from here to prevent layering issues */
}

/* Apply enhanced shadow to the card-inner on hover instead */
.card.hover-flip:hover:not(.selected) .card-inner {
    box-shadow: 0 15px 40px rgba(0,0,0,0.4);
    /* Remove the conflicting transition - let the original flip transition handle it */
}

/* Mobile responsive - Cards stack with 80vh width */
@media (max-width: 768px) {
    .cards-grid {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 20px;
        padding: 0 10px;
    }
    
    .card {
        width: 80vw; /* 80% of viewport width as requested */
        height: calc(80vw * 0.65); /* Maintain aspect ratio */
        max-width: 400px; /* Prevent cards from getting too large on wide mobile screens */
        margin-bottom: 20px;
    }

    .card-title {
        font-size: clamp(1rem, 5vw, 1.4rem);
        margin-bottom: 10px;
    }

    .card-question {
        font-size: clamp(0.75rem, 3.5vw, 0.9rem);
        line-height: 1.25;
    }

    .card-face {
        padding: clamp(12px, 3vw, 20px);
    }

    /* Mobile deselect indicator */
    .card.selected.deselectable::before {
        width: 28px;
        height: 28px;
        font-size: 16px;
        top: 15px;
        right: 15px;
    }
}

@media (max-width: 480px) {
    .card {
        width: 90vw;
        height: calc(90vw * 0.65);
        margin-bottom: 60px;
    }
    
    .cards-container {
        gap: 10px;
        padding: 0 5% 30px 5%;
    }

    .card-title {
        font-size: clamp(0.9rem, 4.5vw, 1.2rem);
        line-height: 1.1;
    }

    .card-question {
        font-size: clamp(0.7rem, 3vw, 0.85rem);
        line-height: 1.2;
    }
}

@media (max-width: 360px) {
    .card {
        width: 90vw;
        height: calc(90vw * 0.65);
        margin-bottom: 65px;
    }

    .card-face {
        padding: 10px;
    }

    .card-title {
        font-size: clamp(0.8rem, 4vw, 1rem);
        margin-bottom: 8px;
    }

    .card-question {
        font-size: clamp(0.65rem, 2.8vw, 0.8rem);
    }
}

/* Large desktop screens */
@media (min-width: 1400px) {
    .card {
        width: 358px;
        height: 256px;
    }
}

/* Loading and error states */
.deck-loading, .deck-error {
    text-align: center;
    padding: 40px;
    font-family: 'Work Sans', sans-serif;
    font-size: 1.2rem;
    color: #666;
}

.deck-error {
    color: #d32f2f;
    background: #ffebee;
    border: 1px solid #f8bbd9;
    border-radius: 8px;
}