:root {
  --bg: #070b14;
  --bg-2: #0c1322;
  --card: #0f1828;
  --line: #1c2a40;
  --text: #e8edf5;
  --muted: #8b9ab3;
  --accent: #ff7a45;
  --accent-2: #5cc8ff;
  --radius: 14px;
  --max: 1080px;
  /* Distance from the content edge to the viewport edge, a little short of it
     so a desktop scrollbar never makes the orbit overflow. */
  --bleed: max(16px, calc((100vw - var(--max)) / 2 + 6px));
  --sans: "Space Grotesk", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  color-scheme: dark;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f6f7fa;
    --bg-2: #eceff5;
    --card: #ffffff;
    --line: #dde3ec;
    --text: #0d1524;
    --muted: #55637a;
    --accent: #e0561f;
    --accent-2: #0f7fc0;
    color-scheme: light;
  }
}

/* Language switch: show only the spans matching <html lang>. */
html[lang="es"] body [lang="en"],
html[lang="en"] body [lang="es"] { display: none !important; }

/* Focus switch: aerospace copy by default, games copy under #videojuegos. */
html:not([data-focus="games"]) .f-games,
html[data-focus="games"] .f-aero { display: none !important; }

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 80px; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
.mono { font-family: var(--mono); }
h1, h2, h3 { line-height: 1.15; margin: 0; }

/* Top bar */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 24px;
  padding: 14px max(16px, calc((100vw - var(--max)) / 2));
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { font-family: var(--mono); font-weight: 500; text-decoration: none; letter-spacing: .05em; }
.blink { color: var(--accent); animation: blink 1.1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.nav { display: flex; gap: 20px; margin-left: auto; }
.nav a { color: var(--muted); text-decoration: none; font-size: 15px; }
.nav a:hover { color: var(--text); }
.lang-toggle {
  font-family: var(--mono); font-size: 13px;
  background: none; border: 1px solid var(--line); border-radius: 999px;
  color: var(--muted); padding: 5px 12px; cursor: pointer;
}
.lang-toggle .sep { margin: 0 4px; opacity: .5; }
html[lang="es"] .lang-toggle [data-lang="es"],
html[lang="en"] .lang-toggle [data-lang="en"] { color: var(--accent); }

main, .footer { max-width: var(--max); margin: 0 auto; padding: 0 16px; }

/* Hero */
.hero { position: relative; padding: 96px 0 64px; min-height: 80vh; display: flex; flex-direction: column; justify-content: center; }
.orbit-clip {
  position: absolute; top: 0; bottom: 0; left: 0; right: calc(-1 * var(--bleed));
  overflow: hidden; pointer-events: none;
}
.orbit {
  position: absolute; right: calc(var(--bleed) - 120px); top: 20px;
  width: 640px; max-width: 90vw; opacity: .9;
}
.orbit .planet { fill: var(--bg-2); stroke: var(--line); }
.orbit .ring { fill: none; stroke: var(--line); stroke-width: 1.2; }
.orbit .ring.faint { stroke-dasharray: 3 7; }
.orbit .sat { fill: var(--accent); filter: drop-shadow(0 0 6px var(--accent)); }
.orbit .sat.small { fill: var(--accent-2); filter: drop-shadow(0 0 5px var(--accent-2)); }
.hero-content { position: relative; max-width: 680px; }
.kicker { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; letter-spacing: .02em; margin: 0 0 22px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: #3ddc84; box-shadow: 0 0 0 4px color-mix(in srgb, #3ddc84 25%, transparent); flex: none; }
h1 { font-size: clamp(24px, 7.8vw, 64px); font-weight: 700; letter-spacing: -.02em; white-space: nowrap; }
.role { font-size: clamp(19px, 2.6vw, 24px); color: var(--accent); margin: 10px 0 18px; font-weight: 500; }
.lead { color: var(--muted); font-size: 18px; margin: 0 0 30px; }
.cta { display: flex; flex-wrap: wrap; gap: 12px; }
.btn {
  display: inline-block; padding: 11px 20px; border-radius: 999px;
  border: 1px solid var(--line); text-decoration: none; font-weight: 500; font-size: 15px;
  transition: border-color .2s, background .2s;
}
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }

.telemetry {
  position: relative;
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px;
  margin: 64px 0 0; background: var(--line);
  border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden;
}
.telemetry div { background: var(--bg-2); padding: 18px 20px; }
.telemetry dt { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .08em; }
.telemetry dd { margin: 4px 0 0; font-size: 28px; font-weight: 500; }
.telemetry small { font-size: 14px; color: var(--muted); }

/* Sections */
.section { padding: 72px 0; border-top: 1px solid var(--line); }
.section-title { display: flex; align-items: baseline; gap: 14px; font-size: clamp(26px, 4vw, 34px); margin-bottom: 36px; }
.section-title .num { font-size: 14px; color: var(--accent); font-weight: 400; }
.prose p { margin: 0 0 16px; color: var(--muted); }
.prose p:nth-child(-n+2) { color: var(--text); }
.about { display: grid; grid-template-columns: 1.5fr 1fr; gap: 40px; align-items: start; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; }
.label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; margin: 0 0 12px; }
.kv { list-style: none; margin: 0; padding: 0; }
.kv li { display: flex; flex-direction: column; padding: 10px 0; border-top: 1px solid var(--line); font-size: 14px; color: var(--muted); }
.kv li:first-child { border-top: 0; padding-top: 0; }
.kv b { color: var(--text); font-weight: 500; font-size: 15px; }

.timeline { list-style: none; margin: 0; padding: 0 0 0 24px; border-left: 1px solid var(--line); }
.timeline > li { position: relative; padding-bottom: 40px; }
.timeline > li:last-child { padding-bottom: 0; }
.timeline > li::before {
  content: ""; position: absolute; left: -30px; top: 6px;
  width: 11px; height: 11px; border-radius: 50%;
  background: var(--bg); border: 2px solid var(--accent);
}
.when { color: var(--accent); font-size: 13px; margin: 0 0 6px; }
.timeline h3, .edu h3 { font-size: 21px; }
.org { color: var(--muted); margin: 4px 0 10px; }
.timeline ul, .edu ul { margin: 0; padding-left: 18px; color: var(--muted); }
.timeline ul li, .edu ul li { margin-bottom: 6px; }

.tags { display: flex; flex-wrap: wrap; gap: 8px; margin: 16px 0 0; }
.tags > span {
  font-size: 12px; padding: 3px 10px; border-radius: 999px;
  border: 1px solid var(--line); color: var(--muted); background: var(--bg-2);
}

.projects { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; }
.project h3 { font-size: 20px; margin-bottom: 10px; }
.project h3 a { text-decoration: none; }
.project h3 a:hover { color: var(--accent); }
.project > p:not(.label):not(.tags):not(.links) { color: var(--muted); margin: 0; font-size: 16px; }
.project.featured {
  grid-column: 1 / -1;
  background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 10%, var(--card)), var(--card) 60%);
  border-color: color-mix(in srgb, var(--accent) 35%, var(--line));
}
.project.featured h3 { font-size: 26px; }
.links { display: flex; gap: 18px; margin: 16px 0 0; font-size: 13px; }
.links a { color: var(--accent); text-decoration: none; }
.links a:hover { text-decoration: underline; }

.project:not(.featured):last-child:nth-child(even) { grid-column: 1 / -1; }

.edu { display: grid; gap: 20px; }

.skills { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.skills > div { background: var(--card); padding: 22px; }
.skills h3 { font-size: 12px; color: var(--accent); text-transform: uppercase; letter-spacing: .08em; margin-bottom: 8px; font-weight: 500; }
.skills p { margin: 0; color: var(--muted); font-size: 15px; }

.contact .big { font-size: clamp(22px, 3.4vw, 30px); max-width: 720px; margin: 0 0 28px; }

.footer { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; padding-top: 28px; padding-bottom: 40px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; }

/* Responsive */
@media (max-width: 860px) {
  .nav { display: none; }
  .lang-toggle { margin-left: auto; }
  .about, .projects { grid-template-columns: 1fr; }
  .skills { grid-template-columns: 1fr 1fr; }
  .telemetry { grid-template-columns: 1fr 1fr; }
  .orbit { right: calc(var(--bleed) - 200px); top: 0; opacity: .45; }
  .hero { min-height: auto; padding-top: 64px; }
}
@media (max-width: 520px) {
  .skills { grid-template-columns: 1fr; }
  .telemetry dd { font-size: 24px; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .blink { animation: none; }
}

/* Project filters */
.filters { display: flex; flex-wrap: wrap; gap: 8px; margin: -12px 0 24px; }
.chip {
  font-family: var(--mono); font-size: 13px;
  padding: 6px 14px; border-radius: 999px; cursor: pointer;
  background: var(--bg-2); color: var(--muted); border: 1px solid var(--line);
  transition: border-color .2s, color .2s;
}
.chip:hover { color: var(--text); border-color: var(--muted); }
.chip.active { color: #fff; background: var(--accent); border-color: var(--accent); }
.project[hidden] { display: none; }
/* Project order: aerospace-oriented by default, games-oriented under #videojuegos. */
.project { order: var(--oa); }
html[data-focus="games"] .project { order: var(--og); }
.projects.filtered .project.featured { grid-column: auto; }
.projects.filtered .project:not(.featured):last-child:nth-child(even) { grid-column: auto; }
.timeline .links { margin-top: 12px; }
