/**
 * 文章正文标题美化样式
 *
 * 三种风格通过 body 上的 class 区分，由 inc/func.php 按后台配置添加：
 * 1. mzt-title-style-dot       —— 浮动圆点（附件提供的样式，颜色改为变量）
 * 2. mzt-title-style-bar       —— 渐变色条 + 底部细线
 * 3. mzt-title-style-underline —— 渐变下划线 + 文字渐变
 *
 * 颜色变量由 func.php 通过 wp_add_inline_style 注入：
 * --mzt-title-c1 / --mzt-title-c2 / --mzt-title-c3
 *
 * 作用域：仅文章/页面正文 .article-content .wp-posts-content 内的 h1/h2/h3，
 * 不影响侧栏、小工具、小墨自制的赞助页等其它标题。
 */

/* ==========================================================================
 * 风格一：浮动圆点（来自附件，颜色改为可配置变量）
 * ========================================================================== */
body.mzt-title-style-dot .article-content > .wp-posts-content > h2,
body.mzt-title-style-dot .article-content .wp-posts-content > h1,
body.mzt-title-style-dot .article-content .wp-posts-content > h3 {
    z-index: 1;
}

body.mzt-title-style-dot .article-content > .wp-posts-content > h2:hover::before,
body.mzt-title-style-dot .article-content > .wp-posts-content > h2:hover::after,
body.mzt-title-style-dot .article-content .wp-posts-content > h1:hover::before,
body.mzt-title-style-dot .article-content .wp-posts-content > h1:hover::after,
body.mzt-title-style-dot .article-content .wp-posts-content > h3:hover::before,
body.mzt-title-style-dot .article-content .wp-posts-content > h3:hover::after {
    transform: scale(1.2) !important;
    transform-origin: center !important;
    transition: 0.4s;
}

body.mzt-title-style-dot .article-content .wp-posts-content h2::before,
body.mzt-title-style-dot .article-content .wp-posts-content h1::before,
body.mzt-title-style-dot .article-content .wp-posts-content h3::before {
    box-shadow: none !important;
    opacity: 0.6 !important;
    border-radius: 50% !important;
    top: -5px !important;
    left: -10px !important;
    z-index: 1;
}

/* 圆点渐变配色：H1 主色 / H2 副色 / H3 强调色 */
body.mzt-title-style-dot .article-content .wp-posts-content h1::before,
body.mzt-title-style-dot .article-content .wp-posts-content h1::after {
    background: linear-gradient(var(--mzt-title-c1, #409eff), transparent) !important;
}
body.mzt-title-style-dot .article-content .wp-posts-content h2::before,
body.mzt-title-style-dot .article-content .wp-posts-content h2::after {
    background: linear-gradient(var(--mzt-title-c2, #00ff62), transparent) !important;
}
body.mzt-title-style-dot .article-content .wp-posts-content h3::before,
body.mzt-title-style-dot .article-content .wp-posts-content h3::after {
    background: linear-gradient(var(--mzt-title-c3, #ff9800), transparent) !important;
}

body.mzt-title-style-dot .article-content .wp-posts-content h1::before {
    height: 35px !important;
    width: 35px !important;
}
body.mzt-title-style-dot .article-content .wp-posts-content h2::before {
    height: 30px !important;
    width: 30px !important;
}
body.mzt-title-style-dot .article-content .wp-posts-content h3::before {
    height: 25px !important;
    width: 25px !important;
}

body.mzt-title-style-dot .article-content .wp-posts-content h2::after,
body.mzt-title-style-dot .article-content .wp-posts-content h1::after,
body.mzt-title-style-dot .article-content .wp-posts-content h3::after {
    content: "";
    opacity: 0.6;
    position: absolute;
    transition: 0.4s;
    border-radius: 50%;
}
body.mzt-title-style-dot .article-content .wp-posts-content h2::after {
    top: -15px;
    left: 15px;
    width: 10px;
    height: 10px;
}
body.mzt-title-style-dot .article-content .wp-posts-content h1::after {
    top: -13px;
    left: 25px;
    width: 13px;
    height: 13px;
}
body.mzt-title-style-dot .article-content .wp-posts-content h3::after {
    top: -17px;
    left: 12px;
    width: 8px;
    height: 8px;
}

/* ==========================================================================
 * 风格二：马克笔高亮（底部一条渐变色带，贴在文字下方、不遮挡文字）
 * ========================================================================== */
body.mzt-title-style-bar .article-content .wp-posts-content h1,
body.mzt-title-style-bar .article-content .wp-posts-content h2,
body.mzt-title-style-bar .article-content .wp-posts-content h3 {
    display: inline-block;
    vertical-align: middle;
    position: relative;
    margin-top: 4px !important;
    padding: 0 6px 6px !important;
    /* 高亮只占底部 7px，横向渐变到透明，像马克笔从字下滑过 */
    background-image: linear-gradient(90deg,
        color-mix(in srgb, var(--mzt-title-c1, #409eff) 45%, transparent),
        color-mix(in srgb, var(--mzt-title-c1, #409eff) 10%, transparent));
    background-size: 100% 7px;
    background-position: left bottom;
    background-repeat: no-repeat;
}
body.mzt-title-style-bar .article-content .wp-posts-content h2 {
    background-image: linear-gradient(90deg,
        color-mix(in srgb, var(--mzt-title-c2, #00ff62) 45%, transparent),
        color-mix(in srgb, var(--mzt-title-c2, #00ff62) 10%, transparent));
}
body.mzt-title-style-bar .article-content .wp-posts-content h3 {
    background-image: linear-gradient(90deg,
        color-mix(in srgb, var(--mzt-title-c3, #ff9800) 45%, transparent),
        color-mix(in srgb, var(--mzt-title-c3, #ff9800) 10%, transparent));
}
/* 不支持 color-mix 时用固定透明度兜底 */
@supports not (background: color-mix(in srgb, red 10%, transparent)) {
    body.mzt-title-style-bar .article-content .wp-posts-content h1 {
        background-image: linear-gradient(90deg, rgba(64, 158, 255, .45), rgba(64, 158, 255, .1));
    }
    body.mzt-title-style-bar .article-content .wp-posts-content h2 {
        background-image: linear-gradient(90deg, rgba(0, 255, 98, .45), rgba(0, 255, 98, .1));
    }
    body.mzt-title-style-bar .article-content .wp-posts-content h3 {
        background-image: linear-gradient(90deg, rgba(255, 152, 0, .45), rgba(255, 152, 0, .1));
    }
}

/* ==========================================================================
 * 风格三：渐变胶囊药丸（浅色渐变背景 + 渐变描边 + 左侧小色点）
 * ========================================================================== */
body.mzt-title-style-underline .article-content .wp-posts-content h1,
body.mzt-title-style-underline .article-content .wp-posts-content h2,
body.mzt-title-style-underline .article-content .wp-posts-content h3 {
    position: relative;
    display: inline-block;
    vertical-align: middle;
    margin-top: 4px !important;
    padding: 3px 18px 3px 26px !important;
    border-radius: 999px;
    background: linear-gradient(105deg,
        color-mix(in srgb, var(--mzt-title-c1, #409eff) 12%, transparent),
        color-mix(in srgb, var(--mzt-title-c1, #409eff) 3%, transparent));
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--mzt-title-c1, #409eff) 28%, transparent);
}
/* H2 / H3 各自的配色 */
body.mzt-title-style-underline .article-content .wp-posts-content h2 {
    background: linear-gradient(105deg,
        color-mix(in srgb, var(--mzt-title-c2, #00ff62) 12%, transparent),
        color-mix(in srgb, var(--mzt-title-c2, #00ff62) 3%, transparent));
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--mzt-title-c2, #00ff62) 28%, transparent);
}
body.mzt-title-style-underline .article-content .wp-posts-content h3 {
    background: linear-gradient(105deg,
        color-mix(in srgb, var(--mzt-title-c3, #ff9800) 12%, transparent),
        color-mix(in srgb, var(--mzt-title-c3, #ff9800) 3%, transparent));
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--mzt-title-c3, #ff9800) 28%, transparent);
}
/* 左侧渐变小圆点 */
body.mzt-title-style-underline .article-content .wp-posts-content h1::before,
body.mzt-title-style-underline .article-content .wp-posts-content h2::before,
body.mzt-title-style-underline .article-content .wp-posts-content h3::before {
    content: "";
    position: absolute;
    left: 11px;
    top: 50%;
    transform: translateY(-50%);
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--mzt-title-c1, #409eff);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--mzt-title-c1, #409eff) 18%, transparent);
}
body.mzt-title-style-underline .article-content .wp-posts-content h2::before {
    background: var(--mzt-title-c2, #00ff62);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--mzt-title-c2, #00ff62) 18%, transparent);
}
body.mzt-title-style-underline .article-content .wp-posts-content h3::before {
    background: var(--mzt-title-c3, #ff9800);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--mzt-title-c3, #ff9800) 18%, transparent);
}
/* 不支持 color-mix 时用纯色淡底兜底，避免整块背景失效 */
@supports not (background: color-mix(in srgb, red 10%, transparent)) {
    body.mzt-title-style-underline .article-content .wp-posts-content h1 { background: rgba(64, 158, 255, .08); }
    body.mzt-title-style-underline .article-content .wp-posts-content h2 { background: rgba(0, 255, 98, .08); }
    body.mzt-title-style-underline .article-content .wp-posts-content h3 { background: rgba(255, 152, 0, .08); }
}

/* ==========================================================================
 * 风格四：图标标题（左侧背景图，来自附件样式）
 * H1/H2 用 h2.png 双竖条，H3/H4 用 h3.png 双箭头
 * 隐藏主题原有的 ::before/::after 装饰，避免与背景图重叠
 * ========================================================================== */
body.mzt-title-style-image .article-content .wp-posts-content h1,
body.mzt-title-style-image .article-content .wp-posts-content h2,
body.mzt-title-style-image .article-content .wp-posts-content h3,
body.mzt-title-style-image .article-content .wp-posts-content h4 {
    padding: 0 0 0 45px !important;
    background-image: url('../img/title/h2.png');
    background-repeat: no-repeat;
    background-position: 10px center;
    background-size: 30px 20px;
    color: #566889;
    margin-top: 4px !important;
}
body.mzt-title-style-image .article-content .wp-posts-content h3,
body.mzt-title-style-image .article-content .wp-posts-content h4 {
    background-image: url('../img/title/h3.png');
}
body.mzt-title-style-image .article-content .wp-posts-content h1::before,
body.mzt-title-style-image .article-content .wp-posts-content h2::before,
body.mzt-title-style-image .article-content .wp-posts-content h3::before,
body.mzt-title-style-image .article-content .wp-posts-content h4::before,
body.mzt-title-style-image .article-content .wp-posts-content h1::after,
body.mzt-title-style-image .article-content .wp-posts-content h2::after,
body.mzt-title-style-image .article-content .wp-posts-content h3::after,
body.mzt-title-style-image .article-content .wp-posts-content h4::after {
    display: none !important;
}

/* ==========================================================================
 * 响应式：窄屏下浮动圆点略微收敛，避免挤压文字
 * ========================================================================== */
@media (max-width: 640px) {
    body.mzt-title-style-dot .article-content .wp-posts-content h1::before { width: 26px !important; height: 26px !important; }
    body.mzt-title-style-dot .article-content .wp-posts-content h2::before { width: 23px !important; height: 23px !important; }
    body.mzt-title-style-dot .article-content .wp-posts-content h3::before { width: 20px !important; height: 20px !important; }
}
