/*!
 * blog 前台主题（原生 CSS，无第三方依赖）
 * 设计令牌沿用后台 ui-theme.css 的调色板，前台单独一套排版与组件。
 */

/* ==========================================================================
   1. 令牌与基础
   ========================================================================== */
:root {
    --bg: #f6f4ef;
    --surface: #ffffff;
    --surface-2: #faf9f6;
    --ink: #1c1d21;
    --ink-2: #565b63;
    --ink-3: #8b9099;
    --line: #e8e4dd;
    --line-2: #f0ece5;
    --brand: #0f766e;
    --brand-dark: #0b5f59;
    --brand-soft: #e6f4f2;
    --radius: 14px;
    --radius-sm: 8px;
    --radius-pill: 999px;
    --shadow: 0 1px 2px rgba(28, 29, 33, .04), 0 10px 30px rgba(28, 29, 33, .06);
    --shadow-hover: 0 4px 10px rgba(28, 29, 33, .06), 0 18px 40px rgba(28, 29, 33, .10);
    --max: 1180px;
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", Arial, sans-serif;
    --font-serif: Georgia, "Songti SC", "Noto Serif SC", "SimSun", serif;
    --ease: cubic-bezier(.32, .72, .31, 1.01);
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    background-color: var(--bg);
    color: var(--ink);
    font-family: var(--font);
    font-size: 16px;
    line-height: 1.65;
    -webkit-font-smoothing: antialiased;
}

img {
    max-width: 100%;
    display: block;
}

a {
    color: inherit;
    text-decoration: none;
    transition: color .2s var(--ease);
}

a:hover {
    color: var(--brand);
}

button,
input {
    font: inherit;
    color: inherit;
}

button {
    cursor: pointer;
}

::selection {
    background: var(--brand);
    color: #fff;
}

/* ==========================================================================
   2. 顶部导航
   ========================================================================== */
.site-header {
    position: sticky;
    top: 0;
    z-index: 50;
    background: rgba(255, 255, 255, .92);
    backdrop-filter: saturate(180%) blur(12px);
    border-bottom: 1px solid var(--line-2);
}

.site-header__inner {
    max-width: var(--max);
    margin: 0 auto;
    padding: 0 24px;
    height: 68px;
    display: flex;
    align-items: center;
    gap: 28px;
}

.site-brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    flex: none;
    font-weight: 700;
    letter-spacing: .02em;
}

.site-brand__logo {
    width: 30px;
    height: 30px;
    border-radius: 8px;
    object-fit: contain;
}

.site-brand__text {
    font-size: 18px;
    white-space: nowrap;
}

.site-nav {
    display: flex;
    align-items: center;
    gap: 4px;
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
}

.site-nav__link {
    padding: 8px 14px;
    border-radius: var(--radius-pill);
    color: var(--ink-2);
    font-size: 15px;
    white-space: nowrap;
    transition: background-color .2s var(--ease), color .2s var(--ease);
}

.site-nav__link:hover {
    background: var(--brand-soft);
    color: var(--brand-dark);
}

.site-search {
    display: flex;
    align-items: center;
    flex: none;
    width: 240px;
    height: 38px;
    padding: 0 4px 0 14px;
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: var(--radius-pill);
    transition: border-color .2s var(--ease), box-shadow .2s var(--ease);
}

.site-search:focus-within {
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(15, 118, 110, .12);
    background: #fff;
}

.site-search__input {
    flex: 1 1 auto;
    min-width: 0;
    height: 100%;
    border: 0;
    outline: 0;
    background: transparent;
    font-size: 14px;
}

.site-search__btn {
    flex: none;
    height: 30px;
    padding: 0 14px;
    border: 0;
    border-radius: var(--radius-pill);
    background: var(--brand);
    color: #fff;
    font-size: 13px;
    transition: background-color .2s var(--ease);
}

.site-search__btn:hover {
    background: var(--brand-dark);
}

.nav-toggle {
    display: none;
    width: 38px;
    height: 38px;
    padding: 9px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--surface);
    flex: none;
}

.nav-toggle span {
    display: block;
    height: 2px;
    margin: 4px 0;
    background: var(--ink-2);
    border-radius: 2px;
}

/* ==========================================================================
   3. 页面骨架
   ========================================================================== */
.blog-shell {
    max-width: var(--max);
    margin: 0 auto;
    padding: 28px 24px 48px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 300px;
    gap: 32px;
    align-items: start;
}

.blog-main {
    min-width: 0;
}

/* ==========================================================================
   4. 首页轮播
   ========================================================================== */
.hero {
    position: relative;
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    background: linear-gradient(135deg, #0f766e, #123c39);
    aspect-ratio: 21 / 8;
    margin-bottom: 26px;
}

.hero__track {
    position: absolute;
    inset: 0;
}

.hero__slide {
    position: absolute;
    inset: 0;
    opacity: 0;
    transform: scale(1.02);
    transition: opacity .6s var(--ease), transform 6s linear;
}

.hero__slide.is-active {
    opacity: 1;
    transform: scale(1);
}

.hero__slide img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.hero__caption {
    position: absolute;
    left: 24px;
    bottom: 22px;
    max-width: 70%;
    padding: 8px 16px;
    border-radius: var(--radius-pill);
    background: rgba(17, 24, 23, .55);
    color: #fff;
    font-size: 14px;
    backdrop-filter: blur(6px);
}

.hero__dots {
    position: absolute;
    right: 20px;
    bottom: 22px;
    display: flex;
    gap: 8px;
}

.hero__dot {
    width: 9px;
    height: 9px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, .45);
    transition: background-color .2s var(--ease), width .2s var(--ease);
}

.hero__dot.is-active {
    width: 24px;
    border-radius: var(--radius-pill);
    background: #fff;
}

/* ==========================================================================
   5. 文章卡片
   ========================================================================== */
.feed {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.post-card {
    display: grid;
    grid-template-columns: 236px minmax(0, 1fr);
    gap: 22px;
    padding: 18px;
    background: var(--surface);
    border: 1px solid var(--line-2);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    transition: transform .25s var(--ease), box-shadow .25s var(--ease), border-color .25s var(--ease);
}

.post-card:hover {
    transform: translateY(-2px);
    border-color: var(--line);
    box-shadow: var(--shadow-hover);
}

.post-card__thumb {
    position: relative;
    display: block;
    height: 152px;
    overflow: hidden;
    border-radius: var(--radius-sm);
    background: linear-gradient(135deg, #d9ece9, #eef6f4);
}

.post-card__thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform .5s var(--ease);
}

.post-card:hover .post-card__thumb img {
    transform: scale(1.04);
}

.post-card__placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    padding: 12px;
    color: var(--brand-dark);
    font-family: var(--font-serif);
    font-size: 15px;
    line-height: 1.5;
    text-align: center;
    overflow: hidden;
}

.post-card__body {
    display: flex;
    flex-direction: column;
    min-width: 0;
    padding: 4px 4px 2px 0;
}

.post-card__title {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    font-size: 20px;
    font-weight: 700;
    line-height: 1.45;
    color: var(--ink);
}

.post-card__excerpt {
    margin: 10px 0 0;
    color: var(--ink-3);
    font-size: 14px;
    line-height: 1.7;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.post-card__meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: auto;
    padding-top: 14px;
    color: var(--ink-3);
    font-size: 13px;
}

.post-card__tag {
    padding: 2px 10px;
    border-radius: var(--radius-pill);
    background: var(--brand-soft);
    color: var(--brand-dark);
    font-size: 12px;
}

.empty {
    padding: 56px 20px;
    background: var(--surface);
    border: 1px dashed var(--line);
    border-radius: var(--radius);
    color: var(--ink-3);
    text-align: center;
}

.load-more {
    margin-top: 22px;
    text-align: center;
}

.btn-more,
.btn-primary {
    display: inline-block;
    padding: 11px 34px;
    border: 1px solid var(--brand);
    border-radius: var(--radius-pill);
    background: var(--surface);
    color: var(--brand-dark);
    font-size: 14px;
    transition: background-color .2s var(--ease), color .2s var(--ease);
}

.btn-more:hover,
.btn-primary:hover {
    background: var(--brand);
    color: #fff;
}

.btn-more:disabled {
    opacity: .6;
    cursor: default;
}

.btn-primary {
    background: var(--brand);
    color: #fff;
}

/* ==========================================================================
   6. 侧边栏
   ========================================================================== */
.blog-aside {
    position: sticky;
    top: 92px;
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.widget {
    padding: 18px 20px 20px;
    background: var(--surface);
    border: 1px solid var(--line-2);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.widget__title {
    position: relative;
    margin: 0 0 14px;
    padding-left: 12px;
    font-size: 15px;
    font-weight: 700;
    color: var(--ink);
}

.widget__title::before {
    content: "";
    position: absolute;
    left: 0;
    top: 3px;
    bottom: 3px;
    width: 3px;
    border-radius: 2px;
    background: var(--brand);
}

.widget-list {
    margin: 0;
    padding: 0;
    list-style: none;
    counter-reset: widget;
}

.widget-list__item {
    counter-increment: widget;
    position: relative;
    padding: 9px 0 9px 26px;
    border-bottom: 1px dashed var(--line-2);
    font-size: 14px;
    line-height: 1.5;
}

.widget-list__item:last-child {
    border-bottom: 0;
}

.widget-list__item::before {
    content: counter(widget);
    position: absolute;
    left: 0;
    top: 9px;
    width: 18px;
    height: 18px;
    border-radius: 5px;
    background: var(--surface-2);
    color: var(--ink-3);
    font-size: 11px;
    line-height: 18px;
    text-align: center;
}

.widget-list__item:nth-child(-n+3)::before {
    background: var(--brand-soft);
    color: var(--brand-dark);
}

.widget-list__item a {
    display: block;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    color: var(--ink-2);
}

.widget-search {
    display: flex;
    gap: 8px;
}

.widget-search input {
    flex: 1 1 auto;
    min-width: 0;
    height: 38px;
    padding: 0 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    outline: 0;
    font-size: 14px;
}

.widget-search input:focus {
    border-color: var(--brand);
    background: #fff;
}

.widget-search button {
    flex: none;
    height: 38px;
    padding: 0 16px;
    border: 0;
    border-radius: var(--radius-sm);
    background: var(--brand);
    color: #fff;
    font-size: 13px;
}

.widget-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.widget-tags a {
    padding: 5px 12px;
    border-radius: var(--radius-pill);
    background: var(--surface-2);
    border: 1px solid var(--line-2);
    color: var(--ink-2);
    font-size: 13px;
}

.widget-tags a:hover {
    background: var(--brand-soft);
    border-color: transparent;
    color: var(--brand-dark);
}

/* ==========================================================================
   7. 分类 / 搜索页
   ========================================================================== */
.page-head {
    margin-bottom: 22px;
    padding: 26px 28px;
    background: linear-gradient(135deg, #fff, #fbfaf7);
    border: 1px solid var(--line-2);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.page-head__title {
    margin: 0;
    font-family: var(--font-serif);
    font-size: 26px;
    font-weight: 700;
    letter-spacing: .01em;
}

.page-head__sub {
    margin: 8px 0 0;
    color: var(--ink-3);
    font-size: 14px;
}

.pager {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 26px;
    justify-content: center;
}

.pager__link {
    min-width: 38px;
    height: 38px;
    padding: 0 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--ink-2);
    font-size: 14px;
}

.pager__link:hover {
    border-color: var(--brand);
    color: var(--brand-dark);
}

.pager__link.is-current {
    border-color: var(--brand);
    background: var(--brand);
    color: #fff;
}

.pager__link.is-disabled {
    color: #c3c8ce;
    background: var(--surface-2);
    cursor: default;
}

.pager__dots {
    padding: 0 4px;
    color: var(--ink-3);
}

/* ==========================================================================
   8. 文章详情
   ========================================================================== */
.article {
    padding: 34px 40px 40px;
    background: var(--surface);
    border: 1px solid var(--line-2);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.article__head {
    padding-bottom: 20px;
    border-bottom: 1px solid var(--line-2);
}

.article__title {
    margin: 0;
    font-family: var(--font-serif);
    font-size: 31px;
    line-height: 1.4;
    font-weight: 700;
    letter-spacing: .01em;
}

.article__meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 14px;
    color: var(--ink-3);
    font-size: 13px;
}

.article__content {
    padding-top: 24px;
    font-size: 16.5px;
    line-height: 1.9;
    color: #2a2d33;
    word-wrap: break-word;
}

.article__content h2,
.article__content h3,
.article__content h4 {
    margin: 1.6em 0 .6em;
    line-height: 1.5;
    color: var(--ink);
}

.article__content p {
    margin: 1em 0;
}

.article__content img {
    max-width: 100%;
    height: auto;
    margin: 1.2em auto;
    border-radius: var(--radius-sm);
}

.article__content a {
    color: var(--brand);
    text-decoration: underline;
    text-underline-offset: 3px;
}

.article__content blockquote {
    margin: 1.2em 0;
    padding: 12px 18px;
    border-left: 3px solid var(--brand);
    background: var(--surface-2);
    color: var(--ink-2);
}

.article__content pre {
    padding: 16px 18px;
    overflow: auto;
    background: #1f2328;
    border-radius: var(--radius-sm);
    color: #e6edf3;
    font-size: 13.5px;
    line-height: 1.7;
}

.article__content code {
    padding: 2px 5px;
    border-radius: 4px;
    background: #f1f3f5;
    font-size: .92em;
}

.article__content pre code {
    padding: 0;
    background: transparent;
    color: inherit;
}

.article__content table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.2em 0;
    font-size: 14px;
}

.article__content th,
.article__content td {
    padding: 9px 12px;
    border: 1px solid var(--line);
    text-align: left;
}

.related {
    padding: 26px 28px 28px;
    margin-top: 20px;
    background: var(--surface);
    border: 1px solid var(--line-2);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.related__title {
    position: relative;
    margin: 0 0 16px;
    padding-left: 12px;
    font-size: 16px;
    font-weight: 700;
}

.related__title::before {
    content: "";
    position: absolute;
    left: 0;
    top: 3px;
    bottom: 3px;
    width: 3px;
    border-radius: 2px;
    background: var(--brand);
}

.related__grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
}

.related__item {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid var(--line-2);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
}

.related__item img {
    width: 100%;
    height: 104px;
    object-fit: cover;
}

.related__placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 104px;
    padding: 10px;
    background: linear-gradient(135deg, #d9ece9, #eef6f4);
    color: var(--brand-dark);
    font-size: 13px;
    text-align: center;
}

.related__name {
    padding: 10px 12px;
    font-size: 13.5px;
    line-height: 1.5;
    color: var(--ink-2);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ==========================================================================
   9. 404
   ========================================================================== */
.not-found {
    padding: 70px 30px 80px;
    background: var(--surface);
    border: 1px solid var(--line-2);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    text-align: center;
}

.not-found__code {
    font-family: var(--font-serif);
    font-size: 82px;
    line-height: 1;
    font-weight: 700;
    color: var(--brand-soft);
    -webkit-text-stroke: 1px var(--brand);
}

.not-found__title {
    margin: 16px 0 8px;
    font-size: 22px;
}

.not-found__desc {
    margin: 0 0 24px;
    color: var(--ink-3);
    font-size: 14px;
}

/* ==========================================================================
   10. 页脚
   ========================================================================== */
.site-footer {
    background: var(--surface);
    border-top: 1px solid var(--line-2);
}

.site-footer__inner {
    max-width: var(--max);
    margin: 0 auto;
    padding: 26px 24px;
    color: var(--ink-3);
    font-size: 13px;
    text-align: center;
}

.site-footer__inner p {
    margin: 4px 0;
}

/* ==========================================================================
   11. 响应式
   ========================================================================== */
@media (max-width: 1080px) {
    .blog-shell {
        grid-template-columns: minmax(0, 1fr);
    }

    .blog-aside {
        position: static;
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 860px) {
    .site-header__inner {
        flex-wrap: wrap;
        height: auto;
        padding: 12px 18px;
        gap: 12px;
    }

    .site-nav {
        order: 3;
        display: none;
        width: 100%;
        flex-wrap: wrap;
        gap: 6px;
        padding-top: 6px;
    }

    .site-nav.is-open {
        display: flex;
    }

    .site-search {
        order: 2;
        width: auto;
        flex: 1 1 auto;
    }

    .nav-toggle {
        display: block;
        order: 3;
        margin-left: auto;
    }

    .site-nav.is-open + .site-search {
        order: 4;
    }

    .blog-shell {
        padding: 18px 16px 36px;
        gap: 22px;
    }

    .hero {
        aspect-ratio: 16 / 9;
    }

    .post-card {
        grid-template-columns: 132px minmax(0, 1fr);
        gap: 14px;
        padding: 14px;
    }

    .post-card__thumb {
        height: 104px;
    }

    .post-card__title {
        font-size: 17px;
        -webkit-line-clamp: 2;
    }

    .post-card__excerpt {
        display: none;
    }

    .article {
        padding: 24px 20px 28px;
    }

    .article__title {
        font-size: 24px;
    }

    .article__content {
        font-size: 16px;
    }

    .related__grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .blog-aside {
        grid-template-columns: minmax(0, 1fr);
    }
}

@media (max-width: 520px) {
    .site-brand__text {
        font-size: 16px;
    }

    .post-card {
        grid-template-columns: minmax(0, 1fr);
    }

    .post-card__thumb {
        height: 168px;
    }

    .post-card__excerpt {
        display: -webkit-box;
    }

    .related__grid {
        grid-template-columns: minmax(0, 1fr);
    }
}
