/* QuadAVpro blog styles: design B, "Engineer's notebook"
   Colours come from quadribakre.com. Change a colour once in :root and it changes everywhere.
   Light is the default; dark is used when the visitor's device is in dark mode, or they pick it in the header. */

/* FONTS
   IBM Plex Sans and JetBrains Mono (SIL Open Font Licence, see assets/fonts), stored on this site
   rather than loaded from Google Fonts, so visitors' IP addresses aren't sent anywhere. */
@font-face { font-family: 'Plex Sans'; font-weight: 400; font-style: normal; font-display: swap; src: url('/assets/fonts/plex-sans-400.woff2') format('woff2'); }
@font-face { font-family: 'Plex Sans'; font-weight: 400; font-style: italic; font-display: swap; src: url('/assets/fonts/plex-sans-400-italic.woff2') format('woff2'); }
@font-face { font-family: 'Plex Sans'; font-weight: 500; font-style: normal; font-display: swap; src: url('/assets/fonts/plex-sans-500.woff2') format('woff2'); }
@font-face { font-family: 'Plex Sans'; font-weight: 600; font-style: normal; font-display: swap; src: url('/assets/fonts/plex-sans-600.woff2') format('woff2'); }
@font-face { font-family: 'Plex Sans'; font-weight: 700; font-style: normal; font-display: swap; src: url('/assets/fonts/plex-sans-700.woff2') format('woff2'); }
@font-face { font-family: 'JetBrains Mono'; font-weight: 400; font-style: normal; font-display: swap; src: url('/assets/fonts/jetbrains-mono-400.woff2') format('woff2'); }
@font-face { font-family: 'JetBrains Mono'; font-weight: 600; font-style: normal; font-display: swap; src: url('/assets/fonts/jetbrains-mono-600.woff2') format('woff2'); }

/* COLOURS (light, the default) */
:root {
    color-scheme: light;
    --bg: #f6f8fa;          /* page */
    --panel: #eaeef2;       /* boxes, table headers, ad backgrounds */
    --line: #d0d7de;        /* borders */
    --line-strong: #8c959f; /* ad outlines */
    --head: #1f2328;        /* headings */
    --text: #31373d;        /* body text */
    --muted: #59636e;       /* dates, labels */
    --accent: #0a7f69;      /* links, active items */
    --on-accent: #ffffff;   /* text on an accent background */
    --header-bg: rgba(246, 248, 250, 0.92);
    --sans: 'Plex Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
    --mono: 'JetBrains Mono', ui-monospace, Menlo, Consolas, monospace;
    --radius: 8px;
}
/* COLOURS (dark): used when the device is set to dark mode, or the visitor picks dark in the header.
   Same names, so every rule below works for both. */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        color-scheme: dark;
        --bg: #0b0f14; --panel: #151b23; --line: #1f2933; --line-strong: #3d4a57;
        --head: #e6edf3; --text: #c9d1d9; --muted: #8b949e; --accent: #2dd4bf; --on-accent: #0b0f14;
        --header-bg: rgba(11, 15, 20, 0.92);
    }
}
:root[data-theme="dark"] {
    color-scheme: dark;
    --bg: #0b0f14; --panel: #151b23; --line: #1f2933; --line-strong: #3d4a57;
    --head: #e6edf3; --text: #c9d1d9; --muted: #8b949e; --accent: #2dd4bf; --on-accent: #0b0f14;
    --header-bg: rgba(11, 15, 20, 0.92);
}

/* BASICS */
* { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; scroll-padding-top: 5.5rem; }
body { background: var(--bg); color: var(--text); font-family: var(--sans); line-height: 1.6; -webkit-font-smoothing: antialiased; }
a { color: var(--accent); }
img { max-width: 100%; height: auto; display: block; }
h1, h2, h3, h4 { color: var(--head); font-family: var(--sans); font-weight: 700; line-height: 1.25; }
.wrap { width: min(75rem, 100% - 3rem); margin-inline: auto; }
.wrap-narrow { width: min(46rem, 100% - 3rem); margin-inline: auto; }
.skip-link { position: absolute; left: -999px; top: 0; background: var(--accent); color: var(--on-accent); padding: 0.6rem 1rem; z-index: 2000; }
.skip-link:focus { left: 1rem; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.box-title, .prompt, .crumbs, .post-meta, .row-meta { font-family: var(--mono); font-size: 0.82rem; color: var(--muted); }
.box-title { display: block; margin-bottom: 0.8rem; }

/* HEADER */
.site-header { position: sticky; top: 0; z-index: 1000; background: var(--header-bg); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.header-inner { display: flex; align-items: center; justify-content: space-between; gap: 1rem 2rem; padding: 0.9rem 0; flex-wrap: wrap; }
.brand { font-family: var(--mono); font-weight: 600; font-size: 1.25rem; color: var(--head); text-decoration: none; }
.brand span { color: var(--accent); }
.nav-links { display: flex; gap: 1.6rem; flex-wrap: wrap; }
.nav-links a { font-family: var(--mono); font-size: 0.9rem; color: var(--head); text-decoration: none; padding: 0.5rem 0; }
.nav-links a:hover, .nav-links a.active { color: var(--accent); }
.header-tools { display: flex; gap: 0.6rem; }
.icon-btn { width: 44px; height: 44px; display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--line); border-radius: var(--radius); background: none; color: var(--head); cursor: pointer; }
.icon-btn:hover { border-color: var(--accent); color: var(--accent); }
.icon-btn svg { width: 18px; height: 18px; }
.theme-toggle .icon-sun { display: none; }
:root[data-theme-current="dark"] .theme-toggle .icon-sun { display: inline; }
:root[data-theme-current="dark"] .theme-toggle .icon-moon { display: none; }

/* INTRO BAND (home, topics, categories, search) */
.intro { border-bottom: 1px solid var(--line); }
.intro .wrap { padding: 3.5rem 0 2.8rem; }
.prompt { color: var(--accent); margin-bottom: 0.8rem; }
.intro h1 { font-size: clamp(1.8rem, 4vw, 2.7rem); max-width: 54rem; letter-spacing: -0.01em; }
.intro-sub { margin-top: 1rem; color: var(--muted); }

/* LIST PAGES: posts on the left, sidebar on the right */
.list-layout { display: flex; flex-wrap: wrap; gap: 3rem; align-items: flex-start; padding: 2.5rem 0 4.5rem; }
.list-main { flex: 999 1 34rem; min-width: 0; }
.topic-filter { display: flex; gap: 0.5rem; overflow-x: auto; white-space: nowrap; padding-bottom: 0.6rem; margin-bottom: 0.5rem; scrollbar-width: thin; }
.topic-filter a { flex: none; font-family: var(--mono); font-size: 0.82rem; color: var(--head); text-decoration: none; border: 1px solid var(--line); border-radius: 6px; padding: 0.6rem 0.9rem; }
.topic-filter a span { color: var(--muted); margin-left: 0.2rem; }
.topic-filter a:hover { border-color: var(--accent); }
.topic-filter a.active { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.topic-filter a.active span { color: var(--on-accent); }
.post-row { display: flex; gap: 1.5rem; align-items: flex-start; padding: 1.5rem 0; border-bottom: 1px solid var(--line); }
.row-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 0.5rem; }
.row-meta { color: var(--accent); }
.row-meta a { color: var(--accent); text-decoration: none; }
.row-title { font-size: 1.45rem; }
.row-title a { color: var(--head); text-decoration: none; }
.row-title a:hover { color: var(--accent); }
.row-desc { color: var(--muted); font-size: 0.95rem; }
.row-img { flex: none; width: 12.5rem; aspect-ratio: 20 / 13; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); background: var(--panel); }
.row-img img { width: 100%; height: 100%; object-fit: cover; }
.empty { padding: 2rem 0; color: var(--muted); }
.sidebar { flex: 1 1 18.75rem; max-width: 20rem; display: flex; flex-direction: column; gap: 2rem; position: sticky; top: 6rem; }
.box { border: 1px solid var(--line); border-radius: 10px; padding: 1.25rem; display: flex; flex-direction: column; }
.topic-link { display: flex; justify-content: space-between; padding: 0.45rem 0; color: var(--head); text-decoration: none; }
.topic-link span { color: var(--muted); }
.topic-link:hover { color: var(--accent); }
.more-link { font-family: var(--mono); font-size: 0.82rem; margin-top: 0.6rem; text-decoration: none; }

/* TOPICS PAGE */
.topics-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr)); gap: 1.25rem; padding: 2.5rem 0 4.5rem; }
.topic-card { border: 1px solid var(--line); border-radius: 10px; padding: 1.4rem; display: flex; flex-direction: column; gap: 0.35rem; text-decoration: none; }
.topic-card:hover { border-color: var(--accent); }
.topic-name { color: var(--head); font-weight: 600; font-size: 1.15rem; }
.topic-count { font-family: var(--mono); font-size: 0.82rem; color: var(--accent); }
.topic-desc { color: var(--muted); font-size: 0.95rem; }

/* POST PAGE: contents on the left, article in the middle, ad rail on the right */
.post-header { padding: 3rem 0 0; }
.crumbs a { color: var(--muted); text-decoration: none; }
.crumbs a:hover { color: var(--accent); }
.post-title { font-size: clamp(1.9rem, 4.5vw, 3rem); max-width: 56rem; margin: 0.8rem 0 1rem; letter-spacing: -0.01em; }
.post-meta .tags { color: var(--accent); }
.post-grid { display: grid; grid-template-columns: 13rem minmax(0, 44rem) 18.75rem; gap: 2.5rem; justify-content: space-between; padding: 2.5rem 0 4.5rem; align-items: start; }
.toc { position: sticky; top: 6rem; font-size: 0.9rem; }
.toc[hidden] { display: block; visibility: hidden; }
.toc ol { list-style: none; border-left: 1px solid var(--line); padding-left: 0.9rem; display: flex; flex-direction: column; gap: 0.6rem; }
.toc a { color: var(--muted); text-decoration: none; }
.toc a:hover { color: var(--accent); }
.post-rail { position: sticky; top: 6rem; }
.post-cover { margin-bottom: 2rem; }
.post-cover img { width: auto; max-width: 100%; max-height: 32rem; margin-inline: auto; border-radius: 10px; border: 1px solid var(--line); }

/* ARTICLE TEXT (posts and pages) */
.post-body { font-size: 1.125rem; line-height: 1.75; }
.post-body > * + * { margin-top: 1.2em; }
.post-body h2 { font-size: 1.6rem; margin-top: 2.2em; }
.post-body h3 { font-size: 1.3rem; margin-top: 1.8em; }
.post-body h4 { font-size: 1.1rem; margin-top: 1.5em; }
.post-body strong { color: var(--head); }
.post-body a { text-underline-offset: 3px; }
.post-body ul, .post-body ol { padding-left: 1.4em; }
.post-body li + li { margin-top: 0.45em; }
.post-body img { border-radius: var(--radius); border: 1px solid var(--line); margin-inline: auto; max-height: 46rem; width: auto; }
.post-body blockquote { border-left: 3px solid var(--accent); padding-left: 1.2em; color: var(--head); font-style: italic; }
.post-body hr { border: none; border-top: 1px solid var(--line); margin: 2.5em 0; }
.post-body code { font-family: var(--mono); font-size: 0.88em; background: var(--panel); padding: 0.1em 0.35em; border-radius: 4px; }
.post-body pre { background: var(--panel); border: 1px solid var(--line); padding: 1rem 1.2rem; border-radius: var(--radius); overflow-x: auto; }
.post-body pre code { background: none; padding: 0; }
.post-body table { width: 100%; border-collapse: collapse; font-size: 0.95rem; line-height: 1.5; display: block; overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); }
.post-body th, .post-body td { padding: 0.7rem 0.85rem; text-align: left; vertical-align: top; border-top: 1px solid var(--line); }
.post-body th { background: var(--panel); color: var(--head); font-family: var(--mono); font-size: 0.85rem; border-top: none; }
.post-footer { margin-top: 3rem; display: flex; flex-direction: column; gap: 2rem; }
.post-nav { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.post-nav a { border: 1px solid var(--line); border-radius: 10px; padding: 1rem 1.1rem; color: var(--head); text-decoration: none; display: flex; flex-direction: column; gap: 0.35rem; }
.post-nav a:hover { border-color: var(--accent); }
.post-nav a span { font-family: var(--mono); font-size: 0.78rem; color: var(--accent); }
.post-nav .next { grid-column: 2; text-align: right; }

/* PAGES (About) */
.page { padding-bottom: 4.5rem; }
.page-header { padding: 3rem 0 2rem; }
.page-header h1 { font-size: clamp(1.9rem, 4.5vw, 2.8rem); }

/* SEARCH */
.search-page { padding: 2.5rem 0 4.5rem; }
.search-page input { width: 100%; font: inherit; font-size: 1.1rem; color: var(--head); background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 0.85rem 1rem; }
.search-page input:focus { border-color: var(--accent); outline: none; }
.search-count { margin-top: 1rem; font-family: var(--mono); font-size: 0.82rem; color: var(--muted); }

/* ADS: label + box. Placeholder boxes only show in previews (see _config.yml) */
.ad { display: flex; flex-direction: column; align-items: center; gap: 0.4rem; }
.ad-label { font-family: var(--mono); font-size: 0.7rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.ad ins { width: 100%; }
/* Real ads: the label stays hidden until Google has actually filled the space,
   and the whole space hides if Google has no ad for it. Readers never see an empty box. */
.ad:has(ins.adsbygoogle) .ad-label { display: none; }
.ad:has(ins.adsbygoogle[data-ad-status="filled"]) .ad-label { display: block; }
.ad ins.adsbygoogle[data-ad-status="unfilled"] { display: none !important; }
.ad:has(ins.adsbygoogle[data-ad-status="unfilled"]) { display: none; }
.ad-placeholder .ad-box { width: 100%; border: 1.5px dashed var(--line-strong); border-radius: var(--radius); background: var(--panel); color: var(--muted); font-family: var(--mono); font-size: 0.85rem; display: flex; align-items: center; justify-content: center; }
.ad-in-feed { margin: 1.5rem 0; }
.ad-in-feed .ad-box { height: 7rem; }
.ad-in-article { margin: 2rem 0; }
.ad-in-article .ad-box { height: 15.6rem; }
.ad-sidebar .ad-box { width: 18.75rem; max-width: 100%; height: 15.6rem; }
.ad-rail .ad-box { width: 18.75rem; max-width: 100%; height: 37.5rem; }
.ad-end-of-post .ad-box { height: 15.6rem; }

/* NOT FOUND */
.notfound-links { margin-top: 1.5rem; display: flex; gap: 1.5rem; font-family: var(--mono); }

/* FOOTER */
.site-footer { border-top: 1px solid var(--line); }
.footer-inner { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 1.5rem; padding: 2rem 0; }
.footer-left p { font-family: var(--mono); font-size: 0.82rem; color: var(--muted); margin-top: 0.3rem; }
.footer-links { display: flex; flex-wrap: wrap; gap: 1.25rem; }
.footer-links a { font-family: var(--mono); font-size: 0.85rem; color: var(--muted); text-decoration: none; padding: 0.4rem 0; }
.footer-links a:hover { color: var(--accent); }
.social-icons { display: flex; gap: 0.5rem; }
.social-icon { width: 44px; height: 44px; display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--line); border-radius: var(--radius); color: var(--head); }
.social-icon:hover { border-color: var(--accent); color: var(--accent); }
.social-icon svg { width: 18px; height: 18px; fill: currentColor; }

/* TABLET: drop the contents column; the ad rail moves below the article */
@media (max-width: 1150px) {
    .post-grid { grid-template-columns: minmax(0, 1fr); max-width: 46rem; margin-inline: auto; }
    .toc { display: none; }
    .post-rail { position: static; }
    .ad-rail .ad-box { height: 15.6rem; }
}
/* PHONE */
@media (max-width: 680px) {
    .header-inner { justify-content: center; }
    .nav-links { gap: 1rem; justify-content: center; order: 3; width: 100%; }
    .intro .wrap { padding: 2.2rem 0 2rem; }
    .post-row { flex-direction: column-reverse; }
    .row-img { width: 100%; }
    .row-title { font-size: 1.25rem; }
    .sidebar { position: static; max-width: none; }
    .post-body { font-size: 1.06rem; }
    .post-nav { grid-template-columns: 1fr; }
    .post-nav .next { grid-column: 1; text-align: left; }
    .footer-inner { flex-direction: column; text-align: center; }
    .footer-links { justify-content: center; }
}
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; transition: none !important; } }
