/* ---------- Design tokens ---------- */
:root,
:root[data-theme="dark"] {
  --bg: #070b14;
  --bg-glow: rgba(47, 107, 255, .16);
  --surface: #0d1424;
  --surface-2: #131c31;
  --line: #1b2844;
  --line-strong: #2a3c63;
  --text: #e8eefc;
  --muted: #95a3c0;
  --accent: #2f6bff;
  --accent-press: #1f55e0;
  --accent-ink: #ffffff;       /* text on accent-colored buttons */
  --link: #7aa2ff;
  --hot: #5b8cff;              /* lit cells in the hero grid, highlights */
  --field-dot: rgba(149, 163, 192, .26);
  --header-bg: rgba(7, 11, 20, .78);

  /* code colors */
  --hl-comment: #8494b4;
  --hl-keyword: #c4a7ff;
  --hl-string: #8fe0a8;
  --hl-number: #ffb86b;
  --hl-func: #7aa2ff;
  --hl-type: #5fd7e6;
  --hl-meta: #ff8fa3;

  --font-mono: ui-monospace, "Cascadia Code", "SFMono-Regular", Menlo, Consolas, monospace;
  --font-display: "Bricolage Grotesque", "Hanken Grotesk", system-ui, sans-serif;
  --font-body: "Hanken Grotesk", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --header-h: 64px;
}

:root[data-theme="light"] {
  --bg: #f6f8fc;
  --bg-glow: rgba(29, 78, 216, .10);
  --surface: #ffffff;
  --surface-2: #eef2f9;
  --line: #dbe3f0;
  --line-strong: #b9c6dd;
  --text: #0b1220;
  --muted: #4a5a72;
  --accent: #1d4ed8;
  --accent-press: #173fb0;
  --accent-ink: #ffffff;
  --link: #1d4ed8;
  --hot: #1d4ed8;
  --field-dot: rgba(74, 90, 114, .30);
  --header-bg: rgba(246, 248, 252, .85);

  --hl-comment: #5a6a85;
  --hl-keyword: #6d28d9;
  --hl-string: #0f7a3d;
  --hl-number: #a14a06;
  --hl-func: #1d4ed8;
  --hl-type: #0e7490;
  --hl-meta: #be123c;
}

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

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background:
    radial-gradient(70rem 34rem at 78% -8rem, var(--bg-glow), transparent 70%) no-repeat,
    var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 1.0625rem;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

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

h1, h2, h3 {
  font-family: var(--font-display);
  line-height: 1.1;
  margin: 0;
}

p { margin: 0 0 1rem; }

a {
  color: var(--link);
  text-decoration: none;
}

code {
  font-size: .9em;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: .1em .4em;
}

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

.container {
  width: min(100% - 2rem, 72rem);
  margin-inline: auto;
}

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

.skip-link {
  position: absolute;
  left: 1rem;
  top: -4rem;
  z-index: 100;
  background: var(--accent);
  color: var(--accent-ink);
  padding: .6rem 1rem;
  border-radius: 8px;
  font-weight: 600;
}
.skip-link:focus { top: 1rem; }

/* ---------- Icons ---------- */
.icon {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: none;
}
.icon--fill { fill: currentColor; stroke: none; }

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

.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--header-h);
}

.nav__logo {
  display: inline-flex;
  align-items: center;
  gap: .6rem;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: -.01em;
  color: var(--text);
}
.nav__mark { width: 18px; height: 18px; fill: var(--text); }
.nav__mark .nav__mark-hot { fill: var(--hot); opacity: 1; }

.nav__actions { display: flex; gap: .5rem; }

/* Mobile: links become a dropdown panel */
.nav__links {
  display: none;
  position: absolute;
  top: var(--header-h);
  left: 0;
  right: 0;
  flex-direction: column;
  margin: 0;
  padding: .5rem 1rem 1rem;
  list-style: none;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.nav__links.is-open { display: flex; }

.nav__links a {
  display: block;
  padding: .75rem .25rem;
  color: var(--text);
  font-weight: 500;
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 42px;
  height: 42px;
  background: transparent;
  color: var(--text);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  cursor: pointer;
  transition: background-color .2s, border-color .2s;
}
.icon-btn:hover { background: var(--surface-2); border-color: var(--hot); }

/* Show the icon for the theme you would switch TO */
.icon--moon { display: none; }
:root[data-theme="light"] .icon--sun { display: none; }
:root[data-theme="light"] .icon--moon { display: block; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-block;
  padding: .8rem 1.5rem;
  border-radius: 8px;
  border: 1px solid transparent;
  font: inherit;
  font-weight: 600;
  line-height: 1.3;
  cursor: pointer;
  transition: background-color .2s, border-color .2s, transform .2s;
}
.btn:hover { transform: translateY(-2px); }
.btn:active { transform: translateY(0); }

.btn--primary { background: var(--accent); color: var(--accent-ink); }
.btn--primary:hover { background: var(--accent-press); }

.btn--ghost {
  background: transparent;
  color: var(--text);
  border-color: var(--line-strong);
}
.btn--ghost:hover { border-color: var(--hot); background: var(--surface-2); }

.btn--small { padding: .45rem .95rem; font-size: .9rem; }

/* ---------- Hero ---------- */
.hero {
  position: relative;
  isolation: isolate;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  min-height: min(calc(100svh - var(--header-h)), 820px);
  padding-top: 5rem;
  overflow: hidden;
}

/* Interactive pixel grid, drawn by script.js */
.hero__field {
  position: absolute;
  inset: 0;
  z-index: -1;
  width: 100%;
  height: 100%;
  -webkit-mask-image: linear-gradient(to bottom, #000 0%, #000 55%, transparent 100%);
  mask-image: linear-gradient(to bottom, #000 0%, #000 55%, transparent 100%);
}

.hero__inner { padding-bottom: 2rem; }

.hero__name {
  font-weight: 800;
  font-size: clamp(3.25rem, 17vw, 14.5rem);
  line-height: .9;
  letter-spacing: -.045em;
}

.hero__role {
  margin: 1.5rem 0 .5rem;
  font-family: var(--font-display);
  font-weight: 500;
  font-size: clamp(1.25rem, 3vw, 2rem);
  letter-spacing: -.01em;
}

.hero__tagline {
  max-width: 34rem;
  margin-bottom: 2rem;
  color: var(--muted);
}

.hero__cta {
  display: flex;
  flex-wrap: wrap;
  gap: .75rem;
}

.facts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin: 3.5rem 0 0;
  border-top: 1px solid var(--line-strong);
}
.facts__item {
  padding: 1.1rem 1rem 1.25rem 0;
  min-width: 0;
}
.facts dt { font-size: .9rem; color: var(--muted); margin-bottom: .15rem; }
.facts dd { margin: 0; font-weight: 500; line-height: 1.4; overflow-wrap: anywhere; }
.facts dd a { color: var(--text); }
.facts dd a:hover { color: var(--link); }

/* One orchestrated entrance for the hero */
.js .hero__inner > * {
  animation: rise .75s cubic-bezier(.2, .7, .2, 1) both;
}
.js .hero__inner > :nth-child(2) { animation-delay: .08s; }
.js .hero__inner > :nth-child(3) { animation-delay: .16s; }
.js .hero__inner > :nth-child(4) { animation-delay: .24s; }
.js .hero__inner > :nth-child(5) { animation-delay: .34s; }

@keyframes rise {
  from { opacity: 0; transform: translateY(16px); }
}

/* ---------- Sections ---------- */
.section {
  padding-block: clamp(4rem, 9vw, 7rem);
  border-top: 1px solid var(--line);
  scroll-margin-top: var(--header-h);
}
#top { scroll-margin-top: 0; }

.section__head {
  display: grid;
  gap: .75rem;
  margin-bottom: 2.5rem;
}

.section__title {
  font-weight: 700;
  font-size: clamp(2.25rem, 5.5vw, 4rem);
  letter-spacing: -.035em;
}

.section__lead {
  max-width: 28rem;
  margin: 0;
  color: var(--muted);
}

/* ---------- Projects ---------- */
.project-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1.25rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.card {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  transition: transform .25s, border-color .25s, box-shadow .25s;
}
.card:hover,
.card:focus-within {
  transform: translateY(-4px);
  border-color: var(--hot);
  box-shadow: 0 20px 40px -24px var(--accent);
}

.card__media {
  overflow: hidden;
  aspect-ratio: 16 / 10;
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
}
.card__img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform .5s cubic-bezier(.2, .7, .2, 1);
}
.card:hover .card__img,
.card:focus-within .card__img { transform: scale(1.04); }

.card__body {
  display: flex;
  flex-direction: column;
  flex: 1;
  padding: 1.25rem 1.25rem 1.4rem;
}

.card__title {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -.02em;
  margin-bottom: .5rem;
}
.card__title a { color: var(--text); transition: color .2s; }
.card__title a:hover { color: var(--link); }
.card__desc { color: var(--muted); font-size: 1rem; }

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
  margin: auto 0 1.1rem;
  padding: 0;
  list-style: none;
}
.tags li {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: .12rem .6rem;
  font-size: .85rem;
  font-weight: 500;
}

.card__links { display: flex; gap: 1.25rem; font-weight: 600; }
.card__links a { position: relative; }

/* Underline that slides in on hover */
.card__links a::after,
.social a span::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: -2px;
  height: 2px;
  background: currentColor;
  transform: scaleX(0);
  transform-origin: left;
  transition: transform .25s;
}
.card__links a:hover::after,
.social a:hover span::after { transform: scaleX(1); }

/* ---------- About ---------- */
.about { display: grid; gap: 3rem; }

.about__text p {
  max-width: 34rem;
  font-size: clamp(1.15rem, 2.2vw, 1.4rem);
  line-height: 1.5;
}
.about__text p:last-child { color: var(--muted); margin-bottom: 0; }

.skills {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr));
  gap: 1.75rem 1.25rem;
  align-content: start;
}
.skills h3 {
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0;
  margin-bottom: .75rem;
}

.slots {
  display: grid;
  gap: .5rem;
  margin: 0;
  padding: 0;
  list-style: none;
}
.slots li {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: .55rem .85rem;
  font-weight: 500;
  transition: border-color .2s, transform .2s;
}
.slots li:hover { border-color: var(--hot); transform: translateX(3px); }

/* ---------- Contact ---------- */
.contact { display: grid; gap: 3rem; }

.contact__email { margin-bottom: 1rem; }
.contact__email a {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(1.5rem, 3.8vw, 2.6rem);
  letter-spacing: -.03em;
  line-height: 1.15;
  color: var(--text);
  overflow-wrap: anywhere;
  background: linear-gradient(var(--hot), var(--hot)) 0 100% / 0 3px no-repeat;
  transition: background-size .3s;
}
.contact__email a:hover { background-size: 100% 3px; }
.contact__actions { margin-bottom: 2rem; }

.social {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  margin: 0;
  padding: 0;
  list-style: none;
}
.social a {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  font-weight: 600;
  color: var(--text);
  transition: color .2s;
}
.social a:hover { color: var(--link); }
.social a span { position: relative; }

.form {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 1.5rem;
}

.field { margin-bottom: 1.1rem; }
.field label { display: block; font-weight: 500; margin-bottom: .35rem; }

.field input,
.field textarea {
  width: 100%;
  padding: .7rem .85rem;
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  transition: border-color .2s;
}
.field input:hover,
.field textarea:hover { border-color: var(--muted); }
.field textarea { resize: vertical; min-height: 8rem; }

.field input:focus-visible,
.field textarea:focus-visible {
  outline: 3px solid var(--hot);
  outline-offset: 1px;
  border-color: var(--hot);
}

.field input[aria-invalid="true"],
.field textarea[aria-invalid="true"] { border-color: #ef4444; }
.field__error { color: #f87171; font-size: .9rem; margin: .35rem 0 0; }
:root[data-theme="light"] .field__error { color: #b91c1c; }

.form__note { color: var(--muted); font-size: .9rem; margin: 1rem 0 0; }

/* Honeypot: hidden from people, ticked by bots */
.form__hp {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.form__status { margin: 1rem 0 0; font-size: .95rem; }
.form__status a { text-decoration: underline; }
.form__status.is-success { color: #4ade80; }
.form__status.is-error { color: #f87171; }
:root[data-theme="light"] .form__status.is-success { color: #15803d; }
:root[data-theme="light"] .form__status.is-error { color: #b91c1c; }

.btn:disabled { opacity: .6; cursor: progress; transform: none; }

/* ---------- Footer ---------- */
.site-footer {
  border-top: 1px solid var(--line);
  padding-block: 2rem;
  color: var(--muted);
  font-size: .95rem;
}
.site-footer p { margin: 0; }
.site-footer__inner {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: .75rem 2rem;
}
.site-footer__links {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem 1.5rem;
  margin: 0;
  padding: 0;
  list-style: none;
}
.site-footer__links a { color: var(--muted); transition: color .2s; }
.site-footer__links a:hover { color: var(--text); }

/* ---------- Scroll reveal ---------- */
/* Only hide when JS is running, so no-JS visitors still see everything */
.js .reveal {
  opacity: 0;
  transform: translateY(12px);
  transition: opacity .5s ease, transform .5s ease;
}
.js .reveal.is-visible { opacity: 1; transform: none; }

/* ---------- Project pages ---------- */
.project-hero {
  padding-block: 2.5rem 3rem;
  border-bottom: 1px solid var(--line);
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  margin-bottom: 1.75rem;
  font-weight: 600;
  color: var(--muted);
  transition: color .2s;
}
.back-link:hover { color: var(--text); }
.back-link .icon { width: 18px; height: 18px; transition: transform .2s; }
.back-link:hover .icon { transform: translateX(-3px); }

.project-hero__title {
  margin-bottom: 1rem;
  font-weight: 800;
  font-size: clamp(2.5rem, 9vw, 6rem);
  line-height: .95;
  letter-spacing: -.04em;
  overflow-wrap: anywhere;
}
.project-hero__lead {
  max-width: 40rem;
  margin-bottom: 1.25rem;
  color: var(--muted);
  font-size: clamp(1.1rem, 2.2vw, 1.35rem);
  line-height: 1.5;
}
.project-hero .tags { margin: 0 0 1.5rem; }
.project-hero__links { display: flex; flex-wrap: wrap; gap: .75rem; }
.project-hero__links:empty { display: none; }

.project-hero__media {
  margin-top: 2.5rem;
  overflow: hidden;
  aspect-ratio: 16 / 10;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 10px;
}
.project-hero__media img { width: 100%; height: 100%; object-fit: cover; }

.doc-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 2rem;
  padding-block: 2.5rem 5rem;
}

/* table of contents */
.toc { min-width: 0; }
.doc-layout--no-toc .toc { display: none; }

.toc__details summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .75rem 1rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  list-style: none;
}
.toc__details summary::-webkit-details-marker { display: none; }
.toc__details summary::after { content: "+"; color: var(--muted); font-size: 1.25rem; line-height: 1; }
.toc__details[open] summary::after { content: "\2212"; }

.toc__list {
  margin: .75rem 0 0;
  padding: 0;
  list-style: none;
  border-left: 1px solid var(--line);
}
.toc__item a {
  display: block;
  margin-left: -1px;
  padding: .35rem 0 .35rem 1rem;
  border-left: 2px solid transparent;
  color: var(--muted);
  font-size: .95rem;
  line-height: 1.35;
  transition: color .2s, border-color .2s;
}
.toc__item--sub a { padding-left: 2rem; font-size: .9rem; }
.toc__item a:hover { color: var(--text); }
.toc__item a[aria-current="true"] {
  color: var(--text);
  border-left-color: var(--hot);
  font-weight: 500;
}

/* doc text */
.prose { min-width: 0; max-width: 44rem; overflow-wrap: break-word; }
.prose > :first-child { margin-top: 0; }

.prose h2,
.prose h3,
.prose h4 {
  scroll-margin-top: calc(var(--header-h) + 1.5rem);
  letter-spacing: -.02em;
}
.prose h2 {
  margin: 3rem 0 1rem;
  font-weight: 700;
  font-size: clamp(1.7rem, 3.4vw, 2.3rem);
  letter-spacing: -.03em;
}
.prose h3 { margin: 2.25rem 0 .75rem; font-weight: 700; font-size: 1.35rem; }
.prose h4 {
  margin: 1.75rem 0 .5rem;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.1rem;
}

.prose p,
.prose ul,
.prose ol { margin: 0 0 1.1rem; }
.prose ul,
.prose ol { padding-left: 1.4rem; }
.prose li { margin-bottom: .4rem; }
.prose li::marker { color: var(--hot); }

.prose a {
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: .2em;
}
.prose a:hover { text-decoration-thickness: 2px; }

.prose blockquote {
  margin: 0 0 1.25rem;
  padding: .85rem 1.1rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 3px solid var(--hot);
  border-radius: 0 8px 8px 0;
  color: var(--muted);
}
.prose blockquote p:last-child { margin-bottom: 0; }

.prose img {
  margin: 1.5rem 0;
  border: 1px solid var(--line);
  border-radius: 8px;
}
.prose hr { margin: 2.5rem 0; border: 0; border-top: 1px solid var(--line); }
.prose code { font-family: var(--font-mono); }

.prose pre {
  margin: 0 0 1.25rem;
  padding: 1rem 1.1rem;
  overflow-x: auto;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: .9rem;
  line-height: 1.55;
  tab-size: 4;
}
.prose pre code {
  display: block;
  padding: 0;
  background: none;
  border: 0;
  font-size: inherit;
}

.table-wrap {
  margin: 0 0 1.25rem;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}
.prose table { width: 100%; border-collapse: collapse; font-size: .95rem; }
.prose th,
.prose td {
  padding: .6rem .9rem;
  text-align: left;
  border-bottom: 1px solid var(--line);
}
.prose th { background: var(--surface); font-weight: 600; white-space: nowrap; }
.prose tr:last-child td { border-bottom: 0; }

/* highlight.js classes */
.hljs { color: var(--text); }
.hljs-comment, .hljs-quote { color: var(--hl-comment); font-style: italic; }
.hljs-keyword, .hljs-selector-tag, .hljs-doctag { color: var(--hl-keyword); }
.hljs-string, .hljs-regexp, .hljs-addition { color: var(--hl-string); }
.hljs-number, .hljs-literal, .hljs-symbol, .hljs-bullet { color: var(--hl-number); }
.hljs-title, .hljs-section { color: var(--hl-func); }
.hljs-title.class_, .hljs-built_in, .hljs-type { color: var(--hl-type); }
.hljs-meta, .hljs-attr, .hljs-attribute, .hljs-variable, .hljs-property, .hljs-deletion { color: var(--hl-meta); }
.hljs-emphasis { font-style: italic; }
.hljs-strong { font-weight: 700; }

/* gallery */
.prose .gallery-section { margin-top: 3rem; }
.prose .gallery {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1.25rem 1rem;
  margin: 1.25rem 0 0;
  padding: 0;
  list-style: none;
}
.prose .gallery li { margin: 0; }
.gallery figure { margin: 0; }
.gallery__link {
  display: block;
  overflow: hidden;
  aspect-ratio: 16 / 10;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  transition: border-color .2s, transform .25s;
}
.gallery__link:hover { border-color: var(--hot); transform: translateY(-3px); }
.prose .gallery__link img {
  width: 100%;
  height: 100%;
  margin: 0;
  object-fit: cover;
  border: 0;
  border-radius: 0;
}
.gallery figcaption { margin-top: .5rem; color: var(--muted); font-size: .9rem; line-height: 1.4; }

/* lightbox */
body:has(.lightbox[open]) { overflow: hidden; }
.lightbox {
  width: 100vw;
  height: 100vh;
  width: 100dvw;
  height: 100dvh;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 1rem;
  overflow: hidden;
  background: transparent;
  border: 0;
  color: #e8eefc;
}
.lightbox[open] { display: grid; place-items: center; }
.lightbox::backdrop {
  background: rgba(3, 6, 12, .9);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}
.lightbox__figure {
  display: grid;
  justify-items: center;
  gap: .75rem;
  max-width: min(100%, 80rem);
  margin: 0;
}
.lightbox__img {
  width: auto;
  height: auto;
  min-width: min(100%, 36rem);
  max-width: 100%;
  max-height: 78vh;
  max-height: 78dvh;
  object-fit: contain;
  background: var(--surface-2);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
}
.lightbox__caption {
  max-width: 40rem;
  min-height: 1.5em;
  font-size: .95rem;
  text-align: center;
}
.lightbox__btn {
  position: fixed;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  color: #e8eefc;
  background: rgba(13, 20, 36, .85);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  cursor: pointer;
  transition: background-color .2s, border-color .2s;
}
.lightbox__btn[hidden] { display: none; }
.lightbox__btn:hover { background: var(--surface-2); border-color: var(--hot); }
.lightbox__close { top: 1rem; right: 1rem; }
.lightbox__prev { bottom: 1rem; left: 1rem; }
.lightbox__next { bottom: 1rem; right: 1rem; }

/* ---------- Larger screens ---------- */
@media (min-width: 640px) {
  .container { width: min(100% - 3rem, 72rem); }
  .form { padding: 2rem; }

  .project-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .card--featured { grid-column: 1 / -1; }
  .card--featured .card__media { aspect-ratio: 2 / 1; }

  .project-hero__media { aspect-ratio: 2 / 1; }
  .prose .gallery { grid-template-columns: repeat(2, minmax(0, 1fr)); }

  .lightbox { padding: 2rem; }
  .lightbox__prev,
  .lightbox__next { top: 50%; bottom: auto; transform: translateY(-50%); }
}

@media (min-width: 960px) {
  .nav__menu-btn { display: none; }

  .nav__links {
    display: flex;
    position: static;
    flex-direction: row;
    gap: 2rem;
    padding: 0;
    background: none;
    border: 0;
  }
  .nav__links a { padding: .25rem 0; position: relative; color: var(--muted); transition: color .2s; }
  .nav__links a:hover { color: var(--text); }
  .nav__links a::after {
    content: "";
    position: absolute;
    left: 0; right: 0; bottom: -2px;
    height: 2px;
    background: var(--hot);
    transform: scaleX(0);
    transform-origin: left;
    transition: transform .25s;
  }
  .nav__links a:hover::after { transform: scaleX(1); }

  .nav { gap: 2rem; }
  .nav__logo { margin-right: auto; }

  .facts { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .facts__item { padding-right: 1.5rem; }
  .facts__item + .facts__item { padding-left: 1.5rem; border-left: 1px solid var(--line); }
  .facts__item:first-child { padding-left: 0; }

  .section__head {
    grid-template-columns: minmax(0, 1fr) minmax(0, 28rem);
    align-items: end;
    gap: 2rem;
  }

  /* Featured card runs the full width: image left, text right */
  .card--featured { flex-direction: row; }
  .card--featured .card__media {
    flex: 0 0 58%;
    aspect-ratio: 16 / 10;
    border-bottom: 0;
    border-right: 1px solid var(--line);
  }
  .card--featured .card__body { justify-content: center; padding: 2.5rem; }
  .card--featured .card__title { font-size: clamp(1.75rem, 3vw, 2.4rem); }
  .card--featured .card__desc { font-size: 1.1rem; }
  .card--featured .tags { margin-top: 0; }

  .doc-layout { grid-template-columns: 15rem minmax(0, 1fr); gap: 4rem; padding-top: 3.5rem; }
  .doc-layout--no-toc { grid-template-columns: minmax(0, 1fr); }
  .toc {
    position: sticky;
    top: calc(var(--header-h) + 1.5rem);
    align-self: start;
    max-height: calc(100vh - var(--header-h) - 3rem);
    overflow-y: auto;
  }
  .toc__details summary { display: none; }
  .toc__list { margin-top: 0; }

  .about { grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: 4rem; }
  .contact { grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); gap: 4rem; }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-delay: 0s !important;
    transition-duration: .01ms !important;
  }
  .js .reveal { opacity: 1; transform: none; }
  .btn:hover, .card:hover, .card:focus-within, .slots li:hover { transform: none; }
  .card:hover .card__img, .card:focus-within .card__img { transform: none; }
  .back-link:hover .icon, .gallery__link:hover { transform: none; }
}
