/* 基础样式重置 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    overflow: visible; /* 允许内容超出可视区域 */
}

body {
    font-family: 'Microsoft YaHei', Arial, sans-serif;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    overflow: visible; /* 确保弹窗不会被隐藏 */
}

/* 触发按钮样式 - 更符合页面风格 */
.blessing-btn {
    background: #ffffff;
    color: #666;
    border: 2px solid #e0e0e0;
    padding: 12px 24px;
    font-size: 16px;
    font-weight: 500;
    border-radius: 12px;
    cursor: pointer;
    box-shadow: 
        0 2px 8px rgba(0, 0, 0, 0.1),
        0 1px 3px rgba(0, 0, 0, 0.08);
    transition: all 0.3s ease;
    z-index: 100;
    position: relative;
    font-family: 'Microsoft YaHei', '微软雅黑', Arial, sans-serif;
    
    /* 纸质效果 */
    background-image: 
        radial-gradient(circle at 30% 40%, rgba(120, 119, 198, 0.02) 0%, transparent 50%),
        radial-gradient(circle at 70% 60%, rgba(255, 119, 198, 0.02) 0%, transparent 50%);
}

.blessing-btn:hover {
    transform: translateY(-1px);
    box-shadow: 
        0 4px 12px rgba(0, 0, 0, 0.15),
        0 2px 6px rgba(0, 0, 0, 0.1);
    border-color: #d0d0d0;
    color: #555;
}

.blessing-btn:active {
    transform: translateY(0);
    box-shadow: 
        0 1px 4px rgba(0, 0, 0, 0.1),
        0 1px 2px rgba(0, 0, 0, 0.08);
}

/* 按钮生成状态 */
.blessing-btn.generating {
    background: #f8f9fa;
    color: #888;
    border-color: #e8e8e8;
    cursor: default;
    animation: pulse 2s infinite;
}

/* 按钮禁用状态 */
.blessing-btn:disabled {
    background: #f0f0f0;
    color: #ccc;
    border-color: #e0e0e0;
    cursor: not-allowed;
    transform: none;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

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

/* 弹窗容器 */
.popup-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 999;
    overflow: visible; /* 确保弹窗可以完全显示 */
}

/* 标签纸风格弹窗 */
.blessing-popup {
    position: absolute;
    pointer-events: auto;
    transform-origin: center center;
    transition: transform 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    z-index: 200;
    cursor: pointer;
}

/* 弹窗悬停效果 - 提升到最上层 */
.blessing-popup:hover {
    z-index: 300;
    transform: scale(1.02);
}

.blessing-popup:hover .popup-content {
    box-shadow: 
        0 8px 25px rgba(0, 0, 0, 0.2),
        0 4px 10px rgba(0, 0, 0, 0.15),
        inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

.popup-content {
    background: #ffffff;
    padding: 20px 25px;
    border-radius: 8px;
    box-shadow: 
        0 4px 12px rgba(0, 0, 0, 0.15),
        0 2px 4px rgba(0, 0, 0, 0.1),
        inset 0 1px 0 rgba(255, 255, 255, 0.8);
    border: 1px solid rgba(0, 0, 0, 0.1);
    position: relative;
    min-width: 180px;
    max-width: 250px;
    /* 移除默认旋转，改为JavaScript中设置 */
    font-family: 'Microsoft YaHei', '微软雅黑', Arial, sans-serif;
    
    /* 纸质纹理效果 */
    background-image: 
        radial-gradient(circle at 20% 50%, rgba(120, 119, 198, 0.03) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(255, 119, 198, 0.03) 0%, transparent 50%),
        radial-gradient(circle at 40% 80%, rgba(120, 200, 255, 0.03) 0%, transparent 50%);
}

/* 标签纸的胶带效果 */
.popup-content::before {
    content: '';
    position: absolute;
    top: -8px;
    left: 50%;
    transform: translateX(-50%) rotate(45deg);
    width: 30px;
    height: 15px;
    background: rgba(255, 255, 255, 0.8);
    border: 1px solid rgba(0, 0, 0, 0.1);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    border-radius: 2px;
}

/* 祝福文字样式 */
.blessing-text {
    display: block;
    font-size: 16px;
    font-weight: 500;
    color: #333;
    text-align: center;
    line-height: 1.4;
    margin-bottom: 10px;
    text-shadow: 0 1px 2px rgba(255, 255, 255, 0.8);
}

/* 关闭按钮样式 - 默认隐藏 */
.close-btn {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #ff6b6b;
    color: white;
    border: 2px solid white;
    font-size: 12px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
    transition: all 0.2s ease;
    line-height: 1;
    opacity: 0;
    transform: scale(0.8);
    pointer-events: none;
}

/* 弹窗悬停时显示关闭按钮 */
.blessing-popup:hover .close-btn {
    opacity: 1;
    transform: scale(1);
    pointer-events: auto;
}

.close-btn:hover {
    background: #ff5252;
    transform: scale(1.1);
}

.close-btn:active {
    transform: scale(0.95);
}

/* 移除nth-child选择器，改为JavaScript中设置固定旋转角度 */

/* 进入动画 - 优化性能 */
.popup-enter {
    animation: popupEnter 0.6s cubic-bezier(0.68, -0.55, 0.265, 1.55) forwards;
    will-change: transform, opacity;
}

@keyframes popupEnter {
    0% {
        opacity: 0;
        transform: scale(0.3) rotate(180deg);
    }
    50% {
        opacity: 0.8;
        transform: scale(1.05) rotate(-5deg);
    }
    100% {
        opacity: 1;
        transform: scale(1) rotate(0deg);
    }
}

/* 退出动画 - 优化性能 */
.popup-exit {
    animation: popupExit 0.3s ease-in forwards;
    will-change: transform, opacity;
    pointer-events: none;
}

@keyframes popupExit {
    0% {
        opacity: 1;
        transform: scale(1) rotate(0deg);
    }
    100% {
        opacity: 0;
        transform: scale(0.2) rotate(-90deg);
    }
}

/* 性能优化 */
.blessing-popup {
    will-change: transform;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

/* 减少重绘 */
.popup-content {
    will-change: box-shadow;
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
}

/* 响应式设计 */
@media (max-width: 768px) {
    .popup-content {
        padding: 15px 20px;
        min-width: 150px;
        max-width: 200px;
    }
    
    .blessing-text {
        font-size: 14px;
    }
    
    .close-btn {
        width: 20px;
        height: 20px;
        font-size: 12px;
        top: -6px;
        right: -6px;
    }
}

/* 确保文字在各种背景色上的可读性 */
.popup-content.dark-bg .blessing-text {
    color: #2c3e50;
    text-shadow: 0 1px 2px rgba(255, 255, 255, 0.9);
}

.popup-content.light-bg .blessing-text {
    color: #2c3e50;
    text-shadow: 0 1px 2px rgba(255, 255, 255, 0.7);
}