/* ============================================
   News & Article Styles — Substack / Markdown feel
   ============================================ */

/* ----- News Index Page ----- */
.scroll-container {
    overflow-x: clip;
    overflow-y: visible;
}

@supports not (overflow-x: clip) {
    .scroll-container {
        overflow-x: visible;
    }
}

.news-page {
    max-width: 1100px;
    margin: 0 auto;
    padding: 2.5rem var(--page-gutter) 4rem;
}

.news-header {
    text-align: center;
    margin-bottom: 2.5rem;
    padding-top: 1.5rem;
}

.news-label {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: #1a8917;
    font-weight: 600;
    margin: 0 0 0.5rem;
}

.news-title {
    font-size: 2.75rem;
    font-weight: 700;
    color: #1a1a1a;
    margin: 0 0 0.6rem;
    letter-spacing: -0.03em;
    line-height: 1.15;
}

.news-subtitle {
    font-size: 1.2rem;
    color: #59616a;
    margin: 0;
    font-weight: 400;
    line-height: 1.5;
}

.news-divider {
    height: 1px;
    background: #e6e6e6;
    margin-bottom: 2.5rem;
}

/* Featured (first) article */
.featured-card {
    display: flex;
    flex-direction: row;
    text-decoration: none;
    color: inherit;
    border-radius: 12px;
    background: #fff;
    overflow: hidden;
    margin-bottom: 3rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 6px 16px rgba(0, 0, 0, 0.04);
    transition: box-shadow 0.25s ease, transform 0.25s ease;
}

.featured-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08), 0 12px 28px rgba(0, 0, 0, 0.07);
    transform: translateY(-2px);
}

.featured-image {
    flex: 0 0 50%;
    max-width: 50%;
    overflow: hidden;
}

.featured-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.4s ease;
}

.featured-card:hover .featured-image img {
    transform: scale(1.03);
}

.featured-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 2rem 2.25rem;
}

.featured-title {
    font-size: 1.65rem;
    font-weight: 700;
    color: #1a1a1a;
    margin: 0 0 0.75rem;
    line-height: 1.3;
    letter-spacing: -0.015em;
}

.featured-description {
    font-size: 1.05rem;
    color: #555;
    line-height: 1.65;
    margin: 0 0 1rem;
}

.read-more {
    font-size: 0.9rem;
    font-weight: 600;
    color: #1a8917;
    margin-top: auto;
}

/* Article grid */
.article-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr));
    gap: 1.75rem;
}

.article-card {
    display: flex;
    flex-direction: column;
    text-decoration: none;
    color: inherit;
    background: #fff;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04), 0 4px 12px rgba(0, 0, 0, 0.03);
    transition: box-shadow 0.25s ease, transform 0.25s ease;
}

.article-card:hover {
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.07), 0 8px 20px rgba(0, 0, 0, 0.06);
    transform: translateY(-2px);
}

.article-card-image {
    overflow: hidden;
}

.article-card-image img {
    width: 100%;
    height: 190px;
    object-fit: cover;
    display: block;
    transition: transform 0.4s ease;
}

.article-card:hover .article-card-image img {
    transform: scale(1.03);
}

.article-card-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 1.25rem 1.5rem 1.5rem;
}

.article-card-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: #1a1a1a;
    margin: 0 0 0.5rem;
    line-height: 1.35;
    letter-spacing: -0.01em;
}

.article-card-description {
    font-size: 0.95rem;
    color: #6b6b6b;
    line-height: 1.6;
    margin: 0 0 0.75rem;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Shared metadata style */
.article-meta {
    display: flex;
    align-items: center;
    gap: 0.35rem 0.75rem;
    flex-wrap: wrap;
    font-size: 0.875rem;
    color: #64748b;
    margin-top: auto;
}

.meta-author {
    font-weight: 600;
    color: #555;
}

.meta-date::before {
    content: "·";
    margin-right: 0.75rem;
}

/* ----- Article Page ----- */
.article-layout {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 var(--page-gutter);
    gap: 3rem;
}

.article-page {
    max-width: 720px;
    min-width: 0;
    width: 100%;
    padding: 2rem 0 4rem;
}

.article-header {
    margin-bottom: 2rem;
    padding-top: 0.5rem;
}

.article-header .back-to-news {
    display: inline-block;
    margin-bottom: 1.5rem;
}

.article-page-title {
    font-size: 2.5rem;
    font-weight: 800;
    color: #1a1a1a;
    line-height: 1.2;
    letter-spacing: -0.03em;
    margin: 0 0 1rem;
}

.article-hero-image {
    margin-bottom: 2.25rem;
    border-radius: 10px;
    overflow: hidden;
}

.article-hero-image img {
    width: 100%;
    height: auto;
    display: block;
    border-radius: 10px;
}

/* Article body — Substack-quality typography */
.article-body {
    font-size: 1.15rem;
    line-height: 1.85;
    color: #292929;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.article-body h1,
.article-body h2 {
    font-size: 1.55rem;
    font-weight: 700;
    color: #1a1a1a;
    margin: 2.5rem 0 0.75rem;
    line-height: 1.3;
    letter-spacing: -0.02em;
    padding-bottom: 0.3rem;
    border-bottom: 1px solid #f0f0f0;
}

.article-body h3 {
    font-size: 1.3rem;
    font-weight: 700;
    color: #1a1a1a;
    margin: 2rem 0 0.6rem;
    line-height: 1.35;
    letter-spacing: -0.01em;
}

.article-body h4 {
    font-size: 1.1rem;
    font-weight: 600;
    color: #333;
    margin: 1.5rem 0 0.5rem;
    line-height: 1.4;
}

.article-body p {
    margin: 0 0 1.5rem;
}

.article-body ul,
.article-body ol {
    margin: 0 0 1.5rem;
    padding-left: 1.5rem;
}

.article-body li {
    margin-bottom: 0.6rem;
}

.article-body strong {
    color: #1a1a1a;
    font-weight: 700;
}

.article-body blockquote {
    border-left: 3px solid #1a8917;
    margin: 1.75rem 0;
    padding: 0.4rem 0 0.4rem 1.5rem;
    color: #555;
    font-style: italic;
    font-size: 1.1rem;
    line-height: 1.7;
    background: #f9faf8;
    border-radius: 0 6px 6px 0;
}

.article-body code {
    background: #f4f4f5;
    padding: 0.2rem 0.45rem;
    border-radius: 4px;
    font-size: 0.9em;
    font-family: 'SFMono-Regular', 'Menlo', 'Monaco', 'Consolas', monospace;
    color: #d63384;
}

.article-body pre {
    background: #1e1e2e;
    color: #cdd6f4;
    padding: 1.25rem 1.5rem;
    border-radius: 8px;
    overflow-x: auto;
    margin: 1.5rem 0;
    font-size: 0.9rem;
    line-height: 1.6;
}

.article-body pre code {
    background: none;
    padding: 0;
    border-radius: 0;
    font-size: inherit;
    color: inherit;
}

.article-body a {
    color: #1a8917;
    text-decoration: underline;
    text-underline-offset: 2px;
    text-decoration-thickness: 1px;
}

.article-body a:hover {
    color: #0f6d0f;
    text-decoration-thickness: 2px;
}

.article-body hr {
    border: none;
    height: 1px;
    background: #e6e6e6;
    margin: 2.5rem 0;
}

.article-body img {
    border-radius: 8px;
    margin: 1.5rem 0;
}

.article-footer {
    margin-top: 3rem;
    padding-top: 1.5rem;
    border-top: 1px solid #e6e6e6;
}

.back-to-news {
    font-size: 0.95rem;
    color: #1a8917;
    text-decoration: none;
    font-weight: 600;
    transition: color 0.15s;
}

.back-to-news:hover {
    color: #0f6d0f;
    text-decoration: underline;
}

/* ----- TOC Sidebar ----- */
.toc-sidebar {
    flex: 0 0 220px;
    max-width: 220px;
    padding-top: 2rem;
    align-self: flex-start;
    position: sticky;
    top: calc(var(--nav-height, 64px) + 2rem);
    max-height: calc(100vh - var(--nav-height, 64px) - 3rem);
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
}

.toc-sticky {
    padding-right: 0.35rem;
}

.toc-heading {
    font-size: 0.875rem;
    text-transform: none;
    letter-spacing: normal;
    color: #64748b;
    font-weight: 700;
    margin: 0 0 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid #e6e6e6;
    cursor: default;
}

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

.toc-nav ul ul {
    padding-left: 0.85rem;
}

.toc-nav li {
    margin-bottom: 0.15rem;
}

.toc-nav a {
    display: block;
    font-size: 0.875rem;
    color: #59616a;
    line-height: 1.4;
    padding: 0.2rem 0 0.2rem 0.65rem;
    text-decoration: none;
    border-left: 2px solid transparent;
    transition: color 0.15s, border-color 0.15s, background-color 0.15s;
}

.toc-nav a:hover {
    color: #1a1a1a;
}

.toc-nav a.toc-active {
    color: #1a8917;
    border-left-color: #1a8917;
    font-weight: 600;
    background: rgba(26, 137, 23, 0.07);
}

/* ----- Legacy card styles (kept for backward compatibility) ----- */
.card-container {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 1.5rem;
    margin: 2rem 0;
}

.card {
    background-color: #ffffff;
    border: 1px solid #e0e0e0;
    border-radius: 10px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    transition: transform 0.2s, box-shadow 0.2s;
    width: 100%;
    max-width: 450px;
    display: flex;
    flex-direction: column;
}

.card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
}

.card-image {
    width: 100%;
    height: 180px;
    object-fit: cover;
}

.card-content {
    padding: 1rem;
    flex: 1;
}

.card-title {
    font-size: 1.25rem;
    margin-bottom: 0.5rem;
    color: #333;
}

.card-description {
    font-size: 1rem;
    color: #666;
    margin-bottom: 1rem;
}

.card-link {
    align-self: flex-start;
    text-decoration: none;
    font-weight: bold;
    color: #fff;
    background-color: #007BFF;
    padding: 0.5rem 1rem;
    border-radius: 5px;
    transition: background-color 0.2s;
}

.card-link:hover {
    background-color: #0056b3;
}

/* Legacy article class */
.article {
    font-size: 18px;
    line-height: 1.6;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.blog-meta {
    background: linear-gradient(135deg, rgba(0, 123, 255, 0.1), rgba(0, 150, 136, 0.1));
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 2rem;
}

.blog-meta dl {
    display: grid;
    gap: 1rem;
}

.blog-meta dt {
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #0d47a1;
}

.blog-meta dd {
    margin: 0;
    font-size: 1rem;
    color: #37474f;
}

.article h1,
.article h2,
.article h3,
.article p {
    margin: 0 0 1em;
}

/* ----- Responsive ----- */
@media (max-width: 960px) {
    .toc-sidebar {
        display: block;
        flex: none;
        width: 100%;
        max-width: 720px;
        order: -1;
        position: sticky;
        top: var(--nav-height, 64px);
        z-index: 10;
        padding-top: 0.75rem;
        margin: 0 auto 1.5rem;
        background: rgba(255, 255, 255, 0.96);
        backdrop-filter: blur(10px);
        border-bottom: 1px solid #e6e6e6;
    }

    .article-layout {
        flex-direction: column;
        align-items: center;
        padding: 0 var(--page-gutter);
        gap: 0;
    }

    .toc-sticky {
        position: static;
        max-height: none;
        overflow: visible;
        padding-right: 0;
    }

    .toc-heading {
        cursor: pointer;
        user-select: none;
        padding: 0.75rem 0;
        margin: 0;
    }

    .toc-heading::after {
        content: " ▸";
        font-size: 0.7rem;
    }

    .toc-nav {
        display: none;
    }

    .toc-open .toc-nav {
        display: block;
        max-height: min(60vh, 600px);
        overflow-y: auto;
        padding-bottom: 0.75rem;
    }

    .toc-open .toc-heading::after {
        content: " ▾";
    }
}

@media (max-width: 768px) {
    .news-title {
        font-size: 2rem;
    }

    .news-subtitle {
        font-size: 1rem;
    }

    .featured-card {
        flex-direction: column;
    }

    .featured-image {
        flex: none;
        max-width: 100%;
    }

    .featured-content {
        padding: 1.25rem 1.5rem 1.5rem;
    }

    .featured-title {
        font-size: 1.35rem;
    }

    .article-grid {
        grid-template-columns: 1fr;
        gap: 1.25rem;
    }

    .article-page-title {
        font-size: 1.875rem;
    }

    .article-body {
        font-size: 1.05rem;
    }

    .article-layout {
        padding: 0 var(--page-gutter);
    }

    .article {
        font-size: 16px;
    }

    .card-container {
        gap: 1rem;
        margin: 1rem 0;
    }

    .card {
        margin: 0 0.5rem;
    }

    .card-image {
        height: 150px;
    }

    .toc-sidebar {
        max-width: 100%;
    }
}

/* A native button on small screens; a simple label beside the desktop article. */
.toc-toggle { display: none; width: 100%; border: 0; border-bottom: 1px solid #e6e6e6; background: transparent; text-align: left; color: #475569; }
.article-card .article-meta { flex-direction: column; align-items: flex-start; gap: .25rem; }
.article-card .meta-date::before { content: none; }
@media (max-width: 600px) {
    .article-meta { flex-direction: column; align-items: flex-start; gap: .25rem; }
    .meta-date::before { content: none; }
}
@media (max-width: 960px) {
    .toc-heading-desktop { display: none; }
    .toc-toggle { display: block; min-height: 44px; }
    .toc-nav a { min-height: 44px; padding: .65rem .75rem; }
    .article-body :is(h2, h3, h4) { scroll-margin-top: 4rem; }
}
