/* ============================
   zhouyi.css - 周易算卦
   统一项目黑白简约风格 + 传统易学风
   ============================ */

.zhouyi-page {
    max-width: 640px;
}

.zhouyi-main {
    background: var(--bg);
    border: 2px solid var(--border);
    border-radius: 10px;
    padding: 1.5rem;
}

/* ===== 方式选择区 ===== */
.setup-panel {
    text-align: center;
}

.setup-hint {
    color: var(--muted);
    font-size: 14px;
    margin-bottom: 1.2rem;
    line-height: 1.6;
}

.method-options {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 1.5rem;
}

.method-opt {
    flex: 1 1 0;
    min-width: 0;
    border: 2px solid var(--light-border);
    border-radius: 8px;
    padding: 0.8rem 0.3rem;
    cursor: pointer;
    transition: all 0.2s;
    background: var(--bg);
    text-align: center;
}

.method-opt:hover {
    border-color: var(--fg);
}

.method-opt.selected {
    border-color: var(--fg);
    background: var(--fg);
    color: var(--bg);
}

.method-name {
    font-size: 13px;
    font-weight: bold;
    margin-bottom: 4px;
}

.method-desc {
    font-size: 10px;
    color: var(--muted);
    line-height: 1.3;
}

.method-opt.selected .method-desc {
    color: #ccc;
}

/* ===== 问题输入 ===== */
.question-input {
    text-align: left;
    margin-bottom: 1.2rem;
}

.question-input label {
    display: block;
    font-size: 13px;
    color: var(--muted);
    margin-bottom: 6px;
}

.question-input input {
    width: 100%;
    padding: 8px 12px;
    border: 1.5px solid var(--light-border);
    border-radius: 6px;
    font-size: 14px;
    background: var(--bg);
    color: var(--fg);
    box-sizing: border-box;
}

.question-input input:focus {
    outline: none;
    border-color: var(--fg);
}

/* ===== 起卦表单（数字/生辰）===== */
.cast-form {
    text-align: left;
    margin-bottom: 1.2rem;
    padding: 14px;
    border: 1.5px dashed var(--light-border);
    border-radius: 8px;
    background: rgba(0,0,0,0.02);
}

.cast-form-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}

.cast-form-row label {
    font-size: 13px;
    color: var(--muted);
    min-width: 70px;
}

.cast-form-row input,
.cast-form-row select {
    flex: 1;
    min-width: 100px;
    padding: 7px 10px;
    border: 1.5px solid var(--light-border);
    border-radius: 5px;
    font-size: 14px;
    background: var(--bg);
    color: var(--fg);
    box-sizing: border-box;
}

.cast-form-row input:focus,
.cast-form-row select:focus {
    outline: none;
    border-color: var(--fg);
}

.cast-form-hint {
    font-size: 11px;
    color: var(--muted);
    margin-top: 4px;
    line-height: 1.5;
}

/* ===== 按钮 ===== */
.btn-main {
    display: inline-block;
    padding: 10px 32px;
    background: var(--fg);
    color: var(--bg);
    border: 2px solid var(--fg);
    border-radius: 6px;
    font-size: 15px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s;
    letter-spacing: 2px;
}

.btn-main:hover {
    opacity: 0.85;
}

.btn-main:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-secondary {
    display: inline-block;
    padding: 10px 28px;
    background: var(--bg);
    color: var(--fg);
    border: 2px solid var(--fg);
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
    margin-left: 10px;
}

.btn-secondary:hover {
    background: var(--fg);
    color: var(--bg);
}

/* ===== 铜钱抛掷区 ===== */
.coin-stage {
    text-align: center;
    padding: 20px 0;
}

.stage-hint {
    color: var(--muted);
    font-size: 13px;
    margin-bottom: 16px;
}

.coins-area {
    display: flex;
    justify-content: center;
    gap: 18px;
    margin-bottom: 16px;
    min-height: 80px;
    align-items: center;
}

.coin {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    border: 2.5px solid var(--fg);
    background: var(--bg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    font-weight: bold;
    color: var(--fg);
    position: relative;
    transition: transform 0.4s ease;
    font-family: 'KaiTi', 'STKaiti', serif;
}

.coin.flipping {
    animation: coinFlip 0.6s ease-in-out;
}

@keyframes coinFlip {
    0% { transform: rotateY(0deg) scale(1); }
    50% { transform: rotateY(180deg) scale(1.15); }
    100% { transform: rotateY(360deg) scale(1); }
}

.coin.yang {
    background: var(--fg);
    color: var(--bg);
}

.coin.yin {
    background: var(--bg);
    color: var(--fg);
}

.toss-result {
    font-size: 14px;
    color: var(--muted);
    margin: 8px 0 12px;
    min-height: 20px;
}

.toss-result strong {
    color: var(--fg);
}

/* 已抛爻符列表 */
.cast-progress {
    margin-top: 18px;
    padding: 12px;
    border: 1.5px solid var(--light-border);
    border-radius: 6px;
    background: var(--bg);
}

.cast-progress-title {
    font-size: 12px;
    color: var(--muted);
    margin-bottom: 8px;
}

.yao-list {
    display: flex;
    flex-direction: column-reverse; /* 上爻在上 */
    gap: 6px;
}

.yao-item {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
}

.yao-pos {
    width: 32px;
    color: var(--muted);
    font-size: 12px;
}

.yao-symbol {
    font-family: 'KaiTi', 'STKaiti', serif;
    font-size: 22px;
    letter-spacing: 2px;
    min-width: 110px;
    color: var(--fg);
}

.yao-symbol-wrap {
    display: inline-flex;
    align-items: center;
    min-width: 110px;
}
.yao-draw {
    display: inline-flex;
    align-items: center;
    height: 14px;
    min-width: 90px;
    position: relative;
}

.yao-draw .yao-line {
    display: block;
    height: 5px;
    background: var(--fg);
    border-radius: 1px;
}

.yao-draw.yang .yao-line {
    width: 80px;
}

.yao-draw.yin .yao-line {
    width: 36px;
}

.yao-draw.yin .yao-gap {
    width: 8px;
    display: inline-block;
}

.yao-draw .yao-mark {
    position: absolute;
    right: -16px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 13px;
    color: #c0392b;
    font-weight: bold;
    line-height: 1;
}

.yao-item.changing .yao-draw .yao-line {
    background: #c0392b;
}

.yao-name {
    font-size: 12px;
    color: var(--muted);
}

.yao-item.changing .yao-symbol {
    color: #c0392b;
}

.yao-item.changing .yao-name {
    color: #c0392b;
    font-weight: bold;
}

/* ===== 结果区 ===== */
.result-panel {
    animation: fadeIn 0.5s ease;
}

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

.question-display {
    text-align: center;
    padding: 10px;
    margin-bottom: 18px;
    border-bottom: 1.5px dashed var(--light-border);
}

.question-display .q-label {
    font-size: 12px;
    color: var(--muted);
    margin-right: 6px;
}

.question-display .q-text {
    font-size: 15px;
    color: var(--fg);
    font-weight: bold;
}

/* 卦象卡片 */
.hexagram-card {
    border: 2px solid var(--fg);
    border-radius: 10px;
    padding: 18px 16px;
    margin-bottom: 16px;
    background: var(--bg);
}

.hexagram-card.ben {
    background: var(--bg);
}

.hexagram-card.bian {
    border-style: dashed;
    background: rgba(0,0,0,0.02);
}

.hexagram-head {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 14px;
    padding-bottom: 12px;
    border-bottom: 1.5px solid var(--light-border);
}

.hexagram-symbol-box {
    text-align: center;
    min-width: 80px;
}

.hexagram-symbol {
    font-size: 64px;
    line-height: 1;
    color: var(--fg);
    font-family: 'Noto Sans Symbols2', 'Segoe UI Symbol', 'Apple Symbols', 'Symbola', 'DejaVu Sans', serif;
    text-shadow: 0 0 1px rgba(0,0,0,0.1);
}

/* CSS 绘制的大卦象图（6爻堆叠） */
.hexagram-drawing {
    display: flex;
    flex-direction: column-reverse; /* 初爻在下，上爻在上 */
    align-items: center;
    gap: 5px;
    margin: 4px auto;
    width: 110px;
}

.hexagram-drawing .hd-yao {
    display: flex;
    align-items: center;
    height: 9px;
    position: relative;
}

.hexagram-drawing .hd-yao .hd-line {
    display: block;
    height: 9px;
    background: var(--fg);
    border-radius: 2px;
}

.hexagram-drawing .hd-yao.yang .hd-line {
    width: 100px;
}

.hexagram-drawing .hd-yao.yin .hd-line {
    width: 44px;
}

.hexagram-drawing .hd-yao.yin .hd-gap {
    width: 12px;
    display: inline-block;
}

.hexagram-drawing .hd-yao.changing .hd-line {
    background: #c0392b;
}

.hexagram-drawing .hd-yao.changing::after {
    content: attr(data-mark);
    position: absolute;
    right: -18px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 14px;
    color: #c0392b;
    font-weight: bold;
}

.hexagram-num {
    font-size: 11px;
    color: var(--muted);
    margin-top: 4px;
}

.hexagram-info {
    flex: 1;
}

.hexagram-name {
    font-size: 22px;
    font-weight: bold;
    margin-bottom: 4px;
    font-family: 'KaiTi', 'STKaiti', serif;
    letter-spacing: 2px;
}

.hexagram-full {
    font-size: 13px;
    color: var(--muted);
    margin-bottom: 6px;
}

.hexagram-wx {
    display: inline-block;
    padding: 2px 10px;
    border: 1.5px solid var(--fg);
    border-radius: 12px;
    font-size: 11px;
    color: var(--fg);
}

.hexagram-section {
    margin-bottom: 12px;
}

.hexagram-section:last-child {
    margin-bottom: 0;
}

.section-label {
    font-size: 12px;
    color: var(--muted);
    margin-bottom: 4px;
    font-weight: bold;
}

.section-text {
    font-size: 14px;
    line-height: 1.7;
    color: var(--fg);
    font-family: 'KaiTi', 'STKaiti', serif;
}

/* 爻辞列表 */
.yao-cis {
    margin-top: 10px;
}

.yao-ci-item {
    padding: 8px 10px;
    border-left: 3px solid var(--light-border);
    margin-bottom: 6px;
    font-size: 13px;
    line-height: 1.6;
    color: var(--fg);
    font-family: 'KaiTi', 'STKaiti', serif;
    background: rgba(0,0,0,0.02);
}

.yao-ci-item.changing {
    border-left-color: #c0392b;
    background: rgba(192, 57, 43, 0.05);
    color: #c0392b;
    font-weight: bold;
}

.yao-ci-pos {
    font-weight: bold;
    margin-right: 4px;
}

/* 综合解读 */
.summary-box {
    border: 2px solid var(--fg);
    border-radius: 10px;
    padding: 16px;
    margin-bottom: 16px;
    background: var(--bg);
}

.summary-title {
    font-size: 15px;
    font-weight: bold;
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1.5px solid var(--light-border);
    text-align: center;
    letter-spacing: 2px;
}

.summary-text {
    font-size: 14px;
    line-height: 1.8;
    color: var(--fg);
}

/* ===== 八字区 ===== */
.bazi-box {
    border: 1.5px dashed var(--fg);
    border-radius: 10px;
    padding: 14px;
    margin-bottom: 16px;
    background: rgba(0,0,0,0.02);
}

.bazi-title {
    font-size: 14px;
    font-weight: bold;
    text-align: center;
    margin-bottom: 10px;
    letter-spacing: 2px;
}

/* 测字笔画分析 */
.word-info-row {
    font-size: 13px;
    line-height: 1.8;
    text-align: left;
    padding: 2px 0;
}

.word-info-row .w-label {
    color: var(--muted);
    margin-right: 4px;
}

.bazi-pillars {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    margin-bottom: 12px;
}

.pillar-cell {
    text-align: center;
    padding: 8px 4px;
    border: 1.5px solid var(--light-border);
    border-radius: 6px;
    background: var(--bg);
}

.pillar-label {
    font-size: 11px;
    color: var(--muted);
    margin-bottom: 4px;
}

.pillar-ganzhi {
    font-size: 18px;
    font-weight: bold;
    font-family: 'KaiTi', 'STKaiti', serif;
    color: var(--fg);
    letter-spacing: 1px;
}

.pillar-shengxiao {
    font-size: 11px;
    color: var(--muted);
    margin-top: 2px;
}

/* 五行分析 */
.wuxing-analysis {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1.5px dashed var(--light-border);
}

.wuxing-row {
    display: flex;
    justify-content: space-around;
    margin-bottom: 8px;
}

.wuxing-item {
    text-align: center;
    flex: 1;
}

.wuxing-name {
    font-size: 13px;
    font-weight: bold;
    margin-bottom: 4px;
}

.wuxing-bar {
    height: 8px;
    background: var(--light-border);
    border-radius: 4px;
    overflow: hidden;
    margin: 0 4px;
}

.wuxing-bar-fill {
    height: 100%;
    background: var(--fg);
    transition: width 0.5s ease;
}

.wuxing-count {
    font-size: 11px;
    color: var(--muted);
    margin-top: 2px;
}

.wuxing-summary {
    font-size: 12px;
    color: var(--muted);
    text-align: center;
    line-height: 1.6;
    margin-top: 8px;
}

.wuxing-summary strong {
    color: var(--fg);
}

.wuxing-tag {
    display: inline-block;
    padding: 1px 6px;
    margin: 0 2px;
    border: 1px solid var(--fg);
    border-radius: 8px;
    font-size: 11px;
}

/* ===== 解卦区 ===== */
.divine-box {
    border: 2px solid var(--fg);
    border-radius: 10px;
    padding: 16px;
    margin-bottom: 16px;
    background: var(--bg);
}

.divine-title {
    font-size: 15px;
    font-weight: bold;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1.5px solid var(--light-border);
    text-align: center;
    letter-spacing: 2px;
}

/* 吉凶指示条 */
.luck-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 10px;
    margin-bottom: 12px;
    border-radius: 6px;
    background: rgba(0,0,0,0.03);
}

.luck-label {
    font-size: 13px;
    color: var(--muted);
}

.luck-value {
    font-size: 22px;
    font-weight: bold;
    font-family: 'KaiTi', 'STKaiti', serif;
    padding: 2px 16px;
    border-radius: 4px;
}

.luck-value.ji {
    color: #1a7a3a;
    background: rgba(26, 122, 58, 0.1);
}

.luck-value.zhongji {
    color: #2d6a9f;
    background: rgba(45, 106, 159, 0.1);
}

.luck-value.xiaohao {
    color: #b8860b;
    background: rgba(184, 134, 11, 0.1);
}

.luck-value.xiong {
    color: #c0392b;
    background: rgba(192, 57, 43, 0.1);
}

.luck-value.ping {
    color: var(--muted);
    background: rgba(128, 128, 128, 0.1);
}

/* 体用分析 */
.tiyong-row {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
    font-size: 13px;
    line-height: 1.7;
}

.tiyong-label {
    color: var(--muted);
    min-width: 60px;
}

.tiyong-value {
    color: var(--fg);
    flex: 1;
}

.tiyong-value strong {
    color: var(--fg);
}

/* 六神表 */
.liushen-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 4px;
    margin: 10px 0;
}

.ls-cell {
    text-align: center;
    padding: 6px 2px;
    border: 1.5px solid var(--light-border);
    border-radius: 4px;
    font-size: 11px;
    background: var(--bg);
}

.ls-pos {
    color: var(--muted);
    font-size: 10px;
    margin-bottom: 2px;
}

.ls-name {
    font-weight: bold;
    font-size: 12px;
}

.ls-name.ji { color: #1a7a3a; }
.ls-name.xiong { color: #c0392b; }
.ls-name.ping { color: var(--muted); }

/* 宜忌 */
.yiji-row {
    display: flex;
    gap: 16px;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1.5px dashed var(--light-border);
}

.yiji-col {
    flex: 1;
}

.yiji-head {
    font-size: 12px;
    font-weight: bold;
    margin-bottom: 6px;
    padding-bottom: 3px;
    border-bottom: 1px solid var(--light-border);
}

.yiji-head.yi { color: #1a7a3a; }
.yiji-head.ji { color: #c0392b; }

.yiji-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.yiji-tag {
    display: inline-block;
    padding: 2px 8px;
    border: 1px solid var(--light-border);
    border-radius: 10px;
    font-size: 11px;
    color: var(--fg);
    background: rgba(0,0,0,0.02);
}

/* 分类建议 */
.advice-box {
    margin-top: 10px;
    padding: 10px;
    border-left: 3px solid var(--fg);
    background: rgba(0,0,0,0.03);
    border-radius: 0 6px 6px 0;
    font-size: 13px;
    line-height: 1.7;
    color: var(--fg);
}

.advice-box .advice-cat {
    font-weight: bold;
    color: var(--fg);
}

/* ===== 历史记录 ===== */
.history-box {
    margin-top: 18px;
    padding: 12px;
    border: 1.5px solid var(--light-border);
    border-radius: 8px;
}

.history-title {
    font-size: 13px;
    font-weight: bold;
    margin-bottom: 8px;
    color: var(--muted);
}

.history-list {
    max-height: 200px;
    overflow-y: auto;
}

.history-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    border-bottom: 1px solid var(--light-border);
    font-size: 12px;
    cursor: pointer;
}

.history-item:hover {
    background: rgba(0,0,0,0.04);
}

.history-item:last-child {
    border-bottom: none;
}

.history-time {
    color: var(--muted);
    font-size: 11px;
    min-width: 110px;
}

.history-symbol {
    font-size: 20px;
}

.history-name {
    flex: 1;
    color: var(--fg);
}

.history-question {
    color: var(--muted);
    font-size: 11px;
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.history-empty {
    text-align: center;
    color: var(--muted);
    font-size: 12px;
    padding: 16px;
}

.history-clear {
    margin-top: 8px;
    text-align: right;
}

.history-clear button {
    background: none;
    border: none;
    color: var(--muted);
    font-size: 11px;
    cursor: pointer;
    text-decoration: underline;
}

/* ===== 操作按钮组 ===== */
.action-buttons {
    text-align: center;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1.5px solid var(--light-border);
}

/* ===== 移动端适配 ===== */
@media (max-width: 480px) {
    .zhouyi-main {
        padding: 1rem;
    }

    .method-options {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }

    .method-opt {
        padding: 0.7rem 0.4rem;
        flex: initial;
    }

    .method-opt:last-child {
        grid-column: span 2;
    }

    .method-name {
        font-size: 12px;
    }

    .method-desc {
        font-size: 10px;
    }

    .coin {
        width: 54px;
        height: 54px;
        font-size: 20px;
    }

    .coins-area {
        gap: 12px;
    }

    .hexagram-head {
        flex-direction: column;
        text-align: center;
        gap: 8px;
    }

    .hexagram-symbol {
        font-size: 48px;
    }

    .hexagram-name {
        font-size: 20px;
    }

    .cast-form-row {
        flex-direction: column;
        align-items: stretch;
        gap: 4px;
    }

    .cast-form-row label {
        min-width: auto;
    }

    .yao-symbol {
        min-width: 90px;
        font-size: 20px;
    }

    .btn-main, .btn-secondary {
        padding: 9px 22px;
        font-size: 14px;
    }

    .btn-secondary {
        margin-left: 0;
        margin-top: 8px;
    }

    .pillar-ganzhi {
        font-size: 16px;
    }

    .history-time {
        min-width: 90px;
    }

    .history-question {
        max-width: 120px;
    }

    .liushen-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 6px;
    }

    .yiji-row {
        flex-direction: column;
        gap: 10px;
    }

    .luck-value {
        font-size: 20px;
    }
}
