/**
 * 포춘쿠키 팝업/배너 스타일
 */

/* ========================================
   팝업 오버레이
======================================== */
.fortune-cookie-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    padding: 20px;
}

.fortune-cookie-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* ========================================
   팝업 컨테이너
======================================== */
.fortune-cookie-popup {
    background: linear-gradient(135deg, #FFFFFF 0%, #F8F9FC 100%);
    border-radius: 24px;
    padding: 32px 24px;
    max-width: 340px;
    width: 100%;
    text-align: center;
    position: relative;
    box-shadow: 0 20px 60px rgba(139, 92, 246, 0.25);
    border: 1px solid rgba(139, 92, 246, 0.1);
    transform: scale(0.9) translateY(20px);
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.fortune-cookie-popup.active {
    transform: scale(1) translateY(0);
    opacity: 1;
}

/* 다크 모드 */
html.dark .fortune-cookie-popup {
    background: linear-gradient(135deg, #1A1A2E 0%, #16162A 100%);
    border: 1px solid rgba(139, 92, 246, 0.2);
}

/* ========================================
   닫기 버튼
======================================== */
.fortune-cookie-close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 32px;
    height: 32px;
    border: none;
    background: rgba(0, 0, 0, 0.05);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.fortune-cookie-close:hover {
    background: rgba(0, 0, 0, 0.1);
}

.fortune-cookie-close .material-symbols-outlined {
    font-size: 18px;
    color: var(--text-secondary, #6B7280);
}

html.dark .fortune-cookie-close {
    background: rgba(255, 255, 255, 0.1);
}

html.dark .fortune-cookie-close:hover {
    background: rgba(255, 255, 255, 0.15);
}

/* ========================================
   쿠키 아이콘
======================================== */
.fortune-cookie-icon {
    font-size: 72px;
    margin-bottom: 16px;
    cursor: pointer;
    transition: transform 0.2s ease;
}

.fortune-cookie-icon:hover {
    transform: scale(1.1);
}

/* 흔들리는 애니메이션 (클릭 유도) */
.fortune-cookie-icon.shake {
    animation: cookieShake 1.5s ease-in-out infinite;
}

@keyframes cookieShake {
    0%, 100% { transform: rotate(0deg) scale(1); }
    10% { transform: rotate(-10deg) scale(1.05); }
    20% { transform: rotate(10deg) scale(1.05); }
    30% { transform: rotate(-10deg) scale(1.05); }
    40% { transform: rotate(10deg) scale(1.05); }
    50% { transform: rotate(0deg) scale(1); }
}

/* 클릭 힌트 */
.fortune-cookie-hint {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 0.95rem;
    color: var(--text-secondary, #6B7280);
    margin-top: 12px;
    animation: hintPulse 2s ease-in-out infinite;
}

html.dark .fortune-cookie-hint {
    color: #A0A0A0;
}

.tap-icon {
    font-size: 1.2rem;
    animation: tapBounce 1s ease-in-out infinite;
}

@keyframes tapBounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-5px); }
}

@keyframes hintPulse {
    0%, 100% { opacity: 0.7; }
    50% { opacity: 1; }
}

/* 깨지기 전 상태 컨테이너 */
.fortune-cookie-unbroken {
    cursor: pointer;
    text-align: center;
}

/* 깨지는 애니메이션 */
.fortune-cookie-unbroken.breaking {
    animation: cookieBreak 0.4s ease-out forwards;
}

@keyframes cookieBreak {
    0% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.2); }
    100% { transform: scale(0); opacity: 0; }
}

/* 깨진 후 상태 */
.fortune-cookie-broken {
    text-align: center;
}

.fortune-cookie-broken.revealed {
    animation: revealContent 0.5s ease-out forwards;
}

@keyframes revealContent {
    0% { opacity: 0; transform: scale(0.8); }
    100% { opacity: 1; transform: scale(1); }
}

/* 깨진 쿠키 아이콘 */
.fortune-cookie-icon-broken {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    font-size: 48px;
    margin-bottom: 16px;
}

.cookie-piece {
    display: inline-block;
}

.cookie-piece.left {
    transform: rotate(-20deg) translateX(5px);
    animation: pieceLeft 0.5s ease-out forwards;
}

.cookie-piece.right {
    transform: rotate(20deg) translateX(-5px) scaleX(-1);
    animation: pieceRight 0.5s ease-out forwards;
}

.cookie-sparkle {
    font-size: 32px;
    animation: sparkle 1s ease-in-out infinite;
}

@keyframes pieceLeft {
    0% { transform: rotate(0) translateX(0); opacity: 0; }
    100% { transform: rotate(-20deg) translateX(5px); opacity: 1; }
}

@keyframes pieceRight {
    0% { transform: rotate(0) translateX(0) scaleX(-1); opacity: 0; }
    100% { transform: rotate(20deg) translateX(-5px) scaleX(-1); opacity: 1; }
}

@keyframes sparkle {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.3); opacity: 0.8; }
}

/* ========================================
   타이틀
======================================== */
.fortune-cookie-title {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--text-primary, #1F2937);
    margin-bottom: 12px;
}

html.dark .fortune-cookie-title {
    color: #F5F5F5;
}

/* ========================================
   카테고리 뱃지
======================================== */
.fortune-cookie-category {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 20px;
}

/* ========================================
   메시지
======================================== */
.fortune-cookie-message {
    font-size: 1.1rem;
    line-height: 1.7;
    color: var(--text-primary, #1F2937);
    margin-bottom: 24px;
    padding: 0 8px;
    font-style: italic;
}

html.dark .fortune-cookie-message {
    color: #E5E5E5;
}

/* ========================================
   확인 버튼
======================================== */
.fortune-cookie-confirm {
    width: 100%;
    padding: 14px 24px;
    background: linear-gradient(135deg, #8B5CF6 0%, #EC4899 100%);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(139, 92, 246, 0.3);
}

.fortune-cookie-confirm:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(139, 92, 246, 0.4);
}

.fortune-cookie-confirm:active {
    transform: translateY(0);
}

/* ========================================
   하단 배너
======================================== */
.fortune-cookie-banner {
    position: fixed;
    bottom: calc(64px + env(safe-area-inset-bottom));
    left: 16px;
    right: 16px;
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.95) 0%, rgba(236, 72, 153, 0.95) 100%);
    backdrop-filter: blur(10px);
    border-radius: 16px;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    z-index: 999;
    box-shadow: 0 4px 20px rgba(139, 92, 246, 0.4);
    transform: translateY(100px);
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.fortune-cookie-banner.active {
    transform: translateY(0);
    opacity: 1;
}

.fortune-banner-content {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    cursor: pointer;
    color: white;
}

.fortune-banner-icon {
    font-size: 1.5rem;
}

.fortune-banner-text {
    font-size: 0.9rem;
    font-weight: 500;
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.fortune-banner-arrow {
    font-size: 1.2rem;
    font-weight: 700;
}

.fortune-banner-close {
    width: 28px;
    height: 28px;
    border: none;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: 8px;
    transition: all 0.2s ease;
}

.fortune-banner-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

.fortune-banner-close .material-symbols-outlined {
    font-size: 16px;
    color: white;
}

/* ========================================
   캐릭터 이미지
======================================== */
.fortune-cookie-character {
    margin-bottom: 12px;
}

.bear-character {
    width: 80px;
    height: 80px;
    object-fit: contain;
    animation: characterBounce 1s ease-in-out;
}

@keyframes characterBounce {
    0% { transform: scale(0) rotate(-10deg); opacity: 0; }
    50% { transform: scale(1.1) rotate(5deg); }
    100% { transform: scale(1) rotate(0); opacity: 1; }
}

/* ========================================
   음성 버튼
======================================== */
.fortune-cookie-voice-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    margin-bottom: 16px;
    background: rgba(139, 92, 246, 0.1);
    border: 2px solid rgba(139, 92, 246, 0.3);
    border-radius: 25px;
    color: #8B5CF6;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.fortune-cookie-voice-btn:hover {
    background: rgba(139, 92, 246, 0.2);
    border-color: #8B5CF6;
    transform: scale(1.05);
}

.fortune-cookie-voice-btn.playing {
    background: #8B5CF6;
    color: white;
    border-color: #8B5CF6;
}

.fortune-cookie-voice-btn .voice-icon {
    font-size: 20px;
}

html.dark .fortune-cookie-voice-btn {
    background: rgba(139, 92, 246, 0.2);
    border-color: rgba(139, 92, 246, 0.4);
}

html.dark .fortune-cookie-voice-btn:hover {
    background: rgba(139, 92, 246, 0.3);
}

/* ========================================
   반응형
======================================== */
@media (max-width: 380px) {
    .fortune-cookie-popup {
        padding: 24px 16px;
    }

    .fortune-cookie-icon {
        font-size: 48px;
    }

    .fortune-cookie-title {
        font-size: 1.1rem;
    }

    .fortune-cookie-message {
        font-size: 1rem;
    }

    .fortune-banner-text {
        font-size: 0.8rem;
    }
}

/* footer-nav가 없는 페이지용 */
@media (max-width: 768px) {
    .fortune-cookie-banner {
        bottom: calc(70px + env(safe-area-inset-bottom));
    }
}

/* ========================================
   포춘 쿠키 히어로 섹션 (인라인)
======================================== */
.fortune-hero {
    background: linear-gradient(135deg, #FFFFFF 0%, #F8F5FF 50%, #FFF5F8 100%);
    border-radius: 16px;
    padding: 12px 14px 14px;
    text-align: center;
    box-shadow: 0 4px 24px rgba(139, 92, 246, 0.12);
    border: 1px solid rgba(139, 92, 246, 0.1);
    position: relative;
    overflow: hidden;
    margin-top: -12px !important;
}

html.dark .fortune-hero {
    background: linear-gradient(135deg, #1A1A2E 0%, #1F1B3D 50%, #2A1F35 100%);
    border: 1px solid rgba(139, 92, 246, 0.2);
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
}

/* 배경 장식 */
.fortune-hero::before {
    content: '✨';
    position: absolute;
    top: 8px;
    left: 12px;
    font-size: 14px;
    opacity: 0.4;
    animation: twinkle 2s ease-in-out infinite;
}

.fortune-hero::after {
    content: '🌟';
    position: absolute;
    top: 10px;
    right: 12px;
    font-size: 12px;
    opacity: 0.4;
    animation: twinkle 2s ease-in-out infinite 0.5s;
}

@keyframes twinkle {
    0%, 100% { opacity: 0.3; transform: scale(1); }
    50% { opacity: 0.7; transform: scale(1.2); }
}

/* 깨지기 전 상태 */
.fortune-hero-unbroken {
    cursor: pointer;
    transition: transform 0.2s ease;
}

.fortune-hero-unbroken:hover {
    transform: scale(1.02);
}

.fortune-hero-unbroken:active {
    transform: scale(0.98);
}

.fortune-hero-cookie {
    font-size: 56px;
    margin-bottom: 8px;
    animation: heroShake 2s ease-in-out infinite;
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.1));
}

@keyframes heroShake {
    0%, 100% { transform: rotate(0deg); }
    10% { transform: rotate(-8deg); }
    20% { transform: rotate(8deg); }
    30% { transform: rotate(-8deg); }
    40% { transform: rotate(8deg); }
    50%, 100% { transform: rotate(0deg); }
}

.fortune-hero-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary, #1F2937);
    margin-bottom: 4px;
    background: linear-gradient(135deg, #8B5CF6 0%, #EC4899 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.fortune-hero-hint {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-size: 0.85rem;
    color: var(--text-secondary, #6B7280);
    animation: hintPulse 2s ease-in-out infinite;
}

.fortune-hero-hint .tap-icon {
    animation: tapBounce 1s ease-in-out infinite;
}

/* 깨지는 애니메이션 */
.fortune-hero-unbroken.breaking {
    animation: heroCookieBreak 0.4s ease-out forwards;
}

@keyframes heroCookieBreak {
    0% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.3); }
    100% { transform: scale(0); opacity: 0; }
}

/* 깨진 후 상태 */
.fortune-hero-broken {
    display: flex;
    flex-direction: column;
    align-items: center;
    animation: heroReveal 0.5s ease-out forwards;
}

@keyframes heroReveal {
    0% { opacity: 0; transform: scale(0.8); }
    100% { opacity: 1; transform: scale(1); }
}

/* ========================================
   개선안: 쿠키 + 카테고리 헤더 (인라인)
======================================== */
.fortune-hero-header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-bottom: 12px;
}

.fortune-hero-cookie-broken {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    font-size: 32px;
    margin-bottom: 8px;
}

.fortune-hero-cookie-broken .piece-left {
    transform: rotate(-20deg) translateX(6px);
    animation: heroPieceLeft 0.5s ease-out forwards;
}

.fortune-hero-cookie-broken .piece-right {
    transform: rotate(20deg) translateX(-6px) scaleX(-1);
    animation: heroPieceRight 0.5s ease-out forwards;
}

.fortune-hero-cookie-broken .sparkle {
    font-size: 20px;
    animation: heroSparkle 1.5s ease-in-out infinite;
}

@keyframes heroPieceLeft {
    0% { transform: rotate(0) translateX(0); opacity: 0; }
    100% { transform: rotate(-20deg) translateX(6px); opacity: 1; }
}

@keyframes heroPieceRight {
    0% { transform: rotate(0) translateX(0) scaleX(-1); opacity: 0; }
    100% { transform: rotate(20deg) translateX(-6px) scaleX(-1); opacity: 1; }
}

@keyframes heroSparkle {
    0%, 100% { transform: scale(1) rotate(0deg); opacity: 1; }
    50% { transform: scale(1.2) rotate(10deg); opacity: 0.8; }
}

/* 카테고리 뱃지 (컴팩트) */
.fortune-hero-category {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    background: rgba(139, 92, 246, 0.12);
    color: #8B5CF6;
    white-space: nowrap;
    margin-bottom: 10px;
}

html.dark .fortune-hero-category {
    background: rgba(139, 92, 246, 0.25);
    color: #A78BFA;
}

/* 메시지 (동적 정렬 지원) */
.fortune-hero-message {
    font-size: 1rem;
    line-height: 1.65;
    color: var(--text-primary, #1F2937);
    margin-bottom: 16px;
    padding: 0 8px;
    font-weight: 600;
    text-align: center;
    /* JavaScript로 길이에 따라 text-align 변경 */
}

.fortune-hero-message.long-text {
    text-align: left;
    font-style: italic;
}

html.dark .fortune-hero-message {
    color: #E5E5E5;
}

/* CTA 버튼 (더 컴팩트) */
.fortune-hero-cta {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 18px;
    background: linear-gradient(135deg, #8B5CF6 0%, #EC4899 100%);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 3px 12px rgba(139, 92, 246, 0.35);
}

.fortune-hero-cta:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 18px rgba(139, 92, 246, 0.45);
}

.fortune-hero-cta:active {
    transform: translateY(0);
}

.fortune-hero-cta .material-symbols-outlined {
    font-size: 18px;
}

/* 반응형 */
@media (max-width: 380px) {
    .fortune-hero {
        padding: 16px 12px;
    }

    .fortune-hero-cookie {
        font-size: 48px;
    }

    .fortune-hero-cookie-broken {
        font-size: 28px;
    }

    .fortune-hero-title {
        font-size: 1.05rem;
    }

    .fortune-hero-message {
        font-size: 0.9rem;
    }

    .fortune-hero-cta {
        padding: 9px 16px;
        font-size: 0.85rem;
    }
}
