:root {
  --paper: #fafafa;
  --ink: #0e0e0e;
  --ink-soft: #4a4a4a;
  --ink-faint: #8a8a8a;
  --line: #e2e2e2;
  --line-strong: #cfcfcf;
  --accent: #0e0e0e;
  --panel-pad: clamp(1.5rem, 4vw, 4rem);
  --sidebar-w: 256px;
  --maxw: 720px;
  --serif: "Space Grotesk", ui-sans-serif, sans-serif;
  --sans: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; font-size: 14.5px; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

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

body {
  margin: 0;
  overflow-x: hidden;
  transition: background-color .35s ease, color .35s ease;
  font-family: var(--sans);
  color: var(--ink);
  background: var(--paper);
  /* subtle geometric grid texture */
  background-image:
    linear-gradient(to right, rgba(0,0,0,0.025) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(0,0,0,0.025) 1px, transparent 1px);
  background-size: 46px 46px;
  -webkit-font-smoothing: antialiased;
  line-height: 1.6;
}

.skip-link {
  position: absolute; left: -999px; top: 0; z-index: 100;
  background: var(--ink); color: var(--paper); padding: .6rem 1rem;
}
.skip-link:focus { left: .5rem; top: .5rem; }

/* ---------- Layout ---------- */
.layout { display: flex; min-height: 100vh; position: relative; z-index: 1; }

/* ---------- Sidebar ---------- */
.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 2.2rem 1.6rem;
  border-right: 1px solid var(--line-strong);
  background: transparent;
}

.brand { display: flex; align-self: flex-start; align-items: center; gap: .8rem; text-decoration: none; color: var(--ink); background: none; border: 0; padding: 0; cursor: pointer; }
.brand__mark { color: var(--ink); display: inline-flex; transition: transform .4s ease; }
.brand:hover .brand__mark { transform: rotate(45deg); }
@media (prefers-reduced-motion: reduce) { .brand:hover .brand__mark { transform: none; } }
.brand__text { display: flex; flex-direction: column; line-height: 1.2; }
.brand__name { font-family: var(--serif); font-weight: 700; font-size: 1.12rem; letter-spacing: -.01em; }
.brand__role { font-size: .72rem; color: var(--ink-faint); letter-spacing: .02em; margin-top: .15rem; }

.nav { display: flex; flex-direction: column; gap: .1rem; margin: 2.4rem 0; position: relative; }
/* soft paper halo so the neural field stays faded-but-readable behind the tabs */
.nav::before {
  content: ""; position: absolute; inset: -16px -22px; z-index: -1;
  background: var(--paper); opacity: 0.62; filter: blur(12px);
  border-radius: 26px; pointer-events: none;
}
.nav__link {
  position: relative;
  text-decoration: none;
  color: var(--ink-soft);
  font-weight: 500;
  font-size: .98rem;
  padding: .5rem .2rem .5rem 1.3rem;
  border-radius: 4px;
  text-shadow: 0 0 7px var(--paper), 0 0 5px var(--paper);
  transition: color .15s ease, background .15s ease;
}
.nav__link::before {
  content: "";
  position: absolute;
  left: .1rem; top: 50%;
  width: 8px; height: 8px;
  border: 1.5px solid var(--line-strong);
  transform: translateY(-50%) rotate(45deg);
  transition: all .18s ease;
}
.nav__link:hover { color: var(--ink); }
.nav__link:hover::before { border-color: var(--ink-soft); }
.nav__link.is-active { color: var(--ink); font-weight: 600; }
.nav__link.is-active::before { background: var(--ink); border-color: var(--ink); }

.sidebar__bottom { display: flex; flex-direction: column; gap: 1.1rem; }

.socials { display: flex; align-items: center; gap: .9rem; position: relative; }
.socials::before {
  content: ""; position: absolute; inset: -12px -18px; z-index: -1;
  background: var(--paper); opacity: 0.62; filter: blur(12px);
  border-radius: 22px; pointer-events: none;
}
.socials a { color: var(--ink-faint); transition: color .15s ease, transform .15s ease; display: inline-flex; }
.socials a:hover { color: var(--ink); transform: translateY(-2px); }

/* ---------- Main ---------- */
.main {
  flex: 1 1 auto;
  margin-left: var(--sidebar-w);
  padding: var(--panel-pad);
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.panel { max-width: var(--maxw); width: 100%; animation: fade .35s ease; position: relative; }
.panel[hidden] { display: none; }
/* soft paper halo so the neural field stays readable behind the text */
.panel::before {
  content: ""; position: absolute; inset: -22px -28px; z-index: -1;
  background: var(--paper); opacity: 0.72; filter: blur(11px);
  border-radius: 28px; pointer-events: none;
}
@keyframes fade { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .panel { animation: none; } }

.eyebrow {
  font-size: .74rem; text-transform: uppercase; letter-spacing: .22em;
  color: var(--ink-faint); margin: 0 0 1rem; font-weight: 600;
  display: inline-flex; align-items: center; gap: .6rem;
}
.eyebrow::after { content: ""; width: 34px; height: 1px; background: var(--line-strong); }

.lede {
  font-family: var(--serif);
  font-weight: 700;
  font-size: clamp(1.7rem, 4vw, 2.5rem);
  line-height: 1.12;
  letter-spacing: -.02em;
  margin: 0 0 1.8rem;
  max-width: 16ch;
}

.prose p { margin: 0 0 1.1rem; color: var(--ink-soft); font-size: 1.04rem; max-width: 62ch; }
.prose p:last-child { margin-bottom: 0; }

.resume-link {
  display: flex; width: fit-content; align-items: center; gap: .45rem;
  margin: 0 0 2rem; font-size: .82rem; font-weight: 600;
  color: var(--ink); text-decoration: none;
  border-bottom: 1px solid var(--line-strong); padding-bottom: 2px;
  transition: border-color .15s ease;
}
.resume-link:hover { border-color: var(--ink); }
.resume-link svg { color: var(--ink-faint); }

/* ---------- Timeline ---------- */
.timeline { list-style: none; margin: 0; padding: 0; }
.job {
  position: relative;
  padding: 0 0 1.9rem 1.7rem;
  border-left: 1px solid var(--line-strong);
}
.job:last-child { border-left-color: transparent; padding-bottom: .4rem; }
.job::before {
  content: ""; position: absolute; left: -5px; top: .4rem;
  width: 9px; height: 9px; background: var(--paper);
  border: 1.5px solid var(--ink); transform: rotate(45deg);
}
.job__head { display: flex; flex-wrap: wrap; align-items: baseline; gap: .4rem .9rem; }
.job__role { font-size: 1.06rem; font-weight: 600; margin: 0; }
.job__date { font-size: .8rem; color: var(--ink-faint); font-variant-numeric: tabular-nums; }
.job__org { margin: .15rem 0 .5rem; font-weight: 500; color: var(--ink); font-size: .92rem; }
.job__desc { margin: 0; color: var(--ink-soft); font-size: .97rem; max-width: 60ch; }

.pubs { margin-top: 2.4rem; padding-top: 1.8rem; border-top: 1px solid var(--line); }
.pubs__title { font-family: var(--serif); font-size: 1.1rem; margin: 0 0 1rem; }
.pubs ul { margin: 0; padding-left: 1.1rem; }
.pubs li { color: var(--ink-soft); font-size: .92rem; margin-bottom: .7rem; }
.pubs em { color: var(--ink); }

/* ---------- Writing empty state ---------- */
.empty-card {
  margin-top: 1.6rem; padding: 2.4rem; border: 1px dashed var(--line-strong);
  display: flex; flex-direction: column; align-items: center; gap: .9rem;
  color: var(--ink-faint); text-align: center;
}
.empty-card__mark {
  width: 26px; height: 26px; border: 1.5px solid var(--line-strong);
  transform: rotate(45deg);
}
.empty-card p { margin: 0; font-size: .92rem; }

/* ---------- Button & contact ---------- */
.button {
  display: inline-flex; align-items: center; gap: .6rem;
  margin-top: 1.7rem; padding: .8rem 1.3rem;
  background: var(--ink); color: var(--paper);
  text-decoration: none; font-weight: 600; font-size: .95rem;
  border: 1px solid var(--ink);
  transition: background .15s ease, color .15s ease, transform .15s ease;
}
.button:hover { background: var(--paper); color: var(--ink); transform: translateY(-2px); }

.contact-list { list-style: none; margin: 1.8rem 0 0; padding: 0; }
.contact-list li {
  display: flex; align-items: baseline; gap: 1rem;
  padding: .95rem 0; border-bottom: 1px solid var(--line);
}
.contact-list li:first-child { border-top: 1px solid var(--line); }
.contact-list__label {
  flex: 0 0 90px; font-size: .74rem; text-transform: uppercase;
  letter-spacing: .14em; color: var(--ink-faint); font-weight: 600;
}
.contact-list a { color: var(--ink); text-decoration: none; border-bottom: 1px solid var(--line-strong); transition: border-color .15s ease; }
.contact-list a:hover { border-color: var(--ink); }

/* ---------- Topbar (mobile) ---------- */
.topbar { display: none; }
.topbar__toggle { background: none; border: none; cursor: pointer; padding: .5rem; display: flex; flex-direction: column; gap: 5px; }
.topbar__toggle span { width: 22px; height: 2px; background: var(--ink); transition: transform .2s ease, opacity .2s ease; }
.topbar__toggle[aria-expanded="true"] span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.topbar__toggle[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.topbar__toggle[aria-expanded="true"] span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ---------- Responsive ---------- */
@media (max-width: 820px) {
  .layout { flex-direction: column; }
  .main { margin-left: 0; }
  .topbar {
    display: flex; align-items: center; justify-content: space-between;
    padding: .9rem 1.1rem; border-bottom: 1px solid var(--line-strong);
    position: sticky; top: 0; z-index: 20; background: var(--paper);
  }
  .topbar__name { font-family: var(--serif); font-weight: 700; text-decoration: none; color: var(--ink); }
  .topbar__logo { display: inline-flex; color: var(--ink); background: none; border: 0; padding: 0; cursor: pointer; }
  .sidebar {
    position: fixed; left: 0; right: 0; top: 54px; bottom: auto; width: 100%; height: auto;
    display: none; z-index: 15;
    border-right: none; border-bottom: 1px solid var(--line-strong);
    background: var(--paper);
    padding: 1rem 1.4rem 1.6rem;
  }
  .sidebar.is-open { display: flex; }
  .sidebar__top { display: none; }
  .nav { margin: .5rem 0 1.5rem; }
  .nav__link { font-size: 1.1rem; padding: .8rem .2rem .8rem 1.4rem; }
}

/* ---------- Lights out (dark mode, toggled by the logo) ---------- */
html.dark {
  --paper: #0c0c0c;
  --ink: #f4f4f4;
  --ink-soft: #bcbcbc;
  --ink-faint: #7c7c7c;
  --line: #232323;
  --line-strong: #3a3a3a;
}
html.dark body {
  background-image:
    linear-gradient(to right, rgba(255,255,255,0.045) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(255,255,255,0.045) 1px, transparent 1px);
}
.sidebar, .topbar { transition: background-color .35s ease, border-color .35s ease; }
html.dark .topbar { background: var(--paper); }

.fire-pulse { pointer-events: none; }

/* double-click the logo: a neural field that creeps across the screen */
.neuro-field {
  position: fixed; inset: 0; width: 100%; height: 100%;
  pointer-events: none; z-index: 0;
  color: var(--ink); opacity: 0.45;
}
