/* ==========================================================================
   BASE — Tokens de diseño, reset, tipografía y utilidades
   Röntgen Design System v4
   ========================================================================== */

:root {
  /* Alinea los controles nativos (scroll, formularios, menús) con el tema */
  color-scheme: light;

  /* ── Marca ─────────────────────────────────────────────── */
  --primary:      #d32f2f;
  --primary-dark: #a81b1b;
  --primary-lite: #ff5252;
  --accent:       #ff6b5b;

  /* Superficies (claro) */
  --bg:           #ffffff;
  --bg-alt:       #f6f7f9;
  --surface:      #ffffff;
  --surface-2:    #f0f2f5;
  --border:       #e3e7ec;
  --border-strong:#cfd6de;

  /* Texto (claro) */
  --text:         #0d131c;
  --text-soft:    #3c4654;
  --text-muted:   #67717f;

  /* Efectos */
  --glow:         rgba(211, 47, 47, 0.28);
  --tint:         rgba(211, 47, 47, 0.08);
  --tint-strong:  rgba(211, 47, 47, 0.16);
  --glass:        rgba(255, 255, 255, 0.72);
  --glass-border: rgba(255, 255, 255, 0.85);

  /* Radios */
  --r-xs:   8px;
  --r-sm:  12px;
  --r:     16px;
  --r-lg:  22px;
  --r-xl:  28px;
  --r-full: 999px;

  /* Elevación */
  --shadow-sm: 0 1px 2px rgb(13 19 28 / 0.06), 0 2px 8px rgb(13 19 28 / 0.04);
  --shadow:    0 4px 12px rgb(13 19 28 / 0.07), 0 12px 28px rgb(13 19 28 / 0.06);
  --shadow-lg: 0 8px 24px rgb(13 19 28 / 0.10), 0 28px 56px rgb(13 19 28 / 0.10);
  --shadow-brand: 0 8px 26px rgba(211, 47, 47, 0.30);

  /* Tipografía */
  --font:      'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, 'SF Mono', 'Cascadia Code', monospace;

  /* Ritmo */
  --wrap:      1180px;
  --wrap-slim: 760px;
  --ease:      cubic-bezier(0.22, 1, 0.36, 1);
  --ease-back: cubic-bezier(0.34, 1.4, 0.64, 1);
}

:root.dark {
  color-scheme: dark;

  --bg:           #070a10;
  --bg-alt:       #0c1017;
  --surface:      #10151e;
  --surface-2:    #161d29;
  --border:       #222b39;
  --border-strong:#334052;

  --text:         #eef2f8;
  --text-soft:    #b9c3d1;
  --text-muted:   #7f8b9c;

  --glow:         rgba(255, 82, 82, 0.34);
  --tint:         rgba(255, 82, 82, 0.10);
  --tint-strong:  rgba(255, 82, 82, 0.18);
  --glass:        rgba(255, 255, 255, 0.045);
  --glass-border: rgba(255, 255, 255, 0.09);

  --shadow-sm: 0 1px 2px rgb(0 0 0 / 0.4);
  --shadow:    0 8px 24px rgb(0 0 0 / 0.45);
  --shadow-lg: 0 20px 50px rgb(0 0 0 / 0.55);
  --shadow-brand: 0 8px 30px rgba(211, 47, 47, 0.40);
}

/* ==================== RESET ==================== */

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

html {
  scroll-behavior: smooth;
  scroll-padding-top: 92px;
  -webkit-text-size-adjust: 100%;
  /* Red de seguridad contra el desplazamiento lateral. `clip` recorta sin
     crear un contenedor de scroll, así que no rompe `position: sticky`. */
  overflow-x: clip;
}

body {
  font-family: var(--font);
  /* Una palabra o URL sin espacios no debe empujar el ancho de la página */
  overflow-wrap: break-word;
  background: var(--bg);
  color: var(--text);
  line-height: 1.65;
  font-size: 1rem;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

/* Fondo con profundidad en modo oscuro.
   `background-attachment: fixed` obliga a repintar el fondo en cada scroll y
   es una fuente conocida de tirones en móvil: se reserva para escritorio. */
:root.dark body {
  background:
    radial-gradient(1000px 600px at 85% -10%, rgba(211, 47, 47, 0.10), transparent 60%),
    radial-gradient(800px 500px at 5% 105%, rgba(211, 47, 47, 0.06), transparent 60%),
    linear-gradient(170deg, #070a10 0%, #0a0e15 55%, #0d0a0c 100%);
}
@media (min-width: 1025px) and (pointer: fine) {
  :root.dark body { background-attachment: fixed; }
}

img, svg, video { max-width: 100%; display: block; }
/* <picture> no debe participar en el layout: solo envuelve al <img> */
picture { display: contents; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; }

/* Iconos Iconify — reserva el espacio antes de que el componente se registre,
   hereda el color del contenedor y se escala con la tipografía. */
iconify-icon {
  display: inline-block;
  width: 1em;
  height: 1em;
  flex-shrink: 0;
  color: inherit;
  vertical-align: -0.125em;
}
iconify-icon > svg { display: block; }

::selection { background: var(--primary); color: #fff; }

/* Scrollbar */
::-webkit-scrollbar { width: 11px; height: 11px; }
::-webkit-scrollbar-track { background: var(--bg-alt); }
::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: var(--r-full);
  border: 3px solid var(--bg-alt);
}
::-webkit-scrollbar-thumb:hover { background: var(--primary); }

/* Foco visible y consistente */
:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 3px;
  border-radius: 4px;
}

/* ==================== LAYOUT ==================== */

.container { max-width: var(--wrap); margin: 0 auto; padding: 0 1.5rem; }
/* En pantallas muy angostas, 48 px de margen lateral se comen el contenido */
@media (max-width: 400px) {
  .container { padding: 0 1rem; }
}

.section { padding: 6.5rem 0; position: relative; }
.section--alt { background: var(--bg-alt); }
:root.dark .section--alt {
  background: rgba(255, 255, 255, 0.018);
  border-block: 1px solid var(--border);
}

@media (max-width: 768px) {
  .section { padding: 4.5rem 0; }
}

/* Encabezado de sección reutilizable */
.section-head {
  max-width: 660px;
  margin: 0 auto 3.5rem;
  text-align: center;
}
.section-head p {
  font-size: 1.05rem;
  color: var(--text-muted);
  margin: 0;
}
.section-head--left { margin-inline: 0; text-align: left; }

/* ==================== TIPOGRAFÍA ==================== */

h1, h2, h3, h4 {
  font-weight: 700;
  line-height: 1.15;
  color: var(--text);
  letter-spacing: -0.025em;
  text-wrap: balance;
}

h1 { font-size: clamp(2.4rem, 6vw, 4rem); font-weight: 800; margin-bottom: 1.25rem; }
h2 { font-size: clamp(1.85rem, 4vw, 2.6rem); margin-bottom: 0.85rem; }
h3 { font-size: 1.15rem; margin-bottom: 0.4rem; }
h4 { font-size: 0.95rem; margin-bottom: 0.3rem; }

p { color: var(--text-muted); margin-bottom: 1rem; text-wrap: pretty; }
p:last-child { margin-bottom: 0; }

strong { color: var(--text); font-weight: 650; }

/* ==================== UTILIDADES ==================== */

.text-center { text-align: center; }

.text-gradient {
  background: linear-gradient(115deg, var(--primary) 0%, var(--accent) 55%, var(--primary-lite) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}

.mono {
  font-family: var(--font-mono);
  font-feature-settings: 'tnum' 1;
  letter-spacing: -0.02em;
}

/* Píldora de sección */
.badge-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.38rem 0.95rem;
  border-radius: var(--r-full);
  background: var(--tint);
  border: 1px solid var(--tint-strong);
  color: var(--primary);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  margin-bottom: 1.1rem;
}
:root.dark .badge-pill { color: var(--primary-lite); }

.badge-pill--muted {
  background: var(--surface-2);
  border-color: var(--border);
  color: var(--text-muted);
}

.badge-pill::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 0 3px color-mix(in srgb, currentColor 22%, transparent);
}

/* Divisor sutil entre secciones */
.rule {
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--border) 25%, var(--border) 75%, transparent);
  border: 0;
}

/* Superficie de tarjeta genérica */
.surface {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
}
:root.dark .surface {
  background: var(--glass);
  border-color: var(--glass-border);
  backdrop-filter: blur(14px);
}

/* Accesible pero invisible */
.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;
}

/* Bloquea el scroll del fondo cuando hay modal abierto */
body.no-scroll { overflow: hidden; }

/* Salto al contenido — primera parada del tabulador */
.skip-link {
  position: fixed;
  top: 0.75rem; left: 0.75rem;
  z-index: 600;
  padding: 0.7rem 1.15rem;
  border-radius: var(--r-sm);
  background: var(--primary);
  color: #fff;
  font-size: 0.9rem;
  font-weight: 650;
  text-decoration: none;
  box-shadow: var(--shadow-lg);
  transform: translateY(-160%);
  transition: transform 0.2s var(--ease);
}
.skip-link:focus-visible { transform: translateY(0); }
