/* ==========================================================
   Site stylesheet — Javier González Anaya
   ----------------------------------------------------------
   To change colors, edit the variables in the two blocks
   below (light mode first, dark mode second). Everything
   else on the site reads from these.
   ========================================================== */

:root {
  --bg:        #ffffff;
  --text:      #1f2328;
  --muted:     #656d76;
  --rule:      #e4e6ea;
  --accent:    #8a1f84;   /* links, active tab, name */
  --accent-bg: #f6eef6;   /* link pills */
  --card:      #fafafb;
}

[data-theme="dark"] {
  --bg:        #16171b;
  --text:      #e6e6e9;
  --muted:     #9a9ca5;
  --rule:      #2c2e35;
  --accent:    #e08ad9;
  --accent-bg: #2e2230;
  --card:      #1c1d22;
}

/* ---------- Base ---------- */

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

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

/* keeps section titles from hiding under the sticky header */
section { scroll-margin-top: 80px; }
section + section { margin-top: 3.5rem; }

.section-title {
  font-size: 1.6rem;
  margin: 0 0 .5rem;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
               "Helvetica Neue", Arial, sans-serif;
  font-size: 17px;
  line-height: 1.65;
  transition: background-color .2s ease, color .2s ease;
}

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

h1, h2, h3 { line-height: 1.25; font-weight: 600; }
h3 { font-size: 1.1rem; margin: 2rem 0 .4rem; }

.container {
  max-width: 1020px;
  margin: 0 auto;
  padding: 0 1.25rem;
}

/* ---------- Header / tabs ---------- */

.site-header {
  border-bottom: 1px solid var(--rule);
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 10;
}

.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 60px;
  flex-wrap: wrap;
}

.site-title {
  font-weight: 600;
  color: var(--text);
  font-size: 1.05rem;
}
.site-title:hover { text-decoration: none; color: var(--accent); }

.site-nav {
  display: flex;
  align-items: center;
  gap: 1.3rem;
  flex-wrap: wrap;
}
.site-nav .lang-toggle + .theme-toggle { margin-left: -.8rem; }  /* keep the two buttons close together */

.site-nav a {
  color: var(--text);
  font-size: .95rem;
  padding: .2rem 0;
  border-bottom: 2px solid transparent;
}
.site-nav a:hover { color: var(--accent); text-decoration: none; }
.site-nav a[aria-current] {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.theme-toggle {
  background: none;
  border: 1px solid var(--rule);
  border-radius: 999px;
  color: var(--text);
  cursor: pointer;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  padding: 0;
}
.theme-toggle:hover { border-color: var(--accent); color: var(--accent); }
.theme-toggle svg { width: 17px; height: 17px; }
.theme-toggle .icon-sun  { display: none; }
[data-theme="dark"] .theme-toggle .icon-sun  { display: block; }
[data-theme="dark"] .theme-toggle .icon-moon { display: none; }

/* ---------- EN/ES link (looks like the dark-mode button) ---------- */
.site-nav a.lang-toggle {
  display: inline-grid;
  place-items: center;
  box-sizing: border-box;
  border: 1px solid var(--rule);
  border-radius: 999px;
  color: var(--text);
  cursor: pointer;
  height: 34px;
  min-width: 34px;
  padding: 0 .55rem;
  font: inherit;
  font-size: .75rem;
  font-weight: 700;
  letter-spacing: .04em;
  text-decoration: none;
}
.site-nav a.lang-toggle:hover { border-color: var(--accent); color: var(--accent); }

/* ---------- Page body ---------- */

main.container { padding-top: 2.5rem; padding-bottom: 3rem; }

.page-title {
  font-size: 2.1rem;
  margin: 0 0 1.6rem;
}
.page-title .first { font-weight: 300; }

.page-subtitle {
  color: var(--muted);
  margin: -1.3rem 0 2rem;
  font-size: .97rem;
}

/* ---------- About page ---------- */

.profile {
  float: right;
  width: 230px;
  margin: 0 0 1.2rem 2rem;
  text-align: center;
  font-size: .9rem;
  color: var(--muted);
}
.profile img {
  width: 100%;
  border-radius: 6px;
  display: block;
  margin-bottom: .7rem;
}
.profile p { margin: .1rem 0; }

/* if the intro text is shorter than the photo box, push the next
   section below the photo instead of letting it run underneath */
#about { display: flow-root; }
#about > :last-child { margin-bottom: 0; }   /* keeps the spacing before the next section the same */

@media (max-width: 620px) {
  .profile { float: none; margin: 0 auto 1.5rem; width: 180px; }
}

/* ---------- Publications ---------- */

.pub-section {
  font-size: .8rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
  font-weight: 600;
  border-bottom: 1px solid var(--rule);
  padding-bottom: .4rem;
  margin: 1.6rem 0 .2rem;
}

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

.pub {
  display: grid;
  grid-template-columns: 4.2rem 1fr;   /* left: link buttons, right: paper */
  gap: 0 .9rem;
  align-items: start;
  padding: .5rem 0;
  border-bottom: 1px solid var(--rule);
  line-height: 1.4;
}
.pub:last-child { border-bottom: none; }

.pub-title { font-weight: 600; }
.pub-meta  { color: var(--muted); font-size: .93rem; }
.pub-meta em { color: var(--text); font-style: italic; }

.pub-links {
  display: flex;
  flex-direction: column;
  gap: .2rem;
  padding-top: .15rem;
}
.pub-links a {
  display: block;
  text-align: center;
  font-size: .72rem;
  font-weight: 600;
  padding: 0 .3rem;
  border-radius: 4px;
  background: var(--accent-bg);
  line-height: 1.55;
}
.pub-links a:hover { text-decoration: none; filter: brightness(.95); }

.note { color: var(--muted); font-size: .88rem; margin-top: 1.5rem; }

/* ---------- Footer ---------- */

.site-footer {
  border-top: 1px solid var(--rule);
  color: var(--muted);
  font-size: .83rem;
  padding: 1.2rem 0 2rem;
}

/* ---------- Phones ----------
   One-row header: the name is hidden there because it's the big title right below.
   Everything else is slightly tighter so the menu and both buttons fit on one line. */
@media (max-width: 620px) {
  body { font-size: 16px; }
  .container { padding: 0 1rem; }
  .site-title { display: none; }
  .site-header .container { min-height: 52px; flex-wrap: nowrap; justify-content: flex-end; }
  .site-nav { gap: .9rem; flex-wrap: nowrap; white-space: nowrap; }
  .site-nav a { font-size: .9rem; }
  .site-nav .lang-toggle + .theme-toggle { margin-left: -.5rem; }
  .theme-toggle, .site-nav a.lang-toggle { height: 32px; min-width: 32px; }
  .theme-toggle { width: 32px; }
  main.container { padding-top: 1.6rem; }
  section { scroll-margin-top: 64px; }
  .page-title { font-size: 1.8rem; }
  .pub { grid-template-columns: 3.7rem 1fr; gap: 0 .7rem; }
  .page-subtitle .nowrap { display: none; }   /* "| CV" — the menu already has cv */
}
.nowrap { white-space: nowrap; }
