/* ==========================================================================
   Base: reset, tipografía, layout, header, footer
   ========================================================================== */

*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  font-size: 100%;
  scroll-padding-top: calc(var(--header-h) + 72px);
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  color: var(--ink);
  background: var(--paper);
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

main { flex: 1; outline: none; }

h1, h2, h3, h4 { margin: 0; line-height: 1.15; overflow-wrap: break-word; }
p { margin: 0; overflow-wrap: break-word; }
ul, ol { margin: 0; padding: 0; }
a { color: inherit; }
img, svg { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button, a { -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

:focus-visible {
  outline: 2.5px solid var(--focus);
  outline-offset: 2px;
  border-radius: 3px;
}

.sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.shell {
  width: min(var(--max), 100% - 2 * var(--gutter));
  margin-inline: auto;
}

/* ---------- Tipografía ---------- */
.display {
  font-family: var(--font-display);
  font-weight: 750;
  letter-spacing: -.035em;
  font-variation-settings: "opsz" 96;
}

.h1 { font-family: var(--font-display); font-size: clamp(2rem, 4.2vw, 3.1rem); font-weight: 750; letter-spacing: -.03em; line-height: 1.05; }
.h2 { font-family: var(--font-display); font-size: clamp(1.6rem, 3vw, 2.25rem); font-weight: 720; letter-spacing: -.025em; line-height: 1.1; }
.h3 { font-size: 1.12rem; font-weight: 680; letter-spacing: -.01em; }

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
  color: var(--muted);
  font-size: .8rem;
  font-weight: 650;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.lede { color: var(--muted); font-size: 1.1rem; line-height: 1.6; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.tiny { font-size: .78rem; }
.num { font-variant-numeric: tabular-nums; }

.dot {
  width: 9px; height: 9px;
  flex: none;
  border-radius: 50%;
  background: currentColor;
}
.dot-negocio { background: var(--negocio); }
.dot-creador { background: var(--creador); }
.dot-piloto { background: var(--piloto); }

/* ---------- Skip link / demo bar ---------- */
.skip-link {
  position: fixed;
  z-index: 1000;
  top: 8px; left: 8px;
  padding: 10px 14px;
  border-radius: var(--r-s);
  color: var(--btn-fg);
  background: var(--btn-bg);
  font-weight: 650;
  text-decoration: none;
  transform: translateY(-160%);
}
.skip-link:focus { transform: none; }

.demo-bar {
  color: var(--ink-2);
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
  font-size: .78rem;
}
.demo-bar .shell {
  min-height: 34px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-block: 6px;
}
.demo-bar strong { font-weight: 650; }
.demo-bar button {
  flex: none;
  padding: 0;
  border: 0;
  background: none;
  color: var(--negocio-ink);
  font-weight: 650;
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* ---------- Header ---------- */
.site-header {
  position: sticky;
  z-index: 100;
  top: 0;
  height: var(--header-h);
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--paper) 92%, transparent);
  backdrop-filter: saturate(1.4) blur(12px);
  -webkit-backdrop-filter: saturate(1.4) blur(12px);
}

.header-inner {
  height: 100%;
  display: flex;
  align-items: center;
  gap: 28px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 1.28rem;
  font-weight: 760;
  letter-spacing: -.04em;
  text-decoration: none;
}
.brand-mark { width: 30px; height: 22px; flex: none; }
[data-brand-mark] { display: inline-flex; flex: none; }

.site-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-right: auto;
}
.site-nav a {
  padding: 8px 12px;
  border-radius: var(--r-s);
  color: var(--ink-2);
  font-size: .92rem;
  font-weight: 560;
  text-decoration: none;
}
.site-nav a:hover { background: var(--surface-2); color: var(--ink); }
.site-nav a[aria-current="page"] { color: var(--ink); background: var(--surface-2); font-weight: 650; }
.site-nav .nav-creadores::before {
  content: "";
  display: inline-block;
  width: 7px; height: 7px;
  margin-right: 7px;
  border-radius: 50%;
  background: var(--creador);
  vertical-align: 1px;
}

.header-actions { display: flex; align-items: center; gap: 8px; }

.space-link {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-full);
  color: var(--ink);
  background: var(--surface);
  font-size: .9rem;
  font-weight: 620;
  text-decoration: none;
}
.space-link:hover { border-color: var(--ink-2); }
.space-link[aria-current="page"] { border-color: var(--ink); }
.space-link svg { width: 18px; height: 18px; }
.count-badge {
  min-width: 20px;
  height: 20px;
  display: inline-grid;
  place-items: center;
  padding: 0 6px;
  border-radius: var(--r-full);
  color: #1b1300;
  background: var(--piloto);
  font-size: .72rem;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
}

.menu-toggle {
  width: 40px; height: 40px;
  display: none;
  place-items: center;
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-s);
  background: var(--surface);
}
.menu-toggle svg { width: 20px; height: 20px; }

/* Letra grande (botón A+ del header): todo lo que usa rem crece */
html.text-lg { font-size: 115%; }

.text-size-btn[aria-pressed="true"] { border-color: var(--ink); color: var(--btn-fg); background: var(--btn-bg); }
.header-call { gap: 6px; }
.header-call svg, .space-link svg { width: 18px; height: 18px; }

/* ---------- Botón flotante de ayuda ---------- */
.help-fab {
  position: fixed;
  z-index: 85;
  right: 20px;
  bottom: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 18px 8px 8px;
  border: 0;
  border-radius: var(--r-full);
  color: var(--btn-primary-fg);
  background: var(--btn-primary-bg);
  box-shadow: var(--shadow-3);
  text-align: left;
  transition: transform .2s ease, background-color .2s ease;
}
.help-fab:hover { transform: translateY(-2px); background: var(--btn-primary-hover); }
.help-fab-icon {
  position: relative;
  width: 42px; height: 42px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #1b1300;
  background: var(--piloto);
}
.help-fab-icon::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid var(--piloto);
  animation: fab-ring 2.6s ease-out infinite;
}
@keyframes fab-ring { from { transform: scale(1); opacity: .9; } to { transform: scale(1.7); opacity: 0; } }
.help-fab-icon svg { width: 20px; height: 20px; }
.help-fab-text { display: grid; font-size: .78rem; line-height: 1.2; opacity: .9; }
.help-fab-text strong { font-size: .92rem; opacity: 1; }
body.has-tray .help-fab, body.has-mobile-cta .help-fab { bottom: 92px; }

/* ---------- Footer ---------- */
.site-footer {
  margin-top: 96px;
  padding-block: 48px 36px;
  border-top: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  font-size: .88rem;
}
.footer-grid {
  display: grid;
  grid-template-columns: 1.4fr repeat(3, 1fr);
  gap: 36px;
}
.footer-grid h2 {
  margin-bottom: 12px;
  color: var(--ink);
  font-size: .8rem;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
}
.footer-grid ul { list-style: none; display: grid; gap: 8px; }
.footer-grid a { text-decoration: none; }
.footer-grid a:hover { color: var(--ink); text-decoration: underline; }
.footer-brand p { max-width: 34ch; margin-block: 12px 16px; }
.footer-brand .btn svg { width: 16px; height: 16px; }
.footer-bottom {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 40px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
  font-size: .8rem;
}
.theme-switch {
  display: inline-flex;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: var(--r-full);
  background: var(--surface-2);
}
.theme-switch button {
  padding: 4px 11px;
  border: 0;
  border-radius: var(--r-full);
  background: transparent;
  color: var(--muted);
  font-size: .78rem;
  font-weight: 600;
}
.theme-switch button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-1); }

/* ---------- Responsive header ---------- */
@media (max-width: 1140px) {
  .menu-toggle { display: inline-grid; }
  .site-nav {
    position: absolute;
    top: 100%;
    left: 0; right: 0;
    display: none;
    flex-direction: column;
    align-items: stretch;
    gap: 2px;
    padding: 10px var(--gutter) 16px;
    border-bottom: 1px solid var(--line);
    background: var(--paper);
    box-shadow: var(--shadow-2);
  }
  .site-nav.open { display: flex; }
  .site-nav a { padding: 12px; }
  .header-inner { gap: 12px; }
  .header-actions { margin-left: auto; }
}

@media (max-width: 900px) {
  .footer-grid { grid-template-columns: 1fr 1fr; }
  .footer-brand { grid-column: 1 / -1; }
}

@media (max-width: 700px) {
  .header-call .call-label { display: none; }
  .header-call { width: 40px; padding: 0; }
  .help-fab { padding: 6px; right: 14px; bottom: 14px; }
  .help-fab-text { display: none; }
  body.has-tray .help-fab, body.has-mobile-cta .help-fab { bottom: 84px; }
}

@media (max-width: 560px) {
  :root { --gutter: 16px; --header-h: 58px; }
  .space-link .space-label { display: none; }
  .space-link { padding: 0 11px; }
  .demo-bar .demo-long { display: none; }
  .header-actions { gap: 6px; }
  .site-footer { margin-top: 64px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
}

/* Celulares angostos: header compacto para que quepan A+, llamar, Mi espacio y menú */
@media (max-width: 420px) {
  .brand { gap: 6px; font-size: 1.1rem; }
  .brand-mark { width: 24px; height: 18px; }
  .header-actions { gap: 4px; }
  .header-actions .icon-btn, .header-call, .menu-toggle { width: 36px; height: 36px; min-height: 36px; }
  .space-link { min-height: 36px; padding: 0 9px; gap: 5px; }
}

/* ---------- Modo claro / oscuro ---------- */
.theme-btn svg { transition: transform .4s cubic-bezier(.4, 0, .2, 1); }
.theme-btn:hover svg { transform: rotate(-20deg) scale(1.08); }

/* Transición circular al cambiar de tema (View Transitions API) */
::view-transition-old(root),
::view-transition-new(root) {
  animation: none;
  mix-blend-mode: normal;
}
::view-transition-old(root) { z-index: 1; }
::view-transition-new(root) { z-index: 2; }

/* En celular el botón flotante ya ofrece "Te llamamos": se libera espacio en el header */
@media (max-width: 560px) {
  .header-actions .header-call { display: none; }
}
