/* ---------- tokens ---------- */
:root {
  /* silver page, "v1 night" ink (also the hero and ink bands), off-white panel */
  --bg: #e2e4e3;
  --ink: #121212;
  --panel: #f4f3ef;
  --panel-2: #d2d5d4;
  --hover: #6e33c7;
  /* v1 accents (from the old Dracula landing page), for use on dark */
  --v1-purple: #b56fff;
  --v1-pink: #ff79c6;
  --v1-mint: #80ffdb;
  /* chip pastels of the v1 accents (mint, purple, pink) */
  --mint: #b8f5e4;
  --violet: #dcc6ff;
  --rose: #ffc6e5;
  --rule: rgba(18, 18, 18, 0.35);
  /* separators between entries; full ink only marks where something starts */
  --rule-soft: rgba(18, 18, 18, 0.16);
  --sans: "Inter", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --mono: "JetBrains Mono", "SF Mono", Menlo, Consolas, monospace;
  --display: "Inter Tight", "Helvetica Neue", Arial, sans-serif;
  --gutter: clamp(16px, 4vw, 56px);
  --nav-h: 52px; /* real nav height: the hero tucks under it by exactly this much */
  --max: 1280px;
}

* { box-sizing: border-box; }

::selection { background: var(--v1-purple); color: var(--ink); }

html { scroll-behavior: smooth; }
/* while the hero is on screen the canvas is night, so overscroll at the top bounces into dark */
html.night { background: var(--ink); }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 18px;
  line-height: 1.35;
  letter-spacing: -0.01em;
  -webkit-font-smoothing: antialiased;
  position: relative;
}
/* real film grain (CC0 Kodak Tri-X 400 scan by Wiley.andrew.r, Wikimedia Commons),
   printed onto the page so it scrolls with the content; the hero has its own moving copy */
body::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background: url("assets/img/grain-trix400.jpg") 0 0 / 512px;
  mix-blend-mode: overlay;
  opacity: 0.3;
}

a { color: inherit; text-decoration: none; }
a:hover { color: var(--hover); }
p { margin: 0 0 0.75em; }
img { max-width: 100%; display: block; }

.mono { font-family: var(--mono); }

/* ---------- layout ---------- */
.wrap {
  max-width: var(--max);
  margin: 0 auto;
  padding-inline: var(--gutter);
}

.section {
  position: relative;
  scroll-margin-top: calc(var(--nav-h) + 10px);
  padding: clamp(30px, 4.5vw, 64px) 12px;
  margin-block: 8px;
}

/* ---------- editor window (hero) ---------- */
.win-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--ink);
  color: var(--panel);
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1;
  padding: 5px 8px;
}
.win-body {
  padding: 12px 14px;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.5;
}
.win-body p { margin: 0; }

/* ---------- nav ---------- */
.nav {
  position: sticky;
  top: 0;
  z-index: 10;
  margin-inline: calc(50% - 50vw);
  padding-inline: calc(50vw - 50%);
  transition: background-color 0.2s ease, box-shadow 0.2s ease, color 0.2s ease;
  color: var(--panel); /* light over the dark hero, ink once solid */
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding-block: 12px;
  font-family: var(--display);
  font-size: 15px;
  font-weight: 500;
}
.nav ul {
  display: flex;
  gap: 4px;
  list-style: none;
  margin: 0;
  padding: 0;
}
.nav.solid {
  color: var(--ink);
  background: var(--bg);
  box-shadow: 0 1px 0 var(--rule-soft);
}
/* nav links are plain text; .box chrome stays for the footer button */
.nav .box { background: none; border-color: transparent; padding-inline: 6px; }
.nav a.box:hover { background: none; color: var(--v1-mint); text-decoration: underline; text-underline-offset: 4px; }
.nav.solid a.box:hover { color: var(--hover); }

.box {
  display: inline-block;
  background: var(--panel);
  border: 1px solid var(--ink);
  padding: 4px 9px;
  line-height: 1.2;
  white-space: nowrap;
}
a.box:hover { background: var(--ink); color: var(--panel); }

/* ---------- hero ---------- */
.hero {
  position: relative;
  margin-inline: calc(50% - 50vw);
  margin-top: calc(-1 * var(--nav-h));
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: clamp(40px, 8vw, 96px) var(--gutter);
  padding-top: calc(var(--nav-h) + clamp(40px, 8vw, 96px));
  overflow: hidden;
  z-index: 2; /* above the page grain: the hero carries its own moving grain */
  background: var(--ink); /* gradient base: the canvas blur fades its edges into this, not the silver page */
  color: var(--panel);
}
#gradient-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  filter: blur(50px);
  /* "v1 night", from the old Dracula landing page: deep teal and purple on near-black, with the
     v1 accents (purple, pink, mint) in the bottom layers so they only glint at the noise peaks (ceil 1) */
  --gradient-color-1: #121212;
  --gradient-color-2: #b56fff;
  --gradient-color-3: #ff79c6;
  --gradient-color-4: #80ffdb;
  --gradient-color-5: #1b3a4b;
  --gradient-color-6: #3c096c;
  --gradient-color-7: #282a36;
  --gradient-ceil-2: 1;
  --gradient-ceil-3: 1;
  --gradient-ceil-4: 1;
}
/* film finish (assets/js/film.js) redraws the gradient with halation, weave and grade; the plain
   canvas stays as the fallback until its first frame */
#film-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: none; }
.hero.film #film-canvas { display: block; }
.hero.film #gradient-canvas { visibility: hidden; }
/* the same grain over the hero scene at 2x scale (clumpier, more like projected film),
   oversized so script can jump it to a new frame */
.hero-grain {
  position: absolute;
  top: -1024px;
  left: -1024px;
  right: 0;
  bottom: 0;
  z-index: 3;
  pointer-events: none;
  background: url("assets/img/grain-trix400.jpg") 0 0 / 1024px;
  mix-blend-mode: overlay;
  opacity: 0.05;
  will-change: transform;
}

/* hero window: dark glass with the projects cards' hairline edges */
.hero .win.term {
  --rule: rgba(244, 243, 239, 0.35);
  position: relative;
  z-index: 1;
  width: min(660px, 100%);
  background: rgba(18, 18, 18, 0.66);
  -webkit-backdrop-filter: blur(24px) saturate(1.25);
  backdrop-filter: blur(24px) saturate(1.25);
  color: var(--panel);
  border: 1px solid var(--rule);
  overflow: hidden;
}
.hero .win.term .win-bar {
  position: relative;
  background: none;
  color: var(--v1-mint);
  padding: 14px 20px;
  border-bottom: 1px solid var(--rule);
}
/* the hero is section 00 of the numbered section labels */
#term-title::before { content: "00 / "; color: var(--v1-pink); }
.hero .win.term .win-body { padding: 16px 20px 20px; overflow: hidden; }
.hero .term .cursor { background: var(--panel); }
.hero .code { font-size: clamp(13px, 1.55vw, 16px); }
.hero .code .kw { color: var(--v1-mint); font-weight: 400; }
.hero .code.out { border-top: 1px dotted var(--rule); }
.hero .code.out a { color: var(--v1-pink); }
.code .ghost { opacity: 0.5; font-style: italic; transition: opacity 0.3s; animation: fade-in 0.3s ease-out 0.2s backwards; }
.code .ghost.accepted { opacity: 1; font-style: normal; }
/* added lines wait for the window to grow before fading in, so they never sit on its edge */
.code.out { animation: fade-in 0.3s ease-out 0.2s backwards; }
.code.out > .ln { opacity: 0; transition: opacity 0.35s ease-out; }
.code.out > .ln.shown { opacity: 1; }
.code.out { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--panel-2); }
.code.out a { text-decoration: underline; text-underline-offset: 3px; }
@keyframes fade-in { from { opacity: 0; } }
.scroll-cue {
  position: absolute;
  z-index: 1;
  bottom: clamp(16px, 4vw, 32px);
  left: 50%;
  transform: translateX(-50%);
  font-size: 13px;
  animation: bob 2.4s ease-in-out infinite;
}
@keyframes bob { 50% { transform: translate(-50%, 6px); } }

/* ---------- big title ---------- */
#about { padding-top: clamp(22px, 3.2vw, 46px); }
.big-title {
  font-family: var(--display);
  font-size: clamp(3rem, 10.5vw, 9.5rem);
  font-weight: 500;
  line-height: 0.86;
  letter-spacing: -0.06em;
  margin: 0 0 clamp(24px, 3vw, 48px);
}
.big-title .thin { font-weight: 300; color: #9a9da0; }

@media (prefers-reduced-motion: reduce) {
  #gradient-canvas { display: none; }
  .scroll-cue { animation: none; }
}

.code {
  margin: 0;
  font-family: var(--mono);
  font-size: 14px;
  white-space: pre;
  overflow-x: auto;
}
.code .kw { font-weight: 700; }
.code .cm { opacity: 0.55; }
.cursor {
  display: inline-block;
  width: 2px;
  height: 1.15em;
  margin-left: 4px;
  background: var(--ink);
  vertical-align: -0.2em;
  animation: blink 1.1s ease-in-out infinite;
}
.cursor.busy { animation: none; }
@keyframes blink { 50% { opacity: 0; } }

/* ---------- eyebrow columns ---------- */
.eyebrow {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 700;
  margin: 0 0 2.2em;
}
.cols {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 32px;
}
/* a short ink tick opens each column */
.col {
  background: linear-gradient(var(--ink), var(--ink)) 0 0 / 48px 2px no-repeat;
  padding-top: 14px;
}
.col .eyebrow { margin-bottom: 0.75em; }
.col p { font-size: clamp(18px, 1.7vw, 24px); letter-spacing: -0.02em; line-height: 1.3; }
.col p strong { font-weight: 700; }
.span-5 { grid-column: span 5; }
.span-4 { grid-column: span 4; }
.span-3 { grid-column: span 3; }

.links { list-style: none; padding: 0; margin: 0; font-family: var(--mono); font-size: 14px; }
.links li { padding: 5px 0; border-bottom: 1px dotted var(--rule); }
.links a { display: flex; justify-content: space-between; }
.links a::after { content: "↗"; }

.photo { margin-top: 28px; }
.photo img {
  width: 100%;
  position: relative;
  z-index: 2; /* above the page grain */
}

/* ---------- section titles ---------- */
.h2 {
  font-family: var(--display);
  font-size: clamp(2.6rem, 7vw, 6.5rem);
  font-weight: 500;
  letter-spacing: -0.06em;
  line-height: 0.9;
  margin: 0 0 0.45em;
}
.h2 small {
  display: block;
  font: 700 12px/1 var(--mono);
  letter-spacing: 0;
  margin-bottom: 1.2em;
}

/* ---------- entries (work / news / pubs) ---------- */
.entry {
  display: grid;
  --date-col: 150px;
  grid-template-columns: var(--date-col) 1fr;
  gap: 24px;
  padding: 22px 0;
  border-top: 1px solid var(--rule-soft);
}
.entry:last-child { border-bottom: 1px solid var(--rule-soft); }
/* the section heading sits on a full ink rule that opens the list */
.h2:has(+ .entry) { margin-bottom: 0; padding-bottom: 0.18em; }
.h2 + .entry { border-top: 2px solid var(--ink); padding-top: 34px; }
.entry.has-logo { grid-template-columns: var(--date-col) 64px 1fr; }
/* date ranges need room; single dates do not */
#now .entry, #past .entry { --date-col: 180px; }
#news .entry, #publications .entry { --date-col: 125px; }
.entry .logo {
  width: 64px;
  height: 64px;
  background: var(--panel);
  border: 1px solid var(--rule-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.entry .logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 6px;
  filter: url(#crunch);
  transition: filter 0.3s;
}
.entry:hover .logo img { filter: none; }
/* org logo inside a headline: a text-height version of the logo tile */
.inline-logo {
  display: inline-block;
  width: 0.95em;
  height: 0.95em;
  padding: 0.12em;
  margin-right: 0.18em;
  vertical-align: -0.12em;
  background: var(--panel);
  border-radius: 0.2em;
  object-fit: contain;
  filter: url(#crunch);
  transition: filter 0.3s;
}
.entry:hover .inline-logo { filter: none; }
/* two-tone marks invert instead of revealing colour */
.entry .logo.invert { transition: background-color 0.2s ease; }
.entry:hover .logo.invert { background: var(--ink); }
.entry:hover .logo.invert img { filter: invert(1); }
.entry .date { font-family: var(--mono); font-size: 13px; padding-top: 5px; white-space: nowrap; }
.entry h3 {
  font-size: clamp(20px, 2vw, 26px);
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.15;
  margin: 0 0 4px;
}
.entry .place { font-family: var(--mono); font-size: 13px; margin-bottom: 10px; }
.entry .text { max-width: 68ch; }
.entry .text a, .entry h3 a { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; }
.entry .authors { max-width: 68ch; font-size: 16px; opacity: 0.85; }
.entry .venue { font-family: var(--mono); font-size: 13px; margin-top: 4px; }
.entry .venue em { font-style: normal; opacity: 0.6; }

.tags { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.tag, .card-foot a {
  --chip: var(--panel);
  --chip-ink: var(--ink);
  font-family: var(--mono);
  font-size: 12px;
  padding: 3px 8px;
  line-height: 1.2;
  background: var(--chip);
  color: var(--chip-ink);
  border: 1.5px solid currentColor;
  box-shadow: 2px 2px 0 var(--chip-shadow, var(--ink));
  transition: background 0.12s ease, color 0.12s ease, box-shadow 0.12s ease, transform 0.12s ease;
}
/* paper = white (default), code = ink, models = mint, package = violet, live = rose */
:is(.tag, .card-foot a)[data-kind="code"] { --chip: var(--ink); --chip-ink: var(--panel); }
:is(.tag, .card-foot a)[data-kind="models"] { --chip: var(--mint); }
:is(.tag, .card-foot a)[data-kind="package"] { --chip: var(--violet); }
:is(.tag, .card-foot a)[data-kind="live"] { --chip: var(--rose); }

/* hover inverts the chip and pops its shadow out in its own colour */
:is(.tag, .card-foot a):hover {
  background: var(--chip-ink);
  color: var(--chip);
  box-shadow: 4px 4px 0 var(--chip);
  transform: translate(-2px, -2px);
}


/* ---------- ink bands ---------- */
.section.ink {
  --rule: rgba(244, 243, 239, 0.35);
  --chip-shadow: var(--v1-mint);
  background-color: var(--ink); /* the hero's night */
  color: var(--panel);
  margin-inline: calc(50% - 50vw);
  padding-inline: calc(50vw - 50% + 12px);
}
.section.ink .h2 small { color: var(--v1-pink); }
.section.ink .entry,
.section.ink .entry:last-child { border-color: var(--rule); }
.section.ink .h2 + .entry { border-top-color: var(--panel); }
/* chips keep their own inverted hover */
.section.ink a:not(.tag, .card-foot a):hover { color: var(--v1-mint); }
/* ink chips would pop an ink shadow onto the ink band: pop mint instead */
.section.ink :is(.tag, .card-foot a)[data-kind="code"]:hover { box-shadow: 4px 4px 0 var(--chip-shadow); }

/* ---------- projects ---------- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 24px;
}
/* hairline cards on the ink band; the outline lights up purple on hover */
.card {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--rule);
  transition: border-color 0.15s ease;
}
.card:hover { border-color: var(--v1-purple); }
.card-name { font-family: var(--mono); font-size: 12px; color: var(--v1-mint); padding: 16px 16px 0; }
.card-body { flex: 1; font-size: 16px; line-height: 1.5; padding: 8px 16px 16px; }
.card-body p { margin: 0; }
.card-foot {
  display: flex; gap: 6px; flex-wrap: wrap;
  padding: 12px 16px;
  border-top: 1px solid var(--rule);
  font-family: var(--mono); font-size: 12px;
}
.card-foot a { padding: 2px 7px; }

/* ---------- footer ---------- */
.footer {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 24px;
  padding-block: 32px 48px;
  flex-wrap: wrap;
}
.foot-note { min-width: 260px; background: linear-gradient(var(--ink), var(--ink)) 0 0 / 48px 2px no-repeat; padding-top: 12px; font-family: var(--mono); font-size: 13px; line-height: 1.5; }
.foot-note strong { display: block; font-size: 12px; margin-bottom: 4px; }
.foot-note p { margin: 0; }
.footer .box { font-size: 13px; } /* same size as the hero's scroll cue */

/* ---------- responsive ---------- */
@media (max-width: 960px) {
  .span-5, .span-4, .span-3 { grid-column: span 6; }
}
@media (max-width: 760px) {
  body { font-size: 17px; }
  :root { --nav-h: 90px; }
  .nav { flex-wrap: wrap; row-gap: 8px; }
  .nav ul {
    order: 3;
    width: 100%;
    overflow-x: auto;
    scrollbar-width: none;
    padding-bottom: 2px;
  }
  .nav ul::-webkit-scrollbar { display: none; }
  .nav ul li { flex: none; }
  .hero { min-height: 88svh; }
  /* the longest code line fits at 12px; the printed output wraps */
  .hero .win.term .win-bar, .hero .win.term .win-body { padding-inline: 14px; }
  .hero .code { font-size: 12px; }
  .hero .code.out { white-space: pre-wrap; }
  .cols { gap: 24px; }
  .span-5, .span-4, .span-3 { grid-column: span 12; }
  .entry, .entry.has-logo { grid-template-columns: 1fr; gap: 6px; }
  .entry .logo { width: 48px; height: 48px; margin-block: 4px; }
  .entry .date { padding-top: 0; }
}
