/* ========================================
   Article Detail Page - scoped article styles
   ======================================== */

.reading-progress {
    position: fixed;
    top: 0;
    left: 0;
    width: 0;
    height: 3px;
    background: var(--primary-color);
    z-index: 1001;
    transition: width 0.1s linear;
}

/* The reference article uses a solid white content card over the page backdrop. */
.article-main {
    padding: 40px;
    margin-bottom: var(--spacing-lg);
    background: rgba(255, 255, 255, 0.94);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
}

.article-main:hover {
    background: rgba(255, 255, 255, 0.97);
}

.article-main .article-header {
    padding-bottom: 22px;
    margin-bottom: 30px;
    border-bottom: 1px solid var(--border-light);
    text-align: center;
}

.article-main .article-title {
    margin: 0 0 14px;
    color: var(--text-primary);
    font-size: 30px;
    font-weight: 700;
    line-height: 1.45;
}

.article-main .article-info {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 6px 14px;
    color: #858585;
    font-size: 13px;
}

.article-main .info-item {
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.article-main .info-item svg {
    width: 13px;
    height: 13px;
}

.article-main .info-item a {
    color: var(--primary-color);
}

.article-main .info-item a:hover {
    text-decoration: underline;
}

.article-main .article-body {
    color: #333;
    font-size: 15px;
    line-height: 2;
    overflow-wrap: break-word;
}

.article-main .article-body p {
    margin: 0 0 18px;
}

.article-main .article-body h2,
.article-main .article-body h3 {
    color: #2f2f2f;
    font-weight: 600;
    line-height: 1.5;
    scroll-margin-top: calc(var(--header-height) + 24px);
}

.article-main .article-body h2 {
    position: relative;
    margin: 34px 0 18px;
    padding: 0 0 9px 15px;
    border-bottom: 1px solid #e8e8e8;
    font-size: 23px;
}

.article-main .article-body h2::before {
    position: absolute;
    top: 7px;
    bottom: 14px;
    left: 0;
    width: 4px;
    border-radius: 2px;
    background: var(--primary-color);
    content: '';
}

.article-main .article-body h3 {
    margin: 28px 0 14px;
    font-size: 19px;
}

.article-main .article-body strong {
    color: var(--primary-dark);
    font-weight: 600;
}

.article-main .article-body a {
    color: var(--primary-color);
    border-bottom: 1px dashed var(--primary-color);
}

.article-main .article-body a:hover {
    color: var(--primary-dark);
    border-bottom-style: solid;
}

.article-main .article-body ul,
.article-main .article-body ol {
    margin: 0 0 18px;
    padding-left: 28px;
}

.article-main .article-body ul {
    list-style: disc;
}

.article-main .article-body ol {
    list-style: decimal;
}

.article-main .article-body li {
    margin: 5px 0;
}

.article-main .article-body pre {
    position: relative;
    margin: 20px 0;
    padding: 38px 20px 18px;
    overflow-x: auto;
    border-radius: 7px;
    background: #282c34;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.12);
}

/* macOS 风格左上红黄绿三色圆点 */
.article-main .article-body pre::before {
    position: absolute;
    top: 13px;
    left: 16px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #fc625d;
    box-shadow: 18px 0 #fdbc40, 36px 0 #35cd4b;
    content: '';
    z-index: 1;
}

/* 代码块外壳：圆角、阴影 —— 配色交由 hljs atom-one-dark 主题 */
.article-main .article-body pre code {
    padding: 0;
    background: none;
    white-space: pre-wrap;
}

/* 覆盖 hljs 主题自带的底纹，与 pre 背景融合 */
.article-main .article-body .hljs {
    background: transparent;
}

.copy-code-btn {
    position: absolute;
    top: 8px;
    right: 10px;
    z-index: 1;
    padding: 4px 9px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.1);
    color: #abb2bf;
    font-size: 12px;
}

.copy-code-btn:hover {
    background: var(--primary-color);
    color: #fff;
}

.article-main .article-body blockquote {
    margin: 20px 0;
    padding: 14px 20px;
    border-left: 4px solid var(--primary-color);
    border-radius: 0 5px 5px 0;
    background: var(--primary-bg);
    color: var(--text-secondary);
}

.article-main .article-body blockquote p {
    margin: 0;
}

.article-main .article-image {
    margin: 24px 0;
    text-align: center;
}

.article-main .article-body img {
    max-width: 100%;
    height: auto;
    margin: 24px auto;
    border-radius: 6px;
    box-shadow: var(--shadow-sm);
    cursor: zoom-in;
}

.article-main .article-image img,
.article-main .article-image-grid img {
    margin-top: 0;
    margin-bottom: 0;
}

.article-main .article-image img {
    margin: 0 auto;
}

.article-main .image-caption {
    margin: 9px 0 0;
    color: var(--text-muted);
    font-size: 13px;
}

.article-main .article-image-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
    margin: 24px 0;
}

.article-main .article-image-grid img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform var(--transition-normal);
}

.article-main .article-image-grid img:hover {
    transform: scale(1.02);
}

.article-main .article-tip {
    margin: 22px 0;
    padding: 17px 20px;
    border: 1px solid #cfe4c6;
    border-radius: 6px;
    background: var(--primary-bg);
}

.article-main .article-tip p {
    margin-bottom: 6px;
}

.article-main .article-tip p:last-child {
    margin-bottom: 0;
}

.article-main .article-footer-section {
    margin-top: 36px;
    padding-top: 0;
    border-top: 0;
}

.article-main .article-copyright {
    position: relative;
    margin-bottom: 13px;
    padding: 12px 16px;
    border: 1px solid #e1e1e1;
    border-radius: 6px;
    color: var(--text-secondary);
    font-size: 13px;
    line-height: 1.9;
}

.article-main .article-copyright::before {
    position: absolute;
    top: 8px;
    right: 13px;
    color: var(--primary-color);
    content: '©';
    font-size: 18px;
    font-weight: 600;
}

.article-main .copyright-label {
    color: var(--primary-color);
    font-weight: 600;
}

.article-main .article-copyright a,
.article-main .article-source a {
    color: var(--primary-color);
    text-decoration: underline;
    overflow-wrap: anywhere;
}

.article-main .article-tags {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin: 0 0 20px;
}

.article-main .tags-label {
    color: var(--text-muted);
    font-size: 12px;
}

.article-main .article-tags .tag-item {
    border: 1px solid var(--primary-color);
    background: transparent;
    color: var(--primary-color);
}

.article-main .article-tags .tag-item:hover {
    background: var(--primary-color);
    color: #fff;
}

.article-main .article-author {
    display: flex;
    align-items: center;
    gap: 13px;
    padding: 15px;
    border-radius: 6px;
    background: #f7f8f7;
}

.article-main .author-avatar-small {
    width: 48px;
    height: 48px;
    flex: none;
    border-radius: 50%;
    object-fit: cover;
}

.article-main .author-info {
    display: flex;
    min-width: 0;
    flex-direction: column;
}

.article-main .author-name-small {
    color: var(--text-primary);
    font-weight: 600;
}

.article-main .article-source {
    color: var(--text-muted);
    font-size: 12px;
}

/* Keep the TOC in view while the detail sidebar spans the full article height. */
.page-detail .main-wrapper > .sidebar {
    position: static;
    height: auto;
    align-self: stretch;
}

.sidebar .toc-sticky-layout {
    position: sticky;
    top: calc(var(--header-height) + 18px);
    z-index: 2;
    max-height: calc(100vh - var(--header-height) - 36px);
    overflow-y: hidden;
}

.sidebar .toc-widget {
    position: relative;
    background: rgba(255, 255, 255, 0.96);
}

.sidebar .toc-heading {
    justify-content: space-between;
}

.sidebar .toc-heading::before {
    flex: none;
}

.sidebar .toc-heading > span:first-of-type {
    margin-right: auto;
}

.sidebar .toc-percentage {
    color: #a0a0a0;
    font-size: 17px;
    font-style: italic;
    font-weight: 400;
}

.sidebar .toc-content {
    max-height: 360px;
    padding: 11px 12px 14px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: #c9d8c2 transparent;
}

.sidebar .toc-list,
.sidebar .toc-list ol {
    margin: 0;
    padding: 0;
    list-style: none;
}

.sidebar .toc-list ol {
    margin-left: 14px;
    padding-left: 10px;
    border-left: 1px solid #d7d7d7;
}

.sidebar .toc-item {
    margin: 2px 0;
}

.sidebar .toc-link {
    display: flex;
    gap: 7px;
    margin: 3px 0;
    padding: 4px 8px;
    border-radius: 6px;
    color: #666;
    font-size: 13px;
    line-height: 1.55;
}

.sidebar .toc-level-3 > .toc-link {
    color: #7a7a7a;
    font-size: 12px;
}

.sidebar .toc-number {
    flex: none;
    color: #999;
}

.sidebar .toc-text {
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar .toc-link:hover {
    color: var(--primary-color);
    background: var(--primary-bg);
}

.sidebar .toc-link.active {
    background: var(--primary-color);
    color: #fff;
}

.sidebar .toc-link.active .toc-number {
    color: rgba(255, 255, 255, 0.8);
}

.image-zoom-overlay {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.9);
    cursor: zoom-out;
}

.image-zoom-overlay img {
    max-width: 90%;
    max-height: 90%;
    border-radius: 6px;
    object-fit: contain;
}

.post-navigation {
    display: grid;
    grid-template-columns: 1fr 1fr;
    margin-bottom: var(--spacing-lg);
    overflow: hidden;
    border-radius: 7px;
    background: rgba(255, 255, 255, 0.9);
    box-shadow: var(--shadow-sm);
}

.post-nav-item {
    min-height: 100px;
    padding: 20px 24px;
    background: rgba(255, 255, 255, 0.8);
}

.post-nav-item + .post-nav-item {
    border-left: 1px solid var(--border-light);
}

.post-nav-next {
    text-align: right;
}

.nav-label {
    display: block;
    margin-bottom: 5px;
    color: var(--text-muted);
    font-size: 12px;
}

.nav-title {
    display: -webkit-box;
    overflow: hidden;
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 500;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
}

.post-nav-item:hover {
    background: var(--primary-bg);
}

.post-nav-item:hover .nav-title {
    color: var(--primary-color);
}

.related-articles {
    padding: 24px;
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.92);
    box-shadow: var(--shadow-sm);
}

.related-articles .section-title {
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--primary-lighter);
    color: var(--text-primary);
    font-size: 18px;
    font-weight: 600;
}

.related-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.related-item {
    display: flex;
    gap: 14px;
    padding: 14px;
}

.related-image {
    width: 100px;
    height: 70px;
    flex: none;
    overflow: hidden;
    border-radius: 5px;
}

.related-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform var(--transition-normal);
}

.related-item:hover .related-image img {
    transform: scale(1.05);
}

.related-content {
    min-width: 0;
}

.related-date {
    color: var(--text-muted);
    font-size: 12px;
}

.related-content h3 {
    display: -webkit-box;
    margin-top: 4px;
    overflow: hidden;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    line-height: 1.45;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
}

.related-item:hover h3 {
    color: var(--primary-color);
}

@media (max-width: 1199px) {
    .article-main {
        padding: 30px;
    }

    .article-main .article-title {
        font-size: 26px;
    }

    .article-main .article-image-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 991px) {
    .article-main {
        padding: 26px;
    }

    .sidebar .toc-sticky-layout {
        position: static;
        max-height: none;
        overflow: visible;
    }

    .sidebar .toc-widget {
        display: none;
    }

    .post-navigation {
        grid-template-columns: 1fr;
    }

    .post-nav-item + .post-nav-item {
        border-top: 1px solid var(--border-light);
        border-left: 0;
    }

    .related-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 767px) {
    .article-main {
        padding: 20px 18px;
    }

    .article-main .article-header {
        margin-bottom: 24px;
    }

    .article-main .article-title {
        font-size: 21px;
    }

    .article-main .article-info {
        gap: 5px 10px;
        font-size: 12px;
    }

    .article-main .article-body {
        font-size: 14px;
        line-height: 1.9;
    }

    .article-main .article-body h2 {
        margin-top: 29px;
        font-size: 19px;
    }

    .article-main .article-body h3 {
        font-size: 17px;
    }

    .article-main .article-image-grid {
        grid-template-columns: 1fr;
    }

    .article-main .article-author {
        align-items: flex-start;
    }
}

@media (max-width: 479px) {
    .article-main {
        padding: 18px 14px;
    }

    .article-main .article-title {
        font-size: 19px;
    }

    .article-main .article-body pre {
        margin-right: -5px;
        margin-left: -5px;
        padding-right: 14px;
        padding-left: 14px;
    }

    .article-main .article-copyright {
        padding-right: 32px;
    }

    .article-main .article-author {
        flex-direction: column;
    }

    .post-nav-item {
        min-height: 0;
        padding: 17px;
    }

    .related-item {
        flex-direction: column;
    }

    .related-image {
        width: 100%;
        height: 130px;
    }
}

/* ========================================
   Article Page Effects
   ======================================== */

/* 文章标题渐入 + 装饰下划线 */
.article-main .article-header {
    animation: fadeInUp 0.6s ease-out both;
}

.article-main .article-title {
    position: relative;
    display: inline-block;
}

.article-main .article-title::after {
    content: '';
    display: block;
    margin: 10px auto 0;
    width: 0;
    height: 3px;
    border-radius: 2px;
    background: linear-gradient(90deg, var(--primary-color), #8fc972);
    animation: titleUnderline 0.8s 0.3s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

@keyframes titleUnderline {
    to { width: 72px; }
}

/* 段落首个标题滑入 */
.article-main .article-body > p:first-of-type {
    animation: fadeInUp 0.6s 0.15s ease-out both;
}

/* 代码块悬浮 */
.article-main .article-body pre {
    transition: box-shadow var(--transition-normal), transform var(--transition-normal);
}

.article-main .article-body pre:hover {
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.14);
}

/* 相关文章 / 上一篇下一篇悬浮 */
.post-nav-item,
.related-item {
    transition: transform var(--transition-normal), box-shadow var(--transition-normal);
}

.post-nav-item:hover,
.related-item:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-md);
}
