/* ⭐ LOADING INDICATOR */
.tarot-loader {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 400px;
}

.tarot-spinner {
    width: 60px;
    height: 60px;
    border: 4px solid rgba(255, 215, 0, 0.2);
    border-top-color: gold;
    border-radius: 50%;
    animation: tarot-spin 1s linear infinite;
}

@keyframes tarot-spin {
    to { transform: rotate(360deg); }
}

/* Hide content until loaded */
.ez-tarot-spread .tarot-content {
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.4s ease;
}

/* Show content when loaded */
.ez-tarot-spread.loaded .tarot-content {
    opacity: 1;
    visibility: visible;
}

/* Hide loader when loaded */
.ez-tarot-spread.loaded .tarot-loader {
    display: none;
}

.ez-tarot-block-editor {
    border: 1px solid #ddd;
    padding: 15px;
    border-radius: 6px;
    background: #fafafa;
}

.tarot-editor-placeholder {
    text-align: center;
    padding: 20px;
    opacity: 0.8;
}

.tarot-editor-placeholder h2 {
    margin-bottom: 10px;
}

/* FIX: Remove theme's gold background from header area */
.ez-tarot-spread .header-area {
    background: none !important;
    background-color: transparent !important;
    box-shadow: none !important;
}

.ez-tarot-spread .header-area h1 {
    font-size: 1.8rem;
    margin-bottom: 10px;
}

.selected-cards {
    margin-top: 20px;
    display: flex;
    gap: 20px;
    justify-content: center;
}

/* FIX: Consistent slot sizing (265px) for selected cards */
.selected-slot,
.ez-tarot-spread .selected-slot {
    border: 1px solid #ddd;
    padding: 10px;
    border-radius: 6px;
    width: 265px !important;
    min-width: 265px !important;
    max-width: 265px !important;
    text-align: center;
}

/* FIX: Constrain images inside slots */
.ez-tarot-spread .selected-slot img {
    width: 100%;
    max-width: 200px;
    height: auto;
    margin: 0 auto;
}

/* FIX: Prevent mid-word breaks in card names */
.ez-tarot-spread .selected-slot h3 {
    word-break: normal !important;
    overflow-wrap: break-word !important;
    hyphens: none !important;
    -webkit-hyphens: none !important;
}

/* Bold the Past / Present / Future labels */
.ez-tarot-spread .position-label,
.ez-tarot-spread .selected-slot .position-label,
.selected-slot .position-label,
.position-label {
    font-weight: 700 !important;
    font-weight: bold !important;
}

.reading-container {
    margin-top: 30px;
}

/* ------------------------------------------
   FIX: Allow tarot images to scale naturally
------------------------------------------ */
.ez-tarot-spread img {
    width: 100%;
    height: auto;
    display: block;
}

/* ------------------------------------------
   FIX: CARD DIMENSIONS (controls fan shape)
------------------------------------------ */
.ez-tarot-spread .card {
    width: 130px;
    height: 230px;
    position: absolute;
    pointer-events: auto;
    transform-origin: center bottom;
    transition: transform 0.6s ease;
    --tarot-base-transform: none;
}

/* ------------------------------------------
   FIX: Proper deck container
------------------------------------------ */
.ez-tarot-spread .deck-container {
    position: relative;
    width: 100%;
    height: 320px;
    /* PERFECT height for your current fan */
    display: flex;
    justify-content: center;
    align-items: flex-end;
    overflow: visible;
    pointer-events: none;
    /* cards handle clicks */
}

.ez-tarot-spread .card-face {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
}

.ez-tarot-spread .card-back {
    transform: rotateY(0deg);
}

.ez-tarot-spread .card-front {
    transform: rotateY(180deg);
}

.ez-tarot-spread .selected-cards {
    margin-top: 40px !important;
}

#deckArea {
    padding-top: 140px !important;
}

/* MOBILE: Smaller cards + tighter layout */
@media (max-width: 600px) {

    .ez-tarot-spread .card {
        width: 85px;
        height: 150px;
    }

    .ez-tarot-spread .deck-container {
        height: 240px;
    }

    .ez-tarot-spread .selected-cards {
        margin-top: 20px !important;
    }

    .selected-cards {
        margin-top: 0 !important;
        transform: translateY(-110px);
        gap: 6px !important;
        flex-direction: column !important;
        align-items: center !important;
    }

    /* FIX: Mobile slot sizing override */
    .selected-slot,
    .ez-tarot-spread .selected-slot {
        margin-top: 0 !important;
        width: 95% !important;  
        max-width: 360px !important;
        min-width: unset !important;
        margin-left: auto;
        margin-right: auto;
        margin-bottom: 4px !important;
    }

    /* prevent mid-word breaks */
    .selected-slot div {
        white-space: normal !important;
        word-break: normal !important;
        overflow-wrap: break-word !important;  
        hyphens: none !important;
        line-height: 1.35;
        text-align: center;
    }
}

/* Raise Past / Present / Future slots on DESKTOP */
@media (min-width: 601px) {
    .selected-cards {
        margin-top: 0 !important;
        transform: translateY(-150px);
    }
}

/* ⭐ TRUE VISIBLE TAROT CLICK FEEDBACK ⭐ */

/* We dynamically store the card's actual fan transform before animating */
.ez-tarot-spread .ez-card-click-feedback {
    animation: ez-tarot-click 0.42s ease-out forwards;
}

@keyframes ez-tarot-click {
    0% {
        transform: translate3d(0, 0, 0) var(--tarot-base-transform) scale(1);
        box-shadow: 0 0 0 rgba(255, 215, 0, 0);
        filter: brightness(1);
    }
    30% {
        transform: translate3d(0, -30px, 0) var(--tarot-base-transform) scale(1.22);
        box-shadow: 0 0 45px 18px rgba(255, 215, 0, 0.8);
        filter: brightness(1.4);
    }
    55% {
        transform: translate3d(0, -48px, 0) var(--tarot-base-transform) scale(1.28);
        box-shadow: 0 0 60px 24px rgba(255, 215, 0, 1);
        filter: brightness(1.7);
    }
    100% {
        transform: translate3d(0, -22px, 0) var(--tarot-base-transform) scale(1.12);
        box-shadow: 0 0 18px 6px rgba(255, 215, 0, 0.5);
        filter: brightness(1.2);
    }
}

/* ⭐ SLOT GLOW when card lands */
.selected-slot.slot-glow {
    animation: ez-slot-glow 0.8s ease-out forwards;
}

@keyframes ez-slot-glow {
    0% {
        box-shadow: 0 0 0 rgba(255, 215, 0, 0);
        filter: brightness(1);
    }
    30% {
        box-shadow: 0 0 40px 15px rgba(255, 215, 0, 0.9);
        filter: brightness(1.3);
    }
    100% {
        box-shadow: 0 0 8px 2px rgba(255, 215, 0, 0.3);
        filter: brightness(1);
    }
}

/* ⭐ MYSTICAL VORTEX SHUFFLE ANIMATION ⭐ */

/* Container needs perspective for 3D effect */
.ez-tarot-spread .deck-container.shuffling {
    perspective: 1000px;
}

/* Cards during shuffle - start stacked at center */
.ez-tarot-spread .card.vortex-shuffle {
    animation: ez-vortex-shuffle 2.5s ease-in-out forwards;
    animation-delay: var(--card-delay, 0ms);
    --final-x: 0px;
    --final-y: 0px;
    --final-rotation: 0deg;
    --orbit-radius: 180px;
    --card-angle: 0deg;
}

@keyframes ez-vortex-shuffle {
    /* Phase 1: Start stacked at center */
    0% {
        transform: translate(0, 0) rotate(0deg) scale(0.8);
        opacity: 0;
        filter: brightness(1);
        box-shadow: 0 0 0 rgba(255, 215, 0, 0);
    }
    
    /* Phase 1b: Fade in, still stacked */
    8% {
        transform: translate(0, 0) rotate(0deg) scale(0.9);
        opacity: 1;
        filter: brightness(1);
        box-shadow: 0 0 5px rgba(255, 215, 0, 0.3);
    }
    
    /* Phase 2: Explode outward to orbit position */
    20% {
        transform: 
            rotate(var(--card-angle))
            translateX(var(--orbit-radius))
            rotate(calc(-1 * var(--card-angle)))
            scale(0.85);
        opacity: 1;
        filter: brightness(1.3);
        box-shadow: 0 0 25px 8px rgba(255, 215, 0, 0.7);
    }
    
    /* Phase 3a: First orbit pass */
    40% {
        transform: 
            rotate(calc(var(--card-angle) + 120deg))
            translateX(var(--orbit-radius))
            rotate(calc(-1 * (var(--card-angle) + 120deg)))
            scale(0.85);
        opacity: 1;
        filter: brightness(1.5);
        box-shadow: 0 0 35px 12px rgba(255, 215, 0, 0.9);
    }
    
    /* Phase 3b: Second orbit pass - peak glow */
    60% {
        transform: 
            rotate(calc(var(--card-angle) + 280deg))
            translateX(calc(var(--orbit-radius) * 1.1))
            rotate(calc(-1 * (var(--card-angle) + 280deg)))
            scale(0.9);
        opacity: 1;
        filter: brightness(1.6);
        box-shadow: 0 0 45px 15px rgba(255, 215, 0, 1);
    }
    
    /* Phase 4: Spiral outward toward final position */
    80% {
        transform: 
            translate(calc(var(--final-x) * 0.7), calc(var(--final-y) * 0.7))
            rotate(calc(var(--final-rotation) * 0.8))
            scale(0.95);
        opacity: 1;
        filter: brightness(1.2);
        box-shadow: 0 0 20px 6px rgba(255, 215, 0, 0.5);
    }
    
    /* Phase 5: Settle into final fan position */
    100% {
        transform: 
            translate(var(--final-x), var(--final-y))
            rotate(var(--final-rotation))
            scale(1);
        opacity: 1;
        filter: brightness(1);
        box-shadow: 0 0 0 rgba(255, 215, 0, 0);
    }
}

/* Glow trail effect on container during shuffle */
.ez-tarot-spread .deck-container.shuffling::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 350px;
    height: 350px;
    transform: translate(-50%, -50%);
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255, 215, 0, 0.15) 0%, transparent 70%);
    animation: ez-vortex-glow 2.5s ease-in-out forwards;
    pointer-events: none;
}

@keyframes ez-vortex-glow {
    0% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.5);
    }
    20% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
    60% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1.2);
    }
    100% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(1.5);
    }
}

/* Mobile: smaller orbit */
@media (max-width: 600px) {
    .ez-tarot-spread .card.vortex-shuffle {
        --orbit-radius: 100px;
    }
    
    .ez-tarot-spread .deck-container.shuffling::after {
        width: 200px;
        height: 200px;
    }
}

.ez-tarot-spread #shuffleBtn.framed {
    width: 187px;
    height: 96px;
    padding: 5px 15px !important;
    background-size: 100% 100%;
    background-repeat: no-repeat;
    background-color: transparent;
    border: none;
    color: inherit;
    
    /* ⭐ Force text wrapping between words */
    font-size: 16px !important;
    font-weight: bold !important;
    line-height: 1.2 !important;
    letter-spacing: normal !important;
    text-transform: none !important;
    white-space: normal !important;
    word-break: normal !important;
    overflow-wrap: normal !important;
    hyphens: none !important;
    
    /* ⭐ Center wrapped text */
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    text-align: center !important;
    
    cursor: pointer;
    transition: all 0.3s ease;
}

/* Hover effect */
.ez-tarot-spread #shuffleBtn.framed:hover {
    filter: brightness(1.3);
    box-shadow: 0 0 25px 8px rgba(255, 215, 0, 0.6);
    transform: scale(1.05);
    transition: all 0.3s ease;
}

/* Click/pressed effect */
.ez-tarot-spread #shuffleBtn.framed:active {
    filter: brightness(0.9);
    box-shadow: 0 0 15px 4px rgba(255, 215, 0, 0.4);
    transform: scale(0.95);
    transition: all 0.1s ease;
}