/* ==========================================================================
   Daniel Fuertes · personal site
   1. Design tokens   2. Base   3. Layout   4. Sidebar   5. Navigation
   6. Sections        7. Components   8. Publications   9. Utilities / responsive
   ========================================================================== */

/* 1. Design tokens -------------------------------------------------------- */
:root {
  --font-sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-serif: "Source Serif 4", Georgia, "Times New Roman", serif;
  --font-mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;

  --bg: #f6f6f3;
  --surface: #ffffff;
  --surface-2: #f0f1ee;
  --text: #1a1f24;
  --muted: #5a6570;
  --border: #e2e3de;
  --accent: #0e6b72;
  --accent-hover: #0a5258;
  --accent-soft: rgba(14, 107, 114, 0.09);
  --journal: #0e6b72;
  --conference: #7a4fb0;
  --thesis: #a8661b;
  --thumb-bg: #ffffff;
  --shadow: 0 1px 2px rgba(20, 30, 40, 0.04), 0 8px 24px rgba(20, 30, 40, 0.06);

  /* Colours used by the canvas animation (read from JS). */
  --graph-bg-1: #0d4f55;
  --graph-bg-2: #13303b;
  --graph-node: rgba(255, 255, 255, 0.4);
  --graph-agents: #7fe3d6, #ffc46b, #f59aa7, #a9b8ff;

  --radius: 14px;
  --radius-sm: 8px;
  --sidebar-width: 300px;
}

[data-theme="dark"] {
  --bg: #0d1113;
  --surface: #141a1d;
  --surface-2: #1a2226;
  --text: #e5e9eb;
  --muted: #98a3aa;
  --border: #253035;
  --accent: #5cc8c4;
  --accent-hover: #86dbd7;
  --accent-soft: rgba(92, 200, 196, 0.12);
  --journal: #5cc8c4;
  --conference: #b597e6;
  --thesis: #e0a55c;
  --thumb-bg: #f3f3f1;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.25);

  --graph-bg-1: #0a2a2e;
  --graph-bg-2: #0b1418;
}

/* 2. Base ----------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; scroll-padding-top: 5rem; }

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.65;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.2s ease, color 0.2s ease;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); text-decoration: underline; text-underline-offset: 3px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

h1, h2, h3, h4 { font-family: var(--font-serif); line-height: 1.25; margin: 0; }
img { max-width: 100%; display: block; }
.icon { flex-shrink: 0; vertical-align: -0.15em; }

.skip-link { position: absolute; left: -999px; top: 1rem; z-index: 100; background: var(--surface); padding: 0.5rem 1rem; border-radius: var(--radius-sm); }
.skip-link:focus { left: 1rem; }

/* 3. Layout --------------------------------------------------------------- */
.layout {
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  gap: 3.5rem;
  max-width: 1160px;
  margin: 0 auto;
  padding: 1.5rem 2rem 0;
}

.content { min-width: 0; }

/* 4. Sidebar -------------------------------------------------------------- */
.sidebar { position: relative; }

.profile-card {
  position: sticky;
  top: 1.5rem;
  max-height: calc(100vh - 3rem); /* never taller than the screen; scrolls inside on very short screens */
  overflow-y: auto;
  scrollbar-width: thin;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  text-align: center;
}

.route-graph {
  display: block;
  width: 100%;
  height: 100px;
  background: linear-gradient(135deg, var(--graph-bg-1), var(--graph-bg-2));
}

.profile-card__photo {
  width: 112px;
  height: 112px;
  margin: -56px auto 0;
  position: relative;
  border-radius: 50%;
  border: 4px solid var(--surface);
  object-fit: cover;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.15);
}

.profile-card__body { padding: 0.75rem 1.25rem 1.25rem; }
.profile-card__name { font-size: 1.6rem; letter-spacing: -0.01em; }
.profile-card__role { margin: 0.25rem 0 0; font-weight: 500; }
.profile-card__affiliation { margin: 0; font-size: 0.9rem; }
.profile-card__affiliation a { color: var(--muted); }

.social-links {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  list-style: none;
  margin: 1rem 0 0;
  padding: 1rem 0 0;
  border-top: 1px solid var(--border);
}
.social-links a {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--border);
  color: var(--muted);
  transition: border-color 0.15s ease, transform 0.15s ease;
}
.social-links a:hover { border-color: var(--accent); color: var(--accent); transform: translateY(-2px); }
.social-links .icon { width: 18px; height: 18px; }
.profile-card__email { display: inline-block; margin-top: 0.6rem; font-size: 0.85rem; color: var(--muted); }
.profile-card .button--block { margin-top: 1rem; }

/* Brand logos: in dark mode, sit on a light tile so dark logos stay visible. */
.logo { width: 20px; height: 20px; object-fit: contain; }
[data-theme="dark"] .logo { background: #f3f3f1; border-radius: 4px; padding: 2px; }

/* Language and theme toggles (top right) */
.top-actions {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 50;
  display: flex;
  gap: 0.5rem;
}
.top-action {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--shadow);
}
.top-action:hover { color: var(--accent); text-decoration: none; }
.theme-toggle .icon { width: 18px; height: 18px; }
.theme-toggle__moon { display: none; }
[data-theme="dark"] .theme-toggle__sun { display: none; }
[data-theme="dark"] .theme-toggle__moon { display: inline; }

/* 5. Section navigation --------------------------------------------------- */
.section-nav {
  position: sticky;
  top: 0;
  z-index: 10;
  margin: 0 0 1rem;
  padding: 0.75rem 0;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.section-nav ul { display: flex; flex-wrap: wrap; gap: 0.25rem; list-style: none; margin: 0; padding: 0 6.5rem 0 0; }
.section-nav a {
  display: block;
  padding: 0.3rem 0.75rem;
  border-radius: 999px;
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--muted);
}
.section-nav a:hover { color: var(--text); background: var(--surface-2); text-decoration: none; }
.section-nav a.is-active { color: var(--accent); background: var(--accent-soft); }

/* 6. Sections ------------------------------------------------------------- */
.section { padding: 1.5rem 0 2.25rem; }
.section + .section { border-top: 1px solid var(--border); }
.section-header { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1.25rem; }
.section-header .section-title { margin: 0; }
.section-title { font-size: 1.6rem; margin-bottom: 1.25rem; letter-spacing: -0.01em; }
.subsection-title {
  font-family: var(--font-sans);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 1rem;
}

.prose p { margin: 0 0 1rem; }
.prose p:last-child { margin-bottom: 0; }

/* Research */
.research-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1rem; }
.research-card {
  padding: 1.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  border-top: 3px solid var(--accent);
}
.research-card__title { font-size: 1.12rem; margin-bottom: 0.5rem; }
.research-card__text { margin: 0; font-size: 0.93rem; color: var(--muted); }

/* Experience timeline */
.timeline-columns { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 2rem; }
.timeline { list-style: none; margin: 0; padding: 0 0 0 1.25rem; border-left: 2px solid var(--border); }
.timeline__item { position: relative; display: flex; flex-direction: column; padding-bottom: 1.25rem; }
.timeline__item:last-child { padding-bottom: 0; }
.timeline__item::before {
  content: "";
  position: absolute;
  left: calc(-1.25rem - 6px);
  top: 0.45rem;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--surface);
  border: 2px solid var(--accent);
}
.timeline__period { font-family: var(--font-mono); font-size: 0.78rem; color: var(--muted); }
.timeline__title { font-weight: 600; }
.timeline__org { font-size: 0.93rem; }
.timeline__desc { font-size: 0.88rem; color: var(--muted); margin-top: 0.15rem; }

/* Awards / teaching */
.plain-list { list-style: none; margin: 0; padding: 0; }
.plain-list__item { display: grid; grid-template-columns: 4rem 1fr; gap: 1rem; padding: 0.5rem 0; }
.plain-list__meta { font-family: var(--font-mono); font-size: 0.82rem; color: var(--muted); padding-top: 0.15rem; }
.plain-list__icon { color: var(--thesis); margin-right: 0.25rem; }
.plain-list strong { font-weight: 600; }

/* Skills */
.skills { display: grid; grid-template-columns: 11rem 1fr; gap: 0.75rem 1.25rem; margin: 0; }
.skills dt { font-weight: 600; font-size: 0.92rem; padding-top: 0.2rem; }
.skills dd { margin: 0; }
.skill-list { display: flex; flex-wrap: wrap; gap: 0.4rem; list-style: none; margin: 0; padding: 0; }
.skill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.25rem 0.65rem 0.25rem 0.4rem;
  font-size: 0.82rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
}

.footer { padding: 2rem 0 3rem; border-top: 1px solid var(--border); font-size: 0.85rem; color: var(--muted); }
.footer p { margin: 0; }

/* 7. Components ----------------------------------------------------------- */
.tag-list { display: flex; flex-wrap: wrap; gap: 0.35rem; list-style: none; margin: 0; padding: 0; }
.tag-list--center { justify-content: center; margin-top: 1rem; }
.tag {
  padding: 0.15rem 0.6rem;
  font-size: 0.78rem;
  font-weight: 500;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.5rem 1rem;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  line-height: 1.2;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease, background-color 0.15s ease;
}
.button:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }
.button[aria-expanded="true"] { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.button--small { padding: 0.3rem 0.65rem; font-size: 0.8rem; }
.button--small .icon { width: 14px; height: 14px; }
.button--primary { background: var(--accent); border-color: var(--accent); color: #fff; }
[data-theme="dark"] .button--primary { color: #0d1113; }
.button--primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: #fff; }
.button--block { width: 100%; }

.badge {
  display: inline-block;
  padding: 0.1rem 0.55rem;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  border-radius: 999px;
  color: var(--badge-color);
  background: color-mix(in srgb, var(--badge-color) 12%, transparent);
}
.badge--journal { --badge-color: var(--journal); }
.badge--conference { --badge-color: var(--conference); }
.badge--thesis { --badge-color: var(--thesis); }

/* 8. Publications --------------------------------------------------------- */
.filter { display: inline-flex; padding: 3px; gap: 2px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; }
.filter__btn {
  padding: 0.3rem 0.8rem;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 999px;
  cursor: pointer;
}
.filter__btn:hover { color: var(--text); }
.filter__btn.is-active { background: var(--surface); color: var(--accent); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1); }

.pub-year { position: relative; padding-left: 4.5rem; }
.pub-year + .pub-year { margin-top: 0.5rem; }
.pub-year__label {
  position: absolute;
  left: 0;
  top: 1rem;
  font-family: var(--font-mono);
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--muted);
}
.pub-year[hidden], .pub[hidden] { display: none; }

.pub {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr);
  gap: 1.25rem;
  padding: 1rem;
  margin: 0 -1rem;
  border-radius: var(--radius);
  transition: background-color 0.15s ease;
}
.pub:hover { background: var(--surface); box-shadow: var(--shadow); }
.pub:target { background: var(--accent-soft); }

.pub__thumb {
  align-self: start;
  display: block;
  aspect-ratio: 1;
  padding: 6px;
  background: var(--thumb-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.pub__thumb img { width: 100%; height: 100%; object-fit: contain; transition: transform 0.3s ease; }
.pub:hover .pub__thumb img { transform: scale(1.06); }

.pub__title { font-family: var(--font-sans); font-size: 1rem; font-weight: 600; line-height: 1.4; margin: 0.4rem 0 0.25rem; }
.pub__title a { color: var(--text); }
.pub__title a:hover { color: var(--accent); }
.pub__authors { margin: 0; font-size: 0.88rem; color: var(--muted); }
.pub__authors strong { color: var(--text); font-weight: 600; }
.pub__venue { margin: 0.1rem 0 0; font-size: 0.88rem; font-style: italic; color: var(--muted); }
.pub__actions { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.7rem; }

.bibtex { position: relative; margin-top: 0.75rem; }
.bibtex pre {
  margin: 0;
  padding: 1rem;
  max-height: 260px;
  overflow: auto;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  line-height: 1.55;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.bibtex__copy {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.55rem;
  font: inherit;
  font-size: 0.75rem;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
}
.bibtex__copy span { display: inline-flex; align-items: center; gap: 0.3rem; }
.bibtex__copy span[hidden] { display: none; }
.bibtex__copy:hover { color: var(--accent); border-color: var(--accent); }
.bibtex__copy .icon { width: 13px; height: 13px; }

/* 9. Utilities / responsive ----------------------------------------------- */
.muted { color: var(--muted); }

@media (max-width: 960px) {
  .layout { grid-template-columns: 1fr; gap: 1.5rem; padding: 1rem 1rem 0; }
  .profile-card { position: static; max-height: none; max-width: 560px; margin: 0 auto; }
}

@media (max-width: 600px) {
  .pub-year { padding-left: 0; }
  .pub-year__label { position: static; padding: 1rem 0 0; }
  .pub { grid-template-columns: 76px minmax(0, 1fr); gap: 0.9rem; margin: 0 -0.5rem; padding: 0.75rem 0.5rem; }
  .skills { grid-template-columns: 1fr; gap: 0.25rem; }
  .skills dd { margin-bottom: 0.75rem; }
  .section-nav { margin-left: -1rem; margin-right: -1rem; padding-left: 1rem; padding-right: 1rem; }
  .section-nav ul { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding-right: 0; }
  .top-actions { top: auto; bottom: 1rem; }
  .filter { display: flex; width: 100%; }
  .filter__btn { flex: 1; padding: 0.3rem 0.25rem; }
}

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

@media print {
  .top-actions, .section-nav, .route-graph, .pub__actions, .filter, .bibtex { display: none !important; }
  .layout { display: block; }
  .profile-card { position: static; box-shadow: none; }
}
