/**
 * 老苏 · Markdown 编辑器 —— 前台内容样式
 *
 * 配套编辑器插入的几段 HTML：
 *   1. 下载按钮 <a class="ls-dl-btn" href="…" download>…</a>
 *      —— 语义仍是链接（button 无法跳转），靠本文件渲染成实心按钮；
 *         只作用于带 .ls-dl-btn 的那一个链接，不改正文里的普通链接。
 *   2. 提示块 <div class="ls-md-callout ls-md-callout--info|warn">
 *   3. 注音 <ruby>文字<rt>…</rt></ruby>（浏览器原生，仅做轻样式）
 *
 * 样式自包含，不引用主题变量：换主题也能用。
 * 加载位置在主题 CSS 之前，因此对 .entry-content 相关规则用了更高的选择器权重。
 * 配色跟随站点唯一的「商务藏青」。
 */

a.ls-dl-btn,
.entry-content a.ls-dl-btn {
    display: inline-flex;
    align-items: center;
    gap: .5em;
    max-width: 100%;
    margin: .25em 0;
    padding: .6em 1.2em;
    border: 1px solid rgba(31, 78, 140, .22);
    border-radius: 10px;
    background: #1F4E8C;
    color: #fff;
    font-size: .94em;
    font-weight: 600;
    line-height: 1.5;
    text-decoration: none;
    vertical-align: middle;
    box-shadow: 0 2px 8px rgba(31, 78, 140, .22);
    transition: transform .15s ease, box-shadow .15s ease, background-color .15s ease;
}

a.ls-dl-btn::before,
.entry-content a.ls-dl-btn::before {
    content: "↓";
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    width: 1.35em;
    height: 1.35em;
    border-radius: 50%;
    background: rgba(255, 255, 255, .2);
    font-size: .95em;
    font-weight: 700;
    line-height: 1;
    /* 防止上层段落的首行缩进（如主题「正文首行缩进 2em」）串进来，把箭头推离圆心 */
    text-indent: 0;
}

a.ls-dl-btn:hover,
.entry-content a.ls-dl-btn:hover,
a.ls-dl-btn:focus-visible,
.entry-content a.ls-dl-btn:focus-visible {
    background: #163C70;
    border-color: rgba(31, 78, 140, .35);
    color: #fff;
    text-decoration: none;
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(31, 78, 140, .3);
}

a.ls-dl-btn:active,
.entry-content a.ls-dl-btn:active {
    transform: translateY(0);
}

a.ls-dl-btn:focus-visible,
.entry-content a.ls-dl-btn:focus-visible {
    outline: 2px solid #8A6428;
    outline-offset: 2px;
}

/* ---------- 提示块 ---------- */

div.ls-md-callout,
.entry-content div.ls-md-callout {
    margin: 1.2em 0;
    padding: .85em 1.05em;
    border-left: 3px solid #1F4E8C;
    border-radius: 0 8px 8px 0;
    background: #F2F6FC;
    color: inherit;
    line-height: 1.75;
}

div.ls-md-callout strong,
.entry-content div.ls-md-callout strong { color: #1F4E8C; }

div.ls-md-callout--warn,
.entry-content div.ls-md-callout--warn {
    border-left-color: #8A6428;
    background: #FBF6EC;
}

div.ls-md-callout--warn strong,
.entry-content div.ls-md-callout--warn strong { color: #8A6428; }

ruby rt { font-size: .68em; opacity: .72; }

/* 主题用 html[data-theme] 标记深浅色（老苏主题即如此） */
html[data-theme="dark"] a.ls-dl-btn,
html[data-theme="dark"] .entry-content a.ls-dl-btn {
    background: #285A9E;
    border-color: rgba(255, 255, 255, .12);
    box-shadow: 0 2px 10px rgba(0, 0, 0, .35);
}

html[data-theme="dark"] a.ls-dl-btn:hover,
html[data-theme="dark"] .entry-content a.ls-dl-btn:hover,
html[data-theme="dark"] a.ls-dl-btn:focus-visible,
html[data-theme="dark"] .entry-content a.ls-dl-btn:focus-visible {
    background: #376BB0;
    border-color: rgba(255, 255, 255, .2);
    box-shadow: 0 6px 16px rgba(0, 0, 0, .4);
}

html[data-theme="dark"] div.ls-md-callout,
html[data-theme="dark"] .entry-content div.ls-md-callout {
    background: #182334;
    border-left-color: #7491B8;
}

html[data-theme="dark"] div.ls-md-callout strong,
html[data-theme="dark"] .entry-content div.ls-md-callout strong { color: #9DB8DC; }

html[data-theme="dark"] div.ls-md-callout--warn,
html[data-theme="dark"] .entry-content div.ls-md-callout--warn {
    background: #2A2419;
    border-left-color: #AB8F64;
}

html[data-theme="dark"] div.ls-md-callout--warn strong,
html[data-theme="dark"] .entry-content div.ls-md-callout--warn strong { color: #D3B88C; }

/* 不用 data-theme 的主题，退回系统偏好 */
@media (prefers-color-scheme: dark) {
    html:not([data-theme="light"]) a.ls-dl-btn,
    html:not([data-theme="light"]) .entry-content a.ls-dl-btn {
        background: #285A9E;
        border-color: rgba(255, 255, 255, .12);
        box-shadow: 0 2px 10px rgba(0, 0, 0, .35);
    }

    html:not([data-theme="light"]) a.ls-dl-btn:hover,
    html:not([data-theme="light"]) .entry-content a.ls-dl-btn:hover {
        background: #376BB0;
    }

    html:not([data-theme="light"]) div.ls-md-callout,
    html:not([data-theme="light"]) .entry-content div.ls-md-callout {
        background: #182334;
        border-left-color: #7491B8;
    }
}

@media (prefers-reduced-motion: reduce) {
    a.ls-dl-btn,
    .entry-content a.ls-dl-btn {
        transition: none;
    }

    a.ls-dl-btn:hover,
    .entry-content a.ls-dl-btn:hover {
        transform: none;
    }
}
