/* ==================== 基础样式 ==================== */
:root {
    --primary-color: #c41e3a;
    --secondary-color: #ffd700;
    --accent-color: #8b4513;
    --dark-color: #2c1810;
    --light-color: #fff5e6;
    
    --text-primary: #2c1810;
    --text-secondary: #666;
    --text-light: #ffffff;
    
    --bg-primary: #ffffff;
    --bg-secondary: #fff5e6;
    --bg-dark: #2c1810;
    
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.15);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.2);
    
    --transition-base: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    overflow-x: hidden;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB',
        'Microsoft YaHei', sans-serif;
    line-height: 1.6;
    color: var(--text-primary);
    background: var(--bg-secondary);
    overflow: hidden;
    height: 100vh;
    width: 100vw;
}

button {
    border: none;
    background: none;
    cursor: pointer;
    font-family: inherit;
}

.hidden {
    display: none !important;
}

/* ==================== 视频容器 ==================== */
.video-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #000;
    z-index: 10;
}

.main-video {
    width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: center;
}

/* 播放覆盖层 */
.play-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        135deg,
        rgba(196, 30, 58, 0.85) 0%,
        rgba(139, 69, 19, 0.85) 100%
    );
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 11;
}

.play-button {
    text-align: center;
    color: white;
    animation: pulse 2s infinite;
}

.play-icon {
    display: block;
    font-size: 5rem;
    margin-bottom: 1rem;
    text-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

.play-text {
    font-size: 1.25rem;
    font-weight: 600;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

/* ==================== 生成卡片按钮 ==================== */
.generate-btn-container {
    position: fixed;
    bottom: 10%;
    left: 50%;
    transform: translateX(-50%);
    z-index: 20;
    width: 90%;
    max-width: 400px;
    animation: slideUp 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.generate-btn {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    padding: 1.5rem 2rem;
    background: linear-gradient(135deg, var(--primary-color), var(--accent-color));
    border-radius: 1.5rem;
    color: white;
    box-shadow: var(--shadow-lg);
    transition: var(--transition-base);
    min-height: 120px;
}

.generate-btn:active {
    transform: scale(0.98);
}

.btn-icon {
    font-size: 3rem;
    animation: bounce 1s infinite;
}

.btn-text {
    font-size: 1.25rem;
    font-weight: 700;
    text-align: center;
}

/* ==================== 卡片弹窗 ==================== */
.card-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem;
    animation: fadeIn 0.3s ease-out;
}

.card-modal-content {
    position: relative;
    width: 100%;
    max-width: 95vw;
    background: white;
    border-radius: 1.5rem;
    overflow: hidden;
    box-shadow: var(--shadow-lg);
    animation: scaleIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.close-btn {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.1);
    color: var(--text-primary);
    font-size: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    transition: var(--transition-base);
}

.close-btn:active {
    background: rgba(0, 0, 0, 0.2);
}

.card-display {
    width: 100%;
    aspect-ratio: 9/16;
    background: linear-gradient(135deg, var(--light-color), white);
    border-radius: 1.5rem;
    overflow: hidden;
}

.card-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    animation: cardAppear 0.6s ease-out;
}

.card-content {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 2rem 1.5rem;
    background: linear-gradient(to top, rgba(44, 24, 16, 0.95), transparent);
    color: white;
}

.card-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    color: var(--secondary-color);
}

.card-message {
    font-size: 1rem;
    line-height: 1.6;
    opacity: 0.95;
}

.card-actions {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
    padding: 1rem;
    background: var(--bg-secondary);
}

.action-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    padding: 1rem 0.5rem;
    border-radius: 0.75rem;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
    transition: var(--transition-base);
    min-height: 80px;
}

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

.save-btn {
    background: linear-gradient(135deg, #4CAF50, #45a049);
    color: white;
}

.share-btn {
    background: linear-gradient(135deg, #2196F3, #1976D2);
    color: white;
}

.regenerate-btn {
    background: linear-gradient(135deg, #FF9800, #F57C00);
    color: white;
}

.action-btn .btn-icon {
    font-size: 1.5rem;
}

.action-btn .btn-text {
    font-size: 0.8rem;
    font-weight: 600;
}

/* ==================== 加载动画 ==================== */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 200;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
}

.loading-spinner {
    width: 4rem;
    height: 4rem;
    border: 4px solid rgba(255, 255, 255, 0.2);
    border-top-color: var(--secondary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.loading-text {
    color: white;
    font-size: 1.1rem;
    font-weight: 600;
}

/* ==================== 动画 ==================== */
@keyframes pulse {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.05);
        opacity: 0.9;
    }
}

@keyframes bounce {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-0.5rem);
    }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translate(-50%, 100%);
    }
    to {
        opacity: 1;
        transform: translate(-50%, 0);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes cardAppear {
    from {
        opacity: 0;
        transform: scale(1.1);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ==================== PC 端适配 (>= 768px) ==================== */
@media (min-width: 768px) {
    html {
        font-size: 18px;
    }

    /* PC端容器居中显示，类似H5效果 */
    .video-container {
        position: fixed;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        width: 375px;
        max-height: 667px;
        border-radius: 2rem;
        box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
        overflow: hidden;
    }

    /* PC端背景装饰 */
    body::before {
        content: '';
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
        z-index: -1;
    }

    /* 装饰元素 */
    body::after {
        content: '🐎';
        position: fixed;
        top: 5%;
        right: 5%;
        font-size: 8rem;
        opacity: 0.1;
        z-index: -1;
    }

    .play-icon {
        font-size: 6rem;
    }

    .play-text {
        font-size: 1.5rem;
    }

    .card-modal-content {
        max-width: 450px;
    }

    .card-display {
        aspect-ratio: 4/5;
    }

    /* PC端弹窗减少内边距 */
    .card-modal {
        padding: 1.5rem;
    }
}

/* ==================== 横屏适配 ==================== */
@media (orientation: landscape) and (max-height: 500px) {
    .play-icon {
        font-size: 3rem;
    }

    .play-text {
        font-size: 1rem;
    }

    .generate-btn {
        flex-direction: row;
        padding: 1rem 2rem;
        min-height: auto;
        gap: 1rem;
    }

    .generate-btn .btn-icon {
        font-size: 2rem;
    }

    .generate-btn .btn-text {
        font-size: 1rem;
    }

    .generate-btn-container {
        bottom: 5%;
    }

    /* PC端横屏时不应用375px宽度 */
    @media (min-width: 768px) {
        .video-container {
            width: 500px;
            max-height: 350px;
        }
    }
}

/* ==================== iOS 安全区域适配 ==================== */
@supports (padding: env(safe-area-inset-bottom)) {
    .generate-btn-container {
        padding-bottom: env(safe-area-inset-bottom);
    }
}
