/* 养心殿 custom.css — 阅读体验覆盖层
   设计意图:内容为主。不重绘主题框架,只打磨正文排版、代码块、
   引用、目录与归档;颜色沿用主题强调色 #fa5555,灰阶取自 #606266 系 */

/* ---------- 基础排版:中文字体栈与阅读节奏 ---------- */
body,
button,
input,
select,
textarea {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
        'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'Noto Sans SC',
        sans-serif;
}

.entry .entry-content {
    font-size: 16.5px;
    line-height: 1.9;
    color: #3f4548;
    word-break: break-word;
}

/* 标题层级:h2 用强调线锚定节奏,h3/h4 轻量递进 */
.entry .entry-content h2 {
    margin: 2.2em 0 0.9em;
    padding-left: 0.6em;
    border-left: 4px solid #fa5555;
    font-size: 1.45em;
    font-weight: 600;
    line-height: 1.4;
}

.entry .entry-content h3 {
    margin: 1.8em 0 0.7em;
    font-size: 1.2em;
    font-weight: 600;
}

.entry .entry-content h4 {
    margin: 1.5em 0 0.6em;
    font-size: 1.05em;
    font-weight: 600;
}

/* 正文链接:主题色 + 悬停加深下划线 */
.entry .entry-content a {
    color: #fa5555;
    text-decoration: none;
    border-bottom: 1px solid rgba(250, 85, 85, 0.35);
    transition: border-color 0.2s;
}

.entry .entry-content a:hover {
    border-bottom-color: #fa5555;
}

.entry .entry-content ul,
.entry .entry-content ol {
    padding-left: 1.6em;
    margin: 1em 0;
}

.entry .entry-content li {
    margin: 0.35em 0;
}

.entry .entry-content img {
    border-radius: 6px;
    max-width: 100%;
    height: auto;
}

.entry .entry-content hr {
    border: 0;
    border-top: 1px solid #e8eaed;
    margin: 2.4em 0;
}

.entry .entry-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.4em 0;
    font-size: 0.95em;
}

.entry .entry-content th,
.entry .entry-content td {
    border: 1px solid #e8eaed;
    padding: 8px 12px;
}

.entry .entry-content th {
    background: #f7f8fa;
}

/* ---------- 代码:行内轻量药丸,块级深色圆角 ---------- */
.entry .entry-content :not(pre) > code {
    padding: 2px 6px;
    margin: 0 2px;
    border-radius: 3px;
    background: rgba(250, 85, 85, 0.08);
    color: #cf4536;
    font-size: 0.88em;
}

.entry .entry-content pre {
    margin: 1.6em 0;
    padding: 1em 1.2em;
    border-radius: 6px;
    background: #282c34;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.entry .entry-content pre code {
    padding: 0;
    background: transparent;
    color: #abb2bf;
    font-size: 0.9em;
    line-height: 1.7;
    font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo,
        'Courier New', monospace;
}

.entry .entry-content pre::-webkit-scrollbar {
    height: 8px;
}

.entry .entry-content pre::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
}

/* ---------- 引用:强调线 + 柔和底色 ---------- */
.entry .entry-content blockquote {
    margin: 1.6em 0;
    padding: 0.8em 1.2em;
    border-left: 4px solid #fa5555;
    border-radius: 0 6px 6px 0;
    background: rgba(250, 85, 85, 0.05);
    color: #6a7076;
}

.entry .entry-content blockquote p {
    margin: 0.3em 0;
}

/* ---------- 阅读数:<i> 默认斜体,归正 ---------- */
.leancloud-visitors-count {
    font-style: normal;
}

/* ---------- 目录 widget:层级缩进 + 悬停高亮,长文随屏 ---------- */
.widget_toc .toc-list {
    list-style: none;
    margin: 0;
    padding: 4px 0 8px;
    font-size: 13.5px;
}

.widget_toc .toc-item {
    border-left: 2px solid #eef0f2;
    transition: border-color 0.2s;
}

.widget_toc .toc-item a {
    display: block;
    padding: 5px 4px 5px 12px;
    color: #606266;
    text-decoration: none;
    line-height: 1.5;
}

.widget_toc .toc-item.toc-level-3 {
    padding-left: 14px;
}

.widget_toc .toc-item.toc-level-4 {
    padding-left: 28px;
}

.widget_toc .toc-item:hover {
    border-left-color: #fa5555;
}

.widget_toc .toc-item:hover a {
    color: #fa5555;
}

/* 侧栏随屏:整栏 sticky(而不是单个 widget)。
   单 widget sticky 时会悬浮盖住下方 widget(近期文章等),整栏一起动则互不遮挡;
   主题自带的 fixed_sidebar JS 把 scroll 事件绑在不滚动的父节点上,实际不生效,故用 CSS 实现。
   侧栏过高时自身出滚动条,保证目录/下方 widget 都能到达 */
@media (min-width: 992px) {
    .sidebar {
        position: -webkit-sticky;
        position: sticky;
        top: 76px;
        max-height: calc(100vh - 96px);
        overflow-y: auto;
    }
}

/* 目录锚点定位时留出固定头部高度(原生 hash 跳转/首次加载兜底) */
.entry .entry-content h2,
.entry .entry-content h3,
.entry .entry-content h4 {
    scroll-margin-top: 76px;
}

/* ---------- 归档页:年份分区 + 日期列对齐的行式列表 ---------- */
.archive-year-title {
    display: flex;
    align-items: baseline;
    gap: 10px;
    margin: 0;
    padding: 18px 24px 10px;
    font-size: 22px;
    font-weight: 700;
    color: #3f4548;
}

.archive-count {
    font-size: 12px;
    font-weight: 400;
    color: #909399;
    background: #f0f2f5;
    border-radius: 10px;
    padding: 2px 10px;
}

.archive-list {
    list-style: none;
    margin: 0;
    padding: 0 12px 18px;
}

.archive-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 10px 12px;
    border-radius: 6px;
}

.archive-item:hover {
    background: #f7f8fa;
}

.archive-date {
    flex: 0 0 auto;
    font-family: 'SFMono-Regular', Consolas, Menlo, monospace;
    font-size: 13px;
    color: #909399;
}

.archive-title {
    color: #3f4548;
    text-decoration: none;
    font-size: 15px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.archive-item:hover .archive-title {
    color: #fa5555;
}

/* ---------- 搜索覆盖层:输入框边界与焦点反馈 ---------- */
.navbar-search-inner .navbar-search-input {
    height: 26px;
    line-height: 24px;
    margin-top: 0;
    padding: 0 10px;
    border: 1px solid #dcdfe6;
    border-radius: 4px;
    box-sizing: border-box;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.navbar-search-inner .navbar-search-input:focus {
    border-color: #fa5555;
    outline: none;
    box-shadow: 0 0 0 3px rgba(250, 85, 85, 0.12);
}

/* 移动端抽屉内还原主题原生搜索框样式(桌面覆盖层规则不进移动端);
   并补上主题遗漏的 top:auto —— 基础规则的 top:20px 残留会把搜索框
   往下顶 20px,导致抽屉里的菜单项叠住输入框下半截 */
@media (max-width: 991px) {
    .navbar-search {
        top: auto;
    }

    .navbar-search-inner .navbar-search-input {
        height: 36px;
        line-height: 20px;
        padding: 5px 10px;
        border: 1px solid #fff;
        border-radius: 0;
        box-shadow: none;
    }
}

/* ---------- 细节:选区颜色 ---------- */
::selection {
    background: rgba(250, 85, 85, 0.2);
}

/* ---------- 移动端 ---------- */
@media (max-width: 767px) {
    .entry .entry-content {
        font-size: 16px;
    }

    .entry .entry-content h2 {
        font-size: 1.3em;
    }

    .archive-title {
        white-space: normal;
    }
}
