/* ============================================================
   站点公告弹窗（announcement.css）
   仅在有可展示公告时由 portal_head.php 条件加载
   ============================================================ */

/* 弹窗打开时锁定背景滚动 */
body.ann-open {
    overflow: hidden;
}

.ann-dialog {
    position: fixed;
    inset: 0;
    margin: auto;
    width: min(560px, calc(100vw - 32px));
    max-height: min(84vh, 640px);
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--fg);
    overflow: visible;
}

.ann-dialog:not([open]) {
    display: none;
}

.ann-dialog::backdrop {
    background: rgba(18, 17, 15, 0.52);
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
    animation: ann-backdrop-in var(--dur-sm) var(--ease-out);
}

.ann-panel {
    display: flex;
    flex-direction: column;
    max-height: inherit;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.55), rgba(255, 255, 255, 0)), var(--bg);
    border: 1px solid var(--hairline);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lift);
    overflow: hidden;
}

.ann-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 18px 20px 14px 24px;
    border-bottom: 1px solid var(--hairline);
}

.ann-kicker {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.14em;
    color: var(--accent-2);
    text-transform: uppercase;
}

.ann-kicker-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent-2);
    box-shadow: 0 0 0 4px var(--accent-soft);
}

.ann-icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    padding: 0;
    border: 1px solid transparent;
    border-radius: 50%;
    background: transparent;
    color: var(--fg-2);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: background var(--dur-sm) var(--ease-out), color var(--dur-sm) var(--ease-out),
                border-color var(--dur-sm) var(--ease-out), transform var(--dur-xs) var(--ease-out);
}

.ann-icon-btn svg {
    width: 18px;
    height: 18px;
}

.ann-icon-btn:hover {
    background: var(--accent-soft);
    border-color: var(--hairline);
    color: var(--fg);
}

.ann-icon-btn:focus-visible {
    outline: 2px solid var(--accent-2);
    outline-offset: 2px;
}

.ann-scroll {
    flex: 1 1 auto;
    min-height: 0;
    padding: 20px 24px 10px;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}

.ann-title {
    margin: 0 0 8px;
    font-family: var(--font-sans);
    font-size: clamp(20px, 3.4vw, 26px);
    font-weight: 700;
    line-height: 1.36;
    letter-spacing: -0.01em;
    color: var(--fg);
    overflow-wrap: anywhere;
    word-break: break-word;
}

.ann-meta {
    margin: 0 0 16px;
    font-size: 12.5px;
    letter-spacing: 0.02em;
    color: var(--fg-3);
}

.ann-content {
    font-size: 15.5px;
    line-height: 1.8;
    color: var(--fg-2);
    overflow-wrap: anywhere;
    word-break: break-word;
}

.ann-content > :first-child {
    margin-top: 0;
}

.ann-content > :last-child {
    margin-bottom: 0;
}

.ann-footer {
    flex: 0 0 auto;
    padding: 16px 24px calc(18px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--hairline);
    background: var(--bg);
}

.ann-feedback {
    display: none;
    margin: 0 0 10px;
    font-size: 13px;
    line-height: 1.5;
    color: var(--fg-3);
}

.ann-feedback.is-ok,
.ann-feedback.is-error {
    display: block;
}

.ann-feedback.is-error {
    color: #b4412f;
}

.ann-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 10px;
}

.ann-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: var(--touch);
    padding: 0 20px;
    border: 1px solid transparent;
    border-radius: 999px;
    font-family: var(--font-sans);
    font-size: 14.5px;
    font-weight: 600;
    line-height: 1.2;
    text-decoration: none;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    transition: transform var(--dur-xs) var(--ease-out), box-shadow var(--dur-sm) var(--ease-out),
                background var(--dur-sm) var(--ease-out), border-color var(--dur-sm) var(--ease-out),
                color var(--dur-sm) var(--ease-out), opacity var(--dur-sm) var(--ease-out);
}

/* 多按钮场景：按下立即有可见反馈，避免「点完没反应」 */
.ann-btn:active:not(:disabled) {
    transform: scale(0.970);
    opacity: 0.92;
}

.ann-btn.is-secondary:active:not(:disabled) {
    background: var(--accent-soft);
    border-color: var(--accent-soft);
}

.ann-icon-btn:active {
    background: var(--accent-soft);
    transform: scale(0.94);
}

.ann-btn.is-primary {
    background: var(--accent-grad);
    color: #fff;
    box-shadow: 0 10px 24px -14px rgba(28, 26, 22, 0.55);
}

.ann-btn.is-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 14px 30px -14px rgba(28, 26, 22, 0.6);
}

.ann-btn.is-secondary {
    background: transparent;
    border-color: var(--hairline);
    color: var(--fg-2);
}

.ann-btn.is-secondary:hover {
    background: var(--accent-soft);
    border-color: var(--accent-soft);
    color: var(--fg);
}

.ann-btn:focus-visible {
    outline: 2px solid var(--accent-2);
    outline-offset: 2px;
}

.ann-btn:disabled {
    opacity: 0.6;
    cursor: default;
}

.ann-hint {
    margin: 12px 0 0;
    font-size: 12.5px;
    line-height: 1.6;
    color: var(--fg-3);
    text-align: right;
}

.ann-hint a {
    color: var(--accent-2);
    text-decoration: none;
    border-bottom: 1px solid transparent;
}

.ann-hint a:hover {
    border-bottom-color: currentColor;
}

.ann-dialog.is-closing .ann-panel {
    animation: ann-panel-out 0.18s var(--ease-in-out) forwards;
}

.ann-dialog.is-closing::backdrop {
    animation: ann-backdrop-out 0.18s var(--ease-in-out) forwards;
}

@keyframes ann-panel-in {
    from {
        opacity: 0;
        transform: translateY(14px) scale(0.985);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes ann-panel-out {
    from {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
    to {
        opacity: 0;
        transform: translateY(10px) scale(0.99);
    }
}

@keyframes ann-backdrop-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes ann-backdrop-out {
    from { opacity: 1; }
    to { opacity: 0; }
}

.ann-dialog[open] .ann-panel {
    animation: ann-panel-in var(--dur-md) var(--ease-spring);
    will-change: transform, opacity;
}

/* 同一会话内再次展示：跳过入场动画（关闭动画不受影响，JS 关闭前会移除该类） */
.ann-dialog.is-instant[open] .ann-panel { animation: none; }
.ann-dialog.is-instant::backdrop { animation: none; }

/* 深色模式：面板填充收敛为石墨色，避免大面积亮面 */
@media (prefers-color-scheme: dark) {
    .ann-panel {
        background: linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0)), var(--bg);
    }

    .ann-footer {
        background: #0f0f0e;
    }

    .ann-feedback.is-error {
        color: #f0a08f;
    }
}

/* 移动端：底部抽屉（全宽、上圆角、粘性头部、安全区） */
@media (max-width: 640px) {
    .ann-dialog {
        width: 100%;
        max-width: 100%;
        max-height: 92dvh;
        margin: auto 0 0;
    }

    .ann-panel {
        max-height: 92dvh;
        border-radius: 22px 22px 0 0;
        border-bottom: 0;
    }

    .ann-head {
        position: sticky;
        top: 0;
        z-index: 2;
        background: var(--bg);
        padding: 14px 16px 12px 20px;
    }

    .ann-scroll {
        padding: 16px 20px 8px;
    }

    .ann-title {
        font-size: 20px;
    }

    .ann-content {
        font-size: 15px;
        line-height: 1.78;
    }

    .ann-footer {
        padding: 14px 20px calc(16px + env(safe-area-inset-bottom));
    }

    .ann-actions {
        display: grid;
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .ann-btn {
        width: 100%;
        min-height: 48px;
    }

    .ann-hint {
        text-align: center;
    }

    .ann-icon-btn {
        width: var(--touch);
        height: var(--touch);
    }

    .ann-dialog[open] .ann-panel {
        animation-name: ann-panel-up;
    }

    /* 抽屉关闭沿同一路径下滑，方向与桌面居中弹窗区分 */
    .ann-dialog.is-closing .ann-panel {
        animation-name: ann-panel-down;
    }

    @keyframes ann-panel-up {
        from {
            opacity: 0.6;
            transform: translateY(100%);
        }
        to {
            opacity: 1;
            transform: translateY(0);
        }
    }

    @keyframes ann-panel-down {
        from {
            opacity: 1;
            transform: translateY(0);
        }
        to {
            opacity: 0;
            transform: translateY(100%);
        }
    }
}

/* 尊重系统减少动效偏好：关闭过渡与动画 */
@media (prefers-reduced-motion: reduce) {
    .ann-dialog[open] .ann-panel,
    .ann-dialog.is-closing .ann-panel,
    .ann-dialog::backdrop,
    .ann-dialog.is-closing::backdrop {
        animation: none !important;
    }

    .ann-btn,
    .ann-icon-btn {
        transition: none !important;
    }
}
