/* ═══════════════════════════════════════════════════════════════
   alejbarea.github.io — stylesheet
   Design tokens live in :root below. To retune the whole site,
   change the colors there (light theme) and in [data-theme="dark"].
   ═══════════════════════════════════════════════════════════════ */

:root {
  /* Palette — cool scientific teal (matches the chemotaxis background) */
  --bg: #f6f8f9;
  --bg-alt: #ecf1f3;
  --surface: #ffffff;
  --ink: #161d23;
  --muted: #5a6771;
  --accent: #176f86;
  --accent-strong: #10566a;
  --accent-soft: rgba(23, 111, 134, 0.09);
  --line: #dce3e7;
  --chip-bg: #ffffff;
  --shadow: 0 1px 2px rgba(20, 32, 40, 0.05), 0 8px 24px rgba(20, 32, 40, 0.06);
  --shadow-lift: 0 2px 4px rgba(20, 32, 40, 0.07), 0 16px 40px rgba(20, 32, 40, 0.12);

  /* Type */
  --serif: 'Newsreader', Georgia, 'Times New Roman', serif;
  --sans: 'Inter', -apple-system, 'Segoe UI', Roboto, sans-serif;

  --radius: 12px;
  --header-h: 3.5rem;

  color-scheme: light;
}

[data-theme="dark"] {
  --bg: #0d1317;
  --bg-alt: #111a1f;
  --surface: #162026;
  --ink: #e5ecef;
  --muted: #93a3ad;
  --accent: #61c3d1;
  --accent-strong: #8bd8e2;
  --accent-soft: rgba(97, 195, 209, 0.13);
  --line: #24313a;
  --chip-bg: #eef3f5;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.35);
  --shadow-lift: 0 2px 4px rgba(0, 0, 0, 0.35), 0 16px 40px rgba(0, 0, 0, 0.5);

  color-scheme: dark;
}

/* ── Reset & base ─────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-h) + 1rem);
}

body {
  margin: 0;
  font-family: var(--sans);
  font-size: 1rem;
  line-height: 1.65;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

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

a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--accent-strong); }

h1, h2, h3 {
  font-family: var(--serif);
  font-optical-sizing: auto;
  line-height: 1.15;
  margin: 0 0 0.5em;
  font-weight: 600;
  letter-spacing: -0.01em;
}

ul { padding-left: 1.2rem; }
li { margin-bottom: 0.35rem; }

.container { max-width: 68rem; margin: 0 auto; padding: 0 1.5rem; }

.sprite { display: none; }

svg { fill: currentColor; flex-shrink: 0; }

/* ── Chemotaxis background ─────────────────────────────────────────
   A full-page canvas of amoeboid cells crawling up a gradient toward
   the pointer. Painted behind everything; the translucent section and
   card backgrounds below let it show through. Purely decorative —
   drawn by js/main.js, and skipped entirely under reduced-motion. */
#cell-bg {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
}

/* Content sits above the canvas. */
.site-header { z-index: 50; }
main, .site-footer { position: relative; z-index: 1; }

.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
  background: var(--accent);
  color: #fff;
  padding: 0.5rem 1rem;
  z-index: 100;
}
.skip-link:focus { left: 0; }

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

::selection { background: var(--accent); color: #fff; }

/* ── Header / nav ─────────────────────────────────────────────── */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--bg) 80%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}

.nav {
  display: flex;
  align-items: center;
  gap: 1rem;
  min-height: var(--header-h);
}

.brand {
  font-family: var(--serif);
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--ink);
  text-decoration: none;
  margin-right: auto;
}
.brand:hover { color: var(--accent); }

.nav-menu {
  display: flex;
  gap: 0.15rem;
  list-style: none;
  margin: 0;
  padding: 0;
}

.nav-menu a {
  display: block;
  padding: 0.4rem 0.65rem;
  font-size: 0.86rem;
  font-weight: 500;
  color: var(--muted);
  text-decoration: none;
  border-radius: 8px;
  transition: color 0.15s, background 0.15s;
}

.nav-menu a:hover { color: var(--ink); background: var(--accent-soft); }

.nav-menu a.active { color: var(--accent); background: var(--accent-soft); }

.nav-toggle {
  display: none;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  border-radius: 8px;
  padding: 0.35rem 0.5rem;
  cursor: pointer;
}

.theme-toggle {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  border-radius: 999px;
  width: 2.1rem;
  height: 2.1rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}
.theme-toggle:hover { color: var(--accent); border-color: var(--accent); }

/* Show sun icon in dark mode, moon icon in light mode */
.theme-toggle .icon-sun { display: none; }
[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
[data-theme="dark"] .theme-toggle .icon-moon { display: none; }

/* ── Hero ─────────────────────────────────────────────────────── */
.hero { padding: 5rem 0 5.5rem; }

.hero-grid {
  display: grid;
  grid-template-columns: 1.25fr 0.75fr;
  gap: 3.5rem;
  align-items: center;
}

.eyebrow {
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 1rem;
}

.hero h1 {
  font-size: clamp(2.6rem, 6vw, 4rem);
  font-weight: 700;
  margin-bottom: 0.4rem;
}

.hero-role {
  font-family: var(--serif);
  font-style: italic;
  font-size: 1.3rem;
  color: var(--muted);
  margin: 0 0 1.4rem;
}

/* Research statement — a pulled-out serif line to the left of a rule */
.hero-statement {
  font-family: var(--serif);
  font-size: 1.35rem;
  line-height: 1.45;
  max-width: 34rem;
  margin: 0 0 1.4rem;
  border-left: 3px solid var(--accent);
  padding-left: 1.1rem;
  text-wrap: pretty;
}

.hero-bio { max-width: 34rem; margin: 0 0 1.5rem; color: var(--muted); text-wrap: pretty; }

/* Interest chips under the bio */
.hero-tags {
  list-style: none;
  margin: 0 0 2rem;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}
.hero-tags li {
  margin: 0;
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.2rem 0.7rem;
  background: color-mix(in srgb, var(--surface) 70%, transparent);
}

.hero-actions { display: flex; flex-wrap: wrap; gap: 0.75rem; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 1.2rem;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.92rem;
  text-decoration: none;
  transition: transform 0.15s, box-shadow 0.15s, background 0.15s, color 0.15s;
}
.btn:hover { transform: translateY(-2px); }

.btn-primary {
  background: var(--accent);
  color: #fff;
  box-shadow: var(--shadow);
}
.btn-primary:hover { background: var(--accent-strong); color: #fff; box-shadow: var(--shadow-lift); }
/* In dark mode the accent is a bright teal, so use dark text for contrast. */
[data-theme="dark"] .btn-primary { color: #0d1317; }
[data-theme="dark"] .btn-primary:hover { color: #0d1317; }

.btn-ghost {
  border: 1px solid var(--line);
  color: var(--ink);
}
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }

.hero-portrait { position: relative; }

.hero-portrait img {
  border-radius: var(--radius);
  box-shadow: var(--shadow-lift);
}

/* Offset frame behind the portrait */
.hero-portrait::before {
  content: "";
  position: absolute;
  inset: 1rem -1rem -1rem 1rem;
  border: 2px solid var(--accent);
  border-radius: var(--radius);
  opacity: 0.35;
  z-index: -1;
}

/* ── Sections ─────────────────────────────────────────────────── */
.section { padding: 4.5rem 0; }
.section-alt { background: color-mix(in srgb, var(--bg-alt) 82%, transparent); }

.site-footer, .section { border-top: 1px solid var(--line); }

.section-title {
  font-size: clamp(1.8rem, 3.5vw, 2.4rem);
  margin-bottom: 2.2rem;
  display: flex;
  align-items: baseline;
  gap: 0.85rem;
}

.section-num {
  font-family: var(--sans);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: 0.08em;
}

.subheading {
  font-family: var(--sans);
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 1.4rem;
}

.subheading-2 { margin-top: 2.5rem; }

/* ── Entries (education / experience / teaching) ──────────────── */
.entry {
  display: grid;
  grid-template-columns: 7rem 1fr;
  gap: 1.75rem;
  padding: 1.75rem;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 1.25rem;
}

.entry-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--chip-bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.75rem;
  height: 7rem;
}

.entry-logo img { max-height: 100%; object-fit: contain; }

.entry-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.25rem 1rem;
  margin-bottom: 0.4rem;
}

.entry-head h3 { font-size: 1.45rem; margin: 0; }

.entry-date {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 0.2rem 0.7rem;
  border-radius: 999px;
  white-space: nowrap;
}

.entry-body p:last-child, .entry-body ul:last-child { margin-bottom: 0; }

/* ── Publications ─────────────────────────────────────────────── */
.publication {
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem 1.75rem;
  margin-bottom: 1.25rem;
}

.pub-citation { margin: 0 0 0.9rem; }

.pub-title { font-family: var(--serif); font-style: italic; font-size: 1.08rem; }

.pub-links { display: flex; flex-wrap: wrap; gap: 0.5rem; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--accent);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.25rem 0.8rem;
  text-decoration: none;
  transition: border-color 0.15s, background 0.15s;
}
.pill:hover { border-color: var(--accent); background: var(--accent-soft); }

.pub-venue { font-size: 0.9rem; color: var(--muted); }

/* Empty-state note (e.g. no talks listed yet) */
.empty-note {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  padding: 1.1rem 1.5rem;
}
.empty-note code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.85em; }

/* Talks & posters */
.talk {
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem 1.75rem;
  margin-bottom: 0.75rem;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem 1rem;
}
.talk-title { margin: 0; font-family: var(--serif); font-style: italic; font-size: 1.08rem; }
.talk-meta { margin: 0.15rem 0 0; font-size: 0.88rem; color: var(--muted); }
.talk-date {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 0.2rem 0.7rem;
  border-radius: 999px;
  white-space: nowrap;
}

/* ── Teaching (compact rows) ──────────────────────────────────── */
.teach-list { display: grid; gap: 0.75rem; }

.teach-row {
  display: grid;
  grid-template-columns: 2.75rem 1fr auto;
  align-items: center;
  gap: 1.25rem;
  padding: 1.1rem 1.5rem;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.teach-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--chip-bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.3rem;
  height: 2.75rem;
}
.teach-logo img { max-height: 100%; object-fit: contain; }

.teach-course { font-size: 1.15rem; margin: 0 0 0.15rem; }
.teach-meta { margin: 0; font-size: 0.86rem; color: var(--muted); }

.teach-term {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 0.2rem 0.7rem;
  border-radius: 999px;
  white-space: nowrap;
}

/* ── Cards (projects / hobbies) ───────────────────────────────── */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr));
  gap: 1.5rem;
}

.card-grid-2 { grid-template-columns: repeat(auto-fill, minmax(19rem, 1fr)); }

.card {
  display: flex;
  flex-direction: column;
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: transform 0.2s, box-shadow 0.2s;
}

.card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lift); }

.card > img { aspect-ratio: 3 / 2; object-fit: cover; width: 100%; }

.card-body {
  display: flex;
  flex-direction: column;
  flex: 1;
  padding: 1.25rem 1.4rem 1.4rem;
}

.card-body h3 { font-size: 1.25rem; }

.card-body p { margin: 0 0 1rem; color: var(--muted); flex: 1; }

.card-link {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.88rem;
  font-weight: 600;
  text-decoration: none;
}
.card-link:hover { text-decoration: underline; }

/* Project tech tags */
.card-tags {
  list-style: none;
  margin: 0 0 1rem;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}
.card-tags li {
  margin: 0;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  background: var(--bg-alt);
  border-radius: 6px;
  padding: 0.12rem 0.5rem;
}

/* ── Certifications ───────────────────────────────────────────── */
.cert-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(13rem, 1fr));
  gap: 1.5rem;
}

.cert {
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem;
  text-align: center;
}

.cert img {
  height: 5.5rem;
  width: auto;
  object-fit: contain;
  margin: 0 auto 1rem;
  border-radius: 8px;
}

.cert h3 { font-family: var(--sans); font-size: 0.98rem; font-weight: 600; line-height: 1.4; }

.cert-date { color: var(--muted); font-size: 0.85rem; margin: 0; }

/* ── Footer / contact ─────────────────────────────────────────── */
.site-footer {
  background: color-mix(in srgb, var(--bg-alt) 82%, transparent);
  padding: 4rem 0 2.5rem;
}

.contact-list {
  list-style: none;
  margin: 0 0 2.5rem;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
  gap: 1rem;
}

.contact-list li { display: flex; align-items: center; gap: 0.7rem; margin: 0; }

.contact-list svg { color: var(--accent); }

.contact-list a { color: var(--ink); text-decoration: none; }
.contact-list a:hover { color: var(--accent); text-decoration: underline; }

.colophon {
  border-top: 1px solid var(--line);
  padding-top: 1.5rem;
  font-size: 0.85rem;
  color: var(--muted);
  margin: 0;
}

/* ── Responsive ───────────────────────────────────────────────── */
@media (max-width: 56rem) {
  .nav-toggle { display: inline-flex; order: 2; }
  .theme-toggle { order: 3; }

  .nav-menu {
    /* collapses into a dropdown; toggled by adding .open in js/main.js */
    display: none;
    position: absolute;
    top: var(--header-h);
    left: 0;
    right: 0;
    flex-direction: column;
    gap: 0.25rem;
    background: var(--bg);
    border-bottom: 1px solid var(--line);
    box-shadow: var(--shadow);
    padding: 0.75rem 1.5rem 1rem;
  }
  .nav-menu.open { display: flex; }
  .nav-menu a { font-size: 1rem; padding: 0.55rem 0.75rem; }

  .hero { padding: 3rem 0 3.5rem; }
  .hero-grid { grid-template-columns: 1fr; gap: 2.5rem; }
  .hero-portrait { order: -1; max-width: 17rem; }

  .entry { grid-template-columns: 1fr; gap: 1rem; }
  .entry-logo { width: 7rem; }

  .section { padding: 3rem 0; }
}

/* ── Motion preferences ───────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* ── Print ────────────────────────────────────────────────────── */
@media print {
  .site-header, .theme-toggle, .skip-link { display: none; }
  .section, .site-footer { border: none; padding: 1.5rem 0; }
  body { background: #fff; color: #000; }
}
