/* ==========================================================================
   BASE — reset, tipografía, layout, temas, utilidades, loader, progreso.
   Sin colores HEX: todo viene de tokens.css
   ========================================================================== */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: auto; }
body {
  margin: 0;
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: var(--lh-body);
  color: var(--color-text-primary);
  background: var(--color-background);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: clip;
}
img, picture, svg, video { display: block; max-width: 100%; height: auto; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
ul, ol { margin: 0; padding: 0; list-style: none; }
h1, h2, h3, h4, p, figure, blockquote { margin: 0; }
:focus-visible { outline: 2px solid var(--color-accent); outline-offset: 3px; border-radius: 2px; }
::selection { background: var(--color-accent); color: var(--color-on-primary); }

/* ---------- Temas por sección ---------- */
.theme-dark {
  --color-background: var(--ink-950);
  --color-surface: var(--ink-900);
  --color-surface-elevated: var(--ink-800);
  --color-text-primary: var(--paper-50);
  --color-text-secondary: var(--steel-200);
  --color-text-muted: var(--brand-steel);
  --color-border: rgb(var(--paper-50-rgb) / 0.14);
  --color-border-strong: rgb(var(--paper-50-rgb) / 0.32);
  --color-accent-text: var(--brand-orange);
  background: var(--color-background);
  color: var(--color-text-primary);
}
.theme-paper { background: var(--color-background); color: var(--color-text-primary); }
.theme-surface { background: var(--color-surface); color: var(--color-text-primary); }
.theme-slate {
  --color-background: var(--ink-800);
  --color-surface: var(--ink-700);
  --color-surface-elevated: var(--ink-600);
  --color-text-primary: var(--paper-50);
  --color-text-secondary: var(--steel-200);
  --color-text-muted: var(--steel-300);
  --color-border: rgb(var(--paper-50-rgb) / 0.16);
  --color-accent-text: var(--brand-orange);
  background: var(--color-background);
  color: var(--color-text-primary);
}

/* ---------- Tipografía ---------- */
.display, .h1, .h2, .h3 {
  font-family: var(--font-heading);
  font-weight: 400;
  letter-spacing: var(--tracking-display);
  line-height: var(--lh-snug);
  text-wrap: balance;
}
.display { font-size: var(--text-display); line-height: var(--lh-tight); }
.h1 { font-size: var(--text-4xl); line-height: var(--lh-tight); }
.h2 { font-size: var(--text-3xl); }
.h3 { font-size: var(--text-2xl); }
.display em, .h1 em, .h2 em, .h3 em { font-style: italic; color: var(--color-accent-text); }
.lead { font-size: var(--text-lg); color: var(--color-text-secondary); max-width: 60ch; }
.prose p + p { margin-top: 1.1em; }
.prose { color: var(--color-text-secondary); max-width: 62ch; }
.eyebrow {
  display: inline-flex; align-items: center; gap: 0.75rem;
  font-size: var(--text-xs); font-weight: 700; letter-spacing: var(--tracking-caps);
  text-transform: uppercase; color: var(--color-accent-text);
}
.eyebrow::before { content: ""; width: 2.25rem; height: 1px; background: currentColor; }
.eyebrow--light { color: var(--brand-orange); }
.muted { color: var(--color-text-muted); }

/* ---------- Layout ---------- */
.container { width: 100%; max-width: calc(var(--container-width) + var(--gutter) * 2); margin-inline: auto; padding-inline: var(--gutter); }
.container--narrow { max-width: calc(var(--container-narrow) + var(--gutter) * 2); }
.section { padding-block: var(--section-y); position: relative; }
.section--tight { padding-block: calc(var(--section-y) * 0.6); }
.section-head { display: grid; gap: var(--space-md); margin-bottom: clamp(2.5rem, 5vw, 4.5rem); max-width: 60rem; }
.section-head--split { max-width: none; grid-template-columns: 1fr; align-items: end; }
@media (min-width: 900px) {
  .section-head--split { grid-template-columns: 1.3fr 1fr; gap: var(--space-xl); }
  .section-head--split .lead { justify-self: end; }
}

/* ---------- Utilidades ---------- */
.visually-hidden { position: absolute !important; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip-link { position: fixed; top: 0.75rem; left: 0.75rem; z-index: var(--z-loader); padding: 0.75rem 1.1rem; background: var(--brand-orange); color: var(--color-on-primary); font-weight: 700; border-radius: var(--radius-sm); transform: translateY(-200%); }
.skip-link:focus { transform: none; }
.no-scroll { overflow: hidden; }
.mask { overflow: hidden; }

/* Silueta de tejado (inspirada en las líneas del logo): recorta imágenes y bloques */
.clip-roof { clip-path: polygon(0 14%, 50% 0, 100% 14%, 100% 100%, 0 100%); }
.clip-roof-sm { clip-path: polygon(0 7%, 50% 0, 100% 7%, 100% 100%, 0 100%); }

/* La máscara de línea de SplitText no debe recortar descendentes (g, y, p…) */
.split-mask { padding-bottom: 0.16em; margin-bottom: -0.16em; }

/* ---------- Estados iniciales de animación (solo con JS y sin movimiento reducido) ---------- */
.has-motion [data-reveal] { opacity: 0; transform: translateY(32px); }
.has-motion [data-split]:not(.is-split) { visibility: hidden; }
.has-motion [data-mask-reveal]:not(.is-revealed) { clip-path: inset(0 0 100% 0); }
.has-motion.reveal-fallback [data-reveal] { opacity: 1; transform: none; }
.has-motion.reveal-fallback [data-split] { visibility: visible; }
.has-motion.reveal-fallback [data-mask-reveal] { clip-path: none; }

/* ---------- Barra de progreso de scroll ---------- */
.scroll-progress { position: fixed; inset: 0 0 auto 0; height: 3px; z-index: var(--z-progress); pointer-events: none; }
.scroll-progress span { display: block; height: 100%; background: var(--brand-orange); transform-origin: 0 50%; transform: scaleX(0); }

/* ---------- Loader (solo html.has-loader) ---------- */
.loader { display: none; position: fixed; inset: 0; z-index: var(--z-loader); background: var(--ink-950); place-items: center; color: var(--paper-50); }
.has-loader .loader { display: grid; }
.has-loader body { overflow: hidden; }
.loader__roof { position: absolute; inset: 0; background: var(--ink-900); clip-path: polygon(0 100%, 50% 38%, 100% 100%); opacity: 0.6; }
.loader__inner { position: relative; width: min(78vw, 520px); display: grid; gap: 1.5rem; justify-items: center; }
.loader__logo { width: 100%; height: auto; }
.loader__bar { width: 100%; height: 2px; background: rgb(var(--paper-50-rgb) / 0.14); overflow: hidden; }
.loader__bar span { display: block; height: 100%; background: var(--brand-orange); transform-origin: 0 50%; transform: scaleX(0); }
.loader__count { font-size: var(--text-xs); letter-spacing: var(--tracking-caps); color: var(--brand-steel); font-variant-numeric: tabular-nums; }

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