:root {
  color-scheme: light dark;

  /* Brand palette based on #034f84 */
  --brand-50: #e5f1fa;
  --brand-100: #c7e0f4;
  --brand-200: #a3caea;
  --brand-300: #7bb0dd;
  --brand-400: #4f92cc;
  --brand-500: #034f84;
  --brand-600: #023f6a;
  --brand-700: #022f4f;
  --brand-800: #021f35;
  --brand-900: #011320;

  /* Dark mode base (background = brand-800) */
  --bg: var(--brand-800);
  --bg-alt: var(--brand-900);
  --bg-soft: #0b1724;

  --fg: #e5e7eb;
  --fg-muted: #9ca3af;

  --accent: var(--brand-400);
  --accent-soft: rgba(3, 79, 132, 0.14);
  --accent-strong: var(--brand-500);

  --danger: #ef4444;

  --shadow-soft: 0 18px 45px rgba(1, 19, 32, 0.85);

  --radius-lg: 1.5rem;
  --radius-md: 0.875rem;
  --radius-pill: 999px;

  --transition-fast: 150ms ease-out;
  --transition-med: 220ms ease;
}

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

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

html {
  scroll-behavior: smooth;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  min-height: 100vh;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "SF Pro Text",
    "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--fg);
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

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

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

a {
  color: inherit;
  text-decoration: none;
}

/* Layout base */
.container {
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

/* ===== HEADER ===== */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: blur(14px);
  background: rgba(2, 31, 53, 0.96);
  border-bottom: 1px solid rgba(148, 163, 184, 0.18);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.9rem 1.5rem;
}

.logo-avatar img {
  height: 2.5rem;
  width: auto;
  transition: transform var(--transition-fast);
  display: block;
}

.logo-avatar img:hover {
  transform: scale(1.05);
}

/* ===== NAVEGACIÓN ESCRITORIO ===== */
.nav {
  display: flex;
  align-items: center;
}

.nav-links {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 0;
  padding: 0;
}

.nav-links a {
  padding: 0.45rem 0.9rem;
  border-radius: 999px;
  font-size: 0.83rem;
  color: var(--fg-muted);
  border: 1px solid transparent;
  transition: background var(--transition-fast), color var(--transition-fast),
    border-color var(--transition-fast), transform var(--transition-fast);
}

.nav-links a:hover {
  color: #e5e7eb;
  background: rgba(148, 163, 184, 0.16);
  border-color: rgba(148, 163, 184, 0.45);
  transform: translateY(-1px);
}

.nav-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 0.18rem;
  width: 2.4rem;
  height: 2.4rem;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.45);
  background: rgba(2, 31, 53, 0.96);
  cursor: pointer;
  margin-left: 1rem;
}

.nav-toggle span {
  height: 2px;
  width: 52%;
  margin: 0 auto;
  background: #e5e7eb;
  border-radius: 999px;
  transition: transform var(--transition-med), opacity var(--transition-med);
}

.nav-toggle[aria-expanded="true"] span:nth-child(1) {
  transform: translateY(3px) rotate(40deg);
}

.nav-toggle[aria-expanded="true"] span:nth-child(2) {
  transform: translateY(-3px) rotate(-40deg);
}

.theme-toggle {
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.45);
  background: rgba(2, 31, 53, 0.96);
  padding: 0.35rem 0.7rem;
  cursor: pointer;
  color: #e5e7eb;
  font-size: 0.9rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-left: 0.5rem;
}

/* ===== HERO ===== */
.hero {
  padding: 5.5rem 0 4.5rem;
}

.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 3fr) minmax(0, 2.1fr);
  gap: 2.75rem;
  align-items: center;
}

.hero-kicker {
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.75rem;
  color: var(--fg-muted);
  margin-bottom: 0.75rem;
}

.hero h1 {
  font-size: clamp(2.2rem, 4vw + 1rem, 3.2rem);
  letter-spacing: -0.04em;
  margin: 0 0 0.9rem;
}

.hero-subtitle {
  margin: 0;
  font-size: 1.02rem;
  color: var(--fg-muted);
  max-width: 36rem;
}

.accent {
  color: var(--accent-strong);
  font-weight: 600;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1.6rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.7rem 1.4rem;
  border-radius: var(--radius-pill);
  border: 1px solid transparent;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast),
    background var(--transition-fast), border-color var(--transition-fast),
    color var(--transition-fast);
}

.btn.primary {
  background: var(--brand-500);
  color: #f9fafb;
  border-color: var(--brand-500);
  box-shadow: 0 16px 36px rgba(1, 19, 32, 0.7);
}

.btn.primary:hover {
  background: var(--brand-400);
  border-color: var(--brand-400);
  transform: translateY(-1px);
  box-shadow: 0 22px 50px rgba(1, 19, 32, 0.9);
}

.btn.ghost {
  background: transparent;
  color: var(--fg);
  border-color: rgba(148, 163, 184, 0.55);
}

.btn.ghost:hover {
  background: rgba(2, 31, 53, 0.9);
  border-color: var(--brand-400);
}

.hero-note {
  margin-top: 1rem;
  font-size: 0.86rem;
  color: var(--fg-muted);
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 0.25rem 0.7rem;
  font-size: 0.74rem;
  background: rgba(22, 163, 74, 0.18);
  color: #bbf7d0;
  border: 1px solid rgba(22, 163, 74, 0.55);
}

.hero-avatar {
  width: 3.5rem;
  height: 3.5rem;
  border-radius: 999px;
  background: var(--brand-500);
  padding: 2px;
  overflow: hidden;
}

.hero-avatar img {
  width: 100%;
  height: 100%;
  border-radius: inherit;
  object-fit: cover;
}

.hero-card {
  border-radius: var(--radius-lg);
  padding: 1.75rem 1.4rem;
  background: var(--bg-alt);
  border: 1px solid rgba(148, 163, 184, 0.3);
  box-shadow: var(--shadow-soft);
}

.hero-role {
  margin: 1.1rem 0 0.1rem;
  font-size: 0.95rem;
}

.hero-location {
  margin: 0;
  font-size: 0.82rem;
  color: var(--fg-muted);
}

.hero-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 1.2rem;
}

.hero-tags span {
  border-radius: 999px;
  padding: 0.28rem 0.7rem;
  font-size: 0.78rem;
  background: rgba(2, 31, 53, 0.9);
  border: 1px solid rgba(148, 163, 184, 0.5);
}

/* ===== SECCIONES ===== */
.section {
  padding: 3.5rem 0;
}

.section-alt {
  background: var(--bg-soft);
}

.section-header {
  text-align: left;
  margin-bottom: 1.6rem;
}

.section-footer {
  margin-top: 2rem;
  text-align: center;
}

.section-header h2 {
  font-size: 1.55rem;
  margin-bottom: 0.3rem;
}

.section-intro {
  margin: 0;
  max-width: 32rem;
  font-size: 0.95rem;
  color: var(--fg-muted);
}

/* ===== ABOUT ===== */
.about-grid {
  display: grid;
  grid-template-columns: minmax(0, 3fr) minmax(0, 2.4fr);
  gap: 2rem;
}

.about-text p {
  margin-top: 0;
  margin-bottom: 0.9rem;
  font-size: 0.97rem;
  color: var(--fg-muted);
}

.about-skills h3 {
  margin-top: 0;
  font-size: 1rem;
}

.chip-list {
  list-style: none;
  padding: 0;
  margin: 0.6rem 0 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.chip-list li {
  padding: 0.4rem 0.8rem;
  border-radius: 999px;
  font-size: 0.8rem;
  background: rgba(2, 31, 53, 0.9);
  border: 1px solid rgba(148, 163, 184, 0.6);
}

/* ===== CARDS ===== */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1.5rem;
  margin-top: 1.6rem;
}

.card {
  border-radius: var(--radius-md);
  padding: 1.3rem 1.1rem;
  background: var(--bg-alt);
  border: 1px solid rgba(148, 163, 184, 0.28);
  box-shadow: 0 16px 40px rgba(1, 19, 32, 0.9);
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  transform: translateY(0);
  transition: transform var(--transition-med), box-shadow var(--transition-med),
    border-color var(--transition-med), background var(--transition-med);
}

.card:hover {
  transform: translateY(-5px);
  box-shadow: 0 24px 55px rgba(1, 19, 32, 0.98);
  border-color: var(--brand-400);
  background: var(--bg-soft);
}

.card-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.6rem;
}

.card-header h3 {
  margin: 0;
  font-size: 1rem;
}

.card-text {
  margin: 0;
  font-size: 0.9rem;
  color: var(--fg-muted);
}

.card-tags {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}

.card-tags li {
  padding: 0.3rem 0.7rem;
  border-radius: 999px;
  background: rgba(2, 31, 53, 0.9);
  border: 1px solid rgba(148, 163, 184, 0.4);
  font-size: 0.78rem;
}

.card-links {
  display: flex;
  gap: 0.7rem;
  margin-top: 0.2rem;
}

.card-links a {
  font-size: 0.82rem;
  color: var(--brand-200);
}

/* ===== TIMELINE ===== */
.timeline {
  margin-top: 1.4rem;
  display: grid;
  gap: 1.2rem;
  border-left: 1px solid rgba(148, 163, 184, 0.4);
  padding-left: 1.2rem;
}

.timeline-item {
  position: relative;
}

.timeline-item::before {
  content: "";
  position: absolute;
  left: -1.68rem;
  top: 0.4rem;
  width: 0.6rem;
  height: 0.6rem;
  border-radius: 999px;
  background: var(--brand-500);
  box-shadow: 0 0 0 3px rgba(3, 79, 132, 0.4);
}

.timeline-meta h3 {
  margin: 0;
  font-size: 0.98rem;
}

.timeline-role {
  margin: 0.18rem 0 0.35rem;
  font-size: 0.82rem;
  color: var(--fg-muted);
}

.timeline-text {
  margin: 0;
  font-size: 0.9rem;
  color: var(--fg-muted);
}

/* ===== CONTACT ===== */
.contact-grid {
  display: grid;
  grid-template-columns: minmax(0, 2.5fr) minmax(0, 3fr);
  gap: 2.1rem;
  align-items: center;
}

.contact-card {
  border-radius: var(--radius-md);
  padding: 1.5rem 1.4rem;
  background: var(--bg-alt);
  border: 1px solid rgba(148, 163, 184, 0.3);
  box-shadow: var(--shadow-soft);
}

.contact-text {
  margin: 0 0 0.8rem;
  font-size: 0.9rem;
  color: var(--fg-muted);
}

.contact-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 0.4rem;
}

.contact-list li {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  font-size: 0.86rem;
}

.contact-list span {
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.68rem;
  color: var(--fg-muted);
}

.contact-list a {
  color: var(--brand-200);
}

/* ===== FOOTER ===== */
.site-footer {
  padding: 1.8rem 0 2.4rem;
  border-top: 1px solid rgba(148, 163, 184, 0.28);
  background: var(--bg-alt);
}

.footer-inner {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  font-size: 0.8rem;
  color: var(--fg-muted);
}

.footer-small {
  opacity: 0.8;
}

/* ===== LIGHT THEME (SOLO ESCRITORIO) ===== */
.theme-light {
  --bg: #f4f7fb;
  --bg-alt: #ffffff;
  --bg-soft: #e8f0fa;
  --fg: #0b1120;
  --fg-muted: #4b5563;

  --accent: var(--brand-500);
  --accent-soft: rgba(3, 79, 132, 0.08);
  --accent-strong: var(--brand-600);

  background: var(--bg);
}

.theme-light .site-header {
  background: rgba(255, 255, 255, 0.95);
  border-bottom-color: rgba(148, 163, 184, 0.32);
}

.theme-light .nav-toggle {
  background: rgba(255, 255, 255, 0.95);
  border-color: rgba(148, 163, 184, 0.6);
}

.theme-light .nav-toggle span {
  background: #111827;
}

/* Estilos de navegación SOLO para escritorio en modo claro */
@media (min-width: 901px) {
  .theme-light .nav-links a {
    color: #4b5563;
  }

  .theme-light .nav-links a:hover {
    color: #111827;
    background: rgba(209, 213, 219, 0.5);
    border-color: rgba(148, 163, 184, 0.7);
  }

  .theme-light .theme-toggle {
    background: #ffffff;
    border-color: rgba(148, 163, 184, 0.8);
    color: #0f172a;
  }
}

.theme-light .btn.ghost {
  background: #ffffff;
  border-color: rgba(148, 163, 184, 0.7);
  color: #111827;
}

.theme-light .btn.primary {
  background: var(--brand-500);
  border-color: var(--brand-500);
  box-shadow: 0 12px 26px rgba(15, 23, 42, 0.18);
  color: #f9fafb;
}

.theme-light .card,
.theme-light .contact-card,
.theme-light .hero-card {
  background: #ffffff;
  border-color: rgba(148, 163, 184, 0.35);
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.08);
}

.theme-light .card-tags li,
.theme-light .chip-list li {
  background: #f3f4f6;
  border-color: rgba(148, 163, 184, 0.6);
  color: #1f2937;
}

.theme-light .hero-tags span {
  background: #e5f1fa;
  border-color: rgba(3, 79, 132, 0.3);
  color: #1e293b;
}

.theme-light .badge {
  background: rgba(22, 163, 74, 0.12);
  border-color: rgba(22, 163, 74, 0.5);
  color: #166534;
}

.theme-light .timeline {
  border-left-color: rgba(148, 163, 184, 0.6);
}

.theme-light .section-alt {
  background: #f9fafb;
}

.theme-light .site-footer {
  background: #ffffff;
  border-top-color: rgba(148, 163, 184, 0.3);
}

/* ===== RESPONSIVE MÓVIL (hasta 900px) ===== */
@media (max-width: 900px) {
  .hero-grid {
    grid-template-columns: 1fr;
    gap: 2rem;
  }

  .hero-card {
    order: -1;
  }

  .about-grid,
  .cards-grid,
  .contact-grid {
    grid-template-columns: 1fr;
  }

  .cards-grid {
    gap: 1.1rem;
  }

  .timeline {
    border-left: none;
    padding-left: 0;
  }

  .timeline-item::before {
    display: none;
  }

  .header-inner {
    padding-inline: 1rem;
  }

  .logo-avatar img {
    height: 2rem;
  }

  .nav-toggle {
    display: flex;
  }

  /* Menú móvil - base (oscuro) */
  .nav-links {
    position: fixed;
    top: 4.5rem;
    right: 1rem;
    left: auto;
    width: min(320px, calc(100vw - 2rem));
    max-height: calc(100vh - 6rem);
    overflow-y: auto;
    padding: 1rem;
    border-radius: var(--radius-lg);
    background: rgba(2, 31, 53, 0.98);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(148, 163, 184, 0.5);
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.4);
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
    transform-origin: top right;
    transform: scale(0.92) translateY(-12px);
    opacity: 0;
    visibility: hidden;
    transition: opacity 280ms ease, transform 280ms cubic-bezier(0.34, 1.56, 0.64, 1),
      visibility 280ms ease;
    z-index: 100;
  }

  .nav.nav-open .nav-links {
    opacity: 1;
    transform: scale(1) translateY(0);
    visibility: visible;
  }

  .nav-links li {
    width: 100%;
  }

  .nav-links a,
  .nav-links .theme-toggle {
    width: 100%;
    text-align: left;
    justify-content: flex-start;
    padding: 0.6rem 0.85rem;
    font-size: 0.95rem;
  }

  .nav-links .theme-toggle {
    border: 1px solid rgba(148, 163, 184, 0.45);
    margin-left: 0;
  }

  .section {
    padding-block: 2.7rem;
  }
}

/* ===== MÓVIL PEQUEÑO (hasta 600px) ===== */
@media (max-width: 600px) {
  .hero {
    padding-top: 4.5rem;
  }

  .hero h1 {
    font-size: clamp(1.8rem, 8vw, 2.4rem);
  }

  .logo-avatar img {
    height: 1.75rem;
  }

  .footer-inner {
    flex-direction: column;
    align-items: flex-start;
  }

  .container {
    padding-inline: 1.1rem;
  }

  .timeline {
    margin-left: 0;
    margin-right: 0;
    width: 100%;
  }

  .timeline-item {
    padding-left: 0;
  }

  .timeline-meta h3 {
    font-size: 0.95rem;
  }
  
  .timeline-role,
  .timeline-text {
    word-break: break-word;
  }
}

/* ===== MÓVIL EN MODO CLARO (solo cuando está activo theme-light) ===== */
@media (max-width: 900px) {
  .theme-light .nav-links {
    background: rgba(255, 255, 255, 0.98);
    border-color: rgba(148, 163, 184, 0.6);
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.15);
  }

  .theme-light .nav-links a {
    color: #4b5563;
  }

  .theme-light .nav-links a:hover {
    color: #111827;
    background: rgba(229, 231, 235, 0.6);
    border-color: rgba(148, 163, 184, 0.7);
  }

  .theme-light .nav-links .theme-toggle {
    background: #ffffff;
    border-color: rgba(148, 163, 184, 0.6);
    color: #0f172a;
  }

  .theme-light .nav-links .theme-toggle:hover {
    background: rgba(229, 231, 235, 0.6);
    border-color: rgba(148, 163, 184, 0.7);
    color: #111827;
  }
}