/* =====================================================
   亲戚关系计算器 - 中式传统现代融合风格
   ===================================================== */

/* CSS 变量 */
:root {
    /* 主色调 */
    --color-primary: #8B2323;
    --color-primary-light: #A52A2A;
    --color-primary-dark: #5C1515;
    
    /* 金色系 */
    --color-gold: #C9A227;
    --color-gold-light: #D4AF37;
    --color-gold-dark: #B8860B;
    
    /* 背景色 */
    --bg-cream: #FDF8F3;
    --bg-warm: #FAF5EF;
    --bg-card: #FFFEFA;
    
    /* 文字色 */
    --text-primary: #2D1810;
    --text-secondary: #5C4033;
    --text-muted: #8B7355;
    
    /* 性别颜色 */
    --color-male: #1E4D7B;
    --color-male-light: #2E6DA4;
    --color-female: #A52A6D;
    --color-female-light: #C71585;
    --color-ambiguous: #6B4E9E;
    --color-self: #2E7D32;
    
    /* 边框与阴影 */
    --border-light: #E8DDD0;
    --border-gold: rgba(201, 162, 39, 0.3);
    --shadow-soft: 0 4px 20px rgba(139, 35, 35, 0.08);
    --shadow-card: 0 8px 32px rgba(139, 35, 35, 0.12);
    --shadow-button: 0 4px 12px rgba(0, 0, 0, 0.15);
    
    /* 圆角 */
    --radius-sm: 8px;
    --radius-md: 16px;
    --radius-lg: 24px;
    --radius-full: 50%;
    
    /* 过渡 */
    --transition-fast: 0.15s ease;
    --transition-normal: 0.3s ease;
    --transition-slow: 0.5s ease;
}

/* 全局重置 */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* 基础样式 */
html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Noto Serif SC', 'Songti SC', 'STSong', serif;
    background: var(--bg-cream);
    color: var(--text-primary);
    line-height: 1.7;
    min-height: 100vh;
    overflow-x: hidden;
}

/* 背景装饰 */
.bg-pattern {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: -2;
    opacity: 0.03;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='60' height='60' viewBox='0 0 60 60'%3E%3Cpath d='M30 5 L35 15 L30 10 L25 15 Z' fill='%238B2323'/%3E%3Cpath d='M30 55 L35 45 L30 50 L25 45 Z' fill='%238B2323'/%3E%3Cpath d='M5 30 L15 35 L10 30 L15 25 Z' fill='%238B2323'/%3E%3Cpath d='M55 30 L45 35 L50 30 L45 25 Z' fill='%238B2323'/%3E%3C/svg%3E");
}

/* 浮动祥云 */
.floating-clouds {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: -1;
    overflow: hidden;
}

.cloud {
    position: absolute;
    background: radial-gradient(ellipse at center, 
        rgba(201, 162, 39, 0.08) 0%, 
        rgba(201, 162, 39, 0.02) 50%,
        transparent 70%);
    border-radius: 50%;
    filter: blur(20px);
}

.cloud-1 {
    width: 400px;
    height: 200px;
    top: 10%;
    left: -5%;
    animation: floatCloud 25s ease-in-out infinite;
}

.cloud-2 {
    width: 300px;
    height: 150px;
    top: 50%;
    right: -5%;
    animation: floatCloud 30s ease-in-out infinite reverse;
}

.cloud-3 {
    width: 350px;
    height: 180px;
    bottom: 20%;
    left: 30%;
    animation: floatCloud 35s ease-in-out infinite;
}

@keyframes floatCloud {
    0%, 100% { transform: translateX(0) translateY(0); }
    25% { transform: translateX(30px) translateY(-20px); }
    50% { transform: translateX(60px) translateY(10px); }
    75% { transform: translateX(30px) translateY(-10px); }
}

/* 容器 */
.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 20px;
    position: relative;
}

/* 顶部装饰 - 灯笼 */
.top-decoration {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 60px;
    pointer-events: none;
}

.lantern {
    position: absolute;
    width: 30px;
    height: 40px;
    background: linear-gradient(180deg, 
        var(--color-primary) 0%, 
        var(--color-primary-light) 50%,
        var(--color-primary) 100%);
    border-radius: 50% 50% 45% 45%;
    box-shadow: 
        inset 0 -5px 10px rgba(0,0,0,0.2),
        0 5px 15px rgba(139, 35, 35, 0.3);
    animation: swingLantern 4s ease-in-out infinite;
}

.lantern::before {
    content: '';
    position: absolute;
    top: -8px;
    left: 50%;
    transform: translateX(-50%);
    width: 12px;
    height: 8px;
    background: var(--color-gold);
    border-radius: 2px 2px 0 0;
}

.lantern::after {
    content: '';
    position: absolute;
    bottom: -15px;
    left: 50%;
    transform: translateX(-50%);
    width: 4px;
    height: 15px;
    background: linear-gradient(180deg, var(--color-gold), var(--color-gold-dark));
    border-radius: 0 0 2px 2px;
}

.lantern-left {
    left: 10%;
    top: 5px;
    animation-delay: 0s;
}

.lantern-right {
    right: 10%;
    top: 5px;
    animation-delay: 2s;
}

@keyframes swingLantern {
    0%, 100% { transform: rotate(-3deg); }
    50% { transform: rotate(3deg); }
}

/* 头部 */
header {
    text-align: center;
    padding: 40px 0 30px;
    position: relative;
}

.header-ornament {
    width: 120px;
    height: 2px;
    margin: 0 auto 20px;
    background: linear-gradient(90deg, 
        transparent, 
        var(--color-gold) 20%, 
        var(--color-gold) 80%, 
        transparent);
    position: relative;
}

.header-ornament::before,
.header-ornament::after {
    content: '✦';
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    color: var(--color-gold);
    font-size: 12px;
}

.header-ornament::before { left: -5px; }
.header-ornament::after { right: -5px; }

.header-ornament.bottom {
    margin: 15px auto 0;
    width: 80px;
}

header h1 {
    font-family: 'ZCOOL XiaoWei', 'Noto Serif SC', serif;
    font-size: clamp(2rem, 6vw, 3.5rem);
    font-weight: 400;
    letter-spacing: 0.15em;
    color: var(--color-primary);
    margin-bottom: 12px;
    text-shadow: 
        2px 2px 0 rgba(201, 162, 39, 0.2),
        4px 4px 8px rgba(139, 35, 35, 0.1);
}

.title-char {
    display: inline-block;
    animation: titleReveal 0.6s ease backwards;
}

.title-char:nth-child(1) { animation-delay: 0.1s; }
.title-char:nth-child(2) { animation-delay: 0.15s; }
.title-char:nth-child(3) { animation-delay: 0.2s; }
.title-char:nth-child(4) { animation-delay: 0.25s; }
.title-char:nth-child(5) { animation-delay: 0.3s; }
.title-char:nth-child(6) { animation-delay: 0.35s; }
.title-char:nth-child(7) { animation-delay: 0.4s; }

@keyframes titleReveal {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.9);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.subtitle {
    font-size: 1.1rem;
    color: var(--text-muted);
    letter-spacing: 0.3em;
    animation: fadeInUp 0.8s ease 0.5s backwards;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 主体 */
main {
    animation: mainReveal 0.8s ease 0.3s backwards;
}

@keyframes mainReveal {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 结果展示区 */
.result-section {
    margin-bottom: 24px;
}

.result-frame {
    background: linear-gradient(135deg, 
        var(--color-primary) 0%, 
        var(--color-primary-dark) 100%);
    border-radius: var(--radius-lg);
    padding: 4px;
    box-shadow: 
        0 10px 40px rgba(139, 35, 35, 0.25),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
    position: relative;
    overflow: hidden;
}

.result-frame::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle at 30% 30%, 
        rgba(255, 255, 255, 0.1) 0%, 
        transparent 50%);
    pointer-events: none;
}

.result-inner {
    background: linear-gradient(180deg, 
        rgba(255, 255, 255, 0.1) 0%, 
        rgba(255, 255, 255, 0.05) 100%);
    border-radius: calc(var(--radius-lg) - 4px);
    padding: 30px 20px;
    text-align: center;
    min-height: 120px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.result-label {
    color: rgba(255, 255, 255, 0.85);
    font-size: 0.95rem;
    letter-spacing: 0.1em;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.label-icon {
    color: var(--color-gold-light);
    font-size: 0.75rem;
    animation: sparkle 2s ease-in-out infinite;
}

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

.result-value {
    font-family: 'ZCOOL XiaoWei', 'Noto Serif SC', serif;
    font-size: clamp(2.5rem, 8vw, 4rem);
    font-weight: 400;
    color: white;
    text-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    transition: all var(--transition-normal);
    animation: resultPulse 3s ease-in-out infinite;
}

@keyframes resultPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.02); }
}

/* 结果颜色变体 - 通过 JS 添加类 */
.result-frame.male {
    background: linear-gradient(135deg, var(--color-male) 0%, #163555 100%);
}

.result-frame.female {
    background: linear-gradient(135deg, var(--color-female) 0%, #6B1A45 100%);
}

.result-frame.ambiguous {
    background: linear-gradient(135deg, var(--color-ambiguous) 0%, #4A3570 100%);
}

.result-frame.self {
    background: linear-gradient(135deg, var(--color-self) 0%, #1B5E20 100%);
}

/* 关系链区域 */
.chain-section {
    margin-bottom: 30px;
}

.chain-frame {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    padding: 20px;
    min-height: 70px;
    box-shadow: var(--shadow-soft);
    position: relative;
}

.chain-frame::before {
    content: '关系链';
    position: absolute;
    top: -10px;
    left: 20px;
    background: var(--bg-card);
    padding: 0 10px;
    font-size: 0.8rem;
    color: var(--text-muted);
    letter-spacing: 0.1em;
}

.chain-container {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 30px;
}

.placeholder-text {
    color: var(--text-muted);
    font-style: italic;
    font-size: 0.95rem;
}

.chain-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: linear-gradient(135deg, var(--color-primary-light), var(--color-primary));
    color: white;
    padding: 8px 16px;
    border-radius: 25px;
    font-size: 0.95rem;
    box-shadow: 0 3px 10px rgba(139, 35, 35, 0.2);
    animation: chainItemIn 0.3s ease backwards;
}

@keyframes chainItemIn {
    from {
        opacity: 0;
        transform: scale(0.8) translateY(10px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.chain-arrow {
    color: var(--color-gold);
    font-size: 1.1rem;
    font-weight: bold;
}

.chain-actions {
    display: flex;
    justify-content: center;
    gap: 16px;
    margin-top: 16px;
}

.action-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 24px;
    border: 1px solid var(--border-light);
    border-radius: 25px;
    background: var(--bg-card);
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all var(--transition-normal);
    box-shadow: var(--shadow-soft);
}

.action-btn:hover:not(:disabled) {
    background: var(--bg-warm);
    border-color: var(--color-gold);
    color: var(--color-primary);
    transform: translateY(-2px);
    box-shadow: var(--shadow-card);
}

.action-btn:active:not(:disabled) {
    transform: translateY(0);
}

.action-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.btn-icon {
    font-size: 1.1rem;
}

/* 关系按钮区 */
.relation-section {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 30px;
    box-shadow: var(--shadow-card);
    border: 1px solid var(--border-light);
}

.relation-group {
    margin-bottom: 28px;
}

.relation-group:last-child {
    margin-bottom: 0;
}

.group-title {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    font-family: 'ZCOOL XiaoWei', 'Noto Serif SC', serif;
    font-size: 1.1rem;
    font-weight: 400;
    color: var(--text-primary);
    letter-spacing: 0.1em;
    margin-bottom: 8px;
}

.title-decorator {
    color: var(--color-gold);
    font-size: 0.7rem;
}

.group-hint {
    text-align: center;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 14px;
}

.button-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: 12px;
}

/* 关系按钮 */
.relation-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 14px 10px;
    border: none;
    border-radius: var(--radius-md);
    font-family: inherit;
    cursor: pointer;
    transition: all var(--transition-normal);
    position: relative;
    overflow: hidden;
}

.relation-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(180deg, 
        rgba(255, 255, 255, 0.15) 0%, 
        transparent 50%);
    pointer-events: none;
}

.relation-btn::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: width 0.4s ease, height 0.4s ease;
}

.relation-btn:active::after {
    width: 200px;
    height: 200px;
}

/* 男性按钮 */
.relation-btn.male {
    background: linear-gradient(145deg, var(--color-male-light), var(--color-male));
    color: white;
    box-shadow: 
        0 4px 15px rgba(30, 77, 123, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.relation-btn.male:hover {
    transform: translateY(-3px);
    box-shadow: 
        0 8px 25px rgba(30, 77, 123, 0.4),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

/* 女性按钮 */
.relation-btn.female {
    background: linear-gradient(145deg, var(--color-female-light), var(--color-female));
    color: white;
    box-shadow: 
        0 4px 15px rgba(165, 42, 109, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.relation-btn.female:hover {
    transform: translateY(-3px);
    box-shadow: 
        0 8px 25px rgba(165, 42, 109, 0.4),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

/* 模糊按钮 */
.relation-btn.ambiguous {
    background: linear-gradient(145deg, #8B6DB5, var(--color-ambiguous));
    color: white;
    box-shadow: 
        0 4px 15px rgba(107, 78, 158, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.relation-btn.ambiguous:hover {
    transform: translateY(-3px);
    box-shadow: 
        0 8px 25px rgba(107, 78, 158, 0.4),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.relation-btn:active {
    transform: translateY(-1px);
}

.btn-emoji {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.15);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 600;
}

.btn-text {
    font-size: 0.9rem;
    font-weight: 500;
    letter-spacing: 0.05em;
}

/* 页脚 */
footer {
    text-align: center;
    padding: 30px 20px;
    margin-top: 20px;
}

.footer-ornament {
    width: 60px;
    height: 1px;
    margin: 0 auto 20px;
    background: linear-gradient(90deg, transparent, var(--border-light), transparent);
}

.footer-content {
    animation: fadeInUp 0.8s ease 0.6s backwards;
}

.tip {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 16px;
}

.legend {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 16px;
}

.legend-item {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.legend-item.male { color: var(--color-male); }
.legend-item.female { color: var(--color-female); }
.legend-item.ambiguous { color: var(--color-ambiguous); }
.legend-item.self { color: var(--color-self); }

/* 响应式设计 */
@media (max-width: 768px) {
    .container {
        padding: 15px;
    }
    
    header {
        padding: 30px 0 20px;
    }
    
    .header-ornament {
        width: 80px;
    }
    
    .result-inner {
        padding: 25px 15px;
    }
    
    .relation-section {
        padding: 20px;
    }
    
    .button-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 10px;
    }
    
    .relation-btn {
        padding: 12px 8px;
    }
    
    .btn-emoji {
        width: 28px;
        height: 28px;
        font-size: 0.8rem;
    }
    
    .btn-text {
        font-size: 0.8rem;
    }
    
    .chain-actions {
        flex-direction: column;
    }
    
    .action-btn {
        width: 100%;
        justify-content: center;
    }
    
    .lantern {
        width: 24px;
        height: 32px;
    }
    
    .lantern-left { left: 5%; }
    .lantern-right { right: 5%; }
}

@media (max-width: 480px) {
    .button-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .legend {
        gap: 12px;
    }
    
    .legend-item {
        font-size: 0.8rem;
    }
}

/* 滚动条美化 */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-warm);
}

::-webkit-scrollbar-thumb {
    background: var(--border-light);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--color-gold);
}

/* 选择文本样式 */
::selection {
    background: var(--color-primary);
    color: white;
}

/* 焦点样式 */
:focus-visible {
    outline: 2px solid var(--color-gold);
    outline-offset: 2px;
}

/* 打印样式 */
@media print {
    .bg-pattern,
    .floating-clouds,
    .top-decoration {
        display: none;
    }
}