/* =========================================================
   Robert Raúl Armejo — Portafolio
   Tema: Dark Tech (por defecto) + Light, con toggle
   ========================================================= */

/* ---------- TOKENS: tema oscuro (por defecto) ---------- */
:root {
  --bg:        #070b16;
  --bg-alt:    rgba(255, 255, 255, .025);
  --surface:   rgba(255, 255, 255, .04);
  --surface-2: rgba(255, 255, 255, .06);
  --text:      #e9eefb;
  --text-soft: #97a3bd;
  --border:    rgba(255, 255, 255, .09);
  --border-2:  rgba(255, 255, 255, .14);

  --primary:   #38bdf8;          /* cian-sky */
  --primary-2: #3b82f6;          /* azul */
  --accent:    #22d3ee;
  --grad:      linear-gradient(120deg, #22d3ee 0%, #3b82f6 100%);

  --grid-line: rgba(120, 160, 220, .055);
  --glow-1:    rgba(34, 211, 238, .14);
  --glow-2:    rgba(59, 130, 246, .16);

  --shadow:    0 18px 50px -20px rgba(0, 0, 0, .7);
  --glow-shadow: 0 10px 40px -10px rgba(56, 189, 248, .45);
  --radius:    16px;
  --maxw:      1120px;
  --font:      'Inter', system-ui, sans-serif;
  --font-head: 'Sora', 'Inter', sans-serif;

  --title-grad: linear-gradient(120deg, #ffffff 20%, #38bdf8 75%, #3b82f6 100%);
  --hero-bg: radial-gradient(1200px circle at 70% -10%, rgba(59,130,246,.10), transparent 60%);
}

/* ---------- TOKENS: tema claro ---------- */
html[data-theme="light"] {
  --bg:        #ffffff;
  --bg-alt:    #f5f8fc;
  --surface:   #ffffff;
  --surface-2: #ffffff;
  --text:      #16203a;
  --text-soft: #5b677d;
  --border:    #e6eaf1;
  --border-2:  #d7deea;

  --primary:   #2563eb;
  --primary-2: #0ea5e9;
  --accent:    #06b6d4;
  --grad:      linear-gradient(120deg, #2563eb 0%, #06b6d4 100%);

  --grid-line: rgba(37, 99, 235, .045);
  --glow-1:    rgba(37, 99, 235, .07);
  --glow-2:    rgba(6, 182, 212, .07);

  --shadow:    0 14px 40px -16px rgba(20, 40, 80, .22);
  --glow-shadow: 0 12px 34px -12px rgba(37, 99, 235, .35);

  --title-grad: linear-gradient(120deg, #16203a 25%, #2563eb 100%);
  --hero-bg: radial-gradient(1200px circle at 70% -10%, rgba(37,99,235,.07), transparent 60%);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  transition: background .4s ease, color .4s ease;
}

/* Fondo global: grid técnico + destellos */
body::before {
  content: ""; position: fixed; inset: 0; z-index: -2; pointer-events: none;
  background-image:
    linear-gradient(var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
  background-size: 52px 52px;
  -webkit-mask-image: radial-gradient(circle at 50% 0%, #000 0%, transparent 75%);
          mask-image: radial-gradient(circle at 50% 0%, #000 0%, transparent 75%);
}
body::after {
  content: ""; position: fixed; inset: 0; z-index: -2; pointer-events: none;
  background:
    radial-gradient(620px circle at 12% 8%, var(--glow-1), transparent 55%),
    radial-gradient(720px circle at 88% 30%, var(--glow-2), transparent 55%);
}

a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }
.container { width: 90%; max-width: var(--maxw); margin: 0 auto; }

/* ---------- Botones ---------- */
.btn {
  display: inline-flex; align-items: center; gap: .5rem;
  padding: .82rem 1.6rem; border-radius: 999px;
  font-weight: 600; font-size: .95rem; font-family: inherit;
  cursor: pointer; border: 1px solid transparent;
  transition: transform .2s ease, box-shadow .25s ease, background .25s ease, border-color .25s ease;
}
.btn--primary { background: var(--grad); color: #06121f; box-shadow: var(--glow-shadow); }
html[data-theme="light"] .btn--primary { color: #fff; }
.btn--primary:hover { transform: translateY(-2px); box-shadow: 0 16px 46px -10px rgba(56,189,248,.6); }
.btn--ghost { background: var(--surface); color: var(--text); border-color: var(--border-2); backdrop-filter: blur(8px); }
.btn--ghost:hover { border-color: var(--primary); color: var(--primary); transform: translateY(-2px); }

/* ---------- Header / Nav ---------- */
.site-header {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  background: color-mix(in srgb, var(--bg) 72%, transparent);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid transparent;
  transition: border-color .3s ease, background .3s ease;
}
.site-header.scrolled { border-color: var(--border); }
.nav { display: flex; align-items: center; justify-content: space-between; height: 70px; }
.nav__logo { font-family: var(--font-head); font-weight: 800; font-size: 1.4rem; letter-spacing: -.02em; }
.nav__logo span { color: var(--primary); }
.nav__menu { display: flex; align-items: center; gap: 1.8rem; list-style: none; }
.nav__menu a { font-weight: 500; font-size: .93rem; color: var(--text-soft); transition: color .2s; }
.nav__menu a:hover { color: var(--text); }
.nav__lang button, .nav__theme button {
  border: 1px solid var(--border-2); background: var(--surface);
  border-radius: 999px; font-weight: 600; cursor: pointer; color: var(--text);
  transition: all .2s; backdrop-filter: blur(8px);
}
.nav__lang button { padding: .42rem .8rem; font-size: .78rem; }
.nav__theme button { width: 38px; height: 38px; font-size: 1rem; display: grid; place-items: center; }
.nav__lang button:hover, .nav__theme button:hover { border-color: var(--primary); color: var(--primary); }
.nav__toggle { display: none; flex-direction: column; gap: 5px; background: none; border: none; cursor: pointer; }
.nav__toggle span { width: 24px; height: 2px; background: var(--text); border-radius: 2px; transition: .3s; }

/* ---------- Hero ---------- */
.hero {
  position: relative; min-height: 100vh;
  display: flex; align-items: center; overflow: hidden;
  background: var(--hero-bg);
}
#hero-canvas { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 0; }
.hero__content { position: relative; z-index: 2; max-width: 780px; padding-top: 70px; }
.hero__eyebrow {
  display: inline-block; color: var(--primary); font-weight: 600; letter-spacing: .03em;
  margin-bottom: 1rem; padding: .35rem .9rem; border: 1px solid var(--border-2);
  border-radius: 999px; background: var(--surface); backdrop-filter: blur(8px); font-size: .88rem;
}
.hero__title {
  font-family: var(--font-head); font-weight: 800;
  font-size: clamp(2.8rem, 8vw, 5.2rem); line-height: 1.04; letter-spacing: -.02em;
  background: var(--title-grad);
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}
.hero__subtitle { font-family: var(--font-head); font-size: clamp(1.2rem, 3vw, 1.85rem); color: var(--text); margin: .6rem 0 1.2rem; font-weight: 600; }
.hero__desc { font-size: 1.12rem; color: var(--text-soft); max-width: 580px; margin-bottom: 2rem; }
.hero__actions { display: flex; gap: 1rem; flex-wrap: wrap; }
.hero__scroll { position: absolute; bottom: 2rem; left: 50%; transform: translateX(-50%); z-index: 2; font-size: 1.4rem; color: var(--primary); animation: bounce 2s infinite; }
@keyframes bounce { 0%,100% { transform: translate(-50%, 0); } 50% { transform: translate(-50%, 10px); } }

/* ---------- Secciones ---------- */
.section { padding: 6.5rem 0; position: relative; }
.section--alt { background: var(--bg-alt); border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.section__head { text-align: center; margin-bottom: 3.5rem; }
.section__label {
  display: inline-block; font-weight: 700; font-size: .78rem; letter-spacing: .14em;
  text-transform: uppercase; margin-bottom: .7rem;
  background: var(--grad); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}
.section__title { font-family: var(--font-head); font-size: clamp(1.8rem, 4vw, 2.7rem); font-weight: 700; letter-spacing: -.02em; }

/* Sobre mí */
.section__grid { display: grid; grid-template-columns: .9fr 1.4fr; gap: 4rem; align-items: center; }
.about__photo { position: relative; }
.about__photo::before {
  content: ""; position: absolute; inset: -14px; border-radius: 22px;
  background: var(--grad); opacity: .35; filter: blur(28px); z-index: -1;
}
.about__photo img {
  width: 100%; aspect-ratio: 4/5; object-fit: cover;
  border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--border-2);
}
.about__photo img.is-placeholder, .card__media img.is-placeholder {
  background: linear-gradient(135deg, var(--surface-2), var(--surface)); min-height: 220px; position: relative;
}
.about__photo img.is-placeholder::after, .card__media img.is-placeholder::after {
  content: "Imagen"; position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  color: var(--text-soft); font-weight: 600; font-size: .9rem;
}
.about__text p { color: var(--text-soft); margin-bottom: 1rem; }
.about__stats { display: flex; gap: 2.5rem; margin-top: 2rem; flex-wrap: wrap; }
.about__stats strong { display: block; font-family: var(--font-head); font-size: 2.1rem; background: var(--grad); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.about__stats span { color: var(--text-soft); font-size: .9rem; }

/* Proyectos */
.projects { display: grid; grid-template-columns: repeat(auto-fill, minmax(310px, 1fr)); gap: 2rem; }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; display: flex; flex-direction: column; backdrop-filter: blur(10px);
  transition: transform .3s ease, box-shadow .3s ease, border-color .3s ease;
}
.card:hover { transform: translateY(-6px); box-shadow: var(--shadow); border-color: var(--border-2); }
.card__media { position: relative; aspect-ratio: 16/10; overflow: hidden; cursor: pointer; background: var(--surface-2); }
.card__media img { width: 100%; height: 100%; object-fit: cover; transition: transform .4s ease; }
.card:hover .card__media img { transform: scale(1.05); }
.card__badge {
  position: absolute; top: .8rem; left: .8rem; background: var(--grad); color: #06121f;
  font-size: .7rem; font-weight: 800; padding: .32rem .72rem; border-radius: 999px; letter-spacing: .04em;
}
html[data-theme="light"] .card__badge { color: #fff; }
.card__body { padding: 1.5rem; display: flex; flex-direction: column; flex: 1; }
.card__title { font-family: var(--font-head); font-size: 1.25rem; margin-bottom: .5rem; }
.card__desc { color: var(--text-soft); font-size: .94rem; flex: 1; }
.card__tags { list-style: none; display: flex; flex-wrap: wrap; gap: .5rem; margin: 1rem 0; }
.card__tags li { background: var(--surface-2); color: var(--text-soft); font-size: .73rem; font-weight: 600; padding: .26rem .66rem; border-radius: 999px; border: 1px solid var(--border); }
.card__links { display: flex; gap: 1.2rem; align-items: center; }
.card__links a, .card__gallery-btn {
  color: var(--primary); font-weight: 600; font-size: .9rem; background: none; border: none; cursor: pointer; font-family: inherit; padding: 0; transition: color .2s;
}
.card__links a:hover, .card__gallery-btn:hover { color: var(--accent); }

/* Experiencia & Educación */
.timeline-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 3.5rem; }
.timeline-grid__h { font-family: var(--font-head); font-size: 1.15rem; margin-bottom: 1.5rem; }
.timeline { position: relative; padding-left: 1.5rem; border-left: 2px solid var(--border); }
.timeline__item { position: relative; padding-bottom: 1.8rem; }
.timeline__item:last-child { padding-bottom: 0; }
.timeline__item::before {
  content: ""; position: absolute; left: calc(-1.5rem - 6px); top: .3rem; width: 11px; height: 11px;
  border-radius: 50%; background: var(--grad); box-shadow: 0 0 0 4px color-mix(in srgb, var(--primary) 18%, transparent);
}
.timeline__date { color: var(--primary); font-weight: 700; font-size: .8rem; letter-spacing: .03em; }
.timeline__item h4 { font-family: var(--font-head); font-size: 1.05rem; margin: .3rem 0; }
.timeline__org { color: var(--text); font-weight: 600; font-size: .92rem; margin-bottom: .4rem; }
.timeline__item p { color: var(--text-soft); font-size: .92rem; }
.certs { list-style: none; display: flex; flex-direction: column; gap: .55rem; }
.certs li { position: relative; padding-left: 1.4rem; color: var(--text-soft); font-size: .92rem; }
.certs li::before { content: "✓"; position: absolute; left: 0; color: var(--primary); font-weight: 800; }

/* Habilidades */
.skills-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 2rem; }
.skills-cat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.5rem; backdrop-filter: blur(10px); transition: border-color .3s, transform .3s; }
.skills-cat:hover { border-color: var(--border-2); transform: translateY(-3px); }
.skills-cat h3 { font-family: var(--font-head); font-size: 1rem; margin-bottom: 1rem; background: var(--grad); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.skills { display: flex; flex-wrap: wrap; gap: .7rem; }
.skill { background: var(--surface-2); border: 1px solid var(--border); padding: .6rem 1.1rem; border-radius: 999px; font-weight: 600; font-size: .9rem; transition: all .2s ease; }
.skill:hover { border-color: var(--primary); color: var(--primary); transform: translateY(-3px); }

/* Contacto */
.contact { text-align: center; max-width: 640px; }
.contact__desc { color: var(--text-soft); font-size: 1.1rem; margin: 1rem 0 2rem; }
.contact__links { display: flex; gap: 1rem; justify-content: center; flex-wrap: wrap; }

/* Footer */
.footer { padding: 2.5rem 0; border-top: 1px solid var(--border); }
.footer__inner { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 1rem; color: var(--text-soft); font-size: .9rem; }

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

/* ---------- Lightbox ---------- */
.lightbox { position: fixed; inset: 0; z-index: 200; background: rgba(4, 7, 15, .94); display: none; align-items: center; justify-content: center; opacity: 0; transition: opacity .25s ease; backdrop-filter: blur(6px); }
.lightbox.open { display: flex; opacity: 1; }
.lightbox__figure { margin: 0; max-width: 90vw; max-height: 88vh; text-align: center; }
.lightbox__figure img { max-width: 90vw; max-height: 80vh; border-radius: 10px; box-shadow: 0 20px 60px -20px rgba(0,0,0,.8); border: 1px solid var(--border-2); }
.lightbox__figure figcaption { color: #cbd5e1; margin-top: .9rem; font-size: .9rem; }
.lightbox__close, .lightbox__nav { position: absolute; background: rgba(255,255,255,.1); color: #fff; border: none; cursor: pointer; border-radius: 50%; width: 48px; height: 48px; font-size: 1.6rem; line-height: 1; display: flex; align-items: center; justify-content: center; transition: background .2s; }
.lightbox__close:hover, .lightbox__nav:hover { background: rgba(56,189,248,.4); }
.lightbox__close { top: 1.5rem; right: 1.5rem; }
.lightbox__prev { left: 1.5rem; top: 50%; transform: translateY(-50%); }
.lightbox__next { right: 1.5rem; top: 50%; transform: translateY(-50%); }

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
  .section { padding: 4.5rem 0; }
  .section__head { margin-bottom: 2.5rem; }
  .section__grid { grid-template-columns: 1fr; gap: 2.5rem; }
  .about__photo { max-width: 320px; margin: 0 auto; }
  .about__stats { gap: 1.8rem; }
  .timeline-grid { grid-template-columns: 1fr; gap: 2.5rem; }
  .hero__content { padding-top: 88px; }
  .hero__desc { font-size: 1.04rem; }
  .footer__inner { justify-content: center; text-align: center; }

  .nav__toggle { display: flex; }
  .nav__menu {
    position: fixed; top: 70px; right: 0; height: calc(100dvh - 70px); width: min(82%, 320px);
    flex-direction: column; align-items: flex-start; gap: 1.5rem; padding: 2.2rem 1.8rem;
    background: var(--bg); border-left: 1px solid var(--border);
    box-shadow: -24px 0 50px -24px rgba(0, 0, 0, .7);
    transform: translateX(100%); transition: transform .3s ease;
    overflow-y: auto;
  }
  .nav__menu a { font-size: 1.06rem; color: var(--text); }
  .nav__menu.open { transform: translateX(0); }
  .nav__toggle.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
  .nav__toggle.open span:nth-child(2) { opacity: 0; }
  .nav__toggle.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }
}

@media (max-width: 480px) {
  .container { width: 88%; }
  .hero__actions { width: 100%; }
  .hero__actions .btn { flex: 1; justify-content: center; }
  .about__stats { gap: 1.4rem; }
  .about__stats strong { font-size: 1.8rem; }
  .contact__links { flex-direction: column; }
  .contact__links .btn { justify-content: center; }
  .lightbox__close { top: 1rem; right: 1rem; }
  .lightbox__prev { left: .4rem; }
  .lightbox__next { right: .4rem; }
  .lightbox__nav, .lightbox__close { width: 42px; height: 42px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
