/* ===== 主页面三栏布局 ===== */
.main-layout {
    display: flex;
    gap: 0;
    /* 宽度必须写死 100%：body 是竖排 flex 容器，而 flex 项在交叉轴上带 auto margin 时
       不会被拉伸、会退化成 fit-content —— 那样三栏总宽就跟内容走，
       列表视图与文章视图的最大内容宽度不同，切进文章时整栏会突然缩窄。 */
    width: 100%;
    min-height: 100vh;
    padding-top: 72px; /* navbar高度 */
    max-width: 1600px;
    margin: 0 auto;
    background: transparent !important;
}

/* ===== Markdown 文章视图 ===== */
.article-view {
    display: none;
}

.article-view.active {
    animation: fadeInUp 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    display: block;
}

.article-view.leaving {
    animation: fadeOutDown 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    display: block;
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes fadeOutDown {
    from { opacity: 1; transform: translateY(0); }
    to   { opacity: 0; transform: translateY(12px); }
}

.blog-list-view {
    display: block;
}

.blog-list-view.hidden {
    display: none;
}

/* 返回按钮 */
.back-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    /* 与全站按钮同一套令牌：默认玻璃底，hover / 聚焦转金 */
    background: var(--ctl-bg);
    border: 1px solid var(--ctl-border);
    color: var(--ctl-fg-dim);
    /* 字体族由 global.css 的「*」规则统一给 Sarasa */
    font-size: 13px;
    letter-spacing: 1px;
    padding: 7px 16px;
    border-radius: var(--ctl-radius);
    cursor: pointer;
    margin-bottom: 28px;
    transition: var(--ctl-transition);
}

.back-btn:hover,
.back-btn:focus-visible {
    border-color: var(--ctl-border-hover);
    color: var(--ctl-fg-hover);
    background: var(--ctl-bg-strong);
}

.back-btn svg {
    width: 14px;
    height: 14px;
    fill: currentColor;
}

/* 文章标题区 */
.article-header {
    margin-bottom: 32px;
    padding-bottom: 24px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.article-header h1 {
    font-size: 26px;
    font-weight: 400;
    letter-spacing: 2px;
    color: rgba(255, 255, 255, 0.9);
    margin-bottom: 10px;
    line-height: 1.4;
}

.article-header .article-meta {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.3);
    display: flex;
    gap: 14px;
    letter-spacing: 1px;
}

/* ===== Markdown 内容渲染样式 ===== */
.markdown-body {
    color: rgba(255, 255, 255, 0.72);
    font-size: 15px;
    line-height: 1.85;
    letter-spacing: 0.3px;
}

.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4,
.markdown-body h5,
.markdown-body h6 {
    font-weight: 400;
    letter-spacing: 2px;
    color: rgba(255, 255, 255, 0.88);
    margin: 2em 0 0.75em;
    line-height: 1.4;
}

.markdown-body h1 { font-size: 22px; border-bottom: 1px solid rgba(255,255,255,0.08); padding-bottom: 10px; }
.markdown-body h2 { font-size: 19px; }
.markdown-body h3 { font-size: 16px; color: rgba(255,215,0,0.75); }
.markdown-body h4 { font-size: 14px; color: rgba(255,255,255,0.6); }

.markdown-body p {
    margin: 0 0 1.2em;
}

.markdown-body a {
    color: rgba(255, 215, 0, 0.8);
    text-decoration: none;
    border-bottom: 1px solid rgba(255, 215, 0, 0.25);
    transition: 0.2s;
}

.markdown-body a:hover {
    color: #FFD700;
    border-bottom-color: rgba(255, 215, 0, 0.6);
}

.markdown-body strong {
    color: rgba(255, 255, 255, 0.9);
    font-weight: 600;
}

.markdown-body em {
    color: rgba(255, 255, 255, 0.6);
    font-style: italic;
}

.markdown-body ul,
.markdown-body ol {
    margin: 0 0 1.2em;
    padding-left: 1.6em;
}

.markdown-body li {
    margin-bottom: 0.4em;
}

.markdown-body li::marker {
    color: rgba(255, 215, 0, 0.5);
}

.markdown-body blockquote {
    border-left: 3px solid rgba(255, 215, 0, 0.3);
    margin: 1.5em 0;
    padding: 0.5em 1.2em;
    background: rgba(255, 255, 255, 0.02);
    color: rgba(255, 255, 255, 0.5);
    font-size: 14px;
    border-radius: 0 4px 4px 0;
}

.markdown-body blockquote p {
    margin: 0;
}

.markdown-body code {
    background: rgba(255, 255, 255, 0.07);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    padding: 0.15em 0.45em;
    font-size: 13px;
    color: rgba(255, 215, 0, 0.7);
    font-family: 'Courier New', Courier, monospace;
    letter-spacing: 0;
}

.markdown-body pre {
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 6px;
    padding: 18px 20px;
    overflow-x: auto;
    margin: 1.5em 0;
}

.markdown-body pre code {
    background: none;
    border: none;
    padding: 0;
    color: rgba(255, 255, 255, 0.7);
    font-size: 13px;
}

.markdown-body table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.5em 0;
    font-size: 14px;
}

.markdown-body th {
    background: rgba(255, 255, 255, 0.05);
    color: rgba(255, 255, 255, 0.7);
    font-weight: 500;
    text-align: left;
    padding: 10px 14px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    letter-spacing: 1px;
}

.markdown-body td {
    padding: 8px 14px;
    border: 1px solid rgba(255, 255, 255, 0.06);
    color: rgba(255, 255, 255, 0.55);
}

.markdown-body tr:hover td {
    background: rgba(255, 255, 255, 0.02);
}

.markdown-body hr {
    border: none;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    margin: 2em 0;
}

.markdown-body img {
    max-width: 100%;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    margin: 1em 0;
}

/* 加载状态 */
.md-loading {
    text-align: center;
    padding: 48px 0;
    color: rgba(255, 255, 255, 0.25);
    font-size: 13px;
    letter-spacing: 2px;
}

.md-loading::before {
    content: '';
    display: block;
    width: 24px;
    height: 24px;
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-top-color: rgba(255, 215, 0, 0.5);
    border-radius: 50%;
    margin: 0 auto 16px;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ===== 左侧栏 ===== */
.left-panel {
    flex: 0 0 220px;
    position: sticky;
    top: 72px;
    height: calc(100vh - 72px);
    overflow-y: auto;
    padding: 40px 20px 30px 40px;
    border-right: 1px solid rgba(255, 255, 255, 0.06);
}

.left-panel nav.vertical-nav {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.left-panel nav.vertical-nav a {
    color: rgba(255, 255, 255, 0.6);
    text-decoration: none;
    font-size: 15px;
    transition: 0.3s;
    padding: 4px 0 4px 4px;
    letter-spacing: 1px;
    border-left: 3px solid transparent;
}

.left-panel nav.vertical-nav a:hover,
.left-panel nav.vertical-nav a.active {
    color: #FFD700;
    opacity: 1;
    padding-left: 10px;
    border-left-color: #FFD700;
}

.left-panel .nav-section-title {
    color: rgba(255, 255, 255, 0.3);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-top: 20px;
    margin-bottom: 10px;
    pointer-events: none;
}

.left-panel .nav-section-title:first-child {
    margin-top: 0;
}

/* ===== 中间栏 ===== */
.center-panel {
    flex: 1;
    min-width: 0;
    padding: 40px 36px;
    border-right: 1px solid rgba(255, 255, 255, 0.06);
}

.blog-header {
    margin-bottom: 32px;
}

.blog-header h1 {
    font-size: 28px;
    font-weight: 400;
    letter-spacing: 3px;
    color: rgba(255, 255, 255, 0.9);
}

.blog-header .subtitle {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.35);
    margin-top: 8px;
    letter-spacing: 1px;
}

.blog-list {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.blog-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 8px;
    padding: 24px;
    transition: 0.3s;
    cursor: pointer;
}

.blog-card:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 215, 0, 0.2);
}

.blog-card .blog-title {
    font-size: 18px;
    color: rgba(255, 255, 255, 0.85);
    margin-bottom: 8px;
    letter-spacing: 1px;
}

.blog-card .blog-meta {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.3);
    display: flex;
    gap: 16px;
}

.blog-card .blog-excerpt {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.5);
    margin-top: 12px;
    line-height: 1.7;
}

/* ==========================================================================
   列表切换动画 与 卡片背景形变
   --------------------------------------------------------------------------
   1) 切分类：整列卡片从右向左离开，新的一列从左向右进来
   2) 点卡片：卡片背景展开成文章正文的背景；返回时缩回卡片形状
   ========================================================================== */

/* 形变层用绝对定位，坐标相对中栏算（见 mainpage.html 的 panelRect） */
.center-panel {
    position: relative;
}

/* 列表横向滑动时要裁剪，否则卡片会滑到左边那一栏上面去 */
.blog-list-view {
    overflow: hidden;
}

.blog-list.switching {
    animation: list-out-left 0.24s ease-in both;
}

.blog-list.entering {
    animation: list-in-left 0.36s cubic-bezier(0.22, 0.61, 0.36, 1) both;
}

@keyframes list-out-left {
    from { opacity: 1; transform: translateX(0); }
    to   { opacity: 0; transform: translateX(-100%); }
}

@keyframes list-in-left {
    from { opacity: 0; transform: translateX(-100%); }
    to   { opacity: 1; transform: translateX(0); }
}

/* 文章内容要压在形变背景之上 */
.article-view {
    position: relative;
    z-index: 1;
}

/* 卡片背景的形变层：位置与尺寸由 JS 写，靠过渡做动画。
   外观与 .blog-card 完全一致 —— 它就是「那张卡片的背景」被拉展开。 */
.article-morph {
    position: absolute;
    z-index: 0;
    opacity: 0;
    pointer-events: none;

    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 8px;

    transition: left 0.42s cubic-bezier(0.4, 0, 0.2, 1),
                top 0.42s cubic-bezier(0.4, 0, 0.2, 1),
                width 0.42s cubic-bezier(0.4, 0, 0.2, 1),
                height 0.42s cubic-bezier(0.4, 0, 0.2, 1),
                opacity 0.26s ease;
}

/* 尊重「减少动态效果」：形变与滑动都几乎瞬时完成 */
@media (prefers-reduced-motion: reduce) {
    .article-morph,
    .blog-list.switching,
    .blog-list.entering {
        transition-duration: 0.001s !important;
        animation-duration: 0.001s !important;
    }
}

/* ===== 右侧栏 ===== */
.right-panel {
    flex: 0 0 320px;
    position: sticky;
    top: 72px;
    height: calc(100vh - 72px);
    overflow-y: auto;
    padding: 40px 30px 30px 24px;
}

/* ===== 日历组件 ===== */
.calendar-widget {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 24px;
}

.calendar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 18px;
}

.calendar-header .year-month {
    font-size: 16px;
    letter-spacing: 2px;
    color: rgba(255, 255, 255, 0.8);
}

.calendar-header .nav-arrows {
    display: flex;
    gap: 8px;
}

.calendar-header .nav-arrow {
    background: none;
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: rgba(255, 255, 255, 0.5);
    width: 28px;
    height: 28px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: 0.2s;
}

.calendar-header .nav-arrow:hover {
    border-color: rgba(255, 215, 0, 0.4);
    color: #FFD700;
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
}

.calendar-grid .day-name {
    text-align: center;
    font-size: 11px;
    color: rgba(255, 255, 255, 0.3);
    padding: 6px 0;
    letter-spacing: 1px;
}

.calendar-grid .day-cell {
    text-align: center;
    padding: 6px 0;
    font-size: 13px;
    color: rgba(255, 255, 255, 0.6);
    border-radius: 4px;
    transition: 0.2s;
    cursor: default;
}

.calendar-grid .day-cell:hover {
    background: rgba(255, 255, 255, 0.06);
}

.calendar-grid .day-cell.today {
    background: rgba(255, 215, 0, 0.15);
    color: #FFD700;
    font-weight: 500;
    border: 1px solid rgba(255, 215, 0, 0.3);
}

.calendar-grid .day-cell.other-month {
    color: rgba(255, 255, 255, 0.15);
}

.calendar-grid .day-cell.other-month:hover {
    background: transparent;
}

/* ===== 右侧附加信息 ===== */
.right-info {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.info-item {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.4);
    letter-spacing: 1px;
    line-height: 1.6;
}

.info-item .label {
    color: rgba(255, 255, 255, 0.2);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-bottom: 4px;
}

/* ===== 响应式 ===== */
@media (max-width: 1024px) {
    .left-panel {
        display: none;
    }
    .right-panel {
        flex: 0 0 240px;
    }
}

@media (max-width: 768px) {
    .main-layout {
        flex-direction: column;
        padding-top: 72px;
    }
    .center-panel {
        padding: 24px 16px;
        border-right: none;
    }
    .right-panel {
        flex: none;
        position: static;
        height: auto;
        padding: 0 16px 30px;
    }
    .blog-card {
        padding: 16px;
    }

    /* 宽表格在窄屏改为横向滚动，别把整页撑宽 */
    .markdown-body table {
        display: block;
        max-width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .markdown-body th,
    .markdown-body td {
        padding: 8px 10px;
        font-size: 13px;
        white-space: nowrap;
    }

    .article-header h1,
    .blog-header h1 {
        font-size: 21px;
        letter-spacing: 1px;
    }

    .calendar-widget {
        padding: 14px;
    }
}
