/* ==========================================================================
   dacastillo.github.io — Main Stylesheet
   Diseño minimalista para investigador en física computacional
   ========================================================================== */

/* ==========================================================================
   1. Variables CSS Globales
   ========================================================================== */
:root {
  /* ─── Colores ──────────────────────────────────────────────────────── */
  --color-bg:           #fafaf8;
  --color-bg-subtle:    #f2f1ed;
  --color-code-bg:      #ebebeb;
  --color-text:         #1a1a18;
  --color-text-muted:   #666660;
  --color-accent:       #1a5c73;
  --color-accent-light: #e8f3f7;
  --color-border:       #d8d7d3;

  /* ─── Tipografía ───────────────────────────────────────────────────── */
  --font-body:    'DM Sans', system-ui, -apple-system, sans-serif;
  --font-heading: 'Spectral', Georgia, 'Times New Roman', serif;
  --font-mono:    'JetBrains Mono', 'Courier New', monospace;

  /* ─── Espaciado ────────────────────────────────────────────────────── */
  --space-xs:   0.25rem;
  --space-sm:   0.5rem;
  --space-md:   1rem;
  --space-lg:   2rem;
  --space-xl:   4rem;

  /* ─── Layout ───────────────────────────────────────────────────────── */
  --max-width:      720px;
  --max-width-wide: 960px;

  /* ─── Bordes y radios ──────────────────────────────────────────────── */
  --radius-sm: 4px;
  --radius-md: 8px;
  --border: 1px solid var(--color-border);

  /* ─── Transiciones ─────────────────────────────────────────────────── */
  --transition-fast: 150ms ease;
  --transition-mid:  300ms ease;
}

/* ==========================================================================
   2. Modo Oscuro (automático via prefers-color-scheme)
   ========================================================================== */
@media (prefers-color-scheme: dark) {
  :root {
    --color-bg:           #141412;
    --color-bg-subtle:    #1e1e1c;
    --color-code-bg:      #2a2a28;
    --color-text:         #e8e7e3;
    --color-text-muted:   #8a8a85;
    --color-accent:       #4da6c0;
    --color-accent-light: #1a3a44;
    --color-border:       #2e2e2c;
  }
}

/* ==========================================================================
   3. Reset y Base
   ========================================================================== */
*, *::before, *::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  padding: 0;
  font-family: var(--font-body);
  font-weight: 300;
  font-size: 1rem;
  line-height: 1.75;
  color: var(--color-text);
  background-color: var(--color-bg);
}

/* Accesibilidad: focus visible */
:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 3px;
  border-radius: var(--radius-sm);
}

/* Respetar prefers-reduced-motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ==========================================================================
   4. Tipografía
   ========================================================================== */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  font-weight: 300;
  letter-spacing: -0.02em;
  line-height: 1.2;
  margin-top: 0;
}

h1 {
  font-size: clamp(2rem, 5vw, 3.5rem);
}

h2 {
  font-size: clamp(1.25rem, 3vw, 1.75rem);
  margin-bottom: var(--space-md);
}

h3 {
  font-size: clamp(1.1rem, 2.5vw, 1.35rem);
}

p {
  margin-top: 0;
  margin-bottom: var(--space-md);
  max-width: 65ch;
}

a {
  color: var(--color-accent);
  text-decoration: none;
  transition: color var(--transition-fast);
}

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

/* Código inline y nombres de herramientas */
code, .stack-tag, .tool-name {
  font-family: var(--font-mono);
  font-size: 0.85em;
  background: var(--color-code-bg);
  padding: 0.1em 0.4em;
  border-radius: 3px;
  color: var(--color-text);
}

/* ==========================================================================
   5. Layout Container
   ========================================================================== */
.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 var(--space-md);
}

.container-wide {
  max-width: var(--max-width-wide);
}

/* ==========================================================================
   6. Navegación
   ========================================================================== */
.site-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-md) 0;
  border-bottom: var(--border);
  gap: var(--space-md);
}

.site-nav ul {
  display: flex;
  list-style: none;
  gap: var(--space-lg);
  margin: 0;
  padding: 0;
}

.site-nav a {
  font-size: 0.9rem;
  font-weight: 400;
  color: var(--color-text-muted);
  text-decoration: none;
  transition: color var(--transition-fast);
  position: relative;
}

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

/* Subrayado animado en hover */
.site-nav a::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 0;
  height: 1px;
  background: var(--color-accent);
  transition: width var(--transition-fast);
}

.site-nav a:hover::after,
.site-nav a[aria-current="page"]::after {
  width: 100%;
}

.nav-logo {
  font-family: var(--font-heading);
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--color-text) !important;
}

.nav-lang {
  font-family: var(--font-mono);
  font-size: 0.8rem;
}

/* ==========================================================================
   7. Hero Section
   ========================================================================== */
.hero {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: var(--space-lg);
  align-items: start;
  padding: var(--space-xl) 0 var(--space-lg);
  border-bottom: var(--border);
  animation: fadeUp 0.5s ease both;
}

.hero-text h1 {
  margin: 0 0 var(--space-xs);
  color: var(--color-text);
  animation: fadeUp 0.5s 0.05s ease both;
}

/* Línea decorativa bajo el h1 */
.hero h1::after {
  content: '';
  display: block;
  width: 3rem;
  height: 2px;
  background: var(--color-accent);
  margin-top: var(--space-sm);
}

.hero-title {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--color-text-muted);
  margin: 0 0 var(--space-md);
  letter-spacing: 0.02em;
  animation: fadeUp 0.5s 0.10s ease both;
}

.hero-bio {
  max-width: 55ch;
  color: var(--color-text);
  margin-bottom: var(--space-md);
  animation: fadeUp 0.5s 0.15s ease both;
}

.hero-badges {
  display: flex;
  gap: var(--space-sm);
  flex-wrap: wrap;
  animation: fadeUp 0.5s 0.20s ease both;
}

.badge-link img {
  height: 20px;
  transition: opacity var(--transition-fast);
}

.badge-link:hover img {
  opacity: 0.8;
}

.hero-photo {
  animation: fadeUp 0.5s 0.25s ease both;
}

.hero-photo img {
  width: 140px;
  height: 140px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid var(--color-bg-subtle);
  filter: grayscale(15%);
  transition: filter var(--transition-mid);
}

.hero-photo img:hover {
  filter: grayscale(0%);
}

/* ==========================================================================
   8. Contenido Principal
   ========================================================================== */
main {
  padding: var(--space-xl) 0;
}

section {
  margin-bottom: var(--space-xl);
}

/* ==========================================================================
   9. Tarjetas de Proyectos
   ========================================================================== */
.project-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: var(--space-md);
}

.project-card {
  padding: var(--space-md);
  border: var(--border);
  border-radius: var(--radius-md);
  background: var(--color-bg);
  transition: border-color var(--transition-fast),
              box-shadow var(--transition-fast);
}

.project-card:hover {
  border-color: var(--color-accent);
  box-shadow: 0 2px 12px rgba(26, 92, 115, 0.08);
}

.project-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: var(--space-sm);
}

.project-title {
  font-family: var(--font-heading);
  font-size: 1.1rem;
  font-weight: 400;
  margin: 0;
}

.project-title a {
  color: var(--color-text);
  text-decoration: none;
}

.project-title a:hover {
  color: var(--color-accent);
}

.project-year {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--color-text-muted);
}

.project-description {
  font-size: 0.9rem;
  color: var(--color-text-muted);
  margin: 0 0 var(--space-sm);
  line-height: 1.6;
}

.project-stack {
  display: flex;
  gap: var(--space-xs);
  flex-wrap: wrap;
}

.project-stack code {
  background: var(--color-bg-subtle);
  padding: 0.2em 0.5em;
  border-radius: 4px;
}

/* ==========================================================================
   10. CV y Publicaciones
   ========================================================================== */
.cv-section {
  margin-bottom: var(--space-lg);
}

.cv-section h2 {
  border-bottom: var(--border);
  padding-bottom: var(--space-sm);
}

.cv-item {
  margin-bottom: var(--space-md);
}

.cv-item h3 {
  margin-bottom: var(--space-xs);
}

.cv-item-meta {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--color-text-muted);
  margin-bottom: var(--space-sm);
}

/* Publicaciones */
.pub-list {
  list-style: none;
  padding: 0;
  counter-reset: pub-counter;
}

.pub-item {
  padding: var(--space-md) 0;
  border-bottom: var(--border);
  line-height: 1.7;
  font-size: 0.95rem;
}

.pub-item:last-child {
  border-bottom: none;
}

.pub-authors {
  color: var(--color-text-muted);
}

.pub-title {
  font-weight: 500;
}

.pub-doi {
  display: inline-block;
  margin-top: var(--space-xs);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--color-accent);
}

.pub-doi:hover {
  text-decoration: underline;
}

/* ==========================================================================
   11. Footer
   ========================================================================== */
.site-footer {
  margin-top: var(--space-xl);
  padding-top: var(--space-lg);
  border-top: var(--border);
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  align-items: center;
  text-align: center;
}

.footer-location {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--color-text-muted);
}

.footer-links {
  display: flex;
  gap: var(--space-lg);
  flex-wrap: wrap;
  justify-content: center;
}

.footer-links a {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--color-text-muted);
  text-decoration: none;
  transition: color var(--transition-fast);
}

.footer-links a:hover {
  color: var(--color-accent);
}

.footer-copy {
  font-size: 0.75rem;
  color: var(--color-text-muted);
}

/* ==========================================================================
   12. Animaciones
   ========================================================================== */
@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ==========================================================================
   13. Responsividad Móvil
   ========================================================================== */
@media (max-width: 600px) {
  /* Hero: apilar verticalmente */
  .hero {
    grid-template-columns: 1fr;
  }

  .hero-photo {
    order: -1;
    display: flex;
    justify-content: center;
    margin-bottom: var(--space-md);
  }

  /* Navegación: reducir gap */
  .site-nav {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-sm);
  }

  .site-nav ul {
    gap: var(--space-md);
    flex-wrap: wrap;
  }

  .site-nav a {
    font-size: 0.8rem;
  }

  /* Tarjetas de proyectos: una columna */
  .project-grid {
    grid-template-columns: 1fr;
  }

  /* Footer: reducir gap */
  .footer-links {
    gap: var(--space-md);
  }

  /* Ajustar padding del container */
  .container {
    padding: 0 var(--space-sm);
  }
}

/* ==========================================================================
   14. Utilidades
   ========================================================================== */
.text-muted {
  color: var(--color-text-muted);
}

.text-center {
  text-align: center;
}

.mt-lg {
  margin-top: var(--space-lg);
}

.mb-lg {
  margin-bottom: var(--space-lg);
}

/* Imágenes responsivas */
img {
  max-width: 100%;
  height: auto;
}

/* ==========================================================================
   15. Estilos específicos para páginas
   ========================================================================== */

/* Página de Links */
.links-list {
  list-style: none;
  padding: 0;
}

.links-list li {
  padding: var(--space-sm) 0;
  border-bottom: 1px solid var(--color-bg-subtle);
}

.links-list li:last-child {
  border-bottom: none;
}

.links-list a {
  color: var(--color-text);
  font-weight: 500;
}

.links-list a:hover {
  color: var(--color-accent);
}

.links-list .link-desc {
  font-size: 0.85rem;
  color: var(--color-text-muted);
  margin-top: var(--space-xs);
}
