/* ---------------------------------------------------------------
   davidgarcia.eu — v2
   Cardo (display) + Inter (text), self-hosted. No dependencies.
   --------------------------------------------------------------- */

@font-face {
  font-family: 'Cardo';
  src: url('assets/fonts/cardo-400.woff2') format('woff2');
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Cardo';
  src: url('assets/fonts/cardo-400-italic.woff2') format('woff2');
  font-weight: 400; font-style: italic; font-display: swap;
}
@font-face {
  font-family: 'Cardo';
  src: url('assets/fonts/cardo-700.woff2') format('woff2');
  font-weight: 700; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Inter';
  src: url('assets/fonts/inter-variable.woff2') format('woff2');
  font-weight: 100 900; font-style: normal; font-display: swap;
}

:root {
  --paper: #f5f4f0;
  --ink: #18150f;
  --ink-2: #201c15;
  --muted: #6e6960;
  --faint: #97918a;
  --accent: #14695e;
  --accent-bright: #0d8573;
  --paper-dim: rgba(246, 242, 234, 0.62);
  --rule: rgba(24, 21, 15, 0.16);
  --rule-soft: rgba(24, 21, 15, 0.08);
  --rule-dark: rgba(246, 242, 234, 0.14);
  --serif: 'Cardo', Georgia, 'Times New Roman', serif;
  --sans: 'Inter', -apple-system, 'Segoe UI', Helvetica, Arial, sans-serif;
  --gutter: clamp(1.25rem, 4vw, 3rem);
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 1.0625rem;
  line-height: 1.65;
  font-feature-settings: 'kern', 'liga';
  -webkit-font-smoothing: antialiased;
}

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

a {
  color: inherit;
  text-decoration: underline;
  text-decoration-color: var(--rule);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
  transition: text-decoration-color 0.2s ease, color 0.2s ease;
}
a:hover { color: var(--accent); text-decoration-color: var(--accent); }

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

.wrap { max-width: 76rem; margin: 0 auto; padding: 0 var(--gutter); }

/* ----- scroll progress + cursor ring -------------------------- */

#progress {
  position: fixed; top: 0; left: 0; right: 0; height: 2px;
  background: var(--accent-bright);
  transform: scaleX(0); transform-origin: 0 50%;
  z-index: 60; pointer-events: none;
}

.cursor-ring {
  position: fixed; top: 0; left: 0;
  width: 30px; height: 30px;
  border: 1px solid var(--accent-bright);
  border-radius: 50%;
  opacity: 0;
  pointer-events: none;
  z-index: 70;
  transition: width 0.25s ease, height 0.25s ease, opacity 0.3s ease,
              background-color 0.25s ease;
}
.cursor-ring.visible { opacity: 0.55; }
.cursor-ring.on { width: 52px; height: 52px; background: rgba(20, 105, 94, 0.07); opacity: 0.9; }

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

.site-header {
  position: fixed; top: 0; left: 0; right: 0; z-index: 50;
  color: var(--ink);
  transition: background-color 0.35s ease, color 0.35s ease, box-shadow 0.35s ease;
}
.site-header .wrap {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 1.5rem; flex-wrap: wrap;
  padding-top: 1.3rem; padding-bottom: 1.1rem;
}
.site-header.solid {
  background: rgba(250, 248, 244, 0.88);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  color: var(--ink);
  box-shadow: 0 1px 0 var(--rule-soft);
}

.wordmark {
  font-family: var(--serif);
  font-size: 1.3rem;
  text-decoration: none;
  white-space: nowrap;
  color: inherit;
}
.wordmark:hover { color: inherit; text-decoration: none; opacity: 0.8; }

.site-nav { display: flex; align-items: baseline; gap: 1.7rem; }
.site-nav a {
  font-size: 0.8rem; font-weight: 480;
  letter-spacing: 0.15em; text-transform: uppercase;
  text-decoration: none;
  color: inherit; opacity: 0.7;
  padding-bottom: 0.2rem;
  border-bottom: 1px solid transparent;
  transition: opacity 0.2s ease, border-color 0.2s ease;
}
.site-nav a:hover { opacity: 1; border-bottom-color: currentColor; color: inherit; }
.site-nav a[aria-current='page'] { opacity: 1; border-bottom-color: var(--accent-bright); }

.lang-switch {
  font: inherit; font-size: 0.8rem; letter-spacing: 0.1em;
  background: none; border: none; padding: 0 0 0.2rem;
  cursor: pointer; color: inherit; opacity: 0.55;
  transition: opacity 0.2s ease;
}
.lang-switch:hover { opacity: 1; }
.lang-switch .active { font-weight: 650; opacity: 1; }

/* ----- hero ----------------------------------------------------- */

.hero {
  position: relative;
  min-height: 100svh;
  display: flex; align-items: center;
  background: var(--paper);
  color: var(--ink);
  overflow: hidden;
}
.hero canvas {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  display: block;
}
.hero-inner { position: relative; z-index: 2; width: 100%; pointer-events: none; }
.hero-inner a, .hero-inner .btn { pointer-events: auto; }

.hero .kicker { color: var(--accent); }
.hero-title {
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(2.9rem, 8vw, 6rem);
  line-height: 1.05;
  letter-spacing: -0.015em;
  margin: 0 0 1.6rem;
  max-width: 14ch;
}
.hero-sub {
  font-size: clamp(1.05rem, 1.6vw, 1.25rem);
  line-height: 1.6;
  color: var(--muted);
  max-width: 44ch;
  margin: 0;
}

.scroll-cue {
  position: absolute; bottom: 2.2rem; left: 50%;
  width: 1px; height: 56px;
  background: var(--rule);
  overflow: hidden;
  z-index: 2;
}
.scroll-cue::after {
  content: '';
  position: absolute; top: -50%; left: 0;
  width: 1px; height: 50%;
  background: var(--accent-bright);
  animation: cue 2.2s cubic-bezier(0.65, 0, 0.35, 1) infinite;
}
@keyframes cue { 0% { top: -50%; } 70%, 100% { top: 110%; } }

/* compact hero for inner pages */
.hero--compact {
  min-height: clamp(330px, 46svh, 460px);
  align-items: flex-end;
  padding-bottom: clamp(2rem, 5vh, 3.5rem);
}
.hero--compact .page-title { margin: 0; }

.kicker {
  font-size: 0.8rem; font-weight: 520;
  letter-spacing: 0.24em; text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 1.2rem;
}

.page-title {
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(2.4rem, 6vw, 4rem);
  line-height: 1.1;
  margin: 0;
}

/* ----- shared section bits -------------------------------------- */

main { padding: clamp(3.5rem, 8vw, 6rem) 0 clamp(3rem, 6vw, 4.5rem); }

.section-label {
  font-size: 0.8rem; font-weight: 520;
  letter-spacing: 0.24em; text-transform: uppercase;
  color: var(--muted);
  margin: 0; padding-bottom: 0.9rem;
  border-bottom: 1px solid var(--rule);
}

section + section { margin-top: clamp(3.5rem, 8vw, 6rem); }

/* reveal */
[data-reveal] {
  opacity: 0;
  transform: translateY(18px);
  transition: opacity 0.7s cubic-bezier(0.22, 1, 0.36, 1),
              transform 0.7s cubic-bezier(0.22, 1, 0.36, 1);
}
[data-reveal].in { opacity: 1; transform: none; }

/* ----- bio (home) ------------------------------------------------ */

.intro {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(190px, 250px);
  gap: clamp(2rem, 6vw, 5rem);
  align-items: start;
}
.intro .bio { max-width: 62ch; font-size: 1.1rem; }
.intro .bio p { margin: 0 0 1.15em; }
.intro .bio a { color: var(--accent); text-decoration-color: rgba(20, 105, 94, 0.35); }
.intro .bio a:hover { text-decoration-color: var(--accent); }

.portrait {
  margin: 0.4rem 0 0;
  transition: transform 0.3s ease;
  will-change: transform;
}
.portrait img {
  width: 100%;
  border-radius: 3px;
  filter: saturate(0.92);
  box-shadow: 0 18px 44px -18px rgba(24, 21, 15, 0.4);
}
.portrait figcaption {
  margin-top: 0.7rem;
  font-size: 0.78rem; color: var(--faint); letter-spacing: 0.02em;
}

.profiles {
  margin-top: 2.6rem; padding-top: 1.5rem;
  border-top: 1px solid var(--rule-soft);
  display: flex; flex-wrap: wrap; gap: 0.7rem 0.9rem;
}
.profiles a {
  font-size: 0.88rem;
  color: var(--muted);
  text-decoration: none;
  border: 1px solid var(--rule);
  border-radius: 999px;
  padding: 0.45rem 1.05rem;
  transition: color 0.2s ease, border-color 0.2s ease, transform 0.2s ease,
              background-color 0.2s ease;
}
.profiles a::after { content: '\2197'; margin-left: 0.35em; font-size: 0.82em; opacity: 0.6; }
.profiles a:hover {
  color: var(--paper); background: var(--accent); border-color: var(--accent);
  transform: translateY(-2px);
}

/* ----- affiliations ---------------------------------------------- */

.logo-row {
  display: flex; flex-wrap: wrap; align-items: center;
  gap: 1.8rem 2.6rem;
  margin-top: 2.1rem;
}
.logo-row a { text-decoration: none; display: block; transition: transform 0.25s ease; }
.logo-row a:hover { transform: translateY(-3px); }
.logo-row img {
  max-height: 52px; width: auto;
  filter: grayscale(1) opacity(0.6);
  transition: filter 0.3s ease;
}
.logo-row a:hover img, .logo-row img:hover { filter: grayscale(0) opacity(1); }

/* ----- entry lists (research / teaching) ------------------------- */

.entry-list { margin-top: 0.5rem; }
.entry {
  position: relative;
  padding: 1.7rem 0 1.7rem 1.4rem;
  border-bottom: 1px solid var(--rule-soft);
  max-width: 80ch;
  transition: transform 0.3s ease;
}
.entry::before {
  content: '';
  position: absolute; left: 0; top: 1.9rem; bottom: 1.9rem;
  width: 2px;
  background: var(--accent);
  transform: scaleY(0);
  transform-origin: 0 0;
  transition: transform 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}
.entry:hover { transform: translateX(6px); }
.entry:hover::before { transform: scaleY(1); }
.entry:last-child { border-bottom: none; }

.entry h3 {
  font-family: var(--serif);
  font-weight: 400;
  font-size: 1.45rem; line-height: 1.3;
  margin: 0 0 0.45rem;
}
.entry h3 a { text-decoration: none; }
.entry h3 a:hover { color: var(--accent); }
.entry .tag {
  display: inline-block;
  font-size: 0.72rem; font-weight: 560;
  letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 0.55rem;
}
.entry .meta { font-size: 0.92rem; color: var(--muted); margin: 0; }
.entry .meta em { font-family: var(--serif); font-size: 1.02em; }
.entry .meta .sep { margin: 0 0.45em; color: var(--faint); }
.entry .meta a { color: var(--accent); text-decoration-color: rgba(20, 105, 94, 0.35); }

/* publications by year */
.year-group {
  display: grid;
  grid-template-columns: 5.5rem minmax(0, 1fr);
  gap: 0 1.5rem;
  border-bottom: 1px solid var(--rule-soft);
}
.year-group:last-of-type { border-bottom: none; }
.year-group .year {
  font-family: var(--serif);
  font-size: 1.35rem; color: var(--faint);
  padding-top: 1.7rem;
}
.year-group .entries { min-width: 0; }
.year-group .entry { border-bottom: 1px solid var(--rule-soft); }
.year-group .entry:last-child { border-bottom: none; }

/* ----- funding ---------------------------------------------------- */

.funding-row {
  margin-top: 2.2rem;
  display: flex; flex-wrap: wrap; align-items: center;
  gap: 2rem 3rem;
}
.funding-row img {
  max-height: 46px; width: auto;
  filter: grayscale(1) opacity(0.6);
  transition: filter 0.3s ease;
}
.funding-row img.tall { max-height: 64px; }
.funding-row a:hover img, .funding-row img:hover { filter: grayscale(0) opacity(1); }
.funding-row .text-logo {
  font-family: var(--serif); font-style: italic;
  font-size: 1.1rem; color: var(--muted);
}

/* ----- cv ---------------------------------------------------------- */

.cv-actions { margin: 0 0 2.2rem; }
.btn {
  display: inline-block;
  font-size: 0.84rem; font-weight: 520;
  letter-spacing: 0.14em; text-transform: uppercase;
  text-decoration: none;
  color: var(--paper); background: var(--ink);
  padding: 0.9rem 1.7rem;
  border-radius: 2px;
  transition: background 0.25s ease, transform 0.25s ease;
  will-change: transform;
}
.btn:hover { background: var(--accent); color: var(--paper); }

.cv-viewer {
  width: 100%; height: 78vh;
  border: 1px solid var(--rule);
  border-radius: 2px;
}
.cv-fallback { padding: 2rem 0; color: var(--muted); }

/* ----- footer ------------------------------------------------------ */

.site-footer {
  background: var(--paper);
  color: var(--ink);
  border-top: 1px solid var(--rule);
  padding: clamp(3.5rem, 8vw, 6rem) 0 2.5rem;
}
.site-footer .cols {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr) minmax(0, 1fr);
  gap: 2.5rem var(--gutter);
  align-items: start;
}
.site-footer .hello-label {
  font-size: 0.78rem; font-weight: 520;
  letter-spacing: 0.22em; text-transform: uppercase;
  color: var(--accent-bright);
  margin: 0 0 1rem;
}
.mail-link {
  display: inline-block;
  font-family: var(--serif); font-style: italic;
  font-size: clamp(1.7rem, 3.6vw, 2.7rem);
  line-height: 1.2;
  color: var(--ink);
  text-decoration: none;
  border-bottom: 1px solid var(--rule);
  padding-bottom: 0.15em;
  transition: border-color 0.25s ease, color 0.25s ease, transform 0.25s ease;
  will-change: transform;
}
.mail-link:hover { color: var(--accent-bright); border-color: var(--accent-bright); }

.site-footer h3 {
  font-size: 0.78rem; font-weight: 520;
  letter-spacing: 0.2em; text-transform: uppercase;
  color: var(--faint);
  margin: 0 0 0.9rem;
}
.site-footer ul { list-style: none; margin: 0; padding: 0; }
.site-footer li { margin-bottom: 0.4rem; }
.site-footer .cols a:not(.mail-link) {
  text-decoration: none;
  color: var(--muted);
  transition: color 0.2s ease;
}
.site-footer .cols a:not(.mail-link):hover { color: var(--accent-bright); }

.colophon {
  margin-top: clamp(3rem, 6vw, 4.5rem);
  padding-top: 1.4rem;
  border-top: 1px solid var(--rule-soft);
  font-size: 0.8rem;
  color: var(--faint);
  display: flex; justify-content: space-between; flex-wrap: wrap; gap: 0.5rem;
}

/* ----- responsive --------------------------------------------------- */

@media (max-width: 720px) {
  .intro { grid-template-columns: 1fr; }
  .portrait { order: -1; max-width: 210px; }
  .year-group { grid-template-columns: 1fr; }
  .year-group .year { padding-top: 1.7rem; margin-bottom: -1.1rem; }
  .site-footer .cols { grid-template-columns: 1fr; }
  .site-nav { gap: 1.1rem; }
  .entry { padding-left: 1rem; }
  .scroll-cue { display: none; }
}

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

@media print {
  .site-header, .site-footer, .scroll-cue, #progress, .cursor-ring { display: none; }
  .hero { min-height: 0; background: none; color: var(--ink); }
  .hero canvas { display: none; }
}

/* light hero adjustments */
.hero { border-bottom: 1px solid var(--rule-soft); }
.hero-title { max-width: 18ch; font-size: clamp(2.5rem, 6.2vw, 4.7rem); }
.hero-title em { font-style: italic; color: var(--accent); }
.site-header.solid { color: var(--ink); }
.hello-label { color: var(--accent) !important; }
.mail-link:hover { color: var(--accent) !important; border-color: var(--accent) !important; }

/* home: wordmark oculto hasta pasar el hero */
.wordmark { transition: opacity 0.35s ease, transform 0.35s ease; }
body.home .site-header:not(.solid) .wordmark {
  opacity: 0;
  transform: translateY(6px);
  pointer-events: none;
}
