/* =========================================================================
   core.css — Foundation, variables, reset, layout primitives
   ========================================================================= */

/* --- Reset minimal --- */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
img, svg, video { max-width: 100%; height: auto; display: block; }
svg[aria-hidden="true"] { display: inline-block; vertical-align: -0.14em; flex-shrink: 0; }
button { font: inherit; cursor: pointer; }
a { color: inherit; text-decoration: none; }

/* --- Design tokens (tema dark + light) --- */
:root {
  /* Colores principales */
  --t-bg: #0b0d1a;
  --t-bg-alt: #0f0c29;
  --t-panel: #14182d;
  --t-panel-2: #1c2240;
  --t-line: #2a2f4a;
  --t-line-2: #3a4060;
  --t-text: #e6e8f0;
  --t-text-2: #aab0c8;
  --t-text-3: #6c7390;
  --t-text-4: #4a5070;
  --t-text-5: #2a2f4a;

  /* Forwarders: nombres historicos del admin reenvian a la escala canon.
     Si una tema activo sobreescribe --t-text-N mediante el context processor,
     las referencias legacy (--t-muted/dim/faint/ghost) siguen la cascada. */
  --t-muted:        var(--t-text-2);
  --t-text-dim:     var(--t-text-3);
  --t-text-faint:   var(--t-text-4);
  --t-text-ghost:   var(--t-text-5);
  --t-primary: #7c5cff;
  --t-primary-2: #5b3df0;
  --t-accent: #7c5cff;
  --t-accent-2: #5b3df0;
  --t-accent2: #2bd4bf;
  --t-warn: #ffb547;
  --t-danger: #ef4444;
  --t-success: #22c55e;
  --t-theme-color: #1c1238;
  --t-theme-color-light: #ffffff;

  /* Tipografia */
  --ff-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --ff-mono: "JetBrains Mono", ui-monospace, "SF Mono", Consolas, monospace;
  --fs-xs: .75rem;
  --fs-sm: .875rem;
  --fs-base: 1rem;
  --fs-lg: 1.125rem;
  --fs-xl: 1.25rem;
  --fs-2xl: 1.5rem;
  --fs-3xl: 2rem;
  --fs-4xl: 2.5rem;
  --fs-5xl: 3.5rem;
  --fs-6xl: 4.5rem;
  --lh-tight: 1.15;
  --lh-snug: 1.3;
  --lh-base: 1.6;

  /* Espaciado */
  --sp-1: .25rem;
  --sp-2: .5rem;
  --sp-3: .75rem;
  --sp-4: 1rem;
  --sp-5: 1.5rem;
  --sp-6: 2rem;
  --sp-7: 3rem;
  --sp-8: 4rem;
  --sp-9: 6rem;
  --sp-10: 8rem;

  /* Bordes y sombras */
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 16px;
  --r-xl: 24px;
  --r-pill: 999px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.06);
  --shadow-md: 0 4px 12px rgba(0,0,0,.12);
  --shadow-lg: 0 12px 32px rgba(0,0,0,.22);
  --shadow-glow: 0 0 32px rgba(124, 92, 255, .35);
  --t-grad: linear-gradient(135deg, #a78bfa 0%, #2bd4bf 50%, #f0abfc 100%);
  --t-grad-soft: linear-gradient(135deg, rgba(124, 92, 255, .15), rgba(43, 212, 191, .15));

  /* Transiciones */
  --ease: cubic-bezier(.2, .7, .2, 1);
  --t-fast: 120ms;
  --t-base: 220ms;
  --t-slow: 360ms;

  /* Layout */
  --container-w: 1200px;
  --container-px: 1.25rem;
  --header-h: 64px;
  --radius-focus: 0 0 0 3px rgba(124, 92, 255, .35);
}

/* Tema claro (auto-switch via prefers-color-scheme) */
@media (prefers-color-scheme: light) {
  :root {
    --t-bg: #ffffff;
    --t-bg-alt: #f5f6fa;
    --t-panel: #ffffff;
    --t-panel-2: #f8f9fc;
    --t-line: #e2e5ee;
    --t-line-2: #c8ccd9;
    --t-text: #0f0c29;
    --t-text-2: #4a4f63;
    --t-text-3: #7a7f95;
  }
}

/* --- Body base --- */
html { scroll-behavior: smooth; }
body {
  font-family: var(--ff-sans);
  font-size: var(--fs-base);
  line-height: var(--lh-base);
  color: var(--t-text);
  background: var(--t-bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100vh;
}

/* --- Container --- */
.container {
  max-width: var(--container-w);
  margin: 0 auto;
  padding: 0 var(--container-px);
}
.container--narrow { max-width: 800px; }
.container--wide { max-width: 1400px; }

/* --- Section --- */
.section { padding: var(--sp-9) 0; }
.section--alt { background: var(--t-bg-alt); }

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

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
  html { scroll-behavior: auto; }
}

:focus-visible {
  outline: 2px solid var(--t-primary);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

/* --- Skip link --- */
.skip-link {
  position: absolute;
  top: 0;
  left: -9999px;
  background: var(--t-primary);
  color: #fff;
  padding: var(--sp-3) var(--sp-4);
  z-index: 10000;
  border-radius: 0 0 var(--r-md) 0;
}
.skip-link:focus { left: 0; }

/* --- Headings --- */
h1, h2, h3, h4, h5, h6 { margin: 0 0 var(--sp-4); font-weight: 700; line-height: var(--lh-tight); }
h1 { font-size: var(--fs-5xl); }
h2 { font-size: var(--fs-3xl); }
h3 { font-size: var(--fs-2xl); }
h4 { font-size: var(--fs-xl); }

@media (max-width: 700px) {
  h1 { font-size: var(--fs-4xl); }
  h2 { font-size: var(--fs-2xl); }
  h3 { font-size: var(--fs-xl); }
}

/* --- Utilities --- */
.center { text-align: center; }
.muted { color: var(--t-text-2); }
.small { font-size: var(--fs-sm); }
.tight { line-height: var(--lh-tight); }
.mt-2 { margin-top: var(--sp-2); }
.mt-3 { margin-top: var(--sp-3); }
.mt-4 { margin-top: var(--sp-4); }
.mt-6 { margin-top: var(--sp-6); }
.mb-2 { margin-bottom: var(--sp-2); }
.mb-4 { margin-bottom: var(--sp-4); }

/* --- Gradiente reutilizable --- */
.grad {
  background: linear-gradient(135deg, #a78bfa 0%, #2bd4bf 50%, #f0abfc 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  -webkit-text-fill-color: transparent;
}

/* --- Reveal animation (utilizada por JS) --- */
.reveal { opacity: 0; transform: translateY(20px); transition: opacity .6s var(--ease), transform .6s var(--ease); }
.reveal.is-visible { opacity: 1; transform: none; }

/* --- Flash messages (Django messages framework) --- */
.flash { padding: var(--sp-4) 0; }
.flash__item {
  padding: var(--sp-3) var(--sp-4);
  margin-bottom: var(--sp-2);
  border-radius: var(--r-md);
  font-size: var(--fs-sm);
  background: var(--t-panel);
  border: 1px solid var(--t-line);
  color: var(--t-text);
}
.flash__item--success,
.flash__item--info { border-color: rgba(34, 197, 94, .35); background: rgba(34, 197, 94, .12); color: var(--t-success); }
.flash__item--warning { border-color: rgba(255, 181, 71, .35); background: rgba(255, 181, 71, .12); color: var(--t-warn); }
.flash__item--error { border-color: rgba(239, 68, 68, .35); background: rgba(239, 68, 68, .12); color: var(--t-danger); }
.microlead__status.is-success { color: var(--t-success); }
.microlead__status.is-error { color: var(--t-danger); }

/* --- Inline form helper --- */
.inline-form { display: inline; }

/* --- Status page (health) --- */
.estado__small { font-size: var(--fs-sm); color: var(--t-text-3); }
.estado__small.center { text-align: center; }
.estado__small a { color: var(--t-primary); text-decoration: underline; }
.estado__highlight {
  padding: var(--sp-3) var(--sp-4);
  background: var(--t-bg-alt);
  border-left: 3px solid var(--t-primary);
  border-radius: 0 var(--r-md) var(--r-md) 0;
  margin: var(--sp-3) 0;
}

/* --- Footer --- */
.footer {
  margin-top: var(--sp-9);
  padding: var(--sp-8) 0 var(--sp-5);
  background: var(--t-bg-alt);
  border-top: 1px solid var(--t-line);
}
.footer__grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--sp-6);
  margin-bottom: var(--sp-6);
}
@media (min-width: 700px) {
  .footer__grid { grid-template-columns: 2fr 1fr 1fr 1fr; gap: var(--sp-5); }
}
.footer__col strong { display: block; margin-bottom: var(--sp-3); font-size: var(--fs-sm); color: var(--t-text-2); text-transform: uppercase; letter-spacing: .05em; }
.footer__col ul { list-style: none; padding: 0; margin: 0; }
.footer__col li { margin-bottom: var(--sp-2); }
.footer__col a { color: var(--t-text-2); font-size: var(--fs-sm); transition: color var(--t-fast) var(--ease); }
.footer__col a:hover { color: var(--t-primary); }
.footer__brand { font-size: var(--fs-lg); display: block; margin-bottom: var(--sp-2); }
.wa-fab {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-3);
  background: #25D366;
  color: #fff;
  border-radius: var(--r-pill);
  font-size: var(--fs-sm);
  font-weight: 600;
  margin-top: var(--sp-2);
  transition: background var(--t-fast) var(--ease);
}
.wa-fab:hover { background: #1ebe5a; }

/* --- Floating CTA (chip telefonico de la home / landing) --- */
.floating-cta {
  position: fixed;
  right: var(--sp-5);
  bottom: var(--sp-5);
  z-index: 50;
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-3) var(--sp-4);
  background: var(--t-panel);
  color: var(--t-text);
  border: 1px solid var(--t-line);
  border-radius: var(--r-pill);
  font-size: var(--fs-sm);
  font-weight: 600;
  text-decoration: none;
  box-shadow: var(--shadow-lg);
  transition: transform var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
}
.floating-cta:hover {
  transform: translateY(-2px);
  border-color: var(--t-accent);
  box-shadow: var(--shadow-lg), var(--shadow-glow);
}
.floating-cta__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: var(--t-accent);
  color: #fff;
  border-radius: 50%;
  flex-shrink: 0;
}
.floating-cta__icon svg { display: block; }
.floating-cta__text { display: inline-flex; flex-direction: column; line-height: 1.15; }
.floating-cta__label { font-size: var(--fs-xs); color: var(--t-text-2); font-weight: 500; }
.floating-cta__phone { font-size: var(--fs-sm); color: var(--t-text); font-weight: 700; }
@media (max-width: 480px) {
  .floating-cta { right: var(--sp-3); bottom: var(--sp-3); padding: var(--sp-2) var(--sp-3); }
  .floating-cta__phone { font-size: var(--fs-xs); }
}

.footer__newsletter {
  padding: var(--sp-5) 0;
  border-top: 1px solid var(--t-line);
  border-bottom: 1px solid var(--t-line);
  text-align: center;
}
.footer__newsletter-label { display: block; margin-bottom: var(--sp-3); color: var(--t-text-2); }
.footer__newsletter-row {
  display: flex;
  gap: var(--sp-2);
  max-width: 560px;
  margin: 0 auto;
  flex-wrap: wrap;
  justify-content: center;
}
.footer__newsletter-input {
  flex: 1 1 280px;
  padding: var(--sp-3) var(--sp-4);
  background: var(--t-panel);
  border: 1px solid var(--t-line);
  border-radius: var(--r-pill);
  color: var(--t-text);
  font-size: var(--fs-sm);
  font-family: inherit;
}
.footer__newsletter-input::placeholder { color: var(--t-text-3); }
.footer__newsletter-input:focus {
  outline: none;
  border-color: var(--t-primary);
}
.footer__newsletter-input:invalid:not(:placeholder-shown) {
  border-color: #ef4444;
}
.footer__bottom {
  margin-top: var(--sp-5);
  padding-top: var(--sp-4);
  border-top: 1px solid var(--t-line);
  text-align: center;
  color: var(--t-text-3);
  font-size: var(--fs-xs);
}

/* --- Error page (404, 500) --- */
.error-page {
  padding: var(--sp-9) 0;
  text-align: center;
  min-height: 60vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.error-page__code {
  font-size: 6rem;
  font-weight: 900;
  background: linear-gradient(135deg, var(--t-primary), var(--t-accent2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  -webkit-text-fill-color: transparent;
  line-height: 1;
  margin-bottom: var(--sp-4);
}
.error-page__title { margin: 0 0 var(--sp-3); }
.error-page__sub { color: var(--t-text-2); max-width: 520px; margin: 0 auto var(--sp-5); }
.error-page__actions { display: flex; gap: var(--sp-3); justify-content: center; flex-wrap: wrap; }