/* ══════════════════════════════════════════════════════════════════════════
   GHM CIVIL — base.css
   Sistema de diseño: tokens, reset, tipografía, layout primitivo, utilidades.
   Dirección de arte: arquitectónica clara — blanco puro, hormigón, grafito,
   acero y un único acento terracota usado con extrema economía.

   REGLA DE COLOR: el acento no decora, señala. Si aparece en más de un
   elemento por pantalla, deja de funcionar.
   ══════════════════════════════════════════════════════════════════════════ */

/* ─── 1. RESET ──────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; padding: 0; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
  /* Compensa la altura del header sticky al saltar a un ancla.
     Se recalcula por JS en --header-h para que móvil y desktop coincidan. */
  scroll-padding-top: calc(var(--header-h, 72px) + 16px);
}

body {
  font-family: var(--font-body);
  font-size: var(--fs-body);
  line-height: 1.62;
  color: var(--graphite);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-synthesis-weight: none;
  text-rendering: optimizeLegibility;
}

img, picture, video, canvas, svg { display: block; max-width: 100%; }
img { height: auto; background-color: var(--concrete); } /* evita destello al cargar */
input, button, textarea, select { font: inherit; color: inherit; }
button { background: none; border: 0; cursor: pointer; }
a { color: inherit; text-decoration: none; }
ul, ol { list-style: none; }
h1, h2, h3, h4, h5, h6 { font-weight: inherit; font-size: inherit; text-wrap: balance; }
p { text-wrap: pretty; }
::selection { background: var(--graphite); color: var(--paper); }

/* Foco visible SIEMPRE. El sitio anterior no tenía ninguno: navegar con
   teclado era imposible. WCAG 2.4.7 (AA). */
:focus-visible {
  outline: 2px solid var(--terracotta);
  outline-offset: 3px;
  border-radius: 2px;
}
.on-dark :focus-visible,
[data-theme="dark"] :focus-visible { outline-color: var(--terracotta-l); }

/* Salto al contenido para lectores de pantalla y teclado */
.skip-link {
  position: absolute; left: 8px; top: -100px; z-index: 2000;
  background: var(--graphite); color: var(--paper);
  padding: 12px 20px; font: 500 var(--fs-micro)/1 var(--font-body);
  transition: top .2s;
}
.skip-link:focus { top: 8px; }

/* ─── 2. TOKENS ─────────────────────────────────────────────────────────── */
:root {
  /* Tipografías. Fallbacks con métricas cercanas para reducir el salto (CLS)
     mientras carga la webfont. */
  --font-display: 'Archivo', 'Helvetica Neue', Arial, sans-serif;
  --font-body:    'Inter Tight', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono:    'IBM Plex Mono', ui-monospace, 'SF Mono', Menlo, monospace;

  /* ── Superficies ── */
  --paper:      #FFFFFF;   /* blanco puro                  */
  --bone:       #F6F5F2;   /* hormigón claro, fondo alterno */
  --concrete:   #EAE7E1;   /* hormigón                      */
  --ink:        #0D0D0C;   /* negro mate, capítulos oscuros */
  --ink-soft:   #171716;

  /* ── Tinta ── */
  --graphite:   #1A1A19;   /* texto principal   · 17.4:1 sobre blanco */
  --steel:      #5F6366;   /* texto secundario  ·  6.1:1 sobre blanco */
  --steel-l:    #8A8D8F;   /* solo texto grande e iconos · 3.3:1      */
  --on-ink:     #F6F5F2;   /* texto sobre oscuro · 17.8:1             */
  --on-ink-2:   #9A9C9B;   /* secundario sobre oscuro · 7.0:1         */

  /* ── Acento único ── */
  --terracotta:   #9E4A28; /* 6.1:1 sobre blanco — apto para texto   */
  --terracotta-l: #C8724A; /* 5.5:1 sobre negro — versión para oscuro */
  --terracotta-w: #F3E9E3; /* lavado, solo fondos                     */

  /* ── Materiales de apoyo ── */
  --timber:     #B07C4F;   /* madera, exclusivo para gráficos         */
  --wa:         #0E7C43;   /* verde WhatsApp accesible · 5.3:1 c/blanco */
  --wa-hover:   #0A6435;

  /* ── Líneas ── */
  --line:        #E3E0DA;  /* separadores decorativos                 */
  --line-strong: #C7C2B9;
  --line-ui:     #8E8A82;  /* bordes de campos · 3.4:1 (WCAG 1.4.11)  */
  --line-dark:   rgba(246,245,242,.16);

  /* ── Tipografía fluida ── */
  --fs-display: clamp(2.7rem, 6.4vw, 6.2rem);
  --fs-h2:      clamp(2.1rem, 4.6vw, 4.1rem);
  --fs-h3:      clamp(1.3rem, 1.1rem + .8vw, 1.75rem);
  --fs-h4:      clamp(1.05rem, 1rem + .3vw, 1.2rem);
  --fs-lead:    clamp(1.125rem, 1.06rem + .35vw, 1.35rem);
  --fs-body:    clamp(1rem, .97rem + .14vw, 1.075rem);
  --fs-small:   0.9375rem;  /* 15px */
  --fs-micro:   0.8125rem;  /* 13px — mínimo absoluto de texto */
  --fs-label:   0.75rem;    /* 12px — solo mono en mayúsculas  */

  /* ── Ritmo ── */
  --gutter:  clamp(1.25rem, 4.2vw, 5rem);
  --section: clamp(5rem, 9.5vw, 10.5rem);
  --maxw:    1560px;
  --maxw-read: 68ch;
  /* --header-min FIJA la altura de la cabecera. --header-h la MIDE (lo escribe
     app.js) y solo la consumen otros elementos: el scroll-padding de los
     anclajes, el panel móvil y las columnas sticky.
     No intercambiarlas: si la cabecera se dimensiona con el valor que ella
     misma genera, el ResizeObserver realimenta el ciclo y la barra crece 1px
     por frame hasta ocupar media pantalla. */
  --header-min: 72px;
  --header-h: 72px;

  /* ── Movimiento ── */
  --ease:      cubic-bezier(.22, .61, .36, 1);
  --ease-out:  cubic-bezier(.16, 1, .3, 1);
  --dur:       .45s;

  /* ── Elevación (muy contenida: el diseño es plano por decisión) ── */
  --shadow-sm: 0 1px 2px rgba(26,26,25,.05), 0 4px 12px rgba(26,26,25,.04);
  --shadow-md: 0 2px 4px rgba(26,26,25,.05), 0 12px 32px rgba(26,26,25,.08);
  --shadow-lg: 0 4px 8px rgba(26,26,25,.06), 0 24px 64px rgba(26,26,25,.12);
}

@media (max-width: 1000px) { :root { --header-min: 64px; } }

@media (min-width: 1900px) {
  /* Ultrawide: el contenido no se estira, respira. */
  :root { --gutter: clamp(5rem, 8vw, 9rem); }
}

/* ─── 3. TIPOGRAFÍA ─────────────────────────────────────────────────────── */
.display {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--fs-display);
  line-height: .9;
  letter-spacing: -.035em;
  text-wrap: balance;
}
.h2 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: var(--fs-h2);
  line-height: 1.0;
  letter-spacing: -.03em;
}
.h3 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: var(--fs-h3);
  line-height: 1.15;
  letter-spacing: -.018em;
}
.h4 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: var(--fs-h4);
  line-height: 1.25;
  letter-spacing: -.01em;
}
.lead {
  font-size: var(--fs-lead);
  line-height: 1.52;
  color: var(--steel);
  max-width: 46ch;
  font-weight: 400;
}
.small { font-size: var(--fs-small); }
.micro { font-size: var(--fs-micro); }

/* Etiqueta técnica — el "sello de plano" del sistema */
.label {
  font-family: var(--font-mono);
  font-size: var(--fs-label);
  font-weight: 500;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--steel);
  line-height: 1;
}
.label--accent { color: var(--terracotta); }
.label--rule { display: inline-flex; align-items: center; gap: .85em; }
.label--rule::before {
  content: ''; display: block; width: 2rem; height: 1px;
  background: currentColor; opacity: .55; flex-shrink: 0;
}

.txt-steel  { color: var(--steel); }
.txt-accent { color: var(--terracotta); }

/* Enlace de texto con subrayado que se dibuja */
.link {
  color: var(--terracotta);
  background-image: linear-gradient(currentColor, currentColor);
  background-size: 0% 1px;
  background-position: 0 100%;
  background-repeat: no-repeat;
  transition: background-size .35s var(--ease);
  padding-bottom: 1px;
}
.link:hover, .link:focus-visible { background-size: 100% 1px; }

/* ─── 4. LAYOUT ─────────────────────────────────────────────────────────── */
.wrap {
  width: min(100% - (var(--gutter) * 2), var(--maxw));
  margin-inline: auto;
}
.wrap--read { max-width: var(--maxw-read); }
.section { padding-block: var(--section); }
.section--tight { padding-block: clamp(3.5rem, 6vw, 6rem); }
.section--bone     { background: var(--bone); }
.section--concrete { background: var(--concrete); }
.section--ink      { background: var(--ink); color: var(--on-ink); }
.section--ink .lead,
.section--ink .label { color: var(--on-ink-2); }
.section--ink .label--accent { color: var(--terracotta-l); }

/* Encabezado de sección reutilizable */
.sec-head { display: grid; gap: 1.1rem; margin-bottom: clamp(2.5rem, 4vw, 4.5rem); }
.sec-head--center { justify-items: center; text-align: center; }
.sec-head--center .lead { margin-inline: auto; }
.sec-head--split {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end; gap: 1.1rem 3rem;
}
.sec-head--split > .sec-head__aside { grid-row: 1 / span 3; grid-column: 2; align-self: end; }
@media (max-width: 900px) {
  .sec-head--split { grid-template-columns: 1fr; }
  .sec-head--split > .sec-head__aside { grid-row: auto; grid-column: 1; justify-self: start; }
}

.stack   { display: grid; gap: var(--stack-gap, 1rem); }
.cluster { display: flex; flex-wrap: wrap; gap: var(--cluster-gap, .75rem); align-items: center; }

/* ─── 5. UTILIDADES ─────────────────────────────────────────────────────── */
.visually-hidden {
  position: absolute !important; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0;
}
.no-scroll { overflow: hidden; }
.full-bleed { width: 100vw; margin-inline: calc(50% - 50vw); }

/* Reserva de altura para secciones largas: evita saltos de layout mientras
   se pintan.

   Deliberadamente NO se usa `content-visibility: auto` aquí. Un subárbol
   saltado por content-visibility no se considera "relevante para el usuario",
   y los elementos que hay dentro no generan notificaciones de
   IntersectionObserver hasta que el subárbol vuelve a serlo. Combinado con el
   rootMargin negativo del observador de revelados, eso puede dejar secciones
   permanentemente en opacity: 0. Si algún día hace falta por rendimiento,
   aplícalo solo a secciones sin elementos .reveal dentro. */
.defer-paint { contain-intrinsic-size: auto 700px; }

/* ─── 6. REVELADO AL SCROLL ─────────────────────────────────────────────── */
/* Sin JS (o con JS fallido) el contenido se ve igual: nunca ocultamos por
   defecto, la clase la añade JS solo si IntersectionObserver existe. */
.js .reveal { opacity: 0; transform: translateY(18px); }
.js .reveal.is-in {
  opacity: 1; transform: none;
  transition: opacity .8s var(--ease-out), transform .8s var(--ease-out);
  transition-delay: var(--reveal-delay, 0ms);
}

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

/* ─── 8. IMPRESIÓN ──────────────────────────────────────────────────────── */
@media print {
  .site-header, .site-topbar, .wa-dock, .scroll-progress, .lightbox { display: none !important; }
  body { color: #000; background: #fff; }
  a[href^="http"]::after { content: " (" attr(href) ")"; font-size: 11px; color: #555; }
}
