/* ==========================================================================
   PEAK® — base.css
   Fundamentos: tipografías, tokens, reset, grano, primitivas de layout.
   Sistema derivado del manual de marca Peak + DESIGN.md (dark editorial).
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. TIPOGRAFÍAS  ·  Aileron (display / UI) + SF Mono (meta)
   -------------------------------------------------------------------------- */

@font-face {
  font-family: 'Aileron';
  src: url('../fonts/aileron-thin.woff2') format('woff2');
  font-weight: 100;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Aileron';
  src: url('../fonts/aileron-thin-italic.woff2') format('woff2');
  font-weight: 100;
  font-style: italic;
  font-display: swap;
}
@font-face {
  font-family: 'Aileron';
  src: url('../fonts/aileron-ultralight.woff2') format('woff2');
  font-weight: 200;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Aileron';
  src: url('../fonts/aileron-light.woff2') format('woff2');
  font-weight: 300;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Aileron';
  src: url('../fonts/aileron-regular.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Aileron';
  src: url('../fonts/aileron-semibold.woff2') format('woff2');
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}

/* SF Mono se sirve local sólo como respaldo: en Apple se usa la del sistema. */
@font-face {
  font-family: 'Peak Mono';
  src: local('SF Mono'), local('SFMono-Regular'),
       url('../fonts/sfmono-regular.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Peak Mono';
  src: local('SF Mono Medium'), url('../fonts/sfmono-medium.woff2') format('woff2');
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Peak Mono';
  src: local('SF Mono Semibold'), url('../fonts/sfmono-semibold.woff2') format('woff2');
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}

/* --------------------------------------------------------------------------
   2. TOKENS
   -------------------------------------------------------------------------- */

:root {
  /* — Paleta: exclusivamente los 4 colores del manual — */
  --ink: #0a0a0a;         /* lienzo base */
  --paper: #f3f3f3;       /* texto primario */
  --paper-pale: #e8f2ff;  /* texto sobre acento */
  --signal: #a6d1ff;      /* acento — PANTONE 543C. Es puntuación, no pintura. */

  /* — Superficies (sólo dos niveles, sin elevación ni sombra) — */
  --surface-0: var(--ink);
  --surface-1: #101010;

  /* — Tintes derivados (misma tinta, distinta presencia) — */
  --paper-70: rgb(243 243 243 / 0.70);
  --paper-52: rgb(243 243 243 / 0.52);
  /* 0.48 y no menos: por debajo de ahi el texto pequeno cae bajo 4.5:1
     contra el lienzo. Medido, no estimado. */
  --paper-48: rgb(243 243 243 / 0.48);
  /* Solo para trazos, nunca para texto: 1.97:1 contra el lienzo. */
  --paper-24: rgb(243 243 243 / 0.24);
  --hairline: rgb(243 243 243 / 0.14);
  --hairline-strong: rgb(243 243 243 / 0.30);

  /* — Familias — */
  --font-display: 'Aileron', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-mono: 'Peak Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  /* — Escala tipográfica fluida — */
  --fs-colossal: clamp(4rem, 15.5vw, 17rem);   /* logotipo / cifras de portada */
  --fs-hero: clamp(2.75rem, 8.2vw, 9rem);      /* titular de portada */
  --fs-display: clamp(2rem, 5vw, 5rem);        /* titulares de sección */
  --fs-title: clamp(1.5rem, 3vw, 2.75rem);     /* títulos de proyecto */
  --fs-lead: clamp(1rem, 1.15vw, 1.0625rem);   /* bajada */
  --fs-body: 1rem;                             /* cuerpo — 16px, tope del sistema */
  --fs-small: 0.875rem;                        /* 14px — piso del sistema */
  --fs-meta: 0.75rem;                          /* 12px mono */
  --fs-micro: 0.6875rem;                       /* 11px mono */

  /* — Tracking — */
  --tr-display: -0.03em;
  --tr-tight: -0.015em;
  --tr-meta: 0.12em;
  --tr-meta-wide: 0.2em;

  /* — Ritmo (base 4px, densidad compacta) — */
  --s-1: 4px;
  --s-2: 8px;
  --s-3: 12px;
  --s-4: 16px;
  --s-5: 20px;
  --s-6: 24px;
  --s-8: 32px;
  --s-10: 40px;
  --s-12: 48px;
  --s-16: 64px;
  --s-20: 80px;

  --gutter: clamp(20px, 4.2vw, 56px);
  --section-gap: clamp(80px, 12vh, 160px);
  --nav-h: 68px;
  --reel-h: 96px;

  /* — Radios: cero en todo el sistema — */
  --radius: 0px;

  /* — Movimiento — */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in-out: cubic-bezier(0.76, 0, 0.24, 1);
  --ease-peak: cubic-bezier(0.83, 0, 0.17, 1);
  --dur-fast: 0.28s;
  --dur: 0.6s;
  --dur-slow: 1.1s;

  /* — Capas — */
  --z-reel: 30;
  --z-nav: 40;
  --z-menu: 50;
  --z-grain: 60;
  --z-cursor: 70;
  --z-transition: 80;
  --z-loader: 90;

  color-scheme: dark;
}

/* --------------------------------------------------------------------------
   3. RESET / BASE
   -------------------------------------------------------------------------- */

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

* { margin: 0; padding: 0; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: auto; /* el scroll suave lo maneja Lenis */
}

/* Cualquier destino de ancla deja aire para la barra fija. Cubre los saltos
   nativos (sin JavaScript) y los de scrollIntoView cuando Lenis está apagado
   por movimiento reducido. En JS el mismo valor vive como NAV_OFFSET. */
[id] { scroll-margin-top: calc(var(--nav-h) + 20px); }

body {
  background: var(--surface-0);
  color: var(--paper);
  font-family: var(--font-display);
  font-weight: 300;
  font-size: var(--fs-body);
  line-height: 1.5;
  letter-spacing: var(--tr-tight);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
  min-height: 100svh;
}

/* Bloquea el scroll mientras corre el loader o una transición. */
body.is-locked { overflow: hidden; height: 100svh; }

/* El atributo `hidden` trae `display: none` en la hoja del navegador, con la
   especificidad mas baja que existe. Cualquier `display: grid` de un
   componente se lo lleva por delante y el elemento sigue en el orden de
   tabulacion aunque parezca invisible. Aqui se zanja. */
[hidden] { display: none !important; }

img, video, svg, picture {
  display: block;
  max-width: 100%;
}

video { height: auto; }

/* Los videos del sitio son decorativos y van en bucle sin sonido. Ningun
   navegador deberia pintar controles nativos encima; algunos lo hacen cuando
   el autoplay queda bloqueado o el elemento aun no tiene fuente. */
video::-webkit-media-controls,
video::-webkit-media-controls-enclosure { display: none !important; }

a {
  color: inherit;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  cursor: pointer;
}

ul, ol { list-style: none; }

h1, h2, h3, h4 {
  font-weight: 100;
  line-height: 0.94;
  letter-spacing: var(--tr-display);
  text-wrap: balance;
}

::selection {
  background: var(--signal);
  color: var(--ink);
}

:focus-visible {
  outline: 1px solid var(--signal);
  outline-offset: 4px;
}

/* Lenis */
html.lenis, html.lenis body { height: auto; }
.lenis.lenis-smooth { scroll-behavior: auto !important; }
.lenis.lenis-stopped { overflow: hidden; }

/* --------------------------------------------------------------------------
   4. UTILIDADES TIPOGRÁFICAS
   -------------------------------------------------------------------------- */

/* Meta: el pulso del sistema. Mono, versalitas, tracking abierto.
   Es lo que le da el ritmo de rótulo de crédito de cine. */
.meta {
  font-family: var(--font-mono);
  font-size: var(--fs-meta);
  font-weight: 400;
  line-height: 1;
  letter-spacing: var(--tr-meta);
  text-transform: uppercase;
  font-feature-settings: 'tnum' 1;
}
.meta--micro { font-size: var(--fs-micro); letter-spacing: var(--tr-meta-wide); }
.meta--dim { color: var(--paper-52); }
.meta--signal { color: var(--signal); }

/* Display ultraligero — la firma del sistema. Nunca en bold. */
.display {
  font-weight: 100;
  line-height: 0.9;
  letter-spacing: var(--tr-display);
}
.display--italic { font-style: italic; }

.lead {
  font-size: var(--fs-lead);
  font-weight: 300;
  line-height: 1.55;
  letter-spacing: var(--tr-tight);
  color: var(--paper-70);
  max-width: 46ch;
}

.u-signal { color: var(--signal); }
.u-dim { color: var(--paper-52); }

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* --------------------------------------------------------------------------
   5. PRIMITIVAS DE LAYOUT
   -------------------------------------------------------------------------- */

.shell {
  width: 100%;
  padding-inline: var(--gutter);
}

.rule {
  height: 1px;
  background: var(--hairline);
  border: 0;
  width: 100%;
}

/* Rejilla editorial de 12 columnas. */
.grid12 {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  column-gap: var(--s-6);
}

@media (max-width: 860px) {
  .grid12 { grid-template-columns: repeat(6, minmax(0, 1fr)); column-gap: var(--s-4); }
}

/* --------------------------------------------------------------------------
   6. GRANO  ·  el manual especifica grano (intensidad 40 / contraste 50)
   Es la textura que separa a Peak de un fondo negro cualquiera.
   -------------------------------------------------------------------------- */

.grain {
  position: fixed;
  inset: -50%;
  z-index: var(--z-grain);
  pointer-events: none;
  background-image: url('../img/grain.png');
  background-repeat: repeat;
  opacity: 0.05;
  mix-blend-mode: overlay;
  will-change: transform;
  animation: grain-drift 0.7s steps(6) infinite;
}

@keyframes grain-drift {
  0%   { transform: translate3d(0, 0, 0); }
  16%  { transform: translate3d(-8%, 4%, 0); }
  33%  { transform: translate3d(6%, -7%, 0); }
  50%  { transform: translate3d(-4%, 9%, 0); }
  66%  { transform: translate3d(9%, 3%, 0); }
  83%  { transform: translate3d(-7%, -5%, 0); }
  100% { transform: translate3d(0, 0, 0); }
}

/* Viñeta muy leve: hunde los bordes como una proyección. */
.vignette {
  position: fixed;
  inset: 0;
  z-index: calc(var(--z-grain) - 1);
  pointer-events: none;
  background: radial-gradient(120% 90% at 50% 45%, transparent 55%, rgb(0 0 0 / 0.42) 100%);
}

/* --------------------------------------------------------------------------
   7. MARCA  ·  el logo como elemento inline escalable
   -------------------------------------------------------------------------- */

.mark {
  display: block;
  width: auto;
  color: currentColor;
}
.mark svg { display: block; height: 100%; width: auto; fill: currentColor; }

/* --------------------------------------------------------------------------
   8. PREFERENCIAS DE MOVIMIENTO
   -------------------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  .grain { animation: none; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
