/* ============ Cross-document View Transitions ============ */
/* Chrome/Edge 126+, Safari 18.2+: transición suave entre home/manual/faq.
   En navegadores sin soporte cae al comportamiento estándar sin costo. */
@view-transition {
  navigation: auto;
}

@keyframes vt-fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes vt-fade-out {
  from { opacity: 1; }
  to   { opacity: 0; }
}
::view-transition-old(root) {
  animation: vt-fade-out 140ms ease both;
}
::view-transition-new(root) {
  animation: vt-fade-in 140ms ease both;
}

/* Respeta a usuarios con reduced motion. */
@media (prefers-reduced-motion: reduce) {
  ::view-transition-old(root),
  ::view-transition-new(root) {
    animation: none;
  }
}

/* ============ Fonts ============ */
/* Self-hosted Inter (variable, latin subset ~48KB). Evita el hop a
   fonts.googleapis.com (~370ms) y sirve desde el mismo origen, que
   queda cacheado entre páginas. */
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("/assets/fonts/inter-latin.woff2") format("woff2-variations"),
       url("/assets/fonts/inter-latin.woff2") format("woff2");
}

/* ============ Theme tokens ============ */
:root {
  --bg: #0b0f1a;
  --bg-2: #0e1426;
  --fg: #eef2ff;
  --muted: #8c95ad;
  --card: #121a2e;
  --card-2: #15203a;
  --border: rgba(255, 255, 255, 0.08);
  --primary: #5b8cff;
  --primary-2: #7aa0ff;
  --accent: #a78bfa;
  --accent-2: #34d399;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --radius: 16px;
  --radius-sm: 10px;
  --maxw: 1200px;
  --shadow-lg: 0 20px 60px -15px rgba(0, 0, 0, 0.6);
  --shadow-md: 0 8px 30px -10px rgba(0, 0, 0, 0.4);
}

html.light {
  --bg: #f7f9fc;
  --bg-2: #eef2f9;
  --fg: #0b1426;
  --muted: #58627a;
  --card: #ffffff;
  --card-2: #f5f7fd;
  --border: rgba(15, 23, 42, 0.08);
  --primary: #2563eb;
  --primary-2: #3b82f6;
  --accent: #7c3aed;
  --accent-2: #059669;
  --shadow-lg: 0 20px 60px -20px rgba(15, 23, 42, 0.2);
  --shadow-md: 0 8px 30px -10px rgba(15, 23, 42, 0.12);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--fg);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
}

a { color: inherit; text-decoration: none; }
img, svg { display: block; max-width: 100%; }

/* Decorative glows — radial-gradient en vez de filter:blur para que
   Safari no pague costo de compositing por blur de 120px en cada
   navegación (era la causa principal del delay de click). */
.glow {
  position: fixed;
  border-radius: 999px;
  opacity: 0.65;
  pointer-events: none;
  z-index: 0;
  /* Pre-compose and isolate so cross-document nav can reuse. */
  will-change: transform;
  transform: translateZ(0);
}
.glow-a {
  top: -200px;
  left: 15%;
  width: 700px;
  height: 700px;
  background: radial-gradient(circle at center, rgba(91, 140, 255, 0.55), rgba(91, 140, 255, 0) 65%);
}
.glow-b {
  top: 25%;
  right: -150px;
  width: 600px;
  height: 600px;
  background: radial-gradient(circle at center, rgba(167, 139, 250, 0.5), rgba(167, 139, 250, 0) 65%);
}
.glow-c {
  bottom: -150px;
  left: -100px;
  width: 560px;
  height: 560px;
  background: radial-gradient(circle at center, rgba(52, 211, 153, 0.35), rgba(52, 211, 153, 0) 65%);
}
html.light .glow { opacity: 0.4; }

/* ============ Nav ============ */
.nav {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 24px;
  max-width: var(--maxw);
  margin: 0 auto;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  background: color-mix(in oklab, var(--bg) 65%, transparent);
  border-bottom: 1px solid var(--border);
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 17px;
  letter-spacing: -0.01em;
}
.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  box-shadow: var(--shadow-md);
}
.brand-accent {
  background: linear-gradient(120deg, var(--primary), var(--accent));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  font-weight: 800;
}
.nav-links {
  display: flex;
  align-items: center;
  gap: 22px;
  font-size: 14px;
  color: var(--muted);
}
.nav-links a { transition: color .15s; }
.nav-links a:hover { color: var(--fg); }
.theme-toggle {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--fg);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background .15s, border-color .15s;
}
.theme-toggle:hover { background: var(--card-2); }
html:not(.light) .theme-toggle .icon-moon { display: none; }
html.light .theme-toggle .icon-sun { display: none; }

/* ============ Buttons ============ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 18px;
  border-radius: 12px;
  font-weight: 600;
  font-size: 14px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform .12s ease, background .15s, border-color .15s, box-shadow .15s;
  white-space: nowrap;
  text-decoration: none;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-sm { padding: 8px 12px; font-size: 13px; border-radius: 10px; }
.btn-lg { padding: 14px 24px; font-size: 15px; border-radius: 14px; }
.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: white;
  box-shadow: var(--shadow-md);
}
.btn-primary:hover { filter: brightness(1.08); }
.btn-outline {
  background: transparent;
  color: var(--fg);
  border-color: var(--border);
}
.btn-outline:hover { background: var(--card); }

/* ============ Hero ============ */
.hero {
  position: relative;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 90px 24px 60px;
  text-align: center;
}
.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--card);
  border: 1px solid var(--border);
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
  margin-bottom: 22px;
}
.dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.55);
  animation: pulse 1.8s infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.55); }
  70% { box-shadow: 0 0 0 10px rgba(16, 185, 129, 0); }
  100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}
.hero-title {
  font-size: clamp(36px, 6.5vw, 68px);
  line-height: 1.05;
  font-weight: 800;
  letter-spacing: -0.03em;
  margin: 0 0 22px;
}
.gradient-text {
  background: linear-gradient(110deg, var(--primary), var(--accent) 40%, var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.hero-sub {
  max-width: 620px;
  margin: 0 auto 32px;
  font-size: clamp(15px, 1.6vw, 18px);
  color: var(--muted);
}
.hero-ctas { display: flex; justify-content: center; gap: 12px; flex-wrap: wrap; }

/* ============ Sections ============ */
.section {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 60px 24px;
  position: relative;
}
.section-head {
  text-align: center;
  margin-bottom: 40px;
}
.section-eyebrow {
  margin: 0 0 6px;
  color: var(--primary);
  font-weight: 600;
  font-size: 13px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.section-head h2 {
  margin: 0;
  font-size: clamp(28px, 4.4vw, 40px);
  letter-spacing: -0.02em;
  font-weight: 800;
}
.section-sub {
  max-width: 620px;
  margin: 14px auto 0;
  color: var(--muted);
}

/* ============ Apps grid ============ */
.apps-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(340px, 100%), 1fr));
  gap: 20px;
}
.app-card {
  position: relative;
  padding: 24px;
  border-radius: var(--radius);
  background: var(--card);
  border: 1px solid var(--border);
  transition: transform .18s ease, border-color .18s, box-shadow .18s;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow: hidden;
  color: var(--fg);
}
.app-card:hover {
  transform: translateY(-3px);
  border-color: color-mix(in oklab, var(--primary) 50%, var(--border));
  box-shadow: var(--shadow-lg);
}
.app-card-featured {
  background: linear-gradient(160deg, var(--card), color-mix(in oklab, var(--card) 70%, var(--primary) 15%));
}
.app-card-gradient {
  position: absolute;
  inset: 0;
  background: radial-gradient(400px 200px at 100% 0, color-mix(in oklab, var(--primary) 30%, transparent), transparent 60%);
  pointer-events: none;
}
.app-card-soon {
  opacity: 0.6;
  cursor: default;
}
.app-card-soon:hover { transform: none; box-shadow: none; }
.app-card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}
.app-icon {
  width: 52px; height: 52px;
  border-radius: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-md);
  color: white;
}
.app-icon-finanzas {
  background: linear-gradient(135deg, #3b82f6, #8b5cf6);
}
.app-icon-soon {
  background: var(--card-2);
  color: var(--muted);
}
.app-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--card-2);
  color: var(--muted);
  border: 1px solid var(--border);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.app-badge-live {
  background: color-mix(in oklab, var(--success) 15%, transparent);
  color: var(--success);
  border-color: color-mix(in oklab, var(--success) 35%, transparent);
}
.pulse {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--success);
  animation: pulse 1.8s infinite;
}
.app-title {
  margin: 4px 0 2px;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.app-desc {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  flex: 1;
}
.app-tags {
  margin: 0; padding: 0;
  display: flex; flex-wrap: wrap; gap: 6px;
  list-style: none;
}
.app-tags li {
  font-size: 11px;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--card-2);
  color: var(--muted);
  border: 1px solid var(--border);
}
.app-card-foot {
  margin-top: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  font-size: 13px;
}
.app-domain {
  font-family: "SF Mono", ui-monospace, monospace;
  color: var(--muted);
  font-size: 12px;
}
.app-cta {
  color: var(--primary);
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

/* ============ Manual ============ */
.manual-layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 36px;
  align-items: flex-start;
}
.manual-toc {
  position: sticky;
  top: 88px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  max-height: calc(100vh - 120px);
  overflow-y: auto;
}
.toc-label {
  margin: 0 0 8px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  font-weight: 700;
}
.manual-toc ol {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.manual-toc a {
  display: block;
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 13px;
  color: var(--muted);
  transition: background .15s, color .15s;
}
.manual-toc a:hover, .manual-toc a.active {
  background: color-mix(in oklab, var(--primary) 14%, transparent);
  color: var(--fg);
}
.manual-body {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
}
.manual-block {
  padding: 22px 0;
  border-bottom: 1px solid var(--border);
  scroll-margin-top: 100px;
}
.manual-block:first-child { padding-top: 0; }
.manual-block:last-child { border-bottom: 0; padding-bottom: 0; }
.manual-block h3 {
  margin: 0 0 12px;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--fg);
}
.manual-block p { margin: 0 0 12px; color: var(--muted); }
.manual-block strong { color: var(--fg); }
.manual-block em { color: var(--fg); font-style: italic; }
.manual-block code {
  font-family: "SF Mono", ui-monospace, monospace;
  background: var(--card-2);
  padding: 2px 6px;
  border-radius: 6px;
  font-size: 13px;
  color: var(--fg);
  border: 1px solid var(--border);
}
.manual-block ul, .manual-block ol {
  color: var(--muted);
  padding-left: 22px;
  margin: 0 0 12px;
}
.manual-block li { margin-bottom: 6px; }
.manual-block a { color: var(--primary); border-bottom: 1px solid transparent; transition: border-color .15s; }
.manual-block a:hover { border-color: var(--primary); }
.tip {
  border-left: 3px solid var(--primary);
  background: color-mix(in oklab, var(--primary) 8%, transparent);
  padding: 12px 16px;
  border-radius: 0 10px 10px 0;
  margin: 14px 0;
  color: var(--fg);
  font-size: 14px;
}

/* ============ FAQ ============ */
.faq {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 800px;
  margin: 0 auto;
}
.faq details {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  transition: border-color .15s;
}
.faq details[open] { border-color: color-mix(in oklab, var(--primary) 40%, var(--border)); }
.faq summary {
  font-weight: 600;
  cursor: pointer;
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--fg);
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after {
  content: "+";
  font-size: 22px;
  color: var(--muted);
  font-weight: 300;
  transition: transform .2s;
}
.faq details[open] summary::after { transform: rotate(45deg); }
.faq p { margin: 10px 0 0; color: var(--muted); }

/* ============ Footer ============ */
.footer {
  border-top: 1px solid var(--border);
  margin-top: 60px;
  padding: 30px 24px;
  background: var(--bg-2);
}
.footer-inner {
  max-width: var(--maxw);
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 14px;
  color: var(--muted);
  font-size: 13px;
}
.footer-links { display: flex; gap: 18px; }
.footer-links a { transition: color .15s; }
.footer-links a:hover { color: var(--fg); }

/* ============ Responsive ============ */
@media (max-width: 900px) {
  .manual-layout { grid-template-columns: 1fr; }
  .manual-toc { position: relative; top: 0; max-height: none; }
  .nav-links { gap: 14px; }
  .nav-links a:not(.btn) { display: none; }
}
@media (max-width: 560px) {
  .nav { padding: 12px 16px; }
  .hero { padding: 60px 20px 40px; }
  .section { padding: 40px 20px; }
  .manual-body { padding: 22px; }
  .theme-toggle { display: none; }
}

/* Active nav state (for /manual.html and /faq.html current page). */
.nav-links a.is-active { color: var(--fg); }
.nav-links a.is-active::after {
  content: "";
  display: block;
  height: 2px;
  margin-top: 4px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  border-radius: 2px;
}

/* Docs section on home (links to /manual.html and /faq.html). */
.section-top { padding-top: 120px; }
.docs-shortcuts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 20px;
  max-width: 1100px;
  margin: 0 auto;
}
.docs-card {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 18px;
  padding: 22px;
  border-radius: 16px;
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--fg);
  text-decoration: none;
  transition: transform .15s, border-color .15s, box-shadow .15s;
}
.docs-card:hover {
  transform: translateY(-2px);
  border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
  box-shadow: 0 12px 32px -16px color-mix(in srgb, var(--accent) 55%, transparent);
}
.docs-icon {
  width: 44px; height: 44px;
  display: grid; place-items: center;
  border-radius: 12px;
  background: color-mix(in srgb, var(--accent) 20%, transparent);
  color: var(--accent);
}
.docs-card h3 { margin: 0 0 4px; font-size: 16px; font-weight: 700; }
.docs-card p { margin: 0; font-size: 14px; color: var(--muted); line-height: 1.5; }
.docs-cta {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 13px; font-weight: 600; color: var(--accent);
  white-space: nowrap;
}

/* Bottom nav on /manual.html and /faq.html. */
.manual-footnav {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 12px;
  margin-top: 48px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}

@media (max-width: 560px) {
  .section-top { padding-top: 90px; }
  .docs-card { grid-template-columns: auto 1fr; }
  .docs-cta { grid-column: 1 / -1; justify-self: end; }
}

/* ============ Password gate ============ */
#gate-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: var(--bg);
  color: var(--fg);
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-feature-settings: "cv11", "ss01";
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: opacity 240ms ease;
}
#gate-overlay.gate-fade-out { opacity: 0; pointer-events: none; }
#gate-overlay .gate-bg {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 0;
}
#gate-overlay .gate-glow {
  position: absolute;
  border-radius: 999px;
  opacity: 0.6;
}
#gate-overlay .gate-glow-a {
  top: -180px;
  left: 20%;
  width: 520px;
  height: 520px;
  background: radial-gradient(circle, rgba(91, 140, 255, 0.45), rgba(91, 140, 255, 0) 65%);
}
#gate-overlay .gate-glow-b {
  bottom: -140px;
  right: -80px;
  width: 440px;
  height: 440px;
  background: radial-gradient(circle, rgba(167, 139, 250, 0.4), rgba(167, 139, 250, 0) 65%);
}
#gate-overlay .gate-card {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 360px;
  padding: 32px;
  border-radius: 20px;
  background: color-mix(in oklab, var(--card) 80%, transparent);
  border: 1px solid var(--border);
  box-shadow: 0 40px 80px -20px rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  text-align: center;
  animation: gate-enter 260ms cubic-bezier(0.4, 0, 0.2, 1);
}
#gate-overlay .gate-logo {
  width: 56px;
  height: 56px;
  margin: 0 auto 16px;
  display: grid;
  place-items: center;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: white;
  box-shadow: 0 10px 24px -10px rgba(91, 140, 255, 0.5);
}
#gate-overlay h1 {
  margin: 0 0 4px;
  font-size: 20px;
  font-weight: 700;
}
#gate-overlay .gate-sub {
  margin: 0 0 22px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
}
#gate-overlay form { display: flex; flex-direction: column; gap: 10px; }
#gate-overlay input {
  width: 100%;
  padding: 14px 16px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: color-mix(in oklab, var(--bg) 80%, transparent);
  color: var(--fg);
  font: inherit;
  font-size: 15px;
  text-align: center;
  letter-spacing: 0.04em;
  outline: none;
  transition: border-color 140ms;
  -webkit-appearance: none;
}
#gate-overlay input:focus { border-color: var(--primary); }
#gate-overlay button {
  margin-top: 6px;
  padding: 12px 20px;
  border-radius: 12px;
  border: none;
  background: var(--primary);
  color: white;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: filter 120ms;
}
#gate-overlay button:hover { filter: brightness(1.08); }
#gate-overlay .gate-error {
  display: none;
  margin: 0;
  font-size: 12px;
  color: var(--danger);
  text-align: center;
}
#gate-overlay .gate-error.gate-visible { display: block; }
#gate-overlay .gate-note {
  margin-top: 18px;
  font-size: 11px;
  color: var(--muted);
}
@keyframes gate-enter {
  from { opacity: 0; transform: translateY(12px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes gate-shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-8px); }
  75% { transform: translateX(8px); }
}
.gate-shake { animation: gate-shake 320ms ease-in-out; }
@media (prefers-reduced-motion: reduce) {
  #gate-overlay .gate-card { animation: none; }
  .gate-shake { animation: none; }
}
