/* Apap Modern - World Map
   全部颜色 / 圆角 / 阴影来自 style.css 的 design tokens，与全站统一节奏。
   蓝白主题：surface-alt 背景 + 品牌蓝点缀；进入视口时数字 + 横线动画。 */

.apap-wm {
    padding: var(--apap-section-pad-y, clamp(56px, 8vw, 96px)) 0;
    background: var(--apap-color-surface-alt, #f2f5f9);
    color: var(--apap-color-text, #0f172a);
    overflow: visible;
}

.apap-wm-container {
    width: 100%;
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 clamp(16px, 4vw, 32px);
    box-sizing: border-box;
}

/* ---------- 外层包裹（保留 .apap-wm-sticky-wrap 类名以兼容已有模板，
   但不再做 sticky / 100vh 强制满屏，统一让 .apap-wm 按内容自然展开） ---------- */

.apap-wm-sticky-wrap {
    position: relative;
    background: var(--apap-color-surface-alt, #f2f5f9);
    overflow: visible;
}

/* ---------- 大屏（≥ 1200px）放大版式 ----------
   通过 clamp / vw / cqi 让标题、统计数字、办事处 marker 在 14"~32" 屏之间平滑缩放，
   所有元素都按内容自然占位，不再受单屏视口高度限制。 */
@media (min-width: 1200px) {
    .apap-wm-sticky-wrap > .apap-wm > .apap-wm-container {
        max-width: clamp(1280px, 92vw, 1600px);
        width: 100%;
    }
    .apap-wm-sticky-wrap > .apap-wm .apap-wm-stage {
        grid-template-columns: minmax(360px, 1fr) minmax(0, 2.4fr);
        gap: clamp(32px, 5vw, 72px);
        align-items: center;
    }
    .apap-wm-sticky-wrap > .apap-wm .apap-wm-intro {
        gap: 22px;
        min-width: 0;
        container-type: inline-size;
    }
    .apap-wm-sticky-wrap > .apap-wm .apap-wm-subheading {
        font-size: clamp(15px, 1vw + 0.3rem, 18px);
    }
    .apap-wm-sticky-wrap > .apap-wm .apap-wm-heading {
        font-size: clamp(28px, min(2.6vw, 11cqi), 48px);
        line-height: 1.18;
        text-wrap: balance;
        overflow-wrap: break-word;
        word-break: normal;
        hyphens: auto;
    }
    .apap-wm-sticky-wrap > .apap-wm .apap-wm-desc {
        font-size: clamp(15px, 0.9vw + 0.4rem, 18px);
        text-wrap: pretty;
    }
    .apap-wm-sticky-wrap > .apap-wm .apap-wm-cta {
        font-size: 16px;
    }
    .apap-wm-sticky-wrap > .apap-wm .apap-wm-cta-arrow {
        width: 38px;
        height: 38px;
    }
    .apap-wm-sticky-wrap > .apap-wm .apap-wm-legend {
        font-size: 14px;
    }
    .apap-wm-sticky-wrap > .apap-wm .apap-wm-legend-dot {
        width: 14px;
        height: 14px;
    }
    .apap-wm-sticky-wrap > .apap-wm .apap-wm-label {
        font-size: clamp(13px, 0.85vw + 0.3rem, 17px);
    }
    .apap-wm-sticky-wrap > .apap-wm .apap-wm-office {
        width: 40px;
        height: 40px;
    }
    .apap-wm-sticky-wrap > .apap-wm .apap-wm-office-dot {
        width: 13px;
        height: 13px;
    }

    /* 底部统计条（按内容流式排版，不再做 vh 压缩，保证标签文字始终可见） */
    .apap-wm-sticky-wrap > .apap-wm .apap-wm-stats {
        margin-top: clamp(28px, 4vw, 56px);
        gap: 24px;
        padding: 12px 8px 0;
    }
    .apap-wm-sticky-wrap > .apap-wm .apap-wm-stat {
        gap: 8px;
        min-width: 140px;
    }
    .apap-wm-sticky-wrap > .apap-wm .apap-wm-stat-icon {
        width: 54px;
        height: 54px;
        margin-bottom: 14px;
    }
    .apap-wm-sticky-wrap > .apap-wm .apap-wm-stat-icon .dashicons {
        font-size: 26px;
        width: 26px;
        height: 26px;
        line-height: 26px;
    }
    .apap-wm-sticky-wrap > .apap-wm .apap-wm-stat-value {
        font-size: clamp(32px, 3vw, 48px);
        gap: 4px;
    }
    .apap-wm-sticky-wrap > .apap-wm .apap-wm-stat-label {
        font-size: 14px;
    }
    .apap-wm-sticky-wrap > .apap-wm .apap-wm-stats-line {
        margin-top: -30px;
    }
}

/* 超大屏（≥ 1600px）再放大一档 */
@media (min-width: 1600px) {
    .apap-wm-sticky-wrap > .apap-wm > .apap-wm-container {
        max-width: 1720px;
    }
    .apap-wm-sticky-wrap > .apap-wm .apap-wm-heading {
        font-size: clamp(32px, min(2.6vw, 11cqi), 64px);
    }
    .apap-wm-sticky-wrap > .apap-wm .apap-wm-stat-value {
        font-size: clamp(40px, 2.8vw, 58px);
    }
}

/* 平板 / 小桌面（< 1200px） — 上下流式布局，地图居中，统计条自然换行 */
@media (max-width: 1199px) {
    .apap-wm {
        padding: clamp(48px, 7vw, 78px) 0;
    }

    .apap-wm-stage {
        grid-template-columns: 1fr;
        gap: 28px;
    }

    .apap-wm-intro {
        max-width: 720px;
    }

    .apap-wm-map {
        max-width: 980px;
        margin: 0 auto;
    }
}

.apap-wm-stage {
    position: relative;
    display: grid;
    grid-template-columns: minmax(260px, 320px) 1fr;
    gap: clamp(24px, 4vw, 56px);
    align-items: center;
}

@media (max-width: 900px) {
    .apap-wm-stage {
        grid-template-columns: 1fr;
        gap: 24px;
    }
}

/* ---------- 左侧文案 ---------- */

.apap-wm-intro {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.apap-wm-subheading {
    margin: 0;
    font-size: 14px;
    line-height: 1.6;
    letter-spacing: 0.02em;
    color: var(--apap-color-accent, #014098);
    font-weight: 600;
    white-space: pre-line;
}

.apap-wm-heading {
    margin: 0;
    font-size: clamp(26px, 3vw, 38px);
    font-weight: 700;
    line-height: 1.25;
    letter-spacing: -0.005em;
    color: var(--apap-color-text-strong, #050912);
}

.apap-wm-heading br {
    line-height: 0;
}

.apap-wm-desc {
    margin: 0;
    font-size: 15px;
    line-height: 1.7;
    color: var(--apap-color-text-muted, #475569);
}

.apap-wm-cta {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 0;
    background: transparent;
    color: var(--apap-color-accent, #014098);
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    width: -moz-fit-content;
    width: fit-content;
    transition: color 0.18s ease;
}

.apap-wm-cta:hover,
.apap-wm-cta:focus-visible {
    color: var(--apap-color-accent-dark, #00317d);
}

.apap-wm-cta.is-static {
    cursor: default;
}

.apap-wm-cta-arrow {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 1px solid currentColor;
    transition: transform 0.18s ease, background 0.18s ease, color 0.18s ease;
}

.apap-wm-cta:hover .apap-wm-cta-arrow,
.apap-wm-cta:focus-visible .apap-wm-cta-arrow {
    background: var(--apap-color-accent, #014098);
    color: #fff;
    transform: translate(2px, -2px);
}

/* ---------- 左侧图例（海外分支机构标识） ---------- */

.apap-wm-legend {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    margin-top: 8px;
    color: var(--apap-color-text-muted, #475569);
    font-size: 13px;
}

.apap-wm-legend-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--apap-color-accent, #014098);
    box-shadow: 0 0 0 4px rgba(1, 64, 152, 0.18);
}

/* ---------- 中央地图 ---------- */

.apap-wm-map {
    position: relative;
    width: 100%;
    border-radius: var(--apap-radius-md, 12px);
    overflow: visible;
    /* 高度由内联 SVG 的真实 viewBox 比例（约 784:458）决定，
       % 定位的 label / 办事处 marker / 弹层始终与海岸线对齐 */
}

.apap-wm-map.is-empty {
    aspect-ratio: 16 / 7;
    background: linear-gradient(180deg, #eaf0f9 0%, #f2f5f9 100%);
    border: 1px dashed var(--apap-color-border-strong, #cdd6e4);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--apap-color-text-muted, #475569);
    font-size: 14px;
    padding: 24px;
    text-align: center;
}

/* ---------- 主题自带 SVG 真实地图（每个国家一条 path，按 data-region 归到 6 大洲） ---------- */

.apap-wm-svg {
    display: block;
    width: 100%;
    height: auto;
    overflow: visible;
    position: relative;
    z-index: 1;
    -webkit-user-select: none;
       -moz-user-select: none;
            user-select: none;
}

/* 默认：未归到任何大洲的 path（海洋边缘小岛 / unmatched ID）—— 极浅蓝 */
.apap-wm-svg path,
.apap-wm-svg g > path {
    fill: #e6edf6;
    stroke: #ffffff;
    stroke-width: 0.4;
    stroke-linejoin: round;
    transition: fill 0.22s ease;
}

/* 已归属到某个大洲的国家：稍深一档浅蓝（cdph 风格灰蓝陆地色） */
.apap-wm-svg [data-region],
.apap-wm-svg [data-region] path {
    fill: #b9cde6;
    cursor: pointer;
}

/* hover 同组任意 path 时，由 JS 把同 data-region 的所有 path / g 加上 is-hover；
   被点击的洲再加 is-active。两个状态都用更深的品牌蓝整块点亮，沿着真实海岸线。 */
.apap-wm-svg [data-region].is-hover,
.apap-wm-svg [data-region].is-hover path,
.apap-wm-svg [data-region].is-active,
.apap-wm-svg [data-region].is-active path {
    fill: #1d6dd1;
}

.apap-wm-svg [data-region].is-active,
.apap-wm-svg [data-region].is-active path {
    fill: #014098;
}

/* 默认禁用 path 的 focus 框，由 JS 把 focus / blur 桥到同组 hover 状态 */
.apap-wm-svg [data-region]:focus {
    outline: none;
}

/* ---------- 大洲文字标签 ---------- */

.apap-wm-labels {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 3;
}

.apap-wm-label {
    position: absolute;
    transform: translate(-50%, -50%);
    font-size: clamp(11px, 1vw, 14px);
    line-height: 1;
    color: #ffffff;
    font-weight: 600;
    letter-spacing: 0.04em;
    white-space: nowrap;
    text-shadow: 0 1px 4px rgba(1, 32, 76, 0.45);
    pointer-events: none;
    opacity: 0.92;
}

/* ---------- 海外办事处 marker（水滴动效） ---------- */

.apap-wm-offices {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 4;
}

.apap-wm-office-wrap {
    position: absolute;
    width: 0;
    height: 0;
    pointer-events: none;
}

.apap-wm-office {
    position: absolute;
    left: 0;
    top: 0;
    transform: translate(-50%, -50%);
    /* hit area 比可见 dot 大很多，避免 hover 时鼠标稍微移动就丢失 */
    width: 32px;
    height: 32px;
    padding: 0;
    background: transparent;
    border: 0;
    cursor: pointer;
    pointer-events: auto;
    color: var(--apap-color-accent, #014098);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.apap-wm-office:focus-visible {
    outline: 2px solid var(--apap-color-focus-ring, rgba(1, 64, 152, 0.45));
    outline-offset: 4px;
    border-radius: 50%;
}

.apap-wm-office-dot {
    position: absolute;
    inset: 0;
    margin: auto;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--apap-color-accent, #014098);
    box-shadow:
        0 0 0 3px #ffffff,
        0 0 0 4px rgba(1, 64, 152, 0.4),
        0 4px 10px rgba(1, 64, 152, 0.35);
    z-index: 3;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.apap-wm-office:hover .apap-wm-office-dot,
.apap-wm-office.is-open .apap-wm-office-dot {
    transform: scale(1.18);
    box-shadow:
        0 0 0 3px #ffffff,
        0 0 0 5px rgba(1, 64, 152, 0.55),
        0 6px 14px rgba(1, 64, 152, 0.45);
}

/* 三层水滴振荡环：每层不同延迟、不同节奏，形成"涟漪"质感 */
.apap-wm-office-pulse {
    position: absolute;
    inset: 0;
    margin: auto;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: rgba(1, 64, 152, 0.45);
    z-index: 1;
    animation: apap-wm-droplet 2.6s cubic-bezier(0.16, 1, 0.3, 1) infinite;
    transform-origin: center center;
    will-change: transform, opacity;
}

.apap-wm-office-pulse-2 {
    background: rgba(1, 64, 152, 0.32);
    animation-delay: 0.6s;
    animation-duration: 2.6s;
}

.apap-wm-office-pulse-3 {
    background: rgba(1, 64, 152, 0.22);
    animation-delay: 1.2s;
    animation-duration: 2.6s;
}

@keyframes apap-wm-droplet {
    0% {
        transform: scale(0.6);
        opacity: 0.85;
    }
    50% {
        opacity: 0.45;
    }
    100% {
        transform: scale(4.5);
        opacity: 0;
    }
}

@media (prefers-reduced-motion: reduce) {
    .apap-wm-office-pulse {
        animation: none;
        opacity: 0.4;
        transform: scale(1.6);
    }
}

/* ---------- 办事处联系卡（cdph 风格：深蓝 header + 三行键值） ---------- */

.apap-wm-office-card {
    position: absolute;
    /* 默认从 marker 右上方出，箭头指向 marker；JS 根据位置切左/右、上/下 */
    left: 14px;
    top: -14px;
    transform: translateY(-100%);
    min-width: 240px;
    max-width: 300px;
    background: #fff;
    border-radius: var(--apap-radius-md, 12px);
    border: 1px solid var(--apap-color-border, #e5eaf2);
    box-shadow: 0 18px 40px -16px rgba(1, 32, 76, 0.35), 0 2px 8px rgba(15, 23, 42, 0.06);
    z-index: 8;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.18s ease, transform 0.2s ease;
    overflow: hidden;
}

.apap-wm-office-wrap.is-open .apap-wm-office-card {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(-100%) translateY(-6px);
}

.apap-wm-office-card[hidden] {
    display: none;
}

.apap-wm-office-wrap.is-open .apap-wm-office-card[hidden] {
    display: block;
}

.apap-wm-office-card-head {
    background: var(--apap-color-accent, #014098);
    color: #fff;
    padding: 10px 16px;
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.apap-wm-office-card-body {
    padding: 14px 16px 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: #f7f9fc;
}

.apap-wm-office-row {
    display: grid;
    grid-template-columns: 44px 1fr;
    gap: 12px;
    font-size: 13px;
    line-height: 1.55;
    align-items: start;
}

.apap-wm-office-key {
    color: var(--apap-color-text-muted, #475569);
    font-size: 12px;
    letter-spacing: 0.04em;
    padding-top: 1px;
}

.apap-wm-office-val {
    color: var(--apap-color-text, #0f172a);
    word-break: break-word;
}

.apap-wm-office-val a {
    color: var(--apap-color-accent, #014098);
    text-decoration: none;
}

.apap-wm-office-val a:hover {
    text-decoration: underline;
}

/* 当卡片靠近右边缘时切到左侧打开 */
.apap-wm-office-wrap[data-side="left"] .apap-wm-office-card {
    left: auto;
    right: 14px;
}

/* 当卡片靠近上边缘时改为从下方打开 */
.apap-wm-office-wrap[data-vside="bottom"] .apap-wm-office-card {
    top: 14px;
    transform: translateY(0);
}

.apap-wm-office-wrap[data-vside="bottom"].is-open .apap-wm-office-card {
    transform: translateY(6px);
}

/* ---------- 大洲点击弹层（国家列表） ---------- */

.apap-wm-region-popovers {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 6;
}

.apap-wm-region-popover {
    position: absolute;
    transform: translate(-50%, -50%) translateY(-50%) scale(0.96);
    transform-origin: center top;
    min-width: 220px;
    max-width: 300px;
    padding: 18px 20px 16px;
    background: #fff;
    border-radius: var(--apap-radius-md, 12px);
    border: 1px solid var(--apap-color-border, #e5eaf2);
    box-shadow: 0 24px 48px -16px rgba(1, 32, 76, 0.32), 0 2px 8px rgba(15, 23, 42, 0.06);
    z-index: 7;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.18s ease, transform 0.22s cubic-bezier(0.22, 1, 0.36, 1);
}

.apap-wm-region-popover.is-open {
    opacity: 1;
    pointer-events: auto;
    transform: translate(-50%, -50%) translateY(-50%) scale(1);
}

.apap-wm-region-popover[hidden] {
    display: none;
}

.apap-wm-region-popover.is-open[hidden] {
    display: block;
}

.apap-wm-region-popover-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 0 0 12px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--apap-color-border, #e5eaf2);
}

.apap-wm-region-popover-head strong {
    font-size: 16px;
    font-weight: 700;
    color: var(--apap-color-text-strong, #050912);
}

.apap-wm-region-popover-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    padding: 0;
    background: transparent;
    border: 0;
    border-radius: 4px;
    color: var(--apap-color-text-muted, #475569);
    cursor: pointer;
    transition: background 0.16s ease, color 0.16s ease;
}

.apap-wm-region-popover-close:hover,
.apap-wm-region-popover-close:focus-visible {
    background: var(--apap-color-accent-soft, #e5f4fb);
    color: var(--apap-color-accent, #014098);
    outline: none;
}

.apap-wm-region-popover-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
    max-height: 280px;
    overflow-y: auto;
}

.apap-wm-region-popover-list li + li {
    border-top: 1px dashed var(--apap-color-border, #e5eaf2);
}

.apap-wm-region-popover-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 9px 6px 9px 4px;
    color: var(--apap-color-text, #0f172a);
    font-size: 14px;
    text-decoration: none;
    border-radius: 4px;
    transition: color 0.16s ease, background 0.16s ease, padding-left 0.16s ease;
}

a.apap-wm-region-popover-item:hover,
a.apap-wm-region-popover-item:focus-visible {
    color: var(--apap-color-accent, #014098);
    background: var(--apap-color-accent-soft, #e5f4fb);
    padding-left: 8px;
    outline: none;
}

.apap-wm-region-popover-item.is-static {
    color: var(--apap-color-text-muted, #475569);
}

.apap-wm-region-popover-arrow {
    display: inline-flex;
    align-items: center;
    color: var(--apap-color-accent, #014098);
    opacity: 0.7;
    transition: transform 0.16s ease, opacity 0.16s ease;
}

a.apap-wm-region-popover-item:hover .apap-wm-region-popover-arrow,
a.apap-wm-region-popover-item:focus-visible .apap-wm-region-popover-arrow {
    transform: translateX(2px);
    opacity: 1;
}

/* ---------- 底部统计条（横向连接线 + 计数动画） ---------- */

.apap-wm-stats {
    margin-top: clamp(28px, 5vw, 56px);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 12px 8px 0;
    flex-wrap: nowrap;
}

@media (max-width: 720px) {
    .apap-wm-stats {
        flex-wrap: wrap;
        gap: 24px 12px;
    }
}

.apap-wm-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    flex: 0 0 auto;
    min-width: 110px;
}

.apap-wm-stat-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: #fff;
    border: 1px solid var(--apap-color-border, #e5eaf2);
    color: var(--apap-color-accent, #014098);
    margin-bottom: 14px;
    box-shadow: 0 2px 6px rgba(1, 64, 152, 0.06);
}

.apap-wm-stat-icon .dashicons {
    font-size: 22px;
    width: 22px;
    height: 22px;
    line-height: 22px;
}

.apap-wm-stat-meta {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.apap-wm-stat-value {
    display: inline-flex;
    align-items: baseline;
    gap: 2px;
    font-size: clamp(24px, 3vw, 32px);
    font-weight: 700;
    color: var(--apap-color-text-strong, #050912);
    font-variant-numeric: tabular-nums;
    line-height: 1.1;
}

.apap-wm-stat-suffix {
    font-size: 0.78em;
    font-weight: 700;
    color: var(--apap-color-accent, #014098);
}

.apap-wm-stat-label {
    font-size: 13px;
    color: var(--apap-color-text-muted, #475569);
    line-height: 1.4;
}

.apap-wm-stats-line {
    flex: 1 1 auto;
    height: 1px;
    background: var(--apap-color-border, #e5eaf2);
    position: relative;
    margin: -22px 6px 0;
    align-self: flex-start;
    border-radius: 1px;
    overflow: hidden;
}

.apap-wm-stats-line-fill {
    position: absolute;
    inset: 0 auto 0 0;
    width: 0%;
    background: linear-gradient(90deg, var(--apap-color-accent, #014098) 0%, rgba(1, 64, 152, 0.35) 100%);
    transition: width 1.6s cubic-bezier(0.22, 1, 0.36, 1);
}

.apap-wm.is-revealed .apap-wm-stats-line-fill {
    width: 100%;
}

@media (prefers-reduced-motion: reduce) {
    .apap-wm-stats-line-fill {
        transition: none;
        width: 100%;
    }
}

@media (max-width: 720px) {
    .apap-wm-stats-line {
        display: none;
    }
}
