/* ============================================================
   TRAMA — Sistemas que respiran
   Tokens de marca + layout + capa de motion.
   Convención: sin dependencias, sin build. Motion siempre detrás
   de @media (prefers-reduced-motion: no-preference).
   ============================================================ */

/* ---------- Fuentes (self-hosted, variables, subset latin) ---------- */
@font-face {
  font-family: "Fraunces";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("/assets/fonts/fraunces-var-latin.woff2") format("woff2");
}
@font-face {
  font-family: "DM Sans";
  font-style: normal;
  font-weight: 100 1000;
  font-display: swap;
  src: url("/assets/fonts/dm-sans-var-latin.woff2") format("woff2");
}

/* ---------- Tokens ---------- */
:root {
  --bosque: #274837;
  --salvia: #5B7B6A;
  --crema: #FAF6F0;
  --terracota: #C4836A;
  --carbon: #2D2D2D;
  --menta: #D4E4D9;

  --display: "Fraunces", Georgia, serif;
  --cuerpo: "DM Sans", -apple-system, BlinkMacSystemFont, sans-serif;

  --ancho: 1040px;
  --ancho-narrow: 680px;
}

/* ---------- Reset mínimo ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

body {
  font-family: var(--cuerpo);
  background-color: var(--crema);
  color: var(--carbon);
  line-height: 1.7;
  font-size: 1.0625rem;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  /* textura de papel: feTurbulence inline, pesa bytes */
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="240" height="240"><filter id="g"><feTurbulence type="fractalNoise" baseFrequency="0.9" numOctaves="2"/><feColorMatrix values="0 0 0 0 0.2 0 0 0 0 0.17 0 0 0 0 0.12 0 0 0 0.035 0"/></filter><rect width="240" height="240" filter="url(%23g)"/></svg>');
}

img { max-width: 100%; height: auto; }

.container { max-width: var(--ancho); margin: 0 auto; padding: 0 24px; }
.container.narrow { max-width: var(--ancho-narrow); }

.visually-hidden {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); border: 0;
}

.skip-link {
  position: absolute; left: -9999px; top: 0;
  background: var(--bosque); color: var(--crema);
  padding: 10px 18px; border-radius: 0 0 8px 0; z-index: 100;
}
.skip-link:focus { left: 0; }

:focus-visible {
  outline: 3px solid var(--terracota);
  outline-offset: 3px;
  border-radius: 2px;
}

::selection { background: var(--menta); color: var(--bosque); }

/* ---------- El hilo vertebral ---------- */
#hilo-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  z-index: 0;
  pointer-events: none;
}
#hilo-path {
  fill: none;
  stroke: var(--terracota);
  stroke-width: 2.5;
  stroke-linecap: round;
  opacity: 0.55;
}
/* se teje al scrollear — CSS puro donde hay soporte */
@supports (animation-timeline: scroll()) {
  @media (prefers-reduced-motion: no-preference) {
    #hilo-path {
      stroke-dasharray: 1;
      stroke-dashoffset: 1;
      animation: tejer linear both;
      animation-timeline: scroll(root);
      animation-range: 0% 92%;
    }
    @keyframes tejer { to { stroke-dashoffset: 0; } }
  }
}

header, main, footer { position: relative; z-index: 1; }

/* ---------- Hero ---------- */
.hero {
  min-height: 92svh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  padding: 48px 24px 32px;
  position: relative;
}
.hero::before {
  /* el fondo que respira */
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse 68% 52% at 50% 44%, rgba(212, 228, 217, 0.75), transparent 70%);
  z-index: -1;
}
.hero-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
}
.hero-logo {
  width: min(480px, 78vw);
  height: auto;
}
.tagline {
  font-family: var(--display);
  font-size: clamp(1.5rem, 4.5vw, 2.25rem);
  font-weight: 480;
  font-variation-settings: "SOFT" 70, "WONK" 1, "opsz" 40;
  color: var(--bosque);
  margin-top: 28px;
}
.bajada {
  max-width: 34ch;
  margin-top: 14px;
  font-size: 1.0625rem;
  color: var(--salvia);
}
@media (prefers-reduced-motion: no-preference) {
  .hero-inner { animation: respirar 7s ease-in-out infinite; transform-origin: 50% 60%; }
  .hero::before { animation: respirar-fondo 7s ease-in-out infinite; }
  @keyframes respirar {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.03); }
  }
  @keyframes respirar-fondo {
    0%, 100% { opacity: 0.75; }
    50% { opacity: 1; }
  }
}
.scroll-cue {
  position: absolute;
  bottom: 28px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  color: var(--salvia);
  text-decoration: none;
  font-size: 0.85rem;
  letter-spacing: 0.04em;
}
@media (prefers-reduced-motion: no-preference) {
  .scroll-cue svg { animation: caer 2.6s ease-in-out infinite; }
  @keyframes caer {
    0%, 100% { transform: translateY(0); opacity: 0.7; }
    50% { transform: translateY(6px); opacity: 1; }
  }
}

/* ---------- Secciones ---------- */
section { padding: 96px 0; }

.kicker {
  font-family: var(--cuerpo);
  font-size: 0.9rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--terracota);
  margin-bottom: 32px;
}

.titulo {
  font-family: var(--display);
  font-weight: 540;
  font-variation-settings: "SOFT" 60, "WONK" 0, "opsz" 60;
  font-size: clamp(1.9rem, 5vw, 3.2rem);
  line-height: 1.15;
  color: var(--bosque);
  margin-bottom: 28px;
  text-wrap: balance;
}

.intro { max-width: 52ch; margin-bottom: 48px; color: var(--carbon); }

/* --- El nudo --- */
.nudo { padding-top: 72px; }
.statement {
  font-family: var(--display);
  font-weight: 420;
  font-variation-settings: "SOFT" 50, "WONK" 0, "opsz" 32;
  font-size: clamp(1.35rem, 3.4vw, 1.9rem);
  line-height: 1.4;
  color: var(--carbon);
  margin-bottom: 28px;
  max-width: 26ch;
}
.statement em {
  font-style: italic;
  color: var(--bosque);
  font-variation-settings: "SOFT" 90, "WONK" 1, "opsz" 32;
}
.remate {
  font-family: var(--display);
  font-weight: 600;
  font-variation-settings: "SOFT" 70, "WONK" 1, "opsz" 72;
  font-size: clamp(2.1rem, 6vw, 3.6rem);
  line-height: 1.12;
  color: var(--bosque);
  margin-top: 56px;
}

/* --- Ondas separadoras --- */
.onda { line-height: 0; }
.onda svg { width: 100%; height: 60px; display: block; }
.onda.to-menta svg path { fill: var(--menta); }
.onda.from-menta svg path { fill: var(--menta); }
.onda.from-menta { background: var(--crema); }
.onda.to-menta { background: var(--crema); }

/* --- Qué es --- */
.que-es { background: var(--menta); }
.dos-columnas {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 40px;
  margin-bottom: 40px;
}
@media (max-width: 720px) { .dos-columnas { grid-template-columns: 1fr; gap: 24px; } }
.anti {
  border-left: 3px solid var(--terracota);
  padding-left: 20px;
  font-style: italic;
  color: var(--bosque);
  max-width: 62ch;
}

/* --- Método --- */
.fases {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 20px;
  counter-reset: fase;
}
.fase {
  background: #fff;
  border: 1px solid rgba(91, 123, 106, 0.16);
  border-radius: 16px;
  padding: 28px 24px;
  box-shadow: 0 2px 10px rgba(39, 72, 55, 0.05);
  position: relative;
}
.fase-num {
  font-family: var(--display);
  font-weight: 300;
  font-variation-settings: "SOFT" 100, "WONK" 1, "opsz" 100;
  font-size: 2.4rem;
  color: var(--terracota);
  display: block;
  margin-bottom: 10px;
  line-height: 1;
}
.fase h3 {
  font-family: var(--display);
  font-weight: 560;
  font-size: 1.3rem;
  color: var(--bosque);
  margin-bottom: 8px;
}
.fase p { font-size: 0.95rem; line-height: 1.6; }

/* --- Tejidos (casos) --- */
.tejidos { background: var(--crema); }
.caso {
  background: #fff;
  border: 1px solid rgba(91, 123, 106, 0.16);
  border-radius: 16px;
  padding: 32px 28px;
  box-shadow: 0 2px 10px rgba(39, 72, 55, 0.05);
}
.caso-contexto {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--salvia);
  margin-bottom: 8px;
}
.caso h3 {
  font-family: var(--display);
  font-weight: 560;
  font-size: 1.45rem;
  color: var(--bosque);
  margin-bottom: 10px;
}
.caso p { font-size: 0.98rem; }
.caso.destacado {
  background: var(--bosque);
  border: none;
  color: var(--crema);
  padding: 44px 36px;
  margin-bottom: 24px;
}
.caso.destacado .caso-contexto { color: var(--menta); }
.caso.destacado h3 { color: var(--crema); font-size: 1.8rem; }
.caso.destacado > p:not(.caso-contexto) { color: rgba(250, 246, 240, 0.9); max-width: 62ch; }

.metricas {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 28px;
  margin-top: 36px;
}
.metrica { display: flex; flex-direction: column; }
.metrica-num {
  font-family: var(--display);
  font-weight: 480;
  font-variation-settings: "SOFT" 60, "WONK" 0, "opsz" 100;
  font-size: clamp(2.6rem, 5vw, 3.6rem);
  line-height: 1;
  color: var(--menta);
  font-variant-numeric: tabular-nums;
}
.metrica-label {
  font-size: 0.88rem;
  color: rgba(250, 246, 240, 0.8);
  margin-top: 6px;
  margin-bottom: 12px;
}
.metrica-barra {
  height: 8px;
  border-radius: 4px;
  background: rgba(250, 246, 240, 0.14);
  overflow: hidden;
  position: relative;
}
.metrica-barra::after {
  content: "";
  position: absolute;
  inset: 0;
  width: var(--fill, 60%);
  border-radius: 4px;
  /* patrón de tejido */
  background: repeating-linear-gradient(
    45deg,
    var(--terracota) 0 6px,
    #d59a82 6px 12px
  );
}
@media (prefers-reduced-motion: no-preference) {
  .metrica-barra::after {
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 1.4s cubic-bezier(0.22, 1, 0.36, 1) 0.2s;
  }
  .is-visible .metrica-barra::after { transform: scaleX(1); }
}

.casos-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
}

/* --- Quiénes somos --- */
.somos p { margin-bottom: 20px; }
.personas {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin: 40px 0 24px;
}
@media (max-width: 640px) { .personas { grid-template-columns: 1fr; } }
.persona {
  background: var(--menta);
  border-radius: 16px;
  padding: 26px 24px;
}
.persona h3 {
  font-family: var(--display);
  font-weight: 560;
  font-size: 1.25rem;
  color: var(--bosque);
}
.persona-rol {
  font-size: 0.82rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--terracota);
  margin-bottom: 10px !important;
}
.persona p { font-size: 0.95rem; margin-bottom: 0; }
.somos-cierre { color: var(--salvia); font-style: italic; }

/* --- Manifiesto --- */
.manifiesto {
  background: var(--bosque);
  text-align: center;
  padding: 110px 0;
}
.manifiesto blockquote {
  font-family: var(--display);
  font-weight: 440;
  font-variation-settings: "SOFT" 80, "WONK" 1, "opsz" 72;
  font-size: clamp(1.8rem, 5vw, 3rem);
  line-height: 1.25;
  color: var(--crema);
  border: none;
}
.manifiesto blockquote span {
  display: block;
  margin-top: 16px;
  font-family: var(--cuerpo);
  font-size: 1.05rem;
  font-weight: 400;
  color: var(--menta);
}

/* --- Contacto --- */
.contacto { text-align: center; padding: 110px 0; }
.contacto p { max-width: 42ch; margin: 0 auto; }
.cta-grupo {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  margin-top: 40px;
}
.cta {
  display: inline-block;
  background: var(--bosque);
  color: var(--crema);
  text-decoration: none;
  font-weight: 600;
  font-size: 1.05rem;
  padding: 16px 36px;
  border-radius: 999px;
  position: relative;
  transition: background 0.3s ease, transform 0.3s ease;
}
.cta:hover { background: #1d3729; transform: translateY(-2px); }
.cta-secundario {
  color: var(--salvia);
  font-size: 0.95rem;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.cta-secundario:hover { color: var(--bosque); }

/* --- Footer --- */
footer {
  background: var(--bosque);
  color: var(--menta);
  text-align: center;
  padding: 44px 0;
  font-size: 0.9rem;
}
.footer-marca {
  font-family: var(--display);
  font-weight: 560;
  font-variation-settings: "SOFT" 70, "WONK" 1, "opsz" 40;
  font-size: 1.6rem;
  color: var(--crema);
  letter-spacing: 0.02em;
  margin-bottom: 6px;
}

/* ---------- Reveal on scroll ----------
   Solo se activa si main.js corrió (html.js) — sin JS todo queda visible. */
@media (prefers-reduced-motion: no-preference) {
  html.js .reveal {
    opacity: 0;
    transform: translateY(22px);
    transition: opacity 0.8s ease, transform 0.8s cubic-bezier(0.22, 1, 0.36, 1);
  }
  html.js .reveal.is-visible { opacity: 1; transform: none; }
}
