/* ============================================================
   kvalvik.org — site.css
   One stylesheet for every page. Edit here, not in the pages.
   ============================================================ */

:root {
  --ink: #050505;            /* page ground — true black */
  --surface: rgba(255,255,255,0.035);
  --surface-hi: rgba(255,255,255,0.07);
  --line: rgba(255,255,255,0.09);
  --line-hi: rgba(255,255,255,0.2);
  --text: #ececec;
  --muted: #9a9a9a;
  --dim: #6a6a6a;
  --blue: #60A5FA;
  --green: #34D399;
  --grad: linear-gradient(100deg, var(--blue), var(--green));

  --serif: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

  --nav-h: 64px;
  --wrap: 1280px;
  --ease: cubic-bezier(.2,.7,.2,1);
}

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

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

body {
  margin: 0;
  background: var(--ink);
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

img { max-width: 100%; display: block; }
a { color: inherit; }
a:focus-visible, button:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 3px;
  border-radius: 2px;
}

/* ---------- type ---------- */
h1, h2, h3 { font-family: var(--serif); font-weight: 600; letter-spacing: -0.02em; line-height: 1.15; margin: 0; }
h1 { font-size: clamp(2rem, 4vw, 3rem); }
h2 { font-size: clamp(1.4rem, 2.4vw, 1.85rem); }
h3 { font-size: 1.15rem; }
p  { margin: 0; }

.grad {
  background: var(--grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  -webkit-text-fill-color: transparent;
  padding-bottom: .05em;  /* keeps descenders from clipping */
}

.lede { color: var(--muted); font-size: 1.05rem; max-width: 60ch; }

/* ---------- nav ---------- */
.nav {
  position: fixed; inset: 0 0 auto 0;
  height: var(--nav-h);
  z-index: 100;
  display: flex; align-items: center;
  padding: 0 clamp(1rem, 3vw, 2.5rem);
  border-bottom: 1px solid transparent;
  transition: background .4s var(--ease), border-color .4s var(--ease), backdrop-filter .4s;
}
.nav.is-scrolled {
  background: rgba(5,5,5,0.78);
  backdrop-filter: blur(14px) saturate(140%);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  border-bottom-color: var(--line);
}
.nav__brand {
  font-family: var(--serif); font-style: italic; font-size: 1.05rem;
  text-decoration: none; color: var(--text); opacity: .9;
  white-space: nowrap; margin-right: auto;
}
.nav__brand:hover { opacity: 1; }
.nav__links {
  display: flex; gap: clamp(1rem, 2.2vw, 2rem);
  list-style: none; margin: 0; padding: 0;
  overflow-x: auto; scrollbar-width: none;
}
.nav__links::-webkit-scrollbar { display: none; }
.nav__links a {
  position: relative; display: block; padding: .35rem 0;
  font-size: .88rem; letter-spacing: .02em; white-space: nowrap;
  color: var(--muted); text-decoration: none;
  transition: color .25s;
}
.nav__links a::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 1px;
  background: var(--grad);
  transform: scaleX(0); transform-origin: left;
  transition: transform .35s var(--ease);
}
.nav__links a:hover { color: var(--text); }
.nav__links a:hover::after { transform: scaleX(1); }
.nav__links a.is-active { color: var(--text); }
.nav__links a.is-active::after { transform: scaleX(1); }

/* ---------- page shell ---------- */
main { flex: 1; }
.wrap { width: min(var(--wrap), 100% - 2rem); margin-inline: auto; }
.page { padding-top: calc(var(--nav-h) + clamp(2rem, 5vw, 4rem)); padding-bottom: clamp(3rem, 6vw, 5rem); }
.page-head { margin-bottom: clamp(1.5rem, 3vw, 2.5rem); }
.page-head h1 { display: inline-block; }
.page-head .lede { margin-top: .6rem; }

/* ---------- hero (home) ---------- */
.hero {
  min-height: 100vh;
  display: flex; align-items: center;
  padding-top: var(--nav-h);
  position: relative;
}
.hero::before {
  /* one quiet vignette; the only decorative element on the page */
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(ellipse 60% 50% at 50% 45%, rgba(96,165,250,0.07), transparent 70%);
}
.hero__inner {
  position: relative;
  display: grid; grid-template-columns: 300px 1fr; gap: clamp(2rem, 5vw, 4.5rem);
  align-items: center;
  max-width: 980px; margin-inline: auto;
}
.portrait { position: relative; width: 300px; height: 300px; }
.portrait img {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.85);
  opacity: 0; transition: opacity 1.2s ease-in-out;
}
.portrait img.is-visible { opacity: 1; }
.hero h1 { font-size: clamp(2.6rem, 5.5vw, 4rem); display: inline-block; }
.hero__role { font-family: var(--serif); font-style: italic; color: var(--muted); font-size: 1.2rem; margin-top: .4rem; }
.hero__blurb { color: var(--muted); max-width: 52ch; margin-top: 1.25rem; }
.hero__contact { margin-top: 1.75rem; color: var(--muted); font-size: .95rem; line-height: 1.8; }
.hero__contact a { color: var(--text); text-decoration: none; border-bottom: 1px solid var(--line-hi); }
.hero__contact a:hover { border-bottom-color: var(--blue); }

.sections {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 1rem;
  max-width: var(--wrap); margin: clamp(2rem, 5vw, 4rem) auto 0;
}
.section-card {
  display: block; text-decoration: none;
  padding: 1.4rem 1.25rem 1.3rem;
  border: 1px solid var(--line); border-radius: 6px;
  background: var(--surface);
  transition: border-color .3s, background .3s, transform .3s var(--ease);
}
.section-card:hover { border-color: var(--line-hi); background: var(--surface-hi); transform: translateY(-3px); }
.section-card h2 { font-size: 1.2rem; }
.section-card p { color: var(--muted); font-size: .88rem; margin-top: .35rem; }

/* ---------- cards / grids ---------- */
.grid { display: grid; gap: 1.25rem; }
.grid--3 { grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); }
.grid--4 { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }

.card {
  border: 1px solid var(--line); border-radius: 6px; overflow: hidden;
  background: var(--surface);
  transition: border-color .3s, transform .3s var(--ease);
}
.card:hover { border-color: var(--line-hi); transform: translateY(-3px); }
.card__body { padding: .9rem 1rem 1rem; }
.card__body h3 { font-size: 1.05rem; }
.card__body p { color: var(--muted); font-size: .88rem; margin-top: .3rem; }

.section + .section { margin-top: clamp(2rem, 4vw, 3rem); }
.section > h2 { padding-bottom: .5rem; border-bottom: 1px solid var(--line); margin-bottom: 1.1rem; }

/* ---------- video facade (click-to-play) ---------- */
.yt {
  position: relative; aspect-ratio: 16/9; background: #000; cursor: pointer;
  overflow: hidden;
}
.yt img { width: 100%; height: 100%; object-fit: cover; opacity: .82; transition: opacity .3s, transform .6s var(--ease); }
.yt:hover img { opacity: 1; transform: scale(1.03); }
.yt__play {
  position: absolute; inset: 0; margin: auto; width: 60px; height: 60px;
  border-radius: 50%; border: 1px solid rgba(255,255,255,0.55);
  background: rgba(5,5,5,0.55); backdrop-filter: blur(4px);
  display: grid; place-items: center; transition: background .3s, border-color .3s;
}
.yt__play::after {
  content: ""; width: 0; height: 0; margin-left: 4px;
  border-left: 16px solid #fff; border-top: 10px solid transparent; border-bottom: 10px solid transparent;
}
.yt:hover .yt__play { background: rgba(5,5,5,0.8); border-color: #fff; }
.yt iframe, .yt video { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.yt video { object-fit: cover; }

/* ---------- photo gallery ---------- */
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1rem; }
.gallery__item {
  position: relative; aspect-ratio: 4/3; overflow: hidden; border-radius: 6px;
  cursor: zoom-in; background: var(--surface); border: 0; padding: 0;
}
.gallery__item img { width: 100%; height: 100%; object-fit: cover; transition: transform .7s var(--ease); }
.gallery__item:hover img { transform: scale(1.04); }
.gallery__cap {
  position: absolute; left: 0; right: 0; bottom: 0;
  padding: .6rem .8rem; font-size: .85rem; color: var(--text);
  background: linear-gradient(to top, rgba(5,5,5,.85), transparent);
  opacity: 0; transform: translateY(6px);
  transition: opacity .3s, transform .3s var(--ease);
}
.gallery__item:hover .gallery__cap, .gallery__item:focus-visible .gallery__cap { opacity: 1; transform: none; }

/* lightbox */
.lightbox {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(5,5,5,.94);
  display: none; align-items: center; justify-content: center;
}
.lightbox.is-open { display: flex; }
.lightbox img { max-width: min(92vw, 1600px); max-height: 88vh; object-fit: contain; }
.lightbox__cap { position: absolute; bottom: 1.5rem; left: 0; right: 0; text-align: center; color: var(--muted); font-size: .9rem; }
.lightbox__btn {
  position: absolute; background: none; border: 0; color: var(--text); cursor: pointer;
  font-size: 2rem; line-height: 1; padding: .5rem .8rem; opacity: .6; transition: opacity .2s;
}
.lightbox__btn:hover { opacity: 1; }
.lightbox__close { top: .75rem; right: 1rem; }
.lightbox__prev { left: .5rem; top: 50%; transform: translateY(-50%); }
.lightbox__next { right: .5rem; top: 50%; transform: translateY(-50%); }

/* ---------- publications: category cards ---------- */
.pubs { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 1.25rem; }
.pub-card {
  position: relative; display: block; text-decoration: none;
  padding: 1.75rem 1.5rem 1.5rem;
  border: 1px solid var(--line); border-radius: 6px; background: var(--surface);
  transition: border-color .3s, background .3s, transform .3s var(--ease);
}
.pub-card:hover { border-color: var(--line-hi); background: var(--surface-hi); transform: translateY(-3px); }
.pub-card__count { position: absolute; top: 1.4rem; right: 1.5rem; font-family: var(--serif); font-style: italic; color: var(--dim); font-size: .95rem; }
.pub-card h2 { display: inline-block; margin-bottom: .75rem; }
.pub-card p { color: var(--muted); font-size: .95rem; }
.pub-card__go { display: inline-block; margin-top: 1.25rem; font-size: .9rem; color: var(--blue); }

/* ---------- publications: paper list + preview ---------- */
.papers { display: grid; grid-template-columns: minmax(260px, 320px) 1fr; gap: clamp(2rem, 5vw, 4rem); align-items: start; }
.papers__list { border-right: 1px solid var(--line); padding-right: clamp(1.25rem, 3vw, 2.5rem); }
.papers__list h1 { display: inline-block; }
.papers__list .lede { font-size: .95rem; margin: .5rem 0 1.5rem; }
.paper {
  display: block; width: 100%; text-align: left; background: none; border: 0; color: var(--text);
  font: inherit; font-weight: 600; font-size: .95rem; line-height: 1.35;
  padding: .85rem 0; border-top: 1px solid var(--line); cursor: pointer;
  transition: color .2s, padding-left .3s var(--ease);
}
.paper:hover, .paper.is-active { padding-left: .6rem; }
.paper.is-active { color: var(--green); }
.papers__preview { position: sticky; top: calc(var(--nav-h) + 2rem); min-height: 50vh; }
.preview { opacity: 0; transform: translateY(8px); transition: opacity .45s var(--ease), transform .45s var(--ease); }
.preview.is-in { opacity: 1; transform: none; }
.preview h2 { display: inline-block; margin-bottom: 1rem; }
.preview__text {
  font-family: var(--serif); font-size: 1.12rem; line-height: 1.7; color: var(--text);
  max-height: 11.5em; overflow: hidden; position: relative;
  -webkit-mask-image: linear-gradient(to bottom, #000 60%, transparent);
  mask-image: linear-gradient(to bottom, #000 60%, transparent);
}
.papers__empty { color: var(--dim); font-family: var(--serif); font-style: italic; font-size: 1.1rem; padding-top: 3rem; }
.btn {
  display: inline-block; margin-top: 1.5rem; padding: .7rem 1.4rem;
  border-radius: 999px; text-decoration: none; color: #050505; font-weight: 600; font-size: .92rem;
  background: var(--grad); transition: transform .25s var(--ease), box-shadow .3s;
}
.btn:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(52,211,153,0.25); }

.pager {
  display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
  margin-top: clamp(2.5rem, 5vw, 4rem); padding-top: 1.25rem; border-top: 1px solid var(--line);
  font-size: .92rem;
}
.pager a { color: var(--muted); text-decoration: none; transition: color .2s; }
.pager a:hover { color: var(--text); }

/* ---------- footer ---------- */
.footer {
  border-top: 1px solid var(--line);
  padding: 1.5rem clamp(1rem, 3vw, 2.5rem);
  display: flex; justify-content: space-between; gap: 1rem 2rem; flex-wrap: wrap;
  font-size: .82rem; color: var(--dim);
}
.footer a { color: var(--dim); text-decoration: none; transition: color .2s; }
.footer a:hover { color: var(--text); }
.footer__meta { display: flex; gap: 1.75rem; flex-wrap: wrap; }

/* ---------- responsive ---------- */
@media (max-width: 860px) {
  .hero__inner { grid-template-columns: 1fr; text-align: center; justify-items: center; }
  .hero__blurb, .lede { margin-inline: auto; }
  .papers { grid-template-columns: 1fr; }
  .papers__list { border-right: 0; padding-right: 0; border-bottom: 1px solid var(--line); padding-bottom: 1rem; }
  .papers__preview { position: static; min-height: 0; }
}
@media (max-width: 560px) {
  .nav__brand { display: none; }
  .portrait { width: 220px; height: 220px; }
  .grid--3 { grid-template-columns: 1fr; }
}
