/* ===================================
   CARD GALLERY OVERLAY
   Trading Card Collection Experience
   =================================== */

/* Overlay Container */
.card-gallery-overlay {
    position: fixed;
    inset: 0;
    z-index: 10000;
    background-color: #FAF8F5;
    background-image: url('images/haus_of_toots_canvas_13ct_512px.png');
    background-repeat: repeat;
    background-size: 512px 500px;
    display: flex;
    flex-direction: column;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.4s ease, visibility 0.4s ease;
    overflow: hidden;
}

/* Vignette overlay - fixed to viewport */
.card-gallery-overlay::before {
    content: '';
    position: fixed;
    inset: 0;
    background: radial-gradient(
        ellipse at center,
        transparent 0%,
        transparent 30%,
        rgba(26, 22, 20, 0.15) 60%,
        rgba(26, 22, 20, 0.4) 80%,
        rgba(26, 22, 20, 0.7) 100%
    );
    pointer-events: none;
    z-index: 1;
}

/* Additional ambient shadow layer - fixed to viewport */
.card-gallery-overlay::after {
    content: '';
    position: fixed;
    inset: 0;
    background: 
        linear-gradient(180deg, rgba(26, 22, 20, 0.3) 0%, transparent 15%),
        linear-gradient(0deg, rgba(26, 22, 20, 0.4) 0%, transparent 20%);
    pointer-events: none;
    z-index: 1;
}

.card-gallery-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* Header */
.card-gallery-header {
    position: relative;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 2rem;
    background: rgba(45, 40, 37, 0.85);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(255, 107, 122, 0.3);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

.card-gallery-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.card-gallery-logo {
    width: 40px;
    height: auto;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
}

.card-gallery-title {
    font-family: 'Chewy', cursive;
    font-size: 1.75rem;
    color: #FF8497;
    letter-spacing: 1px;
    margin: 0;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

@media (max-width: 640px) {
    .card-gallery-logo {
        width: 32px;
    }
    
    .card-gallery-title {
        font-size: 1.25rem;
    }
}

.card-gallery-close {
    width: 48px;
    height: 48px;
    border: none;
    background: rgba(255, 107, 122, 0.2);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    color: #FF8497;
}

.card-gallery-close:hover {
    background: #FF6B7A;
    color: white;
    transform: scale(1.1) rotate(90deg);
    box-shadow: 0 4px 20px rgba(255, 107, 122, 0.5);
}

.card-gallery-close svg {
    width: 24px;
    height: 24px;
}

/* Category Tabs (Deck Selector) */
.card-gallery-tabs {
    display: flex;
    gap: 0.5rem;
    padding: 1rem 2rem;
    justify-content: center;
    flex-wrap: wrap;
    position: relative;
    z-index: 10;
    background: rgba(45, 40, 37, 0.6);
    backdrop-filter: blur(8px);
}

.card-deck-tab {
    padding: 0.5rem 1.25rem;
    border: 2px solid rgba(255, 179, 186, 0.3);
    background: rgba(255, 107, 122, 0.1);
    border-radius: 25px;
    font-family: 'Winky Sans', sans-serif;
    font-size: 0.875rem;
    font-weight: 600;
    color: #FF8497;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    position: relative;
    overflow: hidden;
}

/* Category-specific tab colors */
.card-deck-tab[data-color="#FFB7C2"] {
    border-color: rgba(255, 183, 194, 0.3);
    background: rgba(255, 183, 194, 0.1);
    color: #FFB7C2;
}

.card-deck-tab[data-color="#FFB7C2"]:hover {
    border-color: #FFB7C2;
    background: rgba(255, 183, 194, 0.2);
}

.card-deck-tab[data-color="#FFB7C2"].active {
    background: linear-gradient(135deg, #FFB7C2 0%, #FF8497 100%);
    border-color: #FFB7C2;
}

.card-deck-tab[data-color="#D97EAE"] {
    border-color: rgba(217, 126, 174, 0.3);
    background: rgba(217, 126, 174, 0.1);
    color: #D97EAE;
}

.card-deck-tab[data-color="#D97EAE"]:hover {
    border-color: #D97EAE;
    background: rgba(217, 126, 174, 0.2);
}

.card-deck-tab[data-color="#D97EAE"].active {
    background: linear-gradient(135deg, #D97EAE 0%, #C06A9A 100%);
    border-color: #D97EAE;
}

.card-deck-tab[data-color="#F74560"] {
    border-color: rgba(247, 69, 96, 0.3);
    background: rgba(247, 69, 96, 0.1);
    color: #F74560;
}

.card-deck-tab[data-color="#F74560"]:hover {
    border-color: #F74560;
    background: rgba(247, 69, 96, 0.2);
}

.card-deck-tab[data-color="#F74560"].active {
    background: linear-gradient(135deg, #F74560 0%, #E02E4A 100%);
    border-color: #F74560;
}

.card-deck-tab[data-color="#F06F51"] {
    border-color: rgba(240, 111, 81, 0.3);
    background: rgba(240, 111, 81, 0.1);
    color: #F06F51;
}

.card-deck-tab[data-color="#F06F51"]:hover {
    border-color: #F06F51;
    background: rgba(240, 111, 81, 0.2);
}

.card-deck-tab[data-color="#F06F51"].active {
    background: linear-gradient(135deg, #F06F51 0%, #E85A3A 100%);
    border-color: #F06F51;
}

.card-deck-tab::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, transparent 0%, rgba(255, 255, 255, 0.1) 50%, transparent 100%);
    transform: translateX(-100%);
    transition: transform 0.5s ease;
}

.card-deck-tab:hover::before {
    transform: translateX(100%);
}

.card-deck-tab:hover {
    border-color: #FF6B7A;
    background: rgba(255, 107, 122, 0.2);
    transform: translateY(-2px);
}

.card-deck-tab.active {
    background: linear-gradient(135deg, #FF6B7A 0%, #E85563 100%);
    border-color: #FF6B7A;
    color: white;
    box-shadow: 0 4px 15px rgba(255, 107, 122, 0.4);
}

.card-deck-tab .tab-count {
    display: inline-block;
    margin-left: 0.5rem;
    padding: 0.125rem 0.5rem;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 10px;
    font-size: 0.75rem;
}

/* Main Card Area */
.card-gallery-main {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    -webkit-perspective: 1500px;
    perspective: 1500px;
    padding: 2rem;
    overflow: visible;
    z-index: 5;
}

/* Card Stack Container - Playing card aspect ratio (wider) */
.card-stack {
    position: relative;
    width: 480px;
    height: 560px; /* Wider aspect ratio for playing card feel */
    -webkit-transform-style: preserve-3d;
    transform-style: preserve-3d;
}

/* Larger cards on big screens */
@media (min-width: 1200px) {
    .card-stack {
        width: 530px;
        height: 620px;
    }
}

@media (min-width: 1400px) {
    .card-stack {
        width: 575px;
        height: 670px;
    }
}

@media (max-width: 768px) {
    .card-stack {
        width: 100%;
        max-width: 420px;
        height: 520px;
    }
}

/* ========================================
   MOBILE PEEK LAYOUT (show adjacent cards)
   ======================================== */
@media (max-width: 1023px) {
    .card-gallery-wrapper {
        overflow: visible;
    }
    
    .card-stage {
        overflow: visible;
    }
    
    .card-stack {
        overflow: visible;
    }
    
    /* Active card slightly scaled up on mobile */
    .gallery-card.active {
        transform: scale(1.02) !important;
    }
    
    /* Adjacent cards peeking from sides */
    .gallery-card.stack-1 {
        transform: translateX(85%) rotate(6deg) scale(0.85) !important;
        filter: brightness(0.7);
        z-index: 8 !important;
    }
    
    .gallery-card.stack-2 {
        transform: translateX(115%) rotate(10deg) scale(0.75) !important;
        filter: brightness(0.5);
        z-index: 7 !important;
    }
    
    .gallery-card.stack-prev-1 {
        transform: translateX(-85%) rotate(-6deg) scale(0.85) !important;
        filter: brightness(0.7);
        z-index: 8 !important;
    }
    
    .gallery-card.stack-prev-2 {
        transform: translateX(-115%) rotate(-10deg) scale(0.75) !important;
        filter: brightness(0.5);
        z-index: 7 !important;
    }
}

/* ========================================
   MASONRY GRID LAYOUT FOR DESKTOP (1024px+)
   ======================================== */
@media (min-width: 1024px) {
    /* Allow scrolling in masonry mode */
    .card-gallery-overlay.masonry-mode {
        overflow-y: auto;
    }

    /* In masonry mode, let the main area stretch full height.
       Then the grid can center itself when content is short. */
    .card-gallery-overlay.masonry-mode .card-gallery-main {
        align-items: stretch;
    }
    
    /* Expand card stage to full width for masonry */
    .card-gallery-overlay.masonry-mode .card-stage {
        width: 100%;
        max-width: none;
        padding: 1rem 2rem 2rem;
        min-height: calc(100vh - 120px);
        height: auto;
        overflow: visible;
        /* Remove 3D perspective for flat grid */
        perspective: none;
        -webkit-perspective: none;
        transform-style: flat;
    }
    
    /* Make card stack a masonry grid container */
    .card-gallery-overlay.masonry-mode .card-stack {
        width: 100%;
        max-width: 1400px;
        height: auto;
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(200px, max-content));
        grid-auto-flow: row;
        column-gap: 1.75rem;
        row-gap: 2.5rem;
        padding: 2rem;
        margin: 0 auto;
        position: relative;
        /* Remove 3D transforms for flat grid */
        transform: none;
        perspective: none;
        transform-style: flat;
        /* Ensure proper wrapping */
        overflow-wrap: break-word;
        word-wrap: break-word;

        /* Center rows/columns when there isn't enough content to fill the viewport */
        min-height: 100%;
        align-content: center;
        justify-content: center;
    }
    
    /* Cards in masonry grid */
    .card-gallery-overlay.masonry-mode .gallery-card {
        position: relative;
        width: auto; /* Will be set by JavaScript based on image aspect ratio */
        min-width: 280px;
        height: 400px;
        transform: none !important;
        opacity: 1 !important;
        transition: transform 0.3s ease, box-shadow 0.3s ease;
        /* Flat cards, no 3D */
        transform-style: flat;
        box-sizing: border-box;
        /* Let grid handle placement - each card takes its calculated width */
        grid-column: auto;
    }
    
    .card-gallery-overlay.masonry-mode .gallery-card:hover {
        transform: translateY(-8px) !important;
        z-index: 10;
    }
    
    /* Focused/flipped card gets highlight */
    .card-gallery-overlay.masonry-mode .gallery-card.flipped {
        z-index: 100;
        transform: scale(1.02);
    }
    
    /* Hide navigation arrows in masonry mode */
    .card-gallery-overlay.masonry-mode .card-nav {
        display: none !important;
    }
    
    /* Hide thumbnail strip in masonry - all cards visible */
    .card-gallery-overlay.masonry-mode .deck-preview {
        display: none;
    }
    
    /* Hide counter in masonry mode */
    .card-gallery-overlay.masonry-mode .card-counter {
        display: none;
    }
    
    /* Hide swipe hint on desktop */
    .card-gallery-overlay.masonry-mode .swipe-hint {
        display: none !important;
    }
    
    /* Category tabs stay visible and work as filters */
    .card-gallery-overlay.masonry-mode .card-deck-tabs {
        position: sticky;
        top: 0;
        z-index: 50;
        background: rgba(45, 40, 37, 0.95);
        padding: 0.75rem;
        margin-bottom: 1rem;
        border-radius: 12px;
    }
}

/* Larger cards on bigger screens */
@media (min-width: 1200px) {
    .card-gallery-overlay.masonry-mode .card-stack {
        grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
        column-gap: 2.75rem;
        row-gap: 3rem;
        padding: 2.5rem;
    }
    
    .card-gallery-overlay.masonry-mode .gallery-card {
        height: 420px;
        min-width: 280px;
    }
}

@media (min-width: 1600px) {
    .card-gallery-overlay.masonry-mode .card-stack {
        grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
        max-width: 1800px;
        column-gap: 3rem;
        row-gap: 3.5rem;
        padding: 3rem;
    }
    
    .card-gallery-overlay.masonry-mode .gallery-card {
        height: 450px;
        min-width: 280px;
    }
}

@media (max-width: 480px) {
    .card-stack {
        width: 88vw;
        max-width: 380px;
        height: 470px;
    }
    
    /* Tighter peek on small screens */
    .gallery-card.stack-1 {
        transform: translateX(75%) rotate(5deg) scale(0.85) !important;
    }
    
    .gallery-card.stack-prev-1 {
        transform: translateX(-75%) rotate(-5deg) scale(0.85) !important;
    }
    
    .gallery-card.stack-2,
    .gallery-card.stack-prev-2 {
        display: none; /* Hide second peek on very small screens */
    }
}

/* Individual Card */
.gallery-card {
    position: absolute;
    width: 100%;
    height: 100%;
    cursor: pointer;
    -webkit-transform-style: preserve-3d;
    transform-style: preserve-3d;
    transition: transform 0.6s cubic-bezier(0.34, 1.56, 0.64, 1),
                opacity 0.4s ease,
                box-shadow 0.3s ease;
    will-change: transform;
}

/* Card dealing animation */
.gallery-card.dealing {
    animation: dealCard 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes dealCard {
    0% {
        opacity: 0;
        transform: translateX(200px) translateY(-100px) rotateZ(30deg) scale(0.5);
    }
    100% {
        opacity: 1;
        transform: translateX(var(--deal-x, 0)) translateY(var(--deal-y, 0)) rotateZ(var(--deal-rotation, 0deg)) scale(1);
    }
}

/* Shuffle animation for category change */
.gallery-card.shuffling-out {
    animation: shuffleOut 0.3s ease-in forwards;
}

.gallery-card.shuffling-in {
    animation: shuffleIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes shuffleOut {
    0% {
        transform: translateX(0) translateY(0) rotate(0deg) scale(1);
        opacity: 1;
    }
    100% {
        transform: translateX(var(--shuffle-x, 100px)) translateY(var(--shuffle-y, -50px)) rotate(var(--shuffle-rotate, 25deg)) scale(0.6);
        opacity: 0;
    }
}

@keyframes shuffleIn {
    0% {
        transform: translateY(-80px) rotate(var(--shuffle-rotate, 0deg)) scale(0.5);
        opacity: 0;
    }
    60% {
        opacity: 1;
    }
    100% {
        transform: translateX(0) translateY(0) rotate(0deg) scale(1);
        opacity: 1;
    }
}

/* Card exit animation */
.gallery-card.exiting {
    animation: exitCard 0.4s ease-in forwards;
}

@keyframes exitCard {
    0% {
        opacity: 1;
        transform: translateX(var(--current-x, 0)) rotateY(0deg);
    }
    100% {
        opacity: 0;
        transform: translateX(-300px) rotateY(-45deg) scale(0.8);
    }
}

/* Card Face (shared styles) */
.card-face {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 16px;
    background: #FAF8F5; /* Solid fallback background */
    box-shadow: 
        /* Tight shadow for depth */
        0 2px 4px rgba(0, 0, 0, 0.1),
        /* Medium cast shadow */
        0 8px 16px rgba(0, 0, 0, 0.15),
        /* Large diffuse cast shadow */
        0 20px 40px rgba(0, 0, 0, 0.2),
        /* Extra large ambient shadow */
        0 40px 80px rgba(0, 0, 0, 0.15),
        /* Inner highlight */
        0 0 0 1px rgba(255, 255, 255, 0.1) inset;
    /* Use visibility approach instead of backface-visibility */
    transition: visibility 0s linear 0.3s, opacity 0.3s ease;
    /* Ensure cards are fully opaque */
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
}

/* Card Front */
.card-front {
    background: linear-gradient(145deg, #FAF8F5 0%, #F5F1EC 100%);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 2;
}

/* In masonry mode, card front matches card height */
.card-gallery-overlay.masonry-mode .card-front {
    height: 100%;
}

/* Hide front when flipped - timed with animation */
.gallery-card.flipped .card-front {
    visibility: hidden;
    opacity: 0;
    transition: visibility 0s linear 0.25s, opacity 0.01s ease 0.25s;
}

.gallery-card.flipping .card-front {
    animation: frontFadeOut 0.5s ease-in-out forwards;
}

.gallery-card.flipping-back .card-front {
    animation: frontFadeIn 0.5s ease-in-out forwards;
}

@keyframes frontFadeOut {
    0%, 45% { opacity: 1; visibility: visible; }
    50%, 100% { opacity: 0; visibility: hidden; }
}

@keyframes frontFadeIn {
    0%, 45% { opacity: 0; visibility: hidden; }
    50%, 100% { opacity: 1; visibility: visible; }
}

/* Card Frame Border (trading card style) with rounded corners */
.card-front::before {
    content: '';
    position: absolute;
    inset: 8px;
    border: 3px solid #FF6B7A; /* Default fallback color */
    border-radius: 10px;
    pointer-events: none;
    z-index: 2;
    /* Add subtle gradient-like effect with layered box-shadows */
    box-shadow: 
        inset 0 0 0 1px rgba(255, 179, 186, 0.6),
        inset 0 0 0 2px rgba(255, 107, 122, 0.4);
}

/* Category-specific border colors */
.gallery-card[data-category-color="#FFB7C2"] .card-front::before {
    border-color: #FFB7C2;
    box-shadow: 
        inset 0 0 0 1px rgba(255, 183, 194, 0.6),
        inset 0 0 0 2px rgba(255, 132, 151, 0.4);
}

.gallery-card[data-category-color="#D97EAE"] .card-front::before {
    border-color: #D97EAE;
    box-shadow: 
        inset 0 0 0 1px rgba(217, 126, 174, 0.6),
        inset 0 0 0 2px rgba(192, 106, 154, 0.4);
}

.gallery-card[data-category-color="#F74560"] .card-front::before {
    border-color: #F74560;
    box-shadow: 
        inset 0 0 0 1px rgba(247, 69, 96, 0.6),
        inset 0 0 0 2px rgba(232, 58, 82, 0.4);
}

.gallery-card[data-category-color="#F06F51"] .card-front::before {
    border-color: #F06F51;
    box-shadow: 
        inset 0 0 0 1px rgba(240, 111, 81, 0.6),
        inset 0 0 0 2px rgba(232, 90, 58, 0.4);
}

/* Holographic shimmer effect */
.card-front::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(
        125deg,
        transparent 0%,
        transparent 40%,
        rgba(255, 107, 122, 0.1) 45%,
        rgba(255, 179, 186, 0.2) 50%,
        rgba(255, 107, 122, 0.1) 55%,
        transparent 60%,
        transparent 100%
    );
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    z-index: 3;
}

.gallery-card:hover .card-front::after {
    opacity: 1;
    animation: shimmer 2s infinite;
}

@keyframes shimmer {
    0% {
        transform: translateX(-100%) rotate(25deg);
    }
    100% {
        transform: translateX(200%) rotate(25deg);
    }
}

/* Card Image Area */
.card-image-container {
    flex: 1;
    margin: 16px 16px 8px 16px;
    border-radius: 8px;
    overflow: hidden;
    position: relative;
    /* Canvas texture behind "contain" images */
    background-color: #F5F1EC;
    background-image: url('images/haus_of_toots_canvas_13ct_512px.png');
    background-repeat: repeat;
    background-size: 300px 293px;
    background-position: 0 0;
    /* Ensure our overlay sits under image/badges */
    isolation: isolate;
}

/* Soft vignette over canvas texture (but under the image) */
.card-image-container::after {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(
        ellipse at center,
        rgba(255, 255, 255, 0.55) 0%,
        rgba(255, 255, 255, 0.20) 45%,
        rgba(26, 22, 20, 0.20) 100%
    );
    pointer-events: none;
    z-index: 0;
}

/* In masonry mode, image container has explicit dimensions set by JS */
.card-gallery-overlay.masonry-mode .card-image-container {
    flex: none; /* Override flex: 1 - dimensions set explicitly by JS */
    margin: 16px 16px 8px 16px;
    min-height: 0;
}

.card-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s ease;
    position: relative;
    z-index: 1;
}

/* In masonry mode, image fills container maintaining aspect ratio */
.card-gallery-overlay.masonry-mode .card-image {
    width: 100%;
    height: 100%;
    object-fit: contain; /* Use contain to maintain aspect ratio without cropping */
}

.gallery-card:hover .card-image {
    transform: scale(1.05);
}

/* Category Badge */
.card-category-badge {
    position: absolute;
    top: 12px;
    right: 12px;
    padding: 4px 10px;
    background: linear-gradient(135deg, rgba(255, 107, 122, 0.95) 0%, rgba(232, 85, 99, 0.95) 100%);
    color: white;
    font-family: 'Winky Sans', sans-serif;
    font-size: 0.625rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    z-index: 5;
}

/* Category-specific badge colors */
.card-category-badge[data-color="#FFB7C2"] {
    background: linear-gradient(135deg, rgba(255, 183, 194, 0.95) 0%, rgba(255, 132, 151, 0.95) 100%);
}

.card-category-badge[data-color="#D97EAE"] {
    background: linear-gradient(135deg, rgba(217, 126, 174, 0.95) 0%, rgba(192, 106, 154, 0.95) 100%);
}

.card-category-badge[data-color="#F74560"] {
    background: linear-gradient(135deg, rgba(247, 69, 96, 0.95) 0%, rgba(224, 46, 74, 0.95) 100%);
}

.card-category-badge[data-color="#F06F51"] {
    background: linear-gradient(135deg, rgba(240, 111, 81, 0.95) 0%, rgba(232, 90, 58, 0.95) 100%);
}

/* Before/After Badge */
.card-status-badge {
    position: absolute;
    top: 12px;
    left: 12px;
    padding: 4px 10px;
    font-family: 'Winky Sans', sans-serif;
    font-size: 0.625rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    z-index: 5;
}

.card-status-badge.before {
    background: linear-gradient(135deg, rgba(155, 150, 144, 0.95) 0%, rgba(74, 69, 66, 0.95) 100%);
    color: white;
}

.card-status-badge.after {
    background: linear-gradient(135deg, rgba(255, 107, 122, 0.95) 0%, rgba(232, 85, 99, 0.95) 100%);
    color: white;
}

/* Card Info Area */
.card-info {
    padding: 12px 16px 16px;
    text-align: center;
    position: relative;
    z-index: 2;
}

.card-title {
    font-family: 'Chewy', cursive;
    font-size: 1.125rem;
    color: #4A4542;
    margin: 0 0 4px 0;
    line-height: 1.2;
}

.card-subtitle {
    font-family: 'Winky Sans', sans-serif;
    font-size: 0.75rem;
    color: #9B9690;
    margin: 0;
    font-style: italic;
}

/* Card Back */
.card-back {
    background: linear-gradient(145deg, #2d2825 0%, #1a1614 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px;
    text-align: center;
    z-index: 1;
    /* Hidden by default */
    visibility: hidden;
    opacity: 0;
    transition: visibility 0s linear 0.15s, opacity 0.15s ease;
}

/* Show back when flipped - timed with animation */
.gallery-card.flipped .card-back {
    visibility: visible;
    opacity: 1;
    transition: visibility 0s linear 0s, opacity 0.01s ease 0.25s;
}

.gallery-card.flipping .card-back {
    animation: backFadeIn 0.5s ease-in-out forwards;
}

.gallery-card.flipping-back .card-back {
    animation: backFadeOut 0.5s ease-in-out forwards;
}

@keyframes backFadeIn {
    0%, 45% { opacity: 0; visibility: hidden; }
    50%, 100% { opacity: 1; visibility: visible; }
}

@keyframes backFadeOut {
    0%, 45% { opacity: 1; visibility: visible; }
    50%, 100% { opacity: 0; visibility: hidden; }
}

/* Decorative pattern on back */
.card-back::before {
    content: '';
    position: absolute;
    inset: 12px;
    border: 2px solid rgba(255, 107, 122, 0.3);
    border-radius: 10px;
    background-image: 
        repeating-linear-gradient(
            45deg,
            transparent,
            transparent 10px,
            rgba(255, 107, 122, 0.05) 10px,
            rgba(255, 107, 122, 0.05) 20px
        );
}

.card-back-content {
    position: relative;
    z-index: 2;
}

.card-back-logo {
    width: auto;
    height: auto;
    max-width: 100px;
    max-height: 100px;
    margin-bottom: 1.5rem;
    opacity: 0.9;
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.3));
    object-fit: contain;
}

.card-back-title {
    font-family: 'Chewy', cursive;
    font-size: 1.5rem;
    color: #FF8497;
    margin: 0 0 0.5rem 0;
    text-shadow: 0 2px 10px rgba(255, 107, 122, 0.3);
}

.card-back-category {
    font-family: 'Winky Sans', sans-serif;
    font-size: 0.875rem;
    color: #FF6B7A;
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-bottom: 1rem;
}

.card-back-description {
    font-family: 'Winky Sans', sans-serif;
    font-size: 0.875rem;
    color: rgba(255, 179, 186, 0.8);
    line-height: 1.6;
    max-width: 280px;
}

.card-back-cta {
    margin-top: 1.5rem;
    padding: 0.625rem 1.5rem;
    background: linear-gradient(135deg, #FF6B7A 0%, #E85563 100%);
    color: white;
    border: none;
    border-radius: 25px;
    font-family: 'Winky Sans', sans-serif;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.card-back-cta:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 15px rgba(255, 107, 122, 0.4);
}

/* Flipped state - 3D flip animation */
.gallery-card.flipping {
    animation: cardFlip 0.5s ease-in-out;
}

.gallery-card.flipping-back {
    animation: cardFlipBack 0.5s ease-in-out;
}

@keyframes cardFlip {
    0% { 
        transform: perspective(1000px) rotateY(0deg) scale(1);
    }
    50% { 
        transform: perspective(1000px) rotateY(90deg) scale(0.9);
    }
    100% { 
        transform: perspective(1000px) rotateY(0deg) scale(1);
    }
}

@keyframes cardFlipBack {
    0% { 
        transform: perspective(1000px) rotateY(0deg) scale(1);
    }
    50% { 
        transform: perspective(1000px) rotateY(-90deg) scale(0.9);
    }
    100% { 
        transform: perspective(1000px) rotateY(0deg) scale(1);
    }
}

.gallery-card.active.flipped {
    /* Keep the active positioning after animation */
    z-index: 10;
}

/* Navigation Arrows */
.card-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 56px;
    height: 56px;
    border: none;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    color: #E85563;
    z-index: 100;
    backdrop-filter: blur(10px);
    box-shadow: 
        0 4px 12px rgba(0, 0, 0, 0.15),
        0 0 0 1px rgba(255, 107, 122, 0.2);
}

.card-nav:hover {
    background: #FF6B7A;
    color: white;
    transform: translateY(-50%) scale(1.1);
    box-shadow: 0 8px 24px rgba(255, 107, 122, 0.4);
}

.card-nav:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.5);
}

.card-nav:disabled:hover {
    background: rgba(255, 255, 255, 0.5);
    color: #E85563;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transform: translateY(-50%);
}

.card-nav svg {
    width: 24px;
    height: 24px;
}

.card-nav-prev {
    left: 2rem;
}

.card-nav-next {
    right: 2rem;
}

@media (max-width: 768px) {
    .card-nav {
        width: 44px;
        height: 44px;
    }
    
    .card-nav-prev {
        left: 1rem;
    }
    
    .card-nav-next {
        right: 1rem;
    }
}


/* Card Counter */
.card-counter {
    position: absolute;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    font-family: 'Winky Sans', sans-serif;
    font-size: 0.875rem;
    color: rgba(74, 69, 66, 0.7);
    z-index: 10;
    background: rgba(255, 255, 255, 0.8);
    padding: 0.375rem 1rem;
    border-radius: 20px;
    backdrop-filter: blur(8px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.card-counter-current {
    color: #E85563;
    font-weight: 600;
}

/* Deck Preview (mini cards at bottom) */
.deck-preview {
    display: flex;
    gap: 8px;
    padding: 1rem 2rem 2rem;
    position: relative;
    z-index: 10;
    overflow-x: auto;
    overflow-y: hidden;
    max-width: 100%;
    background: rgba(45, 40, 37, 0.6);
    backdrop-filter: blur(8px);
    scroll-behavior: smooth;
    /* Hide scrollbar but keep functionality */
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.deck-preview::-webkit-scrollbar {
    display: none;
}

/* Add padding to allow centering of edge cards */
.deck-preview::before,
.deck-preview::after {
    content: '';
    flex: 0 0 calc(50vw - 40px);
}


.deck-mini-card {
    width: 48px;
    height: 68px;
    border-radius: 6px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.3s ease;
    opacity: 0.5;
    border: 2px solid transparent;
    flex-shrink: 0;
}

.deck-mini-card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.deck-mini-card:hover {
    opacity: 0.8;
    transform: translateY(-4px);
}

.deck-mini-card.active {
    opacity: 1;
    border-color: #FF6B7A;
    box-shadow: 0 4px 12px rgba(255, 107, 122, 0.4);
}

@media (min-width: 900px) {
    .deck-mini-card {
        width: 56px;
        height: 78px;
    }
}

@media (min-width: 1200px) {
    .deck-mini-card {
        width: 64px;
        height: 90px;
        border-radius: 8px;
    }
}

/* Stacked cards effect */
.card-stack .gallery-card:nth-child(1) {
    z-index: 5;
}

.card-stack .gallery-card:nth-child(2) {
    z-index: 4;
    transform: translateX(8px) translateY(4px) rotate(2deg) scale(0.98);
    opacity: 0.7;
}

.card-stack .gallery-card:nth-child(3) {
    z-index: 3;
    transform: translateX(16px) translateY(8px) rotate(4deg) scale(0.96);
    opacity: 0.5;
}

.card-stack .gallery-card:nth-child(n+4) {
    z-index: 2;
    transform: translateX(20px) translateY(10px) rotate(5deg) scale(0.94);
    opacity: 0.3;
}

/* Active card (on top of stack) */
.gallery-card.active {
    z-index: 100 !important;
    transform: translateX(0) translateY(0) rotate(0deg) scale(1) !important;
    opacity: 1 !important;
}

/* Card navigation - CSS transitions handle the smooth fan shift */
/* No complex animations needed - cards just smoothly transition to new positions */

/* No hover animation - keeps image crisp */

/* ============================================
   STACKED DECK LAYOUT
   Cards stack like a deck - take from top, put at back
   ============================================ */

/* Cards in the stack - offset slightly to show depth */
.gallery-card.in-stack {
    pointer-events: none;
}

/* Stack positions - cards behind the active one */
/* No opacity - just offset and slight darkening via filter */
.gallery-card.stack-1 {
    z-index: 9;
    transform: translateX(6px) translateY(6px);
}

.gallery-card.stack-2 {
    z-index: 8;
    transform: translateX(12px) translateY(12px);
}

.gallery-card.stack-3 {
    z-index: 7;
    transform: translateX(18px) translateY(18px);
}

.gallery-card.stack-4 {
    z-index: 6;
    transform: translateX(24px) translateY(24px);
}

.gallery-card.stack-5 {
    z-index: 5;
    transform: translateX(30px) translateY(30px);
}

/* Simple transitions for stack position changes (not for flipping) */
.gallery-card.in-stack {
    transition: transform 0.25s ease;
}

/* Flip hint */
.flip-hint {
    position: absolute;
    bottom: -40px;
    left: 50%;
    transform: translateX(-50%);
    font-family: 'Winky Sans', sans-serif;
    font-size: 0.75rem;
    color: rgba(74, 69, 66, 0.6);
    white-space: nowrap;
    opacity: 0;
    transition: opacity 0.3s ease;
    background: rgba(255, 255, 255, 0.8);
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
}

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

/* Show flip hint on mobile (touch devices) */
@media (hover: none) and (pointer: coarse) {
    .gallery-card.active .flip-hint {
        opacity: 1;
        animation: pulseHint 2s ease-in-out infinite;
    }
    
    @keyframes pulseHint {
        0%, 100% { opacity: 0.7; }
        50% { opacity: 1; }
    }
}

/* Full Image View (when clicking View Full) */
.card-fullview {
    position: fixed;
    inset: 0;
    z-index: 10001;
    background-color: #FAF8F5;
    background-image: url('images/haus_of_toots_canvas_13ct_512px.png');
    background-repeat: repeat;
    background-size: 512px 500px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

/* Vignette for fullview */
.card-fullview::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(
        ellipse at center,
        transparent 0%,
        transparent 40%,
        rgba(26, 22, 20, 0.2) 70%,
        rgba(26, 22, 20, 0.5) 100%
    );
    pointer-events: none;
}

.card-fullview.active {
    opacity: 1;
    visibility: visible;
}

.card-fullview-image {
    max-width: 90%;
    max-height: 90%;
    object-fit: contain;
    border-radius: 12px;
    box-shadow: 
        0 4px 8px rgba(0, 0, 0, 0.1),
        0 15px 35px rgba(0, 0, 0, 0.2),
        0 40px 80px rgba(0, 0, 0, 0.15);
    animation: zoomIn 0.3s ease;
    position: relative;
    z-index: 1;
}

@keyframes zoomIn {
    from {
        transform: scale(0.8);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

.card-fullview-close {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 48px;
    height: 48px;
    border: none;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    color: #E85563;
    z-index: 2;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.card-fullview-close:hover {
    background: #FF6B7A;
    color: white;
    transform: scale(1.1) rotate(90deg);
}

/* Loading state */
.card-image-container.loading {
    background: linear-gradient(90deg, #E8E4DF 25%, #F5F1EC 50%, #E8E4DF 75%);
    background-size: 200% 100%;
    animation: imageLoading 1.5s infinite;
}

@keyframes imageLoading {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

/* Swipe hint for mobile - shows briefly then fades */
.swipe-hint {
    display: none;
    position: absolute;
    bottom: 1rem;
    left: 50%;
    transform: translateX(-50%);
    font-family: 'Winky Sans', sans-serif;
    font-size: 0.7rem;
    color: rgba(74, 69, 66, 0.5);
    padding: 0.25rem 0.5rem;
    white-space: nowrap;
    z-index: 5;
    pointer-events: none;
}

.swipe-hint svg {
    vertical-align: middle;
    margin: 0 0.15rem;
    opacity: 0.5;
}

@media (hover: none) and (pointer: coarse) {
    .swipe-hint {
        display: flex;
        align-items: center;
        gap: 0.25rem;
        /* Show for 3 seconds then fade out */
        animation: swipeHintFade 4s ease-out forwards;
    }
    
    @keyframes swipeHintFade {
        0%, 60% { 
            opacity: 0.6;
        }
        100% { 
            opacity: 0;
        }
    }
    
    /* Hide nav arrows on touch devices - swipe instead */
    .card-nav {
        display: none;
    }
}

/* Mobile Optimizations */
@media (max-width: 640px) {
    .card-gallery-header {
        padding: 0.75rem 1rem;
    }
    
    .card-gallery-title {
        font-size: 1.25rem;
    }
    
    .card-gallery-tabs {
        padding: 0.75rem 1rem;
        gap: 0.375rem;
    }
    
    .card-deck-tab {
        padding: 0.375rem 0.875rem;
        font-size: 0.75rem;
    }
    
    .card-gallery-main {
        padding: 1rem;
    }
    
    .card-counter {
        bottom: 1rem;
        font-size: 0.75rem;
    }
    
    .deck-preview {
        padding: 0.75rem 1rem 1.5rem;
        gap: 6px;
    }
    
    .deck-mini-card {
        width: 40px;
        height: 56px;
    }
    
    .card-info {
        padding: 8px 12px 12px;
    }
    
    .card-title {
        font-size: 1rem;
    }
    
    .card-subtitle {
        font-size: 0.6875rem;
    }
}

/* Reduced motion preference */
@media (prefers-reduced-motion: reduce) {
    .gallery-card,
    .card-face,
    .card-front::after,
    .card-image,
    .gallery-card.dealing,
    .gallery-card.exiting {
        animation: none;
        transition: opacity 0.2s ease;
    }
}

/* Keyboard focus states */
.gallery-card:focus {
    outline: 3px solid #FF6B7A;
    outline-offset: 4px;
}

.card-nav:focus,
.card-deck-tab:focus,
.deck-mini-card:focus {
    outline: 2px solid #FF8497;
    outline-offset: 2px;
}

