/* === Archive (year-grouped list) === */
/* Header / eyebrow / title / desc 共用 .list-header / .list-eyebrow / .list-title / .list-desc（见 main.css） */
.archive {
    padding-bottom: 4rem;
}

.archive-stream {
    display: flex;
    flex-direction: column;
    gap: 3.5rem;
}

.archive-year {
    position: relative;
}

/* Big outlined year + thin meta line on the right */
.year-label {
    display: flex;
    align-items: baseline;
    gap: 1.2rem;
    margin-bottom: 1.2rem;
}

.year-label-num {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: clamp(2rem, 4.5vw, 3.2rem);
    line-height: 1;
    letter-spacing: -0.01em;
    color: transparent;
    -webkit-text-stroke: 1px var(--accent);
    background: linear-gradient(135deg,
                color-mix(in srgb, var(--accent) 35%, transparent),
                color-mix(in srgb, var(--accent-2) 25%, transparent));
    -webkit-background-clip: text;
            background-clip: text;
    filter: drop-shadow(0 0 3px color-mix(in srgb, var(--neon-glow) 30%, transparent));
}

/* Night scene: dim down stroke / fill and add a slow breathing glow */
[data-scene="night"] .year-label-num {
    -webkit-text-stroke: 1px color-mix(in srgb, var(--accent) 70%, transparent);
    background: linear-gradient(135deg,
                color-mix(in srgb, var(--accent) 22%, transparent),
                color-mix(in srgb, var(--accent-2) 16%, transparent));
    -webkit-background-clip: text;
            background-clip: text;
    animation: year-label-pulse 6s ease-in-out infinite;
}

@keyframes year-label-pulse {
    0%, 100% {
        filter: drop-shadow(0 0 2px color-mix(in srgb, var(--neon-glow) 20%, transparent));
    }
    50% {
        filter: drop-shadow(0 0 18px color-mix(in srgb, var(--neon-glow) 85%, transparent));
    }
}

.year-label-meta {
    display: inline-flex;
    align-items: center;
    gap: 0.8rem;
    flex: 1;
    color: var(--mid);
    font-family: var(--font-mono);
    font-size: 0.78rem;
    letter-spacing: 0.06em;
    padding-bottom: 0.6rem;
}

.year-label-line {
    flex: 1;
    height: 1px;
    background: linear-gradient(90deg, var(--line), transparent);
}

.archive-posts {
    list-style: none;
    padding: 0;
    margin: 0;
}

.archive-posts .post-item {
    border-bottom: 1px dashed var(--line);
}

.archive-posts .post-item:last-child {
    border-bottom: none;
}

.archive-posts .post-item-link {
    display: grid;
    grid-template-columns: 64px 1fr auto;
    align-items: baseline;
    gap: 1.2rem;
    padding: 0.85rem 0.5rem 0.85rem 0;
    transition:
        padding 0.2s ease,
        background-color 0.2s ease;
}

.archive-posts .post-item-link:hover {
    padding-left: 0.8rem;
    background: linear-gradient(90deg,
                color-mix(in srgb, var(--accent) 8%, transparent) 0%,
                transparent 75%);
}

.archive-posts .post-item-date {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--mid);
    letter-spacing: 0.04em;
}

.archive-posts .post-item-title {
    font-family: var(--font-body);
    font-size: 0.98rem;
    color: var(--text);
    font-weight: 500;
    transition: color 0.2s ease;
}

.archive-posts .post-item-link:hover .post-item-title { color: var(--accent); }

/* `.post-item-tags` 左对齐换行 + `.chip` hover 高亮均为通用规则，定义见 home.css */

.archive-posts .post-item-views {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    color: var(--mid);
    opacity: 0.6;
}

.archive-posts .post-item-views::after { content: ' views'; }

.archive-posts .post-item-arrow {
    font-family: var(--font-mono);
    color: var(--mid);
    opacity: 0;
    transition: opacity 0.2s ease, transform 0.2s ease, color 0.2s ease;
}

.archive-posts .post-item-link:hover .post-item-arrow {
    opacity: 1;
    color: var(--accent);
    transform: translateX(4px);
}

@media (max-width: 720px) {
    .archive-posts .post-item-link {
        grid-template-columns: 56px 1fr;
        gap: 0.85rem;
    }
    .archive-posts .post-item-meta { display: none; }
    .year-label-meta { display: none; }
}

/* === Reading progress bar === */
.post-progress {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: 2px;
    z-index: 200;
    background: transparent;
    pointer-events: none;
}
.post-progress > span {
    display: block;
    width: 100%;
    height: 100%;
    transform-origin: left center;
    transform: scaleX(0);
    background: linear-gradient(90deg, var(--accent), var(--accent-2));
    box-shadow: 0 0 12px var(--neon-glow);
    transition: transform 0.08s linear;
}

/* === Single Post Header ===
   Header / eyebrow / title 复用 .list-header.list-header--post / .list-eyebrow / .list-title（见 main.css）
   这里只保留文章详情独有的元信息行 */
.post-meta {
    font-family: var(--font-mono);
    font-size: 0.78rem;
    color: var(--mid);
    display: flex;
    gap: 1.2rem;
    align-items: center;
    flex-wrap: wrap;
    letter-spacing: 0.03em;
    margin-top: 0.8rem;
}

/* === Related posts (article footer) === */
.related-posts {
    margin: 2.5rem 0 2rem;
    padding-top: 1.6rem;
    border-top: 1px dashed var(--line);
}

.related-posts-head {
    margin-bottom: 0.9rem;
}

.related-posts-title {
    font-family: var(--font-display);
    font-size: clamp(1.05rem, 1.6vw, 1.25rem);
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text);
    margin: 0.2rem 0 0;
}

.related-posts-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.related-post {
    border-bottom: 1px dashed var(--line);
}
.related-post:last-child { border-bottom: none; }

.related-post-link {
    display: grid;
    grid-template-columns: 92px 1fr auto auto;
    align-items: baseline;
    gap: 1rem;
    padding: 0.7rem 0.5rem 0.7rem 0;
    color: var(--text);
    transition: padding-left 0.2s ease, background-color 0.2s ease, color 0.2s ease;
}
.related-post-link:hover {
    padding-left: 0.7rem;
    background: linear-gradient(90deg,
                color-mix(in srgb, var(--accent) 6%, transparent) 0%,
                transparent 75%);
}
.related-post-link:hover .related-post-title { color: var(--accent); }

.related-post-date {
    font-family: var(--font-mono);
    font-size: 0.78rem;
    color: var(--mid);
    letter-spacing: 0.03em;
}
.related-post-title {
    font-family: var(--font-body);
    font-size: 0.95rem;
    transition: color 0.2s ease;
}
.related-post-tags {
    display: inline-flex;
    gap: 0.35rem;
    flex-shrink: 0;
}
.related-post-arrow {
    font-family: var(--font-mono);
    color: var(--mid);
    opacity: 0;
    transition: transform 0.2s ease, color 0.2s ease, opacity 0.2s ease;
}
.related-post-link:hover .related-post-arrow {
    opacity: 1;
    color: var(--accent);
    transform: translateX(4px);
}

@media (max-width: 720px) {
    .related-post-link {
        grid-template-columns: 72px 1fr;
        gap: 0.8rem;
    }
    .related-post-tags,
    .related-post-arrow { display: none; }
}

/* === Back-to-top floating button (article pages) ===
   Sits at the left edge of the article container (not glued to the viewport
   edge), a bit above the bottom, with a permanent accent ring + glow so it
   reads at a glance instead of melting into the background. */
.post-back-to-top {
    position: fixed;
    bottom: 4.5rem;
    /* Hugs the article container's left side on wide screens, falls back to
       a viewport-edge margin on narrow ones. Larger offset → farther from
       the main column. */
    left: max(1.5rem, calc(50% - 560px));
    z-index: 60;
    width: 48px;
    height: 48px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    color: var(--accent);
    background: color-mix(in srgb, var(--accent) 14%, transparent);
    border: 1px solid color-mix(in srgb, var(--accent) 55%, var(--line));
    cursor: pointer;
    opacity: 0;
    pointer-events: none;
    transform: translateY(8px);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    box-shadow:
        0 0 0 1px color-mix(in srgb, var(--neon-glow) 70%, transparent),
        0 10px 24px -10px var(--neon-glow);
    transition:
        opacity 0.3s ease,
        transform 0.25s ease,
        border-color 0.2s ease,
        background-color 0.2s ease,
        box-shadow 0.2s ease,
        color 0.2s ease;
}

.post-back-to-top.is-visible {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}

.post-back-to-top:hover {
    border-color: var(--accent);
    background: color-mix(in srgb, var(--accent) 24%, transparent);
    box-shadow:
        0 0 0 1px var(--neon-glow),
        0 14px 30px -10px var(--neon-glow);
    transform: translateY(-3px);
}

.post-back-to-top svg {
    width: 20px;
    height: 20px;
    stroke-width: 2.5;
}

@media (max-width: 720px) {
    .post-back-to-top {
        bottom: 3rem;
        left: 1rem;
        width: 42px;
        height: 42px;
    }
    .post-back-to-top svg { width: 18px; height: 18px; }
}

/* PINNED badge in the article meta row */
.post-pinned-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35em;
    color: var(--accent);
    letter-spacing: 0.18em;
    text-transform: uppercase;
}
.post-pinned-badge .icon-sword {
    filter: drop-shadow(0 0 4px var(--neon-glow));
}

.post-tags {
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
}

.tag {
    font-family: var(--font-mono);
    color: var(--accent);
    font-size: 0.76rem;
    transition: text-shadow 0.2s ease;
}

.tag:hover {
    text-shadow: 0 0 12px var(--neon-glow);
}

/* === Code block enhancements (badge + copy button) === */
.highlight {
    position: relative;
}

.code-lang {
    position: absolute;
    top: 0.55rem;
    right: 0.55rem;
    font-family: var(--font-mono);
    font-size: 0.68rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    padding: 0.18em 0.55em;
    color: var(--accent);
    background: color-mix(in srgb, var(--surface-1) 80%, transparent);
    border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--line));
    border-radius: 4px;
    pointer-events: none;
    opacity: 0.8;
}

.code-filename {
    position: absolute;
    top: 0.55rem;
    left: 0.55rem;
    font-family: var(--font-mono);
    font-size: 0.68rem;
    letter-spacing: 0.04em;
    padding: 0.18em 0.55em;
    color: var(--mid);
    background: color-mix(in srgb, var(--surface-1) 80%, transparent);
    border: 1px solid var(--line);
    border-radius: 4px;
    pointer-events: none;
    opacity: 0.85;
    max-width: calc(50% - 1rem);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.highlight[data-filename] pre {
    padding-top: 2.2rem;
}

.code-copy {
    position: absolute;
    top: 0.45rem;
    right: 0.55rem;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.32em 0.55em;
    font-family: var(--font-mono);
    font-size: 0.72rem;
    color: var(--mid);
    background: color-mix(in srgb, var(--surface-1) 80%, transparent);
    border: 1px solid var(--line);
    border-radius: 4px;
    cursor: pointer;
    opacity: 0;
    transition:
        opacity 0.2s ease,
        color 0.2s ease,
        border-color 0.2s ease,
        box-shadow 0.2s ease;
    line-height: 1;
}

.code-lang ~ .code-copy { right: 4.3rem; }

.highlight:hover .code-copy { opacity: 1; }

.code-copy:hover {
    color: var(--accent);
    border-color: var(--accent);
    box-shadow: 0 0 0 1px var(--neon-glow);
}

.code-copy.is-copied {
    color: var(--accent);
    border-color: var(--accent);
}

.code-copy-label { line-height: 1; }

/* Post content typography */
.post-content {
    font-size: 0.98rem;
    line-height: 1.85;
}

.post-content h2 {
    margin-top: 2.8rem;
    padding-bottom: 0.4rem;
    border-bottom: 1px solid var(--line);
    transition: border-color 0.3s ease;
}

.post-content h3 {
    margin-top: 2.2rem;
}

/* 统一所有级别标题的锚点定位间距,保证 TOC 点击后落点一致 */
.post-content :is(h1, h2, h3, h4, h5, h6) {
    scroll-margin-top: 80px;
}

.post-content ul,
.post-content ol {
    padding-left: 1.5em;
    margin-bottom: 1.2em;
}

.post-content li {
    margin-bottom: 0.35em;
}

.post-content table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1.5em;
    font-size: 0.9rem;
    border: 1px solid var(--line);
    border-radius: 6px;
    overflow: hidden;
}

.post-content th,
.post-content td {
    padding: 0.6em 0.9em;
    border-bottom: 1px solid var(--line);
    text-align: left;
    transition: border-color 0.3s ease;
}

.post-content th {
    font-family: var(--font-mono);
    font-size: 0.78rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--accent);
    background: var(--surface-1);
}

.post-content tr:last-child td { border-bottom: none; }

/* Post footer */
.post-footer {
    margin-top: 3.5rem;
    padding-top: 1.8rem;
    border-top: 1px solid var(--line);
    transition: border-color 0.3s ease;
}

.post-nav {
    display: flex;
    justify-content: space-between;
    gap: 1.2rem;
    margin-bottom: 2.5rem;
}

.post-nav-link {
    display: inline-flex;
    align-items: center;
    gap: 0.4em;
    font-family: var(--font-body);
    font-size: 0.9rem;
    color: var(--mid);
    padding: 0.6em 0.9em;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: color-mix(in srgb, var(--surface-1) 60%, transparent);
    transition:
        color 0.2s ease,
        border-color 0.2s ease,
        background-color 0.2s ease,
        transform 0.2s ease;
}

.post-nav-link:hover {
    color: var(--accent);
    border-color: var(--accent);
    transform: translateY(-1px);
}

.post-nav-link.prev:hover { transform: translate(-3px, -1px); }
.post-nav-link.next:hover { transform: translate(3px, -1px); }

.comment-placeholder {
    text-align: center;
    padding: 2.5rem 2rem;
    border: 1px dashed var(--line);
    border-radius: 8px;
    background: color-mix(in srgb, var(--surface-1) 40%, transparent);
    transition: border-color 0.3s ease;
}

.comment-note {
    font-family: var(--font-mono);
    color: var(--mid);
    font-size: 0.85rem;
    margin: 0;
}

/* === Reading time === */
.post-reading-time {
    color: var(--mid);
}

/* === TOC Sidebar === */
.toc-sidebar {
    margin-bottom: 2rem;
    padding: 1.1rem 1.3rem;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: color-mix(in srgb, var(--surface-1) 60%, transparent);
    backdrop-filter: blur(8px);
    transition: border-color 0.3s ease, background-color 0.3s ease;
}

.toc-title {
    display: block;
    font-family: var(--font-mono);
    font-size: 0.78rem;
    font-weight: 500;
    text-transform: lowercase;
    letter-spacing: 0.06em;
    color: var(--accent);
    margin-bottom: 0.8rem;
}

.toc-title::before { content: '// '; opacity: 0.7; }

.toc-nav ul {
    list-style: none;
    padding-left: 0;
    margin: 0;
}

.toc-nav ul ul {
    padding-left: 1em;
    border-left: 1px solid var(--line);
    margin-left: 0.4em;
}

.toc-nav li {
    margin-bottom: 0.2em;
    position: relative;
}

.toc-nav a {
    display: block;
    font-family: var(--font-body);
    font-size: 0.86rem;
    color: var(--mid);
    padding: 0.18em 0 0.18em 0.6em;
    border-left: 2px solid transparent;
    transition: color 0.2s ease, border-color 0.2s ease, padding-left 0.2s ease;
}

.toc-nav a:hover {
    color: var(--text);
    padding-left: 0.85em;
}

.toc-nav a.is-active {
    color: var(--accent);
    font-weight: 500;
    border-left-color: var(--accent);
}

@media (min-width: 1300px) {
    .post-single {
        position: relative;
    }

    .toc-sidebar {
        position: absolute;
        left: calc(100% + 1.5rem);
        top: 0;
        width: 200px;
        height: 100%;
        margin: 0;
        padding: 0;
        border: none;
        border-radius: 0;
        background: transparent;
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
    }

    .toc-nav {
        position: sticky;
        top: 15vh;
        max-height: calc(100vh - 120px);
        overflow-y: auto;
        padding-right: 0.5rem;
    }

    .toc-nav::-webkit-scrollbar {
        width: 3px;
    }

    .toc-nav::-webkit-scrollbar-thumb {
        background: var(--line);
        border-radius: 3px;
    }

    .toc-nav a {
        font-size: 0.95rem;
        line-height: 1.5;
    }
}

/* === Post footer tags === */
.post-footer-tags {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 1.5rem;
}

/* === Tags cloud page === */
.tags-cloud {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    padding: 1rem 0 3rem;
}

.tag-item {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.3em 0.8em;
    border: 1px solid var(--line);
    border-radius: 6px;
    font-size: 0.85rem;
    color: var(--mid);
    transition:
        border-color 0.2s ease,
        color 0.2s ease;
}

.tag-item:hover {
    border-color: var(--mid);
    color: var(--text);
}

.tag-name {
    color: var(--accent);
}

.tag-count {
    font-size: 0.75rem;
    color: var(--mid);
    opacity: 0.6;
}

/* === Sponsor QR Codes === */
.sponsor-qrcodes {
    display: flex;
    gap: 2.5rem;
    justify-content: center;
    flex-wrap: wrap;
    margin: 2rem 0;
}

.sponsor-qr {
    text-align: center;
}

.sponsor-qr .qr-svg {
    width: 180px;
    height: 180px;
    border-radius: 6px;
    border: 1px dashed var(--line);
    padding: 4px;
    background: transparent;
    color: var(--text);
    transition: border-color 0.3s ease, color 0.3s ease;
}

.sponsor-label {
    display: block;
    margin-top: 0.6rem;
    color: var(--mid);
    font-size: 0.9rem;
}

/* === Pagination === */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1.5rem;
    padding: 2.5rem 0 1rem;
    margin-top: 2rem;
    border-top: 1px solid var(--line);
    transition: border-color 0.3s ease;
}

.page-link {
    font-family: var(--font-mono);
    font-size: 0.82rem;
    letter-spacing: 0.04em;
    color: var(--mid);
    padding: 0.4em 0.9em;
    border: 1px solid transparent;
    border-radius: 6px;
    transition:
        color 0.2s ease,
        border-color 0.2s ease,
        background-color 0.2s ease;
}

.page-link:hover {
    color: var(--accent);
    border-color: var(--accent);
}

.page-link.disabled {
    opacity: 0.3;
    cursor: default;
}

.page-link.disabled:hover {
    color: var(--mid);
    border-color: transparent;
}

.page-info {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--mid);
    letter-spacing: 0.04em;
}

/* === Archive tag filter controls === */
/* `.archive-tag` 按钮样式与 .tl-tag / .tl-toggle-hidden 共用，定义见 main.css */
.archive-controls {
    margin-bottom: 1.5rem;
}

.archive-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

/* Hide filtered items and empty year sections */
.post-item.archive-filtered {
    display: none;
}

.archive-year.archive-year-empty {
    display: none;
}

/* === Mobile: code copy button always visible on touch screens (≤720px) ===
   `:hover` doesn't persist on touch — make the copy button always visible
   so mobile users can actually access it. */
@media (max-width: 720px) {
    .code-copy { opacity: 1; }
}

/* === Very small screens (≤480px): stack post-nav vertically === */
@media (max-width: 480px) {
    .post-nav {
        flex-direction: column;
        gap: 0.6rem;
    }
    .post-nav-link {
        justify-content: center;
        text-align: center;
    }
}

/* === Reduced motion: disable year badge breathing animation === */
@media (prefers-reduced-motion: reduce) {
    [data-scene="night"] .year-label-num {
        animation: none;
    }
}
