/* ==========================================================================
   Alei Fernandes Santos — personal academic site
   Design tokens
   ========================================================================== */

:root {
  /* Type */
  --font-serif: "Newsreader", Georgia, "Times New Roman", serif;
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;

  /* Scale */
  --step--1: clamp(0.83rem, 0.81rem + 0.10vw, 0.89rem);
  --step-0: clamp(1rem, 0.96rem + 0.18vw, 1.09rem);
  --step-1: clamp(1.20rem, 1.13rem + 0.34vw, 1.40rem);
  --step-2: clamp(1.44rem, 1.32rem + 0.60vw, 1.80rem);
  --step-3: clamp(1.73rem, 1.53rem + 0.98vw, 2.31rem);
  --step-4: clamp(2.07rem, 1.76rem + 1.55vw, 2.97rem);

  /* Space */
  --sp-1: 0.25rem;
  --sp-2: 0.5rem;
  --sp-3: 0.75rem;
  --sp-4: 1rem;
  --sp-5: 1.5rem;
  --sp-6: 2rem;
  --sp-7: 3rem;
  --sp-8: 4.5rem;

  --radius: 10px;
  --radius-lg: 16px;
  --measure: 68ch;
  --header-h: 64px;

  /* Light theme */
  --bg: #fdfdfc;
  --bg-elev: #ffffff;
  --surface: #f4f5f4;
  --text: #14181b;
  --text-muted: #5a656e;
  --text-faint: #7d8790;
  --border: #e2e5e6;
  --border-strong: #cdd2d4;
  --accent: #0e5c60;
  --accent-hover: #0a4548;
  --accent-soft: #e4f0f0;
  --shadow-sm: 0 1px 2px rgba(20, 24, 27, 0.05);
  --shadow-md: 0 4px 16px -4px rgba(20, 24, 27, 0.10);
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #0f1316;
  --bg-elev: #151a1e;
  --surface: #1a2126;
  --text: #e7ecef;
  --text-muted: #a0aab2;
  --text-faint: #7f8a92;
  --border: #262f35;
  --border-strong: #3a454c;
  --accent: #6fc9cb;
  --accent-hover: #93dcdd;
  --accent-soft: #16302f;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 20px -4px rgba(0, 0, 0, 0.55);
  color-scheme: dark;
}

/* ==========================================================================
   Base
   ========================================================================== */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-h) + 1rem);
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: var(--step-0);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1,
h2,
h3,
h4 {
  font-family: var(--font-serif);
  font-weight: 500;
  line-height: 1.2;
  letter-spacing: -0.015em;
  margin: 0 0 var(--sp-3);
  color: var(--text);
}

h1 { font-size: var(--step-4); }
h2 { font-size: var(--step-2); }
h3 { font-size: var(--step-1); }
h4 { font-size: var(--step-0); font-family: var(--font-sans); font-weight: 600; }

p { margin: 0 0 var(--sp-4); }

a {
  color: var(--accent);
  text-decoration: none;
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
  transition: color 0.15s ease;
}

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

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

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

hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: var(--sp-6) 0;
}

ul, ol { margin: 0 0 var(--sp-4); padding-left: 1.25rem; }
li { margin-bottom: var(--sp-2); }
li::marker { color: var(--text-faint); }

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 200;
  background: var(--accent);
  color: #fff;
  padding: var(--sp-2) var(--sp-4);
  border-radius: 0 0 var(--radius) 0;
}
.skip-link:focus { left: 0; }

/* ==========================================================================
   Layout
   ========================================================================== */

.wrap {
  width: min(100% - 2.5rem, 1080px);
  margin-inline: auto;
}

.page {
  padding: var(--sp-7) 0 var(--sp-8);
}

.page-narrow {
  width: min(100%, 760px);
}

.page-head {
  margin-bottom: var(--sp-6);
  padding-bottom: var(--sp-5);
  border-bottom: 1px solid var(--border);
}

.page-head h1 { margin-bottom: var(--sp-2); }

.page-head .lede {
  color: var(--text-muted);
  font-size: var(--step-0);
  max-width: var(--measure);
  margin: 0;
}

/* ==========================================================================
   Header / navigation
   ========================================================================== */

.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
}

.site-header .wrap {
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-4);
}

.brand {
  font-family: var(--font-serif);
  font-size: 1.15rem;
  font-weight: 500;
  letter-spacing: -0.01em;
  color: var(--text);
  white-space: nowrap;
}
.brand:hover { color: var(--accent); text-decoration: none; }

.nav-tools {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}

.site-nav ul {
  display: flex;
  align-items: center;
  gap: var(--sp-1);
  list-style: none;
  margin: 0;
  padding: 0;
}

.site-nav li { margin: 0; }

.site-nav a {
  display: block;
  padding: 0.4rem 0.7rem;
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: var(--step--1);
  font-weight: 500;
  letter-spacing: 0.01em;
}

.site-nav a:hover {
  color: var(--text);
  background: var(--surface);
  text-decoration: none;
}

.site-nav a[aria-current="page"] {
  color: var(--accent);
  background: var(--accent-soft);
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.icon-btn:hover {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border-strong);
}

.icon-btn svg { width: 17px; height: 17px; }

.theme-toggle .icon-moon { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: block; }

.nav-toggle { display: none; }

@media (max-width: 720px) {
  .nav-toggle { display: inline-flex; }

  .site-nav {
    position: absolute;
    top: var(--header-h);
    left: 0;
    right: 0;
    background: var(--bg-elev);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-md);
    display: none;
  }

  .site-nav.is-open { display: block; }

  .site-nav ul {
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    padding: var(--sp-2) max(1.25rem, calc((100vw - 1080px) / 2));
  }

  .site-nav a {
    padding: 0.65rem 0.7rem;
    font-size: var(--step-0);
  }
}

/* ==========================================================================
   Home — profile sidebar + intro
   ========================================================================== */

.home-grid {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: var(--sp-7);
  align-items: start;
  padding: var(--sp-7) 0 var(--sp-8);
}

@media (max-width: 860px) {
  .home-grid {
    grid-template-columns: 1fr;
    gap: var(--sp-6);
  }
}

.profile {
  position: sticky;
  top: calc(var(--header-h) + var(--sp-5));
  text-align: left;
}

@media (max-width: 860px) {
  .profile { position: static; }
}

.profile-photo {
  width: 100%;
  max-width: 220px;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  object-position: center;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
  margin-bottom: var(--sp-4);
}

.profile-name {
  font-family: var(--font-serif);
  font-size: var(--step-1);
  font-weight: 500;
  margin: 0 0 var(--sp-1);
  line-height: 1.25;
}

.profile-role {
  font-size: var(--step--1);
  color: var(--text-muted);
  margin: 0 0 var(--sp-4);
  line-height: 1.5;
}

.profile-meta {
  list-style: none;
  margin: 0 0 var(--sp-4);
  padding: 0;
  font-size: var(--step--1);
  color: var(--text-muted);
}

.profile-meta li {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-2);
  margin-bottom: var(--sp-2);
}

.profile-meta svg {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
  margin-top: 0.28em;
  color: var(--text-faint);
}

.social-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
}

.social-row a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  transition: all 0.15s ease;
}

.social-row a:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-soft);
  text-decoration: none;
}

.social-row svg { width: 17px; height: 17px; }

.intro h1 {
  margin-bottom: var(--sp-4);
}

.intro .tagline {
  font-size: var(--step-1);
  color: var(--text-muted);
  font-family: var(--font-serif);
  line-height: 1.45;
  margin-bottom: var(--sp-5);
  max-width: var(--measure);
}

.intro p { max-width: var(--measure); }

.intro-body {
  font-size: 1.02em;
}

.pill-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  margin: var(--sp-5) 0 0;
  padding: 0;
  list-style: none;
}

.pill {
  display: inline-block;
  padding: 0.28rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-muted);
  font-size: var(--step--1);
  margin: 0;
}

/* ==========================================================================
   Sections
   ========================================================================== */

.section {
  margin-top: var(--sp-7);
  padding-top: var(--sp-6);
  border-top: 1px solid var(--border);
}

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--sp-4);
  margin-bottom: var(--sp-5);
}

.section-head h2 { margin: 0; }

.section-head a {
  font-size: var(--step--1);
  font-weight: 500;
  white-space: nowrap;
}

.subsection {
  margin-top: var(--sp-6);
}

.subsection > h2 {
  font-size: var(--step-1);
  padding-bottom: var(--sp-2);
  border-bottom: 1px solid var(--border);
  margin-bottom: var(--sp-4);
}

/* ==========================================================================
   Publication / talk items
   ========================================================================== */

.pub-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.pub {
  padding: var(--sp-4) 0;
  border-bottom: 1px solid var(--border);
  margin: 0;
}

.pub:first-child { padding-top: 0; }
.pub:last-child { border-bottom: 0; }

.pub-title {
  font-family: var(--font-serif);
  font-size: var(--step-1);
  font-weight: 500;
  line-height: 1.3;
  margin: 0 0 var(--sp-2);
}

.pub-authors {
  font-size: var(--step--1);
  color: var(--text-muted);
  margin: 0 0 var(--sp-2);
}

.pub-authors .self { color: var(--text); font-weight: 500; }

.pub-venue {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-2) var(--sp-3);
  font-size: var(--step--1);
  margin: 0;
}

.venue-name {
  font-style: italic;
  color: var(--text);
}

.venue-year {
  color: var(--text-faint);
}

.tag {
  display: inline-block;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid color-mix(in srgb, var(--accent) 25%, transparent);
}

.pub-links {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-3);
  margin-top: var(--sp-3);
  font-size: var(--step--1);
}

.link-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.28rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  font-weight: 500;
  transition: all 0.15s ease;
}

.link-btn:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-soft);
  text-decoration: none;
}

.link-btn svg { width: 14px; height: 14px; }

.pub-note {
  font-size: var(--step--1);
  color: var(--text-muted);
  margin: var(--sp-3) 0 0;
}

/* Press coverage of a paper, listed inside the paper's own entry. */
.pub-media {
  margin-top: var(--sp-3);
  font-size: var(--step--1);
}

.pub-media-label {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin: 0 0 var(--sp-2);
}

.pub-media ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.pub-media li {
  margin: 0;
  padding-left: var(--sp-3);
  border-left: 2px solid var(--border);
  line-height: 1.5;
}

.pub-media li + li { margin-top: var(--sp-2); }

.pub-media-outlet {
  display: block;
  color: var(--text-faint);
}

details.abstract {
  margin-top: var(--sp-3);
  font-size: var(--step--1);
}

details.abstract > summary {
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: var(--text-muted);
  font-weight: 500;
  list-style: none;
  user-select: none;
  width: fit-content;
}

details.abstract > summary::-webkit-details-marker { display: none; }

details.abstract > summary::before {
  content: "";
  width: 0;
  height: 0;
  border-left: 5px solid currentColor;
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
  transition: transform 0.18s ease;
}

details.abstract[open] > summary::before { transform: rotate(90deg); }

details.abstract > summary:hover { color: var(--accent); }

.abstract-body {
  margin-top: var(--sp-3);
  padding: var(--sp-4);
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  color: var(--text-muted);
  line-height: 1.7;
}

.abstract-body p:last-child { margin-bottom: 0; }

/* Talks */

.talk {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  gap: var(--sp-4);
  padding: var(--sp-4) 0;
  border-bottom: 1px solid var(--border);
  margin: 0;
}

.talk:first-child { padding-top: 0; }
.talk:last-child { border-bottom: 0; }

@media (max-width: 560px) {
  .talk { grid-template-columns: 1fr; gap: var(--sp-2); }
}

.talk-date {
  font-size: var(--step--1);
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
  padding-top: 0.15em;
}

.talk-title {
  font-family: var(--font-serif);
  font-size: var(--step-0);
  font-weight: 500;
  line-height: 1.35;
  margin: 0 0 var(--sp-1);
}

.talk-meta {
  font-size: var(--step--1);
  color: var(--text-muted);
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
}

.role {
  display: inline-block;
  padding: 0.05rem 0.45rem;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.dot::before { content: "·"; margin-right: 0.35rem; color: var(--text-faint); }

/* ==========================================================================
   CV
   ========================================================================== */

.cv-section { margin-bottom: var(--sp-6); }

.cv-section > h2 {
  font-size: var(--step-1);
  padding-bottom: var(--sp-2);
  border-bottom: 1px solid var(--border);
  margin-bottom: var(--sp-4);
}

.entry {
  display: grid;
  grid-template-columns: 160px minmax(0, 1fr);
  gap: var(--sp-4);
  padding: var(--sp-3) 0;
  margin: 0;
}

@media (max-width: 620px) {
  .entry { grid-template-columns: 1fr; gap: var(--sp-1); }
}

.entry-date {
  font-size: var(--step--1);
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
  padding-top: 0.15em;
}

.entry-title {
  font-weight: 600;
  margin: 0 0 var(--sp-1);
  line-height: 1.4;
}

.entry-sub {
  font-size: var(--step--1);
  color: var(--text-muted);
  margin: 0;
}

.entry-sub ul {
  margin: var(--sp-1) 0 0;
  padding-left: 1.1rem;
}

.entry-sub li { margin-bottom: var(--sp-1); }

.course-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.course-list li {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.5rem;
  padding: var(--sp-2) 0;
  border-bottom: 1px dashed var(--border);
  margin: 0;
}

.course-list li:last-child { border-bottom: 0; }

.course-name { font-weight: 500; }

.course-note {
  font-size: var(--step--1);
  color: var(--text-muted);
}

.course-years {
  margin-left: auto;
  font-size: var(--step--1);
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
}

@media (max-width: 560px) {
  .course-years { margin-left: 0; }
}

.callout {
  padding: var(--sp-4) var(--sp-5);
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  margin: var(--sp-5) 0;
}

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

/* ==========================================================================
   Contact
   ========================================================================== */

.contact-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: var(--sp-4);
  margin-top: var(--sp-5);
}

.contact-card {
  padding: var(--sp-5);
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.contact-card h3 {
  font-size: var(--step-0);
  font-family: var(--font-sans);
  font-weight: 600;
  margin-bottom: var(--sp-2);
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}

.contact-card h3 svg {
  width: 16px;
  height: 16px;
  color: var(--accent);
}

.contact-card p {
  margin: 0;
  font-size: var(--step--1);
  color: var(--text-muted);
  word-break: break-word;
}

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

/* ==========================================================================
   Footer
   ========================================================================== */

.site-footer {
  border-top: 1px solid var(--border);
  padding: var(--sp-6) 0;
  margin-top: var(--sp-7);
  font-size: var(--step--1);
  color: var(--text-faint);
}

.site-footer .wrap {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-4);
}

.footer-links {
  display: flex;
  gap: var(--sp-4);
  list-style: none;
  margin: 0;
  padding: 0;
}

.footer-links li { margin: 0; }

.footer-links a { color: var(--text-muted); }

/* ==========================================================================
   404
   ========================================================================== */

.notfound {
  text-align: center;
  padding: var(--sp-8) 0;
}

.notfound .code {
  font-family: var(--font-serif);
  font-size: clamp(4rem, 14vw, 8rem);
  line-height: 1;
  color: var(--border-strong);
  margin: 0 0 var(--sp-4);
}

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

@media print {
  .site-header, .site-footer, .social-row, .nav-tools { display: none; }
  body { background: #fff; color: #000; }
  details.abstract[open] .abstract-body { border: 0; background: none; }
}
