/* ---------- Fonts (self-hosted, variable) ---------- */

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

/* ---------- Palette ---------- */

:root {
  color-scheme: light dark;
  --bg: #fcfcfa;
  --ink: #24292e;
  --muted: #6b7480;
  --heading: #183a54;
  --link: #245a81;
  --accent: #b0762b;
  --rule: #e3e2dd;
  --tint: #eef2f6;
  --name-2: #3f7ca8;
}

/* Dark palette: applied when the OS asks for it (unless light is pinned),
   and whenever dark is pinned explicitly by the toggle. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #12171d;
    --ink: #ccd3da;
    --muted: #848d98;
    --heading: #d6e4f0;
    --link: #85b3d6;
    --accent: #dba055;
    --rule: #262d35;
    --tint: #171f28;
    --name-2: #9cc4e4;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #12171d;
  --ink: #ccd3da;
  --muted: #848d98;
  --heading: #d6e4f0;
  --link: #85b3d6;
  --accent: #dba055;
  --rule: #262d35;
  --tint: #171f28;
  --name-2: #9cc4e4;
}

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

/* ---------- Base ---------- */

* {
  margin: 0;
  box-sizing: border-box;
}

body {
  background-color: var(--bg);
  background-image: linear-gradient(to bottom, var(--tint), var(--bg) 21rem);
  background-repeat: no-repeat;
  color: var(--ink);
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 1rem;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

::selection {
  background: var(--heading);
  color: var(--bg);
}

main {
  max-width: 44rem;
  margin: 0 auto;
  padding: 1.5rem 1.5rem 3rem;
}

a {
  color: var(--link);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  text-decoration-color: color-mix(in srgb, var(--link) 35%, transparent);
  transition: text-decoration-color 120ms ease;
}

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

/* ---------- Sticky header ---------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--rule);
}

.site-header .bar {
  max-width: 44rem;
  margin: 0 auto;
  padding: 0.55rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  display: block;
  color: var(--heading);
  transition: color 120ms ease;
}

.brand .logo {
  display: block;
  height: 2rem;
  width: auto;
}

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

.site-nav {
  display: flex;
  align-items: center;
  gap: 1.6rem;
  font-size: 0.8rem;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

/* ---------- Theme toggle ---------- */

.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.25rem;
  color: var(--muted);
  background: none;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: color 120ms ease;
}

.theme-toggle:hover {
  color: var(--accent);
}

.theme-toggle svg {
  display: block;
  width: 1.05rem;
  height: 1.05rem;
}

/* Show the icon of the theme the click will switch to. */
.theme-toggle .sun {
  display: none;
}

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

  :root:not([data-theme="light"]) .theme-toggle .moon {
    display: none;
  }
}

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

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

:root[data-theme="light"] .theme-toggle .sun {
  display: none;
}

:root[data-theme="light"] .theme-toggle .moon {
  display: block;
}

.site-nav a {
  color: var(--muted);
  text-decoration: none;
}

.site-nav a:hover {
  color: var(--link);
}

.site-nav a[aria-current="page"] {
  color: var(--heading);
  border-bottom: 2px solid var(--accent);
  padding-bottom: 2px;
}

/* ---------- Hero ---------- */

.hero {
  margin-top: 2.2rem;
}

.hero .hi {
  font-family: "Newsreader", Georgia, serif;
  font-optical-sizing: auto;
  font-style: italic;
  font-size: 1.35rem;
  color: var(--muted);
  margin-bottom: 0.2rem;
}

.hero h1 {
  font-family: "Newsreader", Georgia, serif;
  font-optical-sizing: auto;
  font-weight: 480;
  font-size: clamp(2.5rem, 7vw, 3.2rem);
  letter-spacing: -0.015em;
  line-height: 1.1;
  color: var(--heading);
}

.hero h1.name {
  font-weight: 560;
  background: linear-gradient(100deg, var(--heading) 30%, var(--name-2));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: var(--heading);
}

.tagline {
  margin-top: 0.9rem;
  color: var(--muted);
  font-size: 1.02rem;
}

.links {
  margin-top: 1.3rem;
  display: flex;
  flex-wrap: wrap;
  gap: 1.4rem;
  font-size: 0.92rem;
}

/* ---------- Sections ---------- */

.about {
  margin-top: 2.8rem;
  display: grid;
  grid-template-columns: 1fr 9rem;
  gap: 2rem;
  align-items: start;
}

.about .portrait {
  order: 1;
  width: 100%;
  height: auto;
  border-radius: 6px;
}

.about p {
  font-family: "Newsreader", Georgia, serif;
  font-optical-sizing: auto;
  font-size: 1.17rem;
  line-height: 1.6;
}

.about p + p {
  margin-top: 1rem;
}

section {
  margin-top: 3.3rem;
}

h2 {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 1.6rem;
}

h2::before {
  content: "";
  width: 1.1rem;
  height: 2px;
  background: var(--accent);
}

h2::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--rule);
}

h3 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--heading);
  line-height: 1.45;
}

h3 a {
  color: inherit;
}

.prose {
  font-size: 0.98rem;
}

/* ---------- Entries (news, projects) ---------- */

.entry {
  display: grid;
  grid-template-columns: 7.5rem 1fr;
  column-gap: 1.5rem;
}

.entry + .entry {
  margin-top: 1.5rem;
}

.entry .meta {
  color: var(--muted);
  font-size: 0.85rem;
  padding-top: 0.15rem;
  font-variant-numeric: tabular-nums;
}

.entry p {
  font-size: 0.95rem;
}

.entry h3 + p {
  margin-top: 0.25rem;
}

/* ---------- Project cards ---------- */

.cards {
  margin-top: 2.5rem;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.1rem;
  align-items: start;
}

.cards.masonry {
  display: flex;
  align-items: flex-start;
}

.cards.masonry .col {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
}

.card {
  border: 1px solid var(--rule);
  border-radius: 1.1rem;
  overflow: hidden;
}

.card .cover {
  display: block;
  width: 100%;
  height: 10.5rem;
  object-fit: cover;
}

.card .cover.contain {
  object-fit: contain;
  background: #fff;
}

.card .body {
  padding: 1rem 1.2rem 1.2rem;
}

.card h3 {
  font-family: "Newsreader", Georgia, serif;
  font-optical-sizing: auto;
  font-size: 1.25rem;
  font-weight: 540;
}

.card .tech {
  margin-top: 0.2rem;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.card p {
  font-size: 0.92rem;
}

.card .tech + p {
  margin-top: 0.6rem;
}

.card .card-links {
  margin-top: 0.8rem;
  display: flex;
  flex-wrap: wrap;
  gap: 1.1rem;
  font-size: 0.88rem;
}

/* ---------- Publications ---------- */

.pubs {
  list-style: none;
  padding: 0;
}

.pubs li + li {
  margin-top: 1.4rem;
}

.pub-title {
  font-family: "Newsreader", Georgia, serif;
  font-optical-sizing: auto;
  font-size: 1.08rem;
  font-weight: 540;
  line-height: 1.45;
  color: var(--heading);
}

.pub-title a {
  color: inherit;
}

.pub-authors {
  margin-top: 0.3rem;
  font-size: 0.88rem;
}

.pub-authors strong {
  font-weight: 600;
}

.pub-meta {
  margin-top: 0.1rem;
  color: var(--muted);
  font-size: 0.88rem;
}

.pub-links {
  margin-top: 0.35rem;
  display: flex;
  gap: 1rem;
}

.pub-btn {
  font-family: inherit;
  font-size: 0.8rem;
  letter-spacing: 0.04em;
  color: var(--link);
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  text-decoration-color: color-mix(in srgb, var(--link) 35%, transparent);
  transition: text-decoration-color 120ms ease;
}

.pub-btn:hover {
  text-decoration-color: var(--accent);
}

.pub-btn.active {
  color: var(--accent);
  text-decoration-color: var(--accent);
}

.pub-panel {
  display: none;
  position: relative;
  margin-top: 0.7rem;
}

.pub-panel.open {
  display: block;
}

.pub-panel p {
  font-size: 0.87rem;
  line-height: 1.6;
  border-left: 2px solid var(--accent);
  padding-left: 0.9rem;
}

.pub-panel pre {
  margin: 0;
  padding: 0.9rem 1rem;
  font-size: 0.76rem;
  line-height: 1.55;
  overflow-x: auto;
  border-radius: 6px;
  background: color-mix(in srgb, var(--rule) 40%, transparent);
}

.bib-copy {
  position: absolute;
  top: 0.5rem;
  right: 0.55rem;
  font-family: inherit;
  font-size: 0.68rem;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--muted);
  background: var(--bg);
  border: 1px solid var(--rule);
  border-radius: 4px;
  padding: 0.16rem 0.5rem;
  cursor: pointer;
  transition: color 120ms ease, border-color 120ms ease;
}

.bib-copy:hover {
  color: var(--link);
  border-color: var(--link);
}

.bib-copy.copied {
  color: var(--accent);
  border-color: var(--accent);
}

/* ---------- Photo gallery ---------- */

.featured {
  margin: 2rem auto 0;
  max-width: 27rem;
}

.featured img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 3px;
}

.featured figcaption {
  margin-top: 0.5rem;
  text-align: center;
  font-size: 0.82rem;
  color: var(--muted);
}

.gallery {
  margin-top: 2rem;
  columns: 3;
  column-gap: 0.9rem;
}

.shot {
  position: relative;
  margin: 0 0 0.9rem;
  border-radius: 3px;
  overflow: hidden;
  break-inside: avoid;
  cursor: pointer;
}

.shot img {
  display: block;
  width: 100%;
  height: auto;
  transition: transform 350ms ease, filter 350ms ease;
}

.shot:hover img,
.shot:focus-visible img {
  transform: scale(1.045);
}

.shot.open img {
  transform: scale(1.06);
  filter: blur(9px) brightness(0.6);
}

.shot figcaption {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 0.35rem;
  padding: 0.9rem;
  text-align: center;
  opacity: 0;
  transition: opacity 300ms ease;
  pointer-events: none;
}

.shot.open figcaption {
  opacity: 1;
}

.shot-title {
  font-family: "Newsreader", Georgia, serif;
  font-optical-sizing: auto;
  font-size: 1rem;
  font-weight: 540;
  line-height: 1.35;
  color: #fff;
}

.shot-place {
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.92);
}

.shot-tech {
  font-size: 0.72rem;
  letter-spacing: 0.02em;
  color: rgba(255, 255, 255, 0.72);
}

/* Discourage casual saving: no dragging, no long-press selection, and the
   image itself never receives events (clicks land on the figure) */
.featured img,
.shot img {
  pointer-events: none;
  -webkit-user-drag: none;
  user-select: none;
  -webkit-user-select: none;
}

@media (prefers-reduced-motion: reduce) {
  .shot img,
  .shot figcaption {
    transition: none;
  }

  .shot:hover img,
  .shot:focus-visible img,
  .shot.open img {
    transform: none;
  }
}

/* ---------- Footer ---------- */

footer {
  margin-top: 4rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--rule);
}

.colophon {
  color: var(--muted);
  font-size: 0.8rem;
}

/* ---------- Small screens ---------- */

@media (max-width: 540px) {
  .site-header .bar {
    padding: 0.6rem 1.25rem;
  }

  .about {
    grid-template-columns: 1fr;
    gap: 1.4rem;
  }

  .about .portrait {
    order: 0;
    width: 9rem;
  }

  .site-nav {
    gap: 1.1rem;
  }

  .entry {
    grid-template-columns: 1fr;
  }

  .entry .meta {
    padding-top: 0;
    margin-bottom: 0.1rem;
  }

  .cards {
    grid-template-columns: 1fr;
  }

  .links {
    gap: 1.1rem;
  }

  .gallery {
    columns: 2;
  }
}
