/* =============================================================================
   Chalkboard theme.
   Most visual choices live in :root variables — change a value there and the
   whole page updates.
   ========================================================================== */

:root {
  --bg:           #2c3838;   /* dark slate "chalkboard" background */
  --bg-darker:    #232c2c;   /* slightly darker — used inside the cite popup */
  --text:         #ebe9dc;   /* chalk-white body text */
  --text-dim:     #a8a89c;   /* dimmer text for metadata */
  --accent:       #a8e065;   /* lime-ish green for links and highlights */
  --accent-bright:#cdf093;   /* hover state */
  --rule:         rgba(235, 233, 220, 0.18);  /* faint dividing lines */
  --max-width:    820px;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

/* Anchor jumps clear the sticky nav bar by this much. */
#bio, section[id$="-section"] { scroll-margin-top: 4rem; }

body {
  background-color: var(--bg);
  /* Subtle "chalk dust" — two soft radial highlights and a faint SVG noise.   */
  background-image:
    radial-gradient(ellipse at 20% 15%, rgba(255,255,255,0.05), transparent 60%),
    radial-gradient(ellipse at 80% 90%, rgba(255,255,255,0.035), transparent 60%),
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='140' height='140'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 1  0 0 0 0 1  0 0 0 0 1  0 0 0 0.04 0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
  background-attachment: fixed;
  color: var(--text);
  /* Sans-serif system stack — clean and consistent across OSes. */
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
               "Helvetica Neue", Arial, sans-serif;
  /* Fluid base size: scales smoothly between phone and desktop. */
  font-size: clamp(16px, 1.6vw + 12px, 18px);
  line-height: 1.65;
  min-height: 100vh;
  padding: 2.5rem 1.25rem 4rem;
  -webkit-text-size-adjust: 100%;
  overflow-wrap: break-word;
  word-wrap: break-word;
}

main {
  max-width: var(--max-width);
  margin: 0 auto;
}

/* ---------- Links ---------- */

a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px dashed rgba(168, 224, 101, 0.35);
  transition: color 0.15s, border-color 0.15s;
}
a:hover, a:focus {
  color: var(--accent-bright);
  border-bottom-color: var(--accent-bright);
  outline: none;
}

/* ---------- Headings ---------- */

h1, h2, h3 {
  color: #fff;
  font-weight: normal;
  letter-spacing: 0.5px;
  /* Faint glow that mimics chalk diffusion on a slate. */
  text-shadow: 0 0 1px rgba(255,255,255,0.35);
  font-family: inherit;
}

h1 {
  /* Fluid heading: shrinks gracefully on phones, grows on desktops. */
  font-size: clamp(1.85rem, 4.2vw + 0.8rem, 2.6rem);
  margin: 0 0 0.25rem;
  letter-spacing: 1px;
  line-height: 1.15;
}
h2 {
  font-size: clamp(1.25rem, 1.4vw + 0.9rem, 1.55rem);
  margin: 2.5rem 0 1rem;
  border-bottom: 1px solid var(--rule);
  padding-bottom: 0.4rem;
}
h3 { font-size: 1.1rem; margin: 1.25rem 0 0.4rem; }

/* ---------- Profile header ---------- */

.profile {
  display: flex;
  gap: 2rem;
  align-items: flex-start;
  margin-bottom: 2rem;
}

.avatar {
  width: 280px;
  height: auto;            /* respect the photo's native aspect ratio */
  border-radius: 2px;      /* hard square corners with a hair of softening */
  flex-shrink: 0;
  border: 1px solid var(--rule);
  box-shadow: 0 0 0 4px rgba(255,255,255,0.04);
}

.profile-text { flex: 1; min-width: 0; }

.role {
  color: var(--text-dim);
  font-style: italic;
  margin: 0 0 0.75rem;
  font-size: 1.08rem;
}

.affiliations,
.contacts { list-style: none; padding: 0; margin: 0; }

.affiliations li { margin: 0.15rem 0; }

.contacts {
  display: flex;
  gap: 0.75rem;
  margin-top: 1rem;
  flex-wrap: wrap;
}
.contacts a {
  display: inline-flex;
  width: 38px;
  height: 38px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--rule);
  border-radius: 50%;
  color: var(--accent);
  padding: 0;
}
.contacts a:hover {
  border-color: var(--accent);
  color: var(--accent-bright);
}
.contacts svg {
  width: 20px;
  height: 20px;
  display: block;
}
.contacts .cv-link {
  width: auto;
  border-radius: 999px;
  padding: 0 0.85rem;
  font-size: 0.9rem;
  letter-spacing: 1px;
}

/* ---------- Bio ---------- */

#bio p { margin: 0; }

/* ---------- Two-column section (Interests / Education) ---------- */

.two-column {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2.5rem;
  margin-top: 1.5rem;
}
.two-column h3 {
  margin: 0 0 0.5rem;
  color: var(--text);            /* match body text — feels like a subsection */
  font-weight: 600;
  letter-spacing: 0.3px;
}
.two-column ul { list-style: none; padding: 0; margin: 0; }
.two-column li { margin: 0.55rem 0; }

/* ---------- Publication list ---------- */

.publication-list {
  display: flex;
  flex-direction: column;
  gap: 1.4rem;
}

.pub { display: flex; flex-direction: column; gap: 0.4rem; }

.pub-row {
  display: flex;
  align-items: flex-start;       /* buttons sit at the top of the line */
  gap: 1rem;
}

.pub-line {
  flex: 1;                        /* text takes the remaining width */
  min-width: 0;                   /* lets long words wrap inside flex */
  margin: 0;
  color: var(--text);
  line-height: 1.5;
  overflow-wrap: anywhere;
}
.pub-line a {
  color: var(--accent);
  border-bottom: 1px dashed rgba(168, 224, 101, 0.35);
}
.pub-line a:hover, .pub-line a:focus {
  color: var(--accent-bright);
  border-bottom-color: var(--accent-bright);
}

.pub-actions {
  display: flex;
  flex-direction: column;     /* stack .bib and Abstract vertically */
  gap: 0.4rem;
  flex-shrink: 0;             /* don't get squeezed by long titles */
  align-items: stretch;
}

.cite-btn, .abs-btn {
  background: transparent;
  border: 1px solid var(--rule);
  color: var(--accent);
  padding: 0.2rem 0.7rem;
  border-radius: 3px;
  cursor: pointer;
  font: inherit;
  font-size: 0.82rem;
  white-space: nowrap;
  text-align: center;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.cite-btn:hover, .abs-btn:hover {
  border-color: var(--accent);
  color: var(--accent-bright);
  background: rgba(168, 224, 101, 0.05);
}

.pub-abstract {
  margin-top: 0.55rem;
  padding: 0.75rem 1rem;
  background: rgba(0, 0, 0, 0.22);
  border-left: 2px solid var(--accent);
  font-size: 0.94rem;
  color: var(--text-dim);
  line-height: 1.55;
}

/* ---------- Cite modal ---------- */

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 0.75rem;
}
.modal[hidden] { display: none; }

.modal-content {
  background: var(--bg-darker);
  border: 1px solid var(--rule);
  padding: 1.5rem 1.5rem 1.25rem;
  border-radius: 4px;
  max-width: 720px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  position: relative;
  box-shadow: 0 6px 30px rgba(0,0,0,0.5);
  -webkit-overflow-scrolling: touch;   /* nicer momentum scroll on iOS */
}
.modal-content h3 { margin-top: 0; }

.modal-close {
  position: absolute;
  top: 0.4rem;
  right: 0.6rem;
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 1.7rem;
  line-height: 1;
  cursor: pointer;
  padding: 0.25rem 0.5rem;
}
.modal-close:hover { color: var(--accent-bright); }

#cite-text {
  background: rgba(0, 0, 0, 0.32);
  padding: 1rem;
  border-radius: 3px;
  white-space: pre;
  overflow-x: auto;
  font-family: "Consolas", "Menlo", "DejaVu Sans Mono", monospace;
  font-size: 0.82rem;
  color: var(--text);
  margin: 0.5rem 0 0.75rem;
  line-height: 1.5;
  max-width: 100%;
}

#cite-copy {
  background: var(--accent);
  color: #1d2727;
  border: none;
  padding: 0.45rem 1.1rem;
  border-radius: 3px;
  cursor: pointer;
  font: inherit;
  font-weight: 600;
}
#cite-copy:hover { background: var(--accent-bright); }

/* ---------- Trainees / Teaching helpers ---------- */

#trainees-list ul,
#teaching-list ul { list-style: none; padding: 0; margin: 0; }
#trainees-list li,
#teaching-list li { margin: 0.5rem 0; }

/* ---------- Sticky section nav ---------- */

.page-nav {
  position: sticky;
  top: 0;
  z-index: 50;
  margin: 0 0 1.5rem;
  background: rgba(44, 56, 56, 0.92);
  backdrop-filter: saturate(150%) blur(8px);
  -webkit-backdrop-filter: saturate(150%) blur(8px);
  border-bottom: 1px solid var(--rule);
}
.page-nav[hidden] { display: none; }

.page-nav ul {
  display: flex;
  flex-wrap: wrap;
  list-style: none;
  margin: 0;
  padding: 0.55rem 0 0.55rem 1rem;   /* breathing room before the first item */
  gap: 1.4rem;
  font-size: 0.95rem;
}
.page-nav a {
  color: var(--text);
  border-bottom: none;
  letter-spacing: 0.3px;
}
.page-nav a:hover, .page-nav a:focus {
  color: var(--accent-bright);
}

@media (max-width: 560px) {
  .page-nav ul { gap: 1rem; padding: 0.45rem 0 0.45rem 0.75rem; font-size: 0.88rem; }
}

/* ---------- Last-updated footer ---------- */

.last-updated {
  margin-top: 4rem;
  text-align: right;
  color: var(--text-dim);
  font-size: 0.85rem;
  font-style: italic;
}

/* ---------- Errors ---------- */

.error {
  color: #f0a8a8;
  font-style: italic;
}

/* ---------- Tablets (single column, smaller avatar gap) ---------- */

@media (max-width: 760px) {
  body { padding: 2rem 1rem 3rem; }
  .profile { gap: 1.5rem; }
  .avatar { width: 220px; }
  .two-column { grid-template-columns: 1fr; gap: 0.5rem; }
}

/* ---------- Phones ---------- */

@media (max-width: 560px) {
  body { padding: 1.5rem 0.9rem 2.5rem; line-height: 1.6; }
  .profile {
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
  }
  .avatar { width: 90%; max-width: 280px; }
  .contacts { justify-content: center; }
  .contacts a { width: 36px; height: 36px; }
  h2 { margin-top: 2rem; }
  /* Stack action buttons below the line on phones so titles aren't squeezed. */
  .pub-row { flex-direction: column; gap: 0.4rem; }
  .pub-actions { flex-direction: row; }
  .modal-content { padding: 1.25rem 1rem 1rem; }
  #cite-text { font-size: 0.78rem; padding: 0.75rem; }
  #cite-copy, .cite-btn, .abs-btn { font-size: 0.85rem; }
}

/* ---------- Very small phones ---------- */

@media (max-width: 360px) {
  body { padding: 1.25rem 0.75rem 2rem; }
  .avatar { width: 95%; max-width: 240px; }
  h1 { letter-spacing: 0.5px; }
}

/* Honour reduced-motion preferences. */
@media (prefers-reduced-motion: reduce) {
  a, .cite-btn, .abs-btn, #cite-copy { transition: none; }
}
