/* 古风易经卜卦样式 */

/* 引入古风字体 - 使用更古朴的书法字体 */
@import url('https://fonts.googleapis.com/css2?family=ZCOOL+XiaoWei&family=ZCOOL+QingKe+HuangYou&family=Noto+Serif+SC:wght@400;600;700&display=swap');

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

body {
    font-family: "Noto Serif SC", "Songti SC", serif;
    min-height: 100vh;
    color: #2c1810;
    background: 
        /* 宣纸纹理 */
        repeating-linear-gradient(
            0deg,
            transparent,
            transparent 2px,
            rgba(139, 90, 43, 0.03) 2px,
            rgba(139, 90, 43, 0.03) 4px
        ),
        repeating-linear-gradient(
            90deg,
            transparent,
            transparent 2px,
            rgba(139, 90, 43, 0.03) 2px,
            rgba(139, 90, 43, 0.03) 4px
        ),
        /* 古纸底色 */
        linear-gradient(
            135deg,
            #f5e6c8 0%,
            #e8d4a8 25%,
            #f2e2b6 50%,
            #e5d098 75%,
            #f3e4c0 100%
        );
    background-attachment: fixed;
}

/* 页面装饰边框 */
body::before {
    content: '';
    position: fixed;
    top: 15px;
    left: 15px;
    right: 15px;
    bottom: 15px;
    border: 2px solid #8b4513;
    pointer-events: none;
    z-index: 1000;
    opacity: 0.4;
}

body::after {
    content: '';
    position: fixed;
    top: 25px;
    left: 25px;
    right: 25px;
    bottom: 25px;
    border: 1px solid #a0522d;
    pointer-events: none;
    z-index: 1000;
    opacity: 0.3;
}

.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 40px 30px;
}

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

header h1 {
    font-family: "ZCOOL QingKe HuangYou", "STXingkai", "Xingkai SC", cursive;
    font-size: 3.5rem;
    color: #8b0000;
    text-shadow: 
        2px 2px 0 rgba(139, 69, 19, 0.3),
        4px 4px 8px rgba(0, 0, 0, 0.1);
    margin-bottom: 15px;
    letter-spacing: 0.3em;
    position: relative;
}

/* 标题装饰 */
header h1::before,
header h1::after {
    content: '☯';
    font-size: 1.5rem;
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    color: #8b4513;
    opacity: 0.6;
}

header h1::before {
    left: -50px;
}

header h1::after {
    right: -50px;
}

.subtitle {
    color: #5c3d2e;
    font-size: 1.1rem;
    letter-spacing: 0.2em;
    border-top: 1px solid #a0522d;
    border-bottom: 1px solid #a0522d;
    padding: 8px 20px;
    display: inline-block;
    background: rgba(139, 69, 19, 0.05);
}

/* 输入区域 */
.input-section {
    background: 
        linear-gradient(135deg, rgba(255,250,240,0.95) 0%, rgba(245,235,220,0.95) 100%);
    border: none;
    border-radius: 0;
    padding: 35px;
    margin-bottom: 30px;
    position: relative;
    box-shadow: 
        inset 0 0 30px rgba(139, 69, 19, 0.1),
        0 5px 20px rgba(0, 0, 0, 0.15);
}

/* 花纹边框 - 使用伪元素绘制 */
.input-section::before {
    content: '';
    position: absolute;
    top: 8px;
    left: 8px;
    right: 8px;
    bottom: 8px;
    border: 2px solid #8b4513;
    pointer-events: none;
}

/* 四角花纹装饰 */
.input-section::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    background: 
        /* 左上角 */
        radial-gradient(circle at 0 0, transparent 15px, #8b4513 15px, #8b4513 18px, transparent 18px),
        /* 右上角 */
        radial-gradient(circle at 100% 0, transparent 15px, #8b4513 15px, #8b4513 18px, transparent 18px),
        /* 左下角 */
        radial-gradient(circle at 0 100%, transparent 15px, #8b4513 15px, #8b4513 18px, transparent 18px),
        /* 右下角 */
        radial-gradient(circle at 100% 100%, transparent 15px, #8b4513 15px, #8b4513 18px, transparent 18px);
}

.input-section label {
    display: block;
    margin-bottom: 15px;
    font-size: 1.1rem;
    color: #5c3d2e;
    font-weight: 600;
}

.input-section textarea {
    width: 100%;
    padding: 15px;
    border: 1px solid #a0522d;
    background: rgba(255, 255, 255, 0.7);
    color: #2c1810;
    font-size: 1rem;
    font-family: inherit;
    resize: none;
    margin-bottom: 20px;
    transition: all 0.3s ease;
}

.input-section textarea:focus {
    outline: none;
    border-color: #8b0000;
    box-shadow: 0 0 10px rgba(139, 0, 0, 0.2);
}

.input-section button {
    width: 100%;
    padding: 15px 30px;
    font-size: 1.3rem;
    font-family: "ZCOOL QingKe HuangYou", "STXingkai", cursive;
    background: linear-gradient(135deg, #8b0000 0%, #a52a2a 50%, #8b0000 100%);
    border: none;
    color: #f5e6c8;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    letter-spacing: 0.2em;
    position: relative;
    overflow: hidden;
    box-shadow: 
        0 3px 10px rgba(139, 0, 0, 0.4),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.input-section button::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    transition: left 0.5s ease;
}

.input-section button:hover::before {
    left: 100%;
}

.input-section button:hover {
    background: linear-gradient(135deg, #a00000 0%, #c04040 50%, #a00000 100%);
    box-shadow: 0 5px 20px rgba(139, 0, 0, 0.4);
    transform: translateY(-2px);
}

.input-section button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* 结果区域 */
.result-section {
    background: linear-gradient(135deg, rgba(255,250,240,0.95) 0%, rgba(245,235,220,0.95) 100%);
    border: none;
    padding: 35px;
    position: relative;
    box-shadow: 
        inset 0 0 30px rgba(139, 69, 19, 0.1),
        0 5px 20px rgba(0, 0, 0, 0.15);
}

/* 花纹边框 */
.result-section::before {
    content: '';
    position: absolute;
    top: 8px;
    left: 8px;
    right: 8px;
    bottom: 8px;
    border: 2px solid #8b4513;
    pointer-events: none;
}

/* 四角花纹装饰 */
.result-section::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    background: 
        radial-gradient(circle at 0 0, transparent 15px, #8b4513 15px, #8b4513 18px, transparent 18px),
        radial-gradient(circle at 100% 0, transparent 15px, #8b4513 15px, #8b4513 18px, transparent 18px),
        radial-gradient(circle at 0 100%, transparent 15px, #8b4513 15px, #8b4513 18px, transparent 18px),
        radial-gradient(circle at 100% 100%, transparent 15px, #8b4513 15px, #8b4513 18px, transparent 18px);
}

.result-section h3 {
    font-family: "ZCOOL QingKe HuangYou", "STXingkai", cursive;
    color: #8b0000;
    font-size: 1.5rem;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid #a0522d;
    letter-spacing: 0.1em;
}

/* 爻象列表 */
.yao-process {
    display: none;
}

.yao-process.show {
    display: block;
}

.yao-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 30px;
    background: rgba(139, 69, 19, 0.05);
    padding: 20px;
    border: 1px solid #d2b48c;
}

.yao-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    background: rgba(255, 255, 255, 0.6);
    border-left: 3px solid #8b4513;
    transition: all 0.3s ease;
    border-radius: 0;
}

.yao-item.changing {
    background: rgba(255, 215, 0, 0.15);
    border-left-color: #ff6600;
    box-shadow: inset 0 0 10px rgba(255, 102, 0, 0.1);
}

.yao-item .position {
    color: #5c3d2e;
    font-size: 0.95rem;
    font-weight: 600;
}

.yao-item .symbol {
    font-size: 1.8rem;
    font-weight: bold;
    color: #8b0000;
    font-family: "ZCOOL XiaoWei", "STLiti", serif;
    letter-spacing: 0.1em;
}

.yao-item .type {
    font-size: 0.95rem;
    color: #5c3d2e;
}

.yao-item .changing-badge {
    background: #8b0000;
    color: #f5e6c8;
    padding: 3px 10px;
    font-size: 0.8rem;
    font-weight: bold;
}

/* 卦象卡片 */
.gua-info {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 30px;
}

.gua-card {
    background: rgba(255, 255, 255, 0.7);
    border: 1px solid #8b4513;
    padding: 25px;
    text-align: center;
    position: relative;
}

.gua-card::before {
    content: '☰';
    position: absolute;
    top: 10px;
    right: 10px;
    font-size: 1.5rem;
    color: #8b4513;
    opacity: 0.3;
}

.gua-card h4 {
    color: #5c3d2e;
    font-size: 0.9rem;
    margin-bottom: 12px;
    letter-spacing: 0.1em;
}

.gua-card .gua-name {
    font-family: "ZCOOL XiaoWei", "STLiti", "Liti SC", serif;
    font-size: 2rem;
    color: #8b0000;
    margin-bottom: 15px;
    letter-spacing: 0.15em;
}

.gua-card .gua-ci {
    font-size: 0.9rem;
    color: #3d2914;
    line-height: 1.8;
}

.ben-gua {
    border-width: 2px;
    background: linear-gradient(135deg, rgba(255,250,240,0.9) 0%, rgba(255,245,230,0.9) 100%);
}

.bian-gua {
    border-width: 2px;
    border-color: #4682b4;
    background: linear-gradient(135deg, rgba(240,248,255,0.9) 0%, rgba(230,240,250,0.9) 100%);
}

.bian-gua::before {
    content: '☷';
    color: #4682b4;
}

/* 解卦文本 */
.interpretation-text {
    background: rgba(255, 255, 255, 0.5);
    border: 1px solid #d2b48c;
    padding: 25px;
    line-height: 2;
    color: #2c1810;
    margin-bottom: 30px;
    overflow-wrap: break-word;
    word-break: break-word;
    overflow-x: hidden;
}

/* AI解卦 */
.ai-interpretation {
    background: rgba(255, 255, 255, 0.6);
    border: 1px solid #8b4513;
    padding: 25px;
    line-height: 2;
    color: #2c1810;
    margin-bottom: 30px;
    border-left: 4px solid #8b0000;
    overflow-wrap: break-word;
    word-break: break-word;
    overflow-x: hidden;
}

.ai-interpretation .stream-cursor {
    color: #8b0000;
    animation: cursorBlink 0.8s infinite;
}

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

.ai-interpretation h4 {
    font-family: "ZCOOL QingKe HuangYou", "STXingkai", cursive;
    color: #8b0000;
    font-size: 1.3rem;
    margin-bottom: 15px;
    letter-spacing: 0.1em;
}

.ai-interpretation hr.fmt-divider,
.interpretation-text hr.fmt-divider {
    border: none;
    border-top: 2px solid #8b4513;
    margin: 15px 0;
}

.ai-interpretation .fmt-section-title,
.interpretation-text .fmt-section-title {
    text-align: center;
    color: #8b0000;
    font-weight: bold;
    font-size: 1.2rem;
    margin: 15px 0 10px;
    letter-spacing: 0.15em;
}

/* 对话区域 */
.chat-section {
    border-top: 2px solid #a0522d;
    padding-top: 25px;
    margin-top: 30px;
}

.chat-section label {
    display: block;
    margin-bottom: 12px;
    color: #5c3d2e;
    font-weight: 600;
}

.chat-input {
    display: flex;
    gap: 10px;
}

.chat-input input {
    flex: 1;
    padding: 12px 15px;
    border: 1px solid #a0522d;
    background: rgba(255, 255, 255, 0.7);
    color: #2c1810;
    font-size: 1rem;
    font-family: inherit;
}

.chat-input input:focus {
    outline: none;
    border-color: #8b0000;
}

.chat-input button {
    padding: 12px 30px;
    background: #8b4513;
    border: none;
    color: #f5e6c8;
    font-weight: bold;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.3s ease;
}

.chat-input button:hover {
    background: #a0522d;
}

.chat-response {
    margin-top: 15px;
    padding: 20px;
    background: rgba(255, 255, 255, 0.5);
    border: 1px solid #d2b48c;
    line-height: 1.8;
}

/* 加载状态 */
.loading {
    text-align: center;
    padding: 50px;
}

.spinner {
    width: 60px;
    height: 60px;
    border: 3px solid #d2b48c;
    border-top-color: #8b0000;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

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

.loading p {
    color: #5c3d2e;
    font-style: italic;
}

/* 页脚 */
footer {
    text-align: center;
    padding: 40px 0 20px;
    color: #5c3d2e;
    font-size: 0.9rem;
}

footer p {
    margin: 5px 0;
}

/* 响应式 */
@media (max-width: 600px) {
    body::before,
    body::after {
        display: none;
    }
    
    header h1 {
        font-size: 2.5rem;
    }
    
    header h1::before,
    header h1::after {
        display: none;
    }
    
    .gua-info {
        grid-template-columns: 1fr;
    }
    
    .chat-input {
        flex-direction: column;
    }
}

/* 硬币动画 - 古风铜钱 */
.coin-animation {
    text-align: center;
    padding: 50px 20px;
    margin-bottom: 30px;
    background: 
        radial-gradient(circle at center, rgba(139, 69, 19, 0.1) 0%, transparent 70%),
        rgba(255, 250, 240, 0.8);
    border: none;
    position: relative;
}

/* 花纹边框 */
.coin-animation::before {
    content: '';
    position: absolute;
    top: 8px;
    left: 8px;
    right: 8px;
    bottom: 8px;
    border: 2px solid #8b4513;
    pointer-events: none;
}

.coin-animation::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    background: 
        radial-gradient(circle at 0 0, transparent 12px, #8b4513 12px, #8b4513 15px, transparent 15px),
        radial-gradient(circle at 100% 0, transparent 12px, #8b4513 12px, #8b4513 15px, transparent 15px),
        radial-gradient(circle at 0 100%, transparent 12px, #8b4513 12px, #8b4513 15px, transparent 15px),
        radial-gradient(circle at 100% 100%, transparent 12px, #8b4513 12px, #8b4513 15px, transparent 15px);
}

.coin-container {
    display: flex;
    justify-content: center;
    gap: 45px;
    margin-bottom: 25px;
}

/* 铜钱容器 */
.coin {
    width: 90px;
    height: 90px;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.5s ease-out;
}

/* 正面朝上 */
.coin.show-front {
    transform: rotateY(0deg);
}

/* 背面朝上 */
.coin.show-back {
    transform: rotateY(180deg);
}

/* 翻转动画 */
.coin.flipping {
    animation: coinFlip 0.5s ease-out forwards;
}

/* 铜钱正反面容器 */
.coin-face {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    border-radius: 50%;
}

.coin-front {
    transform: rotateY(0deg);
}

.coin-back {
    transform: rotateY(180deg);
}

/* SVG铜钱样式 */
.coin-svg {
    width: 100%;
    height: 100%;
    display: block;
    filter: drop-shadow(3px 5px 8px rgba(0, 0, 0, 0.4));
}

/* 铜钱文字样式 */
.coin-text {
    font-family: "ZCOOL XiaoWei", "STLiti", "LiSu", serif;
    font-size: 18px;
    fill: #2c1810;
    font-weight: bold;
}

.coin-text-back {
    font-family: "ZCOOL XiaoWei", "STLiti", "LiSu", serif;
    font-size: 22px;
    fill: #b8960a;
    font-weight: bold;
}

@keyframes coinFlip {
    0% {
        transform: rotateY(0deg) translateY(0) scale(1);
    }
    25% {
        transform: rotateY(180deg) translateY(-40px) scale(1.1);
    }
    50% {
        transform: rotateY(360deg) translateY(-60px) scale(1.15);
    }
    75% {
        transform: rotateY(540deg) translateY(-40px) scale(1.1);
    }
    100% {
        transform: rotateY(720deg) translateY(0) scale(1);
    }
}

.animation-text {
    font-size: 1.3rem;
    color: #8b0000;
    font-family: "ZCOOL QingKe HuangYou", "STXingkai", cursive;
    min-height: 30px;
}

.animation-text #animationResult {
    margin-left: 15px;
    color: #2c1810;
    font-family: "ZCOOL XiaoWei", "STLiti", serif;
}

.yao-item.hidden {
    opacity: 0;
    transform: translateX(-20px);
}

.yao-item.visible {
    opacity: 1;
    transform: translateX(0);
    transition: all 0.3s ease-out;
}

/* 八卦符号装饰 */
.bagua-symbol {
    font-size: 2rem;
    color: rgba(139, 69, 19, 0.2);
    position: absolute;
    z-index: 0;
}

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

::-webkit-scrollbar-track {
    background: #f5e6c8;
}

::-webkit-scrollbar-thumb {
    background: #8b4513;
    border-radius: 0;
}

::-webkit-scrollbar-thumb:hover {
    background: #a0522d;
}

/* 古风错误提示 */
.error-toast {
    position: fixed;
    top: 50px;
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(135deg, #8b0000 0%, #a52a2a 100%);
    color: #f5e6c8;
    padding: 16px 32px;
    border: 2px solid #d4a574;
    box-shadow: 0 8px 30px rgba(139, 0, 0, 0.4);
    z-index: 2000;
    font-family: "Noto Serif SC", serif;
    font-size: 1rem;
    letter-spacing: 0.05em;
    animation: toastSlideIn 0.4s ease-out;
    max-width: 80%;
    text-align: center;
}

.error-toast .error-icon {
    margin-right: 10px;
    font-size: 1.1rem;
}

@keyframes toastSlideIn {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}
