/* hhyurdagul.com — hand-written, component-scoped CSS (native nesting).
 *
 * Theme: every color is a token defined with light-dark(). The page follows
 * the OS scheme; html[data-theme] (set by the inline script in base.html)
 * pins it. Nothing else needs to know which theme is active.
 */

/* ------------------------------------------------------------------ fonts */

@font-face {
  font-family: "Newsreader";
  font-style: normal;
  font-weight: 200 800;
  font-display: swap;
  src: url("../fonts/newsreader-latin-opsz-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Newsreader";
  font-style: normal;
  font-weight: 200 800;
  font-display: swap;
  src: url("../fonts/newsreader-latin-ext-opsz-normal.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Newsreader";
  font-style: italic;
  font-weight: 200 800;
  font-display: swap;
  src: url("../fonts/newsreader-latin-opsz-italic.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Newsreader";
  font-style: italic;
  font-weight: 200 800;
  font-display: swap;
  src: url("../fonts/newsreader-latin-ext-opsz-italic.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Plus Jakarta Sans";
  font-style: normal;
  font-weight: 200 800;
  font-display: swap;
  src: url("../fonts/plus-jakarta-sans-latin-wght-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Plus Jakarta Sans";
  font-style: normal;
  font-weight: 200 800;
  font-display: swap;
  src: url("../fonts/plus-jakarta-sans-latin-ext-wght-normal.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "JetBrains Mono";
  font-style: normal;
  font-weight: 100 800;
  font-display: swap;
  src: url("../fonts/jetbrains-mono-latin-wght-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "JetBrains Mono";
  font-style: normal;
  font-weight: 100 800;
  font-display: swap;
  src: url("../fonts/jetbrains-mono-latin-ext-wght-normal.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* ----------------------------------------------------------------- tokens */

:root {
  color-scheme: light dark;

  &[data-theme="light"] { color-scheme: light; }
  &[data-theme="dark"] { color-scheme: dark; }

  --bg:            light-dark(#FAF9F6, #0E0F12);
  --surface:       light-dark(#FFFFFF, #15161A);
  --surface-2:     light-dark(#F1F0EC, #1D1E23);
  --border:        light-dark(#ECEAE4, #222329);
  --border-strong: light-dark(#D6D3CC, #3A3B42);
  --text:          light-dark(#18181B, #F4F4F5);
  --text-2:        light-dark(#52525B, #A1A1AA);
  --muted:         light-dark(#71717A, #8B8B94);
  --prose:         light-dark(#27272A, #E4E4E7);
  --accent:        light-dark(#B24F37, #FBBF24);
  --accent-soft:   light-dark(rgb(194 89 63 / 0.08), rgb(251 191 36 / 0.1));
  --ok:            light-dark(#047857, #34D399);
  --ok-soft:       light-dark(rgb(16 185 129 / 0.1), rgb(52 211 153 / 0.1));
  --code-bg:       light-dark(#F4F3EF, #15161A);
  --selection:     light-dark(#E7E5E4, #27272A);
  --scrim:         rgb(0 0 0 / 0.4);

  --font-serif: "Newsreader", Georgia, serif;
  --font-sans: "Plus Jakarta Sans", system-ui, -apple-system, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, monospace;

  --radius: 0.75rem;
  --radius-lg: 1rem;
  --topbar-h: 3.25rem;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
}

/* ------------------------------------------------------------------- base */

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

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

  /* Lock page scroll while a drawer is open. */
  &:has(.sidebar:popover-open, .rail:popover-open) { overflow: hidden; }

  @media (width < 1024px) { scroll-padding-top: calc(var(--topbar-h) + 1rem); }
}

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font: 400 1rem/1.6 var(--font-sans);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

:is(h1, h2, h3, h4, p, ul, ol, dl, dd, figure, blockquote) { margin: 0; }
:is(ul, ol):where([class]) { list-style: none; padding: 0; }
img, svg, video { max-width: 100%; }
img, video { height: auto; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; cursor: pointer; }
::selection { background: var(--selection); }

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

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

.icon {
  width: 1rem;
  height: 1rem;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.skip-link {
  position: absolute;
  left: 1rem;
  top: -3rem;
  z-index: 100;
  padding: 0.5rem 0.75rem;
  border-radius: 0.5rem;
  background: var(--text);
  color: var(--bg);
  font-size: 0.875rem;

  &:focus { top: 1rem; }
}

/* ------------------------------------------------------------- primitives */

.eyebrow {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font: 500 0.75rem/1.4 var(--font-mono);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);

  &.accent { color: var(--accent); font-weight: 600; }
}

.meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem 0.75rem;
  font: 0.75rem/1.5 var(--font-mono);
  color: var(--muted);

  & .accent { color: var(--accent); font-weight: 500; }
}

.dot {
  display: inline-block;
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: #10B981;
  flex: none;

  &.pulse { animation: pulse 2s ease-out infinite; }
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgb(16 185 129 / 0.5); }
  70%, 100% { box-shadow: 0 0 0 0.4rem rgb(16 185 129 / 0); }
}

.badge {
  display: inline-block;
  padding: 0.125rem 0.5rem;
  border-radius: 0.375rem;
  background: var(--ok-soft);
  color: var(--ok);
  font: 500 0.75rem/1.5 var(--font-mono);
}

.pill {
  display: inline-flex;
  flex-wrap: wrap;
  column-gap: 0.5rem;
  padding: 0.25rem 0.75rem;
  border-radius: 0.5rem;
  background: var(--surface-2);
  color: var(--text-2);
  font: 0.75rem/1.5 var(--font-mono);

  & span { color: var(--muted); }
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;

  & li, & a {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.125rem 0.5rem;
    border-radius: 0.375rem;
    background: var(--surface-2);
    color: var(--text-2);
    font: 0.72rem/1.6 var(--font-mono);
  }
  & li:has(> a) { padding: 0; background: none; }
  & a { transition: color 0.15s, background-color 0.15s; }
  & a:hover { color: var(--accent); }
  & .accent { background: var(--accent-soft); color: var(--accent); }

  &.large {
    gap: 0.625rem;
    & a {
      padding: 0.625rem 0.875rem;
      border: 1px solid var(--border);
      border-radius: var(--radius);
      background: var(--surface);
      font-size: 0.875rem;
      color: var(--text);
    }
    & a:hover { border-color: var(--accent); }
    & span {
      padding: 0 0.5rem;
      border-radius: 999px;
      background: var(--surface-2);
      color: var(--muted);
      font-size: 0.75rem;
    }
  }
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.45rem 0.85rem;
  border: 1px solid var(--border-strong);
  border-radius: 0.6rem;
  font: 500 0.75rem/1.4 var(--font-mono);
  transition: background-color 0.15s, opacity 0.15s;

  &:hover { background: var(--surface-2); }

  &.primary {
    border-color: transparent;
    background: var(--text);
    color: var(--bg);
    &:hover { opacity: 0.85; }
  }
  &.block { display: flex; width: 100%; }
}

.accent-link {
  color: var(--accent);
  font: 0.75rem var(--font-mono);
  &:hover { text-decoration: underline; }
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: 0;
  border-radius: 0.5rem;
  background: none;
  color: var(--text-2);
  &:hover { color: var(--text); }
}

/* Theme toggle: show the icon for the theme you would switch *to*. Hidden
   without JS, where the page simply follows the OS. */
.theme-toggle {
  & .sun { display: none; }
  :root:not(.js) & { display: none; }
  :root[data-theme="dark"] & .sun { display: block; }
  :root[data-theme="dark"] & .moon { display: none; }
  @media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) & .sun { display: block; }
    :root:not([data-theme="light"]) & .moon { display: none; }
  }
}

/* Layout rhythm */
.stack { display: grid; gap: 1rem; }
.stack-lg { display: grid; gap: 2rem; }
.stack-xl { display: grid; gap: 3rem; }

/* ----------------------------------------------------------------- layout */

.shell {
  max-width: 1440px;
  margin-inline: auto;

  @media (width >= 1024px) {
    display: grid;
    grid-template-columns: 16rem minmax(0, 1fr) 20rem;
    min-height: 100dvh;
  }
}

.main {
  min-width: 0;
  max-width: 48rem;
  padding: 2rem 1.5rem 4rem;

  @media (width >= 640px) { padding-inline: 2.5rem; }
  @media (width >= 1024px) { padding: 3rem 3.5rem 5rem; }
}

/* Mobile top bar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 0.375rem;
  height: var(--topbar-h);
  padding-inline: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(12px);

  @media (width >= 1024px) { display: none; }

  & .brand {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font: 500 1.05rem var(--font-serif);
    letter-spacing: -0.01em;
  }

  & .menu-btn {
    & .icon { width: 1.25rem; height: 1.25rem; }
    & .close { display: none; }
    :root:has(.sidebar:popover-open) & .open { display: none; }
    :root:has(.sidebar:popover-open) & .close { display: block; }
  }
}

.context-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  height: 2rem;
  padding-inline: 0.625rem;
  border: 1px solid var(--border-strong);
  border-radius: 0.5rem;
  background: var(--surface-2);
  color: var(--text-2);
  font: 500 0.75rem var(--font-mono);

  & .icon { width: 0.875rem; height: 0.875rem; }
  @media (width < 390px) { & span { display: none; } }
}

/* Shared by both side columns. They are [popover] elements: on mobile the
   browser handles open/close/Escape/light-dismiss; on desktop we override the
   UA popover styles so they sit in the grid as ordinary sticky columns. */
.sidebar, .rail {
  margin: 0;
  border: 0;
  padding: 1.5rem;
  background: var(--bg);
  color: var(--text);
  overflow-y: auto;
  overscroll-behavior: contain;

  &::backdrop { background: var(--scrim); }

  @media (width >= 1024px) {
    position: sticky;
    inset: auto;
    top: 0;
    width: auto;
    height: 100dvh;
    padding: 2rem;
  }
}

/* Left column */
.sidebar {
  flex-direction: column;
  justify-content: space-between;
  gap: 2rem;

  @media (width < 1024px) {
    inset: var(--topbar-h) 0 auto 0;
    width: 100%;
    max-height: calc(100dvh - var(--topbar-h));
    border-bottom: 1px solid var(--border);
    box-shadow: 0 20px 25px -5px rgb(0 0 0 / 0.1);
    transition: translate 0.3s var(--ease-out), opacity 0.3s, overlay 0.3s allow-discrete, display 0.3s allow-discrete;
    translate: 0 -0.75rem;
    opacity: 0;

    &:popover-open {
      display: flex;
      translate: 0 0;
      opacity: 1;
      @starting-style { translate: 0 -0.75rem; opacity: 0; }
    }
    &::backdrop { inset: var(--topbar-h) 0 0 0; }
  }

  @media (width >= 1024px) {
    display: flex;
    border-right: 1px solid var(--border);
  }

  & .identity {
    margin-bottom: 2.5rem;

    & .brand {
      font: 500 1.25rem/1.3 var(--font-serif);
      letter-spacing: -0.015em;
      transition: color 0.15s;
      &:hover { color: var(--accent); }
      @media (width < 1024px) { display: none; }
    }
    & p {
      margin-top: 0.5rem;
      color: var(--text-2);
      font-size: 0.8rem;
      line-height: 1.6;
      @media (width < 1024px) { margin-top: 0; }
    }
    @media (width < 1024px) { margin-bottom: 1.25rem; }
  }
}

.nav {
  display: grid;
  gap: 0.25rem;
  font-size: 0.875rem;

  & a {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.5rem 0.75rem;
    border-radius: 0.5rem;
    color: var(--text-2);
    transition: color 0.15s, background-color 0.15s;

    & .icon { color: var(--muted); }
    &:hover { color: var(--text); background: color-mix(in srgb, var(--surface-2) 70%, transparent); }
    &[aria-current] { color: var(--text); background: var(--surface-2); font-weight: 500; }
  }
}

.sidebar-foot {
  display: grid;
  gap: 1rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
  font-size: 0.75rem;
  color: var(--muted);

  & .status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-2);
  }

  & .utilities {
    display: flex;
    justify-content: space-between;
    gap: 0.5rem;

    & :is(a, button) {
      display: inline-flex;
      align-items: center;
      gap: 0.3rem;
      padding: 0;
      border: 0;
      background: none;
      color: var(--muted);
      font-size: 0.75rem;
      transition: color 0.15s;
      &:hover { color: var(--text); }
    }
    & .icon { width: 0.875rem; height: 0.875rem; }
  }

  & .copyright { font-size: 0.7rem; }
}

/* Right column: page context */
.rail {
  display: none;
  flex-direction: column;
  gap: 2rem;

  & > section { display: grid; gap: 0.75rem; }

  & .rail-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border);
    @media (width >= 1024px) { display: none; }
  }

  @media (width < 1024px) {
    inset: auto 0 0 0;
    width: 100%;
    max-height: 80dvh;
    border-top: 1px solid var(--border-strong);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    box-shadow: 0 -20px 50px -12px rgb(0 0 0 / 0.25);
    transition: translate 0.3s var(--ease-out), overlay 0.3s allow-discrete, display 0.3s allow-discrete;
    translate: 0 100%;

    &:popover-open {
      display: flex;
      translate: 0 0;
      @starting-style { translate: 0 100%; }
    }
  }

  @media (width >= 1024px) {
    display: flex;
    border-left: 1px solid var(--border);
  }
}

/* ------------------------------------------------------------- components */

/* Bordered surface box used in the rail and elsewhere */
.panel {
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text-2);
  font-size: 0.8rem;
  line-height: 1.6;

  &:is(div) { display: grid; gap: 0.75rem; }
}

/* Key/value rows (a <dl> of <div><dt><dd></div>) */
.kv {
  display: grid;
  gap: 0.625rem;

  & > div {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 1rem;
  }
  & dt { flex: none; }
  & dd {
    text-align: right;
    color: var(--text);
    font: 0.72rem/1.5 var(--font-mono);
    &.ok { color: var(--ok); }
    & a:hover { color: var(--accent); }
  }
}

/* Plain link list with trailing arrow/count */
.links {
  display: grid;
  font: 0.8rem var(--font-mono);

  & a {
    display: flex;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.3rem 0;
    color: var(--text-2);
    transition: color 0.15s;
    &:hover { color: var(--accent); }
    & span { color: var(--muted); }
  }
}

/* Reading shelf */
.shelf {
  display: grid;
  gap: 0.5rem;

  & li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    padding: 0.625rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 0.6rem;
    background: color-mix(in srgb, var(--surface) 70%, transparent);
    font-size: 0.75rem;
  }
  & strong { display: block; font-weight: 500; color: var(--text); }
  & span { font-size: 0.7rem; color: var(--muted); }
  & em {
    flex: none;
    max-width: 4.5rem;
    text-align: right;
    font: normal 0.65rem/1.3 var(--font-mono);
    color: var(--muted);
    &.ok { color: var(--ok); }
  }
}

/* Home hero */
.hero {
  & .pill { margin-bottom: 1.5rem; }
  & h1 {
    font: 400 clamp(1.875rem, 1.4rem + 2vw, 2.25rem)/1.25 var(--font-serif);
    letter-spacing: -0.02em;
  }
}

.lede {
  margin-top: 0.75rem;
  color: var(--text-2);
  line-height: 1.7;
}

/* Section block with a small header row */
.block {
  display: grid;
  gap: 1rem;
}

.block-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
  font: 0.75rem var(--font-mono);
  color: var(--muted);

  & a { font-family: var(--font-sans); transition: color 0.15s; }
  & a:hover { color: var(--text); }
}

/* Title + date rows */
.rows {
  & li + li { border-top: 1px solid var(--border); }
  & a {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 1rem;
    margin-inline: -0.5rem;
    padding: 0.875rem 0.5rem;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    font-weight: 500;
    transition: background-color 0.15s, color 0.15s;
    &:hover { background: color-mix(in srgb, var(--surface-2) 60%, transparent); color: var(--accent); }
  }
  & time {
    flex: none;
    font: 400 0.75rem var(--font-mono);
    color: var(--muted);
  }
}

/* Long-form entries (writing index) */
.entries {
  & li + li { border-top: 1px solid var(--border); }
  & a {
    display: grid;
    gap: 0.4rem;
    margin-inline: -0.75rem;
    padding: 1rem 0.75rem;
    border-radius: var(--radius);
    transition: background-color 0.15s;
    &:hover { background: color-mix(in srgb, var(--surface-2) 60%, transparent); }
    &:hover h2 { color: var(--accent); }
  }
  & h2 {
    font: 400 1.25rem/1.35 var(--font-serif);
    transition: color 0.15s;
  }
  & p:not(.meta) { font-size: 0.875rem; line-height: 1.65; color: var(--text-2); }
}

/* Cards (project lists, featured, roles, engagements) */
.cards { display: grid; gap: 1rem; }

.card {
  display: grid;
  gap: 0.5rem;
  padding: 1.25rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  transition: border-color 0.15s;

  &:is(a):hover, &:has(h2 a:hover) { border-color: var(--border-strong); }

  & :is(h2, h3) {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 1rem;
    font: 400 1.2rem/1.35 var(--font-serif);
    transition: color 0.15s;
  }
  &:is(a):hover :is(h2, h3) { color: var(--accent); }
  & .arrow { font: 0.75rem var(--font-mono); color: var(--muted); }
  & > p:not(.card-meta, .meta) { font-size: 0.875rem; line-height: 1.65; color: var(--text-2); }
  & .badge { justify-self: start; }
  & .chips { margin-top: 0.5rem; }

  & .project-preview {
    display: block;
    width: auto;
    height: auto;
    max-width: 100%;
    max-height: 24rem;
    justify-self: center;
    margin-inline: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 0.5rem;
  }

  & .card-meta {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
    font: 0.75rem var(--font-mono);
    color: var(--muted);
  }

  &.featured {
    padding: 1.5rem;
    & h2 { font-size: clamp(1.25rem, 1.1rem + 0.8vw, 1.5rem); }
    & h2 a:hover { color: var(--accent); }
    & footer {
      display: flex;
      flex-wrap: wrap;
      justify-content: space-between;
      gap: 0.5rem;
      margin-top: 0.5rem;
      padding-top: 1rem;
      border-top: 1px solid var(--border);
      font-size: 0.75rem;
      & span { font-family: var(--font-mono); color: var(--muted); }
      & a { color: var(--accent); font-weight: 500; }
      & a:hover { text-decoration: underline; }
    }
  }

  & details {
    margin-top: 0.25rem;
    padding-top: 0.5rem;
    border-top: 1px solid var(--border);
    & > summary {
      padding: 0.25rem 0;
      font: 0.75rem var(--font-mono);
      color: var(--muted);
      &:hover { color: var(--text); }
    }
    &[open] > :not(summary) { margin-top: 0.75rem; }
  }

  &.engagement {
    & summary { align-items: flex-start; }
    & summary > span { display: grid; gap: 0.25rem; }
    & h3 { font-size: 1.125rem; }
    & summary:hover h3 { color: var(--accent); }
    & summary::after { content: "+"; font-size: 1.25rem; line-height: 1; }
    &[open] summary::after { rotate: 45deg; }
    & > :not(summary) { margin-top: 1rem; }
    & > p { font-size: 0.8rem; line-height: 1.65; color: var(--text-2); }
    &[open] > summary + * { padding-top: 1rem; border-top: 1px solid var(--border); }
  }
}

/* Disclosure summaries: custom chevron, no native marker */
details > summary {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  cursor: pointer;
  list-style: none;
  &::-webkit-details-marker { display: none; }
  &::after { content: "↓"; color: var(--muted); transition: rotate 0.2s; }
}
details[open] > summary::after { rotate: 180deg; }

.bullets {
  display: grid;
  gap: 0.35rem;
  padding-left: 1.1rem !important;
  list-style: disc !important;
  font-size: 0.8rem;
  line-height: 1.6;
  color: var(--text-2);
}

/* Page header */
.page-head {
  display: grid;
  gap: 0.75rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);

  & .back {
    justify-self: start;
    margin-bottom: 0.5rem;
    font: 0.75rem var(--font-mono);
    color: var(--muted);
    &:hover { color: var(--text); }
  }
  & h1 {
    font: 500 clamp(1.875rem, 1.4rem + 2vw, 2.25rem)/1.2 var(--font-serif);
    letter-spacing: -0.02em;
    text-wrap: balance;
  }
  & .lede { margin-top: 0; }
  & .lede p + p { margin-top: 0.75rem; }
  & .byline {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem 0;
    font: 0.75rem var(--font-mono);
    color: var(--muted);
    & > * + *::before { content: "•"; margin-inline: 0.6rem; }
  }
  & .intro {
    margin-top: 0.5rem;
    padding-left: 1rem;
    border-left: 2px solid var(--accent);
    font: italic 1.1rem/1.6 var(--font-serif);
    color: var(--text-2);
  }
  & .actions { margin-top: 0.25rem; }
}

.actions { display: flex; flex-wrap: wrap; gap: 0.75rem; }

/* Article footer */
.page-foot {
  display: grid;
  gap: 1.5rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border);
}

.cite {
  font-size: 0.8rem;
  & > summary {
    justify-content: flex-start;
    font: 0.75rem var(--font-mono);
    color: var(--muted);
    &:hover { color: var(--text); }
  }
  & p {
    margin-top: 0.75rem;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text-2);
    overflow-wrap: anywhere;
    user-select: all;
  }
}

.prev-next {
  display: grid;
  gap: 1rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
  @media (width >= 640px) { grid-template-columns: 1fr 1fr; }

  & a {
    display: grid;
    gap: 0.25rem;
    padding: 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font: 500 0.875rem/1.4 var(--font-serif);
    transition: border-color 0.15s;
    &:hover { border-color: var(--border-strong); }
    &.next { text-align: right; grid-column: 2; @media (width < 640px) { grid-column: auto; } }
  }
  & span { font: 400 0.75rem var(--font-mono); color: var(--muted); }
}

.pager {
  display: flex;
  justify-content: space-between;
  padding-top: 2rem;
  border-top: 1px solid var(--border);
  font: 0.75rem var(--font-mono);
  color: var(--muted);
  & a:hover { color: var(--text); }
}

/* Table of contents */
.toc {
  padding-left: 0.75rem;
  border-left: 1px solid var(--border);
  font-size: 0.75rem;

  & ol { list-style: none; padding: 0; }
  & a {
    display: block;
    padding: 0.25rem 0;
    color: var(--text-2);
    transition: color 0.15s;
    &:hover { color: var(--accent); }
  }
  & ol ol { padding-left: 0.75rem; }
  & ol ol a { padding: 0.125rem 0; color: var(--muted); }
}

/* ------------------------------------------------------------------ prose */

.prose {
  min-width: 0;
  color: var(--prose);
  font: 400 1.15rem/1.8 var(--font-serif);
  letter-spacing: -0.005em;
  overflow-wrap: break-word;
  counter-reset: sidenote;

  & > * + * { margin-top: 1.4rem; }

  & :is(h2, h3, h4) {
    color: var(--text);
    font-family: var(--font-serif);
    font-weight: 500;
    line-height: 1.3;
    letter-spacing: -0.02em;
    text-wrap: balance;
  }
  & h2 { font-size: 1.5rem; margin-top: 2.5rem; }
  & h3 { font-size: 1.25rem; margin-top: 2rem; }
  & h4 { font-size: 1.1rem; margin-top: 1.75rem; }
  & :is(h2, h3, h4) + * { margin-top: 0.75rem; }

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

  & :is(ul, ol) { padding-left: 1.5rem; }
  & li + li { margin-top: 0.5rem; }
  & li > :is(ul, ol) { margin-top: 0.5rem; }

  & blockquote {
    padding-left: 1.25rem;
    border-left: 3px solid var(--accent);
    font-style: italic;
    color: var(--text-2);
  }

  & hr {
    margin-block: 2.5rem;
    border: 0;
    border-top: 1px solid var(--border);
  }

  & :is(img, video) {
    display: block;
    margin-inline: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius);
  }

  & figure { margin-block: 1.75rem; }
  & figcaption {
    margin-top: 0.5rem;
    text-align: center;
    font: 0.75rem/1.5 var(--font-mono);
    color: var(--muted);
  }

  & table {
    width: 100%;
    border-collapse: collapse;
    font: 0.875rem/1.5 var(--font-sans);
    display: block;
    overflow-x: auto;
  }
  & :is(th, td) {
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--border);
    text-align: left;
    vertical-align: top;
  }
  & th { background: var(--surface-2); font-weight: 600; }

  & :not(pre) > code {
    padding: 0.15em 0.35em;
    border-radius: 0.375rem;
    background: var(--surface-2);
    color: var(--accent);
    font: 0.8em var(--font-mono);
  }

  /* Code blocks: language label from code[data-lang], no JS */
  & pre {
    position: relative;
    padding: 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--code-bg);
    overflow-x: auto;
    font: 0.82rem/1.6 var(--font-mono);
    letter-spacing: 0;
    tab-size: 2;

    &:has(> code[data-lang]) { padding-top: 2.5rem; }
    & code { font: inherit; }
    & code[data-lang]::before {
      content: attr(data-lang);
      position: absolute;
      inset: 0 0 auto 0;
      padding: 0.4rem 1rem;
      border-bottom: 1px solid var(--border);
      font-size: 0.7rem;
      color: var(--muted);
    }
  }
}

/* Figures from the `figure` shortcode */
.figure {
  & a { display: block; }
  & img { width: 100%; }
}

.project-page .figure img {
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 24rem;
}

/* Pre-rendered Mermaid diagrams (`diagram` shortcode). Mermaid's own styles
   are stripped at render time; these give them the site's look in both themes. */
.diagram {
  padding: 1.25rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  overflow-x: auto;

  & svg {
    display: block;
    height: auto;
    margin-inline: auto;
    font: 14px var(--font-sans);
  }
  & .node > :is(rect, polygon, circle, path) {
    fill: var(--surface-2);
    stroke: var(--border-strong);
    stroke-width: 1px;
  }
  & text { fill: var(--text); }
  & .label text { text-anchor: middle; }
  & .flowchart-link { fill: none; stroke: var(--muted); stroke-width: 1.25px; }
  & .arrowMarkerPath { fill: var(--muted); stroke: var(--muted); }
  & .edgeLabel {
    & rect { fill: var(--surface); }
    & text { fill: var(--text-2); font-size: 12px; }
  }
}

/* Sidenotes: a numbered marker that reveals its note in place (checkbox, no JS) */
.sn-toggle {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.sn-ref {
  counter-increment: sidenote;
  display: inline-block;
  margin-inline: 0.15em;
  padding: 0 0.4em;
  border-radius: 0.3em;
  background: var(--accent-soft);
  color: var(--accent);
  font: 600 0.7em/1.6 var(--font-mono);
  vertical-align: 0.15em;
  cursor: pointer;
  transition: background-color 0.15s, color 0.15s;

  &::before { content: counter(sidenote); }
  &:hover { background: var(--accent); color: var(--bg); }
}

.sidenote {
  display: none;
  margin-block: 0.75rem;
  padding: 0.75rem 1rem;
  border-left: 2px solid var(--accent);
  border-radius: 0 0.5rem 0.5rem 0;
  background: var(--accent-soft);
  color: var(--text-2);
  font: 0.875rem/1.65 var(--font-sans);
  letter-spacing: 0;

  &::before {
    content: counter(sidenote) ". ";
    color: var(--accent);
    font: 600 0.75rem var(--font-mono);
  }
}

.sn-toggle:checked + .sn-ref { background: var(--accent); color: var(--bg); }
.sn-toggle:checked + .sn-ref + .sidenote { display: block; }
.sn-toggle:focus-visible + .sn-ref { outline: 2px solid var(--accent); outline-offset: 2px; }
