/*
==========================================================================
Reading Page Specific Styles for template-tarot-reading.php
Loaded only when the Tarot Reading Layout page template is active.
==========================================================================
*/

/* --- General Section and Typography --- */

body.page-template-template-tarot-reading #card-selection {
    padding-top: 40px;
    padding-bottom: 60px;
    text-align: center;
    font-family: 'Lato', sans-serif; /* Default to Lato for this page */
}

body.page-template-template-tarot-reading #card-selection h1.entry-title {
    font-family: 'Cinzel', serif !important; /* Force Cinzel */
    font-size: clamp(2rem, 6vw, 2.8rem); /* Responsive */
    color: #FFFFFF; /* Adjust color for theme */
    margin-bottom: 20px;
}

body.page-template-template-tarot-reading #card-selection .instructions {
    font-family: 'Lato', sans-serif;
    color: #FFFFFF;
    margin-bottom: 40px;
    font-size: 1.1rem;
    max-width: 700px;
    margin-left: auto;
    margin-right: auto;
    line-height: 1.6;
}

body.page-template-template-tarot-reading .reading-container {
    max-width: 1140px; /* Limit inner content width */
    margin-left: auto;
    margin-right: auto;
}

/* --- Reading Area Layout (Deck & Selected Cards) --- */

body.page-template-template-tarot-reading .reading-area {
    display: flex;
    flex-direction: column; /* Default mobile: stack */
    align-items: center;    /* Center items horizontally when stacked */
    gap: 50px;
    margin-bottom: 40px;
    width: 100%;
}

/* --- Deck Area --- */

body.page-template-template-tarot-reading .deck-area {
    position: relative;
    /* Updated Size */
    width: 180px;
    height: 264px;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    perspective: 1000px;
    margin-top: 20px;
    flex-shrink: 0; /* Prevent shrinking on desktop flex row */
}
body.page-template-template-tarot-reading .deck-area p {
    position: absolute;
    z-index: 5;
    color: white;
    background-color: rgba(0, 0, 0, 0.6);
    padding: 5px 10px;
    border-radius: 5px;
    transition: opacity 0.3s ease;
    font-size: 0.9em;
}
body.page-template-template-tarot-reading .deck-area.shuffled p {
    opacity: 0;
}

/* --- Card Base Styles --- */

body.page-template-template-tarot-reading .card {
    /* Updated Radius */
    border-radius: 12px;
    width: 100%;
    height: 100%;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2); /* Keep shadow for depth */
    position: absolute;
    top: 0;
    left: 0;
    background-size: cover;
    background-position: center;
    /* Updated transition for flip and fade */
    transition: transform 0.6s ease-in-out, opacity 0.5s ease;
    backface-visibility: hidden; /* Crucial for clean flip */
    border: none; /* Explicitly remove border */
    /* Start cards as invisible */
    opacity: 0;
}

/* --- OVERRIDE: Make visual deck cards visible initially --- */
body.page-template-template-tarot-reading .deck-area .card {
    opacity: 1;
}
/* --- END OVERRIDE --- */


/* --- Class to make placeholder card backs visible (fade-in) --- */
body.page-template-template-tarot-reading .card.visible {
    opacity: 1;
}
/* --- END VISIBLE STATE --- */


body.page-template-template-tarot-reading .card.back {
    background-color: #333; /* Fallback color */
    background-image: url('images/card-back.png'); /* Relative to CSS file location */
    z-index: 1; /* Back is initially "on top" visually before flip */
    transform: rotateY(0deg); /* Starts facing forward */
    /* Opacity controlled by base .card and .visible */
    background-size: cover;
    background-position: center;
}
/* Ensure visible backs have opacity 1 */
body.page-template-template-tarot-reading .card.back.visible {
    opacity: 1;
}


body.page-template-template-tarot-reading .card.front {
    background-color: #f0f0f0; /* Fallback color */
    z-index: 0; /* Front is initially "behind" back */
    transform: rotateY(180deg); /* Starts flipped away */
    /* Opacity controlled by .flipped class rules below */
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.5rem;
    color: #333;
    background-size: cover;
    background-position: center;
}

/* --- Selected Cards Area --- */

body.page-template-template-tarot-reading .selected-cards-area {
    display: flex;
    justify-content: center; /* Center placeholders horizontally */
    gap: 35px; /* Updated gap */
    flex-wrap: wrap;
    min-height: 275px; /* Updated min-height for larger cards */
    width: 100%; /* Take available width */
    /* Start hidden */
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.5s ease-in-out, visibility 0s linear 0.5s;
}
/* Visible state */
body.page-template-template-tarot-reading .selected-cards-area.visible {
    opacity: 1;
    visibility: visible;
    transition-delay: 0s;
}

/* Card Placeholder */
body.page-template-template-tarot-reading .card-placeholder {
    /* Updated Size */
    width: 180px;
    height: 264px;
    border: none; /* No border */
    /* Updated Radius */
    border-radius: 12px;
    display: flex;
    justify-content: center; /* Center any potential content */
    align-items: center;
    flex-direction: column;
    position: relative; /* For absolute positioned cards */
    cursor: default; /* Default state, JS changes when active */
    transition: background-color 0.3s ease, transform 0.3s ease, box-shadow 0.3s ease; /* Transitions */
    perspective: 1000px; /* Needed for 3D flip */
    /* Optional: Subtle background */
    /* background-color: rgba(0,0,0,0.02); */
}

/* Hover effect when clickable (card back is visible, not flipped) */
/* Uses :has() for better targeting if supported, otherwise JS adds/removes .clickable */
body.page-template-template-tarot-reading .card-placeholder:has(.card.back.visible):not(.flipped):hover,
body.page-template-template-tarot-reading .card-placeholder.clickable:not(.flipped):hover {
    transform: scale(1.03);
    box-shadow: 0 0 15px rgba(160, 112, 255, 0.3);
    /* background-color: rgba(160, 112, 255, 0.05); */ /* Optional background hover */
}


/* Ensure card position correctly */
body.page-template-template-tarot-reading .card-placeholder .card {
    position: absolute;
    top: 0;
    left: 0;
}

/* --- Card Labels Area (IF USING SEPARATE LABELS) --- */
body.page-template-template-tarot-reading .card-labels-area {
    display: flex;
    justify-content: center;
    gap: 35px;
    width: 100%;
    margin-top: 15px;
    padding: 0 15px;
    box-sizing: border-box;
    /* Initial Hide */
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.5s ease-in-out 0.3s, visibility 0s linear 0.8s;
}
body.page-template-template-tarot-reading .card-labels-area.visible {
    opacity: 1;
    visibility: visible;
    transition-delay: 0.3s, 0s;
}
body.page-template-template-tarot-reading .card-position-label {
    flex: 0 0 180px; /* Match card width */
    text-align: center;
    font-family: 'Lato', sans-serif;
    color: #666;
    font-size: 0.95rem;
    font-weight: 700;
}


/* --- Animations (Flip & Shuffle) --- */

/* Flipping Animation */
/* When placeholder gets .flipped class: */
body.page-template-template-tarot-reading .card-placeholder.flipped .card.back {
    transform: rotateY(-180deg); /* Rotate back away */
    opacity: 0; /* Fade back out */
    z-index: 0; /* Move back behind */
}
body.page-template-template-tarot-reading .card-placeholder.flipped .card.front {
    transform: rotateY(0deg); /* Rotate front into view */
    opacity: 1; /* Fade front in */
    z-index: 2; /* Bring front above */
}

/* Shuffle Animation */
@keyframes shuffle {
  0% { transform: translate(0, 0) rotate(0deg); }
  15% { transform: translate(-15px, 10px) rotate(-5deg); }
  30% { transform: translate(10px, -12px) rotate(3deg); }
  45% { transform: translate(5px, 15px) rotate(-4deg); }
  60% { transform: translate(-12px, -8px) rotate(6deg); }
  75% { transform: translate(8px, 5px) rotate(-2deg); }
  100% { transform: translate(0, 0) rotate(0deg); }
}
/* Apply animation to cards within the deck when shuffling */
body.page-template-template-tarot-reading .deck-area.shuffling .card:nth-child(2) {
    animation: shuffle 0.6s ease-in-out infinite alternate;
}
body.page-template-template-tarot-reading .deck-area.shuffling .card:nth-child(3) {
    animation: shuffle 0.6s ease-in-out 0.1s infinite alternate;
}
body.page-template-template-tarot-reading .deck-area.shuffling .card:nth-child(4) {
    animation: shuffle 0.6s ease-in-out 0.2s infinite alternate;
}
/* Optional: Slightly transparent deck during shuffle */
/* body.page-template-template-tarot-reading .deck-area.shuffling .card { opacity: 0.7; } */


/* --- Result Area --- */

body.page-template-template-tarot-reading .result-area {
    margin-top: 40px;
    padding: 30px;
    background-color: #000000;
    border-radius: 10px;
    border: 1px solid #eee;
    text-align: left; /* Align text left for readability */
    /* Centering */
    max-width: 800px;
    margin-left: auto;
    margin-right: auto;
    font-family: 'Lato', sans-serif; /* Ensure Lato */
}
body.page-template-template-tarot-reading .result-area h3 {
    color: #A070FF; /* Accent color */
    margin-bottom: 20px;
    text-align: center;
    font-family: 'Cinzel', serif !important; /* Use Cinzel for this heading */
    font-size: 1.8rem;
}

/* Interpretation text placeholder */

body.page-template-template-tarot-reading #interpretation-placeholder {
    color: #ffffff;
    min-height: 100px;
    line-height: 1.7;
}
body.page-template-template-tarot-reading #interpretation-placeholder strong {
    color: #444; /* Slightly darker bold */
}
body.page-template-template-tarot-reading #interpretation-placeholder p {
    margin-bottom: 1em;
}

/* --- Utility --- */

body.page-template-template-tarot-reading .hidden {
    display: none !important; /* Use important if needed */
}

/* --- Reset Button --- */

body.page-template-template-tarot-reading #reset-button {
    /* Inherit theme button styles via class="button" in PHP or add custom styles */
    background-color: #A070FF;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1rem;
    margin-top: 20px;
    display: block; /* Make it block */
    margin-left: auto;
    margin-right: auto; /* Center */
    transition: background-color 0.3s ease;
    font-family: 'Lato', sans-serif; /* Ensure Lato */
}
body.page-template-template-tarot-reading #reset-button:hover {
    background-color: #8a5cd6; /* Darker purple */
}

/* --- Responsive Adjustments --- */

@media (min-width: 768px) {
    body.page-template-template-tarot-reading .reading-area {
        flex-direction: row;
        justify-content: space-around; /* Reverted layout */
        align-items: center; /* Vertically center deck and placeholders */
        gap: 60px;
    }
     body.page-template-template-tarot-reading .deck-area {
        margin-top: 0; /* Reset align correction */
     }
     body.page-template-template-tarot-reading .selected-cards-area {
        width: auto; /* Allow flexbox to determine width */
        justify-content: center; /* Keep cards centered within this area */
     }

    /* Label Area Desktop Alignment (IF USING SEPARATE LABELS) */
     body.page-template-template-tarot-reading .card-labels-area {
        width: auto;
        padding: 0;
        justify-content: center;
        /* Try to align labels under cards (adjust if gap/width changes) */
        /* Example: gap: calc(180px + 60px - 180px); */
        gap: 60px; /* Simpler approach: match reading-area gap */
    }
    body.page-template-template-tarot-reading .card-position-label {
         flex-basis: 180px; /* Match desktop card width */
         flex-grow: 0;
         flex-shrink: 0;
         /* width: 180px; */ /* Explicit width if needed */
    }
}

@media (max-width: 600px) {
    body.page-template-template-tarot-reading .selected-cards-area {
        gap: 20px;
    }
    body.page-template-template-tarot-reading .card-placeholder {
        /* Updated Mobile Size */
        width: 140px;
        height: 205px;
    }
    body.page-template-template-tarot-reading #card-selection h1.entry-title {
        font-size: clamp(1.6rem, 5vw, 2rem);
    }
    body.page-template-template-tarot-reading .result-area {
        margin-top: 40px;
        padding: 30px;
        /* --- CHANGE THIS BACKGROUND COLOR --- */
        background-color: #e9e7f8; /* Example: A very light lavender */
        /* OR try a darker theme matching landing page: background-color: #1a1a2e; */
        /* OR try a slightly darker off-white: background-color: #f0f0f0; */
        /* --- END CHANGE --- */
        border-radius: 10px;
        border: 1px solid #eee; /* You might want to adjust border color too */
        /* border-color: #dcd9f0; */ /* Example if using lavender bg */
        /* border-color: #333; */ /* Example if using dark bg */
        text-align: left;
        max-width: 800px;
        margin-left: auto;
        margin-right: auto;
        font-family: 'Lato', sans-serif;
    }
    
    /* --- ADJUST TEXT COLORS IF BACKGROUND IS DARK --- */
    
    /* Heading inside result area */
    body.page-template-template-tarot-reading .result-area h3 {
        color: #A070FF; /* Current accent purple - MIGHT work on dark, or change */
        /* If dark background, maybe use white: color: #FFFFFF; */
        margin-bottom: 20px;
        text-align: center;
        font-family: 'Cinzel', serif !important;
        font-size: 1.8rem;
    }

     /* Label Area Mobile Alignment (IF USING SEPARATE LABELS) */
    body.page-template-template-tarot-reading .card-labels-area {
        gap: 20px; /* Match mobile card gap */
        margin-top: 10px;
     }
     body.page-template-template-tarot-reading .card-position-label {
        flex-basis: 140px; /* Match mobile card width */
        font-size: 0.9rem;
     }
}

/* --- End Reading Page Specific Styles --- */