/* ==========================================================================
   hybrismart — Modern Blog Design

   Typography best practices applied:
   - Body text: 19px / 1.7 line-height for optimal readability
   - Max content width: 680px (~65-70 characters per line)
   - Serif body font (Source Serif 4) for long-form reading
   - Sans-serif headings (Inter) for contrast and scannability
   - Monospace code (JetBrains Mono) for technical content
   - Generous vertical rhythm with consistent spacing
   - High contrast: #1a1a2e on #ffffff
   - Responsive scaling for all breakpoints
   ========================================================================== */

/* ---------- Reset & Base ---------- */

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

html {
    font-size: 100%; /* 16px base */
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body {
    font-family: 'Source Serif 4', Georgia, 'Times New Roman', serif;
    font-size: 1.1875rem;  /* 19px — sweet spot for long-form reading */
    line-height: 1.7;
    color: #1a1a2e;
    background: #ffffff;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    font-feature-settings: 'kern' 1, 'liga' 1;
}

/* ---------- Lightbox ---------- */

.lightbox {
    position: fixed;
    inset: 0;
    z-index: 300;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: zoom-out;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s, visibility 0.2s;
    -webkit-tap-highlight-color: transparent;
}

.lightbox.active {
    opacity: 1;
    visibility: visible;
}

.lightbox-img {
    max-width: 94vw;
    max-height: 94vh;
    object-fit: contain;
    border-radius: 4px;
    touch-action: none;
    transform-origin: center center;
    transition: transform 0.15s ease;
}

.lightbox.active .lightbox-img {
    animation: lightbox-in 0.25s ease;
}

@keyframes lightbox-in {
    from { transform: scale(0.92); opacity: 0; }
    to   { transform: scale(1);    opacity: 1; }
}

/* ---------- Reading Progress Bar ---------- */

.reading-progress {
    position: fixed;
    top: 0;
    left: 0;
    width: 0;
    height: 3px;
    background: linear-gradient(90deg, #4f46e5, #7c3aed);
    z-index: 1000;
    transition: width 0.1s linear;
}

/* ---------- Site Header ---------- */

.site-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.header-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 2rem;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.site-logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
    color: #1a1a2e;
}

.logo-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: #1a1a2e;
    color: #fff;
    border-radius: 8px;
    font-family: 'Inter', sans-serif;
    font-weight: 700;
    font-size: 1.125rem;
}

.logo-text {
    font-family: 'Inter', sans-serif;
    font-weight: 700;
    font-size: 1.125rem;
    letter-spacing: -0.02em;
}

.header-search {
    display: none; /* temporarily hidden */
    align-items: center;
}

.search-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    background: #f8fafc;
    color: #94a3b8;
    cursor: pointer;
    transition: all 0.15s;
}

.search-toggle:hover {
    background: #f1f5f9;
    color: #64748b;
    border-color: #cbd5e1;
}

.site-nav {
    display: flex;
    gap: 2rem;
}

.site-nav a {
    font-family: 'Inter', sans-serif;
    font-size: 0.9375rem;
    font-weight: 500;
    color: #64748b;
    text-decoration: none;
    transition: color 0.15s;
}

.site-nav a:hover {
    color: #1a1a2e;
}

/* ---------- Search Overlay ---------- */

.search-overlay {
    position: fixed;
    inset: 0;
    z-index: 200;
    background: rgba(15, 23, 42, 0.5);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: min(20vh, 160px);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s, visibility 0.2s;
}

.search-overlay.active {
    opacity: 1;
    visibility: visible;
}

.search-overlay-inner {
    width: 100%;
    max-width: 600px;
    margin: 0 1.5rem;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.2), 0 0 0 1px rgba(0, 0, 0, 0.05);
    overflow: hidden;
    transform: scale(0.97) translateY(-8px);
    transition: transform 0.2s;
}

.search-overlay.active .search-overlay-inner {
    transform: scale(1) translateY(0);
}

.search-form {
    display: flex;
    align-items: center;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid #e2e8f0;
    gap: 0.75rem;
}

.search-form-icon {
    flex-shrink: 0;
    color: #94a3b8;
}

.search-input {
    flex: 1;
    border: none;
    outline: none;
    font-family: 'Inter', sans-serif;
    font-size: 1.0625rem;
    color: #1a1a2e;
    background: transparent;
}

.search-input::placeholder {
    color: #94a3b8;
}

.search-kbd {
    font-family: 'Inter', sans-serif;
    font-size: 0.6875rem;
    font-weight: 500;
    color: #94a3b8;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    border-radius: 4px;
    padding: 0.125rem 0.375rem;
    line-height: 1.4;
    flex-shrink: 0;
}

.search-results {
    padding: 1rem 1.25rem;
    max-height: 400px;
    overflow-y: auto;
}

.search-hint {
    font-family: 'Inter', sans-serif;
    font-size: 0.875rem;
    color: #94a3b8;
    text-align: center;
    padding: 1.5rem 0;
}

/* ---------- Avatar Fallback ---------- */

.avatar-fallback {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: #fff;
    font-family: 'Inter', sans-serif;
    font-weight: 600;
    font-size: 0.75em;
    border-radius: 50%;
    flex-shrink: 0;
}

.author-avatar.avatar-fallback { width: 44px; height: 44px; font-size: 1rem; }
.author-bio-avatar.avatar-fallback { width: 64px; height: 64px; font-size: 1.25rem; }
.card-author-avatar.avatar-fallback { width: 32px; height: 32px; font-size: 0.75rem; }

/* ---------- Search Results ---------- */

.search-result {
    display: block;
    padding: 0.875rem 0;
    border-bottom: 1px solid #f1f5f9;
    text-decoration: none;
    color: inherit;
    transition: background 0.1s;
}

.search-result:last-child {
    border-bottom: none;
}

.search-result:hover {
    background: #f8fafc;
    margin: 0 -1.25rem;
    padding-left: 1.25rem;
    padding-right: 1.25rem;
    border-radius: 8px;
}

.search-result-title {
    font-family: 'Inter', sans-serif;
    font-size: 0.9375rem;
    font-weight: 600;
    color: #1e293b;
    margin-bottom: 0.25rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.search-result-meta {
    font-family: 'Inter', sans-serif;
    font-size: 0.75rem;
    color: #94a3b8;
    margin-bottom: 0.25rem;
}

.search-result-excerpt {
    font-family: 'Inter', sans-serif;
    font-size: 0.8125rem;
    color: #64748b;
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.search-badge {
    font-size: 0.625rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 0.125rem 0.375rem;
    border-radius: 3px;
    flex-shrink: 0;
}

.search-badge.semantic {
    background: #ede9fe;
    color: #7c3aed;
}

.search-badge.both {
    background: #dbeafe;
    color: #2563eb;
}

/* ---------- Article Header ---------- */

.article-header {
    padding: 4rem 2rem 2.5rem;
}

.article-header-inner {
    max-width: 680px;
    margin: 0 auto;
}

.article-meta-top {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    font-family: 'Inter', sans-serif;
    font-size: 0.875rem;
    font-weight: 500;
    color: #64748b;
    margin-bottom: 1.25rem;
}

.article-category {
    color: #4f46e5;
    text-decoration: none;
    font-weight: 600;
}

.article-category:hover {
    color: #3730a3;
}

.article-meta-sep {
    color: #cbd5e1;
}

.article-title {
    font-family: 'Inter', sans-serif;
    font-size: clamp(2rem, 5vw, 2.75rem);
    font-weight: 700;
    line-height: 1.15;
    letter-spacing: -0.025em;
    color: #0f172a;
    margin-bottom: 1rem;
}

.article-subtitle {
    font-size: 1.25rem;
    line-height: 1.5;
    color: #475569;
    margin-bottom: 2rem;
}

/* Author card in header */
.article-authors {
    display: flex;
    gap: 1.5rem;
    flex-wrap: wrap;
}

.author-card {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.author-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    object-fit: cover;
}

.author-info {
    display: flex;
    flex-direction: column;
}

.author-name {
    font-family: 'Inter', sans-serif;
    font-size: 0.9375rem;
    font-weight: 600;
    color: #1a1a2e;
}

.author-role {
    font-family: 'Inter', sans-serif;
    font-size: 0.8125rem;
    color: #64748b;
}

/* ---------- Hero Image ---------- */

.article-hero-image {
    max-width: 960px;
    margin: 0 auto 3rem;
    padding: 0 2rem;
}

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

/* ---------- Table of Contents ---------- */

.toc {
    max-width: 680px;
    margin: 0 auto 3rem;
    padding: 0 2rem;
}

.toc-inner {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 1.5rem 2rem;
}

.toc-title {
    font-family: 'Inter', sans-serif;
    font-size: 0.8125rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #94a3b8;
    margin-bottom: 0.75rem;
}

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

.toc-list li {
    counter-increment: toc-counter;
    margin-bottom: 0.375rem;
}

.toc-list li::before {
    content: counter(toc-counter) ".";
    font-family: 'Inter', sans-serif;
    font-size: 0.8125rem;
    font-weight: 600;
    color: #94a3b8;
    margin-right: 0.5rem;
}

.toc-list a {
    font-family: 'Inter', sans-serif;
    font-size: 0.9375rem;
    color: #334155;
    text-decoration: none;
    transition: color 0.15s;
}

.toc-list a:hover {
    color: #4f46e5;
}

/* ---------- Article Notices (outdated, etc.) ---------- */

.article-notice {
    max-width: 680px;
    margin: 0 auto 2rem;
    padding: 0 2rem;
}

.article-notice > div,
.article-body .article-notice {
    background: linear-gradient(135deg, #fef3c7, #fef9c3);
    border: 1px solid #f59e0b;
    border-left: 4px solid #f59e0b;
    border-radius: 8px;
    padding: 1rem 1.25rem;
    font-family: 'Inter', sans-serif;
    font-size: 0.9375rem;
    line-height: 1.6;
    color: #92400e;
    margin: 0;
}

.article-notice strong {
    color: #78350f;
}

.article-notice a {
    color: #b45309;
    text-decoration: underline;
}

/* Multi-column image gallery */
.image-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.image-gallery img {
    width: 100%;
    height: auto;
    border-radius: 6px;
    cursor: zoom-in;
}

@media (max-width: 480px) {
    .image-gallery {
        grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    }
}

/* ---------- Callouts (margin notes / inline) ---------- */

.callout {
    float: right;
    clear: right;
    width: 240px;
    margin: 0.25rem 0 1.5rem 2rem;
    margin-right: -280px;
    font-family: 'Inter', sans-serif;
}

.callout-inner {
    border-radius: 10px;
    padding: 1rem;
    font-size: 0.8125rem;
    line-height: 1.5;
}

/* Article cross-reference */
.callout-article {
    background: #f0f9ff;
    border: 1px solid #bae6fd;
}

.callout-label {
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 0.5rem;
    color: #94a3b8;
}

.callout-img {
    width: 100%;
    height: auto;
    border-radius: 6px;
    margin-bottom: 0.5rem;
    object-fit: contain;
    background: #f1f5f9;
}

.callout-title {
    display: block;
    font-size: 0.8125rem;
    font-weight: 600;
    color: #0f172a;
    text-decoration: none;
    line-height: 1.35;
    margin-bottom: 0.375rem;
}

.callout-title:hover {
    color: #4f46e5;
}

.callout-teaser {
    font-size: 0.75rem;
    color: #64748b;
    margin: 0;
}

/* Book promo */
.callout-book {
    background: linear-gradient(135deg, #1e1b4b, #312e81);
    border: none;
    text-align: center;
    color: #e0e7ff;
}

.callout-book .callout-label {
    color: #818cf8;
}

.callout-book-cover {
    width: 80px;
    height: auto;
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    margin: 0 auto 0.625rem;
    display: block;
}

.callout-book-title {
    font-size: 0.75rem;
    font-weight: 600;
    color: #fff;
    margin-bottom: 0.5rem;
    line-height: 1.35;
}

.callout-book-btn {
    display: inline-block;
    font-size: 0.6875rem;
    font-weight: 600;
    color: #c7d2fe;
    background: rgba(255, 255, 255, 0.1);
    padding: 0.3rem 0.75rem;
    border-radius: 6px;
    text-decoration: none;
    transition: background 0.15s, color 0.15s;
}

.callout-book-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
}

/* Responsive: when viewport is too narrow for margin, go inline */
@media (max-width: 1100px) {
    .callout {
        float: none;
        width: 100%;
        margin: 1.5rem 0;
        margin-right: 0;
    }

    .callout-inner {
        max-width: 480px;
    }

    .callout-article {
        display: flex;
        gap: 1rem;
        align-items: flex-start;
    }

    .callout-article .callout-img {
        width: 80px;
        flex-shrink: 0;
        margin-bottom: 0;
    }

    .callout-book {
        display: flex;
        gap: 1rem;
        align-items: center;
        text-align: left;
    }

    .callout-book .callout-book-cover {
        width: 56px;
        flex-shrink: 0;
        margin: 0;
    }
}

/* ---------- Article Body — Core Typography ---------- */

.article-body {
    max-width: 680px;      /* ~65-70 chars per line at 19px */
    margin: 0 auto;
    padding: 0 2rem 4rem;
}

.article-body p {
    margin-bottom: 1.5rem;
    hanging-punctuation: first last;
}

.article-body .lead {
    font-size: 1.3125rem;
    line-height: 1.65;
    color: #334155;
    margin-bottom: 2.5rem;
    padding-bottom: 2.5rem;
    border-bottom: 1px solid #e2e8f0;
}

/* Headings */
.article-body h2 {
    font-family: 'Inter', sans-serif;
    font-size: 1.625rem;
    font-weight: 700;
    line-height: 1.3;
    letter-spacing: -0.02em;
    color: #0f172a;
    margin-top: 3rem;
    margin-bottom: 1rem;
    padding-top: 1rem;
}

.article-body h3 {
    font-family: 'Inter', sans-serif;
    font-size: 1.25rem;
    font-weight: 600;
    line-height: 1.4;
    letter-spacing: -0.01em;
    color: #1e293b;
    margin-top: 2.5rem;
    margin-bottom: 0.75rem;
}

.article-body h4 {
    font-family: 'Inter', sans-serif;
    font-size: 1.0625rem;
    font-weight: 600;
    color: #1e293b;
    margin-top: 2rem;
    margin-bottom: 0.5rem;
}

/* Links */
.article-body a {
    color: #4f46e5;
    text-decoration: underline;
    text-decoration-color: rgba(79, 70, 229, 0.3);
    text-underline-offset: 2px;
    transition: text-decoration-color 0.15s;
}

.article-body a:hover {
    text-decoration-color: #4f46e5;
}

/* Strong */
.article-body strong {
    font-weight: 600;
    color: #0f172a;
}

/* Emphasis */
.article-body em {
    font-style: italic;
}

/* Lists */
.article-body ul,
.article-body ol {
    margin-bottom: 1.5rem;
    padding-left: 1.5rem;
}

.article-body li {
    margin-bottom: 0.5rem;
    padding-left: 0.25rem;
}

.article-body li::marker {
    color: #94a3b8;
}

.article-body ol li::marker {
    font-family: 'Inter', sans-serif;
    font-weight: 600;
    font-size: 0.9375rem;
    color: #94a3b8;
}

/* Inline code */
.article-body code {
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    font-size: 0.85em;
    background: #f1f5f9;
    color: #be185d;
    padding: 0.15em 0.4em;
    border-radius: 4px;
    word-break: break-word;
}

/* Code blocks */
.article-body pre {
    margin-bottom: 2rem;
    padding: 1.5rem;
    background: #0f172a;
    color: #e2e8f0;
    border-radius: 12px;
    overflow-x: auto;
    font-size: 0.875rem;
    line-height: 1.7;
    -webkit-overflow-scrolling: touch;
}

.article-body pre code {
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    background: none;
    color: inherit;
    padding: 0;
    border-radius: 0;
    font-size: inherit;
}

/* Syntax highlighting (highlight.js) — dark theme matching #0f172a bg */
.article-body pre code .hljs-keyword,
.article-body pre code .hljs-selector-tag,
.article-body pre code .hljs-built_in,
.article-body pre code .hljs-name { color: #93c5fd; }

.article-body pre code .hljs-string,
.article-body pre code .hljs-attr,
.article-body pre code .hljs-symbol,
.article-body pre code .hljs-bullet,
.article-body pre code .hljs-addition { color: #86efac; }

.article-body pre code .hljs-title,
.article-body pre code .hljs-section,
.article-body pre code .hljs-title.function_ { color: #c4b5fd; }

.article-body pre code .hljs-number,
.article-body pre code .hljs-literal { color: #fda4af; }

.article-body pre code .hljs-type,
.article-body pre code .hljs-title.class_ { color: #fcd34d; }

.article-body pre code .hljs-comment,
.article-body pre code .hljs-quote,
.article-body pre code .hljs-meta { color: #64748b; font-style: italic; }

.article-body pre code .hljs-deletion { color: #fca5a5; }

.article-body pre code .hljs-variable,
.article-body pre code .hljs-template-variable { color: #f0abfc; }

.article-body pre code .hljs-regexp,
.article-body pre code .hljs-link { color: #5eead4; }

.article-body pre code .hljs-tag { color: #94a3b8; }
.article-body pre code .hljs-tag .hljs-name { color: #93c5fd; }
.article-body pre code .hljs-tag .hljs-attr { color: #c4b5fd; }
.article-body pre code .hljs-tag .hljs-string { color: #86efac; }

.article-body pre code .hljs-emphasis { font-style: italic; }
.article-body pre code .hljs-strong { font-weight: 700; }

/* Tables */
.table-wrap {
    margin-bottom: 2rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
}

.article-body table {
    width: 100%;
    border-collapse: collapse;
    font-family: 'Inter', sans-serif;
    font-size: 0.9375rem;
    line-height: 1.5;
    margin: 0;
}

.article-body thead {
    background: #f8fafc;
}

.article-body th {
    padding: 0.875rem 1.25rem;
    font-weight: 600;
    color: #475569;
    text-align: left;
    border-bottom: 2px solid #e2e8f0;
    white-space: nowrap;
    font-size: 0.8125rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.article-body td {
    padding: 0.875rem 1.25rem;
    border-bottom: 1px solid #f1f5f9;
    color: #334155;
}

.article-body tr:last-child td {
    border-bottom: none;
}

.article-body .table-total td {
    border-top: 2px solid #e2e8f0;
    background: #f8fafc;
}

.article-body th.num,
.article-body td.num {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

/* Figures / Images */
.article-figure {
    margin: 2.5rem -2rem;
    text-align: center;
}

.article-figure img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
}

.article-figure figcaption {
    font-family: 'Inter', sans-serif;
    font-size: 0.8125rem;
    color: #94a3b8;
    margin-top: 0.75rem;
}

/* Blockquotes */
.article-body blockquote {
    margin: 2rem 0;
    padding: 0 0 0 1.5rem;
    border-left: 3px solid #4f46e5;
    color: #475569;
    font-style: italic;
}

.article-body blockquote p:last-child {
    margin-bottom: 0;
}

/* Horizontal rule */
.article-body hr {
    border: none;
    height: 1px;
    background: #e2e8f0;
    margin: 3rem 0;
}

/* ---------- Article Footer ---------- */

.article-footer {
    border-top: 1px solid #e2e8f0;
    background: #f8fafc;
}

.article-footer-inner {
    max-width: 680px;
    margin: 0 auto;
    padding: 3rem 2rem;
}

/* Author bio */
.author-bio {
    display: flex;
    gap: 1.5rem;
    margin-bottom: 3rem;
}

.author-bio-avatar {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.author-bio-text h3 {
    font-family: 'Inter', sans-serif;
    font-size: 1rem;
    font-weight: 600;
    color: #1a1a2e;
    margin-bottom: 0.375rem;
}

.author-bio-text h3 a {
    color: inherit;
    text-decoration: none;
}

.author-bio-text h3 a:hover {
    color: #4f46e5;
}

.author-bio-text p {
    font-size: 0.9375rem;
    line-height: 1.6;
    color: #64748b;
    margin-bottom: 0.75rem;
}

.author-social {
    display: flex;
    gap: 0.75rem;
}

.author-social a {
    color: #94a3b8;
    transition: color 0.15s;
}

.author-social a:hover {
    color: #4f46e5;
}

/* Article navigation */
.article-nav {
    display: flex;
    gap: 1.5rem;
    padding-top: 2rem;
    border-top: 1px solid #e2e8f0;
}

.article-nav-link {
    text-decoration: none;
    flex: 1;
}

.article-nav-label {
    display: block;
    font-family: 'Inter', sans-serif;
    font-size: 0.8125rem;
    font-weight: 500;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 0.375rem;
}

.article-nav-title {
    display: block;
    font-family: 'Inter', sans-serif;
    font-size: 1rem;
    font-weight: 600;
    color: #1e293b;
    transition: color 0.15s;
}

.article-nav-link:hover .article-nav-title {
    color: #4f46e5;
}

.article-nav-next {
    text-align: right;
}

/* ---------- Site Footer ---------- */

.site-footer {
    border-top: 1px solid #e2e8f0;
    padding: 2rem 0;
}

.footer-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 2rem;
    text-align: center;
}

.footer-copy {
    font-family: 'Inter', sans-serif;
    font-size: 0.8125rem;
    color: #94a3b8;
}

/* ==========================================================================
   Homepage
   ========================================================================== */

/* ---------- Homepage Hero ---------- */

.home-hero {
    max-width: 680px;
    margin: 0 auto;
    padding: 5rem 2rem 3rem;
    text-align: center;
}

.home-hero h1 {
    font-family: 'Inter', sans-serif;
    font-size: clamp(2rem, 5vw, 3rem);
    font-weight: 700;
    line-height: 1.15;
    letter-spacing: -0.03em;
    color: #0f172a;
    margin-bottom: 1rem;
}

.home-hero p {
    font-size: 1.25rem;
    line-height: 1.6;
    color: #64748b;
    max-width: 520px;
    margin: 0 auto;
}

/* ---------- Article Cards Grid ---------- */

.articles-section {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 2rem 5rem;
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #e2e8f0;
}

.section-title {
    font-family: 'Inter', sans-serif;
    font-size: 0.8125rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #94a3b8;
}

/* Featured article — full width */
.article-card-featured {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2.5rem;
    align-items: center;
    margin-bottom: 3rem;
    padding-bottom: 3rem;
    border-bottom: 1px solid #e2e8f0;
}

.article-card-featured .card-image {
    aspect-ratio: 16 / 7;
    overflow: hidden;
    border-radius: 12px;
}

.article-card-featured .card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

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

.article-card-featured .card-content {
    display: flex;
    flex-direction: column;
}

.card-meta {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-family: 'Inter', sans-serif;
    font-size: 0.8125rem;
    font-weight: 500;
    color: #94a3b8;
    margin-bottom: 0.75rem;
}

.card-category {
    color: #4f46e5;
    font-weight: 600;
}

.card-title {
    font-family: 'Inter', sans-serif;
    font-weight: 700;
    line-height: 1.25;
    letter-spacing: -0.02em;
    color: #0f172a;
    margin-bottom: 0.75rem;
    transition: color 0.15s;
}

.article-card-featured .card-title {
    font-size: 1.5rem;
}

.card-excerpt {
    font-size: 1rem;
    line-height: 1.6;
    color: #64748b;
    margin-bottom: 1.25rem;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.card-author {
    display: flex;
    align-items: center;
    gap: 0.625rem;
}

.card-author-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
}

.card-author-name {
    font-family: 'Inter', sans-serif;
    font-size: 0.8125rem;
    font-weight: 600;
    color: #334155;
}

.card-author-date {
    font-family: 'Inter', sans-serif;
    font-size: 0.8125rem;
    color: #94a3b8;
}

/* Link wrapper */
a.article-card-featured,
a.article-card {
    text-decoration: none;
    color: inherit;
}

a.article-card-featured:hover .card-title,
a.article-card:hover .card-title {
    color: #4f46e5;
}

/* Regular article cards — grid */
.articles-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 2.5rem 2rem;
}

.article-card {
    display: flex;
    flex-direction: column;
    text-decoration: none;
    color: inherit;
    padding-bottom: 2rem;
    border-bottom: 1px solid #e2e8f0;
}

.article-card .card-content {
    display: flex;
    flex-direction: column;
    flex: 1;
}

.article-card .card-author {
    margin-top: auto;
}

.article-card .card-image {
    aspect-ratio: 16 / 9;
    overflow: hidden;
    border-radius: 10px;
    margin-bottom: 1rem;
    background: #f1f5f9;
    display: flex;
    align-items: center;
    justify-content: center;
}

.article-card .card-image img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    transition: transform 0.3s ease;
}

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

.article-card .card-title {
    font-size: 1.125rem;
}

.article-card .card-excerpt {
    font-size: 0.9375rem;
    -webkit-line-clamp: 2;
}

/* ---------- Pagination ---------- */

.pagination {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    padding-top: 3rem;
    border-top: 1px solid #e2e8f0;
    margin-top: 1rem;
}

.pagination a,
.pagination span {
    font-family: 'Inter', sans-serif;
    font-size: 0.875rem;
    font-weight: 500;
    padding: 0.5rem 0.875rem;
    border-radius: 8px;
    text-decoration: none;
    color: #64748b;
    transition: all 0.15s;
}

.pagination a:hover {
    background: #f1f5f9;
    color: #1a1a2e;
}

.pagination .current {
    background: #1a1a2e;
    color: #fff;
}

.pagination .pag-ell {
    padding: 0.5rem 0.25rem;
    color: #94a3b8;
    cursor: default;
}

/* ==========================================================================
   Responsive
   ========================================================================== */

/* Tablet */
@media (max-width: 1024px) {
    .articles-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Tablet portrait */
@media (max-width: 768px) {
    body {
        font-size: 1.0625rem;  /* 17px on smaller screens */
    }

    .header-inner {
        height: 56px;
    }

    .article-header {
        padding: 3rem 1.5rem 2rem;
    }

    .article-body {
        padding: 0 1.5rem 3rem;
    }

    .toc {
        padding: 0 1.5rem;
    }

    .article-hero-image {
        padding: 0 1.5rem;
    }

    .article-card-featured {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }

    .articles-grid {
        grid-template-columns: 1fr;
        gap: 2.5rem;
    }

    .article-body pre {
        margin-left: -1.5rem;
        margin-right: -1.5rem;
        border-radius: 0;
        padding: 1.25rem 1.5rem;
    }

    .article-figure {
        margin-left: -1.5rem;
        margin-right: -1.5rem;
    }

    .article-figure img {
        border-radius: 0;
    }

    .table-wrap {
        margin-left: -1.5rem;
        margin-right: -1.5rem;
        border-radius: 0;
        border-left: none;
        border-right: none;
    }

    .home-hero {
        padding: 3rem 1.5rem 2rem;
    }

    .articles-section {
        padding: 0 1.5rem 3rem;
    }
}

/* Mobile */
@media (max-width: 480px) {
    body {
        font-size: 1rem;  /* 16px on mobile */
        line-height: 1.65;
    }

    .article-header {
        padding: 2rem 1.25rem 1.5rem;
    }

    .article-title {
        font-size: 1.625rem;
    }

    .article-subtitle {
        font-size: 1.0625rem;
    }

    .article-body {
        padding: 0 1.25rem 2.5rem;
    }

    .article-body h2 {
        font-size: 1.375rem;
        margin-top: 2.5rem;
    }

    .article-body h3 {
        font-size: 1.125rem;
    }

    .article-body .lead {
        font-size: 1.125rem;
    }

    .article-body pre {
        font-size: 0.8125rem;
        margin-left: -1.25rem;
        margin-right: -1.25rem;
        padding: 1rem 1.25rem;
    }

    .article-figure {
        margin-left: -1.25rem;
        margin-right: -1.25rem;
    }

    .table-wrap {
        margin-left: -1.25rem;
        margin-right: -1.25rem;
    }

    .toc {
        padding: 0 1.25rem;
        margin-bottom: 2rem;
    }

    .article-hero-image {
        padding: 0;
        margin-bottom: 2rem;
    }

    .article-hero-image img {
        border-radius: 0;
    }

    .author-bio {
        flex-direction: column;
        gap: 1rem;
    }

    .article-footer-inner {
        padding: 2rem 1.25rem;
    }

    .home-hero {
        padding: 2rem 1.25rem 1.5rem;
    }

    .articles-section {
        padding: 0 1.25rem 2.5rem;
    }

    .article-card-featured .card-title {
        font-size: 1.25rem;
    }
}

/* ==========================================================================
   All Articles Page
   ========================================================================== */

.all-articles-hero {
    max-width: 680px;
    margin: 0 auto;
    padding: 4rem 2rem 2rem;
    text-align: center;
}

.all-articles-hero h1 {
    font-family: 'Inter', sans-serif;
    font-size: clamp(2rem, 5vw, 2.75rem);
    font-weight: 700;
    line-height: 1.15;
    letter-spacing: -0.03em;
    color: #0f172a;
    margin-bottom: 0.5rem;
}

.all-articles-hero p {
    font-size: 1.125rem;
    color: #94a3b8;
    font-family: 'Inter', sans-serif;
}

.all-articles-page {
    max-width: 860px;
    margin: 0 auto;
    padding: 0 2rem 5rem;
}

/* Category navigation */
.category-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 1.25rem 0;
    margin-bottom: 2rem;
    border-bottom: 1px solid #e2e8f0;
    position: sticky;
    top: 64px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 50;
}

.category-nav-item {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    font-family: 'Inter', sans-serif;
    font-size: 0.8125rem;
    font-weight: 500;
    color: #64748b;
    text-decoration: none;
    padding: 0.375rem 0.75rem;
    border-radius: 6px;
    border: 1px solid #e2e8f0;
    transition: all 0.15s;
    white-space: nowrap;
}

.category-nav-item:hover {
    color: #1a1a2e;
    background: #f1f5f9;
    border-color: #cbd5e1;
}

.category-nav-count {
    font-size: 0.6875rem;
    font-weight: 600;
    color: #94a3b8;
    background: #f1f5f9;
    padding: 0.0625rem 0.375rem;
    border-radius: 10px;
    line-height: 1.4;
}

.category-nav-item:hover .category-nav-count {
    background: #e2e8f0;
}

/* Category sections */
.category-section {
    margin-bottom: 3rem;
    scroll-margin-top: 250px;
}

.category-section-header {
    display: flex;
    align-items: baseline;
    gap: 0.75rem;
    padding-bottom: 0.75rem;
    margin-bottom: 0.5rem;
    border-bottom: 2px solid #0f172a;
}

.category-section-header h2 {
    font-family: 'Inter', sans-serif;
    font-size: 1.25rem;
    font-weight: 700;
    color: #0f172a;
    margin: 0;
}

.category-article-count {
    font-family: 'Inter', sans-serif;
    font-size: 0.8125rem;
    color: #94a3b8;
    font-weight: 500;
}

/* Article list items */
.article-list-item {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1.5rem;
    padding: 1rem 0;
    border-bottom: 1px solid #f1f5f9;
    text-decoration: none;
    color: inherit;
    transition: background 0.1s;
}

.article-list-item:hover {
    background: #f8fafc;
    margin: 0 -1rem;
    padding-left: 1rem;
    padding-right: 1rem;
    border-radius: 8px;
}

.article-list-main {
    flex: 1;
    min-width: 0;
}

.article-list-title {
    font-family: 'Inter', sans-serif;
    font-size: 1rem;
    font-weight: 600;
    color: #1e293b;
    line-height: 1.35;
    margin: 0 0 0.25rem;
    transition: color 0.15s;
}

.article-list-item:hover .article-list-title {
    color: #4f46e5;
}

.article-list-excerpt {
    font-family: 'Inter', sans-serif;
    font-size: 0.875rem;
    color: #64748b;
    line-height: 1.5;
    margin: 0;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.article-list-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.125rem;
    flex-shrink: 0;
    font-family: 'Inter', sans-serif;
    font-size: 0.8125rem;
    color: #94a3b8;
    white-space: nowrap;
    padding-top: 0.125rem;
}

/* Responsive */
@media (max-width: 768px) {
    .all-articles-hero {
        padding: 3rem 1.5rem 1.5rem;
    }

    .all-articles-page {
        padding: 0 1.5rem 3rem;
    }

    .category-nav {
        top: 56px;
        padding: 1rem 0;
        gap: 0.375rem;
    }

    .article-list-item {
        flex-direction: column;
        gap: 0.375rem;
    }

    .article-list-meta {
        flex-direction: row;
        gap: 0.75rem;
    }
}

@media (max-width: 480px) {
    .all-articles-hero {
        padding: 2rem 1.25rem 1rem;
    }

    .all-articles-page {
        padding: 0 1.25rem 2.5rem;
    }

    .category-nav {
        gap: 0.25rem;
    }

    .category-nav-item {
        font-size: 0.75rem;
        padding: 0.25rem 0.5rem;
    }
}

/* Prevent images from overflowing */
.article-body img {
    max-width: 100%;
    height: auto;
}

/* Selection color */
::selection {
    background: rgba(79, 70, 229, 0.15);
    color: #1a1a2e;
}

/* Focus styles for accessibility */
a:focus-visible {
    outline: 2px solid #4f46e5;
    outline-offset: 2px;
    border-radius: 2px;
}

/* Placeholder card images (no thumbnail) */
.card-image-placeholder {
    background: linear-gradient(135deg, #f1f5f9 0%, #e2e8f0 100%);
    display: flex;
    align-items: center;
    justify-content: center;
}

.placeholder-icon {
    color: #cbd5e1;
}

/* Print styles */
@media print {
    .site-header,
    .reading-progress,
    .toc,
    .article-footer,
    .site-footer {
        display: none;
    }

    body {
        font-size: 12pt;
        color: #000;
    }

    .article-body {
        max-width: none;
    }

    .article-body a {
        color: #000;
        text-decoration: underline;
    }

    .article-body pre {
        border: 1px solid #ccc;
        background: #f5f5f5;
        color: #000;
    }
}
