/* ============================
   chouqian.css - 抽签解签
   黑白简约 + 传统民俗风
   签筒动画 + 签诗展示 + 移动端适配
   ============================ */

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

.chouqian-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;
}

.question-input {
    text-align: left;
    margin-bottom: 1.5rem;
}

.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);
}

/* ===== 签筒动画区 ===== */
.sign-tube-stage {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px 0 28px;
    min-height: 240px;
}

.sign-tube {
    position: relative;
    width: 110px;
    height: 170px;
    cursor: pointer;
    transform-origin: bottom center;
    transition: transform 0.2s;
}

.sign-tube:hover {
    transform: translateY(-2px);
}

/* 签筒内的竹签（露出顶部） */
.tube-sticks {
    position: absolute;
    top: -18px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 3px;
    width: 84px;
    justify-content: center;
}

.tube-stick {
    width: 6px;
    height: 30px;
    background: var(--fg);
    border-radius: 3px 3px 0 0;
}

.tube-stick:nth-child(2) { height: 34px; }
.tube-stick:nth-child(3) { height: 28px; }
.tube-stick:nth-child(4) { height: 36px; }
.tube-stick:nth-child(5) { height: 30px; }

/* 签筒主体 */
.tube-body {
    position: absolute;
    top: 12px;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg);
    border: 2.5px solid var(--fg);
    border-radius: 8px 8px 18px 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: inset 0 -8px 0 rgba(0,0,0,0.04);
}

.tube-body::before {
    content: '';
    position: absolute;
    top: 8px;
    left: 50%;
    transform: translateX(-50%);
    width: 70%;
    height: 1.5px;
    background: var(--light-border);
}

.tube-label {
    font-family: 'KaiTi', 'STKaiti', serif;
    font-size: 22px;
    font-weight: bold;
    color: var(--fg);
    letter-spacing: 4px;
    writing-mode: vertical-rl;
    line-height: 1.4;
}

/* 摇晃动画 */
.sign-tube.shaking {
    animation: shake 1.2s ease-in-out;
}

@keyframes shake {
    0%, 100% { transform: rotate(0deg) translateY(0); }
    8%  { transform: rotate(-9deg) translateY(-2px); }
    16% { transform: rotate(10deg) translateY(-3px); }
    24% { transform: rotate(-12deg) translateY(-4px); }
    32% { transform: rotate(11deg) translateY(-3px); }
    40% { transform: rotate(-10deg) translateY(-4px); }
    48% { transform: rotate(9deg) translateY(-2px); }
    56% { transform: rotate(-8deg) translateY(-3px); }
    64% { transform: rotate(7deg) translateY(-2px); }
    72% { transform: rotate(-5deg) translateY(-1px); }
    80% { transform: rotate(4deg) translateY(-1px); }
    88% { transform: rotate(-2deg) translateY(0); }
}

/* 摇晃时签签轻微跳动 */
.sign-tube.shaking .tube-stick {
    animation: stickJitter 1.2s ease-in-out;
}

@keyframes stickJitter {
    0%, 100% { transform: translateY(0); }
    25% { transform: translateY(-2px); }
    50% { transform: translateY(-4px); }
    75% { transform: translateY(-1px); }
}

/* 弹出的签 */
.sign-out {
    margin-top: 16px;
    min-height: 50px;
    opacity: 0;
    transition: opacity 0.3s;
}

.sign-out.show {
    opacity: 1;
}

.popped-sign {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    animation: signOut 0.7s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* 签支主体（竖向长条，仿竹木签） */
.popped-sign-stick {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    width: 56px;
    padding: 14px 0 10px;
    background: linear-gradient(180deg, #c0392b 0%, #a93226 50%, #922b21 100%);
    color: #fff7e6;
    border-radius: 4px 4px 8px 8px;
    font-family: 'KaiTi', 'STKaiti', serif;
    box-shadow: 0 4px 14px rgba(0,0,0,0.25), inset 0 1px 0 rgba(255,255,255,0.15);
    position: relative;
}

.popped-sign-stick::before {
    content: '';
    position: absolute;
    top: -6px;
    left: 50%;
    transform: translateX(-50%);
    width: 10px;
    height: 10px;
    background: #c0392b;
    border-radius: 50%;
    box-shadow: 0 -2px 4px rgba(0,0,0,0.2);
}

.pss-top {
    font-size: 10px;
    writing-mode: vertical-rl;
    letter-spacing: 3px;
    opacity: 0.9;
}

.pss-num {
    font-size: 32px;
    font-weight: bold;
    line-height: 1;
    text-shadow: 0 1px 2px rgba(0,0,0,0.4);
    padding: 8px 0;
}

.pss-bottom {
    font-size: 12px;
    letter-spacing: 2px;
    opacity: 0.9;
}

.popped-sign-level {
    font-size: 14px;
    font-weight: bold;
    font-family: 'KaiTi', 'STKaiti', serif;
    padding: 3px 12px;
    border: 1.5px solid currentColor;
    border-radius: 12px;
    background: var(--bg);
}

@keyframes signOut {
    0% { transform: translateY(40px) scale(0.4); opacity: 0; }
    60% { transform: translateY(-8px) scale(1.1); opacity: 1; }
    100% { transform: translateY(0) scale(1); opacity: 1; }
}

/* ===== 按钮 ===== */
.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);
}

/* ===== 结果区 ===== */
.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;
}

/* 签卡 */
.sign-card {
    border: 2px solid var(--fg);
    border-radius: 10px;
    padding: 20px 18px;
    margin-bottom: 16px;
    background: var(--bg);
}

.sign-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 14px;
    margin-bottom: 14px;
    border-bottom: 1.5px solid var(--light-border);
}

.sign-num {
    font-size: 24px;
    font-weight: bold;
    font-family: 'KaiTi', 'STKaiti', serif;
    letter-spacing: 2px;
    color: var(--fg);
}

.sign-level {
    padding: 4px 14px;
    border: 1.5px solid var(--fg);
    border-radius: 14px;
    font-size: 13px;
    font-weight: bold;
    font-family: 'KaiTi', 'STKaiti', serif;
}

.sign-story {
    font-size: 13px;
    color: var(--muted);
    margin-bottom: 14px;
    text-align: center;
}

/* 签诗 */
.sign-poem {
    text-align: center;
    padding: 16px 8px;
    margin-bottom: 16px;
    background: rgba(0,0,0,0.02);
    border-radius: 8px;
}

.sign-poem .poem-line {
    display: block;
    font-family: 'KaiTi', 'STKaiti', serif;
    font-size: 22px;
    line-height: 1.9;
    color: var(--fg);
    letter-spacing: 3px;
}

/* 签意速览 */
.sign-quick {
    border-left: 4px solid var(--fg);
    padding: 10px 14px;
    margin-bottom: 14px;
    background: rgba(0,0,0,0.03);
    border-radius: 4px;
    font-size: 13px;
    line-height: 1.7;
    font-family: 'KaiTi', 'STKaiti', serif;
    font-weight: bold;
}

/* 化解之道（仅下签/下下签显示） */
.sign-resolve {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 14px;
    margin-bottom: 14px;
    background: #fff5f5;
    border: 1px dashed #b23a3a;
    border-radius: 6px;
    font-size: 12px;
    line-height: 1.7;
    color: #6b1a1a;
}

.sign-resolve .resolve-label {
    flex-shrink: 0;
    padding: 2px 8px;
    background: #b23a3a;
    color: #fff;
    border-radius: 3px;
    font-size: 11px;
    font-weight: bold;
    white-space: nowrap;
}

.sign-resolve .resolve-text {
    flex: 1;
    font-family: 'KaiTi', 'STKaiti', serif;
}

/* 同签历史提示 */
.dup-tip {
    background: #fff8e1;
    border: 1px dashed #d4a017;
    color: #8a6d00;
    padding: 8px 12px;
    margin-bottom: 14px;
    border-radius: 6px;
    font-size: 12px;
    line-height: 1.6;
    text-align: center;
}

/* 分步展开按钮区 */
.sign-expand-bar {
    text-align: center;
    margin: 14px 0;
}

.btn-expand {
    display: inline-block;
    padding: 8px 22px;
    background: var(--fg);
    color: var(--bg);
    border: 1.5px solid var(--fg);
    border-radius: 20px;
    font-size: 13px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s;
    letter-spacing: 1px;
}

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

.sign-story-wrap, .sign-jie-wrap {
    animation: fadeSlideIn 0.35s ease;
}

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

@media (max-width: 480px) {
    .sign-quick { font-size: 12px; padding: 8px 10px; }
    .sign-resolve { font-size: 11px; padding: 8px 10px; gap: 8px; }
    .sign-resolve .resolve-label { font-size: 10px; padding: 2px 6px; }
    .dup-tip { font-size: 11px; padding: 6px 10px; }
    .btn-expand { font-size: 12px; padding: 7px 18px; }
    .popped-sign-stick { width: 48px; padding: 12px 0 8px; }
    .pss-num { font-size: 26px; }
    .pss-top { font-size: 9px; }
    .pss-bottom { font-size: 11px; }
    .popped-sign-level { font-size: 12px; padding: 2px 10px; }
}

/* 签解段落 */
.sign-section {
    margin-bottom: 16px;
}

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

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

/* 十二项签解 */
.sign-jie-grid {
    border-top: 1.5px dashed var(--light-border);
    padding-top: 14px;
}

.jie-title {
    font-size: 13px;
    font-weight: bold;
    color: var(--muted);
    margin-bottom: 10px;
    text-align: center;
    letter-spacing: 2px;
}

.jie-item {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 7px 0;
    border-bottom: 1px solid var(--light-border);
    font-size: 13px;
    line-height: 1.6;
}

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

.jie-label {
    flex-shrink: 0;
    min-width: 52px;
    padding: 1px 6px;
    background: var(--fg);
    color: var(--bg);
    border-radius: 4px;
    font-size: 12px;
    font-weight: bold;
    text-align: center;
}

.jie-text {
    flex: 1;
    color: var(--fg);
    font-family: 'KaiTi', 'STKaiti', serif;
}

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

/* ===== 历史记录 ===== */
.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: 220px;
    overflow-y: auto;
}

.history-item {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    padding: 7px 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-num {
    font-size: 13px;
    font-weight: bold;
    min-width: 48px;
}

.history-level {
    font-size: 11px;
    padding: 1px 6px;
    border: 1px solid currentColor;
    border-radius: 8px;
}

.history-name {
    flex: 1;
    color: var(--fg);
    font-family: 'KaiTi', 'STKaiti', serif;
    font-size: 12px;
    min-width: 80px;
}

.history-question {
    color: var(--muted);
    font-size: 11px;
    width: 100%;
    padding-left: 118px;
    margin-top: -2px;
}

.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;
}

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

    .sign-tube {
        width: 96px;
        height: 150px;
    }

    .tube-sticks {
        width: 72px;
        top: -16px;
    }

    .tube-stick {
        width: 5px;
        height: 26px;
    }

    .tube-stick:nth-child(2) { height: 30px; }
    .tube-stick:nth-child(3) { height: 24px; }
    .tube-stick:nth-child(4) { height: 32px; }
    .tube-stick:nth-child(5) { height: 26px; }

    .tube-label {
        font-size: 18px;
        letter-spacing: 3px;
    }

    .sign-poem .poem-line {
        font-size: 19px;
        letter-spacing: 2px;
        line-height: 1.85;
    }

    .sign-num {
        font-size: 21px;
    }

    .sign-level {
        font-size: 12px;
        padding: 3px 10px;
    }

    .sign-card {
        padding: 16px 12px;
    }

    .jie-label {
        min-width: 46px;
        font-size: 11px;
    }

    .jie-text {
        font-size: 12.5px;
    }

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

    .btn-secondary {
        margin-left: 6px;
    }

    .history-time {
        min-width: 96px;
        font-size: 10px;
    }

    .history-question {
        padding-left: 104px;
    }

    .action-buttons {
        display: flex;
        justify-content: center;
        gap: 8px;
    }

    .action-buttons .btn-secondary {
        margin-left: 0;
    }
}
