/* ==========================================================================
   Kiersys — sistema compartido (todas las páginas)
   Idea visual: "sala de control". Lo repetitivo se resuelve solo frente a
   tus ojos: cada pieza muestra una pregunta que pasa a estar respondida.
   ========================================================================== */

@property --bg    { syntax: '<color>'; inherits: true; initial-value: #05070d; }
@property --fg    { syntax: '<color>'; inherits: true; initial-value: #eef1f7; }
@property --muted { syntax: '<color>'; inherits: true; initial-value: #8b93a7; }
@property --line  { syntax: '<color>'; inherits: true; initial-value: rgba(255,255,255,.12); }
@property --accent{ syntax: '<color>'; inherits: true; initial-value: #5aa2ff; }

:root {
  --ink: #05070d;
  --ink-2: #0b101b;
  --ink-3: #121a2a;
  --paper: #f2f0eb;
  --paper-2: #e6e3dc;
  --blue: #2563eb;
  --blue-2: #1d4ed8;
  --electric: #5aa2ff;
  --green: #10b981;
  --violet: #a78bfa;

  --sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --serif: "Instrument Serif", "Iowan Old Style", Georgia, serif;

  --ease: cubic-bezier(.2, .7, .1, 1);
  --ease-out: cubic-bezier(.16, 1, .3, 1);
  --gutter: clamp(16px, 4vw, 56px);
  --maxw: 1320px;
  --r-sm: 8px; --r: 12px; --r-lg: 20px;
}

body[data-theme="dark"]  { --bg: #05070d; --fg: #eef1f7; --muted: #8b93a7; --line: rgba(255,255,255,.12); --accent: #5aa2ff; }
body[data-theme="light"] { --bg: #f2f0eb; --fg: #0f172a; --muted: #566074; --line: rgba(15,23,42,.13); --accent: #2563eb; }

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 90px; }
@media (prefers-reduced-motion: no-preference) { html { scroll-behavior: smooth; } }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--sans);
  font-size: 1.0625rem;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
  transition: --bg .8s var(--ease), --fg .8s var(--ease), --muted .8s var(--ease), --line .8s var(--ease), --accent .8s var(--ease);
}
img, svg, canvas { display: block; max-width: 100%; }
a { color: inherit; }
button { font: inherit; color: inherit; }
em { font-family: var(--serif); font-style: italic; font-weight: 400; letter-spacing: -.01em; }
::selection { background: var(--blue); color: #fff; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }

.wrap { width: 100%; max-width: var(--maxw); margin: 0 auto; padding: 0 var(--gutter); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: fixed; left: 16px; top: -60px; z-index: 200; background: var(--blue); color: #fff; padding: 10px 16px; border-radius: var(--r-sm); text-decoration: none; }
.skip:focus { top: 16px; }

/* Grano fino sobre todo el sitio: da materia a los planos de color */
.grain {
  position: fixed; inset: -50%; z-index: 90; pointer-events: none; opacity: .07;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  mix-blend-mode: overlay;
}

/* ---------- Tipografía de sección ---------- */
.label {
  display: inline-flex; align-items: center; gap: .6em;
  font-size: .78rem; font-weight: 600; letter-spacing: .14em; text-transform: uppercase;
  color: var(--muted); margin: 0 0 1.4rem;
}
.label::before { content: ""; width: 18px; height: 1px; background: currentColor; }
.h2 {
  font-size: clamp(2.1rem, 5.2vw, 4.6rem);
  line-height: 1; letter-spacing: -.045em; font-weight: 700;
  margin: 0 0 1.5rem; max-width: 16ch; text-wrap: balance;
}
.h2 em { color: var(--accent); font-size: 1.08em; }
.lede { font-size: clamp(1.05rem, 1.4vw, 1.25rem); color: var(--muted); max-width: 46ch; margin: 0; }

/* ---------- Botones ---------- */
.btn {
  --h: 56px;
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: .6rem;
  height: var(--h); padding: 0 1.6rem; border-radius: 999px;
  font-weight: 600; font-size: 1rem; text-decoration: none; white-space: nowrap;
  border: 1px solid transparent; overflow: hidden; isolation: isolate;
  transition: transform .4s var(--ease-out), background-color .3s, color .3s, border-color .3s;
}
.btn > span { position: relative; z-index: 1; display: inline-flex; align-items: center; gap: .6rem; }
.btn-primary { background: var(--blue); color: #fff; }
.btn-primary::before {
  content: ""; position: absolute; inset: 0; z-index: 0; border-radius: inherit;
  background: radial-gradient(120px circle at var(--bx, 50%) var(--by, 50%), rgba(255,255,255,.35), transparent 60%);
  opacity: 0; transition: opacity .3s;
}
.btn-primary:hover::before { opacity: 1; }
.btn-primary:hover { background: var(--blue-2); }
.btn-ghost { border-color: var(--line); color: var(--fg); }
.btn-ghost:hover { border-color: var(--fg); }
.btn svg { width: 18px; height: 18px; }
.arrow-link {
  display: inline-flex; align-items: center; gap: .5rem; font-weight: 600; text-decoration: none;
  border-bottom: 1px solid currentColor; padding-bottom: 2px;
}
.arrow-link span { transition: transform .35s var(--ease-out); }
.arrow-link:hover span { transform: translateX(5px); }

/* ---------- Cursor propio (solo puntero fino) ---------- */
.cursor { display: none; }
@media (pointer: fine) {
  .has-cursor .cursor {
    display: block; position: fixed; left: 0; top: 0; z-index: 150; pointer-events: none;
    width: 0; height: 0;
  }
  .cursor-ring {
    position: absolute; left: -18px; top: -18px; width: 36px; height: 36px; border-radius: 50%;
    border: 1px solid rgba(255,255,255,.7); mix-blend-mode: difference;
    display: grid; place-items: center;
    transition: width .35s var(--ease-out), height .35s var(--ease-out), left .35s var(--ease-out), top .35s var(--ease-out), background-color .3s, border-color .3s;
  }
  .cursor-ring b { font-size: .72rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: #000; opacity: 0; transition: opacity .2s; }
  .cursor.is-hover .cursor-ring { width: 64px; height: 64px; left: -32px; top: -32px; background: #fff; border-color: #fff; }
  .cursor.is-label .cursor-ring { width: 88px; height: 88px; left: -44px; top: -44px; background: #fff; border-color: #fff; mix-blend-mode: normal; }
  .cursor.is-label .cursor-ring b { opacity: 1; }
  .cursor.is-down .cursor-ring { transform: scale(.85); }
}

/* ---------- Barra de progreso ---------- */
.progress { position: fixed; left: 0; top: 0; height: 2px; width: 100%; z-index: 120; transform-origin: 0 50%; transform: scaleX(0); background: var(--accent); }

/* ---------- Navegación ---------- */
.nav {
  position: fixed; top: 14px; left: 50%; z-index: 100;
  width: min(calc(100% - 24px), 1180px);
  transform: translateX(-50%);
  display: flex; align-items: center; gap: 1rem;
  padding: 8px 8px 8px 20px; border-radius: 999px;
  border: 1px solid transparent;
  transition: transform .5s var(--ease-out), background-color .4s, border-color .4s, backdrop-filter .4s;
}
.nav.is-scrolled {
  background: color-mix(in srgb, var(--bg) 72%, transparent);
  border-color: var(--line);
  -webkit-backdrop-filter: blur(14px) saturate(1.4); backdrop-filter: blur(14px) saturate(1.4);
}
.nav.is-hidden { transform: translate(-50%, calc(-100% - 24px)); }
.nav-logo { display: inline-flex; align-items: center; gap: .6rem; text-decoration: none; font-weight: 800; letter-spacing: .16em; font-size: .95rem; }
.nav-logo img { width: 30px; height: 30px; border-radius: 8px; object-fit: cover; }
.nav-links { display: flex; gap: .25rem; margin-left: auto; }
.nav-links a {
  position: relative; padding: .55rem .9rem; border-radius: 999px; text-decoration: none;
  font-size: .92rem; font-weight: 500; color: var(--muted); transition: color .25s, background-color .25s;
}
.nav-links a:hover { color: var(--fg); background: color-mix(in srgb, var(--fg) 7%, transparent); }
.nav-cta { height: 44px; padding: 0 1.2rem; font-size: .92rem; }
.nav-burger { display: none; margin-left: auto; width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--line); background: transparent; cursor: pointer; position: relative; }
.nav-burger span { position: absolute; left: 13px; right: 13px; height: 1.5px; background: currentColor; transition: transform .4s var(--ease-out); }
.nav-burger span:first-child { top: 18px; }
.nav-burger span:last-child { top: 24px; }
.menu-open .nav-burger span:first-child { transform: translateY(3px) rotate(45deg); }
.menu-open .nav-burger span:last-child { transform: translateY(-3px) rotate(-45deg); }

.menu {
  position: fixed; inset: 0; z-index: 95; background: var(--ink); color: #eef1f7;
  padding: 110px var(--gutter) 40px; display: flex; flex-direction: column; justify-content: space-between;
  clip-path: circle(0 at calc(100% - 46px) 40px); transition: clip-path .7s var(--ease-out); visibility: hidden;
}
.menu-open .menu { clip-path: circle(150% at calc(100% - 46px) 40px); visibility: visible; }
.menu ul { list-style: none; margin: 0; padding: 0; }
.menu li { border-bottom: 1px solid rgba(255,255,255,.08); }
.menu li a { display: flex; align-items: center; font-size: clamp(1.35rem, 5.6vw, 1.75rem); font-weight: 600; letter-spacing: -.025em; line-height: 1.2; text-decoration: none; padding: .85rem 0; }
.menu li a::after { content: "→"; margin-left: auto; color: #8b93a7; font-weight: 400; transition: transform .3s var(--ease-out); }
.menu li a:hover::after { transform: translateX(4px); color: var(--electric); }
.menu li a em { color: var(--electric); margin-left: .3em; }
.menu-foot { display: grid; gap: .4rem; color: #8b93a7; font-size: .95rem; }
.menu-foot a { text-decoration: none; color: #eef1f7; }

@media (max-width: 900px) {
  .nav-links, .nav .nav-cta { display: none; }
  .nav-burger { display: block; }
}

/* ---------- Revelado de palabras ---------- */
.js [data-split] .w { display: inline-block; overflow: hidden; vertical-align: top; padding: 0 .06em .1em; margin: 0 -.06em -.1em; }
.js [data-split] .w > span { display: inline-block; transform: translateY(105%); transition: transform 1s var(--ease-out); transition-delay: calc(var(--i, 0) * 45ms); }
.js [data-split].in .w > span { transform: none; }
.js [data-reveal] { opacity: 0; translate: 0 28px; transition: opacity .9s var(--ease-out), translate .9s var(--ease-out), transform .5s var(--ease-out), border-color .4s, background-color .4s; transition-delay: var(--d, 0ms), var(--d, 0ms), 0ms, 0ms, 0ms; }
.js [data-reveal].in { opacity: 1; translate: none; }


/* ---------- Footer ---------- */
.footer { padding: clamp(3rem, 6vw, 5rem) 0 2rem; border-top: 1px solid var(--line); }
.foot-grid { display: grid; grid-template-columns: minmax(0, 1.3fr) repeat(4, minmax(0, 1fr)); gap: 2.5rem; }
.foot-grid h4 { font-size: .78rem; text-transform: uppercase; letter-spacing: .14em; color: var(--muted); margin: 0 0 1rem; font-weight: 600; }
.foot-grid ul { list-style: none; margin: 0; padding: 0; display: grid; gap: .5rem; }
.foot-grid a { text-decoration: none; color: #c3c9d6; font-size: .93rem; transition: color .2s; }
.foot-grid a:hover { color: #fff; }
.foot-brand p { color: var(--muted); max-width: 32ch; margin: 0 0 1rem; font-size: .95rem; }
.wordmark {
  margin: clamp(3rem, 7vw, 5rem) 0 1.5rem; font-weight: 800; letter-spacing: -.06em; line-height: .8;
  font-size: clamp(4.5rem, 21vw, 19rem); user-select: none; white-space: nowrap;
  color: transparent; -webkit-text-stroke: 1px rgba(255,255,255,.14);
  background: radial-gradient(340px circle at var(--mx, 50%) var(--my, 50%), #5aa2ff, rgba(90,162,255,0) 70%);
  -webkit-background-clip: text; background-clip: text;
}
.foot-legal { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 1rem; font-size: .8rem; color: #6b7487; border-top: 1px solid var(--line); padding-top: 1.5rem; }

@media (max-width: 1000px) {
  .foot-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .foot-brand { grid-column: 1 / -1; }
}
@media (max-width: 560px) {
  .foot-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  .js [data-split] .w > span { transform: none; }
  .js [data-reveal] { translate: none; opacity: 1; }
}

/* ---------- Página actual ---------- */
.nav-links a[aria-current="page"] { color: var(--fg); }
.nav-links a[aria-current="page"]::after { content: ""; position: absolute; left: 50%; bottom: 4px; width: 4px; height: 4px; margin-left: -2px; border-radius: 50%; background: var(--accent); }
.menu a[aria-current="page"] { color: var(--electric); }

/* ---------- WhatsApp flotante ---------- */
.wa-float {
  position: fixed; right: 18px; bottom: 18px; z-index: 80;
  display: inline-flex; align-items: center; gap: .55rem; height: 52px; padding: 0 1.1rem 0 .95rem; border-radius: 999px;
  background: #0b101b; color: #eef1f7; text-decoration: none; font-weight: 600; font-size: .9rem;
  border: 1px solid rgba(255,255,255,.14); box-shadow: 0 18px 40px -16px rgba(0,0,0,.6);
  transition: transform .4s var(--ease-out), background-color .3s, border-color .3s;
}
.wa-float svg { width: 20px; height: 20px; color: #34d399; }
.wa-float:hover { background: var(--blue); border-color: var(--blue); }
.wa-float:hover svg { color: #fff; }
@media (max-width: 560px) { .wa-float span { display: none; } .wa-float { width: 52px; padding: 0; justify-content: center; } }


/* ---------- Teléfono con chat (home y Kiersys AI) ---------- */
.phone {
  position: relative; width: min(360px, 100%); height: min(700px, 82vh);
  border-radius: 46px; padding: 12px; background: #0a0d14;
  box-shadow: 0 50px 100px -30px rgba(15,23,42,.45), 0 0 0 1px rgba(15,23,42,.08), inset 0 0 0 1.5px #2a3242;
}
.phone-screen { position: relative; height: 100%; border-radius: 36px; overflow: hidden; background: #0d131f; display: flex; flex-direction: column; color: #e8ecf4; }
.phone-notch { position: absolute; top: 10px; left: 50%; transform: translateX(-50%); width: 96px; height: 26px; border-radius: 20px; background: #000; z-index: 3; }
.phone-head { display: flex; align-items: center; gap: .7rem; padding: 46px 18px 14px; border-bottom: 1px solid rgba(255,255,255,.07); background: #111a29; }
.phone-head img { width: 38px; height: 38px; border-radius: 50%; object-fit: cover; }
.phone-head b { display: block; font-size: .95rem; }
.phone-head small { font-size: .75rem; color: #34d399; }
.phone-body {
  flex: 1; display: flex; flex-direction: column; justify-content: flex-end; gap: .5rem; padding: 14px; overflow: hidden;
  background-image: radial-gradient(rgba(255,255,255,.04) 1px, transparent 1px); background-size: 18px 18px;
}
.msg { max-width: 84%; padding: .6rem .8rem; border-radius: 16px; font-size: .86rem; line-height: 1.4; display: none; }
.msg.show { display: block; animation: pop .45s var(--ease-out) both; }
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(.96); } }
.msg.me { align-self: flex-end; background: var(--blue); color: #fff; border-bottom-right-radius: 5px; }
.msg.bot { align-self: flex-start; background: #1a2436; border: 1px solid rgba(255,255,255,.06); border-bottom-left-radius: 5px; }
.msg .tag { display: flex; align-items: center; gap: .35rem; font-size: .7rem; font-weight: 600; color: #7fb4ff; margin-bottom: .25rem; letter-spacing: .02em; }
.msg .tag svg { width: 12px; height: 12px; }
.audio { display: flex; align-items: center; gap: .55rem; }
.audio svg { width: 16px; height: 16px; flex: none; }
.wave { display: flex; align-items: center; gap: 2px; height: 18px; }
.wave i { width: 2.5px; border-radius: 2px; background: rgba(255,255,255,.85); }
.file { display: none; align-items: center; gap: .7rem; }
.file.show { display: flex; }
.file-ic { flex: none; width: 38px; height: 44px; border-radius: 6px; background: #ef4444; color: #fff; font-size: .62rem; font-weight: 800; display: grid; place-items: end center; padding-bottom: 6px; }
.file small { display: block; color: #8b93a7; font-size: .72rem; }
.sys { align-self: center; display: none; font-size: .72rem; font-weight: 600; padding: .35rem .75rem; border-radius: 999px; background: rgba(245,158,11,.14); color: #fbbf24; }
.sys.show { display: block; animation: pop .45s var(--ease-out) both; }
.typing { align-self: flex-start; display: none; gap: 4px; padding: .7rem .85rem; border-radius: 16px; background: #1a2436; }
.typing.show { display: flex; }
.typing i { width: 6px; height: 6px; border-radius: 50%; background: #8b93a7; animation: blink 1s infinite; }
.typing i:nth-child(2) { animation-delay: .15s; } .typing i:nth-child(3) { animation-delay: .3s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }
.phone-input { display: flex; align-items: center; gap: .6rem; margin: 0 12px 14px; padding: .7rem 1rem; border-radius: 999px; background: #1a2436; color: #6b7487; font-size: .82rem; }
.phone-input span { flex: 1; }
.phone-input i { width: 30px; height: 30px; border-radius: 50%; background: var(--blue); display: grid; place-items: center; }
.phone-input svg { width: 14px; height: 14px; color: #fff; }
/* Chat que se reproduce solo, en bucle */
.chat-loop .phone-body { transition: opacity .5s var(--ease); }
.chat-loop.is-resetting .phone-body { opacity: 0; }
