/* blog.css - blog post modules (linked separately, only by project.html). Load AFTER /styles.css: it reuses its tokens
   (--ink, --paper, --accent, --border, --shadow) and components (.block, .collapsible).
   Everything is scoped to body.post-page so other pages are unaffected. */

/* ==========================================================================
   1. TOKENS: extra chart colours (read by /js/chart.js)
   ========================================================================== */

:root {
    --chart-1: #000000;
    --chart-2: #ffd93d;
    --chart-3: #ff6b6b;
    --chart-4: #4d96ff;
    --chart-5: #6bcb77;
    --chart-6: #9b5de5;
}

/* W3Schools – "How TO - Smooth Scroll" */
html {
    scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }
}

/* ==========================================================================
   2. PAGE LAYOUT: article + sticky table of contents
   ========================================================================== */

/* undo the portfolio body layout from styles.css (600px column / 2-col grid) */
body.post-page {
    display: block;
    max-width: 1180px;
    margin: 20px auto;
    padding: 0 20px;
}

.post-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 28px;
}

/* wide screens: article left, TOC in a sticky sidebar on the right */
@media only screen and (min-width: 1024px) {
    .post-layout {
        grid-template-columns: minmax(0, 760px) 280px;
        justify-content: center;
        align-items: start;
    }

    .post-toc {
        position: sticky;
        top: 20px;
        grid-column: 2;
        grid-row: 1;
        max-height: calc(100vh - 40px);
        overflow-y: auto;
    }
}

@media only screen and (max-width: 600px) {
    body.post-page {
        padding: 0 16px;
    }
}

/* ==========================================================================
   3. READING PROGRESS BAR (W3Schools – "How TO - Scroll Indicator")
   ========================================================================== */

.progress-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 8px;
    background: var(--paper);
    border-bottom: var(--border);
    z-index: 10;
}

.progress-bar {
    height: 100%;
    width: 0%;
    background: var(--accent);
}

/* ==========================================================================
   4. POST HEADER: title, meta line, tags
   ========================================================================== */

.post-header h1 {
    font-size: clamp(2rem, 5vw, 3.2rem);
    line-height: 1.05;
    margin: 0 0 12px;
}

.post-lead {
    font-size: 1.15rem;
    margin: 0 0 16px;
}

.post-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 16px;
    margin: 0;
    padding: 0;
    list-style: none;
    font-weight: 700;
    font-size: .9rem;
}

.post-meta .fa {
    margin-right: 6px;
}

.tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 16px 0 0;
    padding: 0;
    list-style: none;
}

.tag {
    background: var(--ink);
    color: var(--paper);
    padding: 2px 10px;
    font-size: .8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
}

/* ==========================================================================
   5. ARTICLE BODY: headings, paragraphs, lists, quotes, code, callouts
   ========================================================================== */

.post-body > section {
    margin-bottom: 28px;
}

/* leave room above a heading when jumped to from the TOC */
.post-body h2,
.post-body h3 {
    scroll-margin-top: 24px;
}

.post-body h3 {
    font-size: 1.3rem;
    margin: 24px 0 8px;
}

.post-body p,
.post-body li {
    font-size: 1.05rem;
    line-height: 1.65;
}

.post-body blockquote {
    margin: 20px 0;
    padding: 12px 20px;
    border-left: 8px solid var(--ink);
    background: var(--accent);
    font-size: 1.15rem;
    font-weight: 700;
}

.post-body blockquote cite {
    display: block;
    margin-top: 6px;
    font-size: .9rem;
    font-style: normal;
}

.post-body code {
    font-family: Consolas, Menlo, monospace;
    background: var(--ink);
    color: var(--paper);
    padding: 1px 6px;
}

.post-body pre {
    background: var(--ink);
    color: var(--paper);
    padding: 16px;
    overflow-x: auto;
    border: var(--border);
    box-shadow: 4px 4px 0 var(--accent);
}

.post-body pre code {
    padding: 0;
}

.callout {
    border: var(--border);
    background: var(--paper);
    box-shadow: 4px 4px 0 var(--ink);
    padding: 12px 16px;
    margin: 20px 0;
}

.callout .fa {
    margin-right: 8px;
}

/* ==========================================================================
   6. MEDIA: embedded images with captions
   ========================================================================== */

.post-figure {
    margin: 24px 0;
}

/* W3Schools – "Responsive Web Design - Images" */
.post-figure img {
    max-width: 100%;
    height: auto;
    display: block;
    border: var(--border);
    box-shadow: var(--shadow);
}

.post-figure figcaption {
    margin-top: 12px;
    font-size: .9rem;
    font-weight: 700;
}

/* side-by-side image pair, stacks on phones */
.figure-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
}

/* ==========================================================================
   7. CHARTS (Apache ECharts, built by /js/chart.js)
   ========================================================================== */

.chart-figure {
    margin: 24px 0;
}

.chart {
    width: 100%;
    height: 380px;
    background: #ffffff;
    border: var(--border);
    box-shadow: var(--shadow);
}

.chart-figure figcaption {
    margin-top: 12px;
    font-size: .9rem;
    font-weight: 700;
}

.chart-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
}

.chart-controls button {
    font: inherit;
    font-weight: 700;
    cursor: pointer;
    color: var(--ink);
    background: var(--paper);
    border: var(--border);
    box-shadow: 3px 3px 0 var(--ink);
    padding: 4px 12px;
    transition: transform .1s, box-shadow .1s;
}

.chart-controls button:hover,
.chart-controls button[aria-pressed="true"] {
    transform: translate(3px, 3px);
    box-shadow: 0 0 0 var(--ink);
}

.chart-controls button[aria-pressed="true"] {
    background: var(--accent);
}

@media only screen and (max-width: 600px) {
    .chart {
        height: 300px;
    }
}

/* ==========================================================================
   8. TABLE OF CONTENTS (built by /js/toc.js)
   ========================================================================== */

.post-toc h2 {
    font-size: 20px;
}

.toc-list,
.toc-list ol {
    list-style: none;
    margin: 0;
    padding: 0;
}

.toc-list ol {
    padding-left: 16px;
}

.toc-list a {
    display: block;
    padding: 4px 8px;
    margin: 2px 0;
    text-decoration: none;
    border-left: 4px solid transparent;
}

.toc-list ol a {
    font-weight: 400;
    font-size: .95rem;
}

.toc-list a:hover {
    border-left-color: var(--ink);
}

.toc-list a.is-active {
    background: var(--accent);
    border-left-color: var(--ink);
}

/* ==========================================================================
   9. POST FOOTER
   ========================================================================== */

.post-footer {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
}

/* ==========================================================================
   10. 404 VIEW (shown by project.html when no JSON matches the URL)
   ========================================================================== */

.not-found {
    max-width: var(--page-width);
    margin: 10vh auto;
    text-align: center;
}

.not-found-code {
    font-size: clamp(5rem, 22vw, 9rem);
    font-weight: 700;
    line-height: 1;
    margin: 0 0 16px;
    -webkit-text-stroke: 3px var(--ink);
    color: var(--paper);
    text-shadow: 6px 6px 0 var(--ink);
}

.not-found p {
    margin: 0 0 20px;
}

/* same pressable look as .chart-controls button */
.not-found .button {
    display: inline-block;
    text-decoration: none;
    background: var(--paper);
    border: var(--border);
    box-shadow: var(--shadow-sm);
    padding: 8px 16px;
    transition: transform .1s, box-shadow .1s;
}

.not-found .button:hover {
    transform: translate(4px, 4px);
    box-shadow: 0 0 0 var(--ink);
}

.not-found .button .fa {
    margin-right: 6px;
}

/* keep the [hidden] attribute working on elements that set their own display (e.g. .post-layout grid) */
body.post-page [hidden] {
    display: none !important;
}
