/* ==========================================================================
   Theme: shades of white, black and gray, with blue where it is useful.
   Light and dark, no dependencies. Colors live in the tokens below, so
   re-theming the whole site means editing a handful of values.

   1 Fonts   2 Tokens   3 Base   4 Layout   5 Header   6 Buttons   7 Home
   8 Posts   9 Pagination and blog search   10 Article   11 Exercises   12 Footer   13 Misc
   ========================================================================== */


/* 1 · Fonts (Inter, self-hosted: nothing is loaded from third parties) ------- */
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("../fonts/inter-latin-wght-normal.woff2") format("woff2");
}


/* 2 · Tokens ------------------------------------------------------------------ */
:root {
  color-scheme: light;

  --font-sans: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;

  /* neutrals */
  --bg: #ffffff;
  --bg-soft: #fafafa;
  --bg-muted: #f4f4f5;
  --text: #09090b;
  --text-prose: #27272a;
  --text-soft: #3f3f46;
  --text-muted: #6b6b74;
  --line: #e4e4e7;
  --line-strong: #d4d4d8;

  /* blue */
  --blue: #2563eb;
  --blue-text: #1d4ed8;
  --blue-soft: #eff6ff;
  --blue-line: #bfdbfe;
  --focus: #2563eb;

  /* buttons: black on light, white on dark */
  --btn-bg: #09090b;
  --btn-bg-hover: #27272a;
  --btn-fg: #ffffff;
  --btn-accent: #2563eb;
  --btn-accent-hover: #1d4ed8;

  /* exercise feedback */
  --ok: #15803d;
  --ok-soft: #f0fdf4;
  --ok-line: #86efac;
  --bad: #b91c1c;
  --bad-soft: #fef2f2;
  --bad-line: #fca5a5;

  /* effects */
  --header-bg: rgba(255, 255, 255, 0.8);
  --dot: #d4d4d8;
  --glow: rgba(37, 99, 235, 0.12);
  --shadow: 0 1px 2px rgba(9, 9, 11, 0.04), 0 10px 28px -14px rgba(9, 9, 11, 0.22);

  --radius: 12px;
  --radius-lg: 18px;
  --container: 1080px;
  --measure: 720px;
}

/* Dark theme: chosen with the toggle (data-theme) ... */
:root[data-theme="dark"] {
  color-scheme: dark;

  --bg: #09090b;
  --bg-soft: #0f0f12;
  --bg-muted: #18181b;
  --text: #fafafa;
  --text-prose: #e4e4e7;
  --text-soft: #d4d4d8;
  --text-muted: #a1a1aa;
  --line: #27272a;
  --line-strong: #3f3f46;

  --blue: #3b82f6;
  --blue-text: #7db0fb;
  --blue-soft: rgba(59, 130, 246, 0.14);
  --blue-line: rgba(125, 176, 251, 0.38);
  --focus: #7db0fb;

  --btn-bg: #fafafa;
  --btn-bg-hover: #e4e4e7;
  --btn-fg: #09090b;
  --btn-accent: #2563eb;
  --btn-accent-hover: #1d4ed8;

  --ok: #4ade80;
  --ok-soft: rgba(34, 197, 94, 0.12);
  --ok-line: rgba(74, 222, 128, 0.45);
  --bad: #f87171;
  --bad-soft: rgba(239, 68, 68, 0.12);
  --bad-line: rgba(248, 113, 113, 0.45);

  --header-bg: rgba(9, 9, 11, 0.78);
  --dot: #27272a;
  --glow: rgba(59, 130, 246, 0.2);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 14px 34px -16px rgba(0, 0, 0, 0.75);
}

/* ... or followed from the operating system when JavaScript is off (same values). */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]):not([data-theme="dark"]) {
    color-scheme: dark;

    --bg: #09090b;
    --bg-soft: #0f0f12;
    --bg-muted: #18181b;
    --text: #fafafa;
    --text-prose: #e4e4e7;
    --text-soft: #d4d4d8;
    --text-muted: #a1a1aa;
    --line: #27272a;
    --line-strong: #3f3f46;

    --blue: #3b82f6;
    --blue-text: #7db0fb;
    --blue-soft: rgba(59, 130, 246, 0.14);
    --blue-line: rgba(125, 176, 251, 0.38);
    --focus: #7db0fb;

    --btn-bg: #fafafa;
    --btn-bg-hover: #e4e4e7;
    --btn-fg: #09090b;

    --ok: #4ade80;
    --ok-soft: rgba(34, 197, 94, 0.12);
    --ok-line: rgba(74, 222, 128, 0.45);
    --bad: #f87171;
    --bad-soft: rgba(239, 68, 68, 0.12);
    --bad-line: rgba(248, 113, 113, 0.45);

    --header-bg: rgba(9, 9, 11, 0.78);
    --dot: #27272a;
    --glow: rgba(59, 130, 246, 0.2);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 14px 34px -16px rgba(0, 0, 0, 0.75);
  }
}


/* 3 · Base -------------------------------------------------------------------- */
*,
*::before,
*::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: 5rem;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 1.0625rem;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

main { flex: 1 0 auto; }

h1, h2, h3, h4 {
  margin: 0;
  color: var(--text);
  font-weight: 650;
  line-height: 1.2;
  letter-spacing: -0.02em;
  text-wrap: balance;
}

p { margin: 0 0 1em; }

a { color: var(--blue-text); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }

img { max-width: 100%; height: auto; }

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

::selection { background: var(--blue-soft); color: var(--text); }

[hidden] { display: none !important; }

.icon { flex: none; width: 1.125em; height: 1.125em; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  top: -4rem;
  left: 0.75rem;
  z-index: 100;
  padding: 0.6rem 1rem;
  border-radius: 10px;
  background: var(--btn-bg);
  color: var(--btn-fg);
  font-weight: 600;
}
.skip-link:focus { top: 0.75rem; text-decoration: none; }


/* 4 · Layout ------------------------------------------------------------------ */
.container { width: min(var(--container), 100% - 2rem); margin-inline: auto; }
.container-text { width: min(var(--measure), 100% - 2rem); }

@media (min-width: 640px) {
  .container { width: min(var(--container), 100% - 3rem); }
  .container-text { width: min(var(--measure), 100% - 3rem); }
}


/* 5 · Header ------------------------------------------------------------------ */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  border-bottom: 1px solid var(--line);
  background: var(--header-bg);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  backdrop-filter: saturate(180%) blur(14px);
}

.header-inner { display: flex; align-items: center; gap: 0.5rem; min-height: 4rem; }

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  margin-right: auto;
  color: var(--text);
  font-weight: 650;
  letter-spacing: -0.015em;
  line-height: 1;
}
.brand:hover { text-decoration: none; }
.brand-mark { flex: none; width: 34px; height: 26px; }
.brand-short { display: none; }

@media (max-width: 479px) {
  .brand-full { display: none; }
  .brand-short { display: inline; }
}

.nav { display: flex; gap: 0.125rem; }
.nav a {
  padding: 0.45rem 0.8rem;
  border-radius: 999px;
  color: var(--text-muted);
  font-size: 0.9375rem;
  font-weight: 500;
}
.nav a:hover { background: var(--bg-muted); color: var(--text); text-decoration: none; }
.nav a[aria-current="page"] { background: var(--bg-muted); color: var(--text); }

.theme-toggle {
  display: inline-grid;
  place-items: center;
  width: 2.5rem;
  height: 2.5rem;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
}
.theme-toggle:hover { background: var(--bg-muted); color: var(--text); }
.theme-toggle .icon { width: 1.2rem; height: 1.2rem; }
.theme-toggle .icon-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: block; }


/* 6 · Buttons ----------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  height: 2.75rem;
  padding: 0 1.15rem;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font: inherit;
  font-size: 0.9375rem;
  font-weight: 550;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.btn:hover { text-decoration: none; }

.btn-primary { background: var(--btn-bg); color: var(--btn-fg); }
.btn-primary:hover { background: var(--btn-bg-hover); }

.btn-secondary { border-color: var(--line-strong); background: var(--bg); color: var(--text); }
.btn-secondary:hover { background: var(--bg-muted); }

.btn-accent { background: var(--btn-accent); color: #fff; }
.btn-accent:hover { background: var(--btn-accent-hover); }

.btn-sm { height: 2.25rem; padding: 0 0.9rem; border-radius: 10px; font-size: 0.875rem; }


/* 7 · Home -------------------------------------------------------------------- */
.hero {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  padding: clamp(3.5rem, 10vw, 7.5rem) 0 clamp(2.75rem, 6vw, 4.5rem);
}
/* faint dot grid that fades out downwards */
.hero::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background-image: radial-gradient(var(--dot) 1px, transparent 1.3px);
  background-position: center top;
  background-size: 22px 22px;
  -webkit-mask-image: radial-gradient(ellipse 75% 85% at 50% 0%, #000 10%, transparent 72%);
  mask-image: radial-gradient(ellipse 75% 85% at 50% 0%, #000 10%, transparent 72%);
}
/* soft blue glow */
.hero::after {
  content: "";
  position: absolute;
  top: -14rem;
  left: 50%;
  z-index: -1;
  width: min(56rem, 140vw);
  height: 26rem;
  transform: translateX(-50%);
  background: radial-gradient(closest-side, var(--glow), transparent);
  pointer-events: none;
}

.hero-title {
  max-width: 15em;
  font-size: clamp(2.4rem, 6.6vw, 4.25rem);
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: -0.04em;
}
.hero-title-soft { color: var(--text-muted); }

.hero-lead {
  max-width: 36rem;
  margin: 1.5rem 0 0;
  color: var(--text-soft);
  font-size: clamp(1.0625rem, 2.2vw, 1.25rem);
  line-height: 1.6;
}

.hero-actions { display: flex; flex-wrap: wrap; gap: 0.75rem; margin-top: 2rem; }

/* Home sections: a small label on the left, content on the right */
.row {
  display: grid;
  gap: 1.25rem;
  padding-block: clamp(2.25rem, 5vw, 3.75rem);
  border-top: 1px solid var(--line);
}

@media (min-width: 900px) {
  .row { grid-template-columns: 11rem minmax(0, 1fr); column-gap: 3rem; }
}

.row-label {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.row-label-wrap { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; }

@media (min-width: 900px) {
  .row-label-wrap { flex-direction: column; align-items: flex-start; justify-content: flex-start; gap: 0.75rem; }
}

.row-body { min-width: 0; }
.row-intro { margin: 0 0 1rem; color: var(--text-soft); }

.about-text p { max-width: 40rem; color: var(--text-soft); font-size: 1.125rem; line-height: 1.7; }
.about-text p:last-child { margin-bottom: 0; }

.link-arrow { display: inline-flex; align-items: center; gap: 0.35rem; font-size: 0.9375rem; font-weight: 550; }
.link-arrow .icon { transition: transform 0.15s ease; }
.link-arrow:hover { text-decoration: none; }
.link-arrow:hover .icon { transform: translateX(3px); }

/* Contact */
/* Cards sit side by side only when each one has room for a full Telegram handle or email address; otherwise they stack. */
.contact-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 21rem), 1fr));
  gap: 0.75rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.contact-item {
  display: flex;
  align-items: center;
  gap: 0.875rem;
  height: 100%;
  padding: 0.875rem 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  transition: border-color 0.18s ease, background-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
}
.contact-item:hover { border-color: var(--line-strong); background: var(--bg-soft); box-shadow: var(--shadow); transform: translateY(-2px); text-decoration: none; }

.contact-icon {
  display: grid;
  flex: none;
  place-items: center;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 10px;
  background: var(--bg-muted);
  color: var(--text);
}
.contact-icon .icon { width: 1.25rem; height: 1.25rem; }

.contact-text { display: block; min-width: 0; }
.contact-label { display: block; color: var(--text-muted); font-size: 0.8125rem; line-height: 1.3; }
.contact-value { display: block; font-weight: 600; line-height: 1.35; overflow-wrap: anywhere; }
.contact-arrow { margin-left: auto; color: var(--text-muted); transition: transform 0.15s ease, color 0.15s ease; }
.contact-item:hover .contact-arrow { color: var(--blue-text); transform: translate(2px, -2px); }

/* Very narrow phones (for example a folded foldable): slightly tighter cards, so a Telegram handle still fits on one line. */
@media (max-width: 359px) {
  .contact-item { gap: 0.625rem; padding-inline: 0.75rem; }
  .contact-icon { width: 2.25rem; height: 2.25rem; }
  .contact-value { font-size: 0.9375rem; }
}

/* Projects */
.project-grid { display: grid; gap: 1rem; }
@media (min-width: 700px) { .project-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

.project-card {
  position: relative;
  display: flex;
  flex-direction: column;
  padding: 1.5rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--bg);
  transition: border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
}
.project-card:hover { border-color: var(--line-strong); box-shadow: var(--shadow); transform: translateY(-2px); }
.project-card:has(a:focus-visible) { outline: 2px solid var(--focus); outline-offset: 2px; }

.project-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.25rem; }

.project-icon {
  display: grid;
  place-items: center;
  width: 2.5rem;
  height: 2.5rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg-muted);
  color: var(--text);
}
.project-icon .icon { width: 1.2rem; height: 1.2rem; }

.project-arrow { color: var(--text-muted); transition: transform 0.18s ease, color 0.18s ease; }
.project-card:hover .project-arrow { color: var(--blue-text); transform: translate(2px, -2px); }

.project-name { font-size: 1.25rem; letter-spacing: -0.02em; }
.project-name a { color: var(--text); }
.project-name a:hover { text-decoration: none; }
/* stretched link: the whole card is clickable */
.project-name a::after { content: ""; position: absolute; inset: 0; border-radius: var(--radius-lg); }

.project-subtitle { margin: 0.25rem 0 0; color: var(--text-muted); font-size: 0.875rem; }
.project-desc { margin: 0.875rem 0 1.5rem; color: var(--text-soft); font-size: 1rem; line-height: 1.6; }
.project-url { margin: auto 0 0; color: var(--text-muted); font-family: var(--font-mono); font-size: 0.8125rem; }


/* 8 · Posts (lists, badges, page headings) -------------------------------------- */
.post-list { display: grid; }

.post-item { position: relative; padding: 1.5rem 0; border-top: 1px solid var(--line); }
.post-item:first-child { padding-top: 0; border-top: 0; }

.post-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem 0.5rem;
  color: var(--text-muted);
  font-size: 0.8125rem;
  font-variant-numeric: tabular-nums;
}
.meta-item + .meta-item::before { content: "\00b7"; margin-right: 0.5rem; }

.badge {
  display: inline-flex;
  align-items: center;
  margin-right: 0.25rem;
  padding: 0.125rem 0.6rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--bg-muted);
  color: var(--text-soft);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  line-height: 1.5;
}
.badge-accent { border-color: var(--blue-line); background: var(--blue-soft); color: var(--blue-text); }

.post-title { margin-top: 0.6rem; font-size: clamp(1.25rem, 2.6vw, 1.5rem); letter-spacing: -0.025em; }
.post-title a { color: var(--text); }
.post-title a:hover { color: var(--blue-text); text-decoration: none; }
.post-title a::after { content: ""; position: absolute; inset: 0; }

.post-excerpt { max-width: 42rem; margin: 0.5rem 0 0; color: var(--text-soft); }
.empty { color: var(--text-muted); }

.page-head { padding: clamp(2.5rem, 7vw, 5rem) 0 clamp(1.5rem, 4vw, 2.5rem); }
.eyebrow {
  margin: 0 0 0.75rem;
  color: var(--text-muted);
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.page-title { font-size: clamp(2.25rem, 5.5vw, 3.25rem); font-weight: 700; line-height: 1.08; letter-spacing: -0.035em; }
.page-lead { max-width: 34rem; margin: 1rem 0 0; color: var(--text-soft); font-size: 1.1875rem; }
.page-actions { margin-top: 1.5rem; }

.blog-list { padding-top: 2rem; padding-bottom: clamp(3rem, 7vw, 5rem); border-top: 1px solid var(--line); }


/* 9 · Pagination -------------------------------------------------------------- */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--line);
}

.pagination-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  height: 2.5rem;
  padding: 0 0.9rem;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  color: var(--text);
  font-size: 0.9375rem;
  font-weight: 550;
}
a.pagination-btn:hover { background: var(--bg-muted); text-decoration: none; }
.pagination-btn.is-disabled { border-color: var(--line); color: var(--text-muted); opacity: 0.55; }

.pagination-pages { display: flex; gap: 0.25rem; margin: 0; padding: 0; list-style: none; }
.pagination-pages a,
.pagination-pages [aria-current] {
  display: inline-grid;
  place-items: center;
  min-width: 2.5rem;
  height: 2.5rem;
  padding: 0 0.5rem;
  border-radius: 10px;
  color: var(--text-soft);
  font-size: 0.9375rem;
  font-weight: 550;
  font-variant-numeric: tabular-nums;
}
.pagination-pages a:hover { background: var(--bg-muted); color: var(--text); text-decoration: none; }
.pagination-pages [aria-current] { background: var(--btn-bg); color: var(--btn-fg); }

.pagination-gap { display: inline-grid; place-items: center; min-width: 1.5rem; height: 2.5rem; color: var(--text-muted); }
.pagination-summary { display: none; margin: 0; color: var(--text-soft); font-size: 0.9375rem; font-weight: 550; font-variant-numeric: tabular-nums; }

@media (max-width: 520px) {
  .pagination-many .pagination-pages { display: none; }
  .pagination-many .pagination-summary { display: block; }
  .pagination-btn span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .pagination-btn { padding: 0; width: 2.5rem; justify-content: center; }
}


/* 9b · Blog search and topics --------------------------------------------------- */
/* The search box needs JavaScript, so it is only shown when head.html has added the "js" class to <html>. */
.blog-tools { display: none; margin-top: 2.25rem; }
.js .blog-tools { display: block; }

.search { position: relative; }
.search-icon { position: absolute; top: 50%; left: 1rem; width: 1.15rem; height: 1.15rem; color: var(--text-muted); transform: translateY(-50%); pointer-events: none; }
.search-input {
  display: block;
  width: 100%;
  height: 3rem;
  padding: 0 1rem 0 2.85rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 1rem;
  appearance: none;
}
.search-input::placeholder { color: var(--text-muted); opacity: 1; }
.search-input:hover { border-color: var(--text-muted); }
.search-input:focus-visible { border-color: var(--focus); border-radius: var(--radius); outline-offset: 1px; }

.filter-row { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.5rem 1rem; margin-top: 1.125rem; }
.filter-label { flex: none; width: 4.5rem; color: var(--text-muted); font-size: 0.75rem; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; }
.chips { display: flex; flex: 1 1 0; flex-wrap: wrap; gap: 0.5rem; min-width: 0; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  min-height: 2rem;
  padding: 0.25rem 0.85rem;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--bg);
  color: var(--text-soft);
  font: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1.25;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.chip:hover { background: var(--bg-muted); color: var(--text); }
.chip:focus-visible { border-radius: 999px; }
.chip[aria-pressed="true"] { border-color: var(--btn-bg); background: var(--btn-bg); color: var(--btn-fg); }
.chip[aria-pressed="true"]:hover { background: var(--btn-bg-hover); color: var(--btn-fg); }
.chip-count { color: var(--text-muted); font-size: 0.75rem; font-variant-numeric: tabular-nums; }
.chip[aria-pressed="true"] .chip-count { color: inherit; opacity: 0.75; }
.chip-more { border-style: dashed; color: var(--text-muted); }

.results-bar { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; margin-bottom: 1.5rem; }
.results-status { margin: 0; color: var(--text-soft); font-size: 0.9375rem; }
.link-button { flex: none; padding: 0; border: 0; background: none; color: var(--blue-text); font: inherit; font-size: 0.9375rem; font-weight: 550; cursor: pointer; }
.link-button:hover { text-decoration: underline; }
.results-more { margin-top: 1.5rem; }

@media (max-width: 560px) {
  .filter-label { width: 100%; }
  .chips { flex-basis: 100%; }
}


/* 10 · Article ---------------------------------------------------------------- */
.post { padding-top: clamp(1.5rem, 4vw, 2.5rem); padding-bottom: clamp(3rem, 7vw, 5rem); }

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 2rem;
  color: var(--text-muted);
  font-size: 0.9375rem;
  font-weight: 500;
}
.back-link:hover { color: var(--text); text-decoration: none; }
.back-link .icon { transition: transform 0.15s ease; }
.back-link:hover .icon { transform: translateX(-3px); }

.post-header { margin-bottom: 2.5rem; }
.post-heading { margin-top: 1rem; font-size: clamp(2rem, 5vw, 2.875rem); font-weight: 700; line-height: 1.1; letter-spacing: -0.035em; }
.post-lead { margin: 1rem 0 0; color: var(--text-soft); font-size: 1.25rem; line-height: 1.55; }

.tag-list { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 1.25rem 0 0; padding: 0; list-style: none; }
.tag-list a { display: inline-block; padding: 0.15rem 0.65rem; border: 1px solid var(--line); border-radius: 999px; color: var(--text-muted); font-size: 0.8125rem; transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease; }
.tag-list a:hover { border-color: var(--blue-line); background: var(--blue-soft); color: var(--blue-text); text-decoration: none; }
.tag-list a:focus-visible { border-radius: 999px; }

/* Long-form text */
.prose { color: var(--text-prose); font-size: 1.125rem; line-height: 1.75; overflow-wrap: break-word; }
.prose > :first-child { margin-top: 0; }
.prose h2 { margin: 2.75rem 0 0.75rem; font-size: 1.625rem; letter-spacing: -0.025em; }
.prose h3 { margin: 2rem 0 0.5rem; font-size: 1.25rem; }
.prose p,
.prose ul,
.prose ol,
.prose blockquote,
.prose pre,
.prose details { margin: 0 0 1.25rem; }
.prose ul,
.prose ol { padding-left: 1.4rem; }
.prose li { margin: 0.35rem 0; }
.prose li::marker { color: var(--text-muted); }
.prose a { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; }
.prose a:hover { text-decoration-thickness: 2px; }
.prose strong { color: var(--text); font-weight: 650; }
.prose hr { margin: 2.5rem 0; border: 0; border-top: 1px solid var(--line); }
.prose img { border-radius: var(--radius); }

.prose blockquote { padding: 0.25rem 0 0.25rem 1.25rem; border-left: 3px solid var(--line-strong); color: var(--text-soft); }
.prose blockquote > :last-child { margin-bottom: 0; }

.prose code {
  padding: 0.1em 0.35em;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg-muted);
  font-family: var(--font-mono);
  font-size: 0.88em;
}
.prose pre {
  padding: 1rem 1.1rem;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-soft);
  font-size: 0.9rem;
  line-height: 1.6;
}
.prose pre code { padding: 0; border: 0; background: none; font-size: inherit; }
.prose .highlight { margin: 0 0 1.25rem; }
.prose .highlight pre { margin: 0; }
.highlight .c, .highlight .c1, .highlight .cm { color: var(--text-muted); font-style: italic; }
.highlight .k, .highlight .kd, .highlight .kn, .highlight .kr, .highlight .nt { color: var(--blue-text); }
.highlight .s, .highlight .s1, .highlight .s2, .highlight .se { color: var(--ok); }

/* Tables sit in a wrapper (added in _layouts/post.html): it scrolls sideways when the table is wider than the screen. */
.prose .table-wrap { max-width: 100%; margin: 0 0 1.25rem; overflow-x: auto; }
.prose table { border-collapse: collapse; font-size: 1rem; }
.prose th,
.prose td { padding: 0.6rem 0.9rem; border: 1px solid var(--line); text-align: left; vertical-align: top; }
.prose th { background: var(--bg-muted); color: var(--text); font-weight: 600; }
@media (max-width: 479px) { .prose th, .prose td { padding: 0.5rem 0.65rem; } }

.prose details { padding: 0 1.1rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg-soft); }
.prose summary { padding: 0.85rem 0; color: var(--text); font-weight: 600; cursor: pointer; }
.prose details[open] summary { margin-bottom: 0.85rem; border-bottom: 1px solid var(--line); }
.prose details > :last-child { margin-bottom: 1.1rem; }

/* Helpers you can use in posts */
.note {
  padding: 0.9rem 1.1rem;
  border-left: 3px solid var(--blue);
  border-radius: 0 var(--radius) var(--radius) 0;
  background: var(--blue-soft);
  color: var(--text);
  font-size: 1.0625rem;
}
.prose p.ok,
.prose p.no { position: relative; margin-bottom: 0.5rem; padding-left: 1.75rem; }
.prose p.ok::before,
.prose p.no::before { position: absolute; top: 0; left: 0; font-weight: 700; }
.prose p.ok::before { content: "\2713"; color: var(--ok); }
.prose p.no::before { content: "\2717"; color: var(--bad); }

/* End of post: share + follow, and neighbors */
.post-footer { margin-top: 3.5rem; }

.share-card {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1.25rem 2rem;
  padding: 1.5rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--bg-soft);
}
.share-title { font-size: 1.125rem; letter-spacing: -0.015em; }
.share-text { margin: 0.25rem 0 0; color: var(--text-muted); font-size: 0.9375rem; }
.post-discuss { margin: 0 0 1.25rem; color: var(--text-soft); }
.post-discuss a { text-decoration: underline; text-underline-offset: 0.2em; text-decoration-thickness: 1px; }
.share-actions { display: flex; flex-wrap: wrap; gap: 0.75rem; }

.post-nav { display: grid; gap: 1rem; margin-top: 1rem; }
.post-nav > span:empty { display: none; }
@media (min-width: 640px) {
  .post-nav { grid-template-columns: 1fr 1fr; }
  .post-nav > span:empty { display: block; }
}
.post-nav-link {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 1.1rem 1.25rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
}
.post-nav-link:hover { border-color: var(--line-strong); background: var(--bg-soft); text-decoration: none; }
.post-nav-link.is-older { align-items: flex-end; text-align: right; }
.post-nav-label {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: var(--text-muted);
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.post-nav-title { font-weight: 600; line-height: 1.35; }


/* 11 · Interactive exercises ---------------------------------------------------- */
.exercise {
  margin-top: 3rem;
  padding: clamp(1.25rem, 3.5vw, 2rem);
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--bg-soft);
}
.exercise-head h2 { font-size: 1.375rem; letter-spacing: -0.02em; }
.exercise-head p { margin: 0.35rem 0 0; color: var(--text-soft); }

.ex-list { display: grid; gap: 0.875rem; margin: 1.5rem 0 0; padding: 0; list-style: none; }

.ex-q {
  padding: 1.1rem 1.2rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg);
  transition: border-color 0.15s ease;
}
.ex-q.is-correct { border-color: var(--ok-line); }
.ex-q.is-wrong { border-color: var(--bad-line); }

.ex-prompt { display: flex; align-items: flex-start; gap: 0.8rem; margin: 0; color: var(--text); font-size: 1.0625rem; font-weight: 550; line-height: 1.6; }
.ex-text { min-width: 0; }
.ex-num {
  display: grid;
  flex: none;
  place-items: center;
  width: 1.75rem;
  height: 1.75rem;
  margin-top: 0.05rem;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--bg-soft);
  color: var(--text-soft);
  font-size: 0.8125rem;
  font-weight: 600;
}
.is-correct .ex-num { border-color: var(--ok-line); background: var(--ok-soft); color: var(--ok); }
.is-wrong .ex-num { border-color: var(--bad-line); background: var(--bad-soft); color: var(--bad); }

.ex-blank {
  display: inline-block;
  min-width: 3.25em;
  margin: 0 0.15em;
  padding: 0 0.35em;
  border-bottom: 2px solid var(--line-strong);
  color: var(--blue-text);
  font-weight: 650;
  text-align: center;
}
.ex-blank.is-filled { border-bottom-color: var(--blue); }

/* everything under a question lines up with the text, not the number */
.ex-options,
.ex-fill-row,
.ex-line,
.ex-bank,
.ex-line-tools,
.ex-feedback { margin-left: 2.55rem; }

.ex-options { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.9rem; }
.ex-opt { position: relative; display: inline-flex; }
.ex-opt input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.ex-opt-ui {
  display: inline-flex;
  align-items: center;
  min-height: 2.5rem;
  padding: 0.4rem 0.95rem;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  font-size: 0.9375rem;
  font-weight: 500;
  transition: border-color 0.15s ease, background-color 0.15s ease, color 0.15s ease;
}
.ex-opt:hover .ex-opt-ui { border-color: var(--text-muted); }
.ex-opt input:checked + .ex-opt-ui { border-color: var(--blue); background: var(--blue-soft); color: var(--blue-text); }
.ex-opt input:focus-visible + .ex-opt-ui { outline: 2px solid var(--focus); outline-offset: 2px; }
.ex-opt.is-answer input + .ex-opt-ui { border-color: var(--ok); background: var(--ok-soft); color: var(--ok); }
.ex-opt.is-wrong-pick input + .ex-opt-ui { border-color: var(--bad); background: var(--bad-soft); color: var(--bad); }

.ex-fill-row { margin-top: 0.75rem; }
.ex-input {
  width: 11rem;
  max-width: 100%;
  margin: 0 0.2em;
  padding: 0.3rem 0.65rem;
  border: 1px solid var(--line-strong);
  border-bottom-width: 2px;
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-weight: 500;
}
.ex-input:focus { border-color: var(--focus); outline: 2px solid var(--focus); outline-offset: 1px; }
.is-correct .ex-input { border-color: var(--ok); }
.is-wrong .ex-input { border-color: var(--bad); }

.ex-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  min-height: 3.5rem;
  margin-top: 0.9rem;
  padding: 0.6rem;
  border: 1.5px dashed var(--line-strong);
  border-radius: var(--radius);
  background: var(--bg-soft);
}
.ex-line:empty::before { content: attr(data-placeholder); padding: 0 0.4rem; color: var(--text-muted); font-size: 0.9375rem; }
.is-correct .ex-line { border-style: solid; border-color: var(--ok-line); }
.is-wrong .ex-line { border-style: solid; border-color: var(--bad-line); }

.ex-bank { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.75rem; }
.ex-token {
  padding: 0.45rem 0.85rem;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 0.9375rem;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 0.15s ease;
}
.ex-token:hover { border-color: var(--text-muted); }
.ex-end { align-self: center; margin-left: -0.3rem; color: var(--text-soft); font-weight: 600; }
.ex-line .ex-token { border-color: var(--blue-line); background: var(--blue-soft); color: var(--blue-text); }

.ex-line-tools { min-height: 1.25rem; margin-top: 0.5rem; }
.ex-clear { padding: 0; border: 0; background: none; color: var(--text-muted); font: inherit; font-size: 0.875rem; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.ex-clear:hover { color: var(--text); }

.ex-feedback { margin-top: 0.9rem; font-size: 0.9375rem; line-height: 1.55; }
.ex-verdict { display: flex; flex-wrap: wrap; align-items: center; gap: 0.35rem; margin: 0; }
.ex-verdict .icon { width: 1.1rem; height: 1.1rem; }
.is-correct .ex-verdict { color: var(--ok); }
.is-wrong .ex-verdict { color: var(--bad); }
.ex-verdict .ex-answer { color: var(--text); }
.ex-explain { margin: 0.35rem 0 0; color: var(--text-soft); }

.ex-actions { display: flex; flex-wrap: wrap; gap: 0.75rem; margin-top: 1.5rem; }

.ex-result.is-visible {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem 1.5rem;
  margin-top: 1.25rem;
  padding: 1.1rem 1.35rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--bg);
}
.ex-score { margin: 0; color: var(--text-muted); }
.ex-score strong { color: var(--text); font-size: 2rem; font-weight: 700; letter-spacing: -0.03em; }
.ex-message { margin: 0.15rem 0 0; color: var(--text-soft); }

@media (max-width: 480px) {
  .ex-options,
  .ex-fill-row,
  .ex-line,
  .ex-bank,
  .ex-line-tools,
  .ex-feedback { margin-left: 0; }
  .ex-q { padding: 1rem; }
}


/* 12 · Footer ----------------------------------------------------------------- */
.site-footer { padding-bottom: 2.5rem; color: var(--text-muted); font-size: 0.875rem; }
.footer-inner { padding-top: 2rem; border-top: 1px solid var(--line); }
.footer-top { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 1rem 1.5rem; }
.footer-bottom { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.35rem 1.5rem; margin-top: 1.5rem; }
.footer-bottom p { margin: 0; }
.footer-contact { display: flex; flex-wrap: wrap; align-items: center; gap: 0.35rem 1.25rem; }
.footer-contact-label { color: var(--text-muted); }
.footer-contact a { display: inline-flex; align-items: center; gap: 0.4rem; color: var(--text); text-decoration: none; padding-block: 0.25rem; }
.footer-contact a:hover { color: var(--blue-text); text-decoration: underline; }


/* 13 · Motion and print ------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *,
  *::before,
  *::after { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
  .project-card:hover, .contact-item:hover { transform: none; }
}

@media print {
  .site-header,
  .site-footer,
  .share-card,
  .post-nav,
  .back-link,
  .skip-link,
  .ex-actions { display: none !important; }
  body { background: #fff; color: #000; }
  .hero::before, .hero::after { display: none; }
  .prose a::after { content: " (" attr(href) ")"; font-size: 0.85em; }
}
