/* ==========================================================================
   Umbralith — Base: reset, tipografía, estructura y utilidades
   ========================================================================== */

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

/* El atributo `hidden` debe ganar siempre: las clases de botón y de panel
   tienen `display` propio y, sin esta regla, un `hidden` quedaba visible. */
[hidden] { display: none !important; }

* { margin: 0; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-h) + var(--sp-5));
}

body {
  min-height: 100dvh;
  background-color: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  line-height: var(--lh-normal);
  font-synthesis-weight: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* Fondo ambiental: dos halos de color muy suaves + rejilla tenue. Se pintan
   con gradientes (sin imágenes) para que no cueste nada renderizarlos. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -2;
  background:
    radial-gradient(60% 40% at 12% -5%, rgba(139, 92, 246, 0.16), transparent 70%),
    radial-gradient(50% 40% at 92% 4%, rgba(34, 211, 238, 0.12), transparent 72%),
    radial-gradient(70% 50% at 50% 105%, rgba(236, 72, 153, 0.1), transparent 75%);
  pointer-events: none;
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background-image:
    linear-gradient(to right, rgba(148, 163, 184, 0.045) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(148, 163, 184, 0.045) 1px, transparent 1px);
  background-size: 64px 64px;
  mask-image: radial-gradient(circle at 50% 0%, black, transparent 78%);
  pointer-events: none;
  opacity: 0.7;
}

img, svg, video, canvas { display: block; max-width: 100%; }
img { height: auto; }

button, input, select, textarea { font: inherit; color: inherit; }

button { background: none; border: none; cursor: pointer; }

a { color: inherit; text-decoration: none; }

ul, ol { list-style: none; padding: 0; }

h1, h2, h3, h4 {
  font-family: var(--font-display);
  line-height: var(--lh-tight);
  font-weight: 650;
  letter-spacing: -0.02em;
  text-wrap: balance;
}

h1 { font-size: var(--fs-2xl); }
h2 { font-size: var(--fs-xl); }
h3 { font-size: var(--fs-lg); }
h4 { font-size: var(--fs-md); font-weight: 600; }

p { text-wrap: pretty; }

code, pre, kbd { font-family: var(--font-mono); font-size: 0.92em; }

::selection { background: rgba(139, 92, 246, 0.42); color: #fff; }

:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
  border-radius: var(--r-sm);
}

/* Barra de desplazamiento propia, acorde con el tema. */
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border: 3px solid transparent;
  background-clip: content-box;
  border-radius: var(--r-full);
}
*::-webkit-scrollbar-thumb:hover { background: var(--violet); background-clip: content-box; }

/* --- Estructura ---------------------------------------------------------- */

.shell {
  width: 100%;
  max-width: var(--container);
  margin-inline: auto;
  padding-inline: clamp(1rem, 4vw, 2rem);
}

.shell--narrow { max-width: var(--container-narrow); }

.section { padding-block: clamp(2.5rem, 6vw, 5rem); }
.section--tight { padding-block: clamp(1.75rem, 4vw, 3rem); }

.stack { display: flex; flex-direction: column; gap: var(--sp-4); }
.stack--sm { gap: var(--sp-2); }
.stack--lg { gap: var(--sp-6); }

.row { display: flex; align-items: center; gap: var(--sp-3); }
.row--between { justify-content: space-between; }
.row--wrap { flex-wrap: wrap; }
.row--top { align-items: flex-start; }

.grid { display: grid; gap: var(--sp-5); }
.grid--cards { grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); }
.grid--wide { grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
.grid--2 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr)); }
.grid--3 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr)); }

.divider { height: 1px; background: linear-gradient(90deg, transparent, var(--border), transparent); }

.muted { color: var(--text-muted); }
.faint { color: var(--text-faint); }
.soft { color: var(--text-soft); }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.mono { font-family: var(--font-mono); }
.small { font-size: var(--fs-sm); }
.tiny { font-size: var(--fs-xs); }
.bold { font-weight: 640; }
.grow { flex: 1 1 auto; }
.hidden { display: none !important; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip-path: inset(50%); white-space: nowrap;
}

.text-gradient {
  background: var(--gradient-brand);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: var(--fs-xs);
  font-weight: 620;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.eyebrow::before {
  content: "";
  width: 22px;
  height: 1px;
  background: var(--gradient-brand);
}

.section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--sp-4);
  flex-wrap: wrap;
  margin-bottom: var(--sp-5);
}

.section-head h2 { display: flex; align-items: center; gap: var(--sp-3); }
.section-head p { color: var(--text-muted); max-width: 62ch; font-size: var(--fs-sm); }

/* --- Animaciones --------------------------------------------------------- */

@keyframes fade-up {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: none; }
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse-soft { 0%, 100% { opacity: 1; } 50% { opacity: 0.55; } }
@keyframes shimmer {
  from { background-position: -180% 0; }
  to { background-position: 180% 0; }
}
@keyframes float-slow {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}
@keyframes aurora {
  0% { transform: translate3d(0, 0, 0) scale(1); }
  50% { transform: translate3d(2%, -3%, 0) scale(1.06); }
  100% { transform: translate3d(0, 0, 0) scale(1); }
}
@keyframes ring-spin { to { transform: rotate(360deg); } }
@keyframes ring-spin-reverse { to { transform: rotate(-360deg); } }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(10px) scale(0.98); }
  to { opacity: 1; transform: none; }
}
@keyframes pop-in {
  from { opacity: 0; transform: scale(0.96) translateY(8px); }
  to { opacity: 1; transform: none; }
}

.animate-in { animation: fade-up var(--dur-slow) var(--ease) both; }

/* Aparición al hacer scroll (IntersectionObserver añade .is-visible). */
.reveal { opacity: 0; transform: translateY(18px); }
.reveal.is-visible {
  animation: fade-up 620ms var(--ease) both;
  animation-delay: var(--reveal-delay, 0ms);
}

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