* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* Themes */
:root,
[data-theme="light"] {
  --bg: #fafafa;
  --text: #1a1a1a;
  --text-mid: #333;
  --text-light: #666;
  --text-muted: #888;
  --text-faint: #aaa;
  --border: #ccc;
  --border-light: #eee;
}

[data-theme="dark"] {
  --bg: #111;
  --text: #e8e8e8;
  --text-mid: #ccc;
  --text-light: #999;
  --text-muted: #777;
  --text-faint: #555;
  --border: #444;
  --border-light: #222;
}

[data-theme="midnight"] {
  --bg: #0a0e1a;
  --text: #c8d0e0;
  --text-mid: #a0aec0;
  --text-light: #718096;
  --text-muted: #5a6a80;
  --text-faint: #3a4a5a;
  --border: #2d3748;
  --border-light: #1a202c;
}

[data-theme="warm"] {
  --bg: #fdf6ee;
  --text: #3d2e1e;
  --text-mid: #5c4433;
  --text-light: #8a6d55;
  --text-muted: #a89080;
  --text-faint: #c4b5a5;
  --border: #d4c4b0;
  --border-light: #ebe0d2;
}

body {
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.6;
  max-width: 640px;
  margin: 0 auto;
  padding: 4rem 1.5rem;
  transition: color 0.3s ease;
}

/* Smooth text color transitions during theme change */
h1, h2, p, a, span, li, em, footer, footer p {
  transition: color 3s ease, border-color 3s ease;
}

h1 {
  font-size: 1.8rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.tagline {
  color: var(--text-light);
  margin-top: 0.25rem;
  font-size: 0.95rem;
}

nav {
  margin-top: 1rem;
  display: flex;
  align-items: baseline;
  gap: 1.5rem;
}

nav a {
  color: var(--text);
  text-decoration: none;
  font-size: 0.9rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 1px;
}

nav a:hover {
  border-color: var(--text);
}

/* Email */
.email-wrap {
  display: inline-flex;
  align-items: baseline;
}

.email-label {
  color: var(--text);
  font-size: 0.9rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 1px;
  cursor: pointer;
  display: inline-block;
  transition: opacity 0.3s ease, max-width 0.3s ease, color 3s ease, border-color 3s ease;
  max-width: 4rem;
  overflow: hidden;
  white-space: nowrap;
}

.email-label:hover {
  border-color: var(--text);
}

.email-address {
  font-size: 0.85rem;
  color: var(--text-muted);
  cursor: pointer;
  display: inline-block;
  max-width: 0;
  overflow: hidden;
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.3s ease, max-width 0.4s ease, color 3s ease;
}

.email-address:hover {
  color: var(--text);
}

.email-wrap.expanded .email-label {
  max-width: 0;
  opacity: 0;
}

.email-wrap.expanded .email-address {
  max-width: 20rem;
  opacity: 1;
}

h2 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-light);
}

section {
  margin-top: 3rem;
}

section p {
  color: var(--text-mid);
  font-size: 0.95rem;
}

.section-note {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-bottom: 1rem;
}

/* Gallery */
.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1rem;
}

.gallery figure {
  margin: 0;
}

.gallery img {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 4px;
  cursor: pointer;
  transition: transform 0.2s ease;
}

.gallery img:hover {
  transform: scale(1.03);
}

.gallery figcaption {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.35rem;
}

/* Publications */
.pub-list {
  list-style: none;
}

.pub-list li {
  margin-bottom: 0.75rem;
  font-size: 0.95rem;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
}

.pub-title {
  color: var(--text-mid);
}

.pub-links {
  display: flex;
  gap: 0.75rem;
  white-space: nowrap;
}

.pub-list a {
  color: var(--text-light);
  text-decoration: none;
  font-size: 0.85rem;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.pub-list a:hover {
  border-color: var(--text);
}

/* Footer */
footer {
  margin-top: 4rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border-light);
  transition: border-color 0.3s ease;
}

footer p {
  color: var(--text-faint);
  font-size: 0.8rem;
}

/* Theme switcher */
.theme-switcher {
  position: fixed;
  top: 1.25rem;
  right: 1.25rem;
  display: flex;
  gap: 0.4rem;
  align-items: center;
  z-index: 100;
}

.theme-swatch {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 1.5px solid var(--border);
  cursor: pointer;
  transition: transform 0.2s ease, border-color 0.2s ease;
}

.theme-swatch:hover {
  transform: scale(1.3);
}

.theme-swatch.active {
  border-color: var(--text);
  transform: scale(1.3);
}

.theme-swatch[data-theme="light"] { background: #fafafa; }
.theme-swatch[data-theme="warm"] { background: #fdf6ee; }
.theme-swatch[data-theme="dark"] { background: #111; }
.theme-swatch[data-theme="midnight"] { background: #0a0e1a; }

/* Fluid canvas */
#fluid-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: -1;
  display: none;
  transition: opacity 0.3s ease;
}

/* DNA easter egg */
#dna-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 50;
  display: none;
}

#genetics-trigger {
  cursor: default;
}

/* Lightbox */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.4s ease, visibility 0.4s ease;
}

.lightbox.open {
  opacity: 1;
  visibility: visible;
}

.lightbox img {
  max-width: 90vw;
  max-height: 90vh;
  object-fit: contain;
  border-radius: 4px;
  transform: scale(0.9);
  transition: transform 0.4s cubic-bezier(0.2, 0, 0.2, 1);
}

.lightbox.open img {
  transform: scale(1);
}

/* Mobile */
@media (max-width: 480px) {
  body {
    padding: 2.5rem 1.25rem;
  }

  h1 {
    font-size: 1.5rem;
  }

  .gallery {
    grid-template-columns: 1fr;
  }

  .theme-switcher {
    top: 0.75rem;
    right: 0.75rem;
  }
}
