/*!
 * QA 问答区块 v1.4.0
 */

.apap-qa-block {
    margin: clamp(36px, 6vw, 72px) auto;
    overflow-anchor: none;
}
.apap-qa-block .apap-block-text-link {
    color: var(--apap-block-link-color, currentColor);
    text-decoration-thickness: 1px;
    text-underline-offset: 0.16em;
}

/* 带 Hero 横幅时自身上下 margin 设为 0，让横幅紧贴导航；
   底部留少量 margin 作为 QA 列表与 footer 的视觉间隔。
   配合 page.php 模板里 main 的 padding-top:0 一起生效 */
.apap-qa-block.has-hero {
    margin-top: 0;
    margin-bottom: clamp(24px, 3vw, 40px);
}

.apap-qa-header {
    margin-bottom: clamp(20px, 3vw, 32px);
    text-align: center;
}

.apap-qa-header-inner {
    width: min(920px, calc(100% - 32px));
    margin-inline: auto;
}

.apap-qa-block.has-hero .apap-qa-header {
    position: relative;
    isolation: isolate;
    width: 100vw;
    min-height: var(--apap-qa-hero-height, clamp(220px, 32vw, 360px));
    margin: 0 calc(50% - 50vw) clamp(28px, 4vw, 48px);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background-position: center;
    background-size: cover;
    background-repeat: no-repeat;
    color: #fff;
}

.apap-qa-block.has-hero .apap-qa-header::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    background: linear-gradient(90deg, rgba(0, 71, 150, 0.78), rgba(0, 71, 150, 0.42));
}

.apap-qa-block.has-hero .apap-qa-header-inner {
    position: relative;
    z-index: 1;
}

.apap-qa-heading {
    margin: 0 auto 10px;
    color: var(--apap-color-text, #152238);
    font-size: clamp(1.85rem, 1.45vw + 1.4rem, 2.4rem);
    line-height: 1.25;
}

.apap-qa-intro {
    max-width: 760px;
    margin: 0 auto;
    color: var(--apap-color-muted, #64748b);
    font-size: clamp(1.42rem, 0.8vw + 1.18rem, 1.75rem);
    font-weight: 500;
    line-height: 1.65;
}

.apap-qa-block.has-hero .apap-qa-heading {
    color: #fff;
    font-size: clamp(30px, 4.4vw, 54px);
    text-shadow: 0 3px 16px rgba(0, 0, 0, 0.28);
}

.apap-qa-block.has-hero .apap-qa-intro {
    color: rgba(255, 255, 255, 0.88);
    text-shadow: 0 2px 12px rgba(0, 0, 0, 0.22);
}

.apap-qa-list {
    display: grid;
    gap: 12px;
    overflow-anchor: none;
}

.apap-qa-item {
    border: 0;
    background: #f7f8fa;
    overflow-anchor: none;
}

.apap-qa-item[open] {
    background: #f4f6f8;
}

.apap-qa-list.is-enhanced .apap-qa-item {
    transition: background-color 0.28s ease;
}

.apap-qa-question {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 18px;
    padding: 24px 32px;
    cursor: pointer;
    list-style: none;
    color: var(--apap-color-text, #152238);
    font-size: clamp(16px, 1.6vw, 20px);
    font-weight: 700;
    line-height: 1.45;
}

.apap-qa-question::-webkit-details-marker {
    display: none;
}

.apap-qa-icon {
    width: 24px;
    height: 24px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--apap-color-accent, #005bac);
    color: #fff;
    font-size: 14px;
    font-weight: 700;
}

.apap-qa-toggle {
    position: relative;
    width: 22px;
    height: 22px;
}

.apap-qa-toggle::before,
.apap-qa-toggle::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 16px;
    height: 2px;
    background: rgba(21, 34, 56, 0.58);
    transform: translate(-50%, -50%);
    transition: transform 0.2s ease, opacity 0.2s ease;
}

.apap-qa-toggle::after {
    transform: translate(-50%, -50%) rotate(90deg);
}

.apap-qa-item[open] .apap-qa-toggle::after {
    opacity: 0;
    transform: translate(-50%, -50%) rotate(0deg);
}

.apap-qa-list.is-enhanced .apap-qa-item:not(.is-open) .apap-qa-toggle::after {
    opacity: 1;
    transform: translate(-50%, -50%) rotate(90deg);
}

.apap-qa-answer {
    position: relative;
    margin: 0 32px 28px 74px;
    padding: 24px 0 4px;
    border-top: 1px solid rgba(15, 23, 42, 0.1);
    color: var(--apap-color-muted, #64748b);
    font-size: 15px;
    line-height: 1.9;
}

.apap-qa-list.is-enhanced .apap-qa-answer {
    overflow: hidden;
    max-height: 0;
    opacity: 0;
    margin-bottom: 0;
    padding-top: 0;
    padding-bottom: 0;
    border-top-color: transparent;
    /* 所有参与开合的属性必须用同一时长 + 同一曲线，否则会出现"高度先变 → 内容/内边距再跟上"
       的两段视觉效果（尤其在切换 QA 时旧项收起 + 新项展开同时进行更明显）。
       配合 qa-block.js 的 setActive 一次性调度——所有 transition 锁定同一帧启动，节奏完全同步。 */
    transition:
        max-height 0.42s ease-out,
        opacity 0.42s ease-out,
        margin-bottom 0.42s ease-out,
        padding 0.42s ease-out,
        border-color 0.42s ease-out;
}

.apap-qa-list.is-enhanced .apap-qa-item.is-open .apap-qa-answer {
    opacity: 1;
    margin-bottom: 28px;
    padding: 24px 0 4px;
    border-top-color: rgba(15, 23, 42, 0.1);
}

.apap-qa-answer::before {
    content: "...";
    position: absolute;
    top: 24px;
    left: -42px;
    width: 24px;
    height: 24px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 91, 172, 0.55);
    color: #fff;
    font-size: 13px;
    font-weight: 700;
}

.apap-qa-answer p {
    margin: 0 0 12px;
    color: var(--apap-color-muted, #64748b);
    line-height: 1.65;
}

.apap-qa-answer p:last-child {
    margin-bottom: 0;
}

@media (max-width: 640px) {
    .apap-qa-block.has-hero .apap-qa-header {
        min-height: var(--apap-qa-hero-height, 220px);
    }
    .apap-qa-question {
        gap: 12px;
        padding: 18px 18px;
        font-size: 16px;
    }
    .apap-qa-answer {
        margin: 0 18px 22px 56px;
        padding-top: 18px;
    }
    .apap-qa-list.is-enhanced .apap-qa-item.is-open .apap-qa-answer {
        margin-bottom: 22px;
        padding-top: 18px;
    }
    .apap-qa-answer::before {
        left: -38px;
        top: 18px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .apap-qa-toggle::before,
    .apap-qa-toggle::after,
    .apap-qa-list.is-enhanced .apap-qa-answer,
    .apap-qa-list.is-enhanced .apap-qa-item {
        transition: none;
    }
}
