/* ==========================================================================
   Sergio Lara González — Web personal
   v2 · sistema de diseño inspirado en las Human Interface Guidelines de Apple
   Capa de contenido sólida + capa funcional translúcida (cabecera).
   Paleta de marca: negro + rojo (tomada del logotipo).
   ========================================================================== */

/* ---------- Tokens: apariencia clara ---------- */
:root {
  color-scheme: light dark;

  --bg: #f5f5f7;              /* fondo de página (gris claro de sistema) */
  --surface: #ffffff;         /* superficie elevada / tarjetas */
  --surface-2: #f2f2f4;       /* superficie agrupada, pills */
  --separator: #d9d9de;
  --label: #1d1d1f;           /* texto principal */
  --label-2: #6e6e73;         /* texto secundario */
  --label-3: #86868b;         /* texto terciario */
  --accent: #c8102e;          /* rojo de marca (enlaces, iconos, acciones) */
  --accent-fill: #c8102e;     /* fondo de botón principal */
  --on-accent: #ffffff;
  --accent-soft: rgba(200, 16, 46, 0.09);
  --positive: #1f7a33;

  --radius: 20px;
  --radius-sm: 13px;
  --radius-pill: 980px;
  --maxw: 1120px;
  --header-h: 64px;

  --shadow: 0 1px 2px rgba(0, 0, 0, 0.05), 0 18px 40px -24px rgba(0, 0, 0, 0.22);

  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display",
          "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* ---------- Tokens: apariencia oscura ---------- */
html[data-theme="dark"] {
  --bg: #000000;
  --surface: #1c1c1e;
  --surface-2: #2c2c2e;
  --separator: rgba(255, 255, 255, 0.16);
  --label: #f5f5f7;
  --label-2: #a1a1a6;
  --label-3: #8e8e93;
  --accent: #ff453a;
  --accent-fill: #d70015;
  --on-accent: #ffffff;
  --accent-soft: rgba(255, 69, 58, 0.15);
  --positive: #30d158;
  --shadow: 0 1px 0 rgba(255, 255, 255, 0.04) inset, 0 24px 48px -28px rgba(0, 0, 0, 0.9);
}

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

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-h) + 16px);
}

body {
  margin: 0;
  font-family: var(--font);
  font-size: 1.0625rem;      /* 17 px, tamaño de cuerpo de sistema */
  line-height: 1.5;
  background: var(--bg);
  color: var(--label);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

h1, h2, h3 { margin: 0; line-height: 1.12; letter-spacing: -0.02em; font-weight: 700; }
p { margin: 0; }
a { color: inherit; text-decoration: none; }
img, svg { display: block; max-width: 100%; }
ul, ol { margin: 0; padding: 0; list-style: none; }
strong { color: var(--label); font-weight: 600; }

.container { width: 100%; max-width: var(--maxw); margin: 0 auto; padding: 0 24px; }

.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

/* Iconos lineales: un único trazo, alineados al texto */
.ico {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: none;
  vertical-align: middle;
}
.ico-fill { fill: currentColor; stroke: none; }

/* Foco visible para teclado (WCAG) */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 6px;
}

.skip-link {
  position: absolute; left: -999px; top: 0; z-index: 200;
  background: var(--accent-fill); color: var(--on-accent);
  padding: 10px 16px; border-radius: 0 0 12px 0; font-weight: 600;
}
.skip-link:focus { left: 0; }

/* ---------- Botones ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-family: inherit; font-size: 0.98rem; font-weight: 600;
  padding: 12px 22px; min-height: 44px;
  border-radius: var(--radius-pill); border: 1px solid transparent;
  cursor: pointer; white-space: nowrap;
  transition: background .18s ease, color .18s ease, border-color .18s ease,
              transform .12s ease, box-shadow .18s ease;
}
.btn:active { transform: scale(0.97); }

.btn-primary { background: var(--accent-fill); color: var(--on-accent); }
.btn-primary:hover { background: color-mix(in srgb, var(--accent-fill) 88%, #000); }

.btn-secondary { background: var(--surface); color: var(--label); border-color: var(--separator); }
.btn-secondary:hover { background: var(--surface-2); }

.btn-quiet { background: transparent; color: var(--label); }
.btn-quiet:hover { background: var(--accent-soft); color: var(--accent); }

.btn-sm { padding: 8px 16px; min-height: 38px; font-size: 0.9rem; }
.btn-lg { padding: 14px 28px; min-height: 50px; font-size: 1.03rem; }

/* ---------- Cabecera (capa funcional translúcida) ---------- */
.site-header {
  position: sticky; top: 0; z-index: 100;
  height: var(--header-h);
  display: flex; align-items: center;
  border-bottom: 1px solid transparent;
  transition: background .3s ease, border-color .3s ease;
}
.site-header.scrolled {
  background: color-mix(in srgb, var(--bg) 74%, transparent);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-bottom-color: var(--separator);
}
.nav-wrap { display: flex; align-items: center; justify-content: space-between; gap: 16px; width: 100%; }

.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.02rem; letter-spacing: -0.01em; }
.brand-mark {
  display: grid; place-items: center; width: 34px; height: 34px;
  border-radius: 10px; background: var(--label); color: var(--bg);
  font-size: 0.82rem; font-weight: 700; letter-spacing: -0.02em;
}
.brand-text { color: var(--label); }

.nav { display: flex; align-items: center; gap: 26px; }
.nav > ul { display: flex; gap: 24px; }
.nav > ul a {
  position: relative; padding: 6px 2px;
  font-size: 0.94rem; font-weight: 500; color: var(--label-2);
  transition: color .18s ease;
}
.nav > ul a:hover { color: var(--label); }
.nav > ul a.active { color: var(--label); font-weight: 600; }
.nav > ul a.active::after {
  content: ""; position: absolute; left: 2px; right: 2px; bottom: -3px;
  height: 2px; border-radius: 2px; background: var(--accent);
}
.nav-actions { display: flex; align-items: center; }

.header-tools { display: flex; align-items: center; gap: 8px; }
.icon-btn {
  display: grid; place-items: center; width: 40px; height: 40px;
  border-radius: 11px; border: 1px solid var(--separator);
  background: var(--surface); color: var(--label-2);
  cursor: pointer; transition: color .18s ease, background .18s ease, border-color .18s ease;
}
.icon-btn:hover { color: var(--label); background: var(--surface-2); }
.menu-btn { display: none; }

html[data-theme="dark"] .icon-sun { display: none; }
html[data-theme="light"] .icon-moon { display: none; }

/* ---------- Hero ---------- */
.hero { padding: 72px 0 84px; }
.hero-grid { display: grid; grid-template-columns: 1.05fr 0.95fr; gap: 56px; align-items: center; }

.hero .eyebrow {
  display: inline-flex; align-items: center; gap: 9px;
  font-size: 0.85rem; font-weight: 600; color: var(--label-2);
  background: var(--surface); border: 1px solid var(--separator);
  padding: 6px 15px 6px 12px; border-radius: var(--radius-pill); margin-bottom: 22px;
}
.pulse { width: 8px; height: 8px; border-radius: 50%; background: var(--positive); box-shadow: 0 0 0 4px color-mix(in srgb, var(--positive) 22%, transparent); }

.hero h1 { font-size: clamp(2.4rem, 5.6vw, 3.7rem); letter-spacing: -0.03em; margin-bottom: 16px; }
.hero-role { font-size: 1.06rem; font-weight: 500; color: var(--label-2); margin-bottom: 16px; }
.hero-lead { font-size: 1.12rem; color: var(--label-2); max-width: 36ch; margin-bottom: 28px; }
.hero-cta { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 30px; }
.hero-meta { display: flex; flex-wrap: wrap; gap: 20px; color: var(--label-2); font-size: 0.92rem; }
.hero-meta li { display: inline-flex; align-items: center; gap: 8px; }
.hero-meta .ico { color: var(--label-3); }

.hero-visual { display: flex; flex-direction: column; align-items: center; gap: 18px; }
.brand-card {
  width: min(360px, 84vw); aspect-ratio: 1 / 0.94;
  display: grid; place-items: center; padding: 46px;
  border-radius: 28px; border: 1px solid rgba(0, 0, 0, 0.06);
  /* Superficie clara a propósito: el logotipo es negro/rojo y necesita fondo claro */
  background: linear-gradient(180deg, #ffffff, #f0f0f2);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.06), 0 30px 60px -34px rgba(0, 0, 0, 0.4);
}
.brand-logo { width: 100%; height: auto; }
.brand-caption { font-size: 0.85rem; font-weight: 500; color: var(--label-2); text-align: center; }

/* ---------- Secciones ---------- */
.section { padding: 80px 0; }
.section-head { max-width: 62ch; margin-bottom: 40px; }
.eyebrow { font-size: 0.85rem; font-weight: 600; color: var(--accent); margin-bottom: 10px; }
.section-head h2, .contact-copy h2 { font-size: clamp(1.7rem, 3.4vw, 2.4rem); }
.section-sub { color: var(--label-2); font-size: 1.05rem; margin-top: 12px; }

/* ---------- Sobre mí ---------- */
.about-grid { display: grid; grid-template-columns: 1.25fr 0.75fr; gap: 48px; align-items: start; }
.about-text p { color: var(--label-2); font-size: 1.06rem; margin-bottom: 16px; }
.about-text p:last-child { margin-bottom: 0; }
.about-facts { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.fact-card {
  background: var(--surface); border: 1px solid var(--separator);
  border-radius: var(--radius); padding: 22px 20px;
}
.fact-num { display: block; font-size: 2rem; font-weight: 700; letter-spacing: -0.03em; color: var(--label); }
.fact-label { display: block; font-size: 0.875rem; color: var(--label-2); margin-top: 2px; }

/* ---------- Línea de tiempo ---------- */
.timeline { position: relative; }
.timeline::before {
  content: ""; position: absolute; left: 4px; top: 12px; bottom: 12px;
  width: 1.5px; border-radius: 2px; background: var(--separator);
}
.timeline-item { position: relative; padding-left: 30px; padding-bottom: 16px; }
.timeline-item:last-child { padding-bottom: 0; }
.timeline-item::before {
  content: ""; position: absolute; left: 0; top: 26px;
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--bg); box-shadow: 0 0 0 1.5px var(--separator);
}
.timeline-item:first-child::before { background: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }

.timeline-card {
  background: var(--surface); border: 1px solid var(--separator);
  border-radius: var(--radius); padding: 22px 24px;
}
.timeline-top { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; margin-bottom: 6px; }
.timeline-top h3 { font-size: 1.12rem; font-weight: 600; }
.timeline-org { color: var(--label-2); font-weight: 500; font-size: 0.95rem; }
.timeline-date { color: var(--label-2); font-size: 0.86rem; margin: 2px 0 10px; }
.timeline-desc { color: var(--label-2); font-size: 0.95rem; }

.badge {
  font-size: 0.75rem; font-weight: 600; padding: 4px 11px;
  border-radius: var(--radius-pill); background: var(--surface-2);
  border: 1px solid var(--separator); color: var(--label-2);
}
.badge-live {
  color: var(--positive); border-color: color-mix(in srgb, var(--positive) 36%, transparent);
  background: color-mix(in srgb, var(--positive) 12%, transparent);
}

/* ---------- Tarjetas ---------- */
.cards-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.card {
  background: var(--surface); border: 1px solid var(--separator);
  border-radius: var(--radius); padding: 26px;
}
.card-icon {
  display: inline-grid; place-items: center; width: 42px; height: 42px;
  border-radius: 12px; background: var(--accent-soft); color: var(--accent);
  margin-bottom: 14px;
}
.edu-card h3 { font-size: 1.18rem; font-weight: 600; margin-bottom: 8px; }
.edu-card p { color: var(--label-2); font-size: 0.96rem; }

/* ---------- Conocimientos ---------- */
.skills-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.skill-head { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.skill-head .card-icon { margin-bottom: 0; width: 40px; height: 40px; }
.skill-head h3 { font-size: 1rem; font-weight: 600; }
.skill-card p { color: var(--label-2); font-size: 0.93rem; margin-bottom: 16px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips li {
  font-size: 0.8rem; font-weight: 500; color: var(--label-2);
  background: var(--surface-2); border: 1px solid var(--separator);
  padding: 5px 11px; border-radius: var(--radius-pill);
}

/* ---------- Proyectos ---------- */
.projects-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.project-card {
  display: flex; flex-direction: column; gap: 10px;
  background: var(--surface); border: 1px solid var(--separator);
  border-radius: var(--radius); padding: 26px;
  transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease;
}
.project-card:hover {
  transform: translateY(-3px); box-shadow: var(--shadow);
  border-color: color-mix(in srgb, var(--accent) 40%, var(--separator));
}
.project-cat {
  align-self: flex-start; font-size: 0.72rem; font-weight: 700;
  letter-spacing: 0.06em; text-transform: uppercase; color: var(--accent);
  background: var(--accent-soft); border-radius: var(--radius-pill); padding: 3px 10px;
}
.project-card h3 { font-size: 1.1rem; font-weight: 600; }
.project-card p { color: var(--label-2); font-size: 0.93rem; flex: 1; }
.project-link { display: inline-flex; align-items: center; gap: 5px; font-weight: 600; font-size: 0.9rem; color: var(--accent); margin-top: 4px; }
.project-card:hover .project-link .ico { transform: translate(2px, -2px); }
.project-link .ico { transition: transform .2s ease; }
.projects-cta { margin-top: 40px; text-align: center; }

/* ---------- Contacto ---------- */
.contact-box {
  display: grid; grid-template-columns: 1fr 1fr; gap: 44px; align-items: center;
  background: var(--surface); border: 1px solid var(--separator);
  border-radius: 26px; padding: 46px;
}
.contact-copy p { color: var(--label-2); }
.contact-copy h2 { margin-bottom: 12px; }
.contact-links {
  display: flex; flex-direction: column;
  background: var(--surface-2); border: 1px solid var(--separator);
  border-radius: var(--radius-sm); overflow: hidden;
}
.contact-links li + li { border-top: 1px solid var(--separator); }
.contact-item { display: flex; align-items: center; gap: 14px; padding: 14px 18px; transition: background .18s ease; }
.contact-item:hover { background: var(--surface); }
.contact-item:hover .contact-go { color: var(--accent); transform: translate(2px, -2px); }
.contact-ico {
  display: grid; place-items: center; width: 36px; height: 36px; flex: none;
  border-radius: 10px; background: var(--surface); border: 1px solid var(--separator);
  color: var(--accent);
}
.contact-text { display: flex; flex-direction: column; min-width: 0; }
.contact-text strong { font-size: 0.98rem; font-weight: 600; }
.contact-text em { font-style: normal; font-size: 0.85rem; color: var(--label-2); overflow: hidden; text-overflow: ellipsis; }
.contact-go { margin-left: auto; color: var(--label-3); transition: color .18s ease, transform .18s ease; }

/* ---------- Pie ---------- */
.site-footer { border-top: 1px solid var(--separator); padding: 30px 0; }
.footer-wrap { display: flex; align-items: center; justify-content: space-between; gap: 20px; flex-wrap: wrap; }
.site-footer p { color: var(--label-2); font-size: 0.875rem; }
.footer-nav { display: flex; gap: 22px; flex-wrap: wrap; }
.footer-nav a { color: var(--label-2); font-size: 0.9rem; transition: color .18s ease; }
.footer-nav a:hover { color: var(--accent); }

/* ---------- Aparición al hacer scroll ---------- */
.reveal { opacity: 0; transform: translateY(16px); transition: opacity .55s ease, transform .55s ease; }
.reveal.in { opacity: 1; transform: none; }

/* ---------- Preferencias de accesibilidad ---------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .reveal { opacity: 1; transform: none; transition: none; }
  .btn, .project-card, .project-link .ico, .contact-go { transition: none; }
  .pulse { animation: none; }
}

@media (prefers-reduced-transparency: reduce) {
  .site-header.scrolled { background: var(--bg); backdrop-filter: none; -webkit-backdrop-filter: none; }
  .nav { background: var(--bg) !important; backdrop-filter: none !important; -webkit-backdrop-filter: none !important; }
}

@media (prefers-contrast: more) {
  :root { --separator: #b0b0b6; --label-2: #565659; --label-3: #565659; }
  html[data-theme="dark"] { --separator: rgba(255, 255, 255, 0.34); --label-2: #d0d0d4; --label-3: #c0c0c5; }
  .card, .timeline-card, .fact-card, .project-card { border-width: 1.5px; }
}

/* ---------- Responsive ---------- */
@media (max-width: 980px) {
  .hero-grid { grid-template-columns: 1fr; gap: 44px; }
  .hero-visual { order: -1; }
  .brand-card { width: min(300px, 74vw); }
  .about-grid { grid-template-columns: 1fr; }
  .skills-grid, .projects-grid { grid-template-columns: repeat(2, 1fr); }
  .contact-box { grid-template-columns: 1fr; padding: 36px; gap: 30px; }
}

@media (max-width: 880px) {
  .nav {
    position: fixed; inset: var(--header-h) 0 auto 0;
    flex-direction: column; align-items: stretch; gap: 0;
    background: color-mix(in srgb, var(--bg) 92%, transparent);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    backdrop-filter: saturate(180%) blur(20px);
    border-bottom: 1px solid var(--separator);
    padding: 10px 20px 22px;
    transform: translateY(-130%);
    transition: transform .32s cubic-bezier(0.32, 0.72, 0, 1);
    max-height: calc(100vh - var(--header-h));
    overflow-y: auto;
  }
  .nav.open { transform: translateY(0); }
  .nav > ul { flex-direction: column; gap: 0; }
  .nav > ul a { display: block; padding: 14px 4px; border-bottom: 1px solid var(--separator); font-size: 1.02rem; color: var(--label); }
  .nav > ul a.active::after { display: none; }
  .nav-actions { margin-top: 16px; }
  .nav-actions .btn { width: 100%; }
  .menu-btn { display: grid; }
  .section { padding: 62px 0; }
  .skills-grid, .projects-grid, .cards-2 { grid-template-columns: 1fr; }
  .contact-box { padding: 28px 22px; }
  .footer-wrap { flex-direction: column; text-align: center; }
}

@media (max-width: 420px) {
  .about-facts { grid-template-columns: 1fr; }
  .hero-cta .btn { width: 100%; }
  .hero .eyebrow { margin-bottom: 18px; }
}
