/*
    File: tarot-data/style.css
    Role: Main Stylesheet (Tarot Only).
    Feature Manifest:
    1. 3D Card Flip Animations (Preserve-3d)
    2. Responsive Grid Layouts (CSS Grid)
    3. Dark Mode UI (Merriweather & IM Fell English fonts)
    4. Slide-out Settings Panel
    5. Modal & Toast Notifications
*/

:root {
    /* Fluid card sizing - scales smoothly with viewport */
    --card-width: clamp(45px, 10vw, 100px);
    /* Height is derived from width via ratio (settable from JS) */
    --card-ratio: 1.7;

    /* Gentle type system (readability > dashboard vibes) */
    --text-primary: rgba(224, 224, 224, 0.90);
    --text-secondary: rgba(224, 224, 224, 0.65);
    --text-tertiary: rgba(224, 224, 224, 0.45);
}

html { 
    scroll-behavior: smooth; 
}

body {
    font-family: 'Merriweather', serif;
    background-color: #1a1a2e;
    background-image: radial-gradient(circle at top right, #16222a, #3a6073, #1a1a2e);
    color: var(--text-primary);
    position: relative;
    overflow-x: hidden;
}

/* --- Navigation & Links --- */
.home-link {
    position: absolute;
    top: 1rem;
    left: 1rem;
    background-color: #4a5568; /* Tailwind gray-600 */
    color: white;
    font-weight: bold;
    padding: 0.5rem;
    border-radius: 9999px; /* rounded-full */
    transition: background-color 0.3s;
    z-index: 50;
}
.home-link:hover {
    background-color: #718096; /* Tailwind gray-500 */
}

/* --- Main Controls --- */
.control-base {
    color: white;
    font-family: 'Merriweather', serif;
    border-radius: 8px;
    border: 1px solid #718096;
    /* Keep controls tidy, but avoid heavy elevation */
    box-shadow: none;
    padding: 0.75rem;
    background-color: #4a5568;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

.control-button {
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
    white-space: nowrap;
    padding: 0.75rem 1.5rem;
}
.control-button:hover {
    background-color: #718096;
    transform: translateY(-2px);
    box-shadow: none;
}
.control-button:disabled {
    background-color: #2d3748;
    color: #718096;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* --- Settings Panel --- */
#settings-panel {
    transition: transform 0.3s ease-in-out;
    transform: translateX(100%);
    position: fixed;
    top: 0;
    right: 0;
    height: 100%;
    background-color: #1f2937; /* Tailwind gray-800 */
    border-l: 1px solid #4b5563; /* Tailwind gray-600 */
    padding: 1.5rem;
    z-index: 200;
    width: 280px;
    box-shadow: -10px 0 20px rgba(0,0,0,0.3);
}
#settings-panel.open {
    transform: translateX(0);
}
#settings-overlay {
    transition: opacity 0.3s ease-in-out;
    position: fixed;
    inset: 0;
    background-color: rgba(0,0,0,0.5);
    z-index: 199;
}


/* ================================================================
   TAROT STYLES
   ================================================================ */

/* --- Position Labels (gentle, book-like) --- */
.tarot-position-label {
    width: clamp(70px, 18vw, 180px);
    text-align: center;
    user-select: none;
}

.position-title {
    font-family: 'IM Fell English', serif;
    font-size: clamp(0.5rem, 1.2vw, 0.8rem);
    letter-spacing: 0.03em;
    color: var(--text-primary);
    opacity: 0.88;
    line-height: 1.0;
}

.position-description {
    font-family: 'Merriweather', serif;
    font-size: clamp(0.45rem, 0.9vw, 0.6rem);
    font-style: italic;
    line-height: 1.2;
    color: var(--text-secondary);
    margin-top: 0.35rem;
}

/* --- Card Flip Animation Container --- */
.card-flipper {
    width: var(--card-width);
    height: calc(var(--card-width) * var(--card-ratio));
    perspective: 1000px;
    background-color: transparent;
}

.tarot-card-container { 
    cursor: pointer; 
    display: flex;
    flex-direction: column;
    align-items: center;
}

.card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    transition: transform 0.8s;
    transform-style: preserve-3d;
}

/* Flip State */
.card-flipper.is-flipped .card-inner { 
    transform: rotateY(180deg); 
}
/* Instant Flip (for loading saved states) */
.card-flipper.is-flipped.no-transition .card-inner {
    transition: none;
}

/* Card Faces */
.card-front, .card-back {
    position: absolute;
    width: 100%;
    height: 100%;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    border-radius: 8px;
    background-size: cover;
    background-position: center;
    box-shadow: 0 4px 10px rgba(0,0,0,0.45);
}

/* Front (The Pattern/Back of physical card) */
.card-front {
    border: 2px dashed rgba(255, 255, 255, 0.3);
    background-color: rgba(255, 255, 255, 0.05);
}
.tarot-card-container:hover .card-front:not(.is-flipped) {
     border-color: #c4b5fd;
     box-shadow: 0 0 15px rgba(196, 181, 253, 0.5);
}

/* Back (The Image/Face of physical card) */
.card-back { 
    transform: rotateY(180deg); 
}
.card-back.inverted { 
    transform: rotateY(180deg) rotateZ(180deg); 
}

/* Meaning Text below card */
.card-meaning {
    font-family: 'Merriweather', serif;
    font-style: normal;
    opacity: 0;
    transition: opacity 0.5s ease-in;
    /* Scoped width ensures text doesn't spill over in tight grids */
    width: var(--card-width); 
}


/* --- Spread Grid Layout --- */
#spread-container {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 2rem;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    background-color: rgba(0,0,0,0.15);
    /* Keep it gentle: separation via spacing/opacity, not elevation */
    box-shadow: none;
    min-height: 70vh;
}

/* --- TAROT MODAL STYLES --- */
#tarot-modal { 
    position: fixed; 
    top: 0; 
    left: 0; 
    width: 100%; 
    height: 100%; 
    background-color: rgba(0, 0, 0, 0.8); 
    display: none; 
    justify-content: center; 
    align-items: center; 
    z-index: 300; 
    backdrop-filter: blur(5px); 
    padding: 1rem; 
    opacity: 0; 
    transition: opacity 0.2s ease-in-out; 
}

#tarot-modal .modal-content { 
    background-color: #1e1e3f; 
    border: 1px solid #4a4a70; 
    border-radius: 16px; 
    padding: 2rem; 
    display: flex; 
    flex-direction: column; 
    align-items: center; 
    gap: 1.5rem; 
    width: 90%; 
    max-width: 800px; 
    max-height: 90vh; 
    overflow-y: auto; 
    position: relative; 
    box-shadow: 0 10px 30px rgba(0,0,0,0.5); 
}

#tarot-modal .modal-close { 
    position: absolute; 
    top: 1rem; 
    right: 1rem; 
    font-size: 2rem; 
    color: #a0a0c0; 
    cursor: pointer; 
    line-height: 1; 
}
#tarot-modal .modal-close:hover { color: #ffffff; }

#tarot-modal .modal-card-image { 
    width: 150px; 
    height: 255px; 
    object-fit: cover; 
    border-radius: 12px; 
    box-shadow: 0 5px 15px rgba(0,0,0,0.3); 
}
#tarot-modal .modal-card-image.inverted { 
    transform: rotate(180deg); 
}

#tarot-modal .modal-title { font-family: 'IM Fell English', serif; }

#tarot-modal .modal-symbology { 
    background: rgba(0,0,0,0.2); 
    border: 1px solid #4a4a70;
    border-radius: 8px; 
    padding: 0.75rem 1rem; 
    text-align: left;
}

/* Toast Notification (Used for "Link Copied") */
#toast-message {
    position: fixed;
    bottom: -100px;
    left: 50%;
    transform: translateX(-50%);
    background-color: #1e1e3f;
    border: 1px solid #c4b5fd;
    color: #e0e0e0;
    padding: 1rem 1.5rem;
    border-radius: 8px;
    z-index: 1000;
    box-shadow: 0 0 20px rgba(196, 181, 253, 0.3);
    transition: bottom 0.4s ease-in-out;
    text-align: center;
}
#toast-message.show {
    bottom: 30px;
}
        
/* --- RESPONSIVE STYLES --- */

@media (max-width: 768px) {
    /* Stack modal content vertically */
    #tarot-modal .modal-content { 
        flex-direction: column; 
        text-align: center; 
        max-width: 95%; 
    }
    
    #spread-container {
        padding: 1rem 0.5rem;
    }
}

@media (max-width: 540px) {
    /* Hide descriptions on small mobile - too cluttered */
    .position-description {
        display: none;
    }
}
/* --- Spread Picker Modal Polish --- */
#spread-picker-scroll {
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.18) transparent;
}
#spread-picker-scroll::-webkit-scrollbar {
    width: 10px;
}
#spread-picker-scroll::-webkit-scrollbar-track {
    background: transparent;
}
#spread-picker-scroll::-webkit-scrollbar-thumb {
    background-color: rgba(255,255,255,0.14);
    border-radius: 9999px;
    border: 3px solid transparent;
    background-clip: content-box;
}
#spread-picker-scroll::-webkit-scrollbar-thumb:hover {
    background-color: rgba(255,255,255,0.22);
}
