/* ═══════════════════════════════════════════════════════════
   TREEHOUSE ARTICLE STYLES
   Scoped under .article-page to coexist with Material Kit.
   ═══════════════════════════════════════════════════════════ */

/* ── Design tokens ──────────────────────────────────────── */
.article-page {
    --a-font-serif: 'Source Serif 4', Georgia, serif;
    --a-font-sans: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
    --a-font-mono: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;

    --a-fs-body: clamp(1.05rem, 0.95rem + 0.4vw, 1.2rem);
    --a-fs-small: clamp(0.85rem, 0.8rem + 0.2vw, 0.95rem);
    --a-fs-h1: clamp(2rem, 1.5rem + 2vw, 3rem);
    --a-fs-h2: clamp(1.4rem, 1.2rem + 0.8vw, 1.75rem);
    --a-fs-h3: clamp(1.15rem, 1rem + 0.5vw, 1.35rem);
    --a-fs-caption: clamp(0.8rem, 0.75rem + 0.2vw, 0.9rem);

    --a-w-text: 720px;
    --a-w-wide: 920px;

    --a-c-bg: #FAFAF7;
    --a-c-surface: #FFFFFF;
    --a-c-text: #1A1A1A;
    --a-c-text-secondary: #555555;
    --a-c-text-muted: #888888;
    /*--a-c-accent: #2B6B4F;
    --a-c-accent-light: #E8F0EC;
    --a-c-accent: #C2185B;
    --a-c-accent-light: #FDF2F5;*/
    --a-c-accent: #546E7A;
    --a-c-accent-light: #ECEFF1;
    --a-c-rule: #E0DDD8;
    --a-c-code-bg: #F3F1ED;

    --a-space-xs: 0.5rem;
    --a-space-sm: 1rem;
    --a-space-md: 1.5rem;
    --a-space-lg: 2.5rem;
    --a-space-xl: 4rem;
    --a-space-2xl: 6rem;
}

/* ── Full-width light background ────────────────────────── */
/* Breaks out of Material Kit's dark bg-gray-800 */
.article-page {
    background: var(--a-c-bg);
    min-height: 100vh;
    padding-bottom: var(--a-space-2xl);
}

/* ── Article hero ───────────────────────────────────────── */
.article-hero {
    max-width: var(--a-w-text);
    margin: 0 auto;
    padding: var(--a-space-2xl) var(--a-space-md) var(--a-space-lg);
}

.article-hero__label {
    font-family: var(--a-font-sans);
    font-size: var(--a-fs-small);
    font-weight: 600;
    color: var(--a-c-accent);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: var(--a-space-sm);
}

.article-page .article-hero h1 {
    font-family: var(--a-font-serif);
    font-size: var(--a-fs-h1);
    font-weight: 700;
    line-height: 1.15;
    letter-spacing: -0.02em;
    color: var(--a-c-text);
    margin-bottom: var(--a-space-md);
}

.article-hero__subtitle {
    font-family: var(--a-font-serif);
    font-size: clamp(1.05rem, 1rem + 0.3vw, 1.25rem);
    color: var(--a-c-text-secondary);
    line-height: 1.55;
    margin-bottom: var(--a-space-md);
}

.article-hero__meta {
    font-family: var(--a-font-sans);
    font-size: var(--a-fs-small);
    color: var(--a-c-text-muted);
    display: flex;
    flex-wrap: wrap;
    gap: var(--a-space-sm);
    align-items: center;
    padding-top: var(--a-space-md);
    border-top: 1px solid var(--a-c-rule);
}

.article-hero__meta-sep {
    color: var(--a-c-rule);
}

/* ── Article body ───────────────────────────────────────── */
.article-body {
    max-width: var(--a-w-text);
    margin: 0 auto;
    padding: 0 var(--a-space-md);
    font-family: var(--a-font-serif);
    font-size: var(--a-fs-body);
    line-height: 1.7;
    color: var(--a-c-text);
    -webkit-font-smoothing: antialiased;
}

.article-body > * + * {
    margin-top: var(--a-space-md);
}

/* Headings — need specificity to beat Material Kit */
.article-page .article-body h2 {
    font-family: var(--a-font-serif);
    font-size: var(--a-fs-h2);
    font-weight: 700;
    line-height: 1.25;
    letter-spacing: -0.015em;
    color: var(--a-c-text);
    margin-top: var(--a-space-xl);
    padding-top: var(--a-space-lg);
    border-top: 1px solid var(--a-c-rule);
    margin-bottom: 0;
}

.article-page .article-body h2:first-child {
    border-top: none;
    padding-top: 0;
}

.article-page .article-body h3 {
    font-family: var(--a-font-sans);
    font-size: var(--a-fs-h3);
    font-weight: 600;
    line-height: 1.35;
    color: var(--a-c-text);
    margin-top: var(--a-space-lg);
    margin-bottom: 0;
}

/* Paragraphs */
.article-body p {
    hanging-punctuation: first;
    margin-bottom: 0;
}

/* Links */
.article-page .article-body a {
    color: var(--a-c-accent);
    text-decoration-thickness: 1px;
    text-underline-offset: 2px;
    transition: color 0.2s;
}

.article-page .article-body a:hover {
    color: var(--a-c-text);
}

/* ── Key findings box ───────────────────────────────────── */
.key-findings {
    background: var(--a-c-accent-light);
    border-left: 3px solid var(--a-c-accent);
    border-radius: 0 6px 6px 0;
    padding: var(--a-space-md) var(--a-space-lg);
    margin-top: var(--a-space-lg);
    margin-bottom: var(--a-space-lg);
}

.article-page .key-findings h3 {
    font-family: var(--a-font-sans);
    font-size: var(--a-fs-h3);
    font-weight: 600;
    margin-top: 0;
    padding-top: 0;
    border-top: none;
    margin-bottom: var(--a-space-sm);
    color: var(--a-c-text);
}

.key-findings ul {
    padding-left: 1.2em;
    margin-bottom: 0;
}

.key-findings li {
    font-family: var(--a-font-serif);
    font-size: var(--a-fs-body);
    margin-bottom: var(--a-space-xs);
    line-height: 1.55;
    color: var(--a-c-text);
}

.key-findings li::marker {
    color: var(--a-c-accent);
}

/* ── Figures ────────────────────────────────────────────── */
.article-figure {
    margin: var(--a-space-xl) 0;
}

.article-figure img {
    width: 100%;
    height: auto;
    border-radius: 4px;
    display: block;
}

/* Wide figure — breaks out of text column */
.article-figure--wide {
    max-width: var(--a-w-wide);
    width: calc(100vw - 2 * var(--a-space-md));
    margin-left: 50%;
    transform: translateX(-50%) !important;
}

.article-figure figcaption {
    font-family: var(--a-font-sans);
    font-size: var(--a-fs-caption);
    color: var(--a-c-text-secondary);
    line-height: 1.5;
    margin-top: var(--a-space-xs);
    padding-top: var(--a-space-xs);
    border-top: 1px solid var(--a-c-rule);
}

.article-figure figcaption strong {
    color: var(--a-c-text);
    display: block;
    margin-bottom: 2px;
}

/* ── Tables ─────────────────────────────────────────────── */
.article-page .article-body table {
    width: 100%;
    border-collapse: collapse;
    font-family: var(--a-font-sans);
    font-size: var(--a-fs-small);
    margin: var(--a-space-lg) 0;
}

.article-page .article-body thead {
    border-bottom: 2px solid var(--a-c-text);
}

.article-page .article-body th {
    font-weight: 600;
    text-align: left;
    padding: var(--a-space-xs) var(--a-space-sm);
    color: var(--a-c-text);
}

.article-page .article-body td {
    padding: var(--a-space-xs) var(--a-space-sm);
    border-bottom: 1px solid var(--a-c-rule);
    color: var(--a-c-text);
}

/* ── Blockquotes & pull quotes ──────────────────────────── */
.article-page .article-body blockquote {
    border-left: 3px solid var(--a-c-accent);
    padding-left: var(--a-space-md);
    margin: var(--a-space-lg) 0;
    color: var(--a-c-text-secondary);
    font-style: italic;
    background: none;
}

.article-page .article-body blockquote p {
    font-size: inherit;
}

.article-body .pull-quote {
    font-family: var(--a-font-serif);
    font-size: var(--a-fs-h2);
    font-weight: 600;
    line-height: 1.3;
    color: var(--a-c-accent);
    border: none;
    font-style: normal;
    padding: var(--a-space-lg) 0;
    text-align: center;
    max-width: 85%;
    margin: var(--a-space-xl) auto;
}

/* ── Code ───────────────────────────────────────────────── */
.article-body code {
    font-family: var(--a-font-mono);
    font-size: 0.88em;
    background: var(--a-c-code-bg);
    padding: 0.15em 0.35em;
    border-radius: 3px;
    color: var(--a-c-text);
}

.article-body pre {
    background: var(--a-c-code-bg);
    padding: var(--a-space-md);
    border-radius: 6px;
    overflow-x: auto;
    line-height: 1.5;
}

.article-body pre code {
    background: none;
    padding: 0;
    font-size: 0.85em;
}

/* ── Footnotes ──────────────────────────────────────────── */
.footnote-ref {
    font-family: var(--a-font-sans);
    font-size: 0.7em;
    vertical-align: super;
    line-height: 0;
    color: var(--a-c-accent);
    text-decoration: none;
    font-weight: 600;
    padding: 0 1px;
}

.footnote-ref:hover {
    text-decoration: underline;
}

.article-footnotes {
    margin-top: var(--a-space-xl);
    padding-top: var(--a-space-lg);
    border-top: 1px solid var(--a-c-rule);
}

.article-page .article-footnotes h2 {
    font-family: var(--a-font-sans);
    font-size: var(--a-fs-h3);
    font-weight: 600;
    margin-bottom: var(--a-space-md);
    border-top: none;
    padding-top: 0;
    margin-top: 0;
}

.article-footnotes ol {
    padding-left: 1.5em;
    counter-reset: fn-counter;
    list-style: none;
}

.article-footnotes li {
    font-family: var(--a-font-serif);
    font-size: var(--a-fs-small);
    color: var(--a-c-text-secondary);
    line-height: 1.55;
    margin-bottom: var(--a-space-sm);
    position: relative;
    counter-increment: fn-counter;
}

.article-footnotes li::before {
    content: counter(fn-counter) ".";
    position: absolute;
    left: -1.5em;
    font-weight: 600;
    font-family: var(--a-font-sans);
    font-size: 0.85em;
    color: var(--a-c-accent);
}

.article-footnotes li:target {
    background: var(--a-c-accent-light);
    padding: var(--a-space-xs);
    margin-left: calc(-1 * var(--a-space-xs));
    border-radius: 3px;
}

.footnote-backref {
    font-size: 0.8em;
    color: var(--a-c-accent);
    text-decoration: none;
    margin-left: 0.3em;
}

/* ── Scroll-triggered reveal ────────────────────────────── */
.a-reveal {
    opacity: 0;
    transform: translateY(16px);
    transition: opacity 0.5s ease, transform 0.5s ease;
}

.a-reveal.visible {
    opacity: 1;
    transform: translateY(0);
}

/* ── Make sure header isn't obscured by navbar ────────────────────────────── */
/*#blog_summary {
    scroll-margin-top: 200px;
}*/

/* ── Print ──────────────────────────────────────────────── */
@media print {
    .article-page { background: white; }
    .article-body { max-width: 100%; }
    .article-figure--wide { max-width: 100%; margin-left: 0; transform: none; }
    .a-reveal { opacity: 1; transform: none; }
}
