/* ====== RESET BÁSICO ====== */
*,
*::before,
*::after {
  box-sizing: border-box;
}

:root {
  --bg: #020617;
  --bg-elevated: #020817;
  --bg-soft: #030617;
  --border-subtle: rgba(148, 163, 184, 0.25);
  --accent: #38bdf8;
  --accent-soft: rgba(56, 189, 248, 0.18);
  --accent-strong: #0ea5e9;
  --fg: #e5e7eb;
  --fg-soft: #9ca3af;
  --fg-muted: #6b7280;
  --shadow-soft: 0 18px 45px rgba(15, 23, 42, 0.9);
  --radius-lg: 24px;
  --radius-md: 18px;
  --radius-pill: 999px;
  --nav-height: 72px;
  --transition-fast: 0.18s ease-out;
  --transition-med: 0.25s ease-out;
}

/* Tema claro: sobreescribe variables */
body.theme-light {
  --bg: #f3f4f6;
  --bg-elevated: #ffffff;
  --bg-soft: #e5e7eb;
  --border-subtle: rgba(15, 23, 42, 0.08);
  --accent: #0ea5e9;
  --accent-soft: rgba(14, 165, 233, 0.12);
  --accent-strong: #0284c7;
  --fg: #0f172a;
  --fg-soft: #4b5563;
  --fg-muted: #6b7280;
  --shadow-soft: 0 16px 38px rgba(15, 23, 42, 0.15);
}

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: radial-gradient(circle at top left, #0b1120 0, var(--bg) 45%);
  color: var(--fg);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  transition: background var(--transition-med), color var(--transition-med);
}

/* ====== UTILIDADES ====== */

.container {
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

.section {
  padding: 5rem 0;
}

.section-alt {
  background: radial-gradient(circle at top left, rgba(56, 189, 248, 0.08), transparent 55%);
}

.section-header {
  text-align: left;
  margin-bottom: 2.75rem;
}

.section-title {
  font-size: clamp(1.75rem, 2.3vw, 2rem);
  margin: 0 0 0.2rem;
  letter-spacing: -0.03em;
}

.section-subtitle {
  margin: 0;
  color: var(--fg-soft);
  max-width: 38rem;
  font-size: 0.98rem;
}

/* ====== TOPBAR ====== */

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  backdrop-filter: blur(20px);
  background: linear-gradient(to bottom,
      rgba(15, 23, 42, 0.92),
      rgba(15, 23, 42, 0.75),
      transparent);
  border-bottom: 1px solid rgba(148, 163, 184, 0.28);
}

body.theme-light .topbar {
  background: linear-gradient(to bottom,
      rgba(248, 250, 252, 0.9),
      rgba(248, 250, 252, 0.75),
      transparent);
  border-bottom-color: rgba(148, 163, 184, 0.18);
}

.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--nav-height);
  gap: 1.5rem;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-weight: 600;
  letter-spacing: -0.04em;
}

.logo-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-pill);
  background: radial-gradient(circle at 20% 0%, #38bdf8, #0f172a);
  color: #f9fafb;
  font-size: 0.9rem;
  box-shadow: 0 10px 30px rgba(56, 189, 248, 0.35);
}

.logo-text {
  font-size: 0.95rem;
  color: var(--fg-soft);
}

.nav {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  font-size: 0.9rem;
}

.nav a {
  text-decoration: none;
  color: var(--fg-soft);
  position: relative;
  padding: 0.3rem 0;
  transition: color var(--transition-fast), transform var(--transition-fast);
}

.nav a::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: -0.15rem;
  width: 0;
  height: 2px;
  border-radius: 999px;
  background: linear-gradient(to right, var(--accent), var(--accent-strong));
  transition: width var(--transition-fast);
}

.nav a:hover {
  color: var(--fg);
  transform: translateY(-1px);
}

.nav a:hover::after {
  width: 100%;
}

.topbar-controls {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.lang-select-wrapper {
  display: inline-flex;
  align-items: center;
  padding: 0.1rem;
  border-radius: var(--radius-pill);
  background: rgba(15, 23, 42, 0.75);
  border: 1px solid rgba(148, 163, 184, 0.35);
}

body.theme-light .lang-select-wrapper {
  background: rgba(255, 255, 255, 0.85);
}

#lang-switcher {
  border: none;
  background: transparent;
  color: var(--fg);
  font-size: 0.85rem;
  padding: 0.3rem 0.75rem;
  border-radius: var(--radius-pill);
  outline: none;
  cursor: pointer;
}

#lang-switcher option {
  color: #0f172a;
}

/* Icon button */

.icon-button {
  border: 1px solid rgba(148, 163, 184, 0.45);
  background: radial-gradient(circle at top left,
      rgba(56, 189, 248, 0.2),
      rgba(15, 23, 42, 0.95));
  color: #f9fafb;
  border-radius: 999px;
  width: 38px;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast),
    border-color var(--transition-fast), background var(--transition-fast);
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.75);
}

body.theme-light .icon-button {
  background: radial-gradient(circle at top left,
      rgba(14, 165, 233, 0.16),
      #ffffff);
  color: #0f172a;
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.18);
}

.icon-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 16px 40px rgba(15, 23, 42, 0.9);
  border-color: rgba(148, 163, 184, 0.75);
}

.theme-icon {
  font-size: 1.1rem;
  line-height: 1;
  display: none;
}

.theme-icon-sun {
  display: none;
}

body.theme-light .theme-icon-sun {
  display: inline;
}

body.theme-light .theme-icon-moon {
  display: none;
}

body:not(.theme-light) .theme-icon-moon {
  display: inline;
}

/* ====== HERO ====== */

.hero {
  padding: 4.5rem 0 4rem;
}

.hero-grid {
  display: grid;
  gap: 2.75rem;
}

.hero-text {
  max-width: 640px;
}

.hero-kicker {
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--accent);
  margin: 0 0 1rem;
}

.hero-title {
  font-size: clamp(2.3rem, 4vw, 2.9rem);
  margin: 0 0 0.4rem;
  letter-spacing: -0.05em;
}

.hero-name {
  display: block;
}

.hero-subtitle {
  margin: 0 0 0.75rem;
  color: var(--fg-soft);
  font-size: 1rem;
}

.hero-description {
  margin: 0 0 1.75rem;
  color: var(--fg-muted);
  font-size: 0.98rem;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.9rem;
  margin-bottom: 1.8rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-pill);
  padding: 0.65rem 1.4rem;
  font-size: 0.9rem;
  font-weight: 500;
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast),
    background var(--transition-fast), color var(--transition-fast),
    border-color var(--transition-fast);
}

.btn-primary {
  background: radial-gradient(circle at 10% 0%, var(--accent-strong), var(--accent));
  color: #f9fafb;
  box-shadow: 0 16px 40px rgba(8, 47, 73, 0.9);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 20px 48px rgba(8, 47, 73, 1);
}

.btn-ghost {
  border-color: rgba(148, 163, 184, 0.6);
  background: rgba(15, 23, 42, 0.7);
  color: var(--fg-soft);
}

body.theme-light .btn-ghost {
  background: rgba(255, 255, 255, 0.9);
}

.btn-ghost:hover {
  border-color: var(--accent);
  color: var(--fg);
}

.hero-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  font-size: 0.8rem;
}

.meta-item {
  padding: 0.35rem 0.8rem;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.5);
  background: linear-gradient(to right,
      rgba(15, 23, 42, 0.9),
      rgba(15, 23, 42, 0.6));
  color: var(--fg-soft);
}

body.theme-light .meta-item {
  background: rgba(255, 255, 255, 0.9);
}

/* Hero aside */

.hero-aside {
  max-width: 360px;
  margin-left: auto;
}

.profile-card {
  border-radius: var(--radius-lg);
  padding: 1.5rem 1.4rem;
  background: radial-gradient(circle at top, rgba(56, 189, 248, 0.16), transparent 50%),
    linear-gradient(to bottom right, rgba(15, 23, 42, 0.97), rgba(15, 23, 42, 0.9));
  border: 1px solid rgba(148, 163, 184, 0.45);
  box-shadow: var(--shadow-soft);
  display: grid;
  grid-template-columns: auto 1fr;
  column-gap: 1.1rem;
  row-gap: 0.75rem;
  align-items: center;
}

body.theme-light .profile-card {
  background: linear-gradient(to bottom right, #ffffff, #e5f6fd);
}

.profile-avatar {
  grid-row: 1 / span 2;
}

.avatar-placeholder {
  width: 72px;
  height: 72px;
  border-radius: 999px;
  background: conic-gradient(from 180deg, #38bdf8, #0ea5e9, #0284c7, #38bdf8);
  padding: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.avatar-placeholder span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  background: #020617;
  color: #e5e7eb;
  font-weight: 600;
  font-size: 1rem;
}

.profile-body {
  font-size: 0.9rem;
}

.profile-role {
  margin: 0 0 0.35rem;
  font-weight: 500;
}

.profile-text {
  margin: 0 0 0.65rem;
  color: var(--fg-soft);
  font-size: 0.85rem;
}

.profile-tags {
  list-style: none;
  display: flex;
  gap: 0.35rem;
  padding: 0;
  margin: 0;
  flex-wrap: wrap;
}

.profile-tags li {
  font-size: 0.75rem;
  padding: 0.15rem 0.6rem;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid rgba(148, 163, 184, 0.6);
  color: var(--fg-soft);
}

body.theme-light .profile-tags li {
  background: rgba(255, 255, 255, 0.9);
}

.profile-footer {
  grid-column: 1 / -1;
  border-top: 1px solid rgba(148, 163, 184, 0.4);
  padding-top: 0.6rem;
  margin-top: 0.2rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
}

.profile-link {
  font-size: 0.8rem;
  color: var(--fg-soft);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

.profile-link:hover {
  color: var(--accent-strong);
}

/* ====== ABOUT ====== */

.about-grid {
  display: grid;
  gap: 2.5rem;
}

.about-main p {
  margin-top: 0;
  margin-bottom: 1rem;
  color: var(--fg-soft);
  font-size: 0.95rem;
}

.about-side {
  display: grid;
  gap: 1.4rem;
}

.about-card {
  border-radius: var(--radius-md);
  padding: 1rem 1rem 1.1rem;
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid var(--border-subtle);
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.75);
}

body.theme-light .about-card {
  background: #ffffff;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.12);
}

.about-card h3 {
  margin-top: 0;
  margin-bottom: 0.45rem;
  font-size: 0.95rem;
}

.about-education {
  margin: 0;
  font-size: 0.88rem;
  color: var(--fg-soft);
}

.pill-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  font-size: 0.82rem;
}

.pill-list li {
  padding: 0.2rem 0.65rem;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.5);
  background: rgba(15, 23, 42, 0.85);
  color: var(--fg-soft);
}

body.theme-light .pill-list li {
  background: rgba(248, 250, 252, 0.9);
}

.bullet-list {
  list-style: none;
  padding-left: 0;
  margin: 0;
  font-size: 0.88rem;
  color: var(--fg-soft);
}

.bullet-list li {
  position: relative;
  padding-left: 1rem;
  margin-bottom: 0.25rem;
}

.bullet-list li::before {
  content: "•";
  position: absolute;
  left: 0;
  top: 0;
  color: var(--accent);
}

/* ====== SKILLS ====== */

.skills-grid {
  display: grid;
  gap: 2rem;
}

.skills-column {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.skills-group-title {
  font-size: 0.95rem;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--fg-muted);
}

.skill-card {
  border-radius: 18px;
  padding: 1rem 1rem 0.85rem;
  background: rgba(15, 23, 42, 0.92);
  border: 1px solid rgba(148, 163, 184, 0.45);
  box-shadow: 0 14px 35px rgba(15, 23, 42, 0.85);
  font-size: 0.87rem;
}

body.theme-light .skill-card {
  background: #ffffff;
  box-shadow: 0 10px 32px rgba(15, 23, 42, 0.16);
}

.skill-card-core {
  border-color: rgba(56, 189, 248, 0.8);
  box-shadow: 0 18px 45px rgba(8, 47, 73, 0.9);
}

.skill-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.4rem;
}

.skill-card-header h4 {
  margin: 0;
  font-size: 0.92rem;
}

.skill-chip {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  padding: 0.2rem 0.7rem;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  border: 1px solid rgba(56, 189, 248, 0.6);
}

.skill-description {
  margin: 0 0 0.6rem;
  color: var(--fg-soft);
}

.skill-bar {
  position: relative;
  width: 100%;
  height: 6px;
  border-radius: 999px;
  background: rgba(30, 64, 175, 0.35);
  overflow: hidden;
  margin-bottom: 0.35rem;
}

body.theme-light .skill-bar {
  background: rgba(148, 163, 184, 0.28);
}

.skill-bar-fill {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: calc(var(--level) * 100%);
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--accent-strong));
  box-shadow: 0 0 18px rgba(56, 189, 248, 0.7);
  transform-origin: left;
}

.skill-meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--fg-muted);
}

/* ====== TIMELINE ====== */

.timeline {
  display: grid;
  gap: 1.8rem;
  max-width: 800px;
}

.timeline-item {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 1rem;
  align-items: flex-start;
}

.timeline-badge {
  font-size: 0.8rem;
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.6);
  color: var(--fg-soft);
  background: rgba(15, 23, 42, 0.92);
}

body.theme-light .timeline-badge {
  background: #ffffff;
}

.timeline-card {
  border-radius: 18px;
  padding: 1.1rem 1.1rem 1rem;
  border: 1px solid var(--border-subtle);
  background: rgba(15, 23, 42, 0.9);
  box-shadow: 0 14px 32px rgba(15, 23, 42, 0.9);
}

body.theme-light .timeline-card {
  background: #ffffff;
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.16);
}

.timeline-role {
  margin: 0 0 0.15rem;
  font-size: 0.95rem;
}

.timeline-company {
  margin: 0 0 0.6rem;
  font-size: 0.85rem;
  color: var(--fg-muted);
}

/* ====== PROYECTOS ====== */

.projects-grid {
  display: grid;
  gap: 1.5rem;
}

.project-card {
  border-radius: 18px;
  padding: 1.3rem 1.25rem 1.1rem;
  background: rgba(15, 23, 42, 0.96);
  border: 1px solid rgba(148, 163, 184, 0.5);
  box-shadow: 0 16px 38px rgba(15, 23, 42, 0.9);
}

body.theme-light .project-card {
  background: #ffffff;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.14);
}

.project-header {
  display: flex;
  gap: 0.75rem;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 0.3rem;
}

.project-header h3 {
  margin: 0;
  font-size: 0.98rem;
}

.project-tag {
  font-size: 0.7rem;
  padding: 0.2rem 0.7rem;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid rgba(148, 163, 184, 0.6);
  color: var(--fg-soft);
}

body.theme-light .project-tag {
  background: rgba(248, 250, 252, 0.96);
}

.project-description {
  margin: 0.35rem 0 0.6rem;
  font-size: 0.9rem;
  color: var(--fg-soft);
}

.project-meta {
  list-style: none;
  padding-left: 0;
  margin: 0;
  font-size: 0.82rem;
  color: var(--fg-muted);
}

.project-meta li + li {
  margin-top: 0.2rem;
}

.projects-hint {
  margin-top: 1.8rem;
  font-size: 0.85rem;
  color: var(--fg-muted);
}

/* ====== CONTACTO ====== */

.contact-grid {
  display: grid;
  gap: 1.5rem;
}

.contact-card {
  border-radius: 18px;
  padding: 1.3rem 1.2rem 1.1rem;
  background: rgba(15, 23, 42, 0.96);
  border: 1px solid var(--border-subtle);
  box-shadow: 0 16px 38px rgba(15, 23, 42, 0.9);
}

body.theme-light .contact-card {
  background: #ffffff;
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.14);
}

.contact-card h3 {
  margin-top: 0;
  margin-bottom: 0.4rem;
  font-size: 0.96rem;
}

.contact-list {
  list-style: none;
  padding-left: 0;
  margin: 0;
  font-size: 0.86rem;
}

.contact-list li {
  display: flex;
  flex-direction: column;
  margin-bottom: 0.6rem;
}

.contact-list span {
  color: var(--fg-muted);
  font-size: 0.78rem;
}

.contact-list a {
  color: var(--fg-soft);
  text-decoration: none;
}

.contact-list a:hover {
  color: var(--accent-strong);
}

.form-row {
  display: flex;
  flex-direction: column;
  margin-bottom: 0.7rem;
}

.form-row label {
  font-size: 0.83rem;
  margin-bottom: 0.15rem;
  color: var(--fg-soft);
}

.form-row input,
.form-row textarea {
  border-radius: 12px;
  border: 1px solid rgba(148, 163, 184, 0.6);
  padding: 0.55rem 0.7rem;
  font: inherit;
  color: var(--fg);
  background: rgba(15, 23, 42, 0.92);
  outline: none;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast),
    background var(--transition-fast);
}

body.theme-light .form-row input,
body.theme-light .form-row textarea {
  background: #ffffff;
}

.form-row input:focus,
.form-row textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(56, 189, 248, 0.4);
}

.form-status {
  min-height: 1.1rem;
  margin-top: 0.5rem;
  font-size: 0.8rem;
  color: var(--fg-muted);
}

/* ====== FOOTER ====== */

.footer {
  border-top: 1px solid rgba(15, 23, 42, 0.95);
  padding: 1.5rem 0 1.75rem;
  margin-top: 2rem;
  background: linear-gradient(to top, rgba(15, 23, 42, 0.98), transparent);
}

body.theme-light .footer {
  border-top-color: rgba(148, 163, 184, 0.26);
  background: linear-gradient(to top, #f9fafb, transparent);
}

.footer-inner {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.8rem;
  color: var(--fg-muted);
}

.footer-secondary {
  opacity: 0.9;
}

/* ====== ACCESIBILIDAD ====== */

.visually-hidden {
  border: 0;
  clip: rect(0 0 0 0);
  height: 1px;
  margin: -1px;
  overflow: hidden;
  padding: 0;
  position: absolute;
  width: 1px;
}

/* ====== RESPONSIVE ====== */

@media (min-width: 768px) {
  .hero-grid {
    grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr);
    align-items: center;
  }

  .about-grid {
    grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
  }

  .skills-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .contact-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .projects-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .footer-inner {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
  }
}

@media (max-width: 900px) {
  .nav {
    display: none;
  }

  .topbar-inner {
    justify-content: space-between;
  }
}

@media (max-width: 640px) {
  .hero {
    padding-top: 3.5rem;
  }

  .profile-card {
    grid-template-columns: 1fr;
  }

  .profile-avatar {
    justify-self: flex-start;
  }
}