/* ============================
   answerbook.css - 答案之书样式
   黑白简约 + 3D 翻页动画
   ============================ */

.ab-main {
    max-width: 720px;
    margin: 0 auto;
    padding-bottom: 20px;
}

.subtitle {
    text-align: center;
    color: var(--muted);
    font-size: 0.9rem;
    margin-top: 8px;
}

/* 问题输入区 */
.ab-question-area {
    text-align: center;
    margin-bottom: 30px;
}

.ab-input {
    width: 100%;
    max-width: 420px;
    padding: 12px 16px;
    font-size: 16px;
    border: 2px solid var(--fg);
    border-radius: 8px;
    background: var(--bg);
    color: var(--fg);
    box-sizing: border-box;
    text-align: center;
    font-family: inherit;
    transition: box-shadow 0.2s;
}

.ab-input:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(0,0,0,0.08);
}

.ab-hint {
    margin-top: 10px;
    font-size: 0.8rem;
    color: var(--muted);
    line-height: 1.6;
}

/* 书本舞台 */
.ab-book-stage {
    position: relative;
    width: 100%;
    max-width: 480px;
    height: 340px;
    margin: 0 auto 24px;
    perspective: 1600px;
    perspective-origin: center 40%;
}

.ab-book {
    position: absolute;
    inset: 0;
    transition: opacity 0.4s ease;
}

.ab-book-closed {
    cursor: pointer;
    z-index: 2;
}

.ab-book-closed.flipped {
    opacity: 0;
    pointer-events: none;
    z-index: 1;
}

.ab-book-open {
    opacity: 0;
    pointer-events: none;
    z-index: 1;
}

.ab-book-open.shown {
    opacity: 1;
    pointer-events: auto;
}

/* 闭合书的封面 */
.ab-book-cover {
    position: relative;
    width: 240px;
    height: 320px;
    margin: 10px auto;
    background: linear-gradient(135deg, #1a1a1a 0%, #000 100%);
    border-radius: 4px 8px 8px 4px;
    box-shadow:
        0 12px 30px rgba(0,0,0,0.3),
        inset 4px 0 8px rgba(255,255,255,0.05);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #fff;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.ab-book-closed:hover .ab-book-cover {
    transform: translateY(-4px);
    box-shadow:
        0 18px 40px rgba(0,0,0,0.4),
        inset 4px 0 8px rgba(255,255,255,0.08);
}

.ab-book-spine {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 8px;
    background: linear-gradient(90deg, rgba(0,0,0,0.6), rgba(255,255,255,0.1));
    border-radius: 4px 0 0 4px;
}

.ab-book-title {
    font-size: 1.8rem;
    font-weight: bold;
    letter-spacing: 4px;
    margin-bottom: 8px;
    text-shadow: 0 2px 4px rgba(0,0,0,0.5);
}

.ab-book-subtitle {
    font-size: 0.62rem;
    letter-spacing: 2px;
    color: rgba(255,255,255,0.5);
    margin-bottom: 24px;
}

.ab-book-decor {
    font-size: 1.6rem;
    color: rgba(255,255,255,0.7);
    margin-bottom: 24px;
}

.ab-book-hint {
    font-size: 0.78rem;
    color: rgba(255,255,255,0.6);
    animation: abPulse 2s ease-in-out infinite;
}

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

/* 翻开的书 */
.ab-book-open .ab-page {
    position: absolute;
    top: 0;
    width: 50%;
    height: 100%;
    background: #fdfcf8;
    border: 1px solid #d8d4c8;
    box-shadow: 0 4px 16px rgba(0,0,0,0.1);
    overflow: hidden;
}

.ab-page-left {
    left: 0;
    border-radius: 8px 0 0 8px;
    border-right: none;
    box-shadow: inset -6px 0 12px -8px rgba(0,0,0,0.2);
}

.ab-page-right {
    right: 0;
    border-radius: 0 8px 8px 0;
    border-left: none;
    box-shadow: inset 6px 0 12px -8px rgba(0,0,0,0.2);
}

.ab-page-content {
    padding: 32px 20px;
    height: 100%;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
}

.ab-page-left .ab-page-content {
    align-items: flex-end;
    text-align: right;
}

.ab-page-question {
    font-size: 1rem;
    line-height: 1.7;
    color: #333;
    font-style: italic;
    max-width: 90%;
    word-break: break-word;
}

.ab-page-divider {
    width: 60%;
    height: 1px;
    background: #c8c4b8;
    margin: 16px 0;
}

.ab-page-label {
    font-size: 0.72rem;
    color: var(--muted);
    letter-spacing: 3px;
    text-transform: uppercase;
}

.ab-page-right .ab-page-content {
    align-items: flex-start;
    justify-content: center;
    text-align: left;
}

.ab-answer {
    font-size: 1.5rem;
    font-weight: bold;
    line-height: 1.5;
    color: var(--fg);
    margin-bottom: 14px;
    word-break: break-word;
    animation: abFadeIn 0.8s ease 0.4s both;
}

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

.ab-answer-cat {
    font-size: 0.72rem;
    color: var(--muted);
    letter-spacing: 2px;
    padding: 2px 8px;
    border: 1px solid var(--light-border);
    border-radius: 12px;
    animation: abFadeIn 0.8s ease 0.6s both;
}

/* 翻页动画 */
.ab-flip-page {
    position: absolute;
    top: 0;
    left: 50%;
    width: 50%;
    height: 100%;
    transform-origin: left center;
    transform-style: preserve-3d;
    transform: rotateY(0deg);
    transition: transform 0.9s cubic-bezier(0.4, 0.0, 0.2, 1);
    z-index: 10;
    pointer-events: none;
    opacity: 0;
}

.ab-flip-page.flipping {
    opacity: 1;
    transform: rotateY(-180deg);
}

.ab-flip-front,
.ab-flip-back {
    position: absolute;
    inset: 0;
    backface-visibility: hidden;
    background: #fdfcf8;
    border: 1px solid #d8d4c8;
    border-radius: 0 8px 8px 0;
    box-shadow: 0 4px 16px rgba(0,0,0,0.15);
}

.ab-flip-front {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    color: var(--muted);
}

.ab-flip-back {
    transform: rotateY(180deg);
    border-radius: 8px 0 0 8px;
    background: linear-gradient(135deg, #1a1a1a 0%, #000 100%);
}

/* 操作按钮 */
.ab-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: 24px;
}

.ab-btn {
    padding: 10px 22px;
    font-size: 0.9rem;
    border: 2px solid var(--fg);
    border-radius: 6px;
    background: var(--bg);
    color: var(--fg);
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}

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

.ab-btn-primary {
    background: var(--fg);
    color: var(--bg);
}

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

/* 工具栏 */
.ab-toolbar {
    display: flex;
    gap: 8px;
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: 30px;
}

.ab-tool-btn {
    padding: 6px 14px;
    font-size: 0.8rem;
    border: 1.5px solid var(--light-border);
    border-radius: 16px;
    background: var(--bg);
    color: var(--muted);
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}

.ab-tool-btn:hover {
    border-color: var(--fg);
    color: var(--fg);
}

/* 说明区 */
.ab-info {
    margin: 0 auto;
    max-width: 600px;
    padding: 14px 18px;
    border: 1px solid var(--light-border);
    border-radius: 8px;
    background: #fafafa;
}

.ab-info summary {
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--fg);
    font-weight: 500;
    list-style: none;
}

.ab-info summary::-webkit-details-marker {
    display: none;
}

.ab-info summary::before {
    content: '▸ ';
    color: var(--muted);
}

.ab-info[open] summary::before {
    content: '▾ ';
}

.ab-info-content {
    margin-top: 12px;
    font-size: 0.85rem;
    line-height: 1.7;
    color: #444;
}

.ab-info-content p {
    margin-bottom: 8px;
}

.ab-info-content ol {
    margin: 8px 0 12px 20px;
}

.ab-info-content li {
    margin-bottom: 4px;
}

/* Toast */
.ab-toast {
    position: fixed;
    left: 50%;
    bottom: 110px;
    transform: translateX(-50%) translateY(20px);
    background: var(--fg);
    color: var(--bg);
    padding: 10px 20px;
    border-radius: 22px;
    font-size: 0.85rem;
    z-index: 9999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s, transform 0.25s;
    max-width: 80%;
    text-align: center;
}

.ab-toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* 响应式 */
@media (max-width: 480px) {
    .ab-book-stage {
        height: 280px;
    }

    .ab-book-cover {
        width: 200px;
        height: 270px;
    }

    .ab-book-title {
        font-size: 1.5rem;
    }

    .ab-page-content {
        padding: 24px 14px;
    }

    .ab-answer {
        font-size: 1.25rem;
    }

    .ab-page-question {
        font-size: 0.9rem;
    }

    .ab-btn {
        padding: 8px 16px;
        font-size: 0.85rem;
    }

    .ab-tool-btn {
        padding: 5px 12px;
        font-size: 0.75rem;
    }
}
