/* ==========================================================================
   Cristian Cosci · personal site
   Theme: "Modern tech & gradient". Plain CSS, no build step.
   Every color is a token: light values live on :root, dark values are
   defined twice below (system preference + manual toggle). Keep the two
   dark blocks identical.
   ========================================================================== */

/* ---------- Fonts ----------
   Geist and Geist Mono (variable, latin subset), self-hosted.
   SIL Open Font License 1.1, see assets/fonts/LICENSE-geist*.txt */
@font-face {
  font-family: "Geist";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("../fonts/geist-latin-wght-normal.woff2") format("woff2-variations"),
       url("../fonts/geist-latin-wght-normal.woff2") format("woff2");
}

@font-face {
  font-family: "Geist";
  font-style: italic;
  font-weight: 100 900;
  font-display: swap;
  src: url("../fonts/geist-latin-wght-italic.woff2") format("woff2-variations"),
       url("../fonts/geist-latin-wght-italic.woff2") format("woff2");
}

@font-face {
  font-family: "Geist Mono";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("../fonts/geist-mono-latin-wght-normal.woff2") format("woff2-variations"),
       url("../fonts/geist-mono-latin-wght-normal.woff2") format("woff2");
}

/* ---------- Design tokens: light ---------- */
:root {
  color-scheme: light;
  --bg: #f7f8fc;
  --bg-band: #eff1f9;
  --surface: rgba(255, 255, 255, 0.78);
  --surface-solid: #ffffff;
  --surface-hover: rgba(255, 255, 255, 0.96);
  --glass: rgba(255, 255, 255, 0.66);
  --header-bg: rgba(247, 248, 252, 0.74);
  --text: #0b1022;
  --text-2: #2e3552;
  --muted: #535a76;
  --border: rgba(17, 24, 64, 0.09);
  --border-strong: rgba(17, 24, 64, 0.16);
  --accent: #4f46e5;
  --accent-strong: #4338ca;
  --accent-soft: rgba(79, 70, 229, 0.09);
  --accent-ring: rgba(79, 70, 229, 0.28);
  --focus: #4f46e5;
  --g1: #4f46e5;
  --g2: #7c3aed;
  --g3: #0e7490;
  --brand-shadow: rgba(79, 70, 229, 0.45);
  --tile-1: rgba(79, 70, 229, 0.12);
  --tile-2: rgba(14, 116, 144, 0.08);
  --chip-bg: rgba(17, 24, 64, 0.045);
  --chip-text: #2e3552;
  --nav-hover: rgba(17, 24, 64, 0.05);
  --glow-1: rgba(99, 102, 241, 0.22);
  --glow-2: rgba(168, 85, 247, 0.16);
  --glow-3: rgba(34, 211, 238, 0.18);
  --glow-4: rgba(244, 114, 182, 0.14);
  --grid-line: rgba(17, 24, 64, 0.055);
  --avatar-glow: rgba(124, 58, 237, 0.3);
  --halo: rgba(255, 255, 255, 0.7);
  --mono-hl: rgba(79, 70, 229, 0.1);
  --shadow-sm: 0 1px 2px rgba(17, 24, 64, 0.06);
  --shadow-card: 0 1px 2px rgba(17, 24, 64, 0.04), 0 12px 32px -16px rgba(17, 24, 64, 0.18);
  --shadow-hover: 0 2px 6px rgba(17, 24, 64, 0.05), 0 24px 48px -20px rgba(67, 56, 202, 0.32);
  --inset-hl: inset 0 1px 0 rgba(255, 255, 255, 0.85);
  --selection: rgba(79, 70, 229, 0.18);
  --code-bg: #f3f4fa;
  --code-inline-bg: rgba(17, 24, 64, 0.05);
  --code-border: rgba(17, 24, 64, 0.1);
  --code-text: #1f2335;
  --code-comment: #57606a;
  --code-keyword: #cf222e;
  --code-string: #0a3069;
  --code-number: #0550ae;
  --code-function: #8250df;
  --code-class: #953800;
  --code-inserted: #116329;

  /* Theme-independent tokens */
  --grad-text: linear-gradient(100deg, var(--g1) 0%, var(--g2) 50%, var(--g3) 100%);
  --grad-brand: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%); /* white text on it: >= 5.7:1 */
  --font-sans: "Geist", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: "Geist Mono", ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --radius: 14px;
  --radius-lg: 20px;
  --container: 68rem;
  --narrow: 46rem;
  --gutter: 1rem;
  --header-h: 4rem;
  --card-pad: clamp(1.15rem, 0.9rem + 1vw, 1.75rem);
  --space-section: clamp(4rem, 2.5rem + 6vw, 7rem);
}

/* ---------- Design tokens: dark (system preference) ---------- */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #070912;
    --bg-band: #0a0d19;
    --surface: rgba(255, 255, 255, 0.045);
    --surface-solid: #10131f;
    --surface-hover: rgba(255, 255, 255, 0.07);
    --glass: rgba(15, 18, 32, 0.6);
    --header-bg: rgba(7, 9, 18, 0.7);
    --text: #eef0fa;
    --text-2: #c6cae0;
    --muted: #9aa1be;
    --border: rgba(255, 255, 255, 0.08);
    --border-strong: rgba(255, 255, 255, 0.15);
    --accent: #a5b4fc;
    --accent-strong: #c7d2fe;
    --accent-soft: rgba(129, 140, 248, 0.14);
    --accent-ring: rgba(165, 180, 252, 0.32);
    --focus: #a5b4fc;
    --g1: #818cf8;
    --g2: #c084fc;
    --g3: #22d3ee;
    --brand-shadow: rgba(99, 102, 241, 0.5);
    --tile-1: rgba(129, 140, 248, 0.16);
    --tile-2: rgba(34, 211, 238, 0.07);
    --chip-bg: rgba(255, 255, 255, 0.06);
    --chip-text: #d3d7ea;
    --nav-hover: rgba(255, 255, 255, 0.06);
    --glow-1: rgba(79, 70, 229, 0.34);
    --glow-2: rgba(147, 51, 234, 0.26);
    --glow-3: rgba(6, 182, 212, 0.2);
    --glow-4: rgba(236, 72, 153, 0.16);
    --grid-line: rgba(255, 255, 255, 0.045);
    --avatar-glow: rgba(139, 92, 246, 0.45);
    --halo: rgba(255, 255, 255, 0.04);
    --mono-hl: rgba(129, 140, 248, 0.16);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.3), 0 18px 40px -24px rgba(0, 0, 0, 0.8);
    --shadow-hover: 0 2px 8px rgba(0, 0, 0, 0.35), 0 28px 56px -28px rgba(99, 102, 241, 0.5);
    --inset-hl: inset 0 1px 0 rgba(255, 255, 255, 0.06);
    --selection: rgba(129, 140, 248, 0.32);
    --code-bg: #0c0f1d;
    --code-inline-bg: rgba(255, 255, 255, 0.07);
    --code-border: rgba(255, 255, 255, 0.09);
    --code-text: #e6e9f5;
    --code-comment: #8b949e;
    --code-keyword: #ff7b72;
    --code-string: #a5d6ff;
    --code-number: #79c0ff;
    --code-function: #d2a8ff;
    --code-class: #ffa657;
    --code-inserted: #7ee787;
  }
}

/* ---------- Design tokens: dark (manual toggle) ---------- */
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #070912;
  --bg-band: #0a0d19;
  --surface: rgba(255, 255, 255, 0.045);
  --surface-solid: #10131f;
  --surface-hover: rgba(255, 255, 255, 0.07);
  --glass: rgba(15, 18, 32, 0.6);
  --header-bg: rgba(7, 9, 18, 0.7);
  --text: #eef0fa;
  --text-2: #c6cae0;
  --muted: #9aa1be;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.15);
  --accent: #a5b4fc;
  --accent-strong: #c7d2fe;
  --accent-soft: rgba(129, 140, 248, 0.14);
  --accent-ring: rgba(165, 180, 252, 0.32);
  --focus: #a5b4fc;
  --g1: #818cf8;
  --g2: #c084fc;
  --g3: #22d3ee;
  --brand-shadow: rgba(99, 102, 241, 0.5);
  --tile-1: rgba(129, 140, 248, 0.16);
  --tile-2: rgba(34, 211, 238, 0.07);
  --chip-bg: rgba(255, 255, 255, 0.06);
  --chip-text: #d3d7ea;
  --nav-hover: rgba(255, 255, 255, 0.06);
  --glow-1: rgba(79, 70, 229, 0.34);
  --glow-2: rgba(147, 51, 234, 0.26);
  --glow-3: rgba(6, 182, 212, 0.2);
  --glow-4: rgba(236, 72, 153, 0.16);
  --grid-line: rgba(255, 255, 255, 0.045);
  --avatar-glow: rgba(139, 92, 246, 0.45);
  --halo: rgba(255, 255, 255, 0.04);
  --mono-hl: rgba(129, 140, 248, 0.16);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.3), 0 18px 40px -24px rgba(0, 0, 0, 0.8);
  --shadow-hover: 0 2px 8px rgba(0, 0, 0, 0.35), 0 28px 56px -28px rgba(99, 102, 241, 0.5);
  --inset-hl: inset 0 1px 0 rgba(255, 255, 255, 0.06);
  --selection: rgba(129, 140, 248, 0.32);
  --code-bg: #0c0f1d;
  --code-inline-bg: rgba(255, 255, 255, 0.07);
  --code-border: rgba(255, 255, 255, 0.09);
  --code-text: #e6e9f5;
  --code-comment: #8b949e;
  --code-keyword: #ff7b72;
  --code-string: #a5d6ff;
  --code-number: #79c0ff;
  --code-function: #d2a8ff;
  --code-class: #ffa657;
  --code-inserted: #7ee787;
}

@media (min-width: 40rem) {
  :root { --gutter: 1.5rem; }
}

@media (min-width: 64rem) {
  :root { --gutter: 2rem; }
}

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-padding-top: calc(var(--header-h) + 1rem);
}

@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}

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

main { flex: 1 0 auto; }
main:focus { outline: none; }

img { display: block; max-width: 100%; }

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 1rem; }
ul, ol { margin: 0; }
strong, b { font-weight: 620; }

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-strong); }

::selection { background: var(--selection); }

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 3px;
}

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

.container {
  width: 100%;
  max-width: calc(var(--container) + 2 * var(--gutter));
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.container--narrow { max-width: calc(var(--narrow) + 2 * var(--gutter)); }

.gradient-text {
  background: var(--grad-text);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  -webkit-text-fill-color: transparent;
}

.skip-link {
  position: absolute;
  top: 0.75rem;
  left: 1rem;
  z-index: 100;
  padding: 0.55rem 1rem;
  border-radius: 999px;
  background: var(--surface-solid);
  box-shadow: var(--shadow-card);
  color: var(--text);
  font-weight: 600;
  transform: translateY(-200%);
}

.skip-link:focus { transform: none; }

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

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  height: 100%;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.625rem;
  min-width: 0;
  color: var(--text);
  font-weight: 650;
  letter-spacing: -0.02em;
  white-space: nowrap;
}

.brand:hover { color: var(--text); }

.brand-mark {
  display: grid;
  flex: none;
  place-items: center;
  width: 2rem;
  height: 2rem;
  border-radius: 10px;
  background: var(--grad-brand);
  box-shadow: 0 6px 16px -6px var(--brand-shadow), inset 0 1px 0 rgba(255, 255, 255, 0.25);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.brand-name { font-size: 0.975rem; }

.site-nav {
  display: flex;
  align-items: center;
  gap: 0.375rem;
}

.nav-list {
  display: flex;
  align-items: center;
  gap: 0.125rem;
  padding: 0;
  list-style: none;
}

.nav-list a {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.4rem 0.7rem;
  border-radius: 999px;
  color: var(--text-2);
  font-size: 0.9rem;
  font-weight: 500;
  transition: color 0.2s ease, background-color 0.2s ease, border-color 0.2s ease;
}

.nav-list a:hover { background: var(--nav-hover); color: var(--text); }
.nav-list a[aria-current="page"] { background: var(--accent-soft); color: var(--accent-strong); }

.nav-list .nav-cv {
  margin-left: 0.25rem;
  border: 1px solid var(--border-strong);
  color: var(--text);
}

.nav-list .nav-cv:hover { border-color: var(--accent-ring); }
.nav-cv .icon { width: 0.95rem; height: 0.95rem; color: var(--accent); }

@media (max-width: 47.99rem) {
  .nav-section { display: none; }
}

/* Small phones: tighter nav so the brand, Blog, CV and the toggle always fit */
@media (max-width: 29.99rem) {
  .site-nav { gap: 0.25rem; }
  .nav-list a { padding-inline: 0.6rem; }
  .nav-cv .icon { display: none; }
  .theme-toggle { margin-left: 0; }
}

/* Very narrow screens: keep the "CC" mark, hide the name visually in the header (still announced) */
@media (max-width: 22.49rem) {
  .site-header .brand-name {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }
}

.theme-toggle {
  display: inline-grid;
  place-items: center;
  width: 2.375rem;
  height: 2.375rem;
  margin-left: 0.25rem;
  padding: 0;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--glass);
  color: var(--text-2);
  cursor: pointer;
  transition: color 0.2s ease, border-color 0.2s ease, background-color 0.2s ease;
}

.theme-toggle:hover { border-color: var(--accent-ring); background: var(--surface-hover); color: var(--text); }
.theme-toggle svg { width: 1.1rem; height: 1.1rem; }

.theme-toggle .icon-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .icon-sun { display: block; }
  :root:not([data-theme="light"]) .theme-toggle .icon-moon { display: none; }
}

/* ---------- Hero backgrounds (home, blog, post, 404) ---------- */
.hero,
.page-hero {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  margin-top: calc(-1 * var(--header-h));
}

.hero-bg {
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  -webkit-mask-image: linear-gradient(to bottom, #000 62%, transparent);
  mask-image: linear-gradient(to bottom, #000 62%, transparent);
}

.hero-grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
  background-position: center top;
  background-size: 48px 48px;
  -webkit-mask-image: radial-gradient(ellipse 75% 70% at 50% 0%, #000 25%, transparent 75%);
  mask-image: radial-gradient(ellipse 75% 70% at 50% 0%, #000 25%, transparent 75%);
}

.glow {
  position: absolute;
  width: var(--size);
  height: var(--size);
  border-radius: 50%;
  background: radial-gradient(closest-side, var(--tint), transparent);
}

.glow-1 { --size: clamp(22rem, 62vw, 46rem); --tint: var(--glow-1); top: -24%; left: -16%; }
.glow-2 { --size: clamp(20rem, 52vw, 40rem); --tint: var(--glow-2); top: -14%; right: -14%; }
.glow-3 { --size: clamp(16rem, 42vw, 32rem); --tint: var(--glow-3); bottom: -22%; left: 30%; }
.glow-4 { --size: clamp(12rem, 30vw, 24rem); --tint: var(--glow-4); top: 26%; right: 16%; }

.page-hero .hero-bg { opacity: 0.85; }

/* ---------- Home hero ---------- */
.hero {
  padding-top: calc(var(--header-h) + clamp(2.25rem, 1rem + 6vw, 6rem));
  padding-bottom: clamp(2.5rem, 1rem + 5vw, 4.5rem);
}

.hero-inner {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1.75rem;
}

.hero-copy { min-width: 0; max-width: 48rem; }

@media (min-width: 56rem) {
  .hero-inner {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    column-gap: clamp(2.5rem, 5vw, 5rem);
  }

  .hero-copy { grid-row: 1; grid-column: 1; }
  .hero-avatar { grid-row: 1; grid-column: 2; margin-right: clamp(1.75rem, 3vw, 3rem); }
}

.hero-avatar {
  --size: 5.5rem;
  position: relative;
  flex: none;
  width: var(--size);
  height: var(--size);
}

.hero-avatar::before {
  content: "";
  position: absolute;
  inset: -9px;
  border: 1px solid var(--border-strong);
  border-radius: 50%;
  pointer-events: none;
}

.orbit { display: none; }

@media (min-width: 56rem) {
  .hero-avatar { --size: clamp(12rem, 17vw, 15rem); }
  .hero-avatar::before { inset: -18px; }

  .orbit {
    position: absolute;
    inset: -46px;
    display: block;
    border: 1px dashed var(--border-strong);
    border-radius: 50%;
    pointer-events: none;
  }

  .orbit::before {
    content: "";
    position: absolute;
    top: 50%;
    left: -5px;
    width: 9px;
    height: 9px;
    margin-top: -4.5px;
    border-radius: 50%;
    background: var(--grad-brand);
    box-shadow: 0 0 0 4px var(--accent-soft), 0 0 16px 2px var(--avatar-glow);
  }

  /* Soft aura behind the portrait (desktop only, where no text sits on it) */
  .avatar-ring::before {
    content: "";
    position: absolute;
    inset: -48%;
    z-index: -1;
    border-radius: 50%;
    background: radial-gradient(closest-side, var(--avatar-glow), transparent);
    pointer-events: none;
  }
}

.avatar-ring {
  position: relative;
  width: 100%;
  height: 100%;
  padding: 3px;
  border-radius: 50%;
  background: conic-gradient(from 210deg, var(--g1), var(--g2), var(--g3), var(--g1));
  box-shadow: 0 0 0 6px var(--halo), 0 24px 60px -18px var(--avatar-glow);
}

.avatar-photo,
.monogram {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background-color: var(--surface-solid);
}

.avatar-photo { object-fit: cover; }

.monogram {
  display: grid;
  place-items: center;
  background-image: radial-gradient(circle at 30% 22%, var(--mono-hl), transparent 62%);
}

.monogram span {
  padding-right: 0.04em;
  background: var(--grad-text);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  -webkit-text-fill-color: transparent;
  font-size: calc(var(--size) * 0.36);
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.05em;
}

.hero-pill {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.6rem;
  margin: 0 0 1.5rem;
  padding: 0.4rem 0.95rem 0.4rem 0.75rem;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--glass);
  box-shadow: var(--shadow-sm);
  color: var(--text-2);
  font-size: 0.85rem;
  font-weight: 520;
  line-height: 1.3;
}

.pill-dot {
  position: relative;
  flex: none;
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: var(--grad-brand);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.pill-sep { width: 1px; height: 0.95em; background: var(--border-strong); }

.pill-location { display: inline-flex; align-items: center; gap: 0.3rem; }
.pill-location .icon { width: 0.95rem; height: 0.95rem; color: var(--accent-strong); }

.hero-name {
  font-size: clamp(2.75rem, 1.4rem + 6.2vw, 5.25rem);
  font-weight: 720;
  line-height: 1.02;
  letter-spacing: -0.045em;
}

.hero-role {
  margin: 1rem 0 0;
  color: var(--text-2);
  font-size: clamp(1.15rem, 1rem + 0.9vw, 1.6rem);
  font-weight: 500;
  line-height: 1.35;
  letter-spacing: -0.02em;
}

.focus-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 1.5rem 0 0;
  padding: 0;
  list-style: none;
}

.focus-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.3rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--glass);
  color: var(--text-2);
  font-size: 0.85rem;
  font-weight: 520;
}

.focus-chip::before {
  content: "";
  width: 0.375rem;
  height: 0.375rem;
  border-radius: 50%;
  background: var(--grad-brand);
}

.hero-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.625rem;
  margin: 2rem 0 0;
  padding: 0;
  list-style: none;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 2.75rem;
  padding: 0.55rem 1.15rem;
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: 0.9375rem;
  font-weight: 560;
  line-height: 1.2;
  white-space: nowrap;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.btn .icon { width: 1.05rem; height: 1.05rem; }

.btn-primary {
  background: var(--grad-brand);
  box-shadow: 0 10px 26px -12px var(--brand-shadow), inset 0 1px 0 rgba(255, 255, 255, 0.22);
  color: #fff;
}

.btn-primary:hover {
  box-shadow: 0 14px 32px -12px var(--brand-shadow), inset 0 1px 0 rgba(255, 255, 255, 0.22);
  color: #fff;
}

.btn-glass {
  border-color: var(--border-strong);
  background: var(--glass);
  box-shadow: var(--shadow-sm);
  color: var(--text);
}

.btn-glass:hover { border-color: var(--accent-ring); background: var(--surface-hover); color: var(--text); }
.btn-glass .icon { color: var(--accent); }

.btn-sm { min-height: 2.5rem; padding: 0.45rem 1rem; font-size: 0.875rem; }

/* ---------- Sections ---------- */
.section {
  position: relative;
  padding-block: calc(var(--space-section) / 2);
}

.section--band {
  isolation: isolate;
  overflow: hidden;
  margin-block: calc(var(--space-section) / 2);
  padding-block: var(--space-section);
  border-block: 1px solid var(--border);
  background: var(--bg-band);
}

.section--band::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(42rem 24rem at 100% 0%, var(--glow-2), transparent 70%),
    radial-gradient(38rem 22rem at 0% 100%, var(--glow-3), transparent 70%);
  opacity: 0.75;
  pointer-events: none;
}

.section-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1rem;
  margin-bottom: clamp(1.5rem, 1rem + 2vw, 2.5rem);
}

.section-icon {
  display: grid;
  flex: none;
  place-items: center;
  width: 2.5rem;
  height: 2.5rem;
  border: 1px solid var(--accent-ring);
  border-radius: 12px;
  background: linear-gradient(135deg, var(--tile-1), var(--tile-2)), var(--surface-solid);
  box-shadow: var(--shadow-sm), var(--inset-hl);
  color: var(--accent);
}

.section-icon .icon { width: 1.2rem; height: 1.2rem; }

.section-title {
  /* Long titles wrap beside the icon tile instead of dropping to their own line on small phones */
  min-width: 0;
  max-width: calc(100% - 3.5rem);
  font-size: clamp(1.55rem, 1.2rem + 1.4vw, 2.25rem);
  font-weight: 680;
  line-height: 1.1;
  letter-spacing: -0.035em;
}

.section-rule {
  flex: 1 1 0;
  min-width: 0;
  height: 1px;
  background: linear-gradient(90deg, var(--border-strong), transparent);
}

.section-action {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  color: var(--accent);
  font-size: 0.9rem;
  font-weight: 560;
  white-space: nowrap;
}

.section-action .icon { width: 1rem; height: 1rem; transition: transform 0.2s ease; }

/* ---------- Cards ---------- */
.card {
  position: relative;
  padding: var(--card-pad);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-card), var(--inset-hl);
}

.card-link {
  transition: transform 0.25s ease, box-shadow 0.25s ease, background-color 0.25s ease;
}

/* Gradient border: shown on hover for links, always for the featured publication */
.card-link::before,
.pub-card.is-featured::before {
  content: "";
  position: absolute;
  inset: -1px;
  padding: 1px;
  border-radius: inherit;
  background: linear-gradient(135deg, var(--g1), var(--g2) 50%, var(--g3));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  mask-composite: exclude;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.card-link:hover,
.card-link:focus-within {
  background: var(--surface-hover);
  box-shadow: var(--shadow-hover), var(--inset-hl);
}

.card-link:hover::before,
.card-link:focus-within::before { opacity: 1; }

.stretched-link::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
}

.card-link .stretched-link:focus-visible { outline-offset: 4px; }

@supports selector(:has(*)) {
  .card-link:has(.stretched-link:focus-visible) {
    outline: 2px solid var(--focus);
    outline-offset: 3px;
  }

  .card-link .stretched-link:focus-visible { outline: none; }
}

.icon-tile {
  display: grid;
  flex: none;
  place-items: center;
  width: 2.5rem;
  height: 2.5rem;
  border: 1px solid var(--accent-ring);
  border-radius: 12px;
  background: linear-gradient(135deg, var(--tile-1), var(--tile-2));
  box-shadow: var(--inset-hl);
  color: var(--accent);
}

.icon-tile .icon { width: 1.15rem; height: 1.15rem; }
.icon-tile--sm { width: 2.125rem; height: 2.125rem; border-radius: 10px; }
.icon-tile--sm .icon { width: 1rem; height: 1rem; }

/* ---------- Badges, chips & tags ---------- */
.badge-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0 0 0.9rem;
  padding: 0;
  list-style: none;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.22rem 0.65rem;
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.3;
}

.badge .icon { width: 0.85rem; height: 0.85rem; }

.badge-venue {
  border-color: var(--border-strong);
  background: var(--chip-bg);
  color: var(--text-2);
  font-family: var(--font-mono);
  font-weight: 500;
}

.badge-topic {
  border-color: var(--accent-ring);
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.badge-highlight {
  background: var(--grad-brand);
  box-shadow: 0 6px 16px -8px var(--brand-shadow);
  color: #fff;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  padding: 0;
  list-style: none;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.3rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 0.9rem;
  background: var(--chip-bg);
  color: var(--chip-text);
  font-size: 0.8125rem;
  font-weight: 500;
  line-height: 1.35;
}

.chip .icon { width: 0.95rem; height: 0.95rem; }

.chip--accent {
  border-color: var(--accent-ring);
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  padding: 0;
  list-style: none;
}

.tag {
  padding: 0.12rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--chip-bg);
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.75rem;
}

/* ---------- About ---------- */
.about { max-width: 50rem; }

.lead {
  margin-bottom: 1.25rem;
  color: var(--text);
  font-size: clamp(1.2rem, 1.05rem + 0.65vw, 1.5rem);
  font-weight: 450;
  line-height: 1.5;
  letter-spacing: -0.015em;
}

.lead strong {
  border-radius: 0.2em;
  background: linear-gradient(100deg, var(--tile-1), var(--tile-2)) 0 75% / 100% 42% no-repeat;
  font-weight: 620;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
}

.about p:not(.lead) {
  max-width: 44rem;
  margin-bottom: 0;
  color: var(--text-2);
  font-size: 1.0625rem;
}

/* ---------- Experience timeline ---------- */
.timeline {
  position: relative;
  display: grid;
  gap: 1.25rem;
  padding: 0;
  list-style: none;
}

.timeline::before {
  content: "";
  position: absolute;
  top: 1.25rem;
  bottom: 1.25rem;
  left: 7px;
  width: 2px;
  border-radius: 2px;
  background: linear-gradient(to bottom, var(--g1), var(--g2) 55%, var(--border-strong));
  opacity: 0.6;
}

.timeline-item { position: relative; padding-left: 2rem; }

@media (min-width: 40rem) {
  .timeline-item { padding-left: 2.75rem; }
}

.timeline-dot {
  position: absolute;
  top: calc(var(--card-pad) + 0.75rem - 7px);
  left: 1px;
  width: 14px;
  height: 14px;
  border: 2px solid var(--g2);
  border-radius: 50%;
  background: var(--bg);
  box-shadow: 0 0 0 4px var(--bg);
}

.timeline-item.is-current .timeline-dot {
  border-color: var(--g1);
  background: var(--g1);
  box-shadow: 0 0 0 4px var(--bg), 0 0 0 7px var(--accent-soft);
}

.xp-card { display: grid; gap: 1.25rem; }
.xp-side { min-width: 0; }

.xp-org { font-size: 1.2rem; line-height: 1.25; letter-spacing: -0.02em; }

.xp-loc {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin: 0.4rem 0 0;
  color: var(--muted);
  font-size: 0.875rem;
}

.xp-loc .icon { width: 0.95rem; height: 0.95rem; }

.xp-roles {
  display: grid;
  gap: 0.8rem;
  margin-top: 1.1rem;
  padding: 0;
  list-style: none;
}

.xp-role { position: relative; padding-left: 1.3rem; }

.xp-role::before {
  content: "";
  position: absolute;
  top: 0.4em;
  left: 0;
  width: 10px;
  height: 10px;
  border: 2px solid var(--muted);
  border-radius: 50%;
  background: var(--surface-solid);
}

.xp-role.is-current::before {
  border-color: var(--accent);
  background: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.xp-role:not(:last-child)::after {
  content: "";
  position: absolute;
  top: calc(0.4em + 13px);
  bottom: calc(-0.8rem - 0.4em + 3px);
  left: 4px;
  width: 2px;
  border-radius: 2px;
  background: var(--border-strong);
}

.xp-title { display: block; color: var(--text); font-weight: 580; line-height: 1.4; }

.xp-period {
  display: block;
  margin-top: 0.15rem;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
}

.xp-highlights {
  display: grid;
  gap: 0.75rem;
  padding: 1.1rem 0 0;
  border-top: 1px solid var(--border);
  color: var(--text-2);
  font-size: 0.975rem;
  list-style: none;
}

.xp-highlights li { position: relative; padding-left: 1.4rem; }

.xp-highlights li::before {
  content: "";
  position: absolute;
  top: 0.6em;
  left: 0.15rem;
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 2px;
  background: linear-gradient(135deg, var(--g1), var(--g3));
  transform: rotate(45deg);
}

.xp-highlights strong { color: var(--text); }

@media (min-width: 56rem) {
  .xp-card {
    grid-template-columns: minmax(14rem, 19rem) minmax(0, 1fr);
    gap: 2.5rem;
  }

  .xp-highlights {
    align-content: start;
    padding: 0 0 0 2.5rem;
    border-top: 0;
    border-left: 1px solid var(--border);
  }
}

/* ---------- Publications ---------- */
.pub-list {
  display: grid;
  gap: 1rem;
  padding: 0;
  list-style: none;
}

.pub-card { display: grid; gap: 0.85rem; }

.pub-card.is-featured {
  background: radial-gradient(120% 150% at 0% 0%, var(--accent-soft), transparent 55%), var(--surface);
}

.pub-card.is-featured::before { opacity: 0.85; }

@media (min-width: 48rem) {
  .pub-card { grid-template-columns: 6.5rem minmax(0, 1fr); gap: 2rem; }
}

.pub-year {
  margin: 0;
  font-family: var(--font-mono);
  font-size: clamp(1.5rem, 1.15rem + 1.5vw, 2.25rem);
  font-weight: 600;
  line-height: 1;
  letter-spacing: -0.04em;
}

.pub-body { min-width: 0; }

.pub-title {
  font-size: clamp(1.15rem, 1.02rem + 0.6vw, 1.45rem);
  line-height: 1.3;
  letter-spacing: -0.02em;
}

.pub-title a {
  background: linear-gradient(var(--accent), var(--accent)) 0 100% / 0 1.5px no-repeat;
  color: var(--text);
  transition: color 0.2s ease; /* the underline wipe is added under Motion */
}

.pub-title a:hover { background-size: 100% 1.5px; color: var(--accent-strong); }

.pub-authors { margin: 0.65rem 0 0; color: var(--text-2); font-size: 0.95rem; }
.pub-authors strong { color: var(--text); font-weight: 650; }

.pub-venue { margin: 0.3rem 0 0; color: var(--muted); font-size: 0.9rem; }
.pub-venue em { color: var(--text-2); }

/* ---------- Featured projects ---------- */
.project-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 18.5rem), 1fr));
  gap: 1rem;
  padding: 0;
  list-style: none;
}

.project-card { display: flex; flex-direction: column; }

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

.project-arrow {
  display: grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted);
  transition: color 0.2s ease, border-color 0.2s ease, background-color 0.2s ease, transform 0.25s ease;
}

.project-arrow .icon { width: 1rem; height: 1rem; }

.project-card:hover .project-arrow,
.project-card:focus-within .project-arrow {
  border-color: var(--accent-ring);
  background: var(--accent-soft);
  color: var(--accent);
}

.project-name {
  font-size: 1.075rem;
  line-height: 1.35;
  letter-spacing: -0.015em;
  overflow-wrap: anywhere;
}

.project-name a,
.project-name a:hover { color: var(--text); }

.project-desc {
  flex: 1;
  margin: 0.5rem 0 1.25rem;
  color: var(--text-2);
  font-size: 0.925rem;
  line-height: 1.6;
}

.project-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.9rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.lang {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.78rem;
}

/* Language dot colors follow GitHub's linguist palette */
.lang-dot {
  width: 0.6rem;
  height: 0.6rem;
  border-radius: 50%;
  background: var(--lang, var(--accent));
  box-shadow: 0 0 0 3px var(--chip-bg);
}

.lang-python { --lang: #3572a5; }
.lang-jupyter-notebook { --lang: #da5b0b; }
.lang-matlab { --lang: #e16737; }
.lang-javascript { --lang: #f1e05a; }
.lang-typescript { --lang: #3178c6; }
.lang-java { --lang: #b07219; }
.lang-r { --lang: #198ce7; }
.lang-go { --lang: #00add8; }
.lang-rust { --lang: #dea584; }
.lang-shell { --lang: #89e051; }

/* ---------- Posts ---------- */
.post-list {
  display: grid;
  gap: 1rem;
  padding: 0;
  list-style: none;
}

.post-list--grid { grid-template-columns: repeat(auto-fill, minmax(min(100%, 19rem), 1fr)); }

.post-card { display: flex; flex-direction: column; gap: 0.7rem; }

.post-card-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 1rem;
  margin: 0;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.76rem;
}

.post-card-meta time,
.post-card-meta span { display: inline-flex; align-items: center; gap: 0.35rem; }
.post-card-meta .icon { width: 0.9rem; height: 0.9rem; }

.post-card-title { font-size: 1.2rem; line-height: 1.3; letter-spacing: -0.02em; }
.post-card-title a,
.post-card-title a:hover { color: var(--text); }

.post-card-desc { margin: 0; color: var(--text-2); font-size: 0.95rem; }

.card-cta {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin-top: auto;
  padding-top: 0.35rem;
  color: var(--accent);
  font-size: 0.875rem;
  font-weight: 560;
}

.card-cta .icon { width: 1rem; height: 1rem; transition: transform 0.25s ease; }

.more-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: 1.5rem;
  font-weight: 560;
}

.more-link .icon { width: 1rem; height: 1rem; transition: transform 0.25s ease; }

/* ---------- Talks, teaching & service ---------- */
.activity-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 24rem), 1fr));
  gap: 1rem;
  padding: 0;
  list-style: none;
}

.activity-card { display: flex; align-items: flex-start; gap: 1rem; }
.activity-body { min-width: 0; }

.activity-title { font-size: 1.05rem; line-height: 1.35; letter-spacing: -0.015em; }

.activity-detail { margin: 0.35rem 0 0; color: var(--text-2); font-size: 0.935rem; }

.activity-period {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin: 0.75rem 0 0;
  padding: 0.15rem 0.6rem;
  border-radius: 999px;
  background: var(--chip-bg);
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.75rem;
}

.activity-period .icon { width: 0.85rem; height: 0.85rem; }

/* ---------- Skills ---------- */
.skill-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 18rem), 1fr));
  gap: 1rem;
  padding: 0;
  list-style: none;
}

.skill-card { display: flex; flex-direction: column; gap: 1rem; }

.skill-area {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 1.05rem;
  letter-spacing: -0.015em;
}

/* ---------- Education ---------- */
.edu-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 24rem), 1fr));
  gap: 1rem;
  padding: 0;
  list-style: none;
}

.edu-card { display: flex; flex-direction: column; }

.edu-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.edu-period {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
}

.edu-period .icon { width: 0.9rem; height: 0.9rem; }

.edu-degree { font-size: 1.125rem; line-height: 1.35; letter-spacing: -0.02em; }

.edu-school { margin: 0.35rem 0 0; color: var(--text-2); font-weight: 500; }

.edu-thesis {
  margin: 1rem 0 0;
  padding-top: 1rem;
  border-top: 1px dashed var(--border-strong);
  color: var(--text-2);
  font-size: 0.935rem;
}

.edu-label {
  display: block;
  margin-bottom: 0.2rem;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.edu-thesis a { text-decoration: underline; text-decoration-color: var(--accent-ring); text-underline-offset: 3px; }
.edu-thesis a:hover { text-decoration-color: currentColor; }

.schools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1rem;
  margin-top: 1.75rem;
}

.schools-title {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

/* ---------- Page heroes: blog, post, 404 ---------- */
.page-hero {
  padding-top: calc(var(--header-h) + clamp(2.5rem, 1rem + 5vw, 4.5rem));
  padding-bottom: clamp(1.5rem, 1rem + 2vw, 2.5rem);
}

.page-hero--center { padding-bottom: clamp(4rem, 2rem + 8vw, 7rem); text-align: center; }
.page-hero--center .page-lead { margin-inline: auto; }

.kicker {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  margin: 0 0 1rem;
  color: var(--accent-strong);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.kicker .icon { width: 1rem; height: 1rem; }

.page-title {
  font-size: clamp(2.25rem, 1.6rem + 3.2vw, 3.75rem);
  font-weight: 720;
  line-height: 1.05;
  letter-spacing: -0.04em;
}

.page-lead {
  max-width: 40rem;
  margin: 1rem 0 0;
  color: var(--text-2);
  font-size: clamp(1.05rem, 1rem + 0.4vw, 1.25rem);
  line-height: 1.55;
}

.page-hero .btn { margin-top: 1.75rem; }

.error-code {
  margin: 0 0 0.75rem;
  font-family: var(--font-mono);
  font-size: clamp(4.5rem, 3rem + 8vw, 8rem);
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.06em;
}

.year {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 2.5rem 0 1rem;
  color: var(--text-2);
  font-family: var(--font-mono);
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0;
}

.year::after {
  content: "";
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, var(--border-strong), transparent);
}

.year:first-child { margin-top: 0; }

.empty-state { color: var(--muted); }

/* ---------- Post ---------- */
.back {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 1.75rem;
  padding: 0.35rem 0.9rem 0.35rem 0.7rem;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--glass);
  color: var(--text-2);
  font-size: 0.875rem;
  font-weight: 520;
  transition: color 0.2s ease, border-color 0.2s ease;
}

.back .icon { width: 1rem; height: 1rem; transition: transform 0.25s ease; }
.back:hover { border-color: var(--accent-ring); color: var(--text); }

.post-title { font-size: clamp(2rem, 1.4rem + 3vw, 3.25rem); }

.post-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1.25rem;
  margin: 1.5rem 0 0;
  color: var(--text-2);
  font-family: var(--font-mono);
  font-size: 0.8rem;
}

.post-meta time,
.post-meta span { display: inline-flex; align-items: center; gap: 0.4rem; }
.post-meta .icon { width: 0.95rem; height: 0.95rem; color: var(--accent-strong); }

.post-tags { margin-top: 1rem; }
.post-tags .tag { background: var(--glass); }

.post-content {
  padding: clamp(1rem, 0.5rem + 2vw, 2rem) 0 1rem;
  color: var(--text-2);
  font-size: 1.0625rem;
  line-height: 1.75;
}

.post-content > :first-child { margin-top: 0; }

.post-content p,
.post-content ul,
.post-content ol { margin: 0 0 1.25rem; }

.post-content h2 {
  margin: 2.75rem 0 1rem;
  font-size: clamp(1.4rem, 1.2rem + 0.8vw, 1.75rem);
  letter-spacing: -0.025em;
}

.post-content h2::before {
  content: "";
  display: block;
  width: 2.25rem;
  height: 3px;
  margin-bottom: 0.85rem;
  border-radius: 3px;
  background: var(--grad-text);
}

.post-content h3 { margin: 2rem 0 0.75rem; font-size: 1.25rem; }
.post-content h4 { margin: 1.5rem 0 0.5rem; font-size: 1.05rem; }
.post-content strong { color: var(--text); }

.post-content a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-color: var(--accent-ring);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  transition: text-decoration-color 0.2s ease;
}

.post-content a:hover { color: var(--accent-strong); text-decoration-color: currentColor; }

.post-content ul,
.post-content ol { padding-left: 1.4rem; }

.post-content li { margin: 0.35rem 0; }
.post-content li::marker { color: var(--accent); }

.post-content img {
  height: auto;
  margin: 1.75rem auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
}

.post-content blockquote {
  position: relative;
  margin: 1.75rem 0;
  padding: 1rem 1.25rem 1rem 1.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text-2);
}

.post-content blockquote::before {
  content: "";
  position: absolute;
  top: 0.9rem;
  bottom: 0.9rem;
  left: -1px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: linear-gradient(to bottom, var(--g1), var(--g3));
}

.post-content blockquote > :last-child { margin-bottom: 0; }

.post-content table {
  display: block;
  max-width: 100%;
  margin: 1.75rem 0;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.95rem;
}

.post-content th,
.post-content td {
  padding: 0.6rem 0.9rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
}

.post-content th { background: var(--chip-bg); color: var(--text); font-weight: 600; }
.post-content tr:last-child td { border-bottom: 0; }

.post-content hr {
  height: 1px;
  margin: 2.75rem 0;
  border: 0;
  background: linear-gradient(90deg, transparent, var(--border-strong), transparent);
}

.katex-display { overflow-x: auto; overflow-y: hidden; padding: 0.25rem 0; }

/* ---------- Code ---------- */
code,
kbd,
samp,
pre { font-family: var(--font-mono); }

code { font-size: 0.875em; }

:not(pre) > code {
  padding: 0.14em 0.4em;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--code-inline-bg);
  color: var(--code-text);
  font-size: 0.85em;
  overflow-wrap: anywhere;
}

pre {
  margin: 0;
  overflow-x: auto;
  font-size: 0.875rem;
  line-height: 1.65;
  tab-size: 4;
}

pre code { font-size: inherit; }

div.highlighter-rouge,
figure.highlight {
  position: relative;
  margin: 1.75rem 0;
  overflow: hidden;
  border: 1px solid var(--code-border);
  border-radius: var(--radius);
  background: var(--code-bg);
  box-shadow: var(--shadow-card);
}

div.highlighter-rouge::before,
figure.highlight::before {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  left: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--g1), var(--g2), var(--g3), transparent);
  opacity: 0.7;
}

.highlight pre {
  padding: 1.1rem 1.25rem;
  background: transparent;
  color: var(--code-text);
}

/* Language label for common languages */
div.highlighter-rouge::after {
  position: absolute;
  top: 0.6rem;
  right: 0.75rem;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  background: var(--chip-bg);
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  pointer-events: none;
}

div.language-python::after { content: "python"; }
div.language-bash::after,
div.language-shell::after,
div.language-sh::after,
div.language-console::after { content: "shell"; }
div.language-javascript::after,
div.language-js::after { content: "javascript"; }
div.language-typescript::after,
div.language-ts::after { content: "typescript"; }
div.language-json::after { content: "json"; }
div.language-yaml::after,
div.language-yml::after { content: "yaml"; }
div.language-sql::after { content: "sql"; }
div.language-html::after { content: "html"; }
div.language-css::after { content: "css"; }
div.language-java::after { content: "java"; }
div.language-c::after { content: "c"; }
div.language-cpp::after { content: "c++"; }
div.language-matlab::after { content: "matlab"; }
div.language-latex::after,
div.language-tex::after { content: "latex"; }
div.language-toml::after { content: "toml"; }
div.language-dockerfile::after { content: "dockerfile"; }
div.language-diff::after { content: "diff"; }

:is(div.language-python, div.language-bash, div.language-shell, div.language-sh, div.language-console,
    div.language-javascript, div.language-js, div.language-typescript, div.language-ts, div.language-json,
    div.language-yaml, div.language-yml, div.language-sql, div.language-html, div.language-css,
    div.language-java, div.language-c, div.language-cpp, div.language-matlab, div.language-latex,
    div.language-tex, div.language-toml, div.language-dockerfile, div.language-diff) pre { padding-top: 2.4rem; }

.highlight .c, .highlight .c1, .highlight .cm, .highlight .cs, .highlight .cd, .highlight .ch, .highlight .cpf { color: var(--code-comment); font-style: italic; }
.highlight .cp, .highlight .k, .highlight .kc, .highlight .kd, .highlight .kn, .highlight .kp, .highlight .kr, .highlight .kt, .highlight .ow, .highlight .nt { color: var(--code-keyword); }
.highlight .s, .highlight .s1, .highlight .s2, .highlight .sa, .highlight .sb, .highlight .sc, .highlight .sd, .highlight .se, .highlight .sh, .highlight .si, .highlight .sr, .highlight .ss, .highlight .sx, .highlight .dl { color: var(--code-string); }
.highlight .m, .highlight .mb, .highlight .mf, .highlight .mh, .highlight .mi, .highlight .mo, .highlight .il, .highlight .no, .highlight .vc, .highlight .vg, .highlight .vi { color: var(--code-number); }
.highlight .nf, .highlight .fm, .highlight .nd, .highlight .na { color: var(--code-function); }
.highlight .nc, .highlight .nn, .highlight .nb, .highlight .bp, .highlight .ne { color: var(--code-class); }
.highlight .gd, .highlight .err { color: var(--code-keyword); }
.highlight .gi { color: var(--code-inserted); }
.highlight .gh, .highlight .gu { color: var(--code-function); font-weight: 600; }

/* ---------- Footer ---------- */
.site-footer {
  position: relative;
  margin-top: calc(var(--space-section) / 2);
  border-top: 1px solid var(--border);
  background: var(--bg-band);
}

.site-footer::before {
  content: "";
  position: absolute;
  top: -1px;
  right: 0;
  left: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--g1), var(--g2), var(--g3), transparent);
  opacity: 0.6;
}

.footer-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1.25rem;
  padding-block: 2.25rem 1.5rem;
}

.footer-role { margin: 0.6rem 0 0; color: var(--muted); font-size: 0.875rem; }

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0;
  list-style: none;
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 2.75rem;
  height: 2.75rem;
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text-2);
  transition: color 0.2s ease, border-color 0.2s ease, background-color 0.2s ease, transform 0.2s ease;
}

.icon-btn:hover { border-color: var(--accent-ring); background: var(--surface-hover); color: var(--accent); }

.footer-bottom {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  padding-block: 1.25rem 2rem;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.85rem;
}

.to-top { display: inline-flex; align-items: center; gap: 0.35rem; color: var(--muted); }
.to-top:hover { color: var(--text); }
.to-top .icon { width: 0.95rem; height: 0.95rem; }

/* ---------- Motion (only when the user has not asked to reduce it) ---------- */
@media (prefers-reduced-motion: no-preference) {
  .glow { animation: drift-1 28s ease-in-out infinite alternate; will-change: transform; }
  .glow-2 { animation-name: drift-2; animation-duration: 34s; }
  .glow-3 { animation-name: drift-3; animation-duration: 31s; }
  .glow-4 { animation-name: drift-4; animation-duration: 38s; }

  .hero-avatar,
  .hero-copy > *,
  .page-hero .container > * { animation: rise 0.7s cubic-bezier(0.2, 0.7, 0.2, 1) both; }

  .hero-copy > :nth-child(2),
  .page-hero .container > :nth-child(2) { animation-delay: 0.06s; }
  .hero-copy > :nth-child(3),
  .page-hero .container > :nth-child(3) { animation-delay: 0.12s; }
  .hero-copy > :nth-child(4),
  .page-hero .container > :nth-child(4) { animation-delay: 0.18s; }
  .hero-copy > :nth-child(5),
  .page-hero .container > :nth-child(5) { animation-delay: 0.24s; }
  .hero-avatar { animation-delay: 0.1s; }

  .orbit { animation: spin 48s linear infinite; }

  .pill-dot::after,
  .timeline-item.is-current .timeline-dot::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: var(--g1);
    animation: ping 2.6s cubic-bezier(0, 0, 0.2, 1) infinite;
  }

  .timeline-item.is-current .timeline-dot::after { inset: -2px; }

  .btn:hover,
  .icon-btn:hover { transform: translateY(-1px); }

  .card-link:hover { transform: translateY(-3px); }
  .card-link:hover .card-cta .icon,
  .more-link:hover .icon { transform: translateX(3px); }
  .project-card:hover .project-arrow,
  .section-action:hover .icon { transform: translate(2px, -2px); }
  .back:hover .icon { transform: translateX(-3px); }

  .pub-title a { transition: background-size 0.3s ease, color 0.2s ease; }
}

@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: none; }
}

@keyframes drift-1 {
  from { transform: translate3d(0, 0, 0) scale(1); }
  to { transform: translate3d(8%, 10%, 0) scale(1.12); }
}

@keyframes drift-2 {
  from { transform: translate3d(0, 0, 0) scale(1.05); }
  to { transform: translate3d(-10%, 8%, 0) scale(0.95); }
}

@keyframes drift-3 {
  from { transform: translate3d(0, 0, 0) scale(1); }
  to { transform: translate3d(-12%, -10%, 0) scale(1.15); }
}

@keyframes drift-4 {
  from { transform: translate3d(0, 0, 0) scale(0.9); }
  to { transform: translate3d(-18%, 14%, 0) scale(1.1); }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes ping {
  0% { opacity: 0.55; transform: scale(1); }
  75%, 100% { opacity: 0; transform: scale(2.6); }
}

/* ---------- Forced colors & print ---------- */
@media (forced-colors: active) {
  .gradient-text,
  .monogram span {
    background: none;
    color: CanvasText;
    -webkit-text-fill-color: CanvasText;
  }

  .card { border-color: CanvasText; }
}

@media print {
  :root,
  :root:not([data-theme="light"]),
  :root[data-theme="dark"] {
    --bg: #fff;
    --bg-band: #fff;
    --surface: #fff;
    --text: #000;
    --text-2: #222;
    --muted: #444;
    --border: #ccc;
    --border-strong: #999;
    /* Text tokens that are light in the dark theme (backgrounds are not printed) */
    --accent: #4338ca;
    --accent-strong: #3730a3;
    --accent-ring: #999;
    --chip-text: #222;
    --code-text: #1f2335;
    --code-comment: #57606a;
    --code-keyword: #cf222e;
    --code-string: #0a3069;
    --code-number: #0550ae;
    --code-function: #8250df;
    --code-class: #953800;
    --code-inserted: #116329;
  }

  /* White text on the brand gradient would vanish without printed backgrounds */
  .badge-highlight,
  .brand-mark {
    border-color: currentColor;
    background: none;
    box-shadow: none;
    color: #000;
  }

  .site-header,
  .skip-link,
  .hero-bg,
  .hero-avatar,
  .hero-links,
  .footer-links,
  .to-top { display: none !important; }

  .hero,
  .page-hero { margin-top: 0; padding-top: 1rem; }

  .card { box-shadow: none; break-inside: avoid; }

  .gradient-text,
  .monogram span { background: none; color: #000; -webkit-text-fill-color: #000; }
}
