@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap');

:root {
    --bg-gray: #C6C6C6;
    --border-white: #FFFFFF;
    --border-dark: #555555;
    --slot-bg: #8B8B8B;
    --slot-border: #373737;
}

* {
    box-sizing: border-box;
    font-family: 'Press Start 2P', cursive;
    image-rendering: pixelated;
}

/* Global Dragging State */
body.is-dragging, 
body.is-dragging * {
    cursor: grabbing !important;
}

body, html {
    margin: 0;
    height: 100%;
    background: #111;
    overflow: hidden;
}

.background-parallax {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-image: url('./BG/mine.png'); 
    background-size: cover;
    background-position: center;
    z-index: 0; 
    transform: scale(1.15);
    transition: transform 0.4s cubic-bezier(0.23, 1, 0.32, 1); 
    will-change: transform;
}

.screen-overlay {
    width: 100vw;
    height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
    background-color: rgba(0, 0, 0, 0.6); 
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10; 
    pointer-events: none; 
}

.inventory-scaler {
    transform: scale(1.8);
    display: flex;
    justify-content: center;
    align-items: center;
    pointer-events: auto;
    position: relative;
    z-index: 1000;      
}

.inventory-container {
    background: var(--bg-gray);
    border: 3px solid;
    border-color: var(--border-white) var(--border-dark) var(--border-dark) var(--border-white);
    padding: 10px;
    box-shadow: 4px 4px 0 rgba(0,0,0,0.6);
    border-radius: 2px;
}

.upper-section {
    display: flex;
    gap: 0;
    margin-bottom: 8px;
    width: 100%;
    align-items: flex-start;
}

.character-preview {
    position: relative;
}

.character-box {
    width: 95px;
    height: 128px;
    background-image: url('./BG/cherry.png'); 
    background-size: cover;
    border: 2px solid var(--slot-border);
    border-color: var(--slot-border) var(--border-white) var(--border-white) var(--slot-border);
    display: flex;
    justify-content: center;
    align-items: center; /* Changed from flex-end to center for the 3D model */
    overflow: hidden;
}

/* 3D Model Specific Style */
model-viewer {
    width: 100%;
    height: 100%;
    --poster-color: transparent;
    outline: none;
    /* KEY ADDITIONS BELOW */
    image-rendering: optimizeQuality;
}

.cherry-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url('./BG/cherryfall.gif'); 
    background-size: cover;
    background-repeat: no-repeat;
    pointer-events: none; 
    opacity: 0.8; 
    z-index: 5;
}

.character-name {
    position: absolute;
    top: -6px; 
    left: 50%; 
    transform: translateX(-50%);
    background-color: rgba(0, 0, 0, 0.5); 
    color: #e0e0e0;
    padding: 2px 5px;
    font-size: 6px; 
    white-space: nowrap;
    z-index: 10;
    text-shadow: 1px 1px 0px #222;
}

.extra-slots {
    display: flex;
    align-items: flex-end;
    height: 128px;
    padding-left: 0px;
    padding-bottom: 0px;
}

.crafting-area {
    flex: 1; 
    display: flex;
    flex-direction: column;
    justify-content: center; 
    align-items: center;
}

.crafting-layout {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0; 
    position: relative;
    padding-top: 20px;
}

.crafting-area .label {
    position: absolute;
    top: 0;
    left: 32px; 
    transform: translateX(-50%);
    font-size: 10px;
    letter-spacing: -1px;
    color: #3f3f3f;
    margin: 0;
    white-space: nowrap;
}

.slot {
    width: 32px;
    height: 32px;
    background: var(--slot-bg);
    border: 2px solid;
    border-color: var(--slot-border) var(--border-white) var(--border-white) var(--slot-border);
    position: relative;
    cursor: pointer;
}

.item-sprite {
    max-width: 28px;
    max-height: 28px;
    image-rendering: optimizeQuality;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    pointer-events: auto;
}

.item-icon {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100%;
    font-size: 16px; 
    pointer-events: auto;
}

.armor-slots { display: flex; flex-direction: column; gap: 0px; }
.crafting-grid { display: grid; grid-template-columns: repeat(2, 32px); gap: 0px; }
.grid { display: grid; grid-template-columns: repeat(9, 32px); gap: 0px; }

.arrow {
    width: 25px;
    height: 22px;
    background: #555;
    margin: 0 3px;
    clip-path: polygon(0% 35%, 60% 35%, 60% 0%, 100% 50%, 60% 100%, 60% 65%, 0% 65%);
    border-bottom: 2px solid #373737;
}

.main-grid { margin-top: 4px; }
.hotbar-grid { margin-top: 8px; }

.stack-count {
    position: absolute;
    bottom: 2px;
    right: 2px;
    color: white;
    font-size: 6px;
    text-shadow: 1px 1px 0 #000;
}

.mc-tooltip {
    visibility: hidden;
    position: absolute;
    top: 50%;
    left: 110%; 
    transform: translateY(-50%);
    background: rgba(16, 1, 16, 1);
    border: 2px solid #2d055a; 
    border-radius: 2px;
    padding: 6px 8px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 4px;
    pointer-events: none;
    
    /* --- THE FIX --- */
    max-width: 240px;       /* Only expand to this width, then wrap */
    width: max-content;     /* Shrink the box to fit short text */
    white-space: pre-wrap;  /* Respect \n and wrap at max-width */
    word-wrap: break-word;
}

.tooltip-name { 
    color: #FFFFFF; 
    font-size: 8px; 
    font-weight: bold;
    white-space: pre-wrap; 
}

.tooltip-desc { 
    color: #AA00AA; 
    font-size: 7px; 
    line-height: 1.4;
    white-space: pre-wrap; 
}

.slot:hover .mc-tooltip { visibility: visible; }

.slot.dragging {
    opacity: 0.2; 
    background-color: #555 !important;
}

.slot:hover::after {
    content: "";
    position: absolute;
    top: 0;
    right: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(255, 255, 255, 0.3);
    pointer-events: none;
    z-index: 1;
}

.item-sprite, .item-icon, .stack-count { z-index: 2; }

.placed-sign {
    position: fixed;
    min-width: 48px;
    min-height: 24px;
    max-width: 96px;
    max-height: 48px;
    background: #f8dfa1;
    border: 1px solid #5d442a;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 2px; 
    text-align: center;
    font-size: 7px;
    line-height: 1.7;
    word-wrap: break-word;
    cursor: pointer;
    z-index: 50;
    transform: translate(-50%, -50%);
}

.placed-sign span { display: block; width: 100%; overflow: hidden; }

.dragging .mc-tooltip { display: none !important; }

.armor-slots .slot, .offhand-slot, .crafting-grid .slot, .result-slot {
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
}

/* POPUP STYLES */
.popup-dimmer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.8);
    z-index: 10000;
    display: none; /* Hidden by default */
    justify-content: center;
    align-items: center;
    pointer-events: auto;
}

.popup-dimmer.active {
    display: flex;
}

.popup-box {
    width: 560px;
    background: rgba(16, 1, 16, 1);
    border: 3px solid #2d055a;
    padding: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    box-shadow: 0 0 20px rgba(0,0,0,0.5);
    border-radius: 3px;
}

.popup-header {
    color: #FFFFFF;
    font-size: 17px;
    margin-bottom: 10px;
    text-align: center;
    width: 100%;
    border-bottom: 2px solid #2d055a;
    padding-bottom: 5px;
}

.popup-body {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    margin-bottom: 15px;
}

#popupImage {
    width: 100%;          /* Scale up to fit the 560px box */
    max-width: 500px;   
    max-height: 500px;  /* Your desired max size */
    height: auto;         /* Keep proportions correct */
    object-fit: contain;
    margin: 15px 0;
    /* Remove image-rendering: pixelated; if this is a high-res photo */
}

#popupText {
    color: #FFFFFF;
    font-size: 12px;
    line-height: 1.5;
    text-align: center;
    font-family: 'Press Start 2P', cursive;
}

.popup-close-btn {
    background: var(--bg-gray);
    border: 2px solid;
    border-color: var(--border-white) var(--border-dark) var(--border-dark) var(--border-white);
    padding: 6px 12px;
    font-size: 8px;
    cursor: pointer;
    color: #3f3f3f;
    outline: none;
}

.popup-close-btn:active {
    border-color: var(--border-dark) var(--border-white) var(--border-white) var(--border-dark);
}

/* Replace .nut-count-overlay with this */
.nut-floating-text {
    position: absolute;
    top: -13px;
    left: 50%;
    transform: translateX(-50%);
    color: white;
    font-family: 'Press Start 2P', cursive;
    font-size: 8px; /* Small to fit the slot UI */
    text-shadow: 1px 1px 0px #000;
    pointer-events: none;
    z-index: 2000;
    white-space: nowrap;
    animation: nutFloatUp 3s ease-out forwards;
}

/* The "Floating Up" animation */
@keyframes nutFloatUp {
    0% {
        opacity: 1;
        transform: translate(-50%, 0);
    }
    100% {
        opacity: 0;
        transform: translate(-50%, -40px); /* Moves up 40px */
    }
}

/* Crucial: Ensure the slot doesn't cut off the floating text */
.slot {
    position: relative;
    overflow: visible !important;
}
/* Subtle White Glow for the Item Only */
.nut-item-glow {
    filter: 
        brightness(1.5) 
        drop-shadow(0 0 3px rgba(255, 255, 255, 0.7)) !important;
    /* Keeps it centered while giving a tiny 'click' zoom */
    transform: translate(-50%, -50%) scale(1.1) !important;
    z-index: 100;
}

/* Smooth transition back to normal */
.item-sprite, .item-icon {
    transition: filter 0.2s ease, transform 0.1s ease;
}

/* Tarot Overlay */
.tarot-overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.85);
    z-index: 200;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: white;
    font-family: 'Minecraft', sans-serif;
}

.tarot-overlay.active { display: flex; }

.tarot-display {
    display: flex;
    gap: 20px;
    margin-top: 20px;
}
/* The container for the choices (1 card vs 10 cards) */
.tarot-options {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    gap: 70px; /* INCREASE THIS to spread them out more */
    margin-top: 40px;
}

.tarot-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    transition: transform 0.3s ease;
    width: 160px; /* Constrains the width for better centering */
}

.tarot-option img {
    width: 220px; /* Larger, clearer icons */
    height: auto;
    margin-bottom: 20px;
    border: 2px solid transparent;
    transition: all 0.3s ease;
    filter: drop-shadow(0 5px 15px rgba(0,0,0,0.5));
}

.tarot-option span {
    font-size: 15px; /* Matching your pixel-font style */
    color: #C6C6C6;
    text-align: center;
    line-height: 1.5;
    transition: color 0.4s ease;
}

/* Hover Effects */
.tarot-option:hover img {
    transform: translateY(-20px); /* Card lifts up */
    filter: drop-shadow(0 0 10px #ffd700); /* Gold glow */
}

.tarot-option:hover span {
    color: #ffd700; /* Text turns gold on hover */
}

.tarot-card {
    width: 220px; 
    height: 320px;
    perspective: 2000px;
    cursor: pointer;
    border-radius: 18px; 
    filter: drop-shadow(0 0 2px rgba(0,0,0,0.7));
    transition: transform 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275), filter 0.3s ease;
}

/* The Gold Mystic Highlight from your image */
.tarot-card:hover, .tarot-card.flipped {
    filter: 
        drop-shadow(0 0 1px #ffd700) 
        drop-shadow(0 0 4px rgba(255, 215, 0, 0.8));
    transform: scale(1.1);
}

.card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    transition: transform 1s;
    transform-style: preserve-3d;
}

.tarot-card.flipped .card-inner {
    transform: rotateY(180deg);
}

.card-front, .card-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    /* We remove 'border' and use 'contain' to keep the card's natural shape */
    background-size: 100% 100%; 
    background-repeat: no-repeat;
    background-position: center;
    image-rendering: auto; /* Use auto for high-res art like your Chariot card */
    border-radius: 12px; /* Adjust this number to match the face image curve */
    overflow: hidden;    /* This forces the image to chop off at the corners */
    /* --------------- */
}

.card-back { 
    background-image: url('Tarot/Tarot_Back.jpg'); 
}

.card-front { 
    transform: rotateY(180deg); 
}

/* Celtic Cross Layout Controller */
/* The Main Celtic Spread Container */
.tarot-display.celtic-layout {
    display: grid;
    /* 3 columns for the cross, 1 gap, 1 for the staff */
    grid-template-columns: repeat(3, 230px) 200px 230px;
    /* Shorter rows (110px) allow cards to overlap vertically like your image */
    grid-template-rows: repeat(4, 200px); 
    gap: 15px;
    align-items: center;
    justify-content: center;
    padding: 60px;
    /* Scale the entire layout to ensure it fits the viewport */
    transform: scale(0.7); 
    transform-origin: center center;
}

/* Positioning each card in the Celtic Pattern */
/* Card 1: The Heart (Bottom) */
.c-1 { 
    grid-column: 2; 
    grid-row: 2 / 4; 
    z-index: 2; 
    justify-self: center; 
}

/* Card 2: The Challenge (Top) */
.c-2 { 
    grid-column: 2; 
    grid-row: 2 / 4; 
    z-index: 10; 
    justify-self: center; 
    /* Remove transform from here! */
}

/* Card 2 Inner: Handle the 90deg rotation here instead */
.c-2 .card-inner {
    transform: rotate(90deg);
    transition: transform 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Card 2 Flipped AND Slid to the side */
/* We combine the Flip (rotateY), the Layout (rotate), and the Move (translateX) */
.c-2.flipped .card-inner { 
    transform: rotateY(180deg) rotate(90deg) translateX(240px) translateY(-450px)  !important; 
}
/* 1. When Card 2 is flipped, make the main container "click-through" */
.c-2.flipped {
    pointer-events: none; 
}

/* 2. Re-enable clicking ONLY on the visual card that moved to the side */
.c-2.flipped .card-inner {
    pointer-events: auto;
}
/* Ensure hover doesn't break the slide */
.c-2.flipped:hover .card-inner {
    transform: rotateY(180deg) rotate(90deg) translateX(240px) translateY(-450px)  !important; 
}
.c-3 { grid-column: 2; grid-row: 1; justify-self: center; } /* Goal */
.c-4 { grid-column: 2; grid-row: 4; justify-self: center; } /* Root */
.c-5 { grid-column: 1; grid-row: 2 / 4; justify-self: center; } /* Past */
.c-6 { grid-column: 3; grid-row: 2 / 4; justify-self: center; } /* Future */

/* The Staff (Vertical line on the right) */
.c-7 { grid-column: 5; grid-row: 4; } /* Self */
.c-8 { grid-column: 5; grid-row: 3; } /* Environment */
.c-9 { grid-column: 5; grid-row: 2; } /* Hopes/Fears */
.c-10 { grid-column: 5; grid-row: 1; } /* Outcome */

/* Make the overlay scrollable in case the large cards exceed screen height */
.tarot-overlay {
    overflow-y: auto;
    padding: 100px 0;
}

.tarot-card:hover {
    z-index: 1000; /* Bring hovered card to the very front */
    transform: scale(1.2) translateY(-10px); /* Zoom in 20% */
    filter: 
        drop-shadow(0 0 2px #ffd700) 
        drop-shadow(0 0 12px rgba(255, 215, 0, 0.8));
}

#tarotStatus {
    margin-bottom: 60px; /* Pushes the options/cards further down */
    margin-top: 20px;
    font-size: 20px;
    color: #ffd700;
    text-shadow: 2px 2px 0 #000;
    z-index: 10;
}

/* Shuffling Animation */
.shuffling-pile {
    position: relative;
    width: 220px;
    height: 320px;
    margin: 0 auto;
}

.shuffling-card {
    position: absolute;
    width: 100%;
    height: 100%;
    background: url('Tarot/Tarot_Back.jpg') no-repeat center; /* Or your card back image */
    background-size: cover;
    border-radius: 18px;
    filter: 
      drop-shadow(0 0 1px #ffd700) 
      drop-shadow(0 0 4px rgba(255, 215, 0, 0.8));
    animation: shuffle-move 0.5s infinite ease-in-out;
}

/* Offset each card's animation slightly */
.shuffling-card:nth-child(2) { animation-delay: 0.1s; }
.shuffling-card:nth-child(3) { animation-delay: 0.2s; }

@keyframes shuffle-move {
    0% { transform: translate(0, 0) rotate(0deg); z-index: 1; }
    50% { transform: translate(60px, -10px) rotate(10deg); z-index: 5; }
    100% { transform: translate(0, 0) rotate(0deg); z-index: 1; }
}

#aiReadingBtn {
    /* Base matching your Exit button */
    background: #4a2c5e; /* Mystic Purple Background */
    border: 2px solid;
    /* Mystic Gold Bevel: Bright top/left, Dark bronze bottom/right */
    border-color: #ffe066 #704d00 #704d00 #ffe066; 
    padding: 6px 12px;
    font-size: 12px;
    cursor: pointer;
    color: #ffe066; /* Golden text */
    outline: none;
    font-family: 'Minecraft', sans-serif;
    text-shadow: 1px 1px 0px #2a103d; /* Dark shadow for contrast */
    image-rendering: pixelated;
    display: inline-block;
    vertical-align: middle;
}

#aiReadingBtn:hover {
    background: #5e3a76; /* Lighter purple on hover */
    border-color: #ffffff #a38200 #a38200 #ffffff; /* Brighter gold highlight */
    color: #ffffff;
}

#aiReadingBtn:active {
    /* "Pressed" state: Flip the border colors */
    border-color: #704d00 #ffe066 #ffe066 #704d00;
    padding-top: 7px;
    padding-bottom: 5px;
}

.wiki-card {
    background: white;
    padding: 25px;
    border-radius: 12px;
    border: 3px solid #36c;
    display: flex;
    flex-direction: column;
    text-align: left;
    text-decoration: none; /* Removes link underline */
    color: inherit;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.wiki-card:hover {
    transform: scale(1.05) translateY(-5px);
    border-color: #5d8fff;
    box-shadow: 0 0 20px rgba(93, 143, 255, 0.6), 
                inset 0 0 10px rgba(255, 255, 255, 0.5);
}

/* The "Shine" overlay effect */
.wiki-card::after {
    content: "";
    position: absolute;
    top: -50%;
    left: -60%;
    width: 20%;
    height: 200%;
    background: rgba(255, 255, 255, 0.3);
    transform: rotate(30deg);
    transition: all 0.5s;
    opacity: 0;
}

.wiki-card:hover::after {
    left: 120%;
    opacity: 1;
}
