/* Circuit Owl 3D. Same brand tokens as the circuitowl theme; the bench and card art add a live 3D layer. */
/* Fonts load from this theme's assets/css/fonts.css: Bricolage Grotesque 600 to 800, Schibsted Grotesk 400 to 700. */

:root {
    --bg: #fbfcfc;
    --paper: #ffffff;
    --well: #eef3f3;
    --ink: #0e1716;
    --ink-2: #364240;
    --muted: #56625f;
    --line: #dde4e3;
    --accent: #0f766e;
    --accent-ink: #ffffff;
    --accent-text: #0f766e;
    --soft: #eef3f3;
    --soft-hover: #e3eaea;
    --art-bg: #eef3f3;
    --icon: #87918f;
    --code-bg: #0f1a19;
    --code-ink: #dbe8e6;
    --shadow: 0 12px 32px rgb(9 30 28 / .14);
    --font: var(--gh-font-body, "Schibsted Grotesk", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif);
    --font-head: var(--gh-font-heading, "Bricolage Grotesque", "Schibsted Grotesk", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif);
    --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
    --wrap: 1240px;
    --gutter: 40px;
    --radius-l: 16px;
    --radius-s: 8px;
    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg: #131a1b;
        --paper: #1b2325;
        --well: #1f292b;
        --ink: #eef2f2;
        --ink-2: #d5dddc;
        --muted: #b9c4c5;
        --line: #344143;
        --accent: #4cbcad;
        --accent-ink: #062320;
        --accent-text: #6fd2c3;
        --soft: #232d2f;
        --soft-hover: #2c3739;
        --art-bg: #2a3b3c;
        --icon: #8e9a99;
        --code-bg: #0a0d0e;
        --shadow: 0 12px 32px rgb(0 0 0 / .4);
        color-scheme: dark;
    }
}
:root[data-theme="dark"] {
    --bg: #131a1b;
    --paper: #1b2325;
    --well: #1f292b;
    --ink: #eef2f2;
    --ink-2: #d5dddc;
    --muted: #b9c4c5;
    --line: #344143;
    --accent: #4cbcad;
    --accent-ink: #062320;
    --accent-text: #6fd2c3;
    --soft: #232d2f;
    --soft-hover: #2c3739;
    --art-bg: #2a3b3c;
    --icon: #8e9a99;
    --code-bg: #0a0d0e;
    --shadow: 0 12px 32px rgb(0 0 0 / .4);
    color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 400 17px/1.6 var(--font); -webkit-font-smoothing: antialiased; overflow-x: clip; }
a { color: inherit; text-decoration: none; }
h1, h2, h3 { font-family: var(--font-head); letter-spacing: -0.02em; margin: 0; }
img { max-width: 100%; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.wrap { max-width: var(--wrap); margin: 0 auto; padding: 0 var(--gutter); }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: 12px; top: -60px; z-index: 10; padding: 10px 16px; border-radius: 999px; background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.skip:focus { top: 12px; }
.ico { width: 18px; height: 18px; flex: none; color: var(--icon); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 44px; padding: 0 20px; border: 0; border-radius: 999px; font: 600 15px/1 var(--font); cursor: pointer; white-space: nowrap; transition: background-color .18s ease; }
.btn-accent { background: var(--accent); color: var(--accent-ink); }
.btn-accent:hover { background: color-mix(in srgb, var(--accent) 88%, var(--ink)); }
.btn-soft { background: var(--soft); color: var(--ink); }
.btn-soft:hover { background: var(--soft-hover); }
.btn-icon { width: 44px; padding: 0; }
.btn-icon .ico { color: var(--ink-2); }
.pill { border: 0; background: none; font-family: inherit; cursor: pointer; display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 14px; border-radius: 999px; font-weight: 600; font-size: 15px; color: var(--ink); transition: background-color .18s ease; }
.pill:hover, .pill.is-on { background: var(--soft); }

/* Masthead */
.masthead { display: flex; align-items: center; gap: 24px; min-height: 80px; }
.brand { white-space: nowrap; display: inline-flex; align-items: center; gap: 10px; font: 800 30px/1 var(--font-head); letter-spacing: -0.03em; }
.masthead-line { margin: 0; padding-left: 18px; border-left: 1px solid var(--line); color: var(--muted); font-size: 15px; line-height: 1.35; max-width: 22em; }
.brand-mark { width: 38px; height: 38px; color: var(--accent); }
.masthead-nav { display: flex; gap: 4px; margin-left: auto; }
.nav-link { padding: 10px 14px; border-radius: 999px; font-weight: 600; font-size: 15px; transition: background-color .18s ease; }
.nav-link:hover, .nav-link.is-on { background: var(--soft); }
.masthead-actions { display: flex; align-items: center; gap: 8px; }
.menu { position: relative; }
.menu summary { list-style: none; }
.menu summary::-webkit-details-marker { display: none; }
.menu-panel { position: absolute; right: 0; top: calc(100% + 8px); z-index: 5; display: flex; flex-wrap: wrap; gap: 4px; width: min(360px, calc(100vw - 32px)); padding: 16px; border-radius: var(--radius-l); background: var(--paper); box-shadow: var(--shadow); border: 1px solid var(--line); }
.menu-title { flex-basis: 100%; margin: 6px 0 2px 14px; color: var(--muted); font-size: 14px; font-weight: 600; }
.menu-title:first-child { margin-top: 0; }

/* Hero: the lead story beside the bench */
.hero { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: 32px; align-items: center; padding-top: 8px; }
.lead-title { font-size: clamp(36px, 4vw, 54px); line-height: 1.03; font-weight: 800; }
.dek { margin: 18px 0 20px; color: var(--ink-2); font-size: 19px; line-height: 1.55; }
.lead-read { margin-top: 26px; }
.bench { position: relative; height: 580px; margin-right: calc(-1 * var(--gutter)); overflow: hidden; }
.bench-still { position: absolute; left: 6%; top: 18%; width: 84%; height: auto; transform: perspective(1600px) rotateX(48deg) rotateZ(-12deg); filter: drop-shadow(0 26px 22px rgb(4 20 18 / .22)); border-radius: 3%; transition: opacity .5s ease; }
.bench-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; opacity: 0; touch-action: pan-y; cursor: grab; transition: opacity .5s ease; }
.bench.is-live .bench-canvas { opacity: 1; }
.bench.is-live .bench-still { opacity: 0; }
.bench-callout { --stem: 0px; position: absolute; left: 0; top: 0; translate: -50% calc(-100% - 26px); margin: 0; padding: 9px 14px 10px; border-radius: 12px; background: var(--paper); box-shadow: var(--shadow); font-size: 14px; line-height: 1.35; white-space: nowrap; pointer-events: none; }
.bench-callout b { display: block; font: 700 15px/1.25 var(--font-head); }
.bench-callout span { color: var(--muted); }
.bench-callout::after { content: ""; position: absolute; left: calc(50% + var(--stem)); top: 100%; width: 2px; height: 26px; margin-left: -1px; background: var(--accent); }

/* Topic strip under the hero, tied to the bench */
.topics { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 24px; margin-top: 8px; padding-top: 16px; padding-bottom: 16px; }
.topics-track { display: flex; flex-wrap: wrap; gap: 4px; padding-top: 16px; border-top: 1px solid var(--line); flex: 1 1 100%; }
.topic-count { color: var(--muted); font-weight: 500; }
.topics-hint { margin: 0 0 0 auto; color: var(--muted); font-size: 14px; }
.topic.is-on { background: var(--soft); box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--accent) 55%, transparent); }

/* Story rows with part art */
.latest { display: grid; grid-template-columns: minmax(0, 8fr) minmax(0, 4fr); gap: 64px; margin-top: 36px; }
.section-title { font-size: 30px; line-height: 1.15; margin-bottom: 8px; }
.row { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 28px; padding: 26px 0; border-top: 1px solid var(--line); }
.row-art { display: block; aspect-ratio: 10 / 7; border-radius: 14px; overflow: hidden; background: var(--art-bg); }
.row-art .art-photo { width: 100%; height: 100%; object-fit: cover; display: block; }
.row-title { font-size: 24px; line-height: 1.2; margin-bottom: 8px; }
.row-title a:hover { color: var(--accent-text); }
.excerpt { margin: 0 0 12px; color: var(--ink-2); font-size: 16px; }
.meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 14px; margin: 0; color: var(--muted); font-size: 14px; }
.meta-topic { display: inline-flex; align-items: center; gap: 6px; color: var(--accent-text); font-weight: 600; }
.meta-topic .ico { width: 15px; height: 15px; color: var(--accent-text); }
.rail { padding-top: 46px; }
.rail h2 { font-size: 20px; margin-bottom: 8px; }
.rail p { margin: 0 0 12px; color: var(--ink-2); font-size: 15.5px; }
.rail a { color: var(--accent-text); font-weight: 600; font-size: 15px; }

/* A topic's part: the board drawing zoomed on it, replaced by the live part where 3D runs */
.part { position: relative; display: block; width: 100%; height: 100%; overflow: hidden; --x: 44%; --y: 53%; }
.part-still { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: var(--x) var(--y); transform: scale(2.6); transform-origin: var(--x) var(--y); transition: opacity .4s ease; }
.part canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.part.is-live .part-still { opacity: 0; }
.part[data-crop="power"] { --x: 19%; --y: 24%; }
.part[data-crop="usb"] { --x: 6%; --y: 59%; }
.part[data-crop="header"] { --x: 52%; --y: 88%; }
.part[data-crop="probe"] { --x: 67%; --y: 72%; }
.part[data-crop="bracket"] { --x: 92%; --y: 72%; }
.part[data-crop="reel"] { --x: 6%; --y: 30%; }

/* Lead magnet */
.magnet { margin: 56px 0 8px; padding: 36px 44px; border-radius: var(--radius-l); background: var(--well); }
.magnet h2 { font-size: 28px; line-height: 1.2; }
.magnet p { margin: 8px 0 18px; color: var(--ink-2); }
.magnet-form { display: flex; gap: 10px; max-width: 560px; }
.magnet-form input { flex: 1; min-width: 0; height: 48px; padding: 0 18px; border: 1px solid var(--line); border-radius: 999px; background: var(--paper); color: var(--ink); font: inherit; }
.magnet-form input::placeholder { color: var(--muted); }
.magnet-form .btn { height: 48px; }
.magnet-form .when-loading, .magnet-form .when-done { display: none; }
.magnet-form.loading .when-idle, .magnet-form.success .when-idle { display: none; }
.magnet-form.loading .when-loading, .magnet-form.success .when-done { display: inline; }

/* Archives */
.archive-head { padding-top: 40px; padding-bottom: 24px; }
.archive-title { font-size: clamp(34px, 4vw, 48px); line-height: 1.05; font-weight: 800; }
.archive-sub { margin: 10px 0 12px; color: var(--ink-2); font-size: 18px; max-width: 40em; }
.latest-main { min-width: 0; }
.tag-head { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 40px; align-items: center; }
.tag-art { aspect-ratio: 10 / 7; border-radius: var(--radius-l); overflow: hidden; background: var(--art-bg); }
.pager { display: flex; gap: 10px; margin: 28px 0 0; }

/* Article */
.article-head { display: grid; grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); gap: 48px; align-items: center; padding-top: 32px; padding-bottom: 40px; }
.article-title { font-size: clamp(34px, 4.2vw, 56px); line-height: 1.04; font-weight: 800; }
.article-art { margin: 0; aspect-ratio: 10 / 7; border-radius: var(--radius-l); overflow: hidden; background: var(--art-bg); }
.article-art .art-photo { width: 100%; height: 100%; object-fit: cover; display: block; }
/* A feature image keeps the 1200x630 title card's shape at every width (src/brandfactory/writer/image.py), so cover never cuts its text */
.row-art:has(> .art-photo), .article-art:has(> .art-photo) { aspect-ratio: 1200 / 630; }
.article-art figcaption { padding: 8px 12px; color: var(--muted); font-size: 14px; }
.byline { display: flex; gap: 12px; align-items: center; margin-top: 4px; }
.byline-mark { width: 40px; height: 40px; color: var(--accent); }
.byline-name { margin: 0; font-weight: 700; font-size: 15px; }
.article-grid { display: grid; grid-template-columns: 220px minmax(0, 760px); gap: 56px; padding-top: 8px; }
.article-body { min-width: 0; }
.page-article .article-body { max-width: calc(760px + 2 * var(--gutter)); }
.toc { position: sticky; top: 28px; align-self: start; }
.toc[hidden] { display: block; visibility: hidden; }
.toc-title { margin: 0 0 12px; font: 700 16px/1.3 var(--font-head); }
.toc-list { list-style: none; margin: 0; padding: 0; }
.toc-list a { display: block; padding: 7px 12px; margin: 0 -12px; border-radius: 10px; color: var(--ink-2); font-size: 14.5px; line-height: 1.35; transition: background-color .15s ease, color .15s ease; }
.toc-list a:hover { color: var(--ink); background: var(--soft); }
.toc-list a.is-on { color: var(--accent-text); background: var(--soft); font-weight: 600; }
.toc-mobile { display: none; }
.article-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 32px; padding-top: 18px; border-top: 1px solid var(--line); }
.page-head { max-width: calc(760px + 2 * var(--gutter)); padding-top: 40px; padding-bottom: 24px; }
.related { margin-top: 48px; }
.error-page { padding-top: 80px; padding-bottom: 80px; }
.error-code { margin: 0; color: var(--accent-text); font: 800 64px/1 var(--font-head); }

/* Post body */
.prose { font-size: 18.5px; line-height: 1.7; min-width: 0; }
.prose > * { margin: 0 0 1.15em; }
.prose > :first-child { margin-top: 0; }
.prose h2 { margin: 2em 0 .6em; font-size: 30px; line-height: 1.15; font-weight: 600; }
.prose h3 { margin: 1.7em 0 .5em; font-size: 22px; line-height: 1.25; font-weight: 700; }
.prose a { color: var(--accent-text); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; }
.prose a:hover { text-decoration-thickness: 2px; }
.prose strong { font-weight: 700; }
.prose ul, .prose ol { padding-left: 1.3em; }
.prose li { margin: .4em 0; padding-left: .2em; }
.prose li::marker { color: var(--accent-text); font-weight: 700; }
.prose blockquote { margin: 1.6em 0; padding: 20px 24px; border-radius: var(--radius-s); background: var(--well); font-size: 16.5px; line-height: 1.6; }
.prose blockquote p { margin: 0; }
.prose blockquote p + p { margin-top: .8em; }
.prose ol { list-style: none; padding-left: 0; counter-reset: step; }
.prose ol > li { counter-increment: step; position: relative; padding-left: 50px; margin: 0 0 1.1em; }
.prose ol > li::before { content: counter(step); position: absolute; left: 0; top: .15em; width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: var(--soft); color: var(--accent-text); font: 700 15px/1 var(--font-head); }
.prose blockquote.is-prompt { padding: 0 24px 22px; background: #101518; color: #dfe7e9; border: 1px solid #2a3237; overflow: hidden; font-size: 17px; white-space: pre-line; }
.prompt-bar { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px 10px 24px; margin: 0 -24px 16px; background: #181e22; border-bottom: 1px solid #2a3237; white-space: normal; }
.prompt-bar span { font-weight: 700; font-size: 14px; color: #8e9aa0; }
.prompt-bar button { height: 32px; padding: 0 14px; border: 0; border-radius: 999px; background: #4cc4b3; color: #062320; font: 700 14px/1 var(--font); cursor: pointer; }
.prompt-var { padding: .05em .3em; border-radius: 5px; background: rgb(76 196 179 / .18); color: #7fe0cf; }
.source-host { margin-left: auto; color: var(--muted); font-weight: 500; font-size: 14px; white-space: nowrap; }
.prose ul.is-checklist, .prose ul.is-sources { list-style: none; padding-left: 0; }
.prose ul.is-checklist > li { position: relative; padding-left: 40px; margin: 0 0 .8em; }
.prose ul.is-checklist > li::before { content: ""; position: absolute; left: 0; top: .2em; width: 24px; height: 24px; border-radius: 7px; background: var(--soft); }
.prose ul.is-checklist > li::after { content: ""; position: absolute; left: 8.5px; top: calc(.2em + 5px); width: 6px; height: 11px; border: solid var(--accent-text); border-width: 0 2.5px 2.5px 0; transform: rotate(45deg); }
.prose ul.is-sources { border-top: 1px solid var(--line); font-size: 16px; }
.prose ul.is-sources > li { margin: 0; padding: 0; border-bottom: 1px solid var(--line); }
.prose ul.is-sources a { display: flex; gap: 16px; padding: 12px 0; color: var(--ink); font-weight: 600; text-decoration: none; }
.prose a.cite { font-size: .8em; padding: .12em .5em; border-radius: 6px; background: var(--soft); color: var(--ink-2); text-decoration: none; white-space: nowrap; }
.prose .factory-disclosure { margin-top: 2.4em; padding-top: 16px; border-top: 1px solid var(--line); color: var(--muted); font-size: 14.5px; }
.prose code { font-family: var(--mono); font-size: .86em; background: var(--well); padding: .12em .38em; border-radius: 6px; }
.prose pre { background: var(--code-bg); color: var(--code-ink); padding: 20px 22px; border-radius: var(--radius-s); overflow-x: auto; font-size: 14.5px; line-height: 1.6; }
.prose pre code { background: none; padding: 0; font-size: inherit; color: inherit; }
.prose hr { border: 0; height: 1px; background: var(--line); margin: 2.4em 0; }
.prose table { width: 100%; border-collapse: collapse; font-size: 15.5px; display: block; overflow-x: auto; }
.prose th, .prose td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.prose figure { margin: 1.8em 0; }
.prose figcaption { margin-top: 8px; color: var(--muted); font-size: 14.5px; text-align: center; }
.prose img { border-radius: var(--radius-s); }
.prose .kg-width-wide { width: min(1000px, 100vw - 2 * var(--gutter)); margin-left: 50%; transform: translateX(-50%); }
.prose .kg-width-full { width: 100vw; margin-left: 50%; transform: translateX(-50%); }
.prose .kg-width-full img { border-radius: 0; }
.prose .kg-callout-card { border-radius: var(--radius-s); }
.prose .kg-bookmark-card a { text-decoration: none; }

/* Footer */
.site-footer { margin-top: 64px; border-top: 1px solid var(--line); padding: 40px 0 56px; }
.site-footer-inner { display: flex; justify-content: space-between; gap: 32px; align-items: flex-start; }
.brand-small { font-size: 19px; }
.brand-small .brand-mark { width: 26px; height: 26px; }
.site-footer p { margin: 8px 0 0; color: var(--muted); font-size: 14.5px; max-width: 30em; }
.site-footer-nav { display: flex; flex-wrap: wrap; gap: 6px 22px; color: var(--ink-2); font-size: 15px; }
.site-footer-nav a:hover { color: var(--accent-text); }

@media (max-width: 1000px) {
    .masthead-nav, .masthead-line { display: none; }
    .masthead-actions { margin-left: auto; }
    .hero, .article-head, .latest, .tag-head { grid-template-columns: minmax(0, 1fr); }
    .hero { gap: 8px; }
    .bench { height: 420px; margin: 0 calc(-1 * var(--gutter)); }
    .latest { gap: 24px; margin-top: 32px; }
    .rail { padding-top: 0; }
    .article-head { gap: 28px; }
    .article-grid { grid-template-columns: minmax(0, 1fr); gap: 0; }
    .toc { display: none; }
    .toc-mobile:not([hidden]) { display: block; margin-bottom: 28px; border-radius: var(--radius-s); background: var(--well); }
    .toc-mobile summary { display: flex; justify-content: space-between; padding: 14px 18px; font-weight: 700; font-size: 15.5px; list-style: none; cursor: pointer; }
    .toc-mobile summary::-webkit-details-marker { display: none; }
    .toc-mobile summary::after { content: "+"; color: var(--muted); font-size: 22px; line-height: 1; }
    .toc-mobile[open] summary::after { content: "\2212"; }
    .toc-mobile .toc-list { padding: 0 18px 14px; }
}

@media (max-width: 640px) {
    :root { --gutter: 18px; }
    .masthead { min-height: 68px; gap: 12px; }
    .brand { font-size: 23px; }
    .brand-mark { width: 30px; height: 30px; }
    .masthead-actions { gap: 6px; }
    .masthead-actions .btn { height: 40px; }
    .masthead-actions .btn-icon { width: 40px; }
    .masthead-actions .btn-accent { padding: 0 14px; }
    .hero { padding-top: 8px; }
    .lead-title { font-size: 34px; }
    .dek { font-size: 17.5px; margin: 14px 0 16px; }
    .lead-read { margin-top: 18px; }
    .bench { height: 236px; }
    .topics { margin-top: 0; padding-top: 4px; }
    .topics-track .topic-count { display: none; }
    .bench-still { left: 10%; top: 12%; width: 80%; }
    .topics-track { gap: 2px; padding-top: 12px; }
    .topics-track .pill { min-height: 36px; padding: 0 10px; font-size: 14px; gap: 6px; }
    .topics-hint { margin: 0; font-size: 13.5px; }
    .row { grid-template-columns: 112px minmax(0, 1fr); gap: 16px; padding: 20px 0; }
    .row-art { aspect-ratio: 1; }
    .row-title { font-size: 19px; }
    .row .excerpt { display: none; }
    .section-title { font-size: 26px; }
    .magnet { margin-top: 48px; padding: 26px 22px; }
    .magnet h2 { font-size: 24px; }
    .magnet-form { flex-direction: column; }
    .magnet-form input { flex: none; }
    .article-title { font-size: 34px; }
    .prose { font-size: 17.5px; }
    .prose h2 { font-size: 25px; }
    .site-footer-inner { flex-direction: column; gap: 18px; }
}
