/* style_shuffle.css */

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    display: flex;
    justify-content: center;
    align-items: center; /* container 중앙 정렬 유지 */
    min-height: 100vh;
    background: linear-gradient(to right, #6a11cb, #2575fc);
    margin: 0;
    color: #fff;
    overflow-x: hidden; /* 필요하다면 유지 */
    padding: 20px;
    box-sizing: border-box;
    position: relative; 
    -webkit-user-select: none; /* 텍스트 드래그 방지 */
    -moz-user-select: none; /* 텍스트 드래그 방지 */
    -ms-user-select: none; /* 텍스트 드래그 방지 */
    user-select: none; /* 텍스트 드래그 방지 */
}

.container {
    text-align: center;
    background-color: rgba(0, 0, 0, 0.5);
    padding: 20px;
    border-radius: 15px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4);
    max-width: 1600px; /* 사용자 제공 파일에서 변경된 부분 */
    width: 100%;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    align-items: center;
}

h1 {
    margin-bottom: 1px;
    font-size: 2.5em;
    text-shadow: 2px 2px 5px rgba(0, 0, 0, 0.5);
}

/* h3 태그 자체가 없어지므로, 이 부분의 CSS는 완전히 삭제합니다. */
/* h3 {
    margin-bottom: 30px;
    font-size: 1em;
} */
h4, a {
    text-align: center !important;
    color: #ffff !important;
    font-size: 0.8rem !important;
    text-decoration: none;
    outline: none;
}

/* 버튼 그룹 스타일 */
.button-group {
    display: flex;
    gap: 15px;
    margin-top: 30px; 
    margin-bottom: 20px; 
    justify-content: center;
}

#shuffle-button {
    background-color: #ffcc00;
    color: #333;
    border: none;
    padding: 12px 25px;
    font-size: 1.1em;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.3s ease, transform 0.2s ease;
    font-weight: bold;
}

#shuffle-button:hover {
    background-color: #e6b800;
    transform: translateY(-2px);
}

#shuffle-button:active {
    transform: translateY(0);
}

/* 비활성화된 버튼 스타일 */
#shuffle-button:disabled {
    background-color: #999;
    color: #666;
    cursor: not-allowed;
    transform: none;
}

#tarot-deck {
    position: relative; /* 자식 요소인 #drag-instruction의 position: absolute 기준 */
    width: 90%;
    max-width: 1000px;
    min-height: 300px; 
    margin: 20px auto;
    perspective: 1000px;
    border: none;
    border-radius: 10px;
    transition: opacity 0.5s ease-out;
    box-sizing: border-box;
    overflow-x: hidden; 
    overflow-y: hidden;
    padding-bottom: 50px;
    display: block;
}

/* 섞기 애니메이션 중 덱 컨테이너 숨김 */
#tarot-deck.shuffling {
    opacity: 0;
    pointer-events: none;
}

/* 스크롤 래퍼 스타일 */
#card-scroll-wrapper {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    display: block;
}

/* card-wrapper는 #card-scroll-wrapper 내에서 절대 위치 */
.card-wrapper {
    position: absolute;
    width: 100px; /* PC/태블릿 기본값 */
    height: 160px; /* PC/태블릿 기본값 */
    cursor: pointer;
    transition: transform 0.8s ease, box-shadow 0.3s, border 0.3s, opacity 0.5s;
    transform-style: preserve-3d;
    opacity: 1;
    transform-origin: center 200px; /* PC/태블릿 기본값 */
}

/* 섞기 애니메이션 중 카드 개별 스타일 */
.card-wrapper.shuffling-animation {
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) rotateY(0deg) rotateZ(0deg) scale(0.5) !important;
    transition: transform 0.8s ease-out, opacity 0.8s ease-out, top 0.8s ease-out, left 0.8s ease-out;
    opacity: 0;
    pointer-events: none;
}

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

.card.flipped {
    transform: rotateY(180deg);
}

.card-face {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
    background-position: center;
    border: 3px solid #f0f0f0;
    box-sizing: border-box;
    background-size: contain;
    background-repeat: no-repeat;
}

.card-face.back {
    background-image: url('images/card_back.jpg');
    background-color: #000000;
    background-repeat: no-repeat;
    background-position: center;
    background-size: cover;
}

.card-face.front {
    transform: rotateY(180deg);
    background-color: #ffffff;
    background-position: center;
    background-size: contain;
}

.card-wrapper.selected {
    border: 3px solid #ffeb3b;
    box-shadow: 0 0 20px rgba(255, 235, 59, 0.8);
}

/* 중앙에 표시될 카드 스타일 (tarot-deck 내부 기준) */
#center-card-display {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.1);
    width: 200px; /* PC/태블릿 기본값 */
    height: 320px; /* PC/태블릿 기본값 */
    background-color: rgba(0, 0, 0, 0.8);
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.7);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    opacity: 0;
    visibility: hidden;
    transition: transform 0.5s ease-out, opacity 0.5s ease-out, visibility 0s linear 0.5s;
    padding: 20px;
    box-sizing: border-box;
    text-align: center;
}

#center-card-display.active {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
    visibility: visible;
    transition: transform 0.5s ease-out, opacity 0.5s ease-out, visibility 0s linear 0s;
}

#center-card-display img {
    max-width: 90%;
    max-height: 70%;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
    border: 3px solid #f0f0f0;
}

/* 중앙 카드 디스플레이에서 제목과 설명 숨기기 */
#center-card-display h3,
#center-card-display p {
    display: none;
}

#selected-cards-area {
    margin-top: 30px;
    background-color: rgba(255, 255, 255, 0.1);
    padding: 25px;
    border-radius: 10px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
    width: 100%;
    max-width: 1000px;
    box-sizing: border-box;
}

#selected-cards-container {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 15px;
    min-height: 150px;
    margin-top: 20px;
}

.selected-card-display {
    width: 120px; 
    text-align: center;
    color: #fff;
    position: relative;
    padding-top: 20px;
}

.selected-card-display .card-number {
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    background-color: #ffcc00;
    color: #333;
    font-weight: bold;
    font-size: 1.1em;
    padding: 5px 10px;
    border-radius: 50%;
    width: 25px;
    height: 25px;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
}

.selected-card-display img {
    width: 100%;
    height: auto;
    max-height: 190px; 
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.4);
    border: 3px solid #fff;
    margin-bottom: 10px;
    background-color: #ffffff;
    padding: 5px;
    box-sizing: border-box;
}

.selected-card-display h3 {
    margin: 10px 0 5px;
    font-size: 1.2em;
    color: #ffeb3b;
}

.selected-card-display p {
    font-size: 0.9em;
    line-height: 1.4;
    color: #e0e0e0;
}

/* instruction-message의 마진 조정 */
#instruction-message {
    font-size: 1.1em;
    margin-top: 20px; 
    margin-bottom: 20px; 
    color: #ffeb3b;
}

/* 드래그 안내 메시지 스타일 (tarot-deck에 상대적 위치) */
#drag-instruction {
    position: absolute; /* tarot-deck에 상대적으로 위치 */
    top: -40px; /* tarot-deck 위로 40px 올림 */
    left: 50%;
    transform: translateX(-50%);
    color: white;
    background-color: rgba(0, 0, 0, 0.7); 
    padding: 8px 15px; 
    border-radius: 8px; 
    font-size: 0.9em; 
    font-weight: bold; 
    z-index: 99; /* tarot-deck 내 다른 요소보다 높게 설정 */
    white-space: nowrap; 
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3); 
    text-align: center; 
    display: none; /* 기본적으로 숨김 (PC에서) */
}



/* 모바일 반응형 */
@media (max-width: 768px) {
    .container {
        padding: 15px;
    }

    h1 {
        font-size: 1.8em;
    }

    .button-group {
        flex-direction: column;
        gap: 10px;
    }

    #shuffle-button {
        padding: 10px 18px;
        font-size: 0.95em;
        width: 100%;
    }

    #tarot-deck {
        width: 100%;
        min-height: 300px;
        padding: 10px;
        padding-bottom: 40px;
        overflow-x: scroll;
        -webkit-overflow-scrolling: touch;
    }

    /* 스크롤바 숨기기 (모든 브라우저) */
    #tarot-deck::-webkit-scrollbar {
        display: none;
    }
    #tarot-deck {
        -ms-overflow-style: none;
        scrollbar-width: none;
    }

    #card-scroll-wrapper {
        position: absolute;
        top: 0;
        left: 0;
        height: 100%;
    }

    .card-wrapper {
        width: 90px;
        height: 145px;
        transform-origin: center 185px;
    }

    /* 중앙 카드 디스플레이 모바일 조정 */
    #center-card-display {
        width: 200px;
        height: 320px;
        padding: 10px;
    }
    #center-card-display h3,
    #center-card-display p {
        display: none;
    }

    .selected-card-display {
        width: 110px;
        padding-top: 15px;
    }

    .selected-card-display img {
        height: auto;
        max-height: 165px;
        padding: 3px;
    }

    #instruction-message {
        margin-top: 10px;
        margin-bottom: 15px;
    }

    /* 모바일에서 drag-instruction 보이게 설정 */
    #drag-instruction {
        display: block; /* 모바일에서만 보임 */
        top: 250px; /* tarot-deck 바로 위에 위치하도록 조정 */
        font-size: 0.85em; 
        padding: 6px 12px;
    }
}

