:root {
  --bg: #09090b;
  --bg-card: #18181b;
  --bg-hover: #27272a;
  --border: #27272a;
  --border-hover: #3f3f46;
  --text-main: #fafafa;
  --text-muted: #a1a1aa;
  --accent: #ffffff;
  --accent-text: #000000;
  --shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
  --ring: rgba(255, 255, 255, 0.1);
  --glass: rgba(24, 24, 27, 0.7);
  --grid: rgba(255, 255, 255, 0.03);
  --glow-1: rgba(124, 58, 237, 0.12);
  /* Morado suave */
  --glow-2: rgba(56, 189, 248, 0.12);
  /* Azul suave */
}

[data-theme="light"] {
  --bg: #f4f4f5;
  --bg-card: #ffffff;
  --bg-hover: #e4e4e7;
  --border: #d4d4d8;
  --border-hover: #a1a1aa;
  --text-main: #09090b;
  --text-muted: #52525b;
  --accent: #09090b;
  --accent-text: #ffffff;
  --shadow: 0 6px 24px rgba(0, 0, 0, 0.08);
  --ring: rgba(0, 0, 0, 0.12);
  --glass: rgba(255, 255, 255, 0.85);
  --grid: rgba(0, 0, 0, 0.06);
  --glow-1: rgba(124, 58, 237, 0.12);
  --glow-2: rgba(56, 189, 248, 0.12);
}

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

html {
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background-color: var(--bg);
  background-image:
    linear-gradient(to right, var(--grid) 1px, transparent 1px),
    linear-gradient(to bottom, var(--grid) 1px, transparent 1px);
  background-size: 40px 40px;
  background-position: center top;
  color: var(--text-main);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
  position: relative;
}

/* Background Glowing Orbs */
body::before,
body::after {
  content: "";
  position: fixed;
  border-radius: 50%;
  filter: blur(120px);
  z-index: -1;
  pointer-events: none;
}

body::before {
  top: -100px;
  left: -100px;
  width: 50vw;
  height: 50vh;
  background: var(--glow-1);
  animation: moveGlow1 25s infinite alternate ease-in-out;
}

body::after {
  bottom: -100px;
  right: -100px;
  width: 50vw;
  height: 50vh;
  background: var(--glow-2);
  animation: moveGlow2 20s infinite alternate ease-in-out;
}

@keyframes moveGlow1 {
  0% {
    transform: translate(0, 0) scale(1);
  }

  100% {
    transform: translate(50px, 50px) scale(1.1);
  }
}

@keyframes moveGlow2 {
  0% {
    transform: translate(0, 0) scale(1);
  }

  100% {
    transform: translate(-50px, -50px) scale(1.1);
  }
}

/* Typography */
h1,
h2,
h3,
h4 {
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.03em;
  color: var(--text-main);
}

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

/* Layout Utilities */
.main {
  max-width: 900px;
  margin: 0 auto;
  padding: 0 24px 100px;
}

.section {
  margin-top: 100px;
}

.section-header {
  margin-bottom: 32px;
}

.section h2 {
  font-size: 2rem;
  margin-bottom: 8px;
}

.section-desc {
  color: var(--text-muted);
  font-size: 1.125rem;
}

/* Reading Progress Bar */
.reading-bar {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  width: 0%;
  background: linear-gradient(to right, #7c3aed, #38bdf8);
  z-index: 200;
  transition: width 0.1s linear;
  border-radius: 0 2px 2px 0;
}

/* Cursor Glow */
.cursor-glow {
  position: fixed;
  width: 300px;
  height: 300px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(124, 58, 237, 0.12), transparent 70%);
  pointer-events: none;
  z-index: 0;
  transform: translate(-50%, -50%);
  transition: opacity 0.3s ease;
  will-change: transform;
  top: 0;
  left: 0;
}

[data-theme="light"] .cursor-glow {
  background: radial-gradient(circle, rgba(124, 58, 237, 0.07), transparent 70%);
}

/* Header */
.site-header {
  position: fixed;
  top: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  width: 90%;
  max-width: 1200px;
  z-index: 1000;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 28px;
  background: rgba(10, 10, 10, 0.4);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 100px;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.site-header.scrolled {
  top: 1rem;
  width: 85%;
  background: rgba(10, 10, 10, 0.8);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.5);
  padding: 8px 24px;
}

.brand {
  font-weight: 700;
  font-size: 1.125rem;
  letter-spacing: -0.02em;
  text-decoration: none;
  color: var(--text-main);
  transition: opacity 0.2s ease;
}

.brand:hover {
  opacity: 0.8;
}


.nav {
  display: flex;
  gap: 24px;
}

.nav a {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.9375rem;
  font-weight: 500;
  transition: color 0.2s;
  position: relative;
  padding-bottom: 2px;
}

.nav a::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 0;
  height: 2px;
  background: linear-gradient(to right, #7c3aed, #38bdf8);
  border-radius: 2px;
  transition: width 0.3s ease;
}

.nav a:hover,
.nav a.active {
  color: var(--text-main);
}

.nav a:hover::after,
.nav a.active::after {
  width: 100%;
}

.theme-fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-main);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  cursor: pointer;
  z-index: 100;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.theme-fab:hover {
  transform: translateY(-5px) scale(1.05);
  box-shadow: 0 8px 24px var(--glow-1);
  border-color: var(--border-hover);
  background: var(--bg-hover);
}

/* Hero Section */
.hero {
  margin-top: 150px;
}

/* Animations Scroll Reveal */
.reveal {
  opacity: 0;
  transform: translateY(30px);
  transition: all 0.8s cubic-bezier(0.5, 0, 0, 1);
}

.reveal.visible {
  opacity: 1;
  transform: translateY(0);
}

/* Utilities */
.text-gradient {
  background: linear-gradient(to right, #7c3aed, #38bdf8, #7c3aed);
  background-size: 200% auto;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: gradientText 4s linear infinite;
}

[data-theme="light"] .text-gradient {
  background: linear-gradient(to right, #6d28d9, #0284c7, #6d28d9);
  background-size: 200% auto;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

@keyframes gradientText {
  to {
    background-position: 200% center;
  }
}

.caret {
  display: inline-block;
  vertical-align: baseline;
  width: 3px;
  height: 1em;
  background-color: #7c3aed;
  margin-left: 4px;
  position: relative;
  top: 0.15em;
  animation: blink 0.8s step-end infinite;
  user-select: none;
}

@keyframes blink {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0;
  }
}

/* Hero Section */
.hero {
  margin-top: 150px;
}

.hero-flex {
  display: flex;
  align-items: center;
  gap: 48px;
  justify-content: space-between;
}

.hero-text {
  flex: 2;
  /* Aún más espacio para el texto */
}

.hero-visual {
  flex: 0.4;
  /* Reducido para dar prioridad al título */
  display: flex;
  justify-content: center;
  align-items: center;
  perspective: 1000px;
}

.logo-orb {
  position: relative;
  width: 250px;
  height: 250px;
  display: flex;
  justify-content: center;
  align-items: center;
  animation: floatOrb 8s infinite ease-in-out;
}

.hero-main-logo {
  width: 140px;
  height: auto;
  z-index: 2;
  filter: drop-shadow(0 0 20px rgba(124, 58, 237, 0.3));
  transition: all 0.5s ease-out;
}

.logo-orb:hover .hero-main-logo {
  filter: drop-shadow(0 0 40px rgba(124, 58, 237, 0.5));
}

.orb-ring {
  position: absolute;
  width: 100%;
  height: 100%;
  border: 2px solid rgba(124, 58, 237, 0.15);
  border-radius: 50%;
  animation: rotateRing 15s linear infinite;
}

.orb-ring::before {
  content: '';
  position: absolute;
  top: -5px;
  left: 50%;
  width: 10px;
  height: 10px;
  background: #7c3aed;
  border-radius: 50%;
  box-shadow: 0 0 15px #7c3aed;
}

.orb-glow {
  position: absolute;
  width: 180px;
  height: 180px;
  background: radial-gradient(circle, rgba(124, 58, 237, 0.2), transparent 70%);
  border-radius: 50%;
  filter: blur(20px);
  animation: pulseGlow 4s infinite ease-in-out;
}

@keyframes floatOrb {

  0%,
  100% {
    transform: translateY(0) rotate(0);
  }

  50% {
    transform: translateY(-20px) rotate(2deg);
  }
}

@keyframes rotateRing {
  from {
    transform: rotate(0);
  }

  to {
    transform: rotate(360deg);
  }
}

@keyframes pulseGlow {

  0%,
  100% {
    transform: scale(1);
    opacity: 0.5;
  }

  50% {
    transform: scale(1.3);
    opacity: 0.8;
  }
}

.hero h1.hero-title {
  font-size: 2.8rem;
  /* Reducido para máxima estabilidad en una línea */
  margin-bottom: 24px;
  line-height: 1.2;
  letter-spacing: -0.04em;
  min-height: 2.5em;
  /* Asegura que el espacio sea constante */
}

#typewriterText {
  display: inline-block;
  min-width: 1ch;
}

.hero p.hero-desc {
  font-size: 1.25rem;
  color: var(--text-muted);
  max-width: 700px;
  margin-bottom: 32px;
}

.badges {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 32px;
}

.badge {
  padding: 6px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 99px;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-main);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 20px;
  font-size: 0.9375rem;
  font-weight: 600;
  border-radius: 8px;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.2s ease;
  border: 1px solid transparent;
}

.btn.primary {
  background: var(--accent);
  color: var(--accent-text);
  box-shadow: 0 4px 14px var(--ring);
}

.btn.primary:hover {
  opacity: 0.9;
  transform: translateY(-1px);
}

.btn.ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--text-main);
}

.btn.ghost:hover {
  background: var(--bg-hover);
  border-color: var(--border-hover);
}

.btn.small {
  padding: 6px 14px;
  font-size: 0.875rem;
}

/* Social & CTA Base */
.cta-group {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.social {
  display: flex;
  gap: 12px;
}

.icon-link {
  width: 42px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  border: 1px solid var(--border);
  color: var(--text-muted);
  text-decoration: none;
  transition: all 0.2s ease;
}

.icon-link:hover {
  background: var(--bg-hover);
  color: var(--text-main);
  border-color: var(--border-hover);
}

/* Cards Shared */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
  transition: border-color 0.3s ease, transform 0.3s ease, box-shadow 0.3s ease;
}

/* Timeline */
.timeline {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.timeline-item {
  padding: 24px;
}

.item-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 12px;
  gap: 16px;
  flex-wrap: wrap;
}

.item-header h3 {
  font-size: 1.25rem;
  margin: 0;
}

.periodo {
  font-size: 0.875rem;
  color: var(--text-muted);
  font-weight: 500;
}

.list {
  padding-left: 20px;
  color: var(--text-muted);
  margin-top: 12px;
}

.list li {
  margin-bottom: 8px;
}

/* Projects */
.projects-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 20px;
  margin-bottom: 24px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
}

.projects {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 24px;
}

.project-cover {
  width: 100%;
  height: 240px;
  object-fit: cover;
  object-position: top center;
  border-bottom: 1px solid var(--border);
  transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  transform-origin: center;
}

.project {
  display: flex;
  flex-direction: column;
  height: 100%;
  transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1),
    border-color 0.35s ease,
    box-shadow 0.35s ease;
}

.project:hover {
  border-color: rgba(255, 255, 255, 0.55);
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.2),
    0 16px 40px rgba(0, 0, 0, 0.4),
    0 0 24px rgba(124, 58, 237, 0.25);
  transform: translateY(-8px);
}

[data-theme="light"] .project:hover {
  border-color: rgba(0, 0, 0, 0.35);
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.15),
    0 16px 40px rgba(0, 0, 0, 0.12),
    0 0 20px rgba(124, 58, 237, 0.15);
}

.project:hover .project-cover {
  transform: scale(1.08);
}

.project-body {
  padding: 24px;
  display: flex;
  flex-direction: column;
  flex-grow: 1;
  background: var(--bg-card);
  /* Ensure it covers the image zoom overflow */
  z-index: 10;
}

.project-body h3 {
  font-size: 1.25rem;
  margin-bottom: 8px;
}

.project-body p {
  color: var(--text-muted);
  margin-bottom: 20px;
  font-size: 0.9375rem;
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 24px;
}

.project-body .btn {
  margin-top: auto;
  align-self: flex-start;
}

.tag {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text-main);
  padding: 4px 12px;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  line-height: 1.5;
}

.tag-sm {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 0.7rem;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  line-height: 1.5;
}

/* Tech Grid */
.tech-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 24px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  font-size: 0.9375rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.chip:hover,
.chip.active {
  background: var(--bg-hover);
  border-color: var(--border-hover);
  transform: translateY(-2px);
}

.chip.active {
  border-color: var(--text-main);
  box-shadow: 0 4px 12px rgba(255, 255, 255, 0.05);
}

[data-theme="light"] .chip.active {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.chip-icon {
  width: 18px;
  height: 18px;
}

.tech-summary-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  min-height: 120px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  transition: all 0.3s ease;
}

.tech-summary-box.hidden {
  opacity: 0.5;
}

.tech-summary-box h3 {
  font-size: 1.25rem;
  margin-bottom: 8px;
  color: var(--text-main);
}

.tech-summary-box p {
  font-size: 0.9375rem;
  color: var(--text-muted);
}

/* About Grid */
.about-grid {
  display: flex;
  flex-direction: column;
  padding: 32px;
}

.about-info h3 {
  font-size: 1.5rem;
  margin-bottom: 16px;
}

.about-info p {
  color: var(--text-muted);
  margin-bottom: 24px;
}

.about-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 24px;
}

.about-chips .badge {
  background: var(--bg);
}

.stat {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
}

.stat-icon {
  font-size: 1.5rem;
}

.stat-text strong {
  display: block;
  font-size: 0.9375rem;
}

.stat-text span {
  font-size: 0.8125rem;
  color: var(--text-muted);
}

/* Contact Refined */
.contact-grid-refined {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}

.contact-link-card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 24px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  text-decoration: none;
  color: var(--text-main);
  transition: all 0.2s ease;
}

.contact-link-card:not(.static-card):hover {
  background: var(--bg-hover);
  border-color: var(--border-hover);
  transform: translateY(-2px);
}

.contact-link-card .icon {
  font-size: 1.5rem;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
}

.contact-text {
  display: flex;
  flex-direction: column;
}

.contact-label {
  font-size: 0.8125rem;
  color: var(--text-muted);
  font-weight: 500;
  margin-bottom: 2px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.contact-val {
  font-size: 1rem;
  font-weight: 500;
}

/* Empty State */
.projects-empty {
  display: none;
  padding: 48px 24px;
  text-align: center;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  margin-top: 24px;
}

.empty-icon {
  font-size: 3rem;
  margin-bottom: 16px;
}

/* Footer */
.footer {
  text-align: center;
  padding: 32px 24px;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  font-size: 0.875rem;
}

/* Utilities */
.reveal {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}

.reveal.visible {
  opacity: 1;
  transform: translateY(0);
}

.skip-link {
  position: absolute;
  left: -9999px;
}

.skip-link:focus {
  left: 20px;
  top: 20px;
  z-index: 100;
  background: var(--accent);
  color: var(--accent-text);
  padding: 12px 20px;
  border-radius: 8px;
  text-decoration: none;
  font-weight: 600;
}

/* Responsive */
@media (max-width: 768px) {
  .hero-logo {
    height: 60px;
  }

  .hero h1.hero-title {
    font-size: 2.25rem;
  }

  .hero p.hero-desc {
    font-size: 1.125rem;
  }

  .nav {
    display: none;
  }

  .site-header {
    width: 95%;
    top: 0.75rem;
    padding: 10px 20px;
  }

  .site-header.scrolled {
    width: 92%;
    top: 0.5rem;
  }

  .hero-flex {
    flex-direction: column;
    text-align: center;
    gap: 32px;
  }

  .hero-visual {
    order: -1;
    margin-bottom: 24px;
  }

  .logo-orb {
    width: 180px;
    height: 180px;
  }

  .hero-main-logo {
    width: 100px;
  }

  .hero p.hero-desc {
    margin: 0 auto 32px;
  }

  .badges {
    justify-content: center;
  }

  .social {
    justify-content: center;
  }

  .about-grid {
    grid-template-columns: 1fr;
    padding: 24px 16px;
  }

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

  .tech-grid {
    gap: 8px;
  }

  .chip {
    font-size: 0.85rem;
    padding: 8px 12px;
  }

  .contact-grid-refined {
    display: flex;
    flex-direction: column;
    gap: 16px;
  }

  .theme-fab {
    bottom: 16px;
    right: 16px;
    width: 45px;
    height: 45px;
  }

  .main {
    padding: 0 16px 80px;
  }
}