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

:root {
  --text: #1a1a1a;
  --text-light: #555;
  --bg: #fff;
  --bg-alt: #f8f9fa;
  --border: #e0e0e0;
  --accent: #0066cc;
  --accent-hover: #004da6;
  --sidebar-w: 200px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

html { scroll-behavior: smooth; }
body {
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.65;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); text-decoration: underline; }
img { max-width: 100%; height: auto; display: block; }

/* ── Layout: Sidebar + Main ──────────────────────────────── */
.layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  border-right: 1px solid var(--border);
}

.sidebar-inner {
  position: sticky;
  top: 0;
  padding: 2rem 1.2rem;
  height: 100vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.sidebar-photo {
  margin-bottom: 0.8rem;
}
.sidebar-photo img {
  width: 100%;
  border-radius: 8px;
}

.sidebar-name h1 {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.3;
}
.sidebar .subtitle {
  font-size: 0.72rem;
  color: var(--text-light);
  margin-top: 0.3rem;
  line-height: 1.4;
}

.sidebar nav {
  margin-top: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}
.sidebar nav a {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-light);
  text-decoration: none;
  padding: 0.3rem 0.5rem;
  border-radius: 4px;
  transition: background 0.15s, color 0.15s;
}
.sidebar nav a:hover {
  background: var(--bg-alt);
  color: var(--text);
  text-decoration: none;
}
.sidebar nav a.nav-sub {
  font-size: 0.72rem;
  padding-left: 1.1rem;
  color: var(--text-light);
  opacity: 0.8;
}
.sidebar nav a.nav-sub:hover {
  opacity: 1;
}

/* ── Main ────────────────────────────────────────────────── */
main {
  flex: 1;
  max-width: 780px;
  padding: 0 2rem;
}

section {
  padding: 2.5rem 0;
  border-bottom: 1px solid var(--border);
}
section:last-child { border-bottom: none; }

h2 {
  font-size: 1.1rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-light);
  margin-bottom: 1.2rem;
}
h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-top: 1.5rem;
  margin-bottom: 0.4rem;
}
h4 {
  font-size: 0.9rem;
  font-weight: 600;
  margin-top: 1.2rem;
  margin-bottom: 0.3rem;
}
p { margin-bottom: 0.7rem; }
ul { padding-left: 1.2rem; margin-bottom: 0.7rem; }
li { margin-bottom: 0.3rem; }

/* ── About ───────────────────────────────────────────────── */
.about-grid {
  display: grid;
  grid-template-columns: 1fr 160px;
  gap: 2rem;
  align-items: start;
}
.about-photo img {
  border-radius: 8px;
  width: 100%;
}

/* ── Entries (experience, education) ─────────────────────── */
.project-category {
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent);
  margin-top: 2rem;
  margin-bottom: 0.5rem;
  padding-bottom: 0.3rem;
  border-bottom: 1px dashed var(--border);
}
.project-category:first-of-type { margin-top: 0; }

.project-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.4em;
  height: 1.4em;
  font-size: 0.7em;
  font-weight: 700;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  margin-right: 0.4em;
  vertical-align: middle;
}
/* Details/Summary accordion */
details.project {
  border: 1px solid var(--border);
  border-radius: 6px;
  margin-bottom: 0.5rem;
  overflow: hidden;
}
details.project summary {
  padding: 0.6rem 0.8rem;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.4rem;
  transition: background 0.15s;
}
details.project summary::-webkit-details-marker { display: none; }
details.project summary::after {
  content: "+";
  margin-left: auto;
  font-size: 1.1rem;
  font-weight: 400;
  color: var(--text-light);
  transition: transform 0.2s;
}
details.project[open] summary::after {
  content: "\2212";
}
details.project summary:hover {
  background: var(--bg-alt);
}
.meta-inline {
  font-size: 0.72rem;
  font-weight: 400;
  color: var(--text-light);
}
.project-body {
  padding: 0 0.8rem 0.8rem;
}

.sourced-by {
  font-size: 0.76rem;
  color: var(--text-light);
  border-top: 1px dashed var(--border);
  padding-top: 0.4rem;
  margin-top: 0.6rem;
}

.entry { margin-bottom: 1.5rem; }
.entry-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
}
.entry-header h3 { margin-top: 0; }
.date {
  font-size: 0.82rem;
  color: var(--text-light);
  white-space: nowrap;
}
.org {
  font-size: 0.85rem;
  color: var(--text-light);
  margin-bottom: 0.3rem;
}
.meta {
  font-size: 0.82rem;
  color: var(--text-light);
  margin-bottom: 0.8rem;
}

/* ── Tables ──────────────────────────────────────────────── */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  margin: 0.5rem 0 1rem;
}
td {
  padding: 0.4rem 0.6rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
td:first-child {
  font-weight: 600;
  white-space: nowrap;
  width: 140px;
  color: var(--text-light);
}

/* ── Images ──────────────────────────────────────────────── */
.img-row { margin: 0.8rem 0; }
.img-row img {
  border-radius: 6px;
  border: 1px solid var(--border);
  cursor: pointer;
  transition: opacity 0.15s;
}
.img-row img:hover { opacity: 0.85; }
.img-row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}
.img-row-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 0.5rem;
}
.fig {
  margin: 0;
}
.fig figcaption {
  font-size: 0.7rem;
  color: var(--text-light);
  margin-top: 0.25rem;
  line-height: 1.35;
}

/* Lightbox */
.lightbox-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.85);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: zoom-out;
  animation: lbFadeIn 0.2s ease;
}
@keyframes lbFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
.lightbox-overlay img {
  max-width: 90vw;
  max-height: 90vh;
  border-radius: 8px;
  box-shadow: 0 4px 40px rgba(0,0,0,0.5);
}

/* ── Publications ────────────────────────────────────────── */
.pub-list {
  list-style: none;
  padding-left: 0;
}
.pub-list li {
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.86rem;
  line-height: 1.5;
}
.pub-list li:last-child { border-bottom: none; }

/* ── Contact ─────────────────────────────────────────────── */
.contact-list {
  list-style: none;
  padding-left: 0;
}
.contact-list li {
  margin-bottom: 0.4rem;
  font-size: 0.9rem;
}

/* ── Explore Widget ──────────────────────────────────────── */
.explore-widget { margin-top: 0.5rem; }
.chip-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-bottom: 0.35rem;
}
.chip-group:empty { display: none; margin: 0; }

.kw-chip {
  padding: 0.2rem 0.55rem;
  font-size: 0.76rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  white-space: nowrap;
}
.kw-chip:hover, .kw-chip.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.kw-chip.sub {
  font-size: 0.72rem;
  border-style: dashed;
}
.kw-chip.sub:hover, .kw-chip.sub.active { border-style: solid; }
.kw-chip.leaf {
  font-size: 0.68rem;
  border-style: dotted;
}
.kw-chip.leaf:hover, .kw-chip.leaf.active { border-style: solid; }

#explore-results { margin-top: 0.4rem; }
.explore-result {
  display: block;
  padding: 0.55rem 0.7rem;
  margin-bottom: 0.3rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  text-decoration: none;
  color: var(--text);
  transition: border-color 0.15s;
}
.explore-result:hover {
  border-color: var(--accent);
  text-decoration: none;
  color: var(--text);
}
.explore-result-type {
  display: inline-block;
  font-size: 0.63rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--accent);
  margin-bottom: 0.1rem;
}
.explore-result-title {
  display: block;
  font-weight: 600;
  font-size: 0.84rem;
  line-height: 1.3;
}
.explore-result-desc {
  display: block;
  font-size: 0.76rem;
  color: var(--text-light);
  margin-top: 0.1rem;
  line-height: 1.4;
}

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

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 768px) {
  .layout { flex-direction: column; }

  .sidebar {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .sidebar-inner {
    position: static;
    height: auto;
    padding: 1.2rem 1.5rem;
  }
  .sidebar nav {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 0.1rem 0.6rem;
    margin-top: 0.8rem;
  }

  main { padding: 0 1.5rem; }

  .sidebar-photo { max-width: 80px; }
  .img-row-3 { grid-template-columns: 1fr; }
  .entry-header { flex-direction: column; gap: 0; }
  td:first-child { width: auto; }
}

@media print {
  details { page-break-inside: avoid; }
  details > summary { list-style: none; cursor: default; }
  details > summary::-webkit-details-marker { display: none; }
  details > *:not(summary) { display: block !important; }
}
