/* Colours must match LIGHT / DARK in src/field.rs. */
@font-face {
  font-family: "Geist";
  src: url("/assets/fonts/geist.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}
@font-face {
  font-family: "IBM Plex Sans";
  src: url("/assets/fonts/ibm-plex-sans.woff2") format("woff2");
  font-weight: 100 700;
  font-display: swap;
}
@font-face {
  font-family: "JetBrains Mono";
  src: url("/assets/fonts/jetbrains-mono.woff2") format("woff2");
  font-weight: 100 800;
  font-display: swap;
}

:root {
  --paper: #f4f2ee;
  --ink: #1a1a1a;
  --muted: #6b6862;
  --rule: color-mix(in srgb, var(--ink) 14%, transparent);
  --wash: color-mix(in srgb, var(--ink) 4%, transparent);
  /* Geist: name and headings · IBM Plex Sans: body · JetBrains Mono: labels and the glyph field */
  --display: "Geist", ui-sans-serif, -apple-system, BlinkMacSystemFont, "Helvetica Neue", sans-serif;
  --sans: "IBM Plex Sans", ui-sans-serif, -apple-system, BlinkMacSystemFont, "Helvetica Neue", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --pad: clamp(1.25rem, 4vw, 3rem);
  --max: 72rem;
}
@media (prefers-color-scheme: dark) {
  :root { --paper: #0e0e0f; --ink: #e8e6e1; --muted: #8f8b84; }
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  background: var(--paper);
  color: var(--ink);
  font: 400 1.0625rem/1.55 var(--sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
a { color: inherit; }
ul { list-style: none; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 4px; border-radius: 2px; }

.meta {
  font: 0.75rem/1.2 var(--mono);
  letter-spacing: 0.04em;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.meta a { text-decoration: none; transition: color 0.2s; }
.meta a:hover { color: var(--ink); }

/* ── Glyph field: fixed behind the intro; sections cover it as you scroll. ── */
#field {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100dvh;
  z-index: -1;
  opacity: 0;
  transition: opacity 0.8s ease;
}
.gpu #field { opacity: 1; }
.no-gpu #field { display: none; }

/* ── Top bar ── */
.topbar {
  position: absolute;
  inset: 0 0 auto 0;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  padding: var(--pad);
  z-index: 1;
}
.brand { color: var(--ink); }
.topbar nav { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 0.4rem 1.25rem; }

/* ── Hero: first screen, intro top-left ── */
.hero {
  position: relative;
  min-height: 100dvh;
  padding: calc(var(--pad) + 5.5rem) var(--pad) var(--pad);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  /* The intro halo reaches past the screen edge; never let it cause sideways scrolling. */
  overflow-x: clip;
}
.intro { position: relative; max-width: 40rem; }
/* Soft paper-coloured halo so the intro stays readable over the field. */
.intro::before {
  content: "";
  position: absolute;
  inset: -5rem -7rem -4rem -7rem;
  z-index: -1;
  background: radial-gradient(closest-side, var(--paper) 60%, transparent);
  pointer-events: none;
}
h1 {
  font-family: var(--display);
  font-size: clamp(3.5rem, 12vw, 9rem);
  font-weight: 650;
  letter-spacing: -0.055em;
  line-height: 0.86;
  margin-left: -0.04em;
}
.role {
  margin-top: 1.5rem;
  font: 500 0.8rem/1.4 var(--mono);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
}
.bio {
  margin-top: 1rem;
  font-size: clamp(1.1rem, 2vw, 1.35rem);
  line-height: 1.45;
  letter-spacing: -0.01em;
  max-width: 32rem;
}
.links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.75rem;
  margin-top: 2rem;
  font: 0.9rem/1 var(--mono);
}
.ext {
  text-decoration: none;
  border-bottom: 1px solid var(--rule);
  padding-bottom: 0.2rem;
  transition: border-color 0.2s;
}
.ext:hover { border-color: var(--ink); }
.arrow { display: inline-block; margin-left: 0.3em; transition: transform 0.2s; }
a:hover > .arrow { transform: translate(2px, -2px); }

.hero-foot {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: end;
  margin-top: 3rem;
}
.hero-foot > :last-child { justify-self: end; }
.scroll-hint { animation: nudge 2.4s ease-in-out infinite; }
@keyframes nudge { 50% { transform: translateY(3px); } }

/* ── Sections: editorial index, label column + content column ── */
.sections { background: var(--paper); position: relative; }
.section {
  max-width: var(--max);
  margin: 0 auto;
  padding: clamp(3.5rem, 8vw, 6.5rem) var(--pad);
  border-top: 1px solid var(--rule);
  display: grid;
  grid-template-columns: minmax(10rem, 1fr) 3fr;
  gap: 1.5rem 3rem;
}
.section-label {
  display: flex;
  gap: 0.75rem;
  align-items: baseline;
  font: 500 0.78rem/1.2 var(--mono);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  position: sticky;
  top: 1.5rem;
  align-self: start;
}
.section-label .num { color: var(--ink); }
.section-label h2 { font: inherit; }
@media (max-width: 760px) {
  .section { grid-template-columns: 1fr; }
  .section-label { position: static; }
}

/* Keep line breaks typed in Pages CMS. */
.bio, .now p, .row-text, .contact-line { white-space: pre-line; }

/* Now */
.now p:not(.meta-note) {
  font-size: clamp(1.2rem, 2.4vw, 1.6rem);
  line-height: 1.4;
  letter-spacing: -0.015em;
  max-width: 40rem;
}
.now p + p { margin-top: 0.9rem; }
.meta-note { margin-top: 1.75rem !important; font: 0.75rem/1 var(--mono); color: var(--muted); }

/* Rows: Work and Achievements */
.rows { border-top: 1px solid var(--rule); }
.row {
  display: grid;
  gap: 0.35rem 2rem;
  padding: 1.4rem 0.75rem;
  margin: 0 -0.75rem;
  border-bottom: 1px solid var(--rule);
  border-radius: 4px;
  transition: background-color 0.2s;
}
.row:hover { background: var(--wash); }
.row-title { font-family: var(--display); font-size: 1.15rem; font-weight: 550; letter-spacing: -0.015em; }
.row-title a { text-decoration: none; }
.row-text { color: var(--muted); max-width: 38rem; }
.row-year { font: 0.8rem/1.9 var(--mono); color: var(--muted); font-variant-numeric: tabular-nums; }
.project {
  grid-template-columns: 1fr auto;
  grid-template-areas: "title year" "text text" "tags tags";
}
.project .row-title { grid-area: title; }
.project .row-year { grid-area: year; }
.project .row-text { grid-area: text; }
.project .tags { grid-area: tags; }
.achievement {
  grid-template-columns: 4.5rem 1fr;
  grid-template-areas: "year title" ". text";
}
.achievement .row-year { grid-area: year; }
.achievement .row-title { grid-area: title; }
.achievement .row-text { grid-area: text; }
.tags { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.5rem; }
.tags li, .pills li {
  font: 0.75rem/1 var(--mono);
  padding: 0.4rem 0.65rem;
  border: 1px solid var(--rule);
  border-radius: 999px;
  color: var(--muted);
}

/* Capabilities */
.capabilities { display: grid; grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr)); gap: 2.25rem 3rem; }
.cap-group h3 {
  font: 500 0.78rem/1.2 var(--mono);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 0.9rem;
}
.pills { display: flex; flex-wrap: wrap; gap: 0.45rem; }
.pills li { color: var(--ink); }

/* Photos */
.photos-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: 1.5rem; }
.photos-head p { color: var(--muted); }
.chip {
  font: 0.78rem/1 var(--mono);
  padding: 0.55rem 0.9rem;
  border: 1px solid var(--rule);
  border-radius: 999px;
  white-space: nowrap;
  transition: border-color 0.2s, background-color 0.2s;
}
.chip:hover { border-color: var(--ink); background: var(--wash); }
.photos { columns: 3 13rem; column-gap: 0.75rem; }
.photo { break-inside: avoid; margin-bottom: 0.75rem; border-radius: 4px; overflow: hidden; }
.photo-btn { display: block; width: 100%; cursor: zoom-in; }
.photo img { display: block; width: 100%; height: auto; transition: transform 0.4s ease, filter 0.4s; }
.photo-btn:hover img { transform: scale(1.02); }
.photo.placeholder {
  display: grid;
  place-items: end start;
  padding: 0.75rem;
  border: 1px dashed var(--rule);
  background: repeating-linear-gradient(-45deg, transparent 0 9px, var(--wash) 9px 10px);
  font: 0.72rem/1 var(--mono);
  color: var(--muted);
}
.lightbox {
  margin: auto;
  max-width: min(92vw, 70rem);
  max-height: 92dvh;
  padding: 1rem;
  border: 0;
  border-radius: 6px;
  background: var(--paper);
  color: var(--ink);
}
.lightbox::backdrop { background: color-mix(in srgb, var(--paper) 70%, transparent); backdrop-filter: blur(6px); }
.lightbox img { display: block; max-width: 100%; max-height: 78dvh; margin: 0 auto; border-radius: 4px; }
.lightbox figcaption { margin-top: 0.75rem; }
.lightbox .close { margin-top: 0.75rem; }

/* Contact */
.contact-line { color: var(--muted); margin-bottom: 1rem; }
.email {
  display: inline-block;
  font-family: var(--display);
  font-size: clamp(1.9rem, 6vw, 4.25rem);
  font-weight: 600;
  letter-spacing: -0.045em;
  line-height: 1.05;
  text-decoration: none;
  border-bottom: 2px solid var(--rule);
  transition: border-color 0.2s;
  word-break: break-word;
}
.email:hover { border-color: var(--ink); }
.socials { margin-top: 2.5rem; }

/* Footer */
.footer {
  max-width: var(--max);
  margin: 0 auto;
  padding: 2rem var(--pad) 2.5rem;
  border-top: 1px solid var(--rule);
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.75rem 2rem;
  background: var(--paper);
}

@media (max-width: 560px) {
  .topbar { flex-direction: column; }
  .topbar nav { justify-content: flex-start; }
  .hero { padding-top: calc(var(--pad) + 7rem); }
  .hero-foot { grid-template-columns: 1fr 1fr; }
  .scroll-hint { display: none; }
  .photos { columns: 2; column-gap: 0.5rem; }
  .photo { margin-bottom: 0.5rem; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before { transition: none !important; animation: none !important; }
}
