/**
 * AeroCore 数学公式 —— 前台样式
 */

/* 未渲染（MathJax 未加载 / 加载失败）时的降级显示，避免直接露出 latex 源码显得突兀 */
.aero-math:not(.aero-math--rendered) {
    display: inline-block;
    padding: 0 4px;
    border-radius: 4px;
    background: rgba(100, 116, 139, 0.12);
    color: inherit;
    font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
    font-size: 0.95em;
    white-space: nowrap;
}

.aero-math--rendered {
    display: inline-block;
    background: none;
    padding: 0;
}

/* 独立公式 */
.aero-math-block.aero-math--rendered {
    display: block;
    margin: 1.2em 0;
    text-align: center;
}

.aero-math-block:not(.aero-math--rendered) {
    display: block;
    margin: 1.2em 0;
    padding: 8px 10px;
    white-space: normal;
    word-break: break-all;
}

/* 公式过长时可横向滚动，不撑破容器 */
.aero-math--rendered mjx-container[jax="CHTML"] {
    max-width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 2px 0;
}

.aero-math-block.aero-math--rendered mjx-container[jax="CHTML"][display="true"] {
    margin: 0 !important;
}

/* 右键复制菜单（中文，替代 MathJax 内置菜单） */
.aero-math-menu {
    position: fixed;
    z-index: 99999;
    min-width: 140px;
    padding: 4px;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.15);
    font-size: 13px;
    color: #1e293b;
}

.aero-math-menu-item {
    display: block;
    width: 100%;
    padding: 8px 12px;
    border: 0;
    border-radius: 6px;
    background: none;
    color: inherit;
    font-size: 13px;
    text-align: left;
    cursor: pointer;
}

.aero-math-menu-item:hover {
    background: #f1f5f9;
}

.aero-math-menu-tip {
    padding: 8px 14px;
    color: #16a34a;
}

/* AeroCore 深色模式 */
html[data-theme="dark"] .aero-math:not(.aero-math--rendered) {
    background: rgba(148, 163, 184, 0.16);
}

html[data-theme="dark"] .aero-math-menu {
    background: #2a2a2a;
    border-color: #3a3a3a;
    color: #e8e8e8;
}

html[data-theme="dark"] .aero-math-menu-item:hover {
    background: #3a3a3a;
}

html[data-theme="dark"] .aero-math-menu-tip {
    color: #4ade80;
}

@media (prefers-color-scheme: dark) {
    html:not([data-theme="light"]) .aero-math:not(.aero-math--rendered) {
        background: rgba(148, 163, 184, 0.16);
    }
}
