/* ============================================================
   Juan Carlos Cárdenas — Portfolio
   Modern dark theme with light-mode toggle
   ============================================================ */

:root {
  --bg: #0a0f1e;
  --bg-2: #0f1729;
  --surface: #131c31;
  --surface-2: #182339;
  --border: #223052;
  --text: #e6edf7;
  --text-dim: #97a4bd;
  --primary: #00b4d8;
  --primary-2: #0072c6;
  --accent: #7c5cff;
  --green: #2ecc71;
  --radius: 16px;
  --shadow: 0 20px 50px rgba(0, 0, 0, .45);
  --maxw: 1080px;
  --fira: "Fira Code", ui-monospace, monospace;
}

[data-theme="light"] {
  --bg: #f4f7fc;
  --bg-2: #ffffff;
  --surface: #ffffff;
  --surface-2: #eef2f9;
  --border: #d9e1ef;
  --text: #0d1730;
  --text-dim: #4d5c78;
  --shadow: 0 20px 50px rgba(20, 40, 90, .12);
}

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

html { scroll-behavior: smooth; }

body {
  font-family: "Inter", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  overflow-x: hidden;
  transition: background .4s ease, color .4s ease;
}

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

a { color: inherit; text-decoration: none; }
strong { color: var(--text); font-weight: 700; }

/* ---------- scroll progress ---------- */
.scroll-progress {
  position: fixed; top: 0; left: 0; height: 3px; width: 0%;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  z-index: 200; transition: width .1s linear;
}

/* ---------- nav ---------- */
.header {
  position: sticky; top: 0; z-index: 100;
  backdrop-filter: blur(14px);
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  border-bottom: 1px solid var(--border);
}
.nav { display: flex; align-items: center; justify-content: space-between; height: 68px; }
.nav__logo { font-family: var(--fira); font-weight: 600; font-size: 1.4rem; letter-spacing: 1px; }
.nav__logo span { color: var(--primary); }
.nav__list { display: flex; align-items: center; gap: 1.4rem; list-style: none; }
.nav__link { color: var(--text-dim); font-weight: 500; font-size: .95rem; position: relative; transition: color .25s; }
.nav__link::after {
  content: ""; position: absolute; left: 0; bottom: -6px; height: 2px; width: 0;
  background: var(--primary); transition: width .25s;
}
.nav__link:hover { color: var(--text); }
.nav__link:hover::after { width: 100%; }
.nav__link--cta {
  padding: .5rem 1rem; border: 1px solid var(--primary); border-radius: 30px; color: var(--primary);
}
.nav__link--cta:hover { background: var(--primary); color: #012; }
.theme-toggle {
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text);
  width: 38px; height: 38px; border-radius: 50%; cursor: pointer; font-size: 1rem; transition: transform .3s;
}
.theme-toggle:hover { transform: rotate(30deg) scale(1.05); }
.nav__toggle { display: none; flex-direction: column; gap: 5px; background: none; border: 0; cursor: pointer; }
.nav__toggle span { width: 26px; height: 2px; background: var(--text); transition: .3s; }
.nav__controls { display: flex; align-items: center; gap: .8rem; }

/* language switch */
.lang-switch {
  position: relative; display: inline-flex; align-items: center;
  width: 74px; height: 34px; padding: 3px; border-radius: 30px;
  background: var(--surface-2); border: 1px solid var(--border); cursor: pointer;
}
.lang-switch__opt {
  flex: 1; z-index: 1; text-align: center; font-size: .78rem; font-weight: 700;
  color: var(--text-dim); transition: color .3s; user-select: none;
}
.lang-switch__opt.active { color: #04121f; }
.lang-switch__thumb {
  position: absolute; top: 3px; left: 3px; width: calc(50% - 3px); height: calc(100% - 6px);
  border-radius: 30px; background: linear-gradient(135deg, var(--primary), var(--primary-2));
  transition: transform .3s cubic-bezier(.4,1.3,.5,1); box-shadow: 0 3px 10px rgba(0,180,216,.4);
}
.lang-switch[data-active="en"] .lang-switch__thumb { transform: translateX(100%); }

/* language welcome modal */
.lang-modal {
  position: fixed; inset: 0; z-index: 300; display: grid; place-items: center;
  background: rgba(4, 8, 18, .82); backdrop-filter: blur(8px);
  animation: fadeIn .35s ease;
}
/* Blindaje: el atributo `hidden` SIEMPRE oculta el modal, aunque otra
   regla establezca display. Evita que el modal quede atascado encima. */
.lang-modal[hidden] { display: none !important; }
@keyframes fadeIn { from { opacity: 0 } to { opacity: 1 } }
.lang-modal__box {
  width: min(92%, 440px); text-align: center; padding: 2.6rem 2rem;
  background: var(--surface); border: 1px solid var(--border); border-radius: 24px;
  box-shadow: var(--shadow); animation: popIn .45s cubic-bezier(.2,1.2,.4,1);
}
@keyframes popIn { from { opacity: 0; transform: translateY(24px) scale(.96) } to { opacity: 1; transform: none } }
.lang-modal__flag { font-size: 3rem; margin-bottom: .4rem; animation: float 5s ease-in-out infinite; }
.lang-modal__box h2 { font-size: 1.4rem; line-height: 1.3; margin-bottom: .8rem; }
.lang-modal__box h2 span { color: var(--text-dim); font-weight: 600; font-size: 1.05rem; }
.lang-modal__box p { color: var(--text-dim); font-size: .92rem; margin-bottom: 1.6rem; }
.lang-modal__actions { display: flex; gap: 1rem; justify-content: center; margin-bottom: 1.2rem; }
.lang-choice {
  flex: 1; max-width: 150px; display: flex; flex-direction: column; align-items: center; gap: .4rem;
  padding: 1.1rem; border-radius: 16px; cursor: pointer; font-weight: 700; font-size: 1rem;
  background: var(--surface-2); border: 2px solid var(--border); color: var(--text); transition: .25s;
}
.lang-choice:hover { border-color: var(--primary); transform: translateY(-4px); box-shadow: 0 12px 30px rgba(0,180,216,.25); }
.lang-choice__flag { font-size: 2rem; }
.lang-modal__box small { color: var(--text-dim); font-size: .78rem; }

/* ---------- hero ---------- */
.hero { position: relative; min-height: 100vh; display: flex; align-items: center; overflow: hidden; }
.hero__bg { position: absolute; inset: 0; z-index: 0; }
.blob { position: absolute; border-radius: 50%; filter: blur(80px); opacity: .5; animation: float 14s ease-in-out infinite; }
.blob--1 { width: 420px; height: 420px; background: var(--primary-2); top: -80px; left: -60px; }
.blob--2 { width: 380px; height: 380px; background: var(--accent); bottom: -100px; right: -40px; animation-delay: -4s; }
.blob--3 { width: 300px; height: 300px; background: var(--primary); top: 40%; left: 55%; animation-delay: -8s; }
.grid-overlay {
  position: absolute; inset: 0;
  background-image: linear-gradient(var(--border) 1px, transparent 1px), linear-gradient(90deg, var(--border) 1px, transparent 1px);
  background-size: 46px 46px; opacity: .18; mask-image: radial-gradient(circle at 50% 40%, #000 30%, transparent 80%);
}
@keyframes float { 0%,100%{ transform: translateY(0) } 50%{ transform: translateY(-40px) } }

.hero__content { position: relative; z-index: 1; padding: 4rem 0; }

/* profile photo */
.hero__avatar { position: relative; width: 150px; height: 150px; margin-bottom: 1.6rem; }
.hero__avatar-ring {
  position: absolute; inset: -6px; border-radius: 50%;
  background: conic-gradient(from 0deg, var(--primary), var(--accent), var(--primary));
  animation: spin 6s linear infinite;
  filter: blur(1px);
}
@keyframes spin { to { transform: rotate(360deg); } }
.hero__avatar-img,
.hero__avatar-fallback {
  position: absolute; inset: 0; width: 100%; height: 100%;
  border-radius: 50%; object-fit: cover;
  border: 4px solid var(--bg);
  box-shadow: var(--shadow);
}
.hero__avatar-fallback {
  display: grid; place-items: center;
  font-family: var(--fira); font-weight: 700; font-size: 3rem;
  color: #fff; background: linear-gradient(135deg, var(--primary-2), var(--accent));
}
.hero__avatar:hover .hero__avatar-ring { animation-duration: 2.5s; }

.hero__eyebrow { color: var(--primary); font-family: var(--fira); margin-bottom: .6rem; }
.hero__title { font-size: clamp(2.4rem, 6vw, 4.4rem); font-weight: 800; line-height: 1.05; letter-spacing: -1px; }
.hero__typed { font-family: var(--fira); font-size: clamp(1.1rem, 3vw, 1.7rem); color: var(--text-dim); margin: .6rem 0 1.2rem; min-height: 2.2rem; }
.hero__typed .cursor { color: var(--primary); animation: blink 1s step-end infinite; }
@keyframes blink { 50% { opacity: 0; } }
.hero__desc { max-width: 620px; color: var(--text-dim); font-size: 1.05rem; }
.hero__badges { display: flex; flex-wrap: wrap; gap: .6rem; margin: 1.6rem 0; }
.pill {
  background: var(--surface); border: 1px solid var(--border); color: var(--text);
  padding: .4rem .9rem; border-radius: 30px; font-size: .85rem; font-weight: 500;
}
.hero__cta { display: flex; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.6rem; }
.hero__social { display: flex; gap: .8rem; }
.hero__social a {
  width: 44px; height: 44px; display: grid; place-items: center; border-radius: 12px;
  background: var(--surface); border: 1px solid var(--border); font-family: var(--fira); font-weight: 600;
  color: var(--text-dim); transition: .25s;
}
.hero__social a:hover { color: var(--primary); border-color: var(--primary); transform: translateY(-3px); }

/* buttons */
.btn { padding: .8rem 1.6rem; border-radius: 12px; font-weight: 600; font-size: .95rem; transition: .25s; display: inline-block; cursor: pointer; }
.btn--primary { background: linear-gradient(135deg, var(--primary), var(--primary-2)); color: #04121f; box-shadow: 0 10px 30px rgba(0,180,216,.3); }
.btn--primary:hover { transform: translateY(-3px); box-shadow: 0 16px 40px rgba(0,180,216,.45); }
.btn--ghost { border: 1px solid var(--border); color: var(--text); }
.btn--ghost:hover { border-color: var(--primary); color: var(--primary); }
.btn--lg { padding: 1rem 2rem; font-size: 1.05rem; }

.scroll-hint { position: absolute; bottom: 26px; left: 50%; transform: translateX(-50%); width: 26px; height: 42px; border: 2px solid var(--text-dim); border-radius: 20px; z-index: 1; }
.scroll-hint span { position: absolute; top: 8px; left: 50%; transform: translateX(-50%); width: 4px; height: 8px; background: var(--primary); border-radius: 4px; animation: scrolldot 1.6s infinite; }
@keyframes scrolldot { 0%{opacity:0; top:8px} 40%{opacity:1} 80%{opacity:0; top:22px} }

/* ---------- stats ---------- */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; margin: -3rem auto 2rem; position: relative; z-index: 2; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.6rem 1rem; text-align: center; box-shadow: var(--shadow); }
.stat-card__num { display: block; font-size: 2.4rem; font-weight: 800; background: linear-gradient(135deg, var(--primary), var(--accent)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.stat-card__label { color: var(--text-dim); font-size: .85rem; }

/* ---------- sections ---------- */
.section { padding: 5rem 0; }
.section__title { font-size: clamp(1.6rem, 4vw, 2.2rem); font-weight: 800; margin-bottom: 2.4rem; display: flex; align-items: center; gap: .6rem; }
.section__index { font-family: var(--fira); color: var(--primary); font-size: 1.1rem; }

/* about */
.about { display: grid; grid-template-columns: 1.2fr 1fr; gap: 2.4rem; align-items: start; }
.about__text p { color: var(--text-dim); margin-bottom: 1rem; }
.about__facts { list-style: none; margin-top: 1rem; display: grid; gap: .5rem; }
.about__facts li { color: var(--text-dim); }
.code-window { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.code-window__bar { display: flex; align-items: center; gap: 6px; padding: .7rem 1rem; background: var(--surface-2); border-bottom: 1px solid var(--border); }
.code-window__bar span { width: 12px; height: 12px; border-radius: 50%; }
.code-window__bar span:nth-child(1){ background:#ff5f56 } .code-window__bar span:nth-child(2){ background:#ffbd2e } .code-window__bar span:nth-child(3){ background:#27c93f }
.code-window__bar em { margin-left: auto; font-style: normal; font-family: var(--fira); color: var(--text-dim); font-size: .8rem; }
.code-window pre { padding: 1.2rem; font-family: var(--fira); font-size: .85rem; color: var(--text); overflow-x: auto; }
.code-window .k { color: var(--primary); }

/* skills */
.skills-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1.4rem; }
.skill-block { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.6rem; transition: transform .3s, border-color .3s; }
.skill-block:hover { transform: translateY(-6px); border-color: var(--primary); }
.skill-block h3 { margin-bottom: 1rem; font-size: 1.1rem; }
.chips { display: flex; flex-wrap: wrap; gap: .5rem; }
.chips span { background: var(--surface-2); border: 1px solid var(--border); padding: .35rem .8rem; border-radius: 8px; font-size: .82rem; color: var(--text-dim); transition: .2s; }
.chips span:hover { color: var(--primary); border-color: var(--primary); }
.skills-bars__title { margin: 2.6rem 0 1.4rem; font-size: 1.2rem; }
.skills-bars { display: grid; gap: 1.1rem; }
.bar__label { display: flex; justify-content: space-between; font-size: .9rem; color: var(--text-dim); margin-bottom: .4rem; }
.bar__label b { color: var(--primary); }
.bar__track { height: 10px; background: var(--surface-2); border-radius: 20px; overflow: hidden; border: 1px solid var(--border); }
.bar__track i { display: block; height: 100%; width: 0; border-radius: 20px; background: linear-gradient(90deg, var(--primary), var(--accent)); transition: width 1.3s cubic-bezier(.2,.8,.2,1); }

/* timeline */
.timeline { position: relative; padding-left: 30px; }
.timeline::before { content: ""; position: absolute; left: 7px; top: 6px; bottom: 6px; width: 2px; background: linear-gradient(var(--primary), var(--accent)); }
.tl-item { position: relative; padding-bottom: 2.2rem; }
.tl-dot { position: absolute; left: -30px; top: 4px; width: 16px; height: 16px; border-radius: 50%; background: var(--bg); border: 3px solid var(--primary); box-shadow: 0 0 0 4px color-mix(in srgb, var(--primary) 20%, transparent); }
.tl-content { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.4rem 1.6rem; transition: transform .3s, border-color .3s; }
.tl-content:hover { transform: translateX(6px); border-color: var(--primary); }
.tl-date { font-family: var(--fira); font-size: .78rem; color: var(--primary); }
.tl-content h3 { margin: .3rem 0; font-size: 1.15rem; }
.tl-company { color: var(--text-dim); font-size: .9rem; font-weight: 500; }
.tl-content ul { margin: .8rem 0 0 1.1rem; color: var(--text-dim); font-size: .92rem; display: grid; gap: .35rem; }

/* education */
.edu-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1.2rem; }
.edu-card { background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--primary); border-radius: var(--radius); padding: 1.4rem; transition: transform .3s; }
.edu-card:hover { transform: translateY(-5px); }
.edu-year { font-family: var(--fira); font-size: .8rem; color: var(--primary); }
.edu-card h3 { margin: .4rem 0; font-size: 1.05rem; }
.edu-card p { color: var(--text-dim); font-size: .9rem; }

/* certs */
.cert-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1rem; }
.cert-grid--progress { margin-top: 1rem; }
.cert { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 1.1rem 1.3rem; display: flex; align-items: center; gap: .8rem; font-weight: 500; transition: .25s; }
.cert:hover { border-color: var(--primary); transform: translateX(5px); }
.cert__ico { font-size: 1.4rem; }
.cert--wip { border-style: dashed; color: var(--text-dim); }
.cert-progress__title { margin: 2.2rem 0 .4rem; font-size: 1.15rem; }

/* contact */
.section--contact { text-align: center; }
.contact__lead { color: var(--text-dim); max-width: 600px; margin: 0 auto 2rem; font-size: 1.1rem; }
.contact__actions { display: flex; gap: 1rem; justify-content: center; flex-wrap: wrap; }
.contact__note { margin-top: 1.6rem; color: var(--text-dim); font-size: .85rem; }

/* footer */
.footer { border-top: 1px solid var(--border); padding: 2rem 0; }
.footer__inner { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; color: var(--text-dim); font-size: .85rem; }

/* to top */
.to-top { position: fixed; right: 22px; bottom: 22px; width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; background: linear-gradient(135deg, var(--primary), var(--primary-2)); color: #04121f; font-size: 1.2rem; opacity: 0; pointer-events: none; transform: translateY(20px); transition: .3s; z-index: 90; }
.to-top.show { opacity: 1; pointer-events: auto; transform: translateY(0); }

/* reveal animation */
.reveal { opacity: 0; transform: translateY(28px); transition: opacity .7s ease, transform .7s ease; }
.reveal.in { opacity: 1; transform: none; }

/* ---------- responsive ---------- */
@media (max-width: 860px) {
  .nav__toggle { display: flex; }
  .nav__list {
    position: fixed; inset: 68px 0 auto 0; flex-direction: column; gap: 1.4rem;
    background: var(--bg-2); border-bottom: 1px solid var(--border); padding: 2rem;
    transform: translateY(-120%); transition: transform .35s ease;
  }
  .nav__list.open { transform: translateY(0); }
  .nav__toggle.active span:nth-child(1){ transform: translateY(7px) rotate(45deg); }
  .nav__toggle.active span:nth-child(2){ opacity: 0; }
  .nav__toggle.active span:nth-child(3){ transform: translateY(-7px) rotate(-45deg); }
  .about, .skills-grid, .edu-grid, .cert-grid { grid-template-columns: 1fr; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .nav__controls { justify-content: center; padding-top: .6rem; }
}
@media (max-width: 480px) {
  .stats { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
  .reveal { opacity: 1; transform: none; }
}
