@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;600;800&family=Noto+Sans+SC:wght@300;400;700&display=swap');

:root {
    --bg-dark: #0a0b10;
    --bg-card: rgba(18, 20, 32, 0.65);
    --border-color: rgba(255, 255, 255, 0.08);
    --border-glow: rgba(139, 92, 246, 0.2);
    --color-primary: #8b5cf6;    /* 霓虹紫 */
    --color-secondary: #06b6d4;  /* 赛博青 */
    --color-text: #f3f4f6;
    --color-muted: #9ca3af;
}

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

body {
    background-color: var(--bg-dark);
    background-image: 
        radial-gradient(circle at 10% 20%, rgba(139, 92, 246, 0.15) 0%, transparent 40%),
        radial-gradient(circle at 90% 80%, rgba(6, 182, 212, 0.12) 0%, transparent 45%);
    background-attachment: fixed;
    color: var(--color-text);
    font-family: 'Outfit', 'Noto Sans SC', sans-serif;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

/* 导航栏 */
header {
    width: 100%;
    padding: 1.5rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    background: rgba(10, 11, 16, 0.5);
    backdrop-filter: blur(12px);
    position: sticky;
    top: 0;
    z-index: 50;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo-icon {
    font-size: 2rem;
    background: linear-gradient(135deg, var(--color-secondary), var(--color-primary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: pulse 2s infinite alternate;
}

.logo-text {
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: -0.5px;
    background: linear-gradient(135deg, #ffffff, #a78bfa);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.github-link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--color-text);
    text-decoration: none;
    padding: 0.5rem 1rem;
    border-radius: 9999px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.github-link:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--color-primary);
    transform: translateY(-2px);
    box-shadow: 0 0 15px rgba(139, 92, 246, 0.3);
}

/* 主内容布局 */
main {
    flex: 1;
    max-width: 1400px;
    width: 100%;
    margin: 0 auto;
    padding: 2.5rem 2rem;
    display: grid;
    grid-template-columns: 1.2fr 1fr;
    gap: 2.5rem;
}

@media (max-width: 1024px) {
    main {
        grid-template-columns: 1fr;
    }
}

/* 通用玻璃面板 */
.glass-panel {
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border-color);
    border-radius: 24px;
    padding: 2rem;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    transition: box-shadow 0.3s ease;
}

.glass-panel:hover {
    box-shadow: 0 8px 32px 0 rgba(139, 92, 246, 0.05);
}

/* 左侧：摄像头和捕获画面 */
.capture-section {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.camera-container {
    position: relative;
    width: 100%;
    aspect-ratio: 4 / 3;
    border-radius: 16px;
    overflow: hidden;
    background: #000;
    border: 1px solid var(--border-color);
    box-shadow: inset 0 0 40px rgba(0,0,0,0.8);
}

#webcam {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transform: scaleX(-1); /* 镜像翻转，符合使用直觉 */
}

#canvas-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none; /* 让事件穿透到下层 */
}

.camera-placeholder {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 1.5rem;
    background: linear-gradient(145deg, #11121a, #07080c);
    color: var(--color-muted);
}

.placeholder-icon {
    font-size: 4rem;
    animation: float 3s ease-in-out infinite;
}

.placeholder-btn {
    padding: 0.85rem 2rem;
    font-size: 1.1rem;
    font-weight: 600;
    color: #fff;
    background: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
    border: none;
    border-radius: 12px;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(139, 92, 246, 0.4);
    transition: all 0.3s ease;
}

.placeholder-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 24px rgba(139, 92, 246, 0.6);
}

/* 手势状态栏 */
.status-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    border-radius: 14px;
}

.gesture-status {
    display: flex;
    align-items: center;
    gap: 1rem;
}

#current-gesture {
    font-size: 2rem;
    width: 3.5rem;
    height: 3.5rem;
    background: rgba(255,255,255,0.05);
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    border: 1px solid rgba(255,255,255,0.1);
}

/* 拍照倒计时 */
#countdown-overlay {
    position: absolute;
    inset: 0;
    background: rgba(10, 11, 16, 0.85);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10;
}

#countdown-text {
    font-size: 7rem;
    font-weight: 800;
    color: #fff;
    text-shadow: 0 0 30px var(--color-primary);
    transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* 按钮样式 */
.btn {
    padding: 0.75rem 1.5rem;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: all 0.3s ease;
    border: 1px solid transparent;
}

.btn-primary {
    background: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
    color: white;
    box-shadow: 0 4px 15px rgba(139, 92, 246, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(139, 92, 246, 0.5);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--border-color);
    color: var(--color-text);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--color-primary);
    transform: translateY(-2px);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

/* 选择与控制区 */
.select-wrapper {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.select-wrapper label {
    font-size: 0.875rem;
    color: var(--color-muted);
}

select {
    padding: 0.75rem 1rem;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    color: var(--color-text);
    font-family: inherit;
    outline: none;
    cursor: pointer;
}

select option {
    background: #11121a;
    color: var(--color-text);
}

/* 右侧：表情包生成面板 */
.generator-section {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.section-title {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* 预览画布 */
.preview-container {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    aspect-ratio: 1 / 1;
    border-radius: 16px;
    background: #f8f9fa;
    border: 1px solid var(--border-color);
    overflow: hidden;
    position: relative;
}

#preview-canvas {
    max-width: 100%;
    max-height: 100%;
    aspect-ratio: 1 / 1;
    object-fit: contain;
}

/* 模板列表选择 */
.template-selector {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.template-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
}

.template-card {
    border-radius: 14px;
    border: 2px solid transparent;
    overflow: hidden;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.03);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0.5rem;
    gap: 0.5rem;
}

.template-card img {
    width: 100%;
    aspect-ratio: 1 / 1;
    object-fit: cover;
    border-radius: 8px;
}

.template-card span {
    font-size: 0.85rem;
    font-weight: 600;
}

.template-card:hover {
    transform: translateY(-4px);
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(139, 92, 246, 0.5);
}

/* 表单与配置 */
.control-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.25rem;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.input-group label {
    font-size: 0.875rem;
    color: var(--color-muted);
}

.input-row {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.text-input {
    width: 100%;
    padding: 0.75rem 1rem;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    color: #fff;
    outline: none;
    font-family: inherit;
    font-size: 1rem;
    transition: border-color 0.3s;
}

.text-input:focus {
    border-color: var(--color-primary);
}

.color-picker {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    width: 3rem;
    height: 3rem;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    background: none;
}

.color-picker::-webkit-color-swatch {
    border-radius: 10px;
    border: 1px solid rgba(255,255,255,0.2);
}

/* 滑块样式 */
.slider-container {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex: 1;
}

input[type="range"] {
    -webkit-appearance: none;
    width: 100%;
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 9999px;
    outline: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--color-primary);
    cursor: pointer;
    box-shadow: 0 0 10px var(--color-primary);
    transition: background 0.3s;
}

input[type="range"]::-webkit-slider-thumb:hover {
    background: var(--color-secondary);
}

/* 加载遮罩 */
#loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(10, 11, 16, 0.9);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 1.5rem;
    z-index: 100;
    transition: opacity 0.4s ease;
}

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

.hidden {
    opacity: 0;
    pointer-events: none;
}

/* 页脚 */
footer {
    padding: 2rem;
    text-align: center;
    color: var(--color-muted);
    font-size: 0.875rem;
    border-top: 1px solid var(--border-color);
    margin-top: auto;
}

footer a {
    color: var(--color-primary);
    text-decoration: none;
}

footer a:hover {
    text-decoration: underline;
}

/* 动效关键帧 */
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes pulse {
    0% { filter: drop-shadow(0 0 2px rgba(139, 92, 246, 0.4)); }
    100% { filter: drop-shadow(0 0 12px rgba(6, 182, 212, 0.8)); }
}

@keyframes float {
    0% { transform: translateY(0px); }
    50% { transform: translateY(-10px); }
    100% { transform: translateY(0px); }
}
