/* ============================================================
   Fonts — self-hosted variable fonts.
   One file covers every weight, so there is no separate
   request for bold. font-display:swap means text is readable
   immediately instead of invisible while the font loads.
   ============================================================ */

@font-face {
  font-family: "Inter var";
  src: url("../fonts/inter-var.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "JetBrains Mono";
  src: url("../fonts/jetbrains-mono-var.woff2") format("woff2");
  font-weight: 100 800;
  font-style: normal;
  font-display: swap;
}

/* ============================================================
   VENAIO — design tokens
   Colour in OKLCH: perceptually uniform, so a lightness step
   looks like the same step on every hue. Fixes the classic
   problem where HSL mid-tones drift muddy.
   ============================================================ */

:root {
  color-scheme: light dark;

  /* neutrals */
  --bg:        light-dark(oklch(99%  0.002 260), oklch(17% 0.012 260));
  --surface:   light-dark(oklch(97%  0.004 260), oklch(21% 0.014 260));
  --surface-2: light-dark(oklch(94%  0.006 260), oklch(25% 0.014 260));
  --text:      light-dark(oklch(24%  0.010 260), oklch(94% 0.006 260));
  --text-mute: light-dark(oklch(50%  0.015 260), oklch(70% 0.012 260));
  --border:    light-dark(oklch(90%  0.006 260), oklch(31% 0.014 260));

  /* accent */
  --accent:      light-dark(oklch(53% 0.19 262), oklch(72% 0.15 262));
  --accent-text: light-dark(oklch(99% 0.002 260), oklch(17% 0.012 260));
  --accent-soft: light-dark(oklch(95% 0.03 262), oklch(28% 0.05 262));

  /* semantic */
  --ok:   light-dark(oklch(52% 0.15 155), oklch(72% 0.14 155));
  --warn: light-dark(oklch(58% 0.15 75),  oklch(78% 0.13 75));
  --err:  light-dark(oklch(54% 0.20 25),  oklch(70% 0.16 25));

  /* type — fluid, no media queries needed */
  --font-sans: "Inter var", Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;

  --step--1: clamp(0.83rem, 0.80rem + 0.15vw, 0.92rem);
  --step-0:  clamp(1.00rem, 0.96rem + 0.20vw, 1.13rem);
  --step-1:  clamp(1.25rem, 1.17rem + 0.38vw, 1.48rem);
  --step-2:  clamp(1.56rem, 1.42rem + 0.70vw, 1.94rem);
  --step-3:  clamp(1.95rem, 1.71rem + 1.20vw, 2.55rem);
  --step-4:  clamp(2.44rem, 2.04rem + 1.98vw, 3.36rem);

  /* spacing — one ratio, used everywhere */
  --sp-1: 0.25rem; --sp-2: 0.5rem;  --sp-3: 0.75rem;
  --sp-4: 1rem;    --sp-5: 1.5rem;  --sp-6: 2rem;
  --sp-7: 3rem;    --sp-8: 4rem;    --sp-9: 6rem;

  --radius:    10px;
  --radius-lg: 16px;
  --measure:   68ch;          /* optimal line length for reading */

  --shadow: 0 1px 2px light-dark(oklch(0% 0 0 / 0.04), oklch(0% 0 0 / 0.3)),
            0 4px 16px light-dark(oklch(0% 0 0 / 0.05), oklch(0% 0 0 / 0.25));

  --ease: cubic-bezier(0.32, 0.72, 0, 1);
}

/* explicit override beats the OS preference */
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"]  { color-scheme: dark; }

/* ============================================================
   reset
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: 5rem;   /* clears the sticky header on anchor jumps */
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: var(--step-0);
  line-height: 1.7;
  font-synthesis-weight: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

img, picture, svg, video { display: block; max-width: 100%; height: auto; }
input, button, textarea, select { font: inherit; color: inherit; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 0.2em; }
a:hover { text-decoration-thickness: 2px; }

/* ============================================================
   layout
   ============================================================ */

.wrap {
  width: min(100% - 2.5rem, 1280px);
  margin-inline: auto;
}

.layout {
  display: grid;
  gap: var(--sp-7);
  padding-block: var(--sp-7);
  grid-template-columns: minmax(0, 1fr);
}

@media (min-width: 60rem) {
  .layout { grid-template-columns: minmax(0, 1fr) 20rem; }
  .layout--wide { grid-template-columns: minmax(0, 1fr); }
}

/* ============================================================
   header
   ============================================================ */

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in oklab, var(--bg) 82%, transparent);
  backdrop-filter: blur(12px) saturate(160%);
  border-bottom: 1px solid var(--border);
}

.site-header__inner {
  display: flex;
  align-items: center;
  gap: var(--sp-5);
  min-height: 4rem;
}

.brand {
  font-weight: 680;
  font-size: var(--step-1);
  letter-spacing: -0.02em;
  color: var(--text);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
}

.brand__mark {
  width: 1.6rem; height: 1.6rem;
  border-radius: 7px;
  background: linear-gradient(135deg, var(--accent), oklch(from var(--accent) l c calc(h + 40)));
  display: grid; place-items: center;
  color: var(--accent-text);
  font-size: 0.85rem; font-weight: 700;
}

.nav { display: flex; gap: var(--sp-1); margin-inline-start: auto; align-items: center; }

/* wp_nav_menu emits a <ul>; without this it shows list bullets */
.nav__links, .site-footer .nav__links { list-style: none; margin: 0; padding: 0; }
.nav__links li { list-style: none; }

.nav a {
  color: var(--text-mute);
  text-decoration: none;
  font-size: var(--step--1);
  font-weight: 500;
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--radius);
  transition: color 0.15s var(--ease), background 0.15s var(--ease);
}
.nav a:hover, .nav a[aria-current="page"] { color: var(--text); background: var(--surface-2); }

.icon-btn {
  display: grid; place-items: center;
  width: 2.25rem; height: 2.25rem;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.15s var(--ease), border-color 0.15s var(--ease);
}
.icon-btn:hover { background: var(--surface-2); border-color: var(--text-mute); }
.icon-btn svg { width: 1.05rem; height: 1.05rem; }

/* the toggle swaps which icon shows, based on resolved theme */
.icon-btn .i-moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .icon-btn .i-sun  { display: none; }
  :root:not([data-theme="light"]) .icon-btn .i-moon { display: block; }
}
:root[data-theme="dark"] .icon-btn .i-sun  { display: none; }
:root[data-theme="dark"] .icon-btn .i-moon { display: block; }
:root[data-theme="light"] .icon-btn .i-sun  { display: block; }
:root[data-theme="light"] .icon-btn .i-moon { display: none; }

.nav-toggle { display: none; }
@media (max-width: 48rem) {
  .nav-toggle { display: grid; }
  .nav__links {
    position: fixed; inset: 4rem 0 auto 0;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    flex-direction: column;
    padding: var(--sp-4);
    gap: var(--sp-1);
    display: none;
  }
  .nav__links[data-open="true"] { display: flex; }
  .nav { gap: var(--sp-2); }
}
@media (min-width: 48.001rem) {
  .nav__links { display: flex; gap: var(--sp-1); }
}

/* ============================================================
   article
   ============================================================ */

.article__header { margin-bottom: var(--sp-6); }

.eyebrow {
  display: inline-flex; align-items: center; gap: var(--sp-2);
  font-size: var(--step--1);
  font-weight: 600;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: var(--sp-3);
}

h1, h2, h3, h4 {
  line-height: 1.15;
  letter-spacing: -0.021em;
  font-weight: 640;
  text-wrap: balance;      /* stops orphan words in headings */
}

h1 { font-size: var(--step-4); }
h2 { font-size: var(--step-2); margin-block: var(--sp-7) var(--sp-4); }
h3 { font-size: var(--step-1); margin-block: var(--sp-6) var(--sp-3); }

.article__meta {
  display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-3);
  color: var(--text-mute);
  font-size: var(--step--1);
  margin-top: var(--sp-4);
}
.article__meta .dot { width: 3px; height: 3px; border-radius: 50%; background: currentColor; opacity: 0.5; }

.prose { max-width: var(--measure); }
.prose > * + * { margin-top: var(--sp-4); }
.prose p { text-wrap: pretty; }

.prose ul, .prose ol { padding-inline-start: var(--sp-5); display: grid; gap: var(--sp-2); }

.prose blockquote {
  border-inline-start: 3px solid var(--accent);
  padding: var(--sp-1) 0 var(--sp-1) var(--sp-5);
  color: var(--text-mute);
  font-style: italic;
}

.prose :not(pre) > code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 0.15em 0.4em;
  border-radius: 5px;
  word-break: break-word;
}

.prose pre {
  font-family: var(--font-mono);
  font-size: var(--step--1);
  line-height: 1.6;
  background: light-dark(oklch(21% 0.014 260), oklch(13% 0.012 260));
  color: oklch(92% 0.01 260);
  padding: var(--sp-4) var(--sp-5);
  border-radius: var(--radius);
  border: 1px solid light-dark(transparent, var(--border));
  overflow-x: auto;         /* wide code scrolls, page never does */
  tab-size: 2;
}
.prose pre code { background: none; border: 0; padding: 0; font-size: inherit; }

.prose img, .prose figure { border-radius: var(--radius); margin-block: var(--sp-6); }
.prose figcaption { font-size: var(--step--1); color: var(--text-mute); margin-top: var(--sp-2); }

.prose table { width: 100%; border-collapse: collapse; font-size: var(--step--1); }
.prose :is(th, td) { padding: var(--sp-3); border-bottom: 1px solid var(--border); text-align: start; }
.prose th { font-weight: 620; background: var(--surface); }
.table-scroll { overflow-x: auto; margin-block: var(--sp-5); }

.prose hr { border: 0; border-top: 1px solid var(--border); margin-block: var(--sp-7); }

/* heading anchor links — appear on hover, keyboard reachable */
.heading-anchor {
  opacity: 0; margin-inline-start: 0.4em;
  text-decoration: none; color: var(--text-mute);
  transition: opacity 0.15s var(--ease);
}
:is(h2, h3):hover .heading-anchor, .heading-anchor:focus-visible { opacity: 1; }

/* ============================================================
   cards / archive
   ============================================================ */

.card-grid {
  display: grid;
  gap: var(--sp-5);
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 18rem), 1fr));
}

.card {
  container-type: inline-size;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--sp-5);
  display: flex; flex-direction: column; gap: var(--sp-3);
  transition: border-color 0.2s var(--ease), transform 0.2s var(--ease), box-shadow 0.2s var(--ease);
}
.card:hover { border-color: var(--accent); transform: translateY(-2px); box-shadow: var(--shadow); }

.card__title { font-size: var(--step-1); line-height: 1.3; }
.card__title a { color: var(--text); text-decoration: none; }
.card__title a:hover { color: var(--accent); }
.card__excerpt { color: var(--text-mute); font-size: var(--step--1); line-height: 1.65; }
.card__meta { margin-top: auto; display: flex; gap: var(--sp-3); align-items: center;
              color: var(--text-mute); font-size: var(--step--1); }

.tag {
  display: inline-block;
  font-size: var(--step--1);
  padding: 0.15rem var(--sp-3);
  border-radius: 100px;
  background: var(--accent-soft);
  color: var(--accent);
  text-decoration: none;
  font-weight: 550;
}

/* ============================================================
   sidebar
   ============================================================ */

.sidebar {
  display: flex; flex-direction: column; gap: var(--sp-5);
  font-size: var(--step--1);
}

@media (min-width: 60rem) {
  .sidebar { position: sticky; top: 5rem; align-self: start; max-height: calc(100vh - 6rem); overflow-y: auto; }
}

.widget {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--sp-5);
}
.widget__title {
  font-size: var(--step--1);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-mute);
  font-weight: 640;
  margin-bottom: var(--sp-3);
}
.widget ul { list-style: none; padding: 0; display: grid; gap: var(--sp-2); }
.widget a { color: var(--text); text-decoration: none; }
.widget a:hover { color: var(--accent); }

/* table of contents with scroll-spy */
.toc ol { list-style: none; padding: 0; display: grid; gap: var(--sp-1); counter-reset: toc; }
.toc li.is-h3 { padding-inline-start: var(--sp-4); }
.toc a {
  display: block;
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--radius);
  color: var(--text-mute);
  border-inline-start: 2px solid transparent;
  line-height: 1.4;
  transition: color 0.15s var(--ease), background 0.15s var(--ease);
}
.toc a:hover { color: var(--text); background: var(--surface-2); }
.toc a.is-active {
  color: var(--accent);
  background: var(--accent-soft);
  border-inline-start-color: var(--accent);
  font-weight: 560;
}

/* ============================================================
   ad slots — reserved height prevents layout shift (CLS),
   which is what actually protects your Core Web Vitals score
   ============================================================ */

.ad-slot {
  display: grid; place-items: center;
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  color: var(--text-mute);
  font-size: var(--step--1);
  overflow: hidden;
}
.ad-slot--leaderboard { min-height: 90px;  margin-block: var(--sp-6); }
.ad-slot--in-article  { min-height: 250px; margin-block: var(--sp-6); }
.ad-slot--sidebar     { min-height: 250px; }

/* ============================================================
   footer / misc
   ============================================================ */

.site-footer {
  border-top: 1px solid var(--border);
  margin-top: var(--sp-9);
  padding-block: var(--sp-7);
  color: var(--text-mute);
  font-size: var(--step--1);
}
.site-footer__inner { display: flex; flex-wrap: wrap; gap: var(--sp-5); justify-content: space-between; }
.site-footer a { color: var(--text-mute); text-decoration: none; }
.site-footer a:hover { color: var(--accent); }

.reading-bar {
  position: fixed; top: 0; left: 0; height: 2px;
  background: var(--accent);
  width: var(--progress, 0%);
  z-index: 60;
  transition: width 0.1s linear;
}

.pagination { display: flex; gap: var(--sp-2); margin-top: var(--sp-7); flex-wrap: wrap; }
.pagination .page-numbers {
  padding: var(--sp-2) var(--sp-4);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--text);
}
.pagination .page-numbers.current { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }

.skip-link {
  position: absolute; left: -9999px;
  background: var(--accent); color: var(--accent-text);
  padding: var(--sp-3) var(--sp-4); border-radius: var(--radius); z-index: 100;
}
.skip-link:focus { left: var(--sp-4); top: var(--sp-4); }

.screen-reader-text {
  position: absolute; width: 1px; height: 1px;
  overflow: hidden; clip-path: inset(50%); white-space: nowrap;
}

/* WordPress core alignment classes */
.alignwide { max-width: min(100%, 1100px); margin-inline: auto; }
.alignfull { width: 100vw; margin-inline: calc(50% - 50vw); max-width: none; }
.aligncenter { margin-inline: auto; }

/* progressive enhancement — smooth page transitions where supported */
@view-transition { navigation: auto; }

/* ============================================================
   forms, comments, search
   WordPress emits these with no styling of its own, so a theme
   that skips them looks unfinished the moment anyone comments.
   ============================================================ */

:is(input[type="text"], input[type="email"], input[type="url"],
    input[type="search"], input[type="password"], textarea, select) {
  width: 100%;
  max-width: 100%;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--sp-3) var(--sp-4);
  font-size: var(--step-0);
  line-height: 1.5;
  transition: border-color 0.15s var(--ease), box-shadow 0.15s var(--ease);
}

:is(input, textarea, select):focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

textarea { min-height: 9rem; resize: vertical; }

/* NOTE: :is() inherits the specificity of its MOST specific argument,
   so input[type="submit"] (0,1,1) would otherwise outrank .icon-btn
   (0,1,0) and repaint the header icons. Excluded explicitly. */
:is(button:not(.icon-btn), input[type="submit"], .wp-block-search__button, .btn):not(.icon-btn) {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  background: var(--accent);
  color: var(--accent-text);
  border: 1px solid transparent;
  border-radius: var(--radius);
  padding: var(--sp-3) var(--sp-5);
  font-size: var(--step--1);
  font-weight: 560;
  cursor: pointer;
  transition: filter 0.15s var(--ease), transform 0.1s var(--ease);
}

:is(button:not(.icon-btn), input[type="submit"]):hover { filter: brightness(1.08); }
:is(button:not(.icon-btn), input[type="submit"]):active { transform: translateY(1px); }

/* search form */
.search-form, .wp-block-search__inside-wrapper {
  display: flex;
  gap: var(--sp-2);
}
.search-form label { flex: 1; }

/* comments */
.comments-area {
  margin-top: var(--sp-8);
  padding-top: var(--sp-7);
  border-top: 1px solid var(--border);
  max-width: var(--measure);
}

.comments-area :is(h2, h3) { font-size: var(--step-1); margin-bottom: var(--sp-5); }

.comment-list { list-style: none; padding: 0; display: grid; gap: var(--sp-5); }

.comment-list .comment-body {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--sp-5);
}

.comment-author { display: flex; align-items: center; gap: var(--sp-3); font-weight: 560; }
.comment-author img { border-radius: 50%; }
.comment-metadata { font-size: var(--step--1); color: var(--text-mute); margin-top: var(--sp-1); }
.comment-content { margin-top: var(--sp-3); }
.comment-list .children { list-style: none; margin-top: var(--sp-4); padding-inline-start: var(--sp-5); }

.comment-form { display: grid; gap: var(--sp-4); margin-top: var(--sp-5); }
.comment-form label { display: block; font-size: var(--step--1); font-weight: 560; margin-bottom: var(--sp-2); }
.comment-form .comment-form-cookies-consent { display: flex; align-items: center; gap: var(--sp-2); }
.comment-form .comment-form-cookies-consent input { width: auto; }
.comment-form .comment-notes { font-size: var(--step--1); color: var(--text-mute); }
.comment-form .form-submit { margin: 0; }
.comment-reply-link { font-size: var(--step--1); font-weight: 560; }

/* widget lists that WordPress renders itself */
.widget :is(ol, ul) { list-style: none; padding: 0; display: grid; gap: var(--sp-3); }
.widget li { line-height: 1.5; }
.widget select { margin-top: var(--sp-2); }
