/* ===== Design tokens ===== */
:root {
  --paper: #F3F5F7;
  --paper-raised: #FFFFFF;
  --ink: #14213D;
  --ink-soft: #3A4A6B;
  --steel: #6B7A8F;
  --accent: #E8542E;
  --accent-dim: #F2A38B;
  --line: rgba(20, 33, 61, 0.12);

  --font-display: 'Space Grotesk', sans-serif;
  --font-body: 'IBM Plex Sans', sans-serif;
  --font-mono: 'IBM Plex Mono', monospace;

  --container: 1080px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #12141c;
    --paper-raised: #1b1e29;
    --ink: #F3F5F7;
    --ink-soft: #C3CCDA;
    --steel: #8A97AC;
    --accent: #FF7A52;
    --accent-dim: #7A3323;
    --line: rgba(255, 255, 255, 0.12);
  }
}
:root[data-theme="dark"] {
  --paper: #12141c;
  --paper-raised: #1b1e29;
  --ink: #F3F5F7;
  --ink-soft: #C3CCDA;
  --steel: #8A97AC;
  --accent: #FF7A52;
  --accent-dim: #7A3323;
  --line: rgba(255, 255, 255, 0.12);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.25s ease, color 0.25s ease;
}

.nav, .tag, .hero-photo img, .contact-link, .tl-tag, .nav-cta, .fact-value,
.research-item, .tl-item::before, .timeline::before {
  transition: background-color 0.25s ease, color 0.25s ease, border-color 0.25s ease;
}

h1, h2, h3 { font-family: var(--font-display); margin: 0; color: var(--ink); }
p { margin: 0 0 1em; color: var(--ink-soft); }
a { color: inherit; text-decoration: none; }
ul { margin: 0; padding: 0; list-style: none; }

::selection { background: var(--accent-dim); color: var(--ink); }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

/* ===== Nav ===== */
.nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: color-mix(in srgb, var(--paper) 85%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.nav-inner {
  position: relative;
  max-width: var(--container);
  margin: 0 auto;
  padding: 18px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.nav-brand {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: 0.01em;
  white-space: nowrap;
  opacity: 0;
}
.nav-links {
  display: flex;
  gap: 28px;
  font-size: 0.92rem;
  font-weight: 500;
}
.nav-links a { color: var(--ink-soft); transition: color 0.2s; }
.nav-links a:hover { color: var(--ink); }
.nav-cta {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  border: 1px solid var(--ink);
  padding: 8px 14px;
  border-radius: 3px;
  transition: background 0.2s, color 0.2s;
}
.nav-cta:hover { background: var(--ink); color: var(--paper); }
.arrow { display: inline-block; }

.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: none;
  color: var(--ink);
  cursor: pointer;
  flex-shrink: 0;
}
.theme-toggle:hover { background: var(--line); }
.theme-toggle svg { width: 18px; height: 18px; }
.theme-toggle .icon-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .icon-moon { display: none; }
  :root:not([data-theme="light"]) .theme-toggle .icon-sun { display: block; }
}

.nav-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 32px;
  height: 32px;
  padding: 0;
  background: none;
  border: none;
  cursor: pointer;
}
.nav-toggle span {
  display: block;
  width: 100%;
  height: 2px;
  background: var(--ink);
  transition: transform 0.2s, opacity 0.2s;
}
.nav-toggle[aria-expanded="true"] span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav-toggle[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.nav-toggle[aria-expanded="true"] span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

@media (max-width: 760px) {
  .nav-brand { display: none; }
  .nav-toggle { display: flex; }
  .nav-links {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    flex-direction: column;
    gap: 0;
    background: var(--paper-raised);
    border-bottom: 1px solid var(--line);
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.25s ease;
  }
  .nav-links.open { max-height: 320px; }
  .nav-links a { padding: 14px 24px; border-top: 1px solid var(--line); }
}

/* ===== Hero ===== */
.hero {
  position: relative;
  max-width: var(--container);
  margin: 0 auto;
  padding: 64px 24px 60px;
  overflow: hidden;
}
.hero-grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(var(--line) 1px, transparent 1px),
    linear-gradient(90deg, var(--line) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(ellipse 70% 60% at 30% 20%, black, transparent);
  opacity: 0.6;
  pointer-events: none;
}
.hero-flex {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 48px;
}
.hero-inner { max-width: 560px; flex: 1 1 420px; }
.eyebrow {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 14px;
}
.hero-title {
  font-size: clamp(3.3rem, 7.3vw, 5.9rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 0.95;
  margin-bottom: 18px;
  transform-origin: left top;
}
.hero-sub {
  font-size: 1.1rem;
  max-width: 520px;
  margin-bottom: 0;
}
.hero-photo {
  flex-shrink: 0;
  width: min(320px, 36vw);
}
.hero-photo img {
  display: block;
  width: 100%;
  aspect-ratio: 4/5;
  object-fit: cover;
  object-position: 50% 25%;
  border-radius: 8px;
  border: 1px solid var(--line);
  box-shadow: 0 20px 40px -20px rgba(20, 33, 61, 0.25);
}

@media (max-width: 760px) {
  .hero-flex { flex-direction: column; gap: 32px; }
  .hero-inner { flex: none; max-width: 100%; }
  .hero-photo { width: 100%; align-self: stretch; }
}

/* ===== Dimension-line dividers ===== */
.dim-divider {
  max-width: var(--container);
  margin: 8px auto;
  padding: 0 24px;
  display: flex;
  align-items: center;
  gap: 16px;
}
.dim-divider span {
  flex-grow: 1;
  height: 1px;
  background: var(--line);
}
.dim-divider em {
  font-family: var(--font-mono);
  font-style: normal;
  font-size: 0.72rem;
  color: var(--steel);
  letter-spacing: 0.08em;
  white-space: nowrap;
}

/* ===== Section shared ===== */
.section-title {
  font-size: clamp(1.6rem, 3vw, 2.1rem);
  margin-bottom: 40px;
}

/* ===== About ===== */
.about { max-width: var(--container); margin: 0 auto; padding: 60px 24px; }
.about-inner {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 56px;
}
.about-text h2 { font-size: clamp(1.6rem, 3vw, 2.1rem); margin-bottom: 20px; }
.about-facts {
  display: flex;
  flex-direction: column;
  gap: 20px;
  border-left: 1px solid var(--line);
  padding-left: 28px;
}
.fact { display: flex; flex-direction: column; gap: 4px; }
.fact-label {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
}
.fact-value { font-size: 0.94rem; color: var(--ink); }

@media (max-width: 760px) {
  .about-inner { grid-template-columns: 1fr; }
  .about-facts { border-left: none; padding-left: 0; border-top: 1px solid var(--line); padding-top: 24px; }
}

/* ===== Experience timeline ===== */
.experience { max-width: var(--container); margin: 0 auto; padding: 40px 24px 60px; }
.timeline {
  display: flex;
  flex-direction: column;
  position: relative;
  padding-left: 32px;
}
.timeline::before {
  content: '';
  position: absolute;
  left: 0;
  top: 6px;
  bottom: 6px;
  width: 2px;
  background: var(--accent);
  opacity: 0.35;
}
.tl-item {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 32px;
  padding: 24px 0;
  position: relative;
}
.tl-item::before {
  content: '';
  position: absolute;
  left: -32px;
  top: 28px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--paper);
}
.tl-meta { display: flex; flex-direction: column; gap: 8px; }
.tl-date {
  font-family: var(--font-mono);
  font-size: 0.76rem;
  color: var(--steel);
}
.tl-tag {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 20px;
  padding: 2px 9px;
  width: fit-content;
  letter-spacing: 0.05em;
}
.tl-body h3 { font-size: 1.15rem; margin-bottom: 12px; font-weight: 600; }
.tl-org { font-family: var(--font-body); font-weight: 400; color: var(--steel); font-size: 0.95rem; }
.tl-body p { font-size: 0.95rem; margin: 0; }
.tl-item--placeholder .tl-body p { font-style: italic; color: var(--steel); }
.tl-item--placeholder .tl-body p code {
  background: var(--paper-raised);
  border: 1px solid var(--line);
  padding: 1px 6px;
  border-radius: 3px;
  font-family: var(--font-mono);
  font-size: 0.85em;
  font-style: normal;
}

@media (max-width: 700px) {
  .tl-item { grid-template-columns: 1fr; gap: 10px; }
}

/* ===== Research ===== */
.research { max-width: var(--container); margin: 0 auto; padding: 40px 24px 60px; }
.research-list { display: flex; flex-direction: column; gap: 32px; }
.research-item {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 32px;
  padding-top: 28px;
  border-top: 1px solid var(--line);
}
.research-item:first-child {
  padding-top: 0;
  border-top: none;
}
.research-date { font-family: var(--font-mono); font-size: 0.76rem; color: var(--steel); }
.research-item h3 { font-size: 1.05rem; margin-bottom: 10px; font-weight: 600; }
.research-org { font-family: var(--font-body); font-weight: 400; color: var(--steel); font-size: 0.9rem; }
.research-item p { font-size: 0.92rem; }
.research-links { display: flex; flex-wrap: wrap; gap: 20px; margin-top: 12px; }
.research-link {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--accent);
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  transition: color 0.2s;
}
.research-link:hover { color: var(--ink); }

/* ===== Photo gallery modal ===== */
.gallery-modal {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(10, 14, 22, 0.92);
  padding: 24px;
}
.gallery-modal.open { display: flex; }
.gallery-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  max-width: min(900px, 92vw);
}
.gallery-stage {
  position: relative;
  max-width: 100%;
  max-height: 74vh;
  display: flex;
  align-items: center;
  justify-content: center;
}
.gallery-stage img {
  max-width: 100%;
  max-height: 74vh;
  border-radius: 6px;
  display: block;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
}
.gallery-close {
  position: absolute;
  top: 20px;
  right: 24px;
  color: var(--paper);
  font-family: var(--font-mono);
  font-size: 1.6rem;
  line-height: 1;
  background: none;
  border: none;
  cursor: pointer;
  opacity: 0.85;
  transition: opacity 0.2s;
}
.gallery-close:hover { opacity: 1; }
.gallery-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.3);
  background: rgba(255, 255, 255, 0.08);
  color: var(--paper);
  font-family: var(--font-mono);
  font-size: 1.2rem;
  cursor: pointer;
  transition: background 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.gallery-arrow:hover { background: rgba(255, 255, 255, 0.2); }
.gallery-arrow--prev { left: -60px; }
.gallery-arrow--next { right: -60px; }
.gallery-info {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  max-width: 560px;
  text-align: center;
}
.gallery-caption {
  color: var(--paper);
  font-size: 0.92rem;
  line-height: 1.5;
  margin: 0;
  opacity: 0.92;
}
.gallery-counter {
  color: var(--paper);
  font-family: var(--font-mono);
  font-size: 0.76rem;
  opacity: 0.65;
  letter-spacing: 0.04em;
}

@media (max-width: 700px) {
  .gallery-arrow--prev { left: 4px; }
  .gallery-arrow--next { right: 4px; }
}

.research-item--placeholder { border-top-style: dashed; }
.research-item--placeholder h3,
.research-item--placeholder .research-date { color: var(--steel); }
.research-item--placeholder p { font-style: italic; }
.research-item--placeholder code {
  background: var(--paper-raised);
  border: 1px solid var(--line);
  padding: 1px 6px;
  border-radius: 3px;
  font-family: var(--font-mono);
  font-size: 0.85em;
}

@media (max-width: 700px) {
  .research-item { grid-template-columns: 1fr; gap: 10px; }
}

/* ===== Tools ===== */
.tools { max-width: var(--container); margin: 0 auto; padding: 40px 24px 60px; }
.tools-groups { display: flex; flex-direction: column; gap: 32px; }
.tools-group { display: flex; flex-direction: column; gap: 14px; }
.tools-label {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
}
.tools-tags { display: flex; flex-wrap: wrap; gap: 10px; }
.tag {
  font-family: var(--font-body);
  font-size: 0.9rem;
  color: var(--ink);
  background: var(--paper-raised);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 8px 16px;
}
.tag:hover { border-color: var(--accent); color: var(--accent); }

/* ===== Photography ===== */
.photography { max-width: var(--container); margin: 0 auto; padding: 40px 24px 60px; }
.photo-intro { max-width: 640px; }
.photo-todo { font-family: var(--font-mono); font-size: 0.82rem; color: var(--steel); }
.photo-todo code {
  background: var(--paper-raised);
  border: 1px solid var(--line);
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 0.8em;
}
.photo-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-top: 24px;
}
.photo-placeholder {
  aspect-ratio: 4/3;
  border: 1px dashed var(--line);
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--steel);
  background: var(--paper-raised);
}
.photo-placeholder span { font-family: var(--font-mono); font-size: 1.6rem; margin-bottom: 6px; }
.photo-placeholder p { margin: 0; font-family: var(--font-mono); font-size: 0.74rem; }
.photo-grid img {
  width: 100%;
  height: 100%;
  aspect-ratio: 4/3;
  object-fit: cover;
  border-radius: 6px;
  cursor: pointer;
  transition: opacity 0.2s;
}
.photo-grid img:hover { opacity: 0.85; }

@media (max-width: 700px) {
  .photo-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ===== Contact ===== */
.contact { max-width: var(--container); margin: 0 auto; padding: 40px 24px 100px; }
.contact-sub { max-width: 700px; margin-bottom: 32px; }
.contact-links { display: flex; flex-direction: column; gap: 0; border-top: 1px solid var(--line); }
.contact-link {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 4px;
  border-bottom: 1px solid var(--line);
  transition: padding-left 0.2s, color 0.2s;
}
.contact-link:hover { padding-left: 12px; color: var(--accent); }
.contact-label { font-family: var(--font-mono); font-size: 0.78rem; color: var(--steel); text-transform: uppercase; letter-spacing: 0.06em; }
.contact-value { font-size: 1.05rem; font-weight: 500; }

/* ===== Footer ===== */
.footer {
  max-width: var(--container);
  margin: 0 auto;
  padding: 24px 24px 40px;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--steel);
}

/* ===== Lightbox ===== */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(20, 33, 61, 0.92);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 40px;
}
.lightbox.open { display: flex; }
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 4px; }
.lightbox-close {
  position: absolute;
  top: 24px;
  right: 32px;
  color: var(--paper);
  font-family: var(--font-mono);
  font-size: 1.4rem;
  cursor: pointer;
}
