/* ==========================================================================
   醉沁城 · 视觉优化层（beautify.css）
   --------------------------------------------------------------------------
   本文件在 style.min.css 之后加载，只做「覆盖」，不修改主题原始样式，
   想回退只需在 header.php 里删掉一行 <link>。

   优化目标：
   1. 顶部导航在浅色头图上不可读  → 加渐变遮罩 + 文字阴影，滚动后切换为白底
   2. 头图过高，文章页 70vh 把正文压到很下面 → 降为 46vh
   3. 卡片缩略图 320px 固定高、比例失控 → 改为 16:9 自适应 + 底部渐隐
   4. 正文行距偏紧、中文排版粗糙 → 重设字号/行高/段落间距
   5. 代码块、表格、引用、图片缺乏样式 → 统一补充
   ========================================================================== */

:root {
    --ly-ink: #1f2329;
    --ly-ink-2: #4a5058;
    --ly-ink-3: #8b929c;
    --ly-line: #e8eaee;
    --ly-bg: #f4f5f7;
    --ly-card: #ffffff;
    --ly-accent: #4f6ef7;
    --ly-accent-soft: rgba(79, 110, 247, .08);
    --ly-radius: 14px;
    --ly-shadow-sm: 0 1px 2px rgba(16, 24, 40, .04), 0 4px 12px rgba(16, 24, 40, .05);
    --ly-shadow-md: 0 2px 6px rgba(16, 24, 40, .06), 0 12px 32px rgba(16, 24, 40, .10);
    --ly-font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
               "Hiragino Sans GB", "Microsoft YaHei", "Source Han Sans SC",
               "Noto Sans CJK SC", sans-serif;
    --ly-mono: "JetBrains Mono", "Fira Code", Consolas, Menlo, Monaco,
               "Courier New", monospace;
}

/* --------------------------------------------------------------------------
   1. 顶部导航：浅色头图上的可读性
   -------------------------------------------------------------------------- */

/* 顶部状态：一层半透明深色毛玻璃。
   原样式是 rgba(255,255,255,.2) 的浅色，压在浅色头图（雪景、白底插画）上
   白字几乎不可见；改成深色后任何背景图下都有稳定对比度。 */
#nav-menu.headroom--top {
    background: rgba(14, 18, 26, .38) !important;
    -webkit-backdrop-filter: saturate(150%) blur(12px);
    backdrop-filter: saturate(150%) blur(12px);
    box-shadow: none !important;
}

#nav-menu.headroom--top,
#nav-menu.headroom--top a,
#nav-menu.headroom--top i {
    color: #fff !important;
    text-shadow: 0 1px 8px rgba(0, 0, 0, .5);
}

/* 滚动后：白底毛玻璃，深色文字 */
#nav-menu.headroom--not-top {
    background: rgba(255, 255, 255, .88) !important;
    -webkit-backdrop-filter: saturate(180%) blur(14px);
    backdrop-filter: saturate(180%) blur(14px);
    box-shadow: 0 1px 0 rgba(16, 24, 40, .06), 0 6px 24px rgba(16, 24, 40, .06);
}

#nav-menu.headroom--not-top,
#nav-menu.headroom--not-top a,
#nav-menu.headroom--not-top i {
    color: var(--ly-ink) !important;
    text-shadow: none;
}

#nav-menu a {
    font-family: var(--ly-font);
    font-size: 15px !important;
    font-weight: 500;
    letter-spacing: .2px;
    transition: opacity .2s ease;
}

#nav-menu a:hover { opacity: .62; }

#nav-right i { font-size: 17px !important; }

/* 站点名与头像 */
#nav-left a {
    font-size: 17px !important;
    font-weight: 600;
    letter-spacing: .5px;
}

#site-avatar {
    border-radius: 50%;
    box-shadow: 0 2px 10px rgba(0, 0, 0, .18);
    transition: transform .6s cubic-bezier(.4, 0, .2, 1);
}

/* --------------------------------------------------------------------------
   2. 头图与站点标题
   -------------------------------------------------------------------------- */

#background::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg,
        rgba(10, 14, 22, .18) 0%,
        rgba(10, 14, 22, 0) 32%,
        rgba(10, 14, 22, .10) 100%);
    pointer-events: none;
}

/* 注意：#site-meta 原样式是 absolute + translate(-50%,-50%) 居中覆盖在头图上，
   这里只补文字效果，不要改 position，否则会被挤到文档流里、把头图顶下去。 */
#site-meta {
    text-align: center;
}

/* 标题背后加一层柔和的暗色晕影，避免白字落在雪景/白底插画上糊成一片 */
#site-meta::before {
    content: "";
    position: absolute;
    inset: -10% -6%;
    background: radial-gradient(ellipse at center,
        rgba(8, 12, 20, .42) 0%,
        rgba(8, 12, 20, .20) 45%,
        rgba(8, 12, 20, 0) 74%);
    border-radius: 50%;
    z-index: -1;
    pointer-events: none;
}

#site-name {
    color: #fff !important;
    font-family: var(--ly-font);
    font-weight: 600 !important;
    font-size: clamp(2.4rem, 5.2vw, 4.2rem) !important;
    letter-spacing: .06em;
    text-shadow: 0 2px 24px rgba(0, 0, 0, .45), 0 1px 3px rgba(0, 0, 0, .3) !important;
    margin-bottom: 14px !important;
}

#site-description {
    color: rgba(255, 255, 255, .92) !important;
    font-family: var(--ly-font);
    font-size: clamp(.9rem, 1.5vw, 1.15rem) !important;
    font-weight: 400;
    letter-spacing: .12em;
    text-shadow: 0 1px 14px rgba(0, 0, 0, .5) !important;
}

/* 说明：文章 / 页面页的头图高度在 header.php 的内联样式里控制，
   这里不做覆盖，避免误伤首页 100vh 的整屏头图。 */

/* --------------------------------------------------------------------------
   3. 文章列表卡片
   -------------------------------------------------------------------------- */

#body { background: var(--ly-bg); }

#main article,
.card {
    background: var(--ly-card);
    border-radius: var(--ly-radius) !important;
    border: 1px solid rgba(16, 24, 40, .05);
    box-shadow: var(--ly-shadow-sm);
    padding: 22px 24px !important;
    margin: 28px auto !important;
    transition: transform .32s cubic-bezier(.4, 0, .2, 1),
                box-shadow .32s cubic-bezier(.4, 0, .2, 1) !important;
}

#main article:hover,
.card:hover {
    transform: translateY(-4px);
    box-shadow: var(--ly-shadow-md);
}

.card-title {
    font-family: var(--ly-font);
    font-size: 21px !important;
    font-weight: 650;
    line-height: 1.45 !important;
    letter-spacing: -.01em;
}

.card-title a { color: var(--ly-ink); }
.card-title a:hover { color: var(--ly-accent); }

.card-meta-top {
    margin: 10px 0 14px !important;
    font-family: var(--ly-font);
    font-size: 13px;
    color: var(--ly-ink-3);
}

.card-meta-cate a { color: var(--ly-accent); }

.card-meta-cate,
.card-meta-date {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-right: 12px;
}

/* 缩略图：原样式固定 320px 高、比例失控，在宽屏下会占掉大半屏。
   桌面端改为「左文右图」网格：缩略图收窄成 220px 一列，正文占据主要宽度；
   移动端退回单列，缩略图变成 16:9 横幅。 */
.card-thumbnail {
    height: 0 !important;
    padding-bottom: 56.25%;
    position: relative;
    border-radius: 10px !important;
    overflow: hidden;
    background-size: cover !important;
    background-position: center !important;
    transform: translateZ(0);
}

.card-thumbnail::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, rgba(0, 0, 0, 0) 62%, rgba(0, 0, 0, .14) 100%);
    pointer-events: none;
}

@media (min-width: 900px) {
    #main article.card {
        display: grid;
        grid-template-columns: minmax(0, 1fr) 186px;
        grid-template-areas:
            "title  thumb"
            "meta   thumb"
            "body   thumb"
            "line   line"
            "bottom bottom";
        column-gap: 26px;
        align-items: start;
    }

    #main article.card > .card-title   { grid-area: title; }
    #main article.card > .card-meta-top { grid-area: meta; }
    #main article.card > a              { grid-area: thumb; }
    #main article.card > .card-body     { grid-area: body; }
    #main article.card > .card-line     { grid-area: line; }
    #main article.card > .card-meta-bottom { grid-area: bottom; }

    /* 缩略图容器铺满右侧一列，4:3 比例 */
    #main article.card > a {
        display: block;
        margin-top: 4px;
    }

    #main article.card .card-thumbnail {
        padding-bottom: 75%;
        margin: 0 !important;
        /* 默认缩略图是同一套装饰插画，堆叠时略显重复，
           统一降一点饱和度并压暗边缘，让它更像背景装饰而不是内容 */
        filter: saturate(.82) contrast(.96);
        box-shadow: inset 0 0 0 1px rgba(16, 24, 40, .05);
    }

    /* 没有缩略图的卡片（无图文章）自动变成单列，不留空洞 */
    #main article.card:not(:has(.card-thumbnail)) {
        grid-template-columns: 1fr;
        grid-template-areas:
            "title"
            "meta"
            "body"
            "line"
            "bottom";
    }
}

.card-body {
    font-family: var(--ly-font);
    font-size: 14.5px !important;
    line-height: 1.85 !important;
    color: var(--ly-ink-2) !important;
    margin-bottom: 14px !important;
}

.card-line {
    border-bottom: 1px solid var(--ly-line) !important;
    margin: 14px 0 !important;
}

.card-meta-bottom { font-family: var(--ly-font); }
.card-meta-label { color: var(--ly-ink-3) !important; font-size: 13px; }

/* --------------------------------------------------------------------------
   4. 正文排版
   -------------------------------------------------------------------------- */

#main article { color: var(--ly-ink-2); }

.post-title {
    font-family: var(--ly-font);
    font-size: clamp(1.4rem, 2.4vw, 1.85rem) !important;
    font-weight: 680;
    line-height: 1.4;
    letter-spacing: -.015em;
    color: var(--ly-ink);
    margin: 22px auto 14px !important;
}

.post-meta {
    font-family: var(--ly-font);
    font-size: 13px;
    color: var(--ly-ink-3);
}

.post-meta-label {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    margin: 0 4px 0 0 !important;
    background: var(--ly-accent-soft);
    color: #5566a8;
    border-radius: 20px;
}

.post-meta-label:before { content: none !important; }

.post-content {
    font-family: var(--ly-font);
    font-size: 16px;
    line-height: 1.9;
    color: #33383f;
    word-wrap: break-word;
    overflow-wrap: break-word;
    max-width: 100%;
    min-width: 0;
}

.post-content p { margin: 0 0 1.15em; }

.post-content h1,
.post-content h2,
.post-content h3,
.post-content h4 {
    font-family: var(--ly-font);
    color: var(--ly-ink);
    font-weight: 650;
    line-height: 1.45;
    letter-spacing: -.01em;
    margin: 1.9em 0 .75em;
    scroll-margin-top: 84px;
}

.post-content h2 {
    font-size: 1.35em;
    padding-left: 12px;
    border-left: 4px solid var(--ly-accent);
}

.post-content h3 { font-size: 1.15em; }
.post-content h4 { font-size: 1.02em; }

.post-content a {
    color: var(--ly-accent);
    text-decoration: none;
    border-bottom: 1px solid rgba(79, 110, 247, .32);
    transition: border-color .2s ease, background .2s ease;
}

.post-content a:hover {
    border-bottom-color: var(--ly-accent);
    background: var(--ly-accent-soft);
}

.post-content ul,
.post-content ol { padding-left: 1.5em; margin: 0 0 1.15em; }
.post-content li { margin: .4em 0; }

.post-content img {
    max-width: 100%;
    height: auto;
    border-radius: 10px;
    box-shadow: var(--ly-shadow-sm);
    margin: 1.2em auto;
    display: block;
}

.post-content hr {
    border: none;
    border-top: 1px solid var(--ly-line);
    margin: 2em 0;
}

.post-content blockquote {
    margin: 1.4em 0 !important;
    padding: 14px 18px !important;
    background: #f7f8fa !important;
    border-left: 4px solid var(--ly-accent) !important;
    border-radius: 0 10px 10px 0;
    color: var(--ly-ink-2) !important;
    font-size: .97em;
}

.post-content blockquote p:last-child { margin-bottom: 0; }

/* 行内代码 */
.post-content :not(pre) > code {
    font-family: var(--ly-mono);
    font-size: .88em;
    padding: 2px 6px;
    border-radius: 5px;
    background: #f1f3f6;
    color: #c0392b;
    border: 1px solid #e6e9ee;
    word-break: break-word;
}

/* 代码块
   注意：主题把 <pre> 统一改写成 <pre class="highlight-wrap">，
   它自带顶部留白放「窗口圆点 + 语言标签」，所以不能一刀切 padding。

   ⚠️ 这里的选择器只能写 .post-content pre，不要再带上 .hljs / pre.hljs：
   highlight.js 会把 .hljs 类同时加到 <code> 上，一旦选中它，
   code 就会继承 margin / border-radius / box-shadow / overflow-x，
   在代码块里又套出一层「块中块」，并且多出一条内层滚动条。 */
.post-content pre {
    position: relative;
    font-family: var(--ly-mono) !important;
    font-size: 13.5px !important;
    line-height: 1.75 !important;
    border-radius: 10px !important;
    margin: 1.5em 0 !important;
    overflow-x: auto;
    overflow-y: hidden;
    max-width: 100%;
    box-shadow: var(--ly-shadow-sm);
    -webkit-font-smoothing: antialiased;
}

/* code 只当容器用，所有装饰都交给外层 pre */
.post-content pre > code {
    display: block;
    position: relative;
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
    border-radius: 0 !important;
    overflow: visible !important;
    font: inherit !important;
    white-space: normal;
}

.post-content pre:not(.highlight-wrap) {
    padding: 18px 20px !important;
    background: #282c34 !important;
    color: #abb2bf !important;
    border: 1px solid rgba(255, 255, 255, .06);
}

/* 带窗口装饰的代码块 */
.highlight-wrap {
    background: #282c34 !important;
    color: #abb2bf !important;
    /* 左右内边距交给行号列 / 代码列自己控制，否则会叠加成双倍缩进 */
    padding: 46px 0 14px !important;
    border: 1px solid rgba(255, 255, 255, .06);
    box-shadow: 0 8px 24px rgba(16, 24, 40, .14) !important;
}

.highlight-wrap::before {
    margin-top: -28px !important;
    left: 16px !important;
    width: 11px !important;
    height: 11px !important;
    box-shadow: 19px 0 #fdbc40, 38px 0 #35cd4b !important;
}

.highlight-wrap code[data-lang]::before {
    content: attr(data-lang);
    position: absolute;
    /* 抬到 pre 顶部那 46px 留白里，居中显示；top:0 会压在代码第一行上 */
    top: -46px;
    left: 0;
    width: 100%;
    height: 46px !important;
    line-height: 46px !important;
    text-align: center;
    transform: none !important;
    font-family: var(--ly-mono);
    font-size: 11px !important;
    font-weight: 500 !important;
    letter-spacing: .16em;
    text-transform: uppercase;
    color: rgba(171, 178, 191, .45) !important;
    background: transparent !important;
    pointer-events: none;
}

.highlight-wrap .copy-code {
    top: 12px !important;
    right: 14px !important;
    color: rgba(171, 178, 191, .6) !important;
}

.highlight-wrap .copy-code:hover { color: #fff !important; }

.post-content pre code {
    background: transparent !important;
    border: none !important;
    padding: 0 !important;
    font-size: inherit !important;
    color: inherit !important;
    font-family: var(--ly-mono) !important;
}

.post-content pre::-webkit-scrollbar { height: 8px; }
.post-content pre::-webkit-scrollbar-track { background: transparent; }
.post-content pre::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, .16);
    border-radius: 4px;
}

/* --------------------------------------------------------------------------
   代码语法高亮配色（One Dark 风格）
   原主题只引了 highlight.js，没有引任何 hljs 配色，代码块是单色灰，看不出结构。
   -------------------------------------------------------------------------- */

.hljs,
.hljs-subst { color: #abb2bf; }

.hljs-comment,
.hljs-quote { color: #5c6370; font-style: italic; }

.hljs-doctag,
.hljs-keyword,
.hljs-formula { color: #c678dd; }

.hljs-section,
.hljs-name,
.hljs-selector-tag,
.hljs-deletion,
.hljs-subst { color: #e06c75; }

.hljs-literal { color: #56b6c2; }

.hljs-string,
.hljs-regexp,
.hljs-addition,
.hljs-attribute,
.hljs-meta .hljs-string { color: #98c379; }

.hljs-attr,
.hljs-variable,
.hljs-template-variable,
.hljs-type,
.hljs-selector-class,
.hljs-selector-attr,
.hljs-selector-pseudo,
.hljs-number { color: #d19a66; }

.hljs-symbol,
.hljs-bullet,
.hljs-link,
.hljs-meta,
.hljs-selector-id,
.hljs-title { color: #61afef; }

.hljs-built_in,
.hljs-title.class_,
.hljs-class .hljs-title { color: #e5c07b; }

.hljs-emphasis { font-style: italic; }
.hljs-strong { font-weight: 700; }
.hljs-link { text-decoration: underline; }

/* 行内代码在深色背景里也保持可读 */
.post-content pre .hljs-comment { color: #5c6370 !important; }

/* 表格 */
.post-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.4em 0;
    font-size: .93em;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 0 0 1px var(--ly-line);
}

.post-content thead th {
    background: #f7f8fa;
    color: var(--ly-ink);
    font-weight: 600;
}

.post-content th,
.post-content td {
    padding: 10px 14px;
    border-bottom: 1px solid var(--ly-line);
    text-align: left;
}

.post-content tbody tr:last-child td { border-bottom: none; }
.post-content tbody tr:hover { background: #fafbfc; }

/* 行号是插件用 table 实现的，必须把上面的表格样式在代码块内反向重置，
   否则每行代码之间都会多出一条横线 */
.post-content pre table,
.post-content pre tbody,
.post-content pre tr,
.post-content pre td,
.post-content pre th {
    border: none !important;
    background: transparent !important;
    box-shadow: none !important;
    padding: 0 !important;
    margin: 0 !important;
    border-radius: 0 !important;
}

.post-content pre tbody tr:hover { background: transparent !important; }

/* 表格被 .post-content table 设了 width:100% + overflow:hidden，
   长代码行会被直接裁掉而不是横向滚动，这里要放开 */
.post-content pre table.hljs-ln {
    width: auto !important;
    min-width: 100% !important;
    overflow: visible !important;
    table-layout: auto !important;
    border-collapse: collapse !important;
}

/* 行号列
   主题原本给 td.hljs-ln-numbers 设了 position:absolute;left:0，靠 td.hljs-ln-code
   的 padding-left:30px 让开。这里改回正常表格单元格，布局才可控 */
.post-content pre .hljs-ln-numbers,
.post-content pre td.hljs-ln-numbers {
    position: static !important;
    left: auto !important;
    top: auto !important;
    display: table-cell !important;
    /* 宽度交给内容撑开，三位数行号也不会被挤掉 */
    width: auto !important;
    min-width: 46px !important;
    vertical-align: top;
    text-align: right;
    padding: 0 14px 0 20px !important;
    color: rgba(171, 178, 191, .32) !important;
    user-select: none;
    -webkit-user-select: none;
}

/* 代码列：必须留出左侧内边距，否则首行文字会钻到行号底下被盖住 */
.post-content pre .hljs-ln-code,
.post-content pre td.hljs-ln-code {
    display: table-cell !important;
    padding: 0 20px 0 0 !important;
    white-space: pre;
    vertical-align: top;
}

.post-content pre .hljs-ln-line { white-space: pre; }

/* 文末更新时间 */
.post-update {
    margin-top: 22px;
    padding-top: 14px;
    border-top: 1px dashed var(--ly-line);
    font-family: var(--ly-font);
    font-size: 12.5px;
    color: var(--ly-ink-3);
}

/* --------------------------------------------------------------------------
   5. 侧边 / 搜索 / 返回顶部
   -------------------------------------------------------------------------- */

#search-box {
    border-radius: 0 0 14px 14px;
    box-shadow: var(--ly-shadow-md);
}

#search-text {
    font-family: var(--ly-font);
    font-size: 16px;
}

#go-top {
    border-radius: 50%;
    box-shadow: var(--ly-shadow-md);
}

/* 竖排导航（移动端抽屉） */
#nav-vertical { background: #fff; }
#nav-vertical .nav-vertical-list a {
    font-family: var(--ly-font);
    font-size: 16px;
}

/* --------------------------------------------------------------------------
   6. 页脚
   -------------------------------------------------------------------------- */

#footer {
    padding: 26px 0 30px !important;
    font-family: var(--ly-font);
    font-size: 12.5px !important;
    color: var(--ly-ink-3);
    border-top: 1px solid var(--ly-line);
    background: #fafbfc;
}

#footer a { color: var(--ly-ink-3) !important; font-family: var(--ly-font) !important; }
#footer a:hover { color: var(--ly-accent) !important; }

#footer-info { margin-bottom: 6px !important; }
#footer-declare { color: #a2a8b2 !important; line-height: 1.9; }

/* --------------------------------------------------------------------------
   7. 细节
   -------------------------------------------------------------------------- */

::selection {
    background: rgba(79, 110, 247, .18);
    color: var(--ly-ink);
}

a:focus-visible,
button:focus-visible,
input:focus-visible {
    outline: 2px solid var(--ly-accent);
    outline-offset: 2px;
}

/* 滚动条 */
@media (min-width: 769px) {
    ::-webkit-scrollbar { width: 10px; height: 10px; }
    ::-webkit-scrollbar-track { background: transparent; }
    ::-webkit-scrollbar-thumb {
        background: #d3d7de;
        border-radius: 5px;
        border: 2px solid var(--ly-bg);
    }
    ::-webkit-scrollbar-thumb:hover { background: #b9bfc9; }
}

/* --------------------------------------------------------------------------
   8. 移动端
   -------------------------------------------------------------------------- */

@media (max-width: 768px) {
    #site-name { font-size: 2.1rem !important; }
    #site-description { font-size: .85rem !important; }

    #main article,
    .card {
        margin: 16px auto !important;
        padding: 18px 16px !important;
        border-radius: 12px !important;
    }

    .card-title { font-size: 18px !important; }
    .card-body { font-size: 14px !important; }
    .card-thumbnail { margin: 14px 0 !important; }
    .post-content { font-size: 15.5px; line-height: 1.85; }
    .post-content pre { font-size: 12.5px !important; padding: 14px !important; }
    .post-title { font-size: 1.3rem !important; }
}

/* 尊重系统「减少动效」设置 */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .01ms !important;
        transition-duration: .01ms !important;
    }
}
