/* All colours and fonts live in the :root blocks below, so a re-skin is a single edit.
   Dark is the default, like the old site. Light is available with <html data-theme="light">. */
:root {
  /* One Dark Pro. Page background is #2e313b (a touch lighter than One Dark's own #282c34). */
  --bg: #2e313b;
  --paper: #353a45;
  --ink: #abb2bf;        /* One Dark foreground */
  --strong: #d7dae0;     /* headings and titles */
  --muted: #a0a7b4;      /* lighter than One Dark's comment grey (#7f848e), which is too dim for small text */
  --line: #3e4451;
  --wash: #21252b;       /* code blocks */
  --accent: #61afef;     /* blue: links, active chips */
  --accent-ink: #14181d;
  --teal: #56b6c2;       /* cyan: highlights */
  --steel: #56b6c2;
  --head: #21252b;
  --head2: #282c34;
  --head-ink: #d7dae0;
  --head-muted: #a0a7b4;
  --good-bg: #2f3b2f;
  --good-ink: #98c379;   /* green */
  --f-display: "Poppins", system-ui, sans-serif;
  --f-body: "Poppins", system-ui, sans-serif;
  --f-ui: "DM Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --f-mono: "IBM Plex Mono", ui-monospace, Menlo, Consolas, monospace;
  --gutter: clamp(20px, 6.5vw, 130px);
  --head-h: 80px; /* approx sticky header height, used to offset anchors and sticky columns */
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #eff4f7; --paper: #ffffff; --ink: #3b3c38; --strong: #23241f; --muted: #666a66; --line: #d3dde4;
  --wash: #e4edf2; --accent: #566d8f; --accent-ink: #ffffff;
  --head: #282c34; --head2: #2d313a; --head-ink: #f7f7f7; --head-muted: #aeb6c2;
  --good-bg: #e0f0dc; --good-ink: #2f6a34;
  color-scheme: light;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink); font-family: var(--f-ui); font-size: 15px; line-height: 1.5;
  min-height: 100vh; display: flex; flex-direction: column;
}
a { color: inherit; }
button { font: inherit; color: inherit; }
img { max-width: 100%; height: auto; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- header: sticky; brand centred, menu underneath ---------- */
.site-head { position: sticky; top: 0; z-index: 10; background: var(--head); color: var(--head-ink); }
.brand { display: flex; align-items: center; justify-content: center; gap: 9px; padding: 7px var(--gutter) 6px; text-decoration: none; font: 600 clamp(1.05rem, 2.2vw, 1.3rem) var(--f-display); letter-spacing: -0.01em; }
.logo { width: 34px; height: 34px; flex: none; }
.site-nav { background: var(--head2); display: flex; justify-content: center; flex-wrap: wrap; gap: 0 clamp(16px, 3.2vw, 40px); padding: 6px var(--gutter); border-bottom: 2px solid var(--steel); font: 500 clamp(0.72rem, 1.3vw, 0.82rem) var(--f-ui); letter-spacing: 0.08em; text-transform: uppercase; }
.site-nav a { text-decoration: none; color: var(--head-muted); padding: 1px 0; border-bottom: 2px solid transparent; }
.site-nav a:hover, .site-nav a[aria-current] { color: var(--head-ink); border-bottom-color: var(--teal); }

.site-foot { margin-top: auto; background: var(--head); border-top: 2px solid var(--steel); color: var(--head-muted); padding: 16px var(--gutter); display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; font-size: 0.82rem; }
.site-foot a { text-decoration: none; }
.site-foot a:hover { color: var(--teal); }

/* ---------- hero band: a slice of the cover (or a soft gradient) behind the title ---------- */
.hero { position: relative; overflow: hidden; min-height: clamp(170px, 22vw, 300px); display: flex; align-items: flex-end; color: #fff;
  --sky1: hsl(var(--h, 180) 32% 34%); --sky2: hsl(calc(var(--h, 180) + 25) 36% 26%); --hill: hsl(var(--h, 160) 26% 42%); --hill2: hsl(var(--h, 160) 28% 32%);
  background: radial-gradient(60% 120% at 82% 0%, hsl(var(--h, 180) 40% 52% / .55), transparent 70%), linear-gradient(180deg, var(--sky1), var(--sky2)); }
.hero-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: center 40%; display: block; }
.hero::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, rgb(20 24 30 / .15), rgb(20 24 30 / .6)); }
.hero-inner { position: relative; z-index: 1; width: 100%; padding: 28px var(--gutter); text-shadow: 0 1px 12px rgb(0 0 0 / .45); }
.hero .eyebrow { color: rgb(255 255 255 / .85); margin: 0 0 6px; }
.hero .eyebrow a { text-decoration: none; }
.page-title { font: 600 clamp(1.9rem, 5vw, 3.6rem)/1.1 var(--f-display); margin: 0; text-wrap: balance; letter-spacing: -0.01em; }
.hero-lead { font: 400 clamp(1.1rem, 2.2vw, 1.5rem)/1.5 var(--f-body); max-width: 56ch; margin: 10px 0 0; }
.page-title + .hero-lead { font-size: clamp(1rem, 1.8vw, 1.2rem); opacity: .92; }
.hero-meta { font-size: 0.88rem; margin: 10px 0 0; color: rgb(255 255 255 / .9); }
.hero-meta a { color: inherit; }

/* ---------- page ---------- */
.page { flex: none; }
.wrap { padding: 28px var(--gutter) 64px; }
.eyebrow { font-size: 0.72rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); margin: 0 0 8px; }
h2.sec { font: 600 0.78rem var(--f-ui); letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); margin: 32px 0 10px; }
.intro { font: 400 1rem/1.7 var(--f-body); max-width: 60ch; margin: 0 0 18px; }
.source { font-size: 0.85rem; color: var(--muted); margin: 0 0 6px; }
.source a { color: var(--accent); }

/* ---------- search, chips, badges ---------- */
.search { display: flex; gap: 8px; align-items: center; border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; background: var(--paper); color: var(--muted); width: 100%; max-width: 640px; margin: 0; }
.search input { all: unset; flex: 1; min-width: 0; color: var(--ink); font-size: 1rem; }
.search input::placeholder { color: var(--muted); }
.search + .chips { margin-top: 14px; }
.chips, .tagrow { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 8px; }
.tagrow { margin-top: 22px; align-items: center; }
.chip { border: 1px solid var(--line); background: var(--paper); border-radius: 999px; padding: 3px 11px; font-size: 0.82rem; cursor: pointer; text-decoration: none; color: var(--ink); }
.chip small { color: var(--muted); }
.chip.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.chip.on small { color: inherit; }
.chip:hover { border-color: var(--accent); }
.badge { font-size: 0.7rem; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; padding: 1px 8px; border-radius: 999px; background: var(--good-bg); color: var(--good-ink); }
.badge.wip { background: transparent; border: 1px dashed var(--muted); color: var(--muted); }

.sections { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin: 6px 0 0; }
.sec-link { display: flex; flex-direction: column; gap: 2px; padding: 16px 18px; border: 1px solid var(--line); border-radius: 10px; text-decoration: none; background: var(--paper); }
.sec-link strong { color: var(--strong); font: 600 1.15rem var(--f-display); }
.sec-link span { font-size: 0.82rem; color: var(--muted); }
.sec-link:hover { border-color: var(--accent); }

/* ---------- post lists: columns on wide screens ---------- */
.posts { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 440px), 1fr)); gap: 0 clamp(20px, 3vw, 48px); }
.posts li { border-top: 1px solid var(--line); }
.posts li[hidden] { display: none; }
.post { display: flex; gap: 14px; align-items: center; padding: 14px 0; text-decoration: none; }
.post .body { min-width: 0; flex: 1; }
.post .t { color: var(--strong); font: 600 1.08rem/1.3 var(--f-display); display: block; overflow-wrap: anywhere; }
.post .t small { font: 400 0.8rem var(--f-ui); color: var(--muted); }
.post .m { font-size: 0.8rem; color: var(--muted); display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: center; margin-top: 3px; }
.post .s { font: 400 0.9rem/1.45 var(--f-body); color: var(--muted); margin-top: 4px; display: block; }
.post:hover .t { color: var(--accent); }
.post mark { background: var(--good-bg); color: var(--ink); border-radius: 3px; }

/* ---------- thumbnails ---------- */
.ill { --sky1: hsl(var(--h,160) 22% 26%); --sky2: hsl(calc(var(--h,160) + 30) 25% 22%); --hill: hsl(var(--h,160) 20% 38%); --hill2: hsl(var(--h,160) 22% 30%);
  position: relative; flex: none; border-radius: 10px; overflow: hidden; background: linear-gradient(180deg, var(--sky1), var(--sky2)); border: 1px solid var(--line); display: block; }
.ill svg, .ill img { position: absolute; inset: 0; width: 100%; height: 100%; display: block; object-fit: cover; }
.ill.thumb { width: 64px; height: 64px; }
:root[data-theme="light"] .ill { --sky1: hsl(var(--h, 180) 42% 88%); --sky2: hsl(calc(var(--h, 180) + 25) 48% 80%); --hill: hsl(var(--h, 160) 28% 62%); --hill2: hsl(var(--h, 160) 30% 48%); }

/* ---------- recipe / note ---------- */
.metarow { display: flex; flex-wrap: wrap; gap: 6px 28px; padding: 12px 0; margin: 0 0 18px; border-block: 1px solid var(--line); font-size: 0.92rem; }
.metarow.bare { border: 0; padding: 0; margin: 0 0 6px; }
.metarow b { display: block; font-size: 0.7rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.awake { margin-left: auto; align-self: center; display: flex; align-items: center; gap: 6px; font-size: 0.85rem; cursor: pointer; }
.prose { font: 400 1.02rem/1.75 var(--f-body); max-width: 80ch; overflow-wrap: break-word; min-width: 0; }
.prose h1, .prose h2, .prose h3, .prose h4 { color: var(--strong); font-family: var(--f-display); font-weight: 600; line-height: 1.25; scroll-margin-top: calc(var(--head-h) + 12px); }
.prose h1, .prose h2 { font-size: 1.45rem; margin: 30px 0 8px; }
.prose h3 { font-size: 1.2rem; margin: 24px 0 8px; }
.prose h4 { font-size: 1.05rem; margin: 18px 0 6px; }
.prose > :first-child { margin-top: 0; }
.prose ul, .prose ol { padding-left: 1.3em; margin: 8px 0; }
.prose li { margin: 4px 0; }
.prose li::marker { color: var(--accent); }
.prose p { margin: 8px 0 12px; }
.prose a { color: var(--accent); }
.prose img { border-radius: 10px; display: block; margin: 14px 0; }
.prose table { border-collapse: collapse; display: block; overflow-x: auto; font: 0.9rem var(--f-ui); margin: 12px 0; }
.prose th, .prose td { border: 1px solid var(--line); padding: 5px 10px; text-align: left; }
.prose blockquote { margin: 12px 0; padding-left: 14px; border-left: 3px solid var(--line); color: var(--muted); }
.prose code { font: 0.88em var(--f-mono); background: var(--wash); padding: 1px 5px; border-radius: 5px; }
.prose hr { border: 0; border-top: 1px solid var(--line); margin: 24px 0; }
.recipe-cols { display: grid; gap: 0 clamp(28px, 4vw, 64px); grid-template-columns: 1fr; }
@media (min-width: 860px) {
  .recipe-cols { grid-template-columns: minmax(260px, 340px) minmax(0, 1fr); }
  .recipe-cols .ing { position: sticky; top: calc(var(--head-h) + 16px); align-self: start; }
  .prose:has(.recipe-cols) { max-width: 1100px; }
}
.toc { font-size: 0.88rem; margin: 0 0 18px; padding-left: 12px; border-left: 2px solid var(--line); }
.toc .eyebrow { margin-bottom: 4px; }
.toc a { display: block; text-decoration: none; color: var(--muted); padding: 2px 0; }
.toc a:hover { color: var(--accent); }
.with-toc { display: grid; gap: 0 clamp(28px, 4vw, 64px); }
.with-toc .toc { order: -1; }
@media (min-width: 1100px) {
  .with-toc { grid-template-columns: minmax(0, 80ch) 260px; }
  .with-toc .toc { order: 0; position: sticky; top: calc(var(--head-h) + 16px); align-self: start; }
}

/* ---------- code ---------- */
.codewrap { position: relative; margin: 10px 0; }
pre { margin: 0; background: var(--wash); border-radius: 10px; padding: 12px 14px; overflow-x: auto; font: 0.88rem/1.55 var(--f-mono); }
pre code { background: none; padding: 0; font: inherit; }
.copy { position: absolute; top: 8px; right: 8px; font-size: 0.72rem; border: 1px solid var(--line); background: var(--paper); border-radius: 6px; padding: 2px 8px; cursor: pointer; }
/* Shiki emits both themes as variables; dark by default, light with data-theme="light". */
.shiki, .shiki span { color: var(--shiki-dark); }
:root[data-theme="light"] .shiki, :root[data-theme="light"] .shiki span { color: var(--shiki-light); }
.shiki { background: var(--wash) !important; }

@media (max-width: 520px) {
  .site-nav { gap: 0 16px; }
  .hero-inner { padding-block: 20px; }
}
