/* ═══════════════════════════════════════════════════════════════════
   DO ARC — DESIGN SYSTEM · "La lámina viva"
   Shared by index.html and every proyecto-*.html page.

   Concept: the site behaves like an architectural sheet being drafted.
   Layers (z-scale):
     0    #c            WebGL blueprint (home hero)
     1    #trace        cursor construction-trace canvas
     5    ghosts        oversized numbers / decorative
     10   content       sections, text
     90   .sheet-frame  fixed drawing-sheet border
     100  nav
     900  .grain
     8000 .wipe         page transition
     9000 #lightbox
     9999 cursor
   ═══════════════════════════════════════════════════════════════════ */

/* ═══ FUENTES SELF-HOSTED (D2) ══════════════════════════════════════
   woff2 latin-subset descargados una sola vez de Google Fonts y
   servidos localmente desde demo/assets/fonts/ — cero requests a CDNs
   de terceros para tipografía, funciona offline/file://.
   unicode-range verificado: cubre U+0000-00FF (Latin-1 Supplement),
   por lo tanto incluye Ñ/ñ, Á/É/Í/Ó/Ú/á/é/í/ó/ú, ¿ (U+00BF) y ¡ (U+00A1).
   ═══════════════════════════════════════════════════════════════════ */
@font-face {
  font-family: 'Cormorant Garamond';
  font-style: normal;
  font-weight: 300;
  font-display: swap;
  src: url('assets/fonts/cormorant-garamond-300.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Cormorant Garamond';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('assets/fonts/cormorant-garamond-400.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Cormorant Garamond';
  font-style: italic;
  font-weight: 300;
  font-display: swap;
  src: url('assets/fonts/cormorant-garamond-300-italic.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Cormorant Garamond';
  font-style: italic;
  font-weight: 400;
  font-display: swap;
  src: url('assets/fonts/cormorant-garamond-400-italic.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Jost';
  font-style: normal;
  font-weight: 200;
  font-display: swap;
  src: url('assets/fonts/jost-200.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Jost';
  font-style: normal;
  font-weight: 300;
  font-display: swap;
  src: url('assets/fonts/jost-300.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Jost';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('assets/fonts/jost-400.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'JetBrains Mono';
  font-style: normal;
  font-weight: 300;
  font-display: swap;
  src: url('assets/fonts/jetbrains-mono-300.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  /* ── Fondos ── */
  --bg-primary:   #FFFFFF;
  --bg-secondary: #F4F4F2;
  --bg-elevated:  #ECECE9;
  --bg-glass:     rgba(255, 255, 255, 0.85);
  --bg-inverse:   #1C1A17;

  /* ── Tintas ── */
  --ink:          #1C1A17;
  --ink-soft:     #3A3630;
  --ink-muted:    #6B645A;
  --ink-ghost:    #9E968A;
  --ink-ghost-aa: #726C63; /* variante AA de --ink-ghost para texto de contenido (5.2:1 sobre blanco) */
  --ink-on-dark:  #F4F1EC;

  /* ── Texto claro sobre fondo oscuro (hero estático luna/tour-done) ── */
  --paper:        #F4F1EC;
  --paper-muted:  rgba(244, 241, 236, 0.72);
  --paper-ghost:  rgba(244, 241, 236, 0.45);

  /* ── Acentos / líneas ── */
  --accent:       #1C1A17;
  --accent-hover: #3A3630;
  --line:         rgba(28, 26, 23, 0.12);
  --line-strong:  rgba(28, 26, 23, 0.30);
  --a60: rgba(28, 26, 23, .6);
  --a30: rgba(28, 26, 23, .3);
  --a12: rgba(28, 26, 23, .12);
  --a06: rgba(28, 26, 23, .06);

  /* ── Línea de plano (blueprint) ── */
  --bp-ink:   rgba(28, 26, 23, .55);
  --bp-faint: rgba(28, 26, 23, .22);

  --shadow-soft: 0 8px 30px rgba(28, 26, 23, 0.06);
  --shadow-card: 0 12px 40px rgba(28, 26, 23, 0.08);
  --blur-glass:  blur(14px);

  /* ── Movimiento ── */
  --ease:      cubic-bezier(.16, 1, .3, 1);
  --ease-draw: cubic-bezier(.65, 0, .35, 1);
  --t-micro: .3s;
  --t-draw:  1.1s;

  /* ── Tipografía ── */
  --font-display: 'Cormorant Garamond', Georgia, serif;
  --font-ui:      'Jost', 'Helvetica Neue', sans-serif;
  --font-mono:    'JetBrains Mono', 'SF Mono', monospace;

  --text-hero:    clamp(3.2rem, 8vw, 7.5rem);
  --text-display: clamp(2.4rem, 5vw, 4.5rem);
  --text-heading: clamp(1.6rem, 3vw, 2.4rem);
  --text-subhead: clamp(1.1rem, 2vw, 1.4rem);
  --text-body:    clamp(0.95rem, 1.2vw, 1.1rem);
  --text-caption: clamp(0.7rem, 0.9vw, 0.8rem);
  --text-micro:   0.6rem;

  /* ── Espaciado ── */
  --space-xs:  0.5rem;
  --space-sm:  1rem;
  --space-md:  2rem;
  --space-lg:  4rem;
  --space-xl:  6rem;
  --space-2xl: 10rem;
  --grid-gap:  clamp(1rem, 2vw, 2rem);
  --page-pad:  clamp(1.2rem, 5vw, 4.5rem);

  /* ── Marco de lámina ── */
  --sheet-inset: 14px;
}

/* El home es blanco puro #FFFFFF de punta a punta (la noche del
   manifiesto es la única excepción deliberada). Scoped a body.home:
   las páginas proyecto-*.html conservan los beiges del sistema. */
body.home {
  --bg-secondary: #FFFFFF;
  --bg-elevated:  #FFFFFF;
}
/* Compensaciones: lo que antes contrastaba contra beige necesita
   un canto perceptible sobre blanco puro. */
body.home .pcard-media { box-shadow: inset 0 0 0 1px var(--a06); }
body.home .pcard-media::before { border-left: 1px solid var(--a12); }

/* ═══ BASE ══════════════════════════════════════════════════════════ */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { font-size: 16px; scroll-behavior: smooth; }

body {
  background: var(--bg-primary);
  color: var(--ink);
  font-family: var(--font-ui);
  font-weight: 300;
  overflow-x: hidden;
  min-height: 100dvh;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

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

img { max-width: 100%; }

/* Cursor personalizado sólo con puntero fino */
@media (pointer: fine) {
  body { cursor: none; }
  body a, body button { cursor: none; }
}
@media (pointer: coarse) {
  #cd, #cr, #trace { display: none !important; }
  a, button { cursor: pointer; }
}

/* Accesibilidad: foco visible siempre */
:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 3px;
}
body.night :focus-visible { outline-color: var(--ink-on-dark); }
.skip-link {
  position: fixed; top: -100%; left: var(--page-pad); z-index: 10000;
  background: var(--ink); color: var(--bg-primary);
  font-size: var(--text-caption); letter-spacing: .2em; text-transform: uppercase;
  padding: .8rem 1.4rem; text-decoration: none; transition: top .3s;
  display: inline-flex; align-items: center; min-height: 44px; box-sizing: border-box;
}
.skip-link:focus { top: 0; }

/* ═══ GRAIN ═════════════════════════════════════════════════════════ */
.grain {
  /* 104%: el jitter máximo del keyframe es 2% — con 200% la capa
     rasterizada llegaba a ~11500×7200px y Safari la repintaba en cada
     frame de scroll (6 fps). will-change la fija en su propia capa. */
  position: fixed; inset: -2%; width: 104%; height: 104%;
  will-change: transform;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 512 512' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  opacity: .02; pointer-events: none; z-index: 900;
  animation: grain 8s steps(2) infinite;
}
@keyframes grain {
  0%,100% { transform: translate(0,0) }
  10% { transform: translate(-1%,-1%) }
  30% { transform: translate(-2%,0) }
  50% { transform: translate(2%,-1%) }
  70% { transform: translate(1%,-2%) }
  90% { transform: translate(2%,0) }
}

/* ═══ MARCO DE LÁMINA (sheet frame + registration marks) ═══════════ */
.sheet-frame {
  position: fixed; inset: var(--sheet-inset);
  border: 1px solid var(--line);
  pointer-events: none; z-index: 90;
}
.sheet-frame::before, .sheet-frame::after,
.sheet-frame .sf-c::before, .sheet-frame .sf-c::after {
  content: ''; position: absolute; width: 9px; height: 9px;
  border-color: var(--line-strong); border-style: solid;
}
.sheet-frame::before { top: -5px; left: -5px; border-width: 0 0 1px 1px; transform: rotate(90deg); }
.sheet-frame::after  { top: -5px; right: -5px; border-width: 0 1px 1px 0; transform: rotate(-90deg); }
.sheet-frame .sf-c::before { bottom: -5px; left: -5px; border-width: 1px 0 0 1px; transform: rotate(-90deg); }
.sheet-frame .sf-c::after  { bottom: -5px; right: -5px; border-width: 1px 1px 0 0; transform: rotate(90deg); }
.sheet-frame .sf-tag {
  position: absolute; bottom: -1px; right: 18px;
  font-family: var(--font-mono); font-size: var(--text-micro);
  letter-spacing: .3em; color: var(--ink-muted);
  background: var(--bg-primary); padding: 0 .8em;
  transform: translateY(50%);
  font-variant-numeric: tabular-nums;
}
@media (max-width: 1023px) { .sheet-frame { display: none; } }

/* ═══ CURSOR ════════════════════════════════════════════════════════ */
#cd, #cr {
  position: fixed; border-radius: 50%; pointer-events: none; z-index: 9999;
  transform: translate(-50%,-50%); transition: opacity .4s; left: 0; top: 0;
}
#cd { width: 5px; height: 5px; background: var(--ink); transition: transform .15s ease, opacity .4s; }
#cr { width: 30px; height: 30px; border: 1px solid var(--a30); transition: transform .45s var(--ease), border-color .3s, opacity .4s; }
/* Etiqueta contextual: aparece sobre elementos con data-cursor */
#cl {
  position: fixed; left: 0; top: 0; z-index: 9998; pointer-events: none;
  font-family: var(--font-mono); font-size: .55rem;
  letter-spacing: .3em; text-transform: uppercase; color: var(--ink);
  background: var(--bg-glass);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  border: 1px solid var(--line-strong); border-radius: 2em;
  padding: .42em 1.1em .42em 1.35em; white-space: nowrap;
  transform: translate(-50%, calc(-50% - 38px)) scale(0);
  transition: transform .32s var(--ease);
}
#cl.on { transform: translate(-50%, calc(-50% - 38px)) scale(1); }
body.night #cl {
  color: var(--ink-on-dark); background: rgba(28,26,23,.75);
  border-color: rgba(244,241,236,.3);
}
@media (pointer: coarse) { #cd, #cr, #cl { display: none; } }

/* ═══ LIENZOS (blueprint + trazos de cursor) ═══════════════════════ */
#c { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 0; }
#trace { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 920; pointer-events: none; mix-blend-mode: multiply; }

/* Fallback estático (sin WebGL / reduced motion) */
#bpFallback {
  position: fixed; inset: 0; z-index: 0; display: none;
  align-items: center; justify-content: center; pointer-events: none;
}
#bpFallback svg { width: min(72vw, 980px); height: auto; opacity: .5; }
#bpFallback [stroke] { stroke: var(--ink); }
body.no-webgl #c, body.bp-static #c, body.tour-static #c { display: none; }
body.no-webgl #bpFallback, body.bp-static #bpFallback,
body.tour-static #bpFallback { display: flex; }

/* ═══ TRANSICIÓN DE PÁGINA (wipe) ══════════════════════════════════ */
.wipe {
  position: fixed; inset: 0; z-index: 8000;
  background: var(--bg-primary);
  transform: translateY(101%);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1.2rem;
  pointer-events: none;
}
.wipe.active   { transform: translateY(0); transition: transform .42s var(--ease-draw); }
.wipe.leaving  { transform: translateY(-101%); transition: transform .5s var(--ease-draw); }
.wipe.instant  { transition: none; }
.wipe-rule { width: min(280px, 56vw); height: 1px; background: var(--line-strong); position: relative; overflow: visible; }
.wipe-rule::before, .wipe-rule::after {
  content: ''; position: absolute; top: -4px; width: 1px; height: 9px;
  background: var(--line-strong); transform: rotate(45deg);
}
.wipe-rule::before { left: 0; } .wipe-rule::after { right: 0; }
.wipe-name {
  font-family: var(--font-display); font-style: italic; font-weight: 300;
  font-size: var(--text-subhead); letter-spacing: .04em; color: var(--ink-soft);
}
.wipe-meta {
  font-family: var(--font-mono); font-size: var(--text-micro);
  letter-spacing: .4em; text-transform: uppercase; color: var(--ink-ghost);
}

/* ═══ NAV ═══════════════════════════════════════════════════════════ */
.nav {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  display: flex; justify-content: space-between; align-items: center;
  padding: clamp(1.2rem, 3vw, 2rem) var(--page-pad);
  background: transparent; transition: background .4s, backdrop-filter .4s;
}
/* T6: durante el tour activo, el bloque de nav es más alto que su
   contenido visible y su caja intercepta clics destinados al
   skip-tour-btn (ahora arriba-derecha) aunque éste pinte por encima —
   .tour-overlay es su propio contexto de apilamiento (z-index:12) y
   pierde frente a .nav (100). Se restringe a body.tour-alive para no
   afectar las páginas normales (evita que clics en el padding vacío
   del nav caigan sobre el contenido de archivo/proyecto). */
body.tour-alive .nav { pointer-events: none; }
body.tour-alive .nav > * { pointer-events: auto; }
.nav.scrolled {
  background: var(--bg-glass);
  backdrop-filter: var(--blur-glass); -webkit-backdrop-filter: var(--blur-glass);
}
.wordmark {
  font-family: var(--font-display); font-weight: 300;
  font-size: clamp(1rem, 1.8vw, 1.3rem); letter-spacing: .28em;
  text-transform: uppercase; color: var(--ink); text-decoration: none;
  display: inline-flex; align-items: center; min-height: 44px;
}
.wordmark em { font-style: italic; font-weight: 400; }
.nav-links { display: flex; gap: clamp(1.2rem, 3vw, 2.5rem); list-style: none; }
.nav-links a {
  font-size: var(--text-caption); letter-spacing: .3em; text-transform: uppercase;
  color: var(--ink); text-decoration: none; position: relative;
  display: inline-flex; align-items: center; min-height: 44px;
}
.nav-links a::after {
  content: ''; position: absolute; bottom: 8px; left: 0; width: 100%; height: 1px;
  background: var(--ink); transform: scaleX(0); transform-origin: left;
  transition: transform .4s var(--ease);
}
.nav-links a:hover::after, .nav-links a:focus-visible::after { transform: scaleX(1); }

/* T4.2: Toggle del menú (oculto en escritorio) */
.nav-toggle {
  display: none; width: 44px; height: 44px; border: none; background: transparent;
  cursor: pointer; position: relative; z-index: 1000;
}
.hamburger {
  display: block; width: 24px; height: 1px; background: var(--ink);
  position: absolute; left: 10px; top: 21px; transition: background .3s;
}
.hamburger::before, .hamburger::after {
  content: ''; position: absolute; left: 0; width: 24px; height: 1px; background: var(--ink);
  transition: transform .3s var(--ease);
}
.hamburger::before { transform: translateY(-6px); }
.hamburger::after { transform: translateY(6px); }

/* Compact mode (≤ 1024px) */
@media (max-width: 1024px) {
  .nav-links { gap: clamp(1rem, 2vw, 1.5rem); }
}

/* Mobile overlay (≤ 767px) */
@media (max-width: 767px) {
  .nav-toggle { display: block; }
  
  .nav-links {
    position: fixed; inset: 0; z-index: 999;
    flex-direction: column; justify-content: center; align-items: center;
    background-color: var(--bg-primary);
    background-image: 
      linear-gradient(to right, var(--a06) 1px, transparent 1px),
      linear-gradient(to bottom, var(--a06) 1px, transparent 1px);
    background-size: 40px 40px;
    background-position: center;
    opacity: 0; visibility: hidden; pointer-events: none;
    transform: none;
    transition: opacity .5s cubic-bezier(.4, 0, .2, 1), visibility 0s .5s;
    will-change: opacity;
  }
  /* Enlaces: cascada suave al abrir; al cerrar sólo se desvanecen con
     el overlay (sin salto). Sobrescribe la cascada del hero de escritorio. */
  .nav-links li {
    opacity: 0; transform: translateY(14px);
    transition: opacity .45s cubic-bezier(.22, 1, .36, 1),
                transform .55s cubic-bezier(.22, 1, .36, 1);
  }
  .nav-links a { font-size: clamp(2rem, 9vw, 2.8rem); min-height: 72px; letter-spacing: .18em; }

  body.nav-open { overflow: hidden; }
  /* El backdrop-filter de .nav.scrolled convierte al nav en containing
     block de sus fixed (Safari/iOS): el overlay quedaba recortado a la
     franja del nav a media página. Con el menú abierto, fuera backdrop. */
  body.nav-open .nav {
    background: transparent;
    backdrop-filter: none; -webkit-backdrop-filter: none;
  }
  /* Wordmark visible sobre el overlay, como ancla superior */
  body.nav-open .wordmark { position: relative; z-index: 1000; }
  body.nav-open .nav-links {
    opacity: 1; visibility: visible; pointer-events: auto;
    transition: opacity .5s cubic-bezier(.4, 0, .2, 1), visibility 0s;
  }
  body.nav-open .nav-links li { opacity: 1; transform: translateY(0); }
  body.nav-open .nav-links li:nth-child(1) { transition-delay: .08s; }
  body.nav-open .nav-links li:nth-child(2) { transition-delay: .16s; }
  body.nav-open .nav-links li:nth-child(3) { transition-delay: .24s; }
  body.nav-open .nav-links li:nth-child(4) { transition-delay: .32s; }
  
  body.nav-open .hamburger { background: transparent; }
  body.nav-open .hamburger::before { transform: rotate(45deg); }
  body.nav-open .hamburger::after { transform: rotate(-45deg); }
}
/* En el home, los enlaces entran en cascada cuando el plano "está listo".
   Solo escritorio: en móvil viven dentro del overlay del hamburguesa y
   deben ser visibles siempre (hero-ready puede tardar medio tour). */
@media (min-width: 768px) {
  body.js:has(#hero) .nav-links li {
    opacity: 0; transform: translateY(-10px);
    transition: opacity .7s var(--ease), transform .7s var(--ease);
  }
  body.js:has(#hero) .nav-links li:nth-child(2) { transition-delay: .09s; }
  body.js:has(#hero) .nav-links li:nth-child(3) { transition-delay: .18s; }
  body.hero-ready .nav-links li { opacity: 1; transform: translateY(0); }
}
/* Tras la entrada, el hero queda en manos del scroll (GSAP) sin lags */
body.hero-settled .hero .reveal-line > .rl-inner,
body.hero-settled .hero [data-fade] { transition: none; }

/* ═══ HERO (home) ═══════════════════════════════════════════════════ */
.hero {
  position: relative; min-height: 100dvh; z-index: 10;
  display: flex; flex-direction: column; justify-content: flex-end;
  padding: var(--space-2xl) var(--page-pad) clamp(5rem, 12vh, 8rem);
  background: transparent;
}
.hero-eyebrow {
  font-size: var(--text-caption); letter-spacing: .4em; text-transform: uppercase;
  color: var(--ink-soft); margin-bottom: var(--space-md);
}
.hero-headline {
  font-family: var(--font-display); font-weight: 300;
  font-size: var(--text-hero); line-height: .94; letter-spacing: -.025em;
  max-width: 11ch;
}
.hero-headline em { font-style: italic; }
.hero-sub {
  font-family: var(--font-mono);
  font-size: var(--text-caption); letter-spacing: .3em; text-transform: uppercase;
  color: var(--ink-muted); margin-top: var(--space-md);
}

/* Botón de replay del recorrido — sólo visible con body.tour-done (T6) */
.replay-tour-btn {
  display: none; align-items: center; justify-content: center; min-height: 44px;
  align-self: flex-start;   /* hijo de flex-column: sin esto se estira a todo el ancho */
  margin-top: 1.6rem; padding: .9em 1.8em;
  font-family: var(--font-mono); font-size: .65rem;
  letter-spacing: .25em; text-transform: uppercase;
  color: var(--ink); background: transparent;
  border: 1px solid var(--a30); border-radius: 50px; cursor: pointer;
  transition: border-color .3s var(--ease), color .3s var(--ease);
}
.replay-tour-btn:hover, .replay-tour-btn:focus-visible { border-color: var(--ink); }
body.tour-done .replay-tour-btn { display: inline-flex; }

/* Revelado por líneas — disparado por main.js cuando el plano "está listo" */
.reveal-line { display: block; overflow: hidden; }
.reveal-line > .rl-inner {
  display: block; transform: translateY(112%);
  transition: transform 1s var(--ease);
  transition-delay: calc(var(--rl, 0) * 140ms);
}
body.hero-ready .reveal-line > .rl-inner { transform: translateY(0); }
.hero [data-fade] {
  opacity: 0; transform: translateY(14px);
  transition: opacity .9s var(--ease), transform .9s var(--ease);
  transition-delay: calc(var(--rl, 0) * 140ms + 240ms);
}
body.hero-ready .hero [data-fade] { opacity: 1; transform: translateY(0); }

/* Anotación de plano, esquina inferior derecha */
.hero-annot {
  position: absolute; right: var(--page-pad); bottom: clamp(5rem, 12vh, 8rem);
  text-align: right;
  font-family: var(--font-mono); font-size: var(--text-micro);
  letter-spacing: .3em; text-transform: uppercase; color: var(--ink-ghost);
  display: flex; flex-direction: column; gap: .55em;
}
.hero-annot strong { font-weight: 300; color: var(--ink-muted); }
@media (max-width: 767px) { .hero-annot { display: none; } }

/* Indicador de scroll como barra de escala */
.scroll-scale {
  position: absolute; left: 50%; bottom: 1.8rem; transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: .6rem;
  font-family: var(--font-mono); font-size: var(--text-micro);
  letter-spacing: .4em; text-transform: uppercase; color: var(--ink-ghost);
}
.scroll-scale svg { display: block; overflow: visible; }
.scroll-scale line { stroke: var(--a30); stroke-width: 1; }
.scroll-scale .ss-cursor {
  stroke: var(--ink); animation: ssSweep 2.6s var(--ease-draw) infinite;
}
@keyframes ssSweep {
  0%   { transform: translateX(0);    opacity: 0; }
  12%  { opacity: 1; }
  70%  { transform: translateX(72px); opacity: 1; }
  100% { transform: translateX(72px); opacity: 0; }
}

/* ═══ TOUR 3D (home) — recorrido por la maqueta ════════════════════
   La sección mide 450vh; el interior es sticky 100vh. El lienzo #c
   (fixed, z-index 0) pinta la maqueta debajo; aquí solo viven el hero
   y las tarjetas-overlay de cada habitación. tour.js gobierna las
   clases: body.tour-alive (WebGL vivo) · body.tour-static (fallback). */
.tour-section { height: 560vh; background: transparent; }
.tour-sticky { position: sticky; top: 0; height: 100vh; overflow: hidden; }
.tour-sticky .hero { position: absolute; inset: 0; min-height: 0; }
@media (max-width: 767px) { .tour-section { height: 470vh; } }

/* Sin tour (reduced-motion / sin WebGL / GPU débil): la sección vuelve
   a ser un hero de una pantalla y las destacadas (.pcard.featured)
   reaparecen más abajo con los mismos 3 proyectos. */
body.tour-static .tour-section,
body.no-webgl .tour-section { height: 100dvh; }
/* El tour-overlay debe seguir visible en fallback porque contiene el
   botón skip-tour. Las .tour-room nacen invisibles y como el JS del
   tour no corre en fallback, nunca reciben .is-on. */

/* ═══ HERO FALLBACK ESTÁTICO (tour-static / no-webgl) ══════════════ */
.hero-static-bg {
  display: none; position: absolute; inset: 0; width: 100%; height: 100%;
  z-index: -1;
}
.hero-static-bg img { width: 100%; height: 100%; object-fit: cover; }
body.tour-static .hero-static-bg,
body.no-webgl .hero-static-bg { display: block; }

/* Legibilidad de textos (a11y) sobre fondo oscuro luna-hero */
body.tour-static .hero,
body.no-webgl .hero { color: var(--paper); }
body.tour-static .hero-eyebrow, body.no-webgl .hero-eyebrow,
body.tour-static .hero-sub, body.no-webgl .hero-sub { color: var(--paper-muted); }
body.tour-static .hero-annot, body.no-webgl .hero-annot,
body.tour-static .scroll-scale, body.no-webgl .scroll-scale { color: var(--paper-ghost); }
body.tour-static .scroll-scale .ss-cursor, body.no-webgl .scroll-scale .ss-cursor { stroke: var(--paper); }
body.tour-static .scroll-scale line, body.no-webgl .scroll-scale line { stroke: rgba(244,241,236,0.3); }
/* El cursor propio (punto de tinta + aro) era invisible sobre fondos
   oscuros (hero estático/tour-visto, noche del manifiesto) — y con
   cursor:none el ratón "desaparecía". Blanco + difference se invierte
   contra cualquier fondo: tinta sobre papel, luz sobre oscuro. */
#cd { background: #fff; mix-blend-mode: difference; }
#cr { border-color: rgba(255,255,255,0.75); mix-blend-mode: difference; }
body.tour-static .replay-tour-btn, body.no-webgl .replay-tour-btn {
  color: var(--paper); border-color: rgba(244, 241, 236, 0.3);
}
body.tour-static .replay-tour-btn:hover, body.no-webgl .replay-tour-btn:hover,
body.tour-static .replay-tour-btn:focus-visible, body.no-webgl .replay-tour-btn:focus-visible {
  border-color: var(--paper);
}

/* Velo para garantizar contraste sobre la foto nocturna */
body.tour-static .hero::before,
body.no-webgl .hero::before {
  content: ''; position: absolute; inset: 0; z-index: -1;
  background: linear-gradient(to top, rgba(28,26,23,0.85) 0%, rgba(28,26,23,0.3) 100%);
}

/* Ocultar UI de tour innecesaria en fallback */
body.tour-static #tourProgress, body.no-webgl #tourProgress,
body.tour-static #tourHandoff, body.no-webgl #tourHandoff,
body.tour-static .sf-tag, body.no-webgl .sf-tag { display: none !important; }
/* El grid curado actual no duplica proyectos del tour (ya no existen
   las clases .featured/.in-tour): todas las tarjetas, incluidas las
   span-7 (TownHouse One, Villa Centenario), conservan su span completo
   tanto con tour-alive como en el fallback estático. */

/* El título de #proyectos cambia cuando el tour ya mostró las destacadas */
.section-title .st-tour { display: none; }
body.tour-alive .section-title .st-default { display: none; }
body.tour-alive .section-title .st-tour { display: inline; }

/* — Tarjetas de habitación (overlay HTML real: enlazable y rastreable) — */
.tour-overlay { position: absolute; inset: 0; z-index: 12; pointer-events: none; }

/* Botón Saltar Recorrido (T4.1) */
.skip-tour-btn {
  /* Debe librar el nav fijo (~108px con padding máximo): el nav (z100,
     franja glass al scroll) pinta por encima del overlay (z12) y lo corta. */
  position: absolute; top: clamp(7.2rem, 13vh, 9rem); right: var(--page-pad);
  pointer-events: auto; z-index: 100;
  font-family: var(--font-mono); font-size: 0.65rem;
  letter-spacing: .25em; text-transform: uppercase;
  color: #fff; background: rgba(0,0,0,0.4);
  padding: 1.1em 2em; border-radius: 50px;
  display: inline-flex; align-items: center; justify-content: center; min-height: 44px;
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  box-shadow: 0 4px 20px rgba(0,0,0,0.2), inset 0 0 0 1px rgba(255,255,255,0.15);
  transition: all .4s var(--ease);
  text-decoration: none;
}
.skip-tour-btn:hover, .skip-tour-btn:focus-visible {
  background: rgba(0,0,0,0.7);
  box-shadow: 0 8px 30px rgba(0,0,0,0.3), inset 0 0 0 1px rgba(255,255,255,0.3);
  transform: translateY(-2px);
}
body.tour-static .skip-tour-btn, body.no-webgl .skip-tour-btn { display: none; }
/* En static mode, el fondo es oscuro, ajustar contraste del botón si se desea,
   o dejar la pastilla clara como está. Con var(--bg-glass) se lee bien. */
.tour-room {
  position: absolute; left: var(--page-pad); bottom: clamp(4.5rem, 11vh, 8rem);
  max-width: 32rem;
  padding: 1.5rem 1.8rem 1.2rem;
  background: var(--bg-glass);
  backdrop-filter: var(--blur-glass); -webkit-backdrop-filter: var(--blur-glass);
  box-shadow: inset 0 0 0 1px var(--a06);
  opacity: 0; transform: translateY(26px); visibility: hidden;
  transition: opacity .65s var(--ease), transform .65s var(--ease), visibility 0s .65s;
}
.tour-room.is-on {
  opacity: 1; transform: translateY(0); visibility: visible;
  transition: opacity .65s var(--ease) .12s, transform .65s var(--ease) .12s, visibility 0s;
  pointer-events: auto;
}
/* Móvil: la tarjeta queda acotada por ambos márgenes de página —
   un título largo nunca puede salirse del viewport */
@media (max-width: 767px) {
  .tour-room { right: var(--page-pad); max-width: none; }
}
.tr-num {
  font-family: var(--font-mono); font-size: var(--text-micro);
  letter-spacing: .4em; color: var(--ink-ghost);
  display: flex; align-items: center; gap: 1rem; margin-bottom: .9rem;
}
.tr-num::after { content: ''; width: 34px; height: 1px; background: var(--line-strong); }
.tour-room h2 {
  font-family: var(--font-display); font-weight: 300;
  font-size: var(--text-heading); line-height: 1; letter-spacing: -.01em;
}
.tour-room h2 em { font-style: italic; color: var(--ink-soft); }
.tr-meta {
  font-family: var(--font-mono); font-size: var(--text-micro);
  letter-spacing: .3em; text-transform: uppercase; color: var(--ink-muted);
  margin-top: .8rem;
}
.tr-link {
  display: inline-flex; align-items: center; gap: .6rem; margin-top: 1.3rem;
  font-size: var(--text-caption); letter-spacing: .28em; text-transform: uppercase;
  color: var(--ink); text-decoration: none; position: relative; min-height: 44px;
}
.tr-link::after {
  content: ''; position: absolute; bottom: 8px; left: 0; width: 100%; height: 1px;
  background: var(--ink); transform: scaleX(0); transform-origin: left;
  transition: transform .4s var(--ease);
}
.tr-link:hover::after, .tr-link:focus-visible::after { transform: scaleX(1); }

/* Anotación de maqueta (esquina inferior derecha, fase de extrusión) */
.tour-annot {
  position: absolute; right: var(--page-pad); bottom: clamp(4.5rem, 11vh, 8rem);
  font-family: var(--font-mono); font-size: var(--text-micro);
  letter-spacing: .3em; text-transform: uppercase; color: var(--ink-ghost);
  text-align: right;
  opacity: 0; transform: translateY(14px);
  transition: opacity .6s var(--ease), transform .6s var(--ease);
}
.tour-annot.is-on { opacity: 1; transform: translateY(0); }
@media (max-width: 767px) { .tour-annot { display: none; } }

/* Línea de cierre del tour → invita a seguir hacia el archivo */
.tour-handoff {
  position: absolute; left: 50%; bottom: 1.8rem; transform: translate(-50%, 12px);
  font-family: var(--font-mono); font-size: var(--text-micro);
  letter-spacing: .4em; text-transform: uppercase; color: var(--ink-muted);
  opacity: 0; transition: opacity .6s var(--ease), transform .6s var(--ease);
}
.tour-handoff.is-on { opacity: 1; transform: translate(-50%, 0); }

/* Riel de progreso del recorrido (borde derecho) */
.tour-progress {
  position: absolute; right: calc(var(--sheet-inset) + 14px); top: 50%;
  transform: translateY(-50%);
  display: flex; flex-direction: column; align-items: center; gap: .7rem;
  opacity: 0; transition: opacity .6s var(--ease);
}
body.tour-alive .tour-progress { opacity: 1; }
.tp-rail { position: relative; width: 1px; height: clamp(110px, 22vh, 190px); background: var(--a12); }
.tp-rail i {
  position: absolute; left: 50%; width: 7px; height: 1px;
  background: var(--a30); transform: translateX(-50%);
}
.tp-rail i:nth-child(2) { top: 0; } .tp-rail i:nth-child(3) { top: 20%; }
.tp-rail i:nth-child(4) { top: 40%; } .tp-rail i:nth-child(5) { top: 60%; }
.tp-rail i:nth-child(6) { top: 80%; } .tp-rail i:nth-child(7) { top: 100%; }
.tp-dot {
  position: absolute; left: 50%; top: calc(var(--tp, 0) * 100%);
  width: 5px; height: 5px; border-radius: 50%;
  background: var(--ink); transform: translate(-50%, -50%);
}
.tour-progress .tp-label {
  font-family: var(--font-mono); font-size: var(--text-micro);
  letter-spacing: .2em; color: var(--ink-ghost);
}
@media (max-width: 767px) { .tour-progress { display: none; } }

/* ═══ SECCIONES — comunes ══════════════════════════════════════════ */
main { display: block; }
section { position: relative; z-index: 10; background: var(--bg-primary); }
.section-eyebrow {
  font-size: var(--text-caption); letter-spacing: .3em; text-transform: uppercase;
  color: var(--ink-muted); margin-bottom: var(--space-sm);
  display: flex; align-items: center; gap: 1rem;
}
.section-eyebrow::before {
  content: ''; width: 34px; height: 1px; background: var(--line-strong);
  transform: scaleX(0); transform-origin: left;
  transition: transform .9s var(--ease-draw) .15s;
}
.section-eyebrow.in-view::before,
.manifesto-section.in-view .section-eyebrow::before,
body.night-on .manifesto-section .section-eyebrow::before { transform: scaleX(1); }
.section-title {
  font-family: var(--font-display); font-weight: 300;
  font-size: var(--text-display); line-height: .95; letter-spacing: -.02em;
  margin-bottom: var(--space-lg);
}
.section-title em { font-style: italic; }

/* Regla que se dibuja al entrar (decoración de sección) */
.draw-rule { width: 100%; height: 10px; overflow: visible; display: block; }
.draw-rule line, .draw-rule path {
  stroke: var(--line-strong); stroke-width: 1; fill: none;
}
.draw-rule [pathLength] {
  stroke-dasharray: 100; stroke-dashoffset: 100;
  transition: stroke-dashoffset 1.6s var(--ease-draw) .15s;
}
.in-view .draw-rule [pathLength], .draw-rule.in-view [pathLength] { stroke-dashoffset: 0; }

/* Revelado genérico */
[data-animate] {
  opacity: 0; transform: translateY(20px);
  transition: opacity .8s var(--ease), transform .8s var(--ease);
  transition-delay: calc(var(--stagger, 0) * 90ms);
}
[data-animate].in-view { opacity: 1; transform: translateY(0); }

/* ═══ GRID DE PROYECTOS (home) ═════════════════════════════════════ */
.projects-section {
  padding: var(--space-2xl) var(--page-pad) var(--space-xl);
  max-width: 1440px; margin: 0 auto;
}
.projects-grid {
  /* minmax(0,1fr): una ficha larga (pd-meta) no puede ensanchar la pista
     ni desbordar el viewport móvil. align-start: cada tarjeta mide su
     contenido y el pframe abraza imagen + ficha (sin banda vacía). */
  display: grid; grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: clamp(2.4rem, 5vw, 4.5rem) var(--grid-gap);
  align-items: start;
}

/* — Tarjeta de proyecto: se "delinea" antes de revelarse — */
.pcard { position: relative; }
.pcard-link {
  display: block; position: relative; text-decoration: none; color: var(--ink);
}
.pcard-media {
  position: relative; overflow: hidden; background: var(--bg-secondary);
}
.pcard-media img {
  width: 100%; height: 100%; object-fit: cover; display: block;
  transition: transform 1.4s var(--ease), filter .8s var(--ease);
}
/* Cortina de papel: cubre el render hasta que la tarjeta "se delinea".
   No recorta la <img> (la carga diferida necesita área visible). */
.pcard-media::before {
  content: ''; position: absolute; inset: 0; z-index: 2;
  background: var(--bg-secondary);
  transform: scaleX(1); transform-origin: right;
  transition: transform 1.15s var(--ease-draw) .4s;
}
.pcard.in-view .pcard-media::before { transform: scaleX(0); }
.pcard-link:hover .pcard-media img,
.pcard-link:focus-visible .pcard-media img { transform: scale(1.035); }

/* Marco que se traza (rect SVG con pathLength) */
.pframe {
  position: absolute; inset: 0; width: 100%; height: 100%;
  pointer-events: none; z-index: 3; overflow: visible;
}
.pframe rect {
  fill: none; stroke: var(--line-strong); stroke-width: 1;
  stroke-dasharray: 400; stroke-dashoffset: 400;
  transition: stroke-dashoffset 1.3s var(--ease-draw);
}
.pcard.in-view .pframe rect { stroke-dashoffset: 0; }

/* Micro-plano que aparece al hover (capa blueprint) */
.bp-hover {
  position: absolute; inset: 0; width: 100%; height: 100%;
  pointer-events: none; z-index: 4; overflow: visible;
  opacity: .95;
  /* doble halo de tinta: la línea blanca se separa también de renders claros */
  filter: drop-shadow(0 0 1px rgba(28,26,23,.55)) drop-shadow(0 0 3px rgba(28,26,23,.35));
}
.bp-hover line, .bp-hover circle, .bp-hover rect {
  fill: none; stroke: rgba(244,241,236,.95); stroke-width: 1.2px;
  stroke-dasharray: 100; stroke-dashoffset: 100;
}
.bp-hover [data-d] { transition: stroke-dashoffset .9s var(--ease-draw); }
.bp-hover [data-d="2"] { transition-delay: .12s; }
.bp-hover [data-d="3"] { transition-delay: .24s; }
.bp-hover [data-d="4"] { transition-delay: .36s; }
.pcard-link:hover .bp-hover [data-d],
.pcard-link:focus-visible .bp-hover [data-d] { stroke-dashoffset: 0; }
/* La imagen se atenúa apenas para que la línea respire */
.pcard-link:hover .pcard-media img { filter: brightness(.92); }

/* En táctil (sin hover): el micro-plano se dibuja una vez al entrar y se desvanece */
@media (hover: none) {
  .pcard.in-view .bp-hover [data-d] {
    stroke-dashoffset: 0;
    transition: stroke-dashoffset 1s var(--ease-draw) .9s, opacity 1s ease 2.6s;
  }
  .pcard.in-view .bp-hover { animation: bpSettle 4.2s ease forwards; }
  @keyframes bpSettle { 0%,55% { opacity: .95; } 100% { opacity: .25; } }
}

/* Número fantasma */
.proj-num {
  font-family: var(--font-display); font-weight: 300; font-style: italic;
  font-size: clamp(7rem, 14vw, 12rem); line-height: 1; letter-spacing: -.04em;
  color: rgba(28,26,23,.05); position: absolute; top: -.58em; left: -.02em;
  z-index: 5; pointer-events: none; user-select: none;
  transition: color .7s var(--ease);
}
.pcard:hover .proj-num { color: rgba(28,26,23,.1); }

/* Ficha bajo cada tarjeta — línea de datos mono */
.pcard-data {
  display: flex; flex-wrap: wrap; justify-content: space-between;
  align-items: baseline; gap: .3rem 1rem;
  padding-top: .9rem;
  border-bottom: 1px solid transparent;
}
.pcard-data h3 {
  font-family: var(--font-display); font-weight: 300;
  font-size: var(--text-subhead); letter-spacing: .01em;
}
.pcard-data h3 em { font-style: italic; }
.pcard-data .pd-meta {
  font-family: var(--font-mono); font-size: var(--text-micro);
  letter-spacing: .22em; text-transform: uppercase; color: var(--ink-muted);
  /* sin nowrap: en tarjetas estrechas la ficha baja a su propia línea
     (margin-left auto la mantiene alineada a la derecha) en vez de
     estrangular el título o desbordar el marco */
  text-align: right; margin-left: auto;
}
.pcard-arrow {
  position: absolute; right: .9rem; top: .9rem; z-index: 5;
  width: 38px; height: 38px; border: 1px solid rgba(244,241,236,.55); border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: var(--ink-on-dark); font-size: .9rem;
  opacity: 0; transform: scale(.8); backdrop-filter: blur(3px);
  background: rgba(28,26,23,.25);
  transition: opacity .35s var(--ease), transform .35s var(--ease);
}
.pcard-link:hover .pcard-arrow, .pcard-link:focus-visible .pcard-arrow { opacity: 1; transform: scale(1); }

/* — Jerarquías del grid — */
.pcard.span-12 { grid-column: span 12; }
.pcard.span-8  { grid-column: span 8; }
.pcard.span-7  { grid-column: span 7; }
.pcard.span-6  { grid-column: span 6; }
.pcard.span-5  { grid-column: span 5; }
.pcard.span-4  { grid-column: span 4; }
.pcard .ar-wide   { aspect-ratio: 21/9; }
.pcard .ar-photo  { aspect-ratio: 16/10; }
.pcard .ar-tall   { aspect-ratio: 4/5; }
.pcard .ar-std    { aspect-ratio: 4/3; }
.pcard .ar-square { aspect-ratio: 1/1; }

/* Tarjeta índice — cierre del grid hacia archivo.html */
.pcard-index { grid-column: 1 / -1; }
.pcard-index-link {
  display: flex; flex-direction: column; gap: 1.2rem;
  padding: clamp(3rem, 7vw, 5.5rem) clamp(1.5rem, 4vw, 3rem);
  text-decoration: none; text-align: center; align-items: center;
}
.pi-eyebrow {
  font-family: var(--font-mono); font-size: var(--text-micro);
  letter-spacing: .4em; text-transform: uppercase; color: var(--ink-ghost);
}
.pi-title {
  font-family: var(--font-display); font-weight: 300;
  font-size: clamp(1.8rem, 4.5vw, 3.2rem); line-height: 1.15; color: var(--ink);
}
.pi-title em { font-style: italic; }

/* — Tier destacado ("obra en plano") — */
.pcard.featured .pcard-data h3 { font-size: var(--text-heading); }
.pcard.featured .pcard-media::after {
  /* velo que se retira al hover para dar paso al render */
  content: ''; position: absolute; inset: 0; z-index: 2;
  background: linear-gradient(160deg, rgba(28,26,23,.18), transparent 55%);
  transition: opacity .8s var(--ease);
}
.pcard.featured .pcard-link:hover .pcard-media::after { opacity: 0; }
/* Paneo ambiental lento — la cámara recorre el render */
.pcard.featured .pcard-media img { transform-origin: 50% 42%; }
.pcard.featured.in-view .pcard-media img {
  animation: ambientPan 26s ease-in-out 2.2s infinite alternate;
}
@keyframes ambientPan {
  from { transform: scale(1.02) translateX(-.6%); }
  to   { transform: scale(1.07) translateX(.9%); }
}
.pcard.featured .pcard-link:hover .pcard-media img { animation-play-state: paused; }

/* Destacado con cita lateral (Wellness) */
.proj-pair {
  display: grid; grid-template-columns: minmax(0, 7fr) minmax(0, 5fr);
  gap: clamp(2rem, 4vw, 4rem); align-items: center;
}
.proj-aside { display: flex; flex-direction: column; gap: var(--space-md); padding: var(--space-md) 0; }
.proj-aside blockquote {
  font-family: var(--font-display); font-style: italic; font-weight: 300;
  font-size: clamp(1.3rem, 2.5vw, 2.1rem); line-height: 1.35; color: var(--ink-soft);
  position: relative; padding-left: 1.6rem;
}
.proj-aside blockquote::before {
  content: ''; position: absolute; left: 0; top: .35em; bottom: .35em;
  width: 1px; background: var(--line-strong);
}
.proj-aside .pa-meta {
  font-family: var(--font-mono); font-size: var(--text-micro);
  letter-spacing: .25em; text-transform: uppercase; color: var(--ink-muted);
  line-height: 2.1;
}
.proj-aside-cta {
  display: inline-flex; align-items: center; gap: .6rem; min-height: 44px;
  font-size: var(--text-caption); letter-spacing: .28em; text-transform: uppercase;
  color: var(--ink); text-decoration: none;
  transition: gap .35s var(--ease), opacity .3s; opacity: .55;
}
.proj-aside-cta:hover, .proj-aside-cta:focus-visible { gap: 1.2rem; opacity: 1; }

/* Celda de anotación dentro del grid (acompaña a una tarjeta) */
.grid-aside {
  grid-column: span 5;
  display: flex; flex-direction: column; justify-content: center; gap: var(--space-md);
  padding: var(--space-md);
  border: 1px dashed var(--line-strong);
}
.grid-aside .ga-num {
  font-family: var(--font-mono); font-size: var(--text-micro);
  letter-spacing: .35em; text-transform: uppercase; color: var(--ink-ghost);
}
.grid-aside .ga-text {
  font-family: var(--font-display); font-style: italic; font-weight: 300;
  font-size: clamp(1.15rem, 2vw, 1.6rem); line-height: 1.4; color: var(--ink-soft);
}
@media (max-width: 1023px) { .grid-aside { grid-column: span 12; } }

/* Nota editorial de cierre del grid */
.grid-note {
  grid-column: span 12;
  display: flex; align-items: baseline; gap: 1.4rem; flex-wrap: wrap;
  padding-top: var(--space-md); border-top: 1px solid var(--line);
  font-family: var(--font-mono); font-size: var(--text-caption);
  letter-spacing: .18em; text-transform: uppercase; color: var(--ink-muted);
}
.grid-note a { color: var(--ink); text-decoration: none; border-bottom: 1px solid var(--line-strong); padding-bottom: 2px; transition: border-color .3s; }
.grid-note a:hover { border-color: var(--ink); }

@media (max-width: 1023px) {
  .pcard.span-8, .pcard.span-7, .pcard.span-6,
  .pcard.span-5, .pcard.span-4 { grid-column: span 12; }
  .proj-pair { grid-template-columns: 1fr; }
}

/* ═══ MANIFIESTO — "corte de sección": entrar a otra habitación ════ */
.manifesto-section {
  padding: var(--space-xl) 0 var(--space-2xl);
  background: var(--bg-primary);
}
/* Línea de corte con etiquetas de sección en los extremos */
.cut-line {
  display: flex; align-items: center; gap: 1.1rem;
  padding: 0 var(--page-pad); margin-bottom: calc(var(--space-md) * -1);
  position: relative; z-index: 12;
}
.cut-tag {
  flex-shrink: 0; width: 34px; height: 34px; border-radius: 50%;
  border: 1px solid var(--line-strong);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-mono); font-size: var(--text-micro); letter-spacing: .08em;
  color: var(--ink-muted); background: var(--bg-primary);
}
.cut-line svg { flex: 1; height: 12px; overflow: visible; }
.cut-line line {
  stroke: var(--line-strong); stroke-width: 1; stroke-dasharray: 14 5 2 5;
}
.cut-line .cl-anim {
  stroke-dasharray: 100; stroke-dashoffset: 100;
  transition: stroke-dashoffset 1.8s var(--ease-draw);
}
.manifesto-section.in-view .cut-line .cl-anim { stroke-dashoffset: 0; }

/* La habitación oscura.
   Sin GSAP: panel oscuro estático (rama de respaldo, hoy validada).
   Con GSAP (body.gsap-on): la sección se vuelve un escenario transparente
   de 100dvh y la noche la pone #nightLayer a pantalla completa. */
.room {
  background: var(--bg-inverse); color: var(--ink-on-dark);
  margin: 0 var(--page-pad);
  padding: clamp(4rem, 9vw, 8rem) var(--page-pad);
  display: flex; flex-direction: column; align-items: center; text-align: center;
  position: relative; overflow: hidden;
}
/* El mismo plano, visto de noche: retícula tenue en tinta invertida */
body:not(.night-on) .room::before {
  content: ''; position: absolute; inset: 0; opacity: .55; pointer-events: none;
  background-image:
    repeating-linear-gradient(0deg,  rgba(244,241,236,.05) 0 1px, transparent 1px 72px),
    repeating-linear-gradient(90deg, rgba(244,241,236,.05) 0 1px, transparent 1px 72px);
}
body.night-on .manifesto-section {
  background: transparent;
  /* sin colchones: el .room de 100dvh debe alinear EXACTO con el
     viewport pinneado — si no, sobresale por abajo y el CTA se corta */
  padding-top: 0; padding-bottom: 0;
}
body.night-on .cut-line {
  position: absolute; top: 1.4rem; left: 0; right: 0; margin: 0; z-index: 12;
}
body.night-on .room {
  background: transparent; overflow: visible;
  min-height: 100dvh; justify-content: center;
  margin: 0; padding-top: var(--space-lg); padding-bottom: var(--space-lg);
}
body.night-on .manifesto-text { transition: none; }
.m-cta-wrap { display: inline-flex; margin-top: var(--space-md); }
body.night-on .m-cta-wrap .manifesto-cta { margin-top: 0; }

/* ── LA NOCHE ENTRA EN LA LÁMINA (takeover a pantalla completa) ──── */
#nightLayer {
  position: fixed; inset: 0; z-index: 5;
  background: var(--bg-inverse);
  visibility: hidden; opacity: 0;
  clip-path: inset(50% 0% 50% 0%);
  pointer-events: none; overflow: hidden;
}
.night-grid {
  position: absolute; left: 0; right: 0; top: -50%; height: 200%;
  opacity: .55;
  background-image:
    repeating-linear-gradient(0deg,  rgba(244,241,236,.05) 0 1px, transparent 1px 72px),
    repeating-linear-gradient(90deg, rgba(244,241,236,.05) 0 1px, transparent 1px 72px);
}
/* Inversión del chrome de la página mientras dura la noche */
body.night .nav .wordmark, body.night .nav-links a { color: var(--ink-on-dark); }
body.night .nav-links a::after { background: var(--ink-on-dark); }
body.night .nav.scrolled {
  background: rgba(28, 26, 23, .72);
}
body.night .sheet-frame { border-color: rgba(244,241,236,.16); }
body.night .sheet-frame::before, body.night .sheet-frame::after,
body.night .sheet-frame .sf-c::before, body.night .sheet-frame .sf-c::after {
  border-color: rgba(244,241,236,.35);
}
body.night .sheet-frame .sf-tag { background: var(--bg-inverse); color: rgba(244,241,236,.6); }
body.night #cd { background: var(--ink-on-dark); }
body.night #cr { border-color: rgba(244,241,236,.5); }
body.night #trace { mix-blend-mode: screen; }
body.night .cut-tag {
  background: var(--bg-inverse);
  color: rgba(244,241,236,.6);
  border-color: rgba(244,241,236,.3);
}
body.night .cut-line line { stroke: rgba(244,241,236,.3); }
.cut-tag, .cut-line line { transition: background .35s, color .35s, border-color .35s, stroke .35s; }
.nav .wordmark, .nav-links a { transition: color .35s; }
.sheet-frame, .sheet-frame::before, .sheet-frame::after,
.sheet-frame .sf-c::before, .sheet-frame .sf-c::after, .sheet-frame .sf-tag {
  transition: border-color .35s, color .35s, background .35s;
}
.room > * { position: relative; }
.room .section-eyebrow { color: var(--ink-on-dark); opacity: .45; justify-content: center; }
.room .section-eyebrow::before { background: rgba(244,241,236,.4); }
.room .section-title { color: var(--ink-on-dark); }
.manifesto-text {
  max-width: 600px; font-family: var(--font-display); font-style: italic;
  font-weight: 300; font-size: var(--text-subhead); line-height: 1.82;
  color: rgba(244,241,236,.82); margin-bottom: var(--space-md);
  opacity: 0; transform: translateY(18px);
  transition: opacity 1s var(--ease), transform 1s var(--ease);
  transition-delay: calc(.9s + var(--i, 0) * 220ms);
}
.manifesto-section.in-view .manifesto-text { opacity: 1; transform: translateY(0); }
.manifesto-text em { font-style: normal; font-weight: 400; color: var(--ink-on-dark); }
.manifesto-cta {
  display: inline-flex; align-items: center; gap: .8rem; margin-top: var(--space-md);
  font-size: var(--text-caption); letter-spacing: .3em; text-transform: uppercase;
  color: var(--ink-on-dark); text-decoration: none;
  border: 1px solid rgba(244,241,236,.35);
  padding: .9rem 1.8rem; min-height: 44px;
  position: relative; overflow: hidden; isolation: isolate;
  transition: color .45s var(--ease);
}
.manifesto-cta::before {
  content: ''; position: absolute; inset: 0; z-index: -1;
  background: var(--ink-on-dark);
  transform: scaleX(0); transform-origin: left;
  transition: transform .45s var(--ease);
}
.manifesto-cta:hover, .manifesto-cta:focus-visible { color: var(--bg-inverse); }
.manifesto-cta:hover::before, .manifesto-cta:focus-visible::before { transform: scaleX(1); }

/* Viewports cortos: mientras la noche pinnea (.night-on), todo el bloque
   (eyebrow + título + 3 párrafos + CTA) debe caber bajo el fold — si no,
   los párrafos "se cortan" por mucho recorrido que tenga el pin. */
@media (max-height: 820px) {
  body.night-on .room .section-title {
    font-size: calc(var(--text-display) * .85);
    margin-bottom: var(--space-md);
  }
  body.night-on .manifesto-text {
    font-size: calc(var(--text-subhead) * .88);
    line-height: 1.6; margin-bottom: 1.1rem; max-width: 560px;
  }
  body.night-on .room .m-cta-wrap { margin-top: 1rem; }
}

/* ═══ CONTACTO ══════════════════════════════════════════════════════ */
.contact-section {
  padding: var(--space-2xl) var(--page-pad);
  display: flex; flex-direction: column; align-items: center; text-align: center;
  position: relative; overflow: hidden;
}
/* La malla de puntos vive detrás del contenido de la sección */
#waves { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 0; pointer-events: none; }
.contact-section > :not(canvas) { position: relative; z-index: 10; }
.contact-lead {
  max-width: 520px; font-size: var(--text-body); line-height: 1.8;
  color: var(--ink-soft); margin-bottom: var(--space-lg);
}
.arc-deco { width: min(800px, 100%); height: 60px; display: block; overflow: visible; opacity: .14; margin-bottom: var(--space-lg); }
.arc-deco path {
  fill: none; stroke: var(--ink); stroke-width: 1;
  stroke-dasharray: 100; stroke-dashoffset: 100;
}
.arc-deco.in-view path { stroke-dashoffset: 0; transition: stroke-dashoffset 2.4s var(--ease-draw); }

.socials { display: flex; gap: .9rem; justify-content: center; flex-wrap: wrap; }
.sc {
  display: grid; grid-template-columns: auto 1fr auto; align-items: center;
  gap: 1rem; padding: 1rem 1.5rem; border: 1px solid var(--a30);
  text-decoration: none; color: var(--ink); transition: all .45s var(--ease);
  position: relative; min-width: clamp(200px, 24vw, 260px); transform-style: preserve-3d;
  min-height: 64px;
}
.sc::after {
  content: ''; position: absolute; inset: 0;
  box-shadow: 0 12px 40px rgba(28,26,23,0); transition: box-shadow .45s var(--ease);
}
.sc:hover { border-color: var(--a60); background: rgba(28,26,23,.03); }
.sc:hover::after { box-shadow: 10px 14px 40px rgba(28,26,23,.08); }
.sc-icon {
  display: flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border: 1px solid var(--a30); border-radius: 50%;
  flex-shrink: 0; position: relative; overflow: hidden;
  transition: border-color .45s, transform .45s var(--ease), background .45s;
}
.sc-icon::before {
  content: ''; position: absolute; inset: 0; border-radius: 50%;
  transform: scale(0); opacity: 0;
  transition: transform .5s var(--ease), opacity .35s;
}
.sc[data-brand="instagram"] .sc-icon::before {
  background: radial-gradient(circle at 30% 107%, #fdf497 0%, #fdf497 5%, #fd5949 45%, #d6249f 60%, #285AEB 90%);
}
.sc[data-brand="tiktok"] .sc-icon::before {
  background: linear-gradient(135deg, #010101 35%, #25F4EE 35% 55%, #FE2C55 55% 75%, #010101 75%);
}
.sc[data-brand="whatsapp"] .sc-icon::before {
  background: #25D366;
}
.sc[data-brand="whatsapp"] .sc-icon svg { fill: currentColor; stroke: none; width: 16px; height: 16px; }
.sc:hover .sc-icon { border-color: var(--ink); transform: rotate(10deg) scale(1.06); }
.sc:hover .sc-icon::before { transform: scale(1); opacity: 1; }
.sc:hover .sc-icon svg { stroke: #F4F1EC; }
.sc-icon svg { position: relative; z-index: 1; width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; transition: stroke .45s; }
.sc-info { display: flex; flex-direction: column; gap: .18rem; text-align: left; }
.sc-net { font-size: .52rem; letter-spacing: .32em; text-transform: uppercase; opacity: .45; }
.sc-handle { font-family: var(--font-display); font-size: .98rem; font-weight: 300; letter-spacing: .02em; }
.sc-action { display: flex; flex-direction: column; align-items: flex-end; gap: .2rem; }
.sc-cta { font-size: .54rem; letter-spacing: .22em; text-transform: uppercase; opacity: 0; transform: translateX(-6px); transition: opacity .45s var(--ease), transform .45s var(--ease); }
.sc:hover .sc-cta { opacity: .6; transform: translateX(0); }
.sc-arrow { font-size: .8rem; opacity: .25; transition: opacity .45s, transform .45s var(--ease); }
.sc:hover .sc-arrow { opacity: .65; transform: translateX(3px); }

/* ═══ CIERRE — constelación generativa ═════════════════════════════ */
.cierre-section {
  position: relative; overflow: hidden; z-index: 10;
  background: var(--bg-primary);
  min-height: clamp(400px, 62vh, 640px);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: var(--space-md); text-align: center;
  padding: var(--space-xl) var(--page-pad);
  border-top: 1px solid var(--line);
}
#konste { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 0; pointer-events: none; }
.cierre-section > :not(canvas) { position: relative; z-index: 10; }
.cierre-line {
  font-family: var(--font-display); font-style: italic; font-weight: 300;
  font-size: clamp(1.5rem, 3.4vw, 2.7rem); line-height: 1.28; color: var(--ink);
  max-width: 24ch;
}
.cierre-line em { font-style: italic; font-weight: 400; }

/* ═══ PIE COMO CAJETÍN (title block) ═══════════════════════════════ */
.site-footer {
  position: relative; z-index: 10;
  padding: 0 var(--page-pad) calc(var(--sheet-inset) + var(--space-md));
  background: var(--bg-primary);
}
.tblock {
  border: 1px solid var(--line-strong);
  display: grid; gap: 1px; background: var(--line-strong);
  grid-template-columns: repeat(6, 1fr);
}
.tb-cell { background: var(--bg-primary); padding: 1rem 1.2rem; min-width: 0; }
.tb-label {
  display: block; font-family: var(--font-mono); font-size: var(--text-micro);
  letter-spacing: .32em; text-transform: uppercase; color: var(--ink-ghost-aa);
  margin-bottom: .45rem;
}
.tb-value {
  font-family: var(--font-mono); font-size: .78rem; letter-spacing: .06em;
  color: var(--ink-soft); line-height: 1.6; overflow-wrap: anywhere;
}
.tb-value.serif { font-family: var(--font-display); font-size: 1.05rem; letter-spacing: .02em; }
.tb-value a { color: inherit; text-decoration: none; transition: color .3s; }
.tb-value a:hover { color: var(--ink); }
.tb-cell.tb-brand { grid-column: span 2; display: flex; align-items: center; }
.tb-cell.tb-nav { grid-column: span 2; }
.tb-nav ul { list-style: none; display: flex; gap: 1.4rem; flex-wrap: wrap; }
.tb-nav a {
  font-size: var(--text-caption); letter-spacing: .22em; text-transform: uppercase;
  color: var(--ink-muted); text-decoration: none; transition: color .3s;
  display: inline-flex; align-items: center; min-height: 32px;
}
.tb-nav a:hover { color: var(--ink); }
.tb-row-foot {
  grid-column: 1 / -1; background: var(--bg-primary);
  display: flex; justify-content: space-between; align-items: center; gap: 1rem;
  padding: .85rem 1.2rem; flex-wrap: wrap;
}
.tb-copy { font-size: var(--text-caption); color: var(--ink-ghost-aa); letter-spacing: .1em; }
.tb-coords { font-family: var(--font-mono); font-size: var(--text-micro); letter-spacing: .15em; color: var(--ink-ghost-aa); }
@media (max-width: 1023px) { .tblock { grid-template-columns: repeat(3, 1fr); } .tb-cell.tb-brand, .tb-cell.tb-nav { grid-column: span 3; } }
@media (max-width: 639px)  { .tblock { grid-template-columns: 1fr 1fr; } .tb-cell.tb-brand, .tb-cell.tb-nav { grid-column: span 2; } }

/* ═══════════════════════════════════════════════════════════════════
   PÁGINAS DE PROYECTO (plantilla editorial — proyecto-*.html)
   ═══════════════════════════════════════════════════════════════════ */

/* — Hero partido: 55% imagen / 45% texto — */
.phero {
  display: grid; grid-template-columns: 55fr 45fr;
  min-height: 100dvh; position: relative; z-index: 10;
  background: var(--bg-primary);
}
.phero-media {
  position: relative; overflow: hidden; background: var(--bg-secondary);
  min-height: 58dvh;
}
.phero-media img {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; display: block;
  transform: scale(1.07); filter: saturate(.92);
  transition: transform 2.8s var(--ease), filter 2.8s var(--ease);
}
body.page-in .phero-media img { transform: scale(1); filter: saturate(1); }

/* Plano que se dibuja sobre el render al cargar y se asienta como veladura */
.phero-bp {
  position: absolute; inset: 0; width: 100%; height: 100%;
  pointer-events: none; z-index: 2;
  /* sin blend: el halo de tinta garantiza lectura sobre cualquier render */
  filter: drop-shadow(0 0 1px rgba(28,26,23,.55)) drop-shadow(0 0 3px rgba(28,26,23,.35));
}
.phero-bp line, .phero-bp rect, .phero-bp circle {
  fill: none; stroke: rgba(244,241,236,.9); stroke-width: 1.1px;
  stroke-dasharray: 100; stroke-dashoffset: 100;
}
body.page-in .phero-bp [data-d]   { stroke-dashoffset: 0; transition: stroke-dashoffset 1.5s var(--ease-draw) .25s; }
body.page-in .phero-bp [data-d="2"] { transition-delay: .55s; }
body.page-in .phero-bp [data-d="3"] { transition-delay: .85s; }
body.page-in .phero-bp { animation: bpVeil 5.2s ease forwards; }
@keyframes bpVeil { 0%, 62% { opacity: 1; } 100% { opacity: .22; } }

.phero-body {
  display: flex; flex-direction: column; justify-content: center;
  padding: clamp(7rem, 16vh, 10rem) var(--page-pad) var(--space-lg);
  position: relative;
}
.phero-num {
  position: absolute; top: clamp(4.4rem, 9vh, 6rem); right: var(--page-pad);
  font-family: var(--font-display); font-style: italic; font-weight: 300;
  font-size: clamp(6rem, 11vw, 10rem); line-height: 1; letter-spacing: -.04em;
  color: rgba(28,26,23,.055); pointer-events: none; user-select: none;
}
.phero-eyebrow {
  font-family: var(--font-mono); font-size: var(--text-micro);
  letter-spacing: .38em; text-transform: uppercase; color: var(--ink-muted);
  margin-bottom: var(--space-sm);
}
.phero-title {
  font-family: var(--font-display); font-weight: 300;
  font-size: clamp(2.6rem, 5.2vw, 4.8rem); line-height: .96; letter-spacing: -.02em;
  margin-bottom: var(--space-md); max-width: 12ch;
}
.phero-title em { font-style: italic; }
.phero-desc p {
  font-size: var(--text-body); line-height: 1.82; color: var(--ink-soft);
  max-width: 52ch; margin-bottom: var(--space-sm);
}
.phero-desc p:first-of-type {
  font-family: var(--font-display); font-style: italic; font-weight: 300;
  font-size: var(--text-subhead); line-height: 1.65; color: var(--ink);
}
/* Entrada del texto del hero de proyecto */
.phero-body > *, .phero-desc p {
  opacity: 0; transform: translateY(16px);
  transition: opacity .9s var(--ease), transform .9s var(--ease);
}
body.page-in .phero-body > * { opacity: 1; transform: translateY(0); }
body.page-in .phero-desc p { opacity: 1; transform: translateY(0); }
body.page-in .phero-eyebrow  { transition-delay: .35s; }
body.page-in .phero-title    { transition-delay: .45s; }
body.page-in .phero-desc p:nth-of-type(1) { transition-delay: .6s; }
body.page-in .phero-desc p:nth-of-type(2) { transition-delay: .72s; }
body.page-in .phero-desc p:nth-of-type(3) { transition-delay: .84s; }
.phero-num { transition-delay: .9s !important; }
body.page-in .phero-num { opacity: 1; }

@media (max-width: 1023px) {
  .phero { grid-template-columns: 1fr; min-height: 0; }
  .phero-media { min-height: 52dvh; }
  .phero-body { padding-top: var(--space-lg); }
  .phero-num { top: var(--space-md); }
}

/* — Franja de datos técnicos (eco del cajetín) — */
.ficha-strip {
  margin: 0 var(--page-pad); max-width: 1440px;
  border: 1px solid var(--line-strong);
  display: grid; grid-template-columns: repeat(5, 1fr); gap: 1px;
  background: var(--line-strong);
}
@media (min-width: 1440px) { .ficha-strip { margin: 0 auto; width: calc(100% - 2 * var(--page-pad)); } }
.ficha-strip .fs-cell { background: var(--bg-primary); padding: 1.1rem 1.2rem; }
.fs-label {
  display: block; font-family: var(--font-mono); font-size: var(--text-micro);
  letter-spacing: .32em; text-transform: uppercase; color: var(--ink-ghost);
  margin-bottom: .4rem;
}
.fs-value { font-family: var(--font-mono); font-size: .8rem; letter-spacing: .05em; color: var(--ink); }
@media (max-width: 767px) {
  .ficha-strip { grid-template-columns: 1fr 1fr; }
  .ficha-strip .fs-cell:last-child { grid-column: span 2; }
}

/* — Galería de ritmo determinista (el agente sólo apila figuras) — */
.pgallery {
  padding: var(--space-xl) var(--page-pad) var(--space-2xl);
  max-width: 1440px; margin: 0 auto;
}
.pgallery-eyebrow {
  font-family: var(--font-mono); font-size: var(--text-micro);
  letter-spacing: .35em; text-transform: uppercase; color: var(--ink-ghost);
  margin-bottom: var(--space-lg);
  display: flex; align-items: center; gap: 1rem;
}
.pgallery-eyebrow::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.g-grid { display: grid; grid-template-columns: repeat(12, 1fr); gap: var(--grid-gap); }
.g-item {
  position: relative; overflow: hidden; background: var(--bg-secondary);
  border: 0; padding: 0; margin: 0;
  opacity: 0; transform: translateY(22px);
  transition: opacity .9s var(--ease), transform .9s var(--ease);
}
.g-item.in-view { opacity: 1; transform: translateY(0); }
.g-item img {
  width: 100%; height: 100%; object-fit: cover; display: block;
  transition: transform .7s var(--ease);
}
.g-item:hover img, .g-item:focus-visible img { transform: scale(1.04); }
.g-item::after {
  /* tick de esquina, marca de registro */
  content: ''; position: absolute; top: 10px; left: 10px; width: 14px; height: 14px;
  border-top: 1px solid rgba(244,241,236,.85); border-left: 1px solid rgba(244,241,236,.85);
  opacity: 0; transition: opacity .4s;
}
.g-item:hover::after { opacity: 1; }
/* Ritmo 8: 7+5 / 5+7 / 4+4+4 / 12 — asignado por posición, no por el agente */
.g-item:nth-of-type(8n+1) { grid-column: span 7; aspect-ratio: 16/10; }
.g-item:nth-of-type(8n+2) { grid-column: span 5; aspect-ratio: 4/5; }
.g-item:nth-of-type(8n+3) { grid-column: span 5; aspect-ratio: 4/5; }
.g-item:nth-of-type(8n+4) { grid-column: span 7; aspect-ratio: 16/10; }
.g-item:nth-of-type(8n+5),
.g-item:nth-of-type(8n+6),
.g-item:nth-of-type(8n+7) { grid-column: span 4; aspect-ratio: 3/4; }
.g-item:nth-of-type(8n+8) { grid-column: span 12; aspect-ratio: 21/9; }
@media (max-width: 1023px) {
  .g-item:nth-of-type(8n+1), .g-item:nth-of-type(8n+4) { grid-column: span 12; }
  .g-item:nth-of-type(8n+2), .g-item:nth-of-type(8n+3) { grid-column: span 6; }
  .g-item:nth-of-type(8n+5), .g-item:nth-of-type(8n+6), .g-item:nth-of-type(8n+7) { grid-column: span 6; }
}
@media (max-width: 639px) {
  .g-grid { grid-template-columns: 1fr; }
  .g-item { grid-column: span 1 !important; aspect-ratio: 4/3 !important; }
}

/* — Lightbox — */
#lightbox {
  position: fixed; inset: 0; z-index: 9000;
  background: rgba(28,26,23,.95);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  display: none; align-items: center; justify-content: center;
}
#lightbox.open { display: flex; }
#lightbox img {
  max-width: 90vw; max-height: 86dvh; object-fit: contain;
  box-shadow: 0 30px 80px rgba(0,0,0,.5);
}
.lb-btn {
  background: none; border: none; color: rgba(244,241,236,.55);
  min-width: 44px; min-height: 44px;
  display: flex; align-items: center; justify-content: center;
  transition: color .3s, transform .3s var(--ease);
  font-family: var(--font-ui);
}
.lb-btn:hover, .lb-btn:focus-visible { color: var(--ink-on-dark); }
.lb-close {
  position: absolute; top: var(--space-sm); right: var(--space-sm);
  font-size: var(--text-caption); letter-spacing: .3em; text-transform: uppercase;
  padding: 0 1rem;
}
.lb-prev, .lb-next { position: absolute; top: 50%; transform: translateY(-50%); font-size: 1.4rem; padding: var(--space-md); }
.lb-prev { left: var(--space-xs); } .lb-next { right: var(--space-xs); }
.lb-prev:hover { transform: translateY(-50%) translateX(-4px); }
.lb-next:hover { transform: translateY(-50%) translateX(4px); }
.lb-counter {
  position: absolute; bottom: var(--space-md); left: 50%; transform: translateX(-50%);
  font-family: var(--font-mono); font-size: var(--text-micro);
  letter-spacing: .3em; color: rgba(244,241,236,.4);
}

/* — Navegación anterior / siguiente — */
.project-nav {
  position: relative; z-index: 10;
  border-top: 1px solid var(--line);
  display: grid; grid-template-columns: 1fr 1fr;
  background: var(--bg-secondary);
}
.pnav-item {
  padding: var(--space-lg) var(--page-pad);
  text-decoration: none; color: var(--ink);
  display: flex; flex-direction: column; gap: .5rem;
  transition: background .4s var(--ease);
  position: relative; overflow: hidden;
}
.pnav-item:first-child { border-right: 1px solid var(--line); }
.pnav-item:hover, .pnav-item:focus-visible { background: var(--bg-elevated); }
.pnav-label {
  font-family: var(--font-mono); font-size: var(--text-micro);
  letter-spacing: .4em; text-transform: uppercase; color: var(--ink-ghost);
}
.pnav-title { font-family: var(--font-display); font-size: var(--text-subhead); font-weight: 300; }
.pnav-item::after {
  content: ''; position: absolute; bottom: 0; left: 0; right: 0; height: 1px;
  background: var(--ink); transform: scaleX(0); transform-origin: left;
  transition: transform .5s var(--ease);
}
.pnav-item:hover::after { transform: scaleX(1); }
.pnav-item.pnav-next { text-align: right; align-items: flex-end; }
.pnav-item.pnav-next::after { transform-origin: right; }
@media (max-width: 639px) {
  .project-nav { grid-template-columns: 1fr; }
  .pnav-item:first-child { border-right: none; border-bottom: 1px solid var(--line); }
}

/* — Nav de regreso en páginas de proyecto — */
/* Chips de vidrio: legibles sobre cualquier render del hero partido */
.nav-project .back-link, .nav-project .wordmark {
  background: var(--bg-glass);
  backdrop-filter: var(--blur-glass); -webkit-backdrop-filter: var(--blur-glass);
  border: 1px solid var(--line);
  padding: .35rem 1rem;
}
/* El menú de escritorio (Proyectos/Archivo/Estudio/Contacto) queda sobre
   la misma foto de hero partido; sin chip se vuelve ilegible cuando cae
   sobre zonas oscuras de la imagen (≥768px, donde es un menú inline). */
@media (min-width: 768px) {
  .nav-project .nav-links {
    background: var(--bg-glass);
    backdrop-filter: var(--blur-glass); -webkit-backdrop-filter: var(--blur-glass);
    border: 1px solid var(--line);
    padding: .35rem 1.2rem;
  }
  .nav-project.scrolled .nav-links {
    background: transparent; border-color: transparent;
    backdrop-filter: none; -webkit-backdrop-filter: none;
  }
}
.nav-project.scrolled .back-link, .nav-project.scrolled .wordmark {
  background: transparent; border-color: transparent;
  backdrop-filter: none; -webkit-backdrop-filter: none;
}
.back-link {
  display: inline-flex; align-items: center; gap: .6rem; min-height: 44px;
  font-size: var(--text-caption); letter-spacing: .28em; text-transform: uppercase;
  color: var(--ink); text-decoration: none;
  transition: gap .3s var(--ease);
}
.back-link:hover, .back-link:focus-visible { gap: 1rem; }
.back-link svg { width: 14px; height: 14px; flex-shrink: 0; }

/* ═══ REDUCED MOTION — la experiencia completa, ya dibujada ════════ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    transition-delay: 0ms !important;
    scroll-behavior: auto !important;
  }
  /* Todo visible y "ya trazado" sin esperar observers ni timeline */
  [data-animate], .manifesto-text, .phero-body > *, .phero-desc p, .g-item { opacity: 1 !important; transform: none !important; }
  .reveal-line > .rl-inner { transform: none !important; }
  .hero [data-fade] { opacity: 1 !important; transform: none !important; }
  .pcard-media img { animation: none !important; }
  .pcard-media::before { display: none !important; }
  .pframe rect, .bp-hover [data-d], .phero-bp [data-d],
  .arc-deco path, .draw-rule [pathLength], .cut-line .cl-anim { stroke-dashoffset: 0 !important; }
  .phero-bp { opacity: .22 !important; }
  .room { clip-path: none !important; }
  .scroll-scale .ss-cursor { animation: none !important; }
  .grain { animation: none; }
  .wipe { display: none !important; }
  /* Las capas animadas del home v2 no existen sin movimiento:
     el manifiesto vuelve a su panel oscuro estático (rama por defecto). */
  #nightLayer, #waves, #konste, #cl { display: none !important; }
  .nav-links li { opacity: 1 !important; transform: none !important; }
  .section-eyebrow::before { transform: scaleX(1) !important; }
}

/* ═══ RESPONSIVE GLOBAL ════════════════════════════════════════════ */
@media (max-width: 767px) {
  .nav-links { gap: 1rem; }
  .nav-links a { font-size: .58rem; letter-spacing: .2em; }
  .hero { padding-bottom: 6.5rem; }
}
@media (max-width: 639px) {
  .socials { flex-direction: column; align-items: stretch; width: 100%; max-width: 340px; }
  .sc { width: 100%; min-width: 0; }
  .sc-icon::before { transform: scale(1); opacity: 1; }
  .sc-icon svg { stroke: #F4F1EC; }
  .sc:active .sc-icon { border-color: var(--ink); transform: rotate(10deg) scale(1.06); }
  .proj-num { font-size: clamp(4.6rem, 18vw, 7rem); }
}

@media print {
  .grain, #c, #trace, #cd, #cr, .wipe, .scroll-scale { display: none !important; }
}

/* ═══ PRELOADER · "la lámina se dibuja" ══════════════════════════════
   Cover visible sólo bajo .loading (la añade el script inline → JS off
   = sin cover). z 9500: sobre .wipe(8000)/#lightbox(9000), bajo cursor. */
#preloader { display: none; }
.loading { overflow: hidden; }
/* Vuelta atrás: la cortina no debe ni parpadear */
.is-return #preloader { display: none !important; }
.loading #preloader {
  display: grid; place-items: center;
  position: fixed; inset: 0; z-index: 9500;
  background: var(--bg-primary);
  transition: transform .9s var(--ease);
  will-change: transform;
}
/* el cursor custom aún no vive durante la carga → restaurar el del SO */
@media (pointer: fine) { .loading, .loading * { cursor: auto !important; } }
/* ocultar el cursor custom (#cd/#cr/#cl, z 9999) mientras la lámina cubre */
.loading #cd, .loading #cr, .loading #cl { display: none !important; }

.pl-sheet { width: min(72vw, 560px); display: flex; flex-direction: column; gap: clamp(1rem, 3vh, 2rem); }

.pl-mark {
  font-family: var(--font-display); font-weight: 300;
  font-size: clamp(1.4rem, 3vw, 2rem); letter-spacing: .12em; color: var(--ink);
}
.pl-mark em { font-style: italic; font-weight: 400; }

.pl-plan { width: 100%; height: auto; }
.pl-plan .pl-grid line { stroke: var(--ink); stroke-width: .5; opacity: .12; }
.pl-plan .pl-draw {
  stroke: var(--ink); stroke-width: 1; fill: none;
  stroke-dasharray: 100;
  stroke-dashoffset: calc(100 - var(--p, 0) * 100);
  transition: stroke-dashoffset .25s linear;
}

.pl-meta {
  display: flex; justify-content: space-between; align-items: baseline;
  font-family: var(--font-mono); font-size: var(--text-caption);
  text-transform: uppercase; letter-spacing: .15em; color: var(--ink-muted);
}
.pl-count { color: var(--ink); font-variant-numeric: tabular-nums; }
.pl-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* reveal: la lámina se levanta */
#preloader.is-done { transform: translateY(-100%); }

/* reduced-motion: sin dibujo ni levantamiento → fundido corto. La clase
   .pl-reduced la pone el script inline; el @media cubre el resto. */
.pl-reduced .pl-plan .pl-draw { transition: none; stroke-dashoffset: 0; }
.pl-reduced.loading #preloader { transition: opacity .4s linear; }   /* compound: ambas clases en <html> */
.pl-reduced #preloader.is-done { transform: none; opacity: 0; }
@media (prefers-reduced-motion: reduce) {
  .pl-plan .pl-draw { transition: none; stroke-dashoffset: 0; }
  .loading #preloader { transition: opacity .4s linear; }
  #preloader.is-done { transform: none; opacity: 0; }
}

/* ═══ ARCHIVO — índice tipográfico ═════════════════════════════════ */
body.archive { background: var(--bg-primary); }
.archive-main { padding: clamp(7rem, 14vh, 10rem) var(--page-pad) clamp(4rem, 8vh, 6rem); }
.archive-head { margin-bottom: clamp(3rem, 7vh, 5rem); }
.archive-note {
  margin-top: 1.2rem; font-family: var(--font-mono); font-size: var(--text-micro);
  letter-spacing: .35em; text-transform: uppercase; color: var(--ink-ghost-aa);
}
.archive-list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--a12); }
.ax-row a {
  display: grid; align-items: baseline;
  grid-template-columns: 4.5rem 1fr auto auto 2rem;
  gap: clamp(.8rem, 2.5vw, 2rem);
  padding: clamp(.9rem, 2vh, 1.3rem) 0;
  border-bottom: 1px solid var(--a12);
  text-decoration: none; color: var(--ink);
  transition: padding-left .35s var(--ease), background .35s var(--ease);
}
.ax-row a:hover, .ax-row a:focus-visible { padding-left: 1rem; background: rgba(28,26,23,.04); }
.ax-year, .ax-type {
  font-family: var(--font-mono); font-size: var(--text-micro);
  letter-spacing: .25em; color: var(--ink-ghost-aa);
}
.ax-name { font-size: clamp(1.1rem, 2.6vw, 1.7rem); font-weight: 300; }
.ax-place { font-size: .85rem; color: var(--ink-muted); }
.ax-arrow { color: var(--ink-ghost); transition: transform .35s var(--ease); }
.ax-row a:hover .ax-arrow { transform: translate(3px, -3px); color: var(--ink); }
.ax-thumb {
  position: fixed; top: 0; left: 0; width: 230px; aspect-ratio: 4/3;
  object-fit: cover; opacity: 0; pointer-events: none; z-index: 50;
  transition: opacity .25s var(--ease);
}
.ax-thumb.on { opacity: 1; }
@media (max-width: 767px) {
  .ax-row a { grid-template-columns: 3.2rem 1fr 1.4rem; }
  .ax-place, .ax-type { display: none; }
  .ax-thumb { display: none; }
}

/* ── Menú móvil durante la noche del manifiesto (fix) ──────────────
   body.night invierte wordmark/links a crema para el chrome sobre el
   nightLayer, pero: (a) el hamburguesa quedaba en tinta oscura sobre
   fondo oscuro (invisible), y (b) con el overlay abierto (fondo claro
   --bg-primary) los enlaces crema eran ilegibles. Estas reglas van al
   final del archivo para ganar por orden de fuente a las de body.night. */
@media (max-width: 767px) {
  body.night .hamburger { background: var(--ink-on-dark); }
  body.night .hamburger::before,
  body.night .hamburger::after { background: var(--ink-on-dark); }

  /* Overlay abierto: siempre tinta sobre fondo claro, noche o no */
  body.nav-open .nav-links a { color: var(--ink); }
  body.nav-open .nav-links a::after { background: var(--ink); }
  body.nav-open .nav .wordmark { color: var(--ink); }
  body.nav-open .hamburger { background: transparent; }
  body.nav-open .hamburger::before,
  body.nav-open .hamburger::after { background: var(--ink); }
}
