/* ── Reset & Base ── */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg: #fafaf9;
  --text: #1c1917;
  --text-secondary: #57534e;
  --accent: #292524;
  --border: #e7e5e4;
  --nav-bg: #ffffff;
  --card-bg: #ffffff;
  --link: #2563eb;
  --link-hover: #1d4ed8;
  --nav-bg-alpha: rgba(255, 255, 255, 0.92);
  --hover-bg: rgba(0, 0, 0, 0.04);
  --shadow-color: rgba(0, 0, 0, 0.08);
  --shadow-color-sm: rgba(0, 0, 0, 0.06);
  --max-width: 960px;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-serif: 'Source Serif 4', Georgia, 'Times New Roman', serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1a2332;
    --text: #e5e5e5;
    --text-secondary: #a3b1c2;
    --accent: #e5e5e5;
    --border: #2f3d4f;
    --nav-bg: #1a2332;
    --card-bg: #212c3b;
    --link: #60a5fa;
    --link-hover: #93bbfd;
    --nav-bg-alpha: rgba(26, 35, 50, 0.92);
    --hover-bg: rgba(255, 255, 255, 0.06);
    --shadow-color: rgba(0, 0, 0, 0.3);
    --shadow-color-sm: rgba(0, 0, 0, 0.2);
  }
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-sans);
  color: var(--text);
  background: var(--bg);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  color: var(--link);
  text-decoration: none;
  transition: color 0.15s ease;
}

a:hover {
  color: var(--link-hover);
  text-decoration: underline;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

/* ── Rainbow Splash ── */
.rainbow-splash {
  height: 10px;
  background: linear-gradient(to right, red, orange, yellow, green, blue, indigo, violet);
}

/* ── Navigation ── */
.site-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--nav-bg);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(12px);
  background: var(--nav-bg-alpha);
}

.nav-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
}

.nav-brand {
  font-family: var(--font-serif);
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
  letter-spacing: -0.01em;
}

.nav-brand:hover {
  color: var(--text);
  text-decoration: none;
}

.nav-links {
  display: flex;
  gap: 0.25rem;
  list-style: none;
}

.nav-links a {
  display: block;
  padding: 0.4rem 0.75rem;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  text-decoration: none;
  border-radius: 6px;
  transition: color 0.15s ease, background 0.15s ease;
}

.nav-links a:hover,
.nav-links a.active {
  color: var(--text);
  background: var(--hover-bg);
  text-decoration: none;
}

/* ── Nav Dropdown ── */
.nav-dropdown {
  position: relative;
}

.nav-dropdown-toggle {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  cursor: pointer;
}

.nav-dropdown-toggle svg {
  width: 10px;
  height: 10px;
  transition: transform 0.2s ease;
}

.nav-dropdown-menu {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 220px;
  background: var(--nav-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.4rem 0;
  box-shadow: 0 8px 24px var(--shadow-color);
  z-index: 200;
  list-style: none;
}

.nav-dropdown:hover .nav-dropdown-menu,
.nav-dropdown.open .nav-dropdown-menu {
  display: block;
}

.nav-dropdown-menu li a {
  padding: 0.5rem 1rem;
  font-size: 0.8rem;
  white-space: nowrap;
}

.nav-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.5rem;
  color: var(--text);
}

.nav-toggle svg {
  width: 24px;
  height: 24px;
}

/* ── Main Content ── */
.main {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 3rem 1.5rem 4rem;
  min-height: calc(100vh - 64px - 80px);
}

/* ── Homepage Hero ── */
.hero {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 3rem;
  align-items: start;
  margin-bottom: 2rem;
}

.hero-image {
  border-radius: 12px;
  overflow: hidden;
  aspect-ratio: 3/4;
  object-fit: cover;
  object-position: 30% top;
  box-shadow: 0 4px 24px var(--shadow-color);
}

.hero-content {
  padding-top: 0.5rem;
}

.hero-title {
  font-size: 1.1rem;
  color: var(--text);
  margin-bottom: 1.5rem;
  line-height: 1.6;
}

.hero-bio {
  font-size: 0.95rem;
  color: var(--text);
  line-height: 1.8;
}

.hero-bio p {
  margin-bottom: 1rem;
}

.hero-bio p:last-child {
  margin-bottom: 0;
}

/* ── PDF Embed ── */
.pdf-embed {
  width: 100%;
  height: 85vh;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card-bg);
}

/* ── Video Embed ── */
.video-embed {
  position: relative;
  padding-bottom: 56.25%;
  height: 0;
  overflow: hidden;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.video-embed iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

/* ── Widget Container ── */
.widget-container {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 2rem;
  min-height: 400px;
}

/* ── Cards ──
   Static item cards for hand-written pages. Proportions follow the cards
   rendered by the publications (orcid-display) and code (github-portfolio)
   widgets, which style their own shadow DOM; colors come from the site tokens
   so light and dark mode follow the rest of the site. */
.card-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(280px, 100%), 1fr));
  gap: 16px;
}

.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 16px;
  min-width: 0;
  overflow-wrap: break-word;
  line-height: 1.5;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.card:hover {
  border-color: var(--link);
  box-shadow: 0 1px 3px var(--shadow-color);
}

.card-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  gap: 4px 12px;
  margin-bottom: 8px;
  font-size: 12px;
  color: var(--text-secondary);
}

.card-tag {
  font-weight: 600;
  letter-spacing: 0.02em;
}

.card-title {
  font-family: var(--font-sans);
  font-size: 16px;
  font-weight: 600;
  line-height: 1.4;
  margin: 0 0 8px;
  color: var(--text);
}

.card-title:last-child,
.card-desc:last-child {
  margin-bottom: 0;
}

.card-desc {
  margin: 0 0 12px;
  font-size: 14px;
  color: var(--text-secondary);
}

.card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 12px;
}

.card-badge {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 3px 8px;
  color: var(--text-secondary);
}

.card-badge:hover {
  background: var(--hover-bg);
  color: var(--text);
  text-decoration: none;
}

/* ── Contact ── */
.contact-info {
  font-size: 1.05rem;
  line-height: 2;
}

.contact-info a {
  font-weight: 500;
}

/* ── Footer ── */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 1.5rem;
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

/* ── Responsive ── */
@media (max-width: 768px) {
  .nav-toggle {
    display: block;
  }

  .nav-links {
    display: none;
    position: absolute;
    top: 64px;
    left: 0;
    right: 0;
    background: var(--nav-bg);
    border-bottom: 1px solid var(--border);
    flex-direction: column;
    padding: 0.5rem 1rem 1rem;
    box-shadow: 0 8px 24px var(--shadow-color-sm);
  }

  .nav-links.open {
    display: flex;
  }

  .nav-dropdown-menu {
    position: static;
    box-shadow: none;
    border: none;
    padding-left: 1rem;
    min-width: 0;
  }

  .nav-dropdown:hover .nav-dropdown-menu {
    display: none;
  }

  .nav-dropdown.open .nav-dropdown-menu {
    display: block;
  }

  .hero {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }

  .hero-image {
    max-width: 280px;
    margin: 0 auto;
  }

  .hero-name {
    font-size: 1.8rem;
  }

  .main {
    padding: 2rem 1rem 3rem;
  }

  .pdf-embed {
    height: 70vh;
  }
}

@media (max-width: 480px) {
  .hero-image {
    max-width: 220px;
  }

  .hero-name {
    font-size: 1.5rem;
  }
}
