/* =========================================================
   Francisco Javier Ferrada — personal site
   ========================================================= */

:root {
  --bg: #f6f7f9;
  --bg-soft: #ffffff;
  --surface: #ffffff;
  --surface-2: #eef1f6;
  --border: rgba(23, 37, 63, 0.10);
  --border-strong: rgba(23, 37, 63, 0.18);
  --text: #1b2739;
  --text-soft: #4c5a6e;
  --text-dim: #7c8899;
  --brand: #2f6fb3;
  --brand-strong: #285f9c;
  --ok: #2e9e6b;
  --radius: 14px;
  --radius-sm: 10px;
  --maxw: 1120px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --shadow: 0 14px 34px rgba(23, 37, 63, 0.10);
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  font-family: "Inter", system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

h1, h2, h3, h4 { font-family: "Space Grotesk", "Inter", sans-serif; line-height: 1.12; letter-spacing: -0.015em; }

a { color: inherit; text-decoration: none; }

.container { width: 100%; max-width: var(--maxw); margin-inline: auto; padding-inline: 24px; }

/* ---------- Subtle background ---------- */
.bg-grid {
  position: fixed; inset: 0; z-index: -3;
  background:
    radial-gradient(1000px 520px at 80% -10%, rgba(47, 111, 179, 0.07), transparent 70%),
    radial-gradient(800px 500px at 0% 0%, rgba(47, 111, 179, 0.04), transparent 70%),
    var(--bg);
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 22px; border-radius: var(--radius-sm);
  font-weight: 600; font-size: 15px; cursor: pointer; border: 1px solid transparent;
  transition: transform .18s var(--ease), background .18s, border-color .18s, color .18s;
  white-space: nowrap;
}
.btn--sm { padding: 8px 16px; font-size: 14px; }
.btn--primary { color: #fff; background: var(--brand-strong); border-color: var(--brand-strong); }
.btn--primary:hover { background: var(--brand); border-color: var(--brand); transform: translateY(-1px); }
.btn--ghost { color: var(--text); background: transparent; border-color: var(--border-strong); }
.btn--ghost:hover { border-color: var(--brand); color: var(--brand); }
.btn--icon { padding: 11px; background: transparent; border-color: var(--border-strong); color: var(--text-soft); }
.btn--icon:hover { border-color: var(--brand); color: var(--brand); }
.btn--icon .ic { width: 20px; height: 20px; }
.ic { width: 16px; height: 16px; fill: currentColor; }

/* ---------- Navbar ---------- */
.nav {
  position: fixed; top: 0; left: 0; right: 0; z-index: 50;
  transition: background .3s, border-color .3s, backdrop-filter .3s;
  border-bottom: 1px solid transparent;
}
.nav.scrolled {
  background: rgba(246, 247, 249, 0.85);
  backdrop-filter: blur(12px);
  border-bottom-color: var(--border);
}
.nav__inner { display: flex; align-items: center; justify-content: space-between; height: 72px; }
.nav__brand { display: flex; align-items: center; gap: 10px; font-weight: 700; }
.nav__logo { color: var(--brand); display: inline-flex; }
.nav__name { font-family: "Space Grotesk", sans-serif; font-size: 16px; }
.nav__links { display: flex; gap: 30px; }
.nav__links a { color: var(--text-soft); font-size: 15px; font-weight: 500; position: relative; transition: color .2s; }
.nav__links a::after { content: ""; position: absolute; left: 0; bottom: -6px; width: 0; height: 2px; background: var(--brand); transition: width .25s var(--ease); }
.nav__links a:hover { color: var(--text); }
.nav__links a:hover::after { width: 100%; }
.nav__actions { display: flex; align-items: center; gap: 14px; }

.lang-toggle { display: inline-flex; border: 1px solid var(--border-strong); border-radius: 8px; overflow: hidden; }
.lang-toggle button { background: transparent; color: var(--text-dim); border: 0; padding: 6px 11px; font-size: 13px; font-weight: 600; cursor: pointer; transition: background .2s, color .2s; }
.lang-toggle button.is-active { background: var(--brand-strong); color: #fff; }

.nav__burger { display: none; flex-direction: column; gap: 5px; background: none; border: 0; cursor: pointer; padding: 6px; }
.nav__burger span { width: 24px; height: 2px; background: var(--text); border-radius: 2px; transition: transform .3s, opacity .3s; }
.nav__burger.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav__burger.open span:nth-child(2) { opacity: 0; }
.nav__burger.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ---------- Hero ---------- */
.hero {
  display: grid; grid-template-columns: 1.15fr 0.85fr; gap: 56px; align-items: center;
  padding-top: 150px; padding-bottom: 80px;
}
.eyebrow {
  display: inline-block; font-family: "JetBrains Mono", monospace; font-size: 12.5px;
  letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-soft);
  padding: 6px 14px; border: 1px solid var(--border-strong); border-radius: 100px;
  margin-bottom: 22px;
}
.hero__title { font-size: clamp(42px, 6.5vw, 74px); font-weight: 700; margin: 0 0 20px; color: var(--text); }
.grad { color: var(--brand); }
.hero__lead { font-size: clamp(16px, 2vw, 18.5px); color: var(--text-soft); max-width: 560px; margin: 0 0 26px; }
.hero__meta { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 30px; }
.chip {
  display: inline-flex; align-items: center; gap: 8px; font-size: 14px; color: var(--text-soft);
  padding: 7px 14px; border: 1px solid var(--border); border-radius: 100px; background: var(--surface);
}
.chip .ic { width: 15px; height: 15px; fill: var(--brand); }
.chip--ok .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); }
.hero__cta { display: flex; flex-wrap: wrap; gap: 12px; }

/* Portrait + credential */
.hero__visual { position: relative; justify-self: center; width: min(100%, 400px); }
.hero__photo {
  border-radius: 18px; overflow: hidden; border: 1px solid var(--border-strong);
  background: var(--surface); box-shadow: var(--shadow); aspect-ratio: 5 / 6;
}
.hero__photo img { width: 100%; height: 100%; object-fit: cover; object-position: center 20%; display: block; }
.hero__badge { position: absolute; left: -26px; bottom: -22px; }
.hero__badge #r { transform: scale(0.62); transform-origin: bottom left; filter: drop-shadow(0 10px 22px rgba(23,37,63,.28)); }

/* ---------- Stats ---------- */
.stats {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px;
  padding-block: 20px 40px;
}
.stat {
  text-align: center; padding: 24px 16px; border: 1px solid var(--border);
  border-radius: var(--radius); background: var(--surface);
}
.stat__num { display: block; font-family: "Space Grotesk", sans-serif; font-size: 38px; font-weight: 700; color: var(--text); }
.stat__label { display: block; font-size: 13.5px; color: var(--text-dim); margin-top: 6px; }

/* ---------- Sections ---------- */
.section { padding-block: 70px; }
.section__head { margin-bottom: 44px; }
.section__kicker { font-family: "JetBrains Mono", monospace; font-size: 12.5px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--brand); }
.section__title { font-size: clamp(28px, 4vw, 42px); margin: 10px 0 0; color: var(--text); }

/* ---------- About ---------- */
.about { display: grid; grid-template-columns: 1.6fr 1fr; gap: 40px; align-items: start; }
.about__text p { color: var(--text-soft); margin: 0 0 18px; font-size: 16.5px; }
.about__text a { color: var(--brand); border-bottom: 1px solid rgba(47,111,179,.35); }
.about__text strong { color: var(--text); }
.about__list { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.about__list li {
  display: flex; flex-direction: column; padding: 16px 18px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); background: var(--surface); border-left: 3px solid var(--brand);
  transition: transform .18s var(--ease);
}
.about__list li:hover { transform: translateX(3px); }
.about__list span { font-weight: 600; }
.about__list small { color: var(--text-dim); font-family: "JetBrains Mono", monospace; font-size: 12.5px; }

/* ---------- Timeline ---------- */
.timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.timeline::before { content: ""; position: absolute; left: 7px; top: 6px; bottom: 6px; width: 2px; background: var(--border-strong); }
.tl { position: relative; padding-left: 40px; margin-bottom: 26px; }
.tl__dot { position: absolute; left: 0; top: 6px; width: 16px; height: 16px; border-radius: 50%; background: var(--brand); border: 3px solid var(--bg); }
.tl__card {
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface);
  padding: 22px 24px; transition: transform .18s var(--ease), border-color .18s;
}
.tl__card:hover { transform: translateY(-2px); border-color: var(--border-strong); }
.tl__top { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; align-items: baseline; }
.tl__top h3 { font-size: 19px; margin: 0; }
.tl__date { font-family: "JetBrains Mono", monospace; font-size: 13px; color: var(--brand); white-space: nowrap; }
.tl__org { color: var(--text-soft); margin: 4px 0 12px; font-size: 15px; }
.tl__org a { color: var(--brand); }
.tl__card ul { margin: 0 0 14px; padding-left: 18px; color: var(--text-soft); }
.tl__card li { margin-bottom: 6px; font-size: 15px; }

/* ---------- Tags ---------- */
.tags { display: flex; flex-wrap: wrap; gap: 8px; }
.tags span {
  font-family: "JetBrains Mono", monospace; font-size: 12px; color: var(--text-soft);
  padding: 4px 11px; border: 1px solid var(--border); border-radius: 100px;
}
.tags--lg span { font-size: 13.5px; padding: 7px 15px; }

/* ---------- Projects ---------- */
.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 22px; }
.card {
  position: relative; display: flex; flex-direction: column;
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface);
  padding: 26px; transition: transform .2s var(--ease), border-color .2s;
}
.card:hover { transform: translateY(-3px); border-color: var(--border-strong); }
.card--feature { border-color: var(--border-strong); background: var(--surface-2); }
.card__badge {
  align-self: flex-start; font-family: "JetBrains Mono", monospace; font-size: 11px; text-transform: uppercase;
  letter-spacing: .06em; color: var(--brand); padding: 4px 10px; border-radius: 100px;
  border: 1px solid var(--border-strong); margin-bottom: 16px;
}
.card__badge--os { color: var(--text-dim); }
.card__title { font-size: 22px; margin: 0 0 12px; }
.card__desc { color: var(--text-soft); font-size: 15px; margin: 0 0 18px; flex: 1; }
.card .tags { margin-bottom: 18px; }
.card__links { margin-top: auto; }
.link-arrow { color: var(--brand); font-weight: 600; font-size: 15px; transition: color .2s; }
.link-arrow:hover { color: var(--brand-strong); }

/* ---------- Skills ---------- */
.skills { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; }
.skillset { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); padding: 22px 24px; }
.skillset h4 { margin: 0 0 14px; font-size: 15px; color: var(--brand); font-family: "JetBrains Mono", monospace; letter-spacing: .03em; }

/* ---------- Publications ---------- */
.pubs { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; }
.pubs li { border: 1px solid var(--border); border-left: 3px solid var(--brand); border-radius: var(--radius-sm); background: var(--surface); padding: 18px 22px; transition: transform .18s var(--ease); }
.pubs li:hover { transform: translateX(3px); }
.pubs__name { margin: 0 0 4px; font-weight: 600; font-size: 16px; }
.pubs__journal { font-style: italic; color: var(--text-dim); font-size: 14px; }

/* ---------- Contact ---------- */
.contact {
  display: grid; grid-template-columns: 1.3fr 1fr; gap: 40px; align-items: center;
  border: 1px solid var(--border-strong); border-radius: 20px;
  background: var(--surface-2);
  padding: 48px;
}
.contact__text p { color: var(--text-soft); margin: 14px 0 0; max-width: 460px; }
.contact__actions { display: flex; flex-direction: column; gap: 14px; }
.contact__actions .btn { width: 100%; }
.contact__links { display: flex; flex-wrap: wrap; gap: 8px 18px; margin-top: 8px; }
.contact__links a { color: var(--text-dim); font-size: 14px; font-family: "JetBrains Mono", monospace; transition: color .2s; }
.contact__links a:hover { color: var(--brand); }

/* ---------- Footer ---------- */
.footer { border-top: 1px solid var(--border); padding-block: 28px; margin-top: 40px; }
.footer__inner { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; color: var(--text-dim); font-size: 14px; }

/* ---------- Reveal animation ---------- */
.reveal { opacity: 0; transform: translateY(20px); transition: opacity .6s var(--ease), transform .6s var(--ease); }
.reveal.in { opacity: 1; transform: none; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .hero { grid-template-columns: 1fr; gap: 56px; padding-top: 120px; }
  .hero__visual { order: -1; width: min(78%, 320px); }
  .about, .contact { grid-template-columns: 1fr; }
  .grid { grid-template-columns: 1fr 1fr; }
  .skills { grid-template-columns: 1fr; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .nav__links { display: none; }
  .nav__burger { display: flex; }

  .nav__links.open {
    display: flex; position: absolute; top: 72px; left: 0; right: 0; flex-direction: column;
    gap: 0; background: rgba(246,247,249,.98); backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border); padding: 8px 24px 20px;
  }
  .nav__links.open a { padding: 14px 0; border-bottom: 1px solid var(--border); }
}
@media (max-width: 560px) {
  .grid { grid-template-columns: 1fr; }
  .contact { padding: 30px 24px; }
  .nav__name { display: none; }
  .footer__inner { flex-direction: column; }
  .hero__badge { left: -14px; }
  .hero__badge #r { transform: scale(0.5); }
}

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