﻿/* ============================================================
   Brian Montero — Portfolio
   Tema: oscuro futurista · negro/dorado/cian (colores Auribot)
   ============================================================ */

:root {
  --bg: #06080f;
  --bg-soft: #0a0e1a;
  --surface: rgba(255, 255, 255, 0.04);
  --surface-2: rgba(255, 255, 255, 0.07);
  --border: rgba(148, 163, 184, 0.16);
  --text: #e6edf6;
  --muted: #93a1b8;
  --cyan: #22d3ee;
  --gold: #f7c14b;
  --gold-deep: #e8a020;
  --green: #34d399;
  --gradient: linear-gradient(120deg, #ffd76b, #f0a429);
  --radius: 18px;
  --font-head: "Space Grotesk", system-ui, sans-serif;
  --font-body: "Inter", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, monospace;
  --nav-h: 72px;
}

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

/* El atributo hidden debe ganar siempre, incluso sobre display:flex/grid */
[hidden] { display: none !important; }

html { scroll-behavior: smooth; scroll-padding-top: calc(var(--nav-h) + 16px); }

body {
  background:
    radial-gradient(1100px 600px at 85% -10%, rgba(247, 193, 75, 0.07), transparent 60%),
    radial-gradient(900px 500px at -10% 30%, rgba(34, 211, 238, 0.08), transparent 60%),
    var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  line-height: 1.6;
  overflow-x: hidden;
}

::selection { background: rgba(34, 211, 238, 0.35); }

.container { width: min(1140px, 92vw); margin-inline: auto; }

h1, h2, h3 { font-family: var(--font-head); line-height: 1.15; letter-spacing: -0.02em; }

section { padding: clamp(64px, 9vw, 110px) 0; }

.gradient-text {
  background: var(--gradient);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

kbd {
  font-family: var(--font-mono);
  font-size: 0.72em;
  padding: 2px 7px;
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 6px;
  background: var(--surface);
  color: var(--muted);
}

.dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 10px var(--green);
  animation: pulse-dot 2s ease-in-out infinite;
}
@keyframes pulse-dot { 50% { opacity: 0.4; } }
@keyframes blink { 50% { opacity: 0; } }

/* ============ Preloader ============ */
#preloader {
  position: fixed; inset: 0; z-index: 200;
  background: var(--bg);
  display: grid; place-items: center;
  transition: opacity 0.5s ease, visibility 0.5s;
}
#preloader.done { opacity: 0; visibility: hidden; }
.preloader-terminal {
  font-family: var(--font-mono);
  font-size: clamp(12px, 2.4vw, 15px);
  color: var(--cyan);
  white-space: pre-wrap;
  min-width: 280px;
}
/* el prompt del terminal va en dorado; el texto, en cian */
.preloader-terminal .pl-prompt { color: var(--gold); }

/* ============ Progress + cursor ============ */
#scroll-progress {
  position: fixed; top: 0; left: 0; height: 3px; width: 0;
  background: var(--gradient);
  z-index: 150;
}

#cursor-glow {
  position: fixed; top: 0; left: 0;
  width: 480px; height: 480px;
  border-radius: 50%;
  pointer-events: none;
  z-index: 1;
  background: radial-gradient(circle, rgba(34, 211, 238, 0.07), transparent 65%);
  transform: translate(-50%, -50%);
  transition: opacity 0.4s;
  opacity: 0;
}
body.cursor-active #cursor-glow { opacity: 1; }
@media (pointer: coarse) { #cursor-glow { display: none; } }

/* ============ Navbar ============ */
#navbar {
  position: fixed; top: 0; left: 0; right: 0;
  z-index: 100;
  transition: background 0.3s, border-color 0.3s, backdrop-filter 0.3s;
  border-bottom: 1px solid transparent;
}
#navbar.scrolled {
  background: rgba(6, 8, 15, 0.72);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom-color: var(--border);
}
.nav-inner {
  width: min(1240px, 94vw);
  margin-inline: auto;
  height: var(--nav-h);
  display: flex; align-items: center; gap: 24px;
}
.logo { display: flex; align-items: center; gap: 12px; text-decoration: none; }
.pet-logo { --pet-scale: 0.165; flex-shrink: 0; transition: transform 0.25s; }
.logo:hover .pet-logo { transform: translateY(-2px) scale(1.05); }
.logo-name {
  font-family: var(--font-head); font-weight: 700; font-size: 20px;
  letter-spacing: 0.03em;
  color: var(--text);
}
.logo-name::after { content: "_"; color: var(--cyan); animation: blink 1.2s steps(1) infinite; }

.nav-links {
  display: flex; gap: 4px; list-style: none; margin-left: auto;
}
.nav-links a {
  color: var(--muted); text-decoration: none; font-size: 14.5px;
  padding: 8px 13px; border-radius: 9px;
  transition: color 0.2s, background 0.2s;
}
.nav-links a:hover, .nav-links a.active { color: var(--text); background: var(--surface-2); }
.nav-actions { display: flex; align-items: center; gap: 10px; }

.ghost-btn {
  background: var(--surface); color: var(--muted);
  border: 1px solid var(--border); border-radius: 9px;
  font: 500 13px var(--font-body);
  padding: 8px 12px; cursor: pointer;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  transition: color 0.2s, border-color 0.2s;
}
.ghost-btn:hover { color: var(--text); border-color: rgba(148, 163, 184, 0.4); }
#theme-toggle {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 0;
  flex: 0 0 34px;
}
#theme-toggle svg.lucide {
  width: 16px;
  height: 16px;
}
.palette-hint kbd { margin-left: 4px; }

.btn {
  display: inline-block;
  font: 600 15px var(--font-body);
  text-decoration: none;
  padding: 13px 26px;
  border-radius: 12px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s, background 0.2s;
}
.btn-sm { padding: 9px 18px; font-size: 14px; }
/* vidrio dorado: translúcido, con blur del fondo y filo de luz arriba */
.btn-primary {
  background: rgba(247, 193, 75, 0.16);
  color: var(--gold);
  border-color: rgba(247, 193, 75, 0.45);
  backdrop-filter: blur(12px) saturate(1.2);
  -webkit-backdrop-filter: blur(12px) saturate(1.2);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.14),
    0 8px 28px rgba(247, 193, 75, 0.15);
}
.btn-primary:hover {
  transform: translateY(-2px);
  background: rgba(247, 193, 75, 0.26);
  border-color: rgba(247, 193, 75, 0.7);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.18),
    0 12px 36px rgba(247, 193, 75, 0.28);
}
html[data-theme="light"] .btn-primary {
  color: #7a5208;
  background: rgba(247, 193, 75, 0.26);
  border-color: rgba(200, 138, 18, 0.55);
}
.btn-ghost {
  color: var(--text);
  border-color: var(--border);
  background: var(--surface);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.07);
}
.btn-ghost:hover { border-color: var(--cyan); transform: translateY(-2px); }

#menu-toggle {
  display: none;
  flex-direction: column; gap: 6px;
  background: none; border: none; cursor: pointer; padding: 8px;
}
#menu-toggle span {
  width: 24px; height: 2px; background: var(--text);
  transition: transform 0.3s, opacity 0.3s;
}
#mobile-menu {
  display: none;
  flex-direction: column;
  padding: 10px 4vw 18px;
  background: rgba(6, 8, 15, 0.95);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}
#mobile-menu a {
  color: var(--text); text-decoration: none;
  padding: 13px 8px; border-bottom: 1px solid rgba(148, 163, 184, 0.08);
  font-size: 16px;
}
#navbar.menu-open #mobile-menu { display: flex; }
#navbar.menu-open #menu-toggle span:first-child { transform: translateY(4px) rotate(45deg); }
#navbar.menu-open #menu-toggle span:last-child { transform: translateY(-4px) rotate(-45deg); }

/* ============ Hero ============ */
#hero {
  position: relative;
  isolation: isolate;
  min-height: 100svh;
  display: flex;
  align-items: flex-start;
  padding: calc(var(--nav-h) + 4px) 0 18px;
  overflow: hidden;
  background-color: var(--bg);
  background-image:
    radial-gradient(ellipse 58% 54% at 50% 28%, rgba(6, 8, 15, 0.35), rgba(6, 8, 15, 0.16) 68%, transparent 100%),
    linear-gradient(180deg, rgba(6, 8, 15, 0.18) 0%, rgba(6, 8, 15, 0.25) 68%, var(--bg) 100%),
    linear-gradient(90deg, rgba(6, 8, 15, 0.26), rgba(6, 8, 15, 0.08) 34%, rgba(6, 8, 15, 0.08) 68%, rgba(6, 8, 15, 0.24)),
    url("https://yzdbodnmvmswpvszzxpc.supabase.co/storage/v1/object/public/img/negro.jpeg");
  background-position: center top;
  background-repeat: no-repeat;
  background-size: cover;
}
#hero::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse 48% 50% at 50% 30%, rgba(6, 8, 15, 0.18), transparent 78%),
    linear-gradient(180deg, transparent 58%, rgba(6, 8, 15, 0.14) 82%, rgba(6, 8, 15, 0.42) 100%);
}
#hero::after {
  content: "";
  position: absolute;
  inset: -20%;
  z-index: 5;
  pointer-events: none;
  opacity: 0;
  transform: scale(0.55);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(120, 230, 255, 0.3), rgba(80, 100, 210, 0.12) 30%, transparent 68%);
}
html.theme-switching #hero::after {
  animation: theme-cosmic-flash 0.58s cubic-bezier(0.2, 0.75, 0.25, 1);
}
html.theme-switching #theme-toggle svg {
  animation: theme-icon-spin 0.62s cubic-bezier(0.2, 0.8, 0.2, 1);
}
@keyframes theme-cosmic-flash {
  0% { opacity: 0; transform: scale(0.45) rotate(-8deg); }
  38% { opacity: 0.34; }
  100% { opacity: 0; transform: scale(1.28) rotate(5deg); }
}
@keyframes theme-icon-spin {
  from { transform: rotate(-150deg) scale(0.65); opacity: 0.35; }
  to { transform: rotate(0) scale(1); opacity: 1; }
}
#neural-canvas {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  z-index: 1;
  opacity: 1;
  /* la galaxia baja apenas de intensidad hacia la cinta: el panel de
     vidrio la esfuma encima, así que tiene que seguir viva detrás */
  -webkit-mask-image: linear-gradient(#000 72%, rgba(0, 0, 0, 0.72) 92%, transparent 100%);
  mask-image: linear-gradient(#000 72%, rgba(0, 0, 0, 0.72) 92%, transparent 100%);
}
.hero-factory {
  position: relative;
  z-index: 2;
  isolation: isolate;
  width: min(1280px, 96vw);
  margin-inline: auto;
  border: 0;
  overflow: visible;
  background: transparent;
  box-shadow: none;
}
.hero-factory::before {
  content: "";
  position: absolute;
  inset: -12% -6%;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(58% 54% at 24% 25%, rgba(34, 211, 238, 0.045), transparent 76%),
    radial-gradient(52% 52% at 78% 72%, rgba(247, 193, 75, 0.032), transparent 78%);
  filter: blur(42px);
  opacity: 0.72;
}
.hero-inner {
  position: relative; z-index: 2;
  display: flex; flex-direction: column; align-items: center;
  text-align: center;
  gap: 4px;
  width: min(980px, calc(100% - 40px));
  margin-inline: auto;
  padding: 8px 0;
}
.hero-copy { max-width: 820px; display: flex; flex-direction: column; align-items: center; }
.accent {
  color: transparent;
  background: linear-gradient(110deg, #67e8f9 5%, var(--cyan) 48%, #8b5cf6 105%);
  -webkit-background-clip: text;
  background-clip: text;
  filter: drop-shadow(0 0 22px rgba(34, 211, 238, 0.2));
}
.eyebrow {
  display: inline-flex; align-items: center; gap: 9px;
  font-size: 13px; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--muted);
  border: 1px solid var(--border);
  background: var(--surface);
  padding: 7px 13px; border-radius: 999px;
  margin-bottom: 8px;
}
#hero h1 {
  max-width: 20ch;
  font-size: clamp(2.45rem, 4.7vw, 4.2rem);
  font-weight: 750;
  line-height: 0.99;
  letter-spacing: -0.06em;
  text-wrap: balance;
  margin-bottom: 12px;
  text-shadow: 0 12px 45px rgba(0, 0, 0, 0.16);
}
.hero-sub {
  color: var(--muted);
  font-size: clamp(0.98rem, 1.5vw, 1.08rem);
  max-width: 62ch;
  margin-bottom: 10px;
}
.hero-ctas { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; margin-bottom: 10px; }

/* ---- selector de rubro y caso ---- */
.hero-picker {
  display: flex; flex-direction: column; align-items: center;
  gap: 6px;
  margin-top: 0;
}
.picker-label {
  font: 600 12px var(--font-mono);
  letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--muted);
}
.niche-row, .case-row {
  display: flex; flex-wrap: wrap; justify-content: center;
  gap: 9px;
}
.niche-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted);
  font: 500 14px var(--font-body);
  padding: 9px 17px;
  cursor: pointer;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
  transition: color 0.2s, border-color 0.2s, background 0.2s, transform 0.2s;
}
.niche-btn:hover { color: var(--text); transform: translateY(-1px); }
.niche-btn.active {
  color: var(--gold);
  border-color: rgba(247, 193, 75, 0.55);
  background: rgba(247, 193, 75, 0.14);
}
.case-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted);
  font: 500 13px var(--font-body);
  padding: 7px 14px;
  cursor: pointer;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
  transition: color 0.2s, border-color 0.2s, background 0.2s;
}
.case-btn:hover { color: var(--text); border-color: rgba(34, 211, 238, 0.4); }
/* el caso activo: vidrio dorado, como los botones primarios */
.case-btn.active {
  background: rgba(247, 193, 75, 0.18);
  border-color: rgba(247, 193, 75, 0.6);
  color: var(--gold);
  font-weight: 600;
}
html[data-theme="light"] .niche-btn.active,
html[data-theme="light"] .case-btn.active { color: #7a5208; }
/* ============ Cinta transportadora de agentes ============ */
.hero-belt {
  position: relative;
  z-index: 2;
  width: 100%;
  border-top: 0;
  background: transparent;
  padding: 6px 18px 4px;
}
.belt-head {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: 8px 16px;
}
.belt-title {
  display: flex; align-items: center; gap: 9px;
  font: 600 14px var(--font-head);
}
.belt-controls { display: flex; align-items: center; gap: 14px; }
.sfx-control { position: relative; }
.sfx-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 190px;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 11px;
  color: var(--muted);
  background: var(--bg-soft);
  background: color-mix(in srgb, var(--bg-soft) 88%, transparent);
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.32);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}
.sfx-panel[hidden] { display: none; }
.sfx-panel label,
.sfx-panel output { font: 600 11px var(--font-mono); }
.sfx-panel output { width: 36px; color: var(--text); text-align: right; }
.sfx-panel input {
  width: 108px;
  accent-color: var(--gold);
  cursor: pointer;
}
#sfx-toggle {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 0;
}
#sfx-toggle svg.lucide { width: 17px; height: 17px; }
.belt-counter { font: 12.5px var(--font-mono); color: var(--muted); }
#belt-count { color: var(--green); font-weight: 700; }
.belt-hint { flex-basis: 100%; font-size: 12px; color: var(--muted); opacity: 0.75; }

.belt-viewport {
  padding: 0 18px 4px;
  overflow: visible;
  scrollbar-width: thin;
}
.belt-stage {
  position: relative;
  width: 100%;
  height: 260px;
  min-width: 760px;
  overflow: visible;
  background: radial-gradient(60% 65% at 50% 78%, rgba(34, 211, 238, 0.025), transparent 74%);
}

/* piso 3D en perspectiva (estilo grid futurista) */
.belt-floor {
  position: absolute; left: -12%; right: -12%; bottom: -6px;
  height: 175px;
  background:
    repeating-linear-gradient(90deg, rgba(34, 211, 238, 0.32) 0 2px, transparent 2px 70px),
    repeating-linear-gradient(0deg, rgba(247, 193, 75, 0.26) 0 2px, transparent 2px 46px),
    linear-gradient(rgba(34, 211, 238, 0.07), rgba(247, 193, 75, 0.05));
  transform: perspective(380px) rotateX(57deg);
  transform-origin: bottom center;
  animation: floor-flow 2.6s linear infinite;
  -webkit-mask-image: linear-gradient(transparent, #000 40%);
  mask-image: linear-gradient(transparent, #000 40%);
  z-index: 0;
}
@keyframes floor-flow { to { background-position-x: 70px, 0, 0; } }

/* niebla de profundidad detrás de los agentes */
.belt-fog {
  position: absolute; left: 0; right: 0; bottom: 110px;
  height: 95px;
  background: radial-gradient(
    ellipse 72% 100% at 50% 100%,
    rgba(10, 14, 26, 0.24) 0%,
    rgba(10, 14, 26, 0.1) 48%,
    transparent 82%
  );
  z-index: 1;
}

/* ===== Cinta transportadora pixel-art (SVG generado por JS) =====
   main.js → buildMachine() dibuja la máquina al ancho real del stage:
   banda diagonal animada, poleas que giran en las puntas, rodillos,
   patas con travesaño y tolva de entrada — como la referencia. */
:root {
  --belt-outline: #0a0f1c;
  --belt-body: #2e3c58;     /* carcasa */
  --belt-body2: #1d2740;    /* sombra de carcasa */
  --belt-band: #141d33;     /* fondo de la banda */
  --belt-stripe: #2e4d6e;   /* franja que avanza */
  --belt-metal: #8fa1bd;    /* metal claro (poleas, tolva) */
  --belt-metal2: #4d5e7a;   /* metal sombra */
}
html[data-theme="light"] {
  --belt-outline: #1c2638;
  --belt-body: #aebad0;
  --belt-body2: #8d9cb8;
  --belt-band: #76869f;
  --belt-stripe: #9fb4cf;
  --belt-metal: #e3e9f2;
  --belt-metal2: #8d9cb8;
}
.belt-track {
  position: absolute; left: 0; right: 0; bottom: 6px;
  height: 88px;
  z-index: 2;
  pointer-events: none;
  filter: drop-shadow(0 12px 16px rgba(0, 0, 0, 0.34));
}
.belt-track svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
}
/* franjas de la banda: ruedan hacia la derecha (period 28px, loop exacto) */
.belt-run { animation: belt-run 0.85s linear infinite; }
@keyframes belt-run { to { transform: translateX(28px); } }
/* poleas: giran con un tornillo excéntrico que delata el movimiento */
.belt-pulley {
  animation: belt-spin 1.5s linear infinite;
  transform-box: fill-box;
  transform-origin: center;
}
@keyframes belt-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .belt-run, .belt-pulley { animation: none; }
}

.station {
  position: absolute; bottom: 78px;
  left: var(--pos);
  transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  z-index: 3;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
/* sombra elíptica en el piso, ancla al agente en la escena */
.station::after {
  content: "";
  position: absolute; bottom: -34px; left: 50%;
  transform: translateX(-50%);
  width: 86px; height: 16px;
  border-radius: 50%;
  background: radial-gradient(ellipse, rgba(0, 0, 0, 0.6) 0%, transparent 68%);
}
.station img {
  height: clamp(76px, 9vw, 106px);
  image-rendering: pixelated;
  /* --st-hue lo setea beltFactory; así la variante de color
     no pisa la sombra (todos los agentes la llevan) */
  filter: var(--st-hue, hue-rotate(0deg)) drop-shadow(0 12px 20px rgba(0, 0, 0, 0.55));
  transition: transform 0.2s;
}
html[data-theme="light"] .station img {
  filter: var(--st-hue, hue-rotate(0deg)) drop-shadow(0 10px 14px rgba(13, 20, 40, 0.38));
}
.station:hover img { transform: translateY(-4px); }
.station.working img { animation: station-bob 0.45s ease infinite; }
@keyframes station-bob { 50% { transform: translateY(-7px); } }
.station-tag {
  font: 600 10.5px var(--font-mono);
  letter-spacing: 0.04em;
  white-space: nowrap;
  color: var(--muted);
  background: rgba(6, 8, 15, 0.75);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px 9px;
  transition: color 0.2s, border-color 0.2s;
}
.station.working .station-tag { color: var(--cyan); border-color: rgba(34, 211, 238, 0.45); }
/* estación humana: quien valida y aprueba al final de la cinta */
.station-human .station-tag { color: var(--gold); border-color: rgba(247, 193, 75, 0.45); }
.station-human.working .station-tag { color: var(--gold); }
.station.swap img { animation: station-swap 0.4s cubic-bezier(0.34, 1.56, 0.64, 1); }
@keyframes station-swap { from { transform: scale(0.55); opacity: 0; } }

.bubble {
  position: absolute;
  bottom: calc(100% + 10px + var(--bubble-lift, 0px));
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-soft);
  border: 1px solid rgba(34, 211, 238, 0.4);
  color: var(--text);
  font-size: 12px;
  line-height: 1.45;
  padding: 7px 11px;
  border-radius: 10px;
  white-space: normal;
  width: max-content;
  max-width: 215px;
  text-align: center;
  z-index: var(--bubble-z, 6);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  animation: msg-in 0.2s ease;
}
.bubble::after {
  content: "";
  position: absolute; top: 100%; left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: rgba(34, 211, 238, 0.4);
}
/* las estaciones de las puntas anclan su burbuja hacia adentro
   para que el recorte del escenario no la corte */
.station-first .bubble { left: 0; transform: none; }
.station-first .bubble::after { left: 38px; }
.station-last .bubble { left: auto; right: 0; transform: none; }
.station-last .bubble::after { left: auto; right: 32px; transform: none; }

#belt-items { position: absolute; inset: 0; pointer-events: none; z-index: 4; overflow: visible; }
.belt-item {
  position: absolute; bottom: 36px; left: 0;
  display: flex; align-items: center; gap: 7px;
  background: rgba(10, 14, 26, 0.94);
  border: 1px solid rgba(34, 211, 238, 0.35);
  border-radius: 10px;
  padding: 7px 10px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.5), 0 16px 14px -8px rgba(0, 0, 0, 0.5);
  will-change: transform;
}
.bi-icon { font-size: 17px; line-height: 1; }
.bi-pips { display: flex; gap: 3px; }
.bi-pips i {
  width: 6px; height: 6px; border-radius: 50%;
  background: rgba(147, 161, 184, 0.35);
}
.bi-pips i.on { background: var(--green); box-shadow: 0 0 6px var(--green); }
.belt-item.processing { animation: item-buzz 0.45s ease; }
@keyframes item-buzz {
  25% { margin-bottom: 5px; }
  50% { margin-bottom: 0; }
  75% { margin-bottom: 3px; }
}
/* entra: cae desde la tolva y rebota al aterrizar en la banda */
.belt-item.drop-in { animation: item-drop 0.5s cubic-bezier(0.34, 1.4, 0.64, 1); }
@keyframes item-drop {
  from { margin-bottom: 48px; opacity: 0; rotate: -7deg; }
  60%  { margin-bottom: -3px; opacity: 1; }
  to   { margin-bottom: 0; rotate: 0deg; }
}
/* sale: se hunde en el cajón receptor */
.belt-item.drop-out { animation: item-out 0.4s ease-in forwards; }
@keyframes item-out {
  to { margin-bottom: -26px; opacity: 0; scale: 0.45; }
}
.belt-item.completed {
  width: 64px;
  justify-content: center;
  transform: translateX(-50%);
  transform-origin: center;
  will-change: left;
  color: var(--gold);
  border-color: rgba(247, 193, 75, 0.7);
  background: rgba(247, 193, 75, 0.14);
  box-shadow: 0 0 18px rgba(247, 193, 75, 0.24), 0 10px 24px rgba(0, 0, 0, 0.45);
  animation: package-ready 0.32s ease-out;
}
.belt-item.completed.package-travel {
  box-shadow: 0 0 12px rgba(247, 193, 75, 0.18), 0 8px 20px rgba(0, 0, 0, 0.4);
}
.belt-item.completed .bi-icon { font-size: 22px; }
.bi-done { font: 700 11px var(--font-mono); }
@keyframes package-ready {
  from { opacity: 0.55; filter: brightness(1.45); }
  to { opacity: 1; filter: brightness(1); }
}
/* Mufi: gato con guion propio — espera, se sube a la cinta, recorre,
   se baja al final y vuelve caminando (la posición la maneja main.js) */
.belt-mufi {
  position: absolute; left: 0; bottom: 8px;
  z-index: 5;
  background: none; border: none; padding: 0;
  cursor: pointer;
  will-change: transform;
  filter: drop-shadow(0 8px 8px rgba(0, 0, 0, 0.5));
}
.belt-mufi img {
  height: 48px;
  display: block;
  image-rendering: pixelated;
  transform: scaleX(var(--flip, 1));
  transform-origin: bottom center;
}
/* caminando de vuelta mira hacia la izquierda */
.belt-mufi.flip img,
.belt-mufi.flip .mufi-walk { --flip: -1; transform: scaleX(var(--flip)); }
/* walk cycle real: hoja de 8 frames de 78×40px (tira de 624px).
   El ?v= importa: sin él, el navegador puede servir una tira vieja
   y se ve la hoja entera deslizándose. */
.mufi-walk {
  display: none;
  width: 78px;
  height: 40px;
  overflow: hidden;
  background-image: url("../img/mufi-walk.webp?v=6");
  background-size: 312px 40px;
  background-position: 0 0;
  background-repeat: no-repeat;
  transform-origin: bottom center;
}
.belt-mufi.walking.walk-ready img { display: none; }
.belt-mufi.walking.walk-ready .mufi-walk {
  display: block;
  animation: mufi-walk-cycle 0.55s steps(4, end) infinite;
}
@keyframes mufi-walk-cycle { to { background-position-x: -312px; } }
/* fallback sin spritesheet: el gato de siempre con su balanceo */
.belt-mufi.walking.no-walk img {
  height: 40px;
  animation: mufi-gait 0.4s ease-in-out infinite;
}
@keyframes mufi-gait {
  0%, 100% { transform: scaleX(var(--flip, 1)) translateY(0) rotate(0deg); }
  50%      { transform: scaleX(var(--flip, 1)) translateY(-2.5px) rotate(2deg); }
}
.mufi-say {
  position: absolute;
  bottom: calc(100% + 8px + var(--bubble-lift, 0px));
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-soft);
  border: 1px solid rgba(247, 193, 75, 0.5);
  color: var(--text);
  font-size: 12px; line-height: 1.4;
  padding: 7px 11px;
  border-radius: 10px;
  white-space: normal;
  width: max-content; max-width: 200px;
  text-align: center;
  z-index: var(--bubble-z, 7);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  animation: msg-in 0.2s ease;
}
/* caja receptora al final de la cinta (cajón pixel-art, hace pop al recibir) */
.belt-bin {
  position: absolute; right: 4px; bottom: 10px;
  width: 46px; z-index: 4;
  filter: drop-shadow(0 10px 10px rgba(0, 0, 0, 0.55));
  transition: transform 0.2s;
}
.belt-bin svg { display: block; width: 100%; height: auto; }
.belt-bin.pop { animation: bin-pop 0.4s ease; }
@keyframes bin-pop { 40% { transform: scale(1.25) rotate(-7deg); } }

/* ============ Stats ============ */
#metricas { padding-top: 10px; }
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: clamp(22px, 4vw, 40px);
}
.stat { text-align: center; }
.stat-number {
  display: block;
  font: 700 clamp(1.9rem, 4vw, 2.9rem) var(--font-head);
  background: var(--gradient);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.stat-label { color: var(--muted); font-size: 14px; }

/* ============ Section headers ============ */
.section-head { max-width: 940px; margin-bottom: clamp(34px, 5vw, 56px); }
.kicker {
  font: 600 13px var(--font-mono);
  color: var(--gold);
  text-transform: uppercase; letter-spacing: 0.18em;
  margin-bottom: 12px;
}
.section-head h2 {
  max-width: 26ch;
  font-size: clamp(2.1rem, 4.2vw, 3.5rem);
  font-weight: 730;
  line-height: 1.03;
  letter-spacing: -0.05em;
  text-wrap: balance;
  margin-bottom: 18px;
}
.section-sub { color: var(--muted); }

/* ============ Cards ============ */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
}
.card {
  position: relative;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 28px 24px;
  transition: border-color 0.25s, background 0.25s, transform 0.25s;
  will-change: transform;
}
.card:hover { border-color: rgba(34, 211, 238, 0.45); background: var(--surface-2); }
.card-icon { font-size: 28px; margin-bottom: 16px; color: var(--cyan); }
.card-icon svg.lucide { width: 30px; height: 30px; }
.lucide-ready .ic-fb { display: none; }
.niche-btn svg.lucide { width: 15px; height: 15px; vertical-align: -2.5px; margin-right: 3px; color: var(--cyan); }
.card h3 { font-size: 1.15rem; margin-bottom: 10px; }
.card p { color: var(--muted); font-size: 14.5px; margin-bottom: 16px; }
.card-tags {
  display: flex; flex-wrap: wrap; gap: 7px;
  list-style: none;
}
.card-tags li {
  font: 500 11.5px var(--font-mono);
  color: var(--cyan);
  border: 1px solid rgba(34, 211, 238, 0.25);
  background: rgba(34, 211, 238, 0.06);
  border-radius: 999px;
  padding: 4px 10px;
}

/* ============ Timeline / Proceso (escena scroll) ============ */
#proceso { position: relative; overflow: hidden; }
/* .fx-on la pone scrollfx.js solo cuando hay GSAP + desktop + sin reduced-motion */
#proceso.fx-on {
  min-height: 100vh;
  display: flex;
  align-items: center;
  padding-block: clamp(76px, 9vw, 110px);
}
.proceso-inner { position: relative; }

/* Número gigante de fondo (01→04), solo en la escena animada */
.proceso-bignum {
  position: absolute;
  right: -10px; top: -36px;
  z-index: 0;
  font: 700 clamp(120px, 20vw, 240px)/1 var(--font-head);
  letter-spacing: -0.04em;
  color: transparent;
  -webkit-text-stroke: 1.5px rgba(247, 193, 75, 0.2);
  pointer-events: none;
  user-select: none;
}
.proceso-bignum span { display: inline-block; }
.proceso-bignum span.pop { animation: bignum-pop 0.45s cubic-bezier(0.22, 1, 0.36, 1); }
@keyframes bignum-pop {
  from { transform: translateY(16px); opacity: 0.15; }
  to   { transform: none; opacity: 1; }
}

/* Riel de energía que conecta los pasos */
.proceso-rail {
  position: relative;
  z-index: 1;
  height: 2px;
  border-radius: 999px;
  background: var(--border);
  margin: 46px 0 40px;
}
.proceso-rail-fill {
  position: absolute; inset: 0;
  border-radius: inherit;
  background: var(--gradient);
  transform-origin: left center;
  box-shadow: 0 0 14px rgba(247, 193, 75, 0.45);
}

/* Nodo de cada paso, apoyado sobre el riel */
.step-node {
  position: absolute;
  top: -47px; left: 50%;
  width: 12px; height: 12px;
  margin-left: -6px;
  border-radius: 50%;
  background: var(--bg-soft);
  border: 2px solid var(--border);
  transition: background 0.3s, border-color 0.3s, box-shadow 0.3s;
}
.timeline-step.active .step-node,
.timeline-step.done .step-node {
  background: var(--gold);
  border-color: var(--gold);
  box-shadow: 0 0 14px rgba(247, 193, 75, 0.7);
}

/* Sin la escena (mobile / sin GSAP / reduced-motion): grid clásico visible */
#proceso:not(.fx-on) .proceso-rail,
#proceso:not(.fx-on) .step-node,
#proceso:not(.fx-on) .proceso-bignum { display: none; }

.timeline {
  list-style: none;
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 18px;
  counter-reset: step;
}
.timeline-step {
  position: relative;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  /* fondo sólido: la ola pasa por detrás y el texto debe resaltar */
  background: linear-gradient(160deg, rgba(247, 193, 75, 0.06), transparent 45%), #0c1322;
  padding: 26px 22px;
}
html[data-theme="light"] .timeline-step {
  background: linear-gradient(160deg, rgba(232, 160, 32, 0.07), transparent 45%), #f4f7fc;
}
/* En la escena, GSAP maneja transform/opacity: sin transiciones que compitan */
#proceso.fx-on .timeline-step {
  transition: border-color 0.3s, background-color 0.3s, filter 0.35s;
  transition-delay: 0s;
}
#proceso.fx-on .timeline-step.active {
  border-color: rgba(247, 193, 75, 0.55);
  background: var(--surface-2);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.35);
}
#proceso.fx-on .timeline-step.done { filter: brightness(0.65) saturate(0.7); }
.step-num {
  font: 700 26px var(--font-mono);
  letter-spacing: 0.02em;
  background: var(--gradient);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  display: block; margin-bottom: 12px;
}
/* el paso activo enciende su número */
#proceso.fx-on .timeline-step.active .step-num {
  filter: drop-shadow(0 0 12px rgba(247, 193, 75, 0.55));
}
.timeline-step h3 { font-size: 1.05rem; margin-bottom: 8px; }
.timeline-step p { color: var(--muted); font-size: 14px; }

/* ============ Projects ============ */
.projects-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
}
.project {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: linear-gradient(160deg, rgba(247, 193, 75, 0.07), transparent 45%), var(--surface);
  padding: 28px 24px;
  display: flex; flex-direction: column;
  transition: transform 0.25s, border-color 0.25s;
}
.project:hover { transform: translateY(-5px); border-color: rgba(247, 193, 75, 0.5); }
.project-metric {
  font: 700 2.4rem var(--font-head);
  margin-bottom: 14px;
}
.project h3 { font-size: 1.1rem; margin-bottom: 10px; }
.project p { color: var(--muted); font-size: 14.5px; margin-bottom: 12px; }
/* antes / ahora: el contraste del proceso viejo vs. el automatizado */
.project-ba { display: flex; flex-direction: column; gap: 10px; margin-bottom: 14px; }
.project-ba p { margin: 0; font-size: 14px; line-height: 1.55; }
.ba-tag {
  display: inline-block;
  font: 600 10px var(--font-mono);
  letter-spacing: 0.1em; text-transform: uppercase;
  border-radius: 999px;
  padding: 2px 9px;
  margin-right: 6px;
  vertical-align: 1px;
}
.ba-antes { color: #ff9a9a; background: rgba(255, 107, 107, 0.08); border: 1px solid rgba(255, 107, 107, 0.32); }
.ba-ahora { color: var(--green); background: rgba(52, 211, 153, 0.08); border: 1px solid rgba(52, 211, 153, 0.34); }
html[data-theme="light"] .ba-antes { color: #c24343; }
html[data-theme="light"] .ba-ahora { color: #0e8a60; }
.project-result {
  font-size: 13.5px !important;
  color: var(--green) !important;
  font-weight: 500;
}
.project .card-tags { margin-top: auto; }
.projects-note { margin-top: 22px; color: var(--muted); font-size: 13px; opacity: 0.75; }

/* ============ About ============ */
.about-grid {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: clamp(30px, 5vw, 70px);
  align-items: center;
}
.about-copy h2 { font-size: clamp(1.7rem, 3.6vw, 2.6rem); margin-bottom: 18px; }
.about-copy p { color: var(--muted); margin-bottom: 16px; max-width: 58ch; }
.stack-label {
  font: 600 12px var(--font-mono);
  color: var(--text);
  text-transform: uppercase; letter-spacing: 0.14em;
  margin: 22px 0 12px;
}
.id-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: linear-gradient(150deg, rgba(34, 211, 238, 0.08), rgba(247, 193, 75, 0.08)), var(--bg-soft);
  padding: 30px;
  display: flex; align-items: center; gap: 20px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
  transform: rotate(-1.5deg);
  transition: transform 0.3s;
}
.id-card:hover { transform: rotate(0deg) scale(1.02); }
.id-avatar {
  width: 92px; height: 92px; flex-shrink: 0;
  border-radius: 22px;
  background: var(--gradient);
  display: grid; place-items: center;
  overflow: hidden;
}
.id-avatar img {
  width: 100%; height: 100%;
  object-fit: cover; object-position: top;
  image-rendering: pixelated;
}
.id-name { font: 600 1.2rem var(--font-head); }
.id-role { color: var(--cyan); font: 500 13px var(--font-mono); margin: 4px 0 12px; }
.id-meta { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.id-meta span { display: flex; align-items: center; gap: 7px; }

/* ============ Trayectoria / CV ============ */
.cv-grid {
  display: grid;
  grid-template-columns: 1.25fr 0.75fr;
  gap: clamp(30px, 5vw, 64px);
  align-items: start;
}
.cv-timeline { list-style: none; position: relative; }
.cv-timeline::before {
  content: "";
  position: absolute; left: 7px; top: 8px; bottom: 8px;
  width: 2px;
  background: linear-gradient(rgba(247, 193, 75, 0.55), rgba(232, 160, 32, 0.25));
}
.cv-item { position: relative; padding: 0 0 32px 36px; }
.cv-item:last-child { padding-bottom: 0; }
.cv-item::before {
  content: "";
  position: absolute; left: 1px; top: 5px;
  width: 13px; height: 13px;
  border-radius: 50%;
  background: var(--bg);
  border: 2px solid var(--gold);
  box-shadow: 0 0 12px rgba(247, 193, 75, 0.5);
}
.cv-tag {
  font: 600 10.5px var(--font-mono);
  letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--gold);
  background: rgba(247, 193, 75, 0.07);
  border: 1px solid rgba(247, 193, 75, 0.3);
  border-radius: 999px;
  padding: 3px 10px;
}
.cv-tag-now {
  color: #2a1d04;
  background: var(--gold);
  border-color: var(--gold);
}
/* los chips de tools quedan en cian: el balance dorado/celeste de la sección */
.cv-item h3 { font-size: 1.08rem; margin: 11px 0 7px; }
.cv-item p { color: var(--muted); font-size: 14.5px; max-width: 62ch; }
.cv-item .card-tags { margin-top: 10px; }

.cv-side {
  position: sticky; top: calc(var(--nav-h) + 30px);
  display: flex; flex-direction: column; gap: 20px;
}
.cv-quote {
  border: 1px solid var(--border);
  border-left: 3px solid var(--gold);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 22px;
  font-size: 15.5px;
  line-height: 1.55;
}
.cv-quote cite { display: block; margin-top: 12px; color: var(--muted); font-style: normal; font-size: 13px; }
.cv-actions { display: flex; flex-direction: column; gap: 12px; }
.cv-actions .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-align: center;
}
.cv-actions .btn .lucide { width: 17px; height: 17px; }
.cv-stack { opacity: 0.9; }

/* ============ Contact ============ */
/* menos colchón contra el footer: el cierre queda pegado a la despedida */
#contacto { padding-bottom: clamp(28px, 4vw, 48px); }
.contact-panel {
  display: flex; flex-direction: column; align-items: center;
  text-align: center;
  gap: 14px;
  border: 1px solid var(--border);
  border-radius: 24px;
  /* vidrio sobre la galaxia profunda */
  background:
    radial-gradient(700px 320px at 50% 0%, rgba(247, 193, 75, 0.12), transparent 65%),
    rgba(10, 14, 26, 0.42);
  backdrop-filter: blur(16px) saturate(1.15);
  -webkit-backdrop-filter: blur(16px) saturate(1.15);
  padding: clamp(40px, 6vw, 72px) clamp(22px, 5vw, 56px);
}
html[data-theme="light"] .contact-panel {
  background:
    radial-gradient(700px 320px at 50% 0%, rgba(232, 160, 32, 0.1), transparent 65%),
    rgba(255, 255, 255, 0.55);
}
.contact-panel h2 { font-size: clamp(1.7rem, 3.4vw, 2.5rem); max-width: 20ch; }
.contact-sub { color: var(--muted); max-width: 54ch; }
/* CTA principal de contacto (abre el formulario) — vidrio dorado grande */
.btn-cta {
  display: inline-flex; align-items: center; gap: 12px;
  margin-top: 12px;
  font-size: 17px; font-weight: 700;
  padding: 17px 36px;
  border-radius: 15px;
  background: rgba(247, 193, 75, 0.16);
  color: var(--gold);
  border: 1px solid rgba(247, 193, 75, 0.5);
  cursor: pointer;
  backdrop-filter: blur(14px) saturate(1.2);
  -webkit-backdrop-filter: blur(14px) saturate(1.2);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.16),
    0 16px 44px rgba(247, 193, 75, 0.18);
  transition: transform 0.2s, box-shadow 0.2s, background 0.2s, border-color 0.2s;
}
.btn-cta:hover {
  transform: translateY(-3px) scale(1.02);
  background: rgba(247, 193, 75, 0.26);
  border-color: rgba(247, 193, 75, 0.75);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.2),
    0 20px 54px rgba(247, 193, 75, 0.3);
}
html[data-theme="light"] .btn-cta {
  color: #7a5208;
  background: rgba(247, 193, 75, 0.28);
  border-color: rgba(200, 138, 18, 0.55);
}
.btn-cta .lucide { width: 20px; height: 20px; }
.contact-note { font-size: 13px; color: var(--muted); opacity: 0.8; }

/* ============ Modal del formulario de contacto ============ */
#contact-overlay {
  position: fixed; inset: 0; z-index: 170;
  background: rgba(4, 6, 12, 0.72);
  backdrop-filter: blur(8px);
  display: grid; place-items: center;
  padding: 20px;
  overflow-y: auto;
}
#contact-modal {
  position: relative;
  width: min(480px, 94vw);
  max-height: 92vh;
  overflow-y: auto;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 32px 28px;
  animation: palette-in 0.2s ease;
}
#cf-close {
  position: absolute; top: 10px; right: 14px;
  background: none; border: none;
  color: var(--muted); font-size: 26px;
  cursor: pointer;
}
#contact-modal h3 {
  font-size: 1.5rem;
  text-align: center;
  margin-bottom: 6px;
}
.cf-sub { color: var(--muted); text-align: center; font-size: 14px; margin-bottom: 22px; }
#cf-form { display: flex; flex-direction: column; gap: 16px; }
#cf-form label > span,
.cf-radio legend {
  display: block;
  font: 600 13px var(--font-body);
  color: var(--text);
  margin-bottom: 7px;
}
#cf-form input[type="text"],
#cf-form input[type="email"],
#cf-form input[type="tel"],
#cf-form textarea {
  width: 100%;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font: 400 14.5px var(--font-body);
  padding: 12px 14px;
  resize: vertical;
}
#cf-form input:focus,
#cf-form textarea:focus {
  outline: none;
  border-color: var(--cyan);
}
.cf-radio { border: none; padding: 0; }
.cf-radio label {
  display: inline-flex; gap: 7px; align-items: center;
  margin-right: 22px;
  font-size: 14px; color: var(--text);
  cursor: pointer;
}
.cf-radio input { accent-color: var(--gold); }
/* honeypot: invisible para humanos, irresistible para bots */
.cf-hp { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }
.cf-status { text-align: center; font-size: 14px; color: var(--green); }
.cf-status.error { color: #ff8a8a; }

/* Confirmación del formulario: Auribot entrega la misión */
#contact-modal.is-success {
  width: min(520px, 94vw);
  overflow: hidden;
  border-color: rgba(247, 193, 75, 0.55);
  box-shadow:
    0 30px 90px rgba(0, 0, 0, 0.65),
    0 0 70px rgba(34, 211, 238, 0.1),
    inset 0 0 60px rgba(247, 193, 75, 0.05);
}
.cf-success {
  position: relative;
  isolation: isolate;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 10px 4px 2px;
}
.cf-success-pet {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 8px;
  filter: drop-shadow(0 12px 24px rgba(0, 0, 0, 0.45));
}
.pet-success {
  --pet-scale: 0.72;
  animation: cf-success-arrive 0.65s cubic-bezier(0.22, 1.5, 0.36, 1) both;
}
.pet-success .pet-sprite { animation: pet-talking 0.72s steps(6) infinite; }
.cf-success-shadow {
  width: 82px;
  height: 13px;
  margin-top: -3px;
  border-radius: 50%;
  background: radial-gradient(ellipse, rgba(0, 0, 0, 0.65), transparent 70%);
  animation: pet-shadow 2.4s ease-in-out infinite;
}
.cf-success-kicker {
  margin: 2px 0 8px;
  color: var(--gold);
  font: 700 12px var(--font-mono);
  letter-spacing: 0.2em;
}
.cf-success h3 {
  max-width: 15ch;
  margin: 0 auto 12px !important;
  font-size: clamp(1.55rem, 5vw, 2rem) !important;
  line-height: 1.12;
}
.cf-success-copy {
  max-width: 39ch;
  margin: 0;
  color: var(--text);
  font-size: 15px;
  line-height: 1.65;
}
.cf-success-note {
  margin: 12px 0 22px;
  color: var(--muted);
  font-size: 12.5px;
}
.cf-success .btn { min-width: 180px; }
.cf-success-stars {
  position: absolute;
  z-index: -1;
  inset: -24px -20px 30%;
  opacity: 0;
  background:
    radial-gradient(circle at 16% 32%, var(--gold) 0 2px, transparent 3px),
    radial-gradient(circle at 83% 18%, var(--cyan) 0 2px, transparent 3px),
    radial-gradient(circle at 72% 62%, var(--gold) 0 1.5px, transparent 2.5px),
    radial-gradient(circle at 28% 72%, var(--cyan) 0 1.5px, transparent 2.5px),
    radial-gradient(circle at 50% 12%, #fff 0 1px, transparent 2px);
}
.cf-success.celebrate .cf-success-stars { animation: cf-stars 1.1s ease-out both; }
@keyframes cf-success-arrive {
  from { opacity: 0; transform: translateY(32px) scale(0.72); }
  to { opacity: 1; transform: none; }
}
@keyframes cf-stars {
  0% { opacity: 0; transform: scale(0.55) rotate(-5deg); }
  35% { opacity: 1; }
  100% { opacity: 0.6; transform: scale(1.08) rotate(3deg); }
}
html[data-theme="light"] #cf-form input[type="text"],
html[data-theme="light"] #cf-form input[type="email"],
html[data-theme="light"] #cf-form input[type="tel"],
html[data-theme="light"] #cf-form textarea {
  background: rgba(13, 20, 40, 0.05);
}
html[data-theme="light"] .cf-status.error { color: #c24343; }

/* ============ Footer ============ */
footer {
  border-top: 1px solid var(--border);
  padding: 28px 0;
  /* vidrio sobre la galaxia profunda */
  background: rgba(8, 11, 21, 0.5);
  backdrop-filter: blur(14px) saturate(1.1);
  -webkit-backdrop-filter: blur(14px) saturate(1.1);
}
html[data-theme="light"] footer { background: rgba(255, 255, 255, 0.5); }

/* ============ Galaxia profunda (canvas fijo detrás del contenido) ============ */
#deep-galaxy {
  position: fixed; inset: 0;
  width: 100%; height: 100%;
  z-index: 0;
  pointer-events: none;
  opacity: 0;
}
/* el contenido viaja por encima del telón */
main, footer { position: relative; z-index: 1; }

.footer-links a { color: var(--muted); text-decoration: none; }
.footer-links a:hover { color: var(--cyan); }
.footer-links { display: flex; gap: 16px; flex-wrap: wrap; }
.cf-consent {
  display: grid !important;
  grid-template-columns: auto 1fr;
  align-items: start;
  gap: 9px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}
.cf-consent input { margin-top: 3px; accent-color: var(--gold); }
.cf-consent a { color: var(--cyan); }

/* ============ Command palette ============ */
#palette-overlay {
  position: fixed; inset: 0; z-index: 180;
  background: rgba(4, 6, 12, 0.7);
  backdrop-filter: blur(6px);
  display: grid;
  place-items: start center;
  padding-top: 16vh;
}
#palette {
  width: min(560px, 92vw);
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--bg-soft);
  box-shadow: 0 40px 100px rgba(0, 0, 0, 0.6);
  overflow: hidden;
  animation: palette-in 0.18s ease;
}
@keyframes palette-in { from { transform: translateY(-12px); opacity: 0; } }
#palette-input {
  width: 100%;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--border);
  padding: 17px 20px;
  color: var(--text);
  font: 15.5px var(--font-body);
}
#palette-input:focus { outline: none; }
#palette-list { list-style: none; max-height: 320px; overflow-y: auto; padding: 8px; }
#palette-list li {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px;
  border-radius: 10px;
  color: var(--muted);
  cursor: pointer;
  font-size: 14.5px;
}
#palette-list li .pi { width: 22px; text-align: center; }
#palette-list li.selected, #palette-list li:hover { background: var(--surface-2); color: var(--text); }
.palette-foot {
  padding: 10px 16px;
  border-top: 1px solid var(--border);
  font-size: 12px; color: var(--muted);
}

/* ============ Chatbot ============ */
/* ---- Auribot: sprite animado ----
   Hoja de 1536x1872: grilla de 8x9, celdas de 192x208.
   La fila 1 es el idle; otras filas se usan para hover y conversación. */
.pet-box {
  display: block;
  width: calc(192px * var(--pet-scale, 0.2));
  height: calc(208px * var(--pet-scale, 0.2));
  overflow: hidden;
}
.pet-sprite {
  display: block;
  width: 192px; height: 208px;
  background: url("../img/auribot-lite.webp?v=1") 0 0 no-repeat;
  image-rendering: pixelated;
  transform: scale(var(--pet-scale, 0.2));
  transform-origin: top left;
  animation: pet-idle 0.95s steps(6) infinite;
}
@keyframes pet-idle { to { background-position-x: -1152px; } }
@keyframes pet-tablet-hover {
  from { background-position: 0 -208px; }
  to { background-position: -1152px -208px; }
}
@keyframes pet-talking {
  from { background-position: 0 -416px; }
  to { background-position: -1152px -416px; }
}
.pet-fab { --pet-scale: 0.62; animation: pet-bob 3s ease-in-out infinite; }
.pet-avatar { --pet-scale: 0.18; }
@keyframes pet-bob { 50% { transform: translateY(-7px); } }

/* FAB sin contenedor: solo el pet flotando con glow y sombra propia */
#chat-fab {
  position: fixed; right: 26px; bottom: 16px; z-index: 160;
  background: none; border: none; padding: 6px 4px 16px;
  cursor: pointer;
  filter: drop-shadow(0 8px 16px rgba(0, 0, 0, 0.45));
  transition: transform 0.2s;
}
#chat-fab:hover { transform: scale(1.08); }
#chat-fab:hover .pet-fab { animation-duration: 1.1s; }
@media (hover: hover) and (pointer: fine) {
  #chat-fab:hover .pet-sprite {
    animation: pet-tablet-hover 0.9s steps(6) infinite;
  }
}
#chat-fab:focus-visible .pet-sprite {
  animation: pet-tablet-hover 0.9s steps(6) infinite;
}
#chat-fab:focus-visible { outline: 2px solid var(--cyan); outline-offset: 4px; border-radius: 12px; }

/* aura viva detrás del pet */
#chat-fab::before {
  content: "";
  position: absolute; inset: -16px -20px 0;
  border-radius: 50%;
  background: radial-gradient(closest-side,
    rgba(245, 197, 66, 0.3),
    rgba(34, 211, 238, 0.12) 55%,
    transparent 78%);
  filter: blur(7px);
  animation: pet-glow 2.8s ease-in-out infinite;
  z-index: -1;
}
@keyframes pet-glow { 50% { opacity: 0.5; transform: scale(0.9); } }

/* sombra elíptica en el piso, respira a contrafase del bob */
#chat-fab::after {
  content: "";
  position: absolute; left: 50%; bottom: 6px;
  width: 60%; height: 11px;
  transform: translateX(-50%);
  border-radius: 50%;
  background: radial-gradient(ellipse, rgba(0, 0, 0, 0.6), transparent 68%);
  animation: pet-shadow 3s ease-in-out infinite;
}
@keyframes pet-shadow { 50% { transform: translateX(-50%) scale(0.78); opacity: 0.65; } }

/* burbuja de invitación al hover */
.fab-tip {
  position: absolute; bottom: calc(100% - 2px); right: 4px;
  background: var(--bg-soft);
  border: 1px solid rgba(245, 197, 66, 0.5);
  color: var(--text);
  font: 600 12px var(--font-head);
  padding: 6px 11px;
  border-radius: 11px;
  border-bottom-right-radius: 3px;
  white-space: nowrap;
  opacity: 0;
  transform: translateY(5px);
  transition: opacity 0.2s, transform 0.2s;
  pointer-events: none;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.5);
}
#chat-fab:hover .fab-tip, #chat-fab:focus-visible .fab-tip, #chat-fab.tip-show .fab-tip { opacity: 1; transform: none; }
#chat-fab.tip-show .pet-fab { animation-duration: 0.9s; }

body.chat-open #chat-fab { display: none; }

/* ============ Diálogo NPC con Auribot ============ */
#dialogue {
  position: fixed; inset: 0; z-index: 170;
  background: rgba(4, 6, 12, 0.78);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: flex; align-items: flex-end; justify-content: center;
  padding: 4vh 4vw;
  animation: dlg-in 0.25s ease;
}
@keyframes dlg-in { from { opacity: 0; } }
#dialogue-close {
  position: absolute; top: 16px; right: 24px;
  background: none; border: none;
  color: var(--muted); font-size: 38px; line-height: 1;
  cursor: pointer;
  transition: color 0.2s, transform 0.2s;
}
#dialogue-close:hover { color: var(--text); transform: rotate(90deg); }
#dialogue-close:focus-visible,
.dlg-options button:focus-visible,
.dlg-contact-actions button:focus-visible,
#dlg-form button:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 3px;
}

.dlg-stage {
  display: flex; align-items: flex-end; gap: 24px;
  width: min(900px, 100%);
  margin-bottom: 3vh;
}
.dlg-pet {
  flex-shrink: 0;
  display: flex; flex-direction: column; align-items: center;
  animation: dlg-pet-in 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes dlg-pet-in { from { transform: translateY(40px); opacity: 0; } }
.pet-big { --pet-scale: 1.05; animation: pet-bob 3s ease-in-out infinite; }
#dialogue.talking .pet-sprite {
  animation: pet-talking 0.72s steps(6) infinite;
}
.dlg-pet-shadow {
  display: block;
  width: 64%; height: 18px;
  margin-top: 2px;
  border-radius: 50%;
  background: radial-gradient(ellipse, rgba(0, 0, 0, 0.65), transparent 68%);
  animation: pet-shadow 3s ease-in-out infinite;
}

.dlg-panel {
  position: relative; flex: 1;
  background: rgba(10, 14, 26, 0.94);
  border: 2px solid rgba(247, 193, 75, 0.55);
  border-radius: 18px;
  border-bottom-left-radius: 4px;
  padding: 18px 22px 16px;
  box-shadow:
    0 30px 80px rgba(0, 0, 0, 0.6),
    inset 0 0 50px rgba(247, 193, 75, 0.04);
  animation: dlg-panel-in 0.35s ease;
}
@keyframes dlg-panel-in { from { transform: translateY(24px); opacity: 0; } }
.dlg-scroll {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
/* cola del globo apuntando al pet */
.dlg-panel::before {
  content: "";
  position: absolute; left: -16px; bottom: 30px;
  border: 8px solid transparent;
  border-right-color: rgba(247, 193, 75, 0.55);
}
.dlg-name {
  font: 700 13px var(--font-mono);
  letter-spacing: 0.2em;
  color: var(--gold);
  margin-bottom: 8px;
}
.dlg-role { color: var(--muted); font-weight: 500; letter-spacing: 0.04em; }
.dlg-echo {
  font-size: 12.5px; color: var(--muted);
  font-style: italic;
  margin-bottom: 6px;
}
.dlg-text {
  font-size: 15.5px; line-height: 1.65;
  white-space: pre-line;
  min-height: 88px;
  cursor: pointer; /* clic = mostrar el texto completo, como en los juegos */
}
.dlg-text::after {
  content: "▮";
  color: var(--gold);
  animation: blink 0.9s steps(1) infinite;
  margin-left: 2px;
}
#dialogue:not(.talking) .dlg-text::after { content: ""; }
.dlg-options { display: flex; flex-direction: column; gap: 5px; margin: 14px 0 2px; }
.dlg-options button { animation: opt-in 0.28s ease both; animation-delay: calc(var(--i, 0) * 60ms); }
@keyframes opt-in { from { opacity: 0; transform: translateX(-8px); } }
.dlg-options button {
  text-align: left;
  background: none;
  border: 1px solid transparent;
  border-radius: 9px;
  color: var(--cyan);
  font: 500 14px var(--font-body);
  padding: 8px 11px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.15s;
}
.dlg-options button::before { content: "▸ "; color: var(--gold); }
.dlg-options button:hover {
  background: rgba(247, 193, 75, 0.07);
  border-color: rgba(247, 193, 75, 0.32);
  transform: translateX(5px);
}
.dlg-options .dlg-guide-action {
  color: #06080f;
  background: linear-gradient(135deg, var(--gold), #ffe29a);
  border-color: rgba(255, 226, 154, 0.75);
  font-weight: 700;
  margin-bottom: 5px;
}
.dlg-options .dlg-guide-action::before { content: "↳ "; color: #06080f; }
.dlg-options .dlg-guide-action:hover {
  color: #06080f;
  background: linear-gradient(135deg, #ffd36d, #fff0bf);
  border-color: #fff0bf;
}
#dlg-form {
  display: flex; gap: 9px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

/* Formulario de contacto embebido en la conversación de Auribot */
#dlg-contact-form {
  margin-top: 12px;
  padding-top: 14px;
  border-top: 1px solid rgba(34, 211, 238, 0.2);
}
.dlg-contact-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.dlg-contact-grid label > span,
.dlg-contact-grid legend {
  display: block;
  margin-bottom: 5px;
  color: var(--text);
  font: 600 11.5px var(--font-body);
}
.dlg-contact-grid input[type="text"],
.dlg-contact-grid input[type="email"],
.dlg-contact-grid input[type="tel"],
.dlg-contact-grid textarea {
  width: 100%;
  padding: 10px 11px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  border-radius: 9px;
  font: 400 13px var(--font-body);
}
.dlg-contact-grid input:focus,
.dlg-contact-grid textarea:focus {
  outline: none;
  border-color: var(--cyan);
}
.dlg-contact-grid textarea { resize: vertical; }
.dlg-contact-grid fieldset { margin: 0; padding: 0; border: 0; }
.dlg-contact-wide { grid-column: 1 / -1; }
.dlg-contact-radio {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-right: 14px;
  color: var(--text);
  font-size: 12.5px;
}
.dlg-contact-radio input,
.dlg-contact-consent input { accent-color: var(--gold); }
.dlg-contact-consent {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: start;
  gap: 8px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
}
.dlg-contact-consent input { margin-top: 2px; }
.dlg-contact-consent a { color: var(--cyan); }
.dlg-contact-actions {
  display: flex;
  justify-content: flex-end;
  gap: 9px;
  margin-top: 13px;
}
.dlg-contact-actions button {
  min-height: 39px;
  padding: 9px 14px;
  border-radius: 9px;
  font: 700 12px var(--font-body);
  cursor: pointer;
}
.dlg-contact-back {
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--border);
}
.dlg-contact-send {
  color: #06080f;
  background: linear-gradient(135deg, var(--gold), #ffe29a);
  border: 1px solid #ffe29a;
}
.dlg-contact-send:disabled { cursor: wait; opacity: 0.65; }
.dlg-contact-status {
  margin: 10px 0 0;
  color: var(--green);
  font-size: 12px;
  text-align: right;
}
.dlg-contact-status.error { color: #ff8a8a; }
#dialogue.contact-mode .dlg-panel {
  max-height: 88vh;
  overflow-y: auto;
  border-color: rgba(34, 211, 238, 0.52);
  box-shadow:
    0 30px 80px rgba(0, 0, 0, 0.6),
    0 0 55px rgba(34, 211, 238, 0.08);
}
#dialogue.contact-mode .dlg-text { min-height: 0; }
#dlg-input {
  flex: 1;
  background: rgba(6, 8, 15, 0.6);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 13px;
  color: var(--text);
  font: 14px var(--font-body);
}
#dlg-input:focus { outline: none; border-color: var(--gold); }
#dlg-form button {
  background: var(--gold);
  border: none; border-radius: 10px;
  width: 44px;
  color: #04060c; font-size: 16px;
  cursor: pointer;
}

@media (max-width: 640px) {
  .dlg-stage { flex-direction: column; align-items: center; gap: 6px; }
  .pet-big { --pet-scale: 0.62; }
  .dlg-panel { width: 100%; border-bottom-left-radius: 18px; }
  .dlg-panel::before { content: none; }
  .dlg-text { min-height: 120px; font-size: 14.5px; }
}

/* ============ Reveal animations ============ */
.reveal {
  opacity: 0;
  transform: translateY(26px);
  transition: opacity 0.7s ease, transform 0.7s ease;
}
.reveal.visible { opacity: 1; transform: none; }

/* ============ Responsive ============ */
@media (max-width: 980px) {
  #hero { min-height: auto; align-items: stretch; padding-top: calc(var(--nav-h) + 8px); }
  .hero-factory { width: 96vw; }
  .hero-inner { width: calc(100% - 32px); }
  .hero-belt { padding-inline: 12px; }
  .belt-viewport {
    margin-inline: -12px;
    padding-inline: 18px;
    overflow-x: auto;
    overflow-y: hidden;
  }
  .cv-grid { grid-template-columns: 1fr; }
  .cv-side { position: static; }
  .cards-grid, .projects-grid { grid-template-columns: repeat(2, 1fr); }
  .timeline { grid-template-columns: repeat(2, 1fr); }
  .timeline-step::after { content: none; }
  .about-grid, .contact-panel { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 28px 14px; }
  .nav-links, .palette-hint { display: none; }
  #menu-toggle { display: flex; }
}
@media (max-width: 580px) {
  #hero { padding-bottom: 22px; }
  .hero-factory { border-radius: 20px; }
  .hero-inner { width: calc(100% - 24px); padding-top: 8px; }
  .hero-belt { padding-top: 10px; }
  .belt-head { align-items: flex-start; }
  .belt-controls { width: 100%; flex-wrap: wrap; gap: 8px 10px; }
  .cards-grid, .projects-grid, .timeline { grid-template-columns: 1fr; }
  .hero-ctas .btn { width: 100%; text-align: center; }
  .nav-actions .btn { display: none; }
  .pet-fab { --pet-scale: 1.5; }
  #chat-fab { right: 16px; bottom: 10px; }
}

/* ============ Reduced motion ============ */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .reveal { opacity: 1; transform: none; }
  #neural-canvas { display: none; }
}

/* ============ Logo wordmark ============ */
.logo-img {
  height: 26px; width: auto; display: block;
  filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.45));
  transition: transform 0.2s;
}
.logo:hover .logo-img { transform: translateY(-2px) scale(1.03); }

/* ============ Firma ============ */
.firma {
  display: block;
  height: 58px; width: auto;
  margin: 4px 0 6px;
  opacity: 0.9;
  filter: invert(0.92);
}
html[data-theme="light"] .firma { filter: none; }

/* ============ Aprender ============ */
#aprender { position: relative; }
.learn-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
}
.learn-card {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 220px;
  padding: 24px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(34, 211, 238, 0.055), transparent 48%),
    var(--surface);
  overflow: hidden;
}
.learn-card::before {
  content: "";
  position: absolute; inset: 0;
  background: linear-gradient(135deg, rgba(247, 193, 75, 0.14), transparent 38%);
  opacity: 0;
  transition: opacity 0.25s;
}
.learn-card:hover::before { opacity: 1; }
.learn-card > * { position: relative; z-index: 1; }
.learn-type {
  margin-bottom: 14px;
  color: var(--gold);
  font: 700 11px var(--font-mono);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.learn-card h3 {
  margin-bottom: 10px;
  font-size: 1.18rem;
}
.learn-card p:not(.learn-type) {
  color: var(--muted);
  font-size: 14.5px;
}
.learn-card a:not(.btn) {
  margin-top: auto;
  color: var(--cyan);
  text-decoration: none;
  font: 700 13px var(--font-body);
}
.learn-card a:not(.btn):hover { color: var(--gold); }
.learn-card-wide {
  grid-column: 1 / -1;
  min-height: 0;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 20px;
  background:
    radial-gradient(420px 180px at 85% 20%, rgba(247, 193, 75, 0.13), transparent 62%),
    radial-gradient(360px 180px at 10% 0%, rgba(34, 211, 238, 0.1), transparent 62%),
    var(--surface);
}

/* ============ Blog / Radar ============ */
.blog-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
}
.insight-tabs { display: flex; justify-content: center; gap: 8px; margin: 0 0 22px; }
.insight-tab {
  border: 1px solid var(--border); border-radius: 999px; background: transparent;
  color: var(--muted); padding: 8px 15px; font: 600 12px var(--font-mono); cursor: pointer;
  transition: background .2s, border-color .2s, color .2s;
}
.insight-tab:hover { color: var(--text); border-color: rgba(247, 193, 75, .5); }
.insight-tab.is-active { color: #18130b; background: var(--gold); border-color: var(--gold); }
.blog-loading { color: var(--muted); font: 14px var(--font-mono); }
.blog-card {
  display: flex; flex-direction: column;
  text-align: left;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
  cursor: pointer;
  padding: 0;
  font: inherit; color: inherit;
  transition: transform 0.25s, border-color 0.25s;
}
.blog-card:hover { transform: translateY(-5px); border-color: rgba(247, 193, 75, 0.5); }
.blog-cover {
  width: 100%; aspect-ratio: 16 / 9;
  object-fit: cover;
  background: var(--surface-2);
}
.blog-body { padding: 16px 18px 18px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.blog-meta { font: 600 11.5px var(--font-mono); color: var(--gold); letter-spacing: 0.06em; }
.blog-card h3 {
  font-size: 1.02rem; line-height: 1.35;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}
.blog-excerpt {
  color: var(--muted); font-size: 13.5px;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical;
  overflow: hidden;
}
.blog-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: auto; }
.blog-foot { margin-top: 24px; text-align: center; }

/* lector de posts */
#post-overlay {
  position: fixed; inset: 0; z-index: 185;
  background: rgba(4, 6, 12, 0.78);
  backdrop-filter: blur(10px);
  display: grid; place-items: center;
  padding: 4vh 4vw;
}
#post-modal {
  position: relative;
  width: min(680px, 100%);
  max-height: 86vh;
  overflow-y: auto;
  background: var(--bg-soft);
  border: 1px solid rgba(247, 193, 75, 0.4);
  border-radius: 18px;
  padding: 26px 28px 30px;
  box-shadow: 0 40px 100px rgba(0, 0, 0, 0.6);
  animation: dlg-panel-in 0.3s ease;
}
#post-close {
  position: sticky; top: 0; float: right;
  background: none; border: none;
  color: var(--muted); font-size: 30px; line-height: 1;
  cursor: pointer;
}
#post-close:hover { color: var(--text); }
#post-img { width: 100%; border-radius: 12px; margin-bottom: 16px; }
#post-title { font-size: 1.3rem; margin-bottom: 8px; }
#post-meta { font: 600 12px var(--font-mono); color: var(--gold); margin-bottom: 16px; }
#post-body { white-space: pre-line; color: var(--text); font-size: 15px; line-height: 1.7; }

/* ============ Modo claro ============ */
html[data-theme="light"] {
  --bg: #eef1f7;
  --bg-soft: #ffffff;
  --surface: rgba(13, 20, 40, 0.045);
  --surface-2: rgba(13, 20, 40, 0.08);
  --border: rgba(13, 20, 40, 0.15);
  --text: #121a2e;
  --muted: #50607b;
  --cyan: #0a6378; /* teal oscuro: el cian brillante se lava sobre claro */
}
/* los chips usan tintes literales del cian oscuro: borde y fondo con cuerpo */
html[data-theme="light"] .card-tags li {
  color: var(--cyan);
  border-color: rgba(10, 99, 120, 0.45);
  background: rgba(10, 99, 120, 0.08);
}
html[data-theme="light"] .accent {
  background: linear-gradient(110deg, #087f99 5%, #1d72ad 52%, #6554c7 100%);
  -webkit-background-clip: text;
  background-clip: text;
  filter: drop-shadow(0 0 18px rgba(29, 114, 173, 0.12));
}
html[data-theme="light"] #hero {
  background-color: var(--bg);
  background-image:
    radial-gradient(ellipse 58% 54% at 50% 28%, rgba(255, 255, 255, 0.16), rgba(32, 32, 32, 0.04) 70%, transparent 100%),
    linear-gradient(180deg, rgba(28, 28, 28, 0.05) 0%, rgba(28, 28, 28, 0.08) 68%, var(--bg) 100%),
    linear-gradient(90deg, rgba(28, 28, 28, 0.1), rgba(255, 255, 255, 0.015) 34%, rgba(255, 255, 255, 0.015) 68%, rgba(28, 28, 28, 0.027)),
    url("https://yzdbodnmvmswpvszzxpc.supabase.co/storage/v1/object/public/img/blanco.jpeg");
}
html[data-theme="light"] #hero::before {
  background:
    radial-gradient(ellipse 50% 52% at 50% 29%, rgba(255, 255, 255, 0.3), rgba(245, 245, 245, 0.12) 54%, transparent 82%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.02), rgba(225, 225, 225, 0.05) 68%, rgba(238, 241, 247, 0.48) 100%);
}
html[data-theme="light"] #hero::after {
  background: radial-gradient(circle, rgba(255, 255, 255, 0.42), rgba(96, 210, 235, 0.16) 30%, transparent 68%);
}
html[data-theme="light"] #neural-canvas {
  opacity: 1;
}
html[data-theme="light"] .hero-sub,
html[data-theme="light"] .picker-label,
html[data-theme="light"] .belt-hint,
html[data-theme="light"] .belt-counter {
  color: #35445f;
  text-shadow: 0 1px 2px rgba(255, 255, 255, 0.82);
}
html[data-theme="light"] .eyebrow,
html[data-theme="light"] .niche-btn,
html[data-theme="light"] .case-btn,
html[data-theme="light"] .ghost-btn {
  background: rgba(246, 249, 254, 0.7);
  backdrop-filter: blur(9px);
  -webkit-backdrop-filter: blur(9px);
}
html[data-theme="light"] .belt-head {
  background: transparent;
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}
html[data-theme="light"] .belt-counter {
  padding: 7px 11px;
  border: 1px solid rgba(13, 20, 40, 0.14);
  border-radius: 9px;
  background: rgba(246, 249, 254, 0.76);
  box-shadow: 0 4px 16px rgba(42, 58, 90, 0.06);
  backdrop-filter: blur(9px);
  -webkit-backdrop-filter: blur(9px);
}
html[data-theme="light"] #navbar.scrolled { background: rgba(255, 255, 255, 0.82); }
html[data-theme="light"] #mobile-menu { background: rgba(255, 255, 255, 0.97); }
html[data-theme="light"] .hero-factory {
  background: transparent;
  box-shadow: none;
}
html[data-theme="light"] .hero-factory::before {
  background:
    radial-gradient(58% 54% at 24% 25%, rgba(14, 116, 144, 0.035), transparent 76%),
    radial-gradient(52% 52% at 78% 72%, rgba(232, 160, 32, 0.026), transparent 78%);
}
html[data-theme="light"] .hero-belt { background: transparent; }
html[data-theme="light"] .belt-stage {
  background: radial-gradient(60% 65% at 50% 78%, rgba(14, 116, 144, 0.035), transparent 74%);
}
html[data-theme="light"] .belt-fog {
  background: radial-gradient(
    ellipse 72% 100% at 50% 100%,
    rgba(220, 228, 241, 0.16) 0%,
    rgba(220, 228, 241, 0.06) 48%,
    transparent 82%
  );
}
html[data-theme="light"] .belt-item { background: rgba(255, 255, 255, 0.96); }
html[data-theme="light"] .station-tag { background: rgba(255, 255, 255, 0.85); }
html[data-theme="light"] .bubble { background: #ffffff; }
html[data-theme="light"] .dlg-panel { background: rgba(255, 255, 255, 0.97); }
html[data-theme="light"] #dialogue, html[data-theme="light"] #post-overlay, html[data-theme="light"] #palette-overlay {
  background: rgba(228, 233, 243, 0.8);
}
html[data-theme="light"] #dlg-input, html[data-theme="light"] #palette-input {
  background: rgba(13, 20, 40, 0.05);
}
html[data-theme="light"] .logo-img { filter: none; }
html[data-theme="light"] .menu-toggle span, html[data-theme="light"] #menu-toggle span { background: var(--text); }
html[data-theme="light"] .terminal-body, html[data-theme="light"] .preloader-terminal { color: #0c7d92; }

/* el humano viene de una imagen de alta resolución: escala suave, no pixelada */
.station-human img { image-rendering: auto; }

/* botón de sonido de la cinta */
#sfx-toggle svg.lucide { color: var(--cyan); }

@media (max-width: 980px) {
  .blog-grid, .learn-grid { grid-template-columns: 1fr; }
  .learn-card-wide { grid-template-columns: 1fr; align-items: start; }
}


/* ============ Refuerzo dorado en secciones ============ */
.card { position: relative; overflow: hidden; }
.card::before {
  content: "";
  position: absolute; top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
  opacity: 0;
  transition: opacity 0.3s;
}
.card:hover::before { opacity: 1; }
.card:hover { border-color: rgba(247, 193, 75, 0.45); }
.card-icon {
  width: 52px; height: 52px;
  display: grid; place-items: center;
  border-radius: 14px;
  border: 1px solid rgba(247, 193, 75, 0.35);
  background: rgba(247, 193, 75, 0.07);
}
.card-icon svg.lucide { color: var(--gold); }

.timeline-step { transition: transform 0.25s, border-color 0.25s; }
.timeline-step:hover { transform: translateY(-4px); border-color: rgba(247, 193, 75, 0.45); }

.project-metric { filter: drop-shadow(0 4px 14px rgba(247, 193, 75, 0.18)); }

/* ============ Footer ============ */
footer {
  border-top: 1px solid var(--border);
  background:
    radial-gradient(700px 260px at 50% 0%, rgba(247, 193, 75, 0.07), transparent 65%),
    var(--surface);
  padding: 0;
}
.footer-grid {
  display: grid;
  grid-template-columns: 1.2fr 1fr 1fr;
  gap: clamp(24px, 4vw, 60px);
  padding: 44px 0 30px;
  align-items: start;
}
.f-brand { display: flex; flex-direction: column; gap: 12px; align-items: flex-start; }
.f-brand .logo-img { height: 30px; }
.f-tag { color: var(--muted); font-size: 13.5px; }
.f-links { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 22px; }
.f-links a {
  color: var(--muted); text-decoration: none; font-size: 14px;
  transition: color 0.2s, transform 0.2s;
}
.f-links a:hover { color: var(--gold); transform: translateX(3px); }
.f-cta { display: flex; flex-direction: column; gap: 11px; align-items: flex-start; }
.f-social {
  display: inline-flex; align-items: center; gap: 7px;
  color: var(--muted); text-decoration: none; font-size: 13.5px;
  transition: color 0.2s;
}
.f-social .lucide { width: 16px; height: 16px; }
.f-social:hover { color: var(--cyan); }
.footer-bottom {
  display: flex; justify-content: space-between; align-items: center;
  flex-wrap: wrap; gap: 10px;
  border-top: 1px solid var(--border);
  padding: 16px 0 18px;
  color: var(--muted); font-size: 13px;
}

/* ============ Detalle de agente ============ */
#agent-overlay {
  position: fixed; inset: 0; z-index: 185;
  background: rgba(4, 6, 12, 0.78);
  backdrop-filter: blur(10px);
  display: grid; place-items: center;
  padding: 4vh 4vw;
}
html[data-theme="light"] #agent-overlay { background: rgba(228, 233, 243, 0.8); }
#agent-modal {
  position: relative;
  width: min(520px, 100%);
  max-height: 88vh;
  overflow-x: hidden;
  overflow-y: auto;
  background: var(--bg-soft);
  border: 1px solid rgba(247, 193, 75, 0.45);
  border-radius: 18px;
  padding: 24px 58px 26px;
  box-shadow: 0 40px 100px rgba(0, 0, 0, 0.6);
  animation: dlg-panel-in 0.3s ease;
}
#agent-modal:focus { outline: none; }
#agent-close {
  position: absolute; top: 10px; right: 16px;
  background: none; border: none;
  color: var(--muted); font-size: 30px; line-height: 1;
  cursor: pointer;
}
#agent-close:hover { color: var(--text); }
#agent-close:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 3px;
  border-radius: 6px;
}
.agent-head { display: flex; align-items: center; gap: 18px; margin-bottom: 14px; }
#agent-modal .card-tags { justify-content: center; }
#agent-img {
  height: 96px; width: auto;
  image-rendering: pixelated;
  filter: drop-shadow(0 8px 16px rgba(0, 0, 0, 0.45));
}
#agent-img.is-human { image-rendering: auto; }
.agent-role { font: 600 11px var(--font-mono); letter-spacing: 0.12em; color: var(--gold); text-transform: uppercase; margin-bottom: 5px; }
#agent-title { font-size: 1.25rem; }
.agent-sec {
  font: 600 11.5px var(--font-mono);
  letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--muted);
  margin: 16px 0 8px;
}
.agent-tasks { list-style: none; display: flex; flex-direction: column; gap: 6px; }
.agent-tasks li { font-size: 14.5px; padding-left: 18px; position: relative; }
.agent-tasks li::before { content: "▸"; position: absolute; left: 0; color: var(--gold); }
.agent-note { margin-top: 16px; font-size: 12.5px; color: var(--muted); opacity: 0.85; }
#agent-cta { display: block; text-align: center; margin-top: 16px; }

@media (max-width: 720px) {
  .footer-grid { grid-template-columns: 1fr; }
}


/* navegación entre agentes dentro del módulo de detalle */
.agent-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  left: 8px;
  width: 30px;
  height: 46px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--gold);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  z-index: 2;
  box-shadow: none;
  opacity: 0.85;
  transition: opacity 0.2s, transform 0.15s;
}
.agent-arrow:hover {
  background: transparent;
  opacity: 1;
  transform: translateY(-50%) scale(1.08);
}
.agent-arrow:active {
  background: transparent;
  transform: translateY(-50%) translateX(2px);
}
.agent-arrow-r {
  left: auto;
  right: 8px;
}
.agent-arrow-r:active { transform: translateY(-50%) translateX(-2px); }
.agent-nav {
  display: flex; justify-content: center; flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}
.agent-nav button {
  width: 46px; height: 46px;
  border-radius: 11px;
  border: 1px solid var(--border);
  background: var(--surface);
  display: grid; place-items: center;
  padding: 4px;
  cursor: pointer;
  transition: border-color 0.2s, transform 0.2s, background 0.2s;
}
.agent-nav button:hover { transform: translateY(-2px); }
.agent-nav button.active { border-color: var(--gold); background: rgba(247, 193, 75, 0.1); }
.agent-nav button img { max-height: 34px; max-width: 34px; image-rendering: pixelated; }


/* ============ FX de trabajo en la cinta ============ */
/* rayo del agente sobre la tarea que está procesando */
.beam {
  position: absolute;
  top: calc(100% - 4px); left: calc(50% - 24px);
  transform: translateX(-50%) skewX(15deg);
  width: 36px; height: 38px;
  background: linear-gradient(rgba(34, 211, 238, 0), rgba(34, 211, 238, 0.5));
  clip-path: polygon(38% 0, 62% 0, 100% 100%, 0 100%);
  animation: beam-flicker 0.3s linear infinite;
  pointer-events: none;
  z-index: 1;
}
.beam.gold { background: linear-gradient(rgba(247, 193, 75, 0), rgba(247, 193, 75, 0.55)); }
@keyframes beam-flicker { 50% { opacity: 0.5; } }

/* refuerzo positivo flotante */
.float-pop {
  position: absolute; bottom: 80px;
  font: 700 13px var(--font-mono);
  color: var(--green);
  text-shadow: 0 0 8px rgba(52, 211, 153, 0.6);
  pointer-events: none;
  z-index: 5;
  animation: float-pop 0.9s ease forwards;
}
.float-pop.fix { color: var(--gold); text-shadow: 0 0 8px rgba(247, 193, 75, 0.6); }
@keyframes float-pop {
  from { opacity: 0; transform: translateY(8px); }
  25% { opacity: 1; }
  to { opacity: 0; transform: translateY(-28px); }
}

/* tarea con problema: se nota, y se nota cuando se resuelve */
.belt-item.issue {
  border-color: rgba(255, 107, 107, 0.75);
  box-shadow: 0 0 16px rgba(255, 107, 107, 0.35);
}

/* flechas del módulo de agente con UI propia */
.agent-arrow {
  display: grid;
  place-items: center;
}
.agent-arrow svg.lucide { width: 22px; height: 22px; }


/* ============ Shine en botones primarios ============
   Cada botón recibe su propio --sheen-delay (lo asigna main.js) para
   que los barridos NO ocurran todos a la vez; al hacer hover el brillo
   barre al instante. */
.btn-primary, .btn-cta {
  position: relative;
  overflow: hidden;
}
.btn-primary::after, .btn-cta::after {
  content: "";
  position: absolute; inset: 0;
  background: linear-gradient(110deg, transparent 32%, rgba(255, 255, 255, 0.38) 50%, transparent 68%);
  transform: translateX(-130%);
  animation: btn-sheen 7s ease-in-out var(--sheen-delay, 0s) infinite;
  pointer-events: none;
}
.btn-primary:hover::after, .btn-cta:hover::after {
  animation: btn-sheen-hover 0.7s ease-out;
}
@keyframes btn-sheen {
  0% { transform: translateX(-130%); }
  9% { transform: translateX(130%); }
  100% { transform: translateX(130%); }
}
@keyframes btn-sheen-hover {
  from { transform: translateX(-130%); }
  to   { transform: translateX(130%); }
}
@media (prefers-reduced-motion: reduce) {
  .btn-primary::after, .btn-cta::after { animation: none; }
}


/* ============ Secciones con fondo liquid vector ============ */
.liquid-section { position: relative; overflow: hidden; }
.liquid-canvas {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  z-index: 0;
  pointer-events: none;
  /* los fondos entran y salen en degradado: la transición entre
     secciones se siente continua, no cortada */
  -webkit-mask-image: linear-gradient(transparent, #000 14%, #000 86%, transparent);
  mask-image: linear-gradient(transparent, #000 14%, #000 86%, transparent);
}
.liquid-section > *:not(.liquid-canvas) { position: relative; z-index: 1; }
/* viñeta sutil para que el contenido respire sobre las ondas */
.liquid-section::after {
  content: "";
  position: absolute; inset: 0;
  z-index: 0;
  pointer-events: none;
  background: radial-gradient(70% 55% at 50% 42%, rgba(6, 8, 15, 0.3), transparent 75%);
}
html[data-theme="light"] .liquid-section::after {
  background: radial-gradient(70% 55% at 50% 42%, rgba(238, 241, 247, 0.42), transparent 75%);
}

/* ============ Reveals escalonados ============ */
.cards-grid > .reveal:nth-child(2), .timeline > .reveal:nth-child(2),
.projects-grid > .reveal:nth-child(2), .cv-timeline > .reveal:nth-child(2) { transition-delay: 0.09s; }
.cards-grid > .reveal:nth-child(3), .timeline > .reveal:nth-child(3),
.projects-grid > .reveal:nth-child(3), .cv-timeline > .reveal:nth-child(3) { transition-delay: 0.18s; }
.cards-grid > .reveal:nth-child(4), .timeline > .reveal:nth-child(4),
.cv-timeline > .reveal:nth-child(4) { transition-delay: 0.27s; }
.cards-grid > .reveal:nth-child(5), .cv-timeline > .reveal:nth-child(5) { transition-delay: 0.36s; }
.cards-grid > .reveal:nth-child(6) { transition-delay: 0.45s; }

/* la línea de tiempo entra desde la izquierda */
.cv-item.reveal { transform: translateX(-32px); }
.cv-item.reveal.visible { transform: none; }

/* ============ Servicios (entrada coreografiada) ============ */
/* con la escena GSAP activa, el reveal clásico no debe competir */
#servicios.fx-on .card.reveal {
  opacity: 1;
  transform: none;
  transition: none;
  transition-delay: 0s;
}

/* ============ Proyectos (escena scroll: mazo de cards) ============ */
/* .fx-on la pone scrollfx.js solo con GSAP + desktop + sin reduced-motion */
#proyectos { position: relative; overflow: hidden; }
#proyectos.fx-on {
  min-height: 100vh;
  display: flex;
  align-items: center;
  padding-top: var(--nav-h);
}
.proy-inner { position: relative; }

/* Métrica gigante de fondo, sincronizada con el caso activo */
.proy-bignum {
  position: absolute;
  right: -10px; top: -20px;
  z-index: 0;
  font: 700 clamp(110px, 17vw, 210px)/1 var(--font-head);
  letter-spacing: -0.04em;
  color: transparent;
  -webkit-text-stroke: 1.5px rgba(247, 193, 75, 0.2);
  pointer-events: none;
  user-select: none;
}
.proy-bignum span { display: inline-block; }
.proy-bignum span.pop { animation: bignum-pop 0.45s cubic-bezier(0.22, 1, 0.36, 1); }
#proyectos:not(.fx-on) .proy-bignum { display: none; }

/* En la escena las cards se apilan como mazo en el centro */
#proyectos.fx-on .projects-grid {
  position: relative;
  z-index: 1;
  display: block;
  height: 490px;
  max-width: 680px;
  margin-inline: auto;
}
#proyectos.fx-on .project {
  position: absolute;
  inset: 0;
  /* fondo SÓLIDO: apiladas no debe traslucirse la card de atrás */
  background: linear-gradient(160deg, rgba(247, 193, 75, 0.07), transparent 45%), #0c1322;
  /* GSAP maneja transform/opacity: sin transiciones que compitan */
  transition: border-color 0.3s, box-shadow 0.3s;
}
html[data-theme="light"] #proyectos.fx-on .project {
  background: linear-gradient(160deg, rgba(232, 160, 32, 0.08), transparent 45%), #f4f7fc;
}
#proyectos.fx-on .project.active {
  border-color: rgba(247, 193, 75, 0.55);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
}
#proyectos.fx-on .projects-note { text-align: center; }

/* ============ Trayectoria (escena scroll: la línea se enciende) ============ */
/* La línea base queda apagada y un trazo dorado la va dibujando con el scroll */
#trayectoria.fx-on .cv-timeline::before { background: var(--border); }
.cv-line-fill {
  position: absolute;
  left: 7px; top: 8px; bottom: 8px;
  width: 2px;
  background: linear-gradient(var(--gold), var(--cyan));
  transform-origin: top center;
  box-shadow: 0 0 10px rgba(247, 193, 75, 0.4);
}
#trayectoria:not(.fx-on) .cv-line-fill { display: none; }

/* Los hitos esperan apagados y se encienden cuando la línea les llega */
#trayectoria.fx-on .cv-item {
  opacity: 0.3;
  transform: translateX(-18px);
  transition: opacity 0.45s, transform 0.45s;
}
#trayectoria.fx-on .cv-item.lit { opacity: 1; transform: none; }
#trayectoria.fx-on .cv-item::before {
  background: var(--bg);
  border-color: var(--border);
  box-shadow: none;
  transition: background 0.4s, border-color 0.4s, box-shadow 0.4s;
}
#trayectoria.fx-on .cv-item.lit::before {
  background: var(--gold);
  border-color: var(--gold);
  box-shadow: 0 0 14px rgba(247, 193, 75, 0.7);
}

/* ============ Mobile-first refinements ============ */
body.overlay-open { overflow: hidden; overscroll-behavior: none; }
.mobile-factory { display: none; }

@media (max-width: 980px) {
  section { padding-block: clamp(62px, 8vw, 82px); }
  #mobile-menu {
    max-height: calc(100dvh - var(--nav-h));
    overflow-y: auto;
    overscroll-behavior: contain;
    padding-bottom: max(18px, env(safe-area-inset-bottom));
  }
  #mobile-menu a { min-height: 48px; display: flex; align-items: center; }
  .ghost-btn, .btn, #menu-toggle { min-height: 44px; }
}

@media (max-width: 720px) {
  :root {
    --nav-h: 64px;
    --radius: 16px;
  }

  html { overflow-x: hidden; scroll-padding-top: calc(var(--nav-h) + 10px); }
  body { overflow-x: hidden; }
  .container { width: min(100% - 28px, 680px); }
  section { padding: 56px 0; }

  .nav-inner { width: calc(100% - 24px); gap: 8px; }
  .logo-img { height: 23px; max-width: 144px; object-fit: contain; }
  .nav-actions { gap: 5px; margin-left: auto; }
  #theme-toggle, #lang-toggle { width: 40px; min-width: 40px; height: 44px; padding: 0; }
  #menu-toggle { width: 42px; align-items: center; justify-content: center; padding: 9px; }
  #mobile-menu { padding-inline: 14px; }

  #hero {
    min-height: auto;
    padding: calc(var(--nav-h) + 10px) 0 28px;
    overflow: clip;
  }
  #neural-canvas { opacity: 0.84; }
  .hero-factory { width: 100%; }
  .hero-factory::before { inset: -4% 0; filter: blur(28px); }
  .hero-inner {
    width: 100%;
    padding: 4px 14px 0;
    gap: 6px;
  }
  .eyebrow {
    max-width: 100%;
    margin-bottom: 6px;
    padding: 6px 10px;
    font-size: 10px;
    letter-spacing: 0.08em;
    line-height: 1.35;
    text-align: left;
  }
  #hero h1 {
    max-width: 13ch;
    margin-bottom: 10px;
    font-size: clamp(2.05rem, 10.5vw, 3rem);
    line-height: 1;
    letter-spacing: -0.055em;
  }
  .hero-sub {
    max-width: 38ch;
    margin-bottom: 10px;
    font-size: 0.95rem;
    line-height: 1.55;
  }
  .hero-ctas { width: 100%; gap: 9px; margin-bottom: 12px; }
  .hero-ctas .btn { width: 100%; padding: 12px 18px; text-align: center; }

  .hero-picker { width: 100%; align-items: stretch; gap: 7px; }
  .picker-label { padding-inline: 2px; font-size: 10.5px; letter-spacing: 0.1em; }
  .niche-row, .case-row {
    width: 100%;
    justify-content: flex-start;
    flex-wrap: nowrap;
    gap: 8px;
    padding: 2px 2px 7px;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scroll-snap-type: x proximity;
    scrollbar-width: none;
  }
  .niche-row::-webkit-scrollbar, .case-row::-webkit-scrollbar { display: none; }
  .niche-btn, .case-btn {
    flex: 0 0 auto;
    min-height: 42px;
    scroll-snap-align: start;
  }
  .niche-btn { padding: 8px 14px; font-size: 13px; }
  .case-btn { padding: 8px 13px; font-size: 12.5px; }

  .hero-belt { padding: 14px 14px 2px; }
  .belt-head { gap: 9px; }
  .belt-title { width: 100%; font-size: 13px; line-height: 1.35; }
  .belt-controls {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 44px;
    width: 100%;
    gap: 8px;
  }
  #belt-inject { width: 100%; min-height: 44px; color: var(--text); }
  #sfx-toggle { width: 44px; height: 44px; padding: 0; }
  .belt-counter {
    grid-column: 1 / -1;
    line-height: 1.4;
    font-size: 11.5px;
  }
  .belt-hint { display: none; }
  .belt-viewport { display: none; }

  .mobile-factory {
    display: block;
    position: relative;
    margin-top: 12px;
    padding: 10px 0 2px;
  }
  .mobile-flow {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 10px;
  }
  .mobile-flow::before {
    content: "";
    position: absolute;
    z-index: 0;
    top: 38px;
    bottom: 38px;
    left: 31px;
    width: 2px;
    background: linear-gradient(var(--cyan), rgba(34, 211, 238, 0.2) 65%, var(--gold));
    box-shadow: 0 0 12px rgba(34, 211, 238, 0.18);
  }
  .mobile-step {
    position: relative;
    z-index: 1;
    display: grid;
    grid-template-columns: 64px minmax(0, 1fr);
    align-items: center;
    width: 100%;
    min-height: 88px;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--text);
    font: inherit;
    text-align: left;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }
  .mobile-step-node {
    position: relative;
    display: grid;
    place-items: center;
    width: 62px;
    height: 72px;
  }
  .mobile-step-node::before {
    content: "";
    position: absolute;
    inset: 8px 5px 4px;
    border: 1px solid var(--border);
    border-radius: 15px;
    background: #0c1322;
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.24);
    transition: border-color 0.25s, box-shadow 0.25s, background 0.25s;
  }
  html[data-theme="light"] .mobile-step-node::before { background: #f4f7fc; }
  .mobile-step-node img {
    position: relative;
    z-index: 1;
    width: 48px;
    height: 58px;
    object-fit: contain;
    object-position: center bottom;
    image-rendering: pixelated;
    filter: var(--st-hue, hue-rotate(0deg)) drop-shadow(0 7px 8px rgba(0, 0, 0, 0.42));
  }
  .mobile-step-node img.is-human { image-rendering: auto; }
  .mobile-step-num {
    position: absolute;
    z-index: 2;
    top: 0;
    left: 1px;
    padding: 2px 5px;
    border-radius: 6px;
    background: var(--bg-soft);
    color: var(--cyan);
    font: 700 9px var(--font-mono);
    border: 1px solid var(--border);
  }
  .mobile-step-copy {
    display: flex;
    min-width: 0;
    flex-direction: column;
    gap: 3px;
    margin-left: 10px;
    padding: 13px 14px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--surface);
    transition: border-color 0.25s, background 0.25s, transform 0.25s;
  }
  .mobile-step-role {
    color: var(--cyan);
    font: 600 9.5px var(--font-mono);
    letter-spacing: 0.1em;
    text-transform: uppercase;
  }
  .mobile-step-copy strong { font: 600 13.5px/1.35 var(--font-head); }
  .mobile-step-status {
    overflow: hidden;
    color: var(--muted);
    font-size: 11.5px;
    line-height: 1.4;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .mobile-step.active .mobile-step-copy {
    transform: translateX(3px);
    border-color: rgba(34, 211, 238, 0.65);
    background: rgba(34, 211, 238, 0.08);
  }
  .mobile-step.active .mobile-step-node::before {
    border-color: var(--cyan);
    box-shadow: 0 0 22px rgba(34, 211, 238, 0.22);
  }
  .mobile-step.done .mobile-step-num { color: var(--green); border-color: rgba(52, 211, 153, 0.4); }
  .mobile-step.done .mobile-step-copy { border-color: rgba(52, 211, 153, 0.28); }
  .mobile-step-human .mobile-step-role, .mobile-step-human .mobile-step-num { color: var(--gold); }
  .mobile-step-human .mobile-step-copy { border-color: rgba(247, 193, 75, 0.3); }
  .mobile-step-human.active .mobile-step-copy {
    border-color: rgba(247, 193, 75, 0.72);
    background: rgba(247, 193, 75, 0.09);
  }
  .mobile-step-human.active .mobile-step-node::before {
    border-color: var(--gold);
    box-shadow: 0 0 22px rgba(247, 193, 75, 0.24);
  }
  .mobile-flow-task {
    position: absolute;
    z-index: 5;
    top: 0;
    left: 17px;
    display: grid;
    place-items: center;
    width: 29px;
    height: 29px;
    border: 1px solid rgba(34, 211, 238, 0.72);
    border-radius: 50%;
    background: var(--bg-soft);
    box-shadow: 0 0 16px rgba(34, 211, 238, 0.4);
    transition: transform 0.62s cubic-bezier(0.22, 1, 0.36, 1);
    will-change: transform;
  }
  .mobile-task-icon { position: relative; z-index: 1; font-size: 14px; line-height: 1; }
  .mobile-task-pulse {
    position: absolute;
    inset: -5px;
    border: 1px solid rgba(34, 211, 238, 0.45);
    border-radius: inherit;
    animation: mobile-task-pulse 1.1s ease-out infinite;
  }
  @keyframes mobile-task-pulse {
    to { transform: scale(1.55); opacity: 0; }
  }
  .mobile-mufi {
    display: flex;
    align-items: center;
    gap: 9px;
    max-width: calc(100% - 66px);
    min-height: 44px;
    margin: 8px 0 0 66px;
    padding: 7px 11px;
    border: 1px solid rgba(247, 193, 75, 0.3);
    border-radius: 12px;
    background: rgba(247, 193, 75, 0.06);
    color: var(--muted);
    font: 500 11px/1.35 var(--font-body);
    text-align: left;
  }
  .mobile-mufi img { width: 36px; height: 36px; object-fit: contain; image-rendering: pixelated; }
  .mobile-mufi.celebrate { animation: mobile-mufi-pop 0.55s cubic-bezier(0.34, 1.56, 0.64, 1); }
  @keyframes mobile-mufi-pop {
    45% { transform: translateY(-5px) rotate(-2deg) scale(1.04); }
  }

  .cards-grid, .projects-grid, .timeline, .blog-grid { grid-template-columns: 1fr; }
  .card, .project, .timeline-step { padding: 22px 19px; }
  .section-head { margin-bottom: 30px; }
  .section-head h2 { font-size: clamp(1.9rem, 9vw, 2.55rem); }
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 22px 8px; padding: 22px 12px; }
  .stat-number { font-size: clamp(1.65rem, 9vw, 2.3rem); }
  .stat-label { display: block; font-size: 12px; line-height: 1.4; }
  .about-grid, .contact-panel, .cv-grid { grid-template-columns: 1fr; }
  .id-card { padding: 22px 18px; transform: none; }
  .id-avatar { width: 76px; height: 76px; border-radius: 18px; }
  .cv-item { padding-left: 30px; }
  .contact-panel { padding: 34px 18px; border-radius: 19px; }
  .btn-cta { width: 100%; justify-content: center; padding: 15px 18px; font-size: 15px; }
  .footer-grid { padding-block: 34px 24px; }
  .f-links { gap: 9px 14px; }
  .footer-bottom { align-items: flex-start; flex-direction: column; }

  #contact-overlay, #post-overlay, #agent-overlay {
    display: flex;
    align-items: flex-end;
    padding: 12px 0 0;
  }
  #contact-modal, #post-modal, #agent-modal {
    width: 100%;
    max-height: calc(100dvh - 12px);
    border-radius: 20px 20px 0 0;
    padding: 26px 18px max(24px, env(safe-area-inset-bottom));
    overscroll-behavior: contain;
  }
  #agent-modal { padding-inline: 46px; }
  .agent-head { align-items: center; gap: 12px; }
  #agent-img { height: 76px; }
  .agent-arrow { position: fixed; top: 50%; width: 42px; height: 58px; }
  .agent-nav { flex-wrap: nowrap; justify-content: flex-start; overflow-x: auto; }
  .agent-nav button { flex: 0 0 44px; width: 44px; height: 44px; }
  #contact-modal { max-height: 100dvh; }
  #cf-form { gap: 13px; }
  #cf-form input[type="text"], #cf-form input[type="email"],
  #cf-form input[type="tel"], #cf-form textarea {
    min-height: 46px;
    font-size: 16px;
  }
  #post-modal { padding-inline: 18px; }

  #palette-overlay {
    align-items: flex-start;
    padding: max(12px, env(safe-area-inset-top)) 10px max(12px, env(safe-area-inset-bottom));
  }
  #palette {
    width: 100%;
    max-height: calc(100dvh - 24px);
    border-radius: 14px;
  }
  #palette-input { min-height: 54px; font-size: 16px; }
  #palette-list { max-height: calc(100dvh - 150px); }

  .pet-fab { --pet-scale: 0.35; }
  #chat-fab {
    right: max(8px, env(safe-area-inset-right));
    bottom: max(6px, env(safe-area-inset-bottom));
    padding: 4px 3px 10px;
  }
  #chat-fab::before { inset: -9px -11px 0; filter: blur(5px); }
  #chat-fab::after { height: 7px; bottom: 3px; }
  .fab-tip { display: none; }

  #dialogue {
    align-items: stretch;
    justify-content: flex-start;
    padding:
      max(48px, calc(env(safe-area-inset-top) + 38px))
      10px
      max(8px, env(safe-area-inset-bottom));
    overflow-y: auto;
    overscroll-behavior: contain;
  }
  #dialogue-close {
    position: fixed;
    z-index: 4;
    top: max(8px, env(safe-area-inset-top));
    right: 12px;
    width: 44px;
    height: 44px;
    font-size: 32px;
  }
  .dlg-stage {
    flex-direction: column;
    align-items: stretch;
    gap: 5px;
    width: 100%;
    min-height: 0;
    margin: auto 0 0;
  }
  .dlg-pet { align-self: center; }
  .pet-big { --pet-scale: 0.4; }
  .dlg-pet-shadow { height: 8px; margin-top: -2px; }
  .dlg-panel {
    display: flex;
    flex-direction: column;
    width: 100%;
    min-height: 0;
    max-height: calc(100dvh - 145px);
    padding: 15px 14px max(12px, env(safe-area-inset-bottom));
    border-width: 1px;
    border-radius: 17px 17px 0 0;
    overflow: hidden;
    overscroll-behavior: contain;
  }
  .dlg-panel::before { content: none; }
  #dialogue.contact-mode .dlg-panel {
    max-height: calc(100dvh - 145px);
    overflow: hidden;
  }
  .dlg-scroll {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding-bottom: 8px;
  }
  .dlg-name { font-size: 11px; margin-bottom: 6px; }
  .dlg-text { min-height: 64px; font-size: 14px; line-height: 1.55; }
  .dlg-text,
  .dlg-options,
  #dlg-contact-form {
    flex: 0 0 auto;
  }
  .dlg-options { margin-top: 9px; padding-bottom: 2px; }
  .dlg-options button { min-height: 42px; padding: 9px 10px; }
  .dlg-options button,
  .dlg-contact-actions button,
  #dlg-form button {
    touch-action: manipulation;
  }
  #dlg-form {
    position: static;
    flex: 0 0 auto;
    z-index: 2;
    margin-top: 8px;
    padding-top: 10px;
    background: var(--bg-soft);
  }
  #dlg-input { min-width: 0; min-height: 46px; font-size: 16px; }
  #dlg-form button { flex: 0 0 46px; width: 46px; min-height: 46px; }
  .dlg-contact-grid { grid-template-columns: 1fr; }
  .dlg-contact-wide { grid-column: auto; }
  .dlg-contact-grid input[type="text"],
  .dlg-contact-grid input[type="email"],
  .dlg-contact-grid input[type="tel"],
  .dlg-contact-grid textarea {
    min-height: 44px;
    font-size: 16px;
  }
  .dlg-contact-actions {
    position: sticky;
    bottom: 0;
    padding-top: 10px;
    background: var(--bg-soft);
  }
  .dlg-contact-actions button { flex: 1; min-height: 44px; }
}

@media (max-width: 380px) {
  .nav-actions { gap: 2px; }
  #theme-toggle, #lang-toggle { width: 36px; min-width: 36px; }
  .logo-img { max-width: 126px; }
  #hero h1 { font-size: 2rem; }
  .hero-inner, .hero-belt { padding-inline: 11px; }
  .mobile-step { grid-template-columns: 58px minmax(0, 1fr); }
  .mobile-step-node { width: 56px; }
  .mobile-flow::before { left: 28px; }
  .mobile-flow-task { left: 14px; }
  .mobile-step-copy { margin-left: 7px; padding-inline: 11px; }
  .mobile-mufi { max-width: calc(100% - 60px); margin-left: 60px; }
  #agent-modal { padding-inline: 40px; }
}

@media (max-width: 720px) and (orientation: landscape) {
  #hero h1 { max-width: 18ch; font-size: clamp(2rem, 7vw, 2.7rem); }
  .pet-big { --pet-scale: 0.28; }
  .dlg-stage { flex-direction: row; align-items: flex-end; }
  .dlg-pet { flex: 0 0 auto; }
  .dlg-panel { max-height: calc(100dvh - 58px); border-radius: 16px; }
}

@media (max-width: 720px) and (prefers-reduced-motion: reduce) {
  .mobile-task-pulse { animation: none; }
  .mobile-flow-task { transition: none; }
  .mobile-mufi { animation: none !important; }
}
