:root {
  --navy-900: #0d1b2a;
  --navy-800: #14263b;
  --navy-700: #1b3a5c;
  --navy-600: #24507c;
  --blue-500: #3a6ea5;
  --blue-100: #dce8f4;
  --gray-100: #f4f6f8;
  --gray-200: #e4e8ec;
  --gray-500: #64748b;
  --gray-700: #334155;
  --white: #ffffff;
  --radius: 14px;
  --shadow: 0 6px 24px rgba(13, 27, 42, 0.08);
  --shadow-lg: 0 16px 48px rgba(13, 27, 42, 0.18);
  --font: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: 84px;
}

body {
  font-family: var(--font);
  color: var(--gray-700);
  background: var(--white);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

.container {
  width: min(1100px, 92%);
  margin-inline: auto;
}

.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
  background: var(--navy-800);
  color: var(--white);
  padding: 0.6rem 1rem;
  z-index: 200;
}

.skip-link:focus {
  left: 0;
}

:focus-visible {
  outline: 3px solid var(--blue-500);
  outline-offset: 2px;
}

/* Barra de progreso de lectura */
.scroll-progress {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  z-index: 200;
  background: transparent;
}

.scroll-progress span {
  display: block;
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--blue-500), var(--navy-600));
  transition: width 0.1s linear;
}

/* Header */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--gray-200);
  transition: box-shadow 0.25s ease;
}

.site-header.scrolled {
  box-shadow: var(--shadow);
}

.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 68px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  text-decoration: none;
  color: var(--navy-900);
  font-weight: 700;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--navy-800);
  color: var(--white);
  font-size: 0.9rem;
  letter-spacing: 0.05em;
}

.brand-text {
  font-size: 1.05rem;
}

.nav-menu {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  list-style: none;
}

.nav-link {
  display: block;
  padding: 0.5rem 0.8rem;
  border-radius: 8px;
  text-decoration: none;
  color: var(--gray-700);
  font-weight: 500;
  font-size: 0.95rem;
  transition: background 0.2s ease, color 0.2s ease;
}

.nav-link:hover {
  background: var(--blue-100);
  color: var(--navy-800);
}

.nav-link.active {
  color: var(--navy-800);
  background: var(--blue-100);
}

.nav-cta {
  background: var(--navy-800);
  color: var(--white);
}

.nav-cta:hover {
  background: var(--navy-600);
  color: var(--white);
}

.nav-toggle {
  display: none;
  flex-direction: column;
  gap: 5px;
  background: none;
  border: 0;
  padding: 0.5rem;
  cursor: pointer;
}

.nav-toggle span {
  width: 24px;
  height: 2px;
  background: var(--navy-900);
  border-radius: 2px;
  transition: transform 0.25s ease, opacity 0.25s ease;
}

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

.nav-toggle[aria-expanded="true"] span:nth-child(2) {
  opacity: 0;
}

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

/* Hero */
.hero {
  background: linear-gradient(135deg, var(--navy-900), var(--navy-700) 45%, var(--blue-500) 90%, var(--navy-800));
  background-size: 220% 220%;
  animation: heroShift 24s ease-in-out infinite alternate;
  color: var(--white);
  padding: 5.5rem 0;
  overflow: hidden;
}

@keyframes heroShift {
  0% {
    background-position: 0% 0%;
  }
  100% {
    background-position: 100% 100%;
  }
}

@keyframes heroIn {
  from {
    opacity: 0;
    transform: translateY(24px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.hero-info > * {
  animation: heroIn 0.8s ease backwards;
}

.hero-info > *:nth-child(1) { animation-delay: 0.05s; }
.hero-info > *:nth-child(2) { animation-delay: 0.15s; }
.hero-info > *:nth-child(3) { animation-delay: 0.3s; }
.hero-info > *:nth-child(4) { animation-delay: 0.45s; }
.hero-info > *:nth-child(5) { animation-delay: 0.6s; }

.hero-card {
  animation: heroIn 0.8s ease 0.5s backwards;
}

.hero-grid {
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  gap: 3rem;
  align-items: center;
}

.hero-kicker {
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.78rem;
  color: var(--blue-100);
  margin-bottom: 0.9rem;
}

.hero h1 {
  font-size: clamp(2rem, 5vw, 3.1rem);
  line-height: 1.12;
  letter-spacing: -0.02em;
  margin-bottom: 1rem;
}

.hero h1 .accent {
  color: #9ec5e8;
}

.hero-role {
  font-size: 1.15rem;
  font-weight: 600;
  margin-bottom: 0.4rem;
}

.hero-role span {
  font-weight: 400;
  color: var(--blue-100);
  font-size: 1rem;
}

.hero-summary {
  max-width: 34rem;
  color: var(--blue-100);
  margin-bottom: 1.8rem;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem;
}

.hero-card {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: var(--radius);
  padding: 2rem;
  text-align: center;
}

.avatar {
  display: grid;
  place-items: center;
  width: 96px;
  height: 96px;
  margin: 0 auto 1.4rem;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.25);
  font-size: 1.9rem;
  font-weight: 800;
  letter-spacing: 0.05em;
}

.hero-facts {
  list-style: none;
  display: grid;
  gap: 1rem;
}

.hero-facts li {
  display: flex;
  flex-direction: column;
}

.hero-facts strong {
  font-size: 1.4rem;
}

.hero-facts span {
  color: var(--blue-100);
  font-size: 0.9rem;
}

/* Sections */
.section {
  padding: 4.5rem 0;
}

.section-alt {
  background: var(--gray-100);
}

.section-title {
  font-size: clamp(1.5rem, 3vw, 2rem);
  color: var(--navy-900);
  letter-spacing: -0.01em;
  margin-bottom: 1.8rem;
  position: relative;
  padding-bottom: 0.6rem;
}

.section-title::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: 0;
  width: 56px;
  height: 4px;
  border-radius: 4px;
  background: var(--blue-500);
}

.section-sub {
  color: var(--gray-500);
  margin: -1rem 0 1.8rem;
}

.card {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 1.6rem;
  box-shadow: var(--shadow);
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.card:hover {
  transform: translateY(-4px);
  box-shadow: 0 14px 34px rgba(13, 27, 42, 0.14);
}

.card h3 {
  color: var(--navy-900);
  font-size: 1.08rem;
  margin-bottom: 0.6rem;
}

/* Perfil */
.profile-grid {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 1.5rem;
  align-items: start;
}

.profile-text p + p {
  margin-top: 1rem;
}

.tags {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.tags li {
  background: var(--blue-100);
  color: var(--navy-800);
  border-radius: 999px;
  padding: 0.35rem 0.85rem;
  font-size: 0.86rem;
  font-weight: 500;
}

/* Timeline */
.timeline {
  list-style: none;
  position: relative;
  padding-left: 2rem;
}

.timeline::before {
  content: "";
  position: absolute;
  left: 8px;
  top: 6px;
  bottom: 6px;
  width: 2px;
  background: var(--gray-200);
}

.timeline-progress {
  position: absolute;
  left: 8px;
  top: 6px;
  width: 2px;
  height: 0;
  border-radius: 2px;
  background: linear-gradient(180deg, var(--blue-500), var(--navy-600));
  transition: height 0.15s ease-out;
  pointer-events: none;
}

.timeline-item {
  position: relative;
  padding-bottom: 1.5rem;
}

.timeline-item:last-child {
  padding-bottom: 0;
}

.timeline-marker {
  position: absolute;
  left: -2rem;
  top: 1.7rem;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--blue-500);
  border: 3px solid var(--white);
  box-shadow: 0 0 0 2px var(--blue-500);
}

.section-alt .timeline-marker {
  border-color: var(--gray-100);
}

.timeline-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.3rem 1rem;
  margin-bottom: 0.8rem;
}

.timeline-meta {
  color: var(--gray-500);
  font-size: 0.88rem;
  font-weight: 500;
  white-space: nowrap;
}

.card ul:not(.tags):not(.history-list) {
  padding-left: 1.2rem;
  display: grid;
  gap: 0.45rem;
}

.history-list {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 0.6rem 1.5rem;
}

.history-list li {
  display: flex;
  flex-direction: column;
  padding-left: 1rem;
  border-left: 3px solid var(--blue-100);
}

.history-list span {
  font-weight: 600;
  color: var(--navy-900);
  font-size: 0.95rem;
}

.history-list em {
  font-style: normal;
  color: var(--gray-500);
  font-size: 0.86rem;
}

/* Homelab */
.lab-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.2rem;
}

.lab-item p {
  color: var(--gray-500);
  font-size: 0.95rem;
}

/* Skills */
.skills-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.2rem;
}

.skills-grid p {
  color: var(--gray-500);
  font-size: 0.95rem;
}

/* Formación */
.edu-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.2rem;
}

.edu-item p {
  color: var(--gray-500);
  font-size: 0.95rem;
}

/* Certificados */
.cert-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.2rem;
}

.cert-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.cert-icon {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border-radius: 12px;
  background: var(--blue-100);
  color: var(--navy-700);
  margin-bottom: 1rem;
}

.cert-icon svg {
  width: 28px;
  height: 28px;
}

.cert-card p {
  color: var(--gray-500);
  font-size: 0.92rem;
  margin-bottom: 1.1rem;
  flex-grow: 1;
}

/* Botones */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.7rem 1.4rem;
  border-radius: 10px;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  text-decoration: none;
  border: 2px solid transparent;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, transform 0.15s ease, box-shadow 0.2s ease;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: var(--blue-500);
  color: var(--white);
}

.btn-primary:hover {
  background: var(--navy-600);
}

.hero .btn-primary {
  background: var(--white);
  color: var(--navy-800);
}

.hero .btn-primary:hover {
  background: var(--blue-100);
}

.btn-outline {
  border-color: var(--navy-700);
  color: var(--navy-800);
  background: transparent;
}

.btn-outline:hover {
  background: var(--navy-800);
  color: var(--white);
}

.hero .btn-outline {
  border-color: rgba(255, 255, 255, 0.5);
  color: var(--white);
}

.hero .btn-outline:hover {
  background: var(--white);
  color: var(--navy-800);
}

.btn-ghost {
  background: var(--gray-200);
  color: var(--navy-800);
}

.btn-ghost:hover {
  background: var(--navy-800);
  color: var(--white);
}

/* Contacto */
.contact {
  background: linear-gradient(135deg, var(--navy-900) 0%, var(--navy-700) 100%);
  color: var(--white);
}

.contact .section-title {
  color: var(--white);
}

.contact .section-title::after {
  background: var(--blue-100);
}

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

.contact-inner .section-title::after {
  left: 50%;
  transform: translateX(-50%);
}

.contact-lead {
  color: var(--blue-100);
  margin-bottom: 1.8rem;
}

.contact-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.8rem;
}

.contact .btn-outline {
  border-color: rgba(255, 255, 255, 0.5);
  color: var(--white);
}

.contact .btn-outline:hover {
  background: var(--white);
  color: var(--navy-800);
}

.contact .btn-ghost {
  background: rgba(255, 255, 255, 0.12);
  color: var(--white);
}

.contact .btn-ghost:hover {
  background: rgba(255, 255, 255, 0.24);
}

.contact-note {
  min-height: 1.5rem;
  margin-top: 1rem;
  font-size: 0.9rem;
  color: #9ec5e8;
}

/* Footer */
.site-footer {
  background: var(--navy-900);
  color: var(--blue-100);
  padding: 1.4rem 0;
  font-size: 0.88rem;
  text-align: center;
}

.footer-credit {
  margin-top: 0.5rem;
  font-size: 0.82rem;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
  justify-content: center;
}

.footer-credit strong {
  color: var(--white);
  font-weight: 600;
}

.credit-icon {
  width: 15px;
  height: 15px;
  vertical-align: -2px;
}

.credit-sep {
  opacity: 0.5;
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: grid;
  place-items: center;
  padding: 1rem;
}

.modal[hidden] {
  display: none;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(13, 27, 42, 0.72);
}

.modal-box {
  position: relative;
  width: min(900px, 100%);
  height: min(86vh, 780px);
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.9rem 1.2rem;
  border-bottom: 1px solid var(--gray-200);
}

.modal-head h3 {
  font-size: 1rem;
  color: var(--navy-900);
}

.modal-close {
  background: var(--gray-100);
  border: 0;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  font-size: 1rem;
  cursor: pointer;
  color: var(--gray-700);
  transition: background 0.2s ease;
}

.modal-close:hover {
  background: var(--gray-200);
}

.modal-body {
  flex: 1;
  min-height: 0;
}

.modal-body iframe {
  width: 100%;
  height: 100%;
  border: 0;
}

.modal-note {
  padding: 0.55rem 1.2rem;
  font-size: 0.8rem;
  color: var(--gray-500);
  border-top: 1px solid var(--gray-200);
  background: var(--gray-100);
}

body.modal-open {
  overflow: hidden;
}

/* Animaciones */
.reveal {
  opacity: 0;
  transform: translateY(18px);
  transition: opacity 0.55s ease, transform 0.55s ease;
}

.reveal.visible {
  opacity: 1;
  transform: none;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  .reveal {
    opacity: 1;
    transform: none;
    transition: none;
  }

  .hero,
  .hero-info > *,
  .hero-card {
    animation: none !important;
  }

  .timeline-progress {
    display: none;
  }

  * {
    animation: none !important;
    transition: none !important;
  }
}

/* Responsive */
@media (max-width: 900px) {
  .hero-grid {
    grid-template-columns: 1fr;
    gap: 2.2rem;
  }

  .hero-card {
    max-width: 380px;
  }

  .profile-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .nav-toggle {
    display: flex;
  }

  .nav-menu {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    flex-direction: column;
    align-items: stretch;
    gap: 0.2rem;
    background: var(--white);
    border-bottom: 1px solid var(--gray-200);
    box-shadow: var(--shadow);
    padding: 0.8rem 4%;
    display: none;
  }

  .nav-menu.open {
    display: flex;
  }

  .nav-link {
    padding: 0.75rem 1rem;
  }

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

  .section {
    padding: 3.2rem 0;
  }

  .hero {
    padding: 3.8rem 0;
  }

  .timeline {
    padding-left: 1.6rem;
  }

  .timeline-marker {
    left: -1.6rem;
  }

  .history-list {
    grid-template-columns: 1fr;
  }

  .contact-actions .btn {
    width: 100%;
    max-width: 320px;
  }
}

/* Impresión */
@media print {
  .site-header,
  .hero-actions,
  .contact-actions,
  .btn-view,
  .modal,
  .nav-toggle,
  .scroll-progress,
  .timeline-progress {
    display: none !important;
  }

  .hero,
  .contact {
    background: var(--white);
    color: var(--navy-900);
  }

  .card {
    box-shadow: none;
    break-inside: avoid;
  }

  body {
    color: #000;
  }
}
