/* ============================================================
   OneLab — onelab.men
   Un momento autorizado: la portada converge desde el ruido.
   Todo lo demás está quieto.
   ============================================================ */

/* ---------- Tipografía ----------
   Display: Bricolage Grotesque (variable, carácter irregular)
   Cuerpo:  Instrument Sans
   Datos:   IBM Plex Mono — solo para medidas y registros reales
------------------------------------------------------------- */

:root {
  /* Color — verificado AA sobre el fondo base */
  --bg:        #0A0C10;
  --bg-2:      #0D1015;
  --surface:   #12151C;
  --surface-2: #171B23;

  --fg:        #EDEFF3;   /* 17.0:1 */
  --fg-mid:    #A6AEBC;   /*  8.8:1 */
  --fg-dim:    #8A93A2;   /*  6.3:1 */

  --line:      #242A35;
  --line-2:    #323A48;

  --accent:    #3DDC84;   /* 11.0:1 */
  --on-accent: #08130C;   /* 10.6:1 sobre el acento */

  /* Tipografía */
  --font-display: 'Bricolage Grotesque', ui-sans-serif, system-ui, sans-serif;
  --font-body: 'IBM Plex Sans', ui-sans-serif, system-ui, -apple-system, sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, 'SFMono-Regular', Menlo, monospace;

  /* Espaciado */
  --s-1: .25rem; --s-2: .5rem;  --s-3: .75rem; --s-4: 1rem;   --s-5: 1.25rem;
  --s-6: 1.5rem; --s-8: 2rem;   --s-10: 2.5rem; --s-12: 3rem; --s-14: 3.5rem;
  --s-16: 4rem;  --s-20: 5rem;  --s-28: 7rem;  --s-36: 9rem;

  /* Forma — radios contenidos; las píldoras son para controles pequeños */
  --r-sm: 6px; --r-md: 10px; --r-lg: 14px; --r-full: 999px;

  /* Elevación — neutra, con desplazamiento y desenfoque reales */
  --e-1: 0 1px 2px rgba(0,0,0,.45);
  --e-2: 0 10px 24px -12px rgba(0,0,0,.7);

  /* Movimiento */
  --ease: cubic-bezier(.16, 1, .3, 1);
  --t-tap:  130ms;
  --t-state: 220ms;
  --t-view:  380ms;

  --maxw: 72rem;
  --measure: 68ch;
}

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

html {
  -webkit-text-size-adjust: 100%;
  scrollbar-color: var(--line-2) var(--bg);
  scrollbar-width: thin;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.6;
  font-synthesis: none;
  -webkit-font-smoothing: antialiased;
  caret-color: var(--accent);
}

/* --- Superficies del navegador: nada se queda con el estilo por defecto --- */

::selection { background: var(--accent); color: var(--on-accent); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb {
  background: var(--line-2);
  border: 2px solid var(--bg);
  border-radius: var(--r-full);
}
::-webkit-scrollbar-thumb:hover { background: #46506180; }

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

a {
  color: inherit;
  text-decoration-color: color-mix(in srgb, currentColor 35%, transparent);
  text-underline-offset: .22em;
  text-decoration-thickness: 1px;
}

img, svg, canvas { display: block; max-width: 100%; }
img { height: auto; }
p { margin: 0; }

h1, h2, h3 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 700;
  line-height: 1.04;
  letter-spacing: -.03em;
  text-wrap: balance;
}

/* ============================================================
   Estructura
   ============================================================ */

.wrap {
  width: 100%;
  max-width: var(--maxw);
  margin-inline: auto;
  padding-inline: var(--s-6);
}

.skip-link {
  position: absolute;
  left: -9999px; top: var(--s-2);
  z-index: 100;
  padding: var(--s-3) var(--s-5);
  border-radius: var(--r-sm);
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 600;
}
.skip-link:focus { left: var(--s-4); }

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

/* ============================================================
   Lienzo de la convergencia
   ============================================================ */

#scene {
  position: fixed;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  pointer-events: none;
}

/* Hasta que el shader arranca, el fondo es el fondo: nada parpadea */
#scene:not(.is-ready) { opacity: 0; }

.page { position: relative; z-index: 1; }

/* ============================================================
   Navegación
   ============================================================ */

.nav {
  position: sticky;
  top: 0;
  z-index: 20;
  border-bottom: 1px solid transparent;
  transition: background-color var(--t-state) var(--ease),
              border-color var(--t-state) var(--ease);
}
/* El desenfoque existe porque el contenido pasa por debajo, no de adorno */
.nav.is-stuck {
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom-color: var(--line);
}

.nav__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-4);
  min-height: 68px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: var(--s-3);
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: -.02em;
  text-decoration: none;
}
.brand__mark { width: 24px; height: 24px; flex: none; }
.brand__tld { color: var(--fg-dim); font-weight: 400; }

.nav__links {
  display: flex;
  align-items: center;
  gap: var(--s-8);
  font-size: .95rem;
}
.nav__links a {
  color: var(--fg-mid);
  text-decoration: none;
  padding-block: var(--s-2);
  transition: color var(--t-state) var(--ease);
}
.nav__links a:hover { color: var(--fg); }

@media (max-width: 760px) { .nav__links { display: none; } }

/* ============================================================
   Portada — el momento autorizado
   ============================================================ */

.hero {
  min-height: 92svh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding-block: var(--s-28) var(--s-20);
}

.hero__title {
  max-width: 17ch;
  font-size: clamp(2.6rem, 6.4vw, 4.9rem);
  letter-spacing: -.032em;
}

/* La parte que resuelve desde el ruido */
.scramble {
  display: inline-block;
  color: var(--accent);
}

.hero__lead {
  margin-top: var(--s-8);
  max-width: 46ch;
  font-size: clamp(1.1rem, 2.2vw, 1.3rem);
  color: var(--fg-mid);
  text-wrap: pretty;
}

.hero__actions {
  margin-top: var(--s-10);
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-3);
}

/* La portada entra una sola vez, y solo ella */
@media (prefers-reduced-motion: no-preference) {
  .hero > * {
    opacity: 0;
    transform: translateY(14px);
    transition: opacity 700ms var(--ease), transform 700ms var(--ease);
  }
  .is-loaded .hero > * { opacity: 1; transform: none; }
  .is-loaded .hero__lead    { transition-delay: 540ms; }
  .is-loaded .hero__actions { transition-delay: 640ms; }
}

/* ============================================================
   Botones
   ============================================================ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  min-height: 48px;
  padding: var(--s-3) var(--s-6);
  border: 1px solid transparent;
  border-radius: var(--r-md);
  font-family: var(--font-body);
  font-size: .98rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: background-color var(--t-state) var(--ease),
              border-color var(--t-state) var(--ease),
              color var(--t-state) var(--ease),
              transform var(--t-tap) var(--ease);
}
.btn .icon { width: 17px; height: 17px; flex: none; }
.btn:active { transform: translateY(1px); }

.btn--primary { background: var(--accent); color: var(--on-accent); }
.btn--primary:hover { background: #55E695; }

.btn--ghost { color: var(--fg); border-color: var(--line-2); }
.btn--ghost:hover { border-color: var(--fg-dim); background: var(--surface); }

/* ============================================================
   Secciones
   ============================================================ */

.section {
  padding-block: var(--s-20);
  border-top: 1px solid var(--line);
}

.section__title {
  font-size: clamp(1.7rem, 4.2vw, 2.6rem);
}
.section__desc {
  margin-top: var(--s-4);
  max-width: var(--measure);
  color: var(--fg-mid);
  text-wrap: pretty;
}

/* ============================================================
   Registro de experimentos — una bitácora, no una rejilla de fichas
   ============================================================ */

.log { margin-top: var(--s-12); }

/* Estado del laboratorio: cifras reales, por eso van en monoespaciada */
.status {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-3) var(--s-8);
  padding-block: var(--s-4);
  border-block: 1px solid var(--line);
  font-family: var(--font-mono);
  font-size: .78rem;
  color: var(--fg-dim);
  font-variant-numeric: tabular-nums;
}
.status b {
  color: var(--fg-mid);
  font-weight: 400;
}

.entry {
  display: grid;
  grid-template-columns: 7rem 1fr auto;
  gap: var(--s-6);
  align-items: baseline;
  padding: var(--s-6) var(--s-4);
  border-bottom: 1px solid var(--line);
  text-decoration: none;
  transition: background-color var(--t-state) var(--ease);
}
a.entry:hover { background: var(--surface); }

.entry__ref {
  font-family: var(--font-mono);
  font-size: .8rem;
  font-variant-numeric: tabular-nums;
  color: var(--fg-dim);
  letter-spacing: 0;
}
.entry__name {
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 600;
  letter-spacing: -.02em;
}
.entry__desc {
  margin-top: var(--s-2);
  max-width: 56ch;
  color: var(--fg-mid);
  font-size: .96rem;
}
.entry__state {
  font-family: var(--font-mono);
  font-size: .78rem;
  color: var(--fg-dim);
  white-space: nowrap;
}

@media (max-width: 720px) {
  .entry { grid-template-columns: 1fr; gap: var(--s-2); }
  .entry__state { order: -1; }
}

/* Estado vacío: honesto, no tres fichas inventadas */
.empty {
  padding: var(--s-16) var(--s-4);
  text-align: left;
}
.empty__title {
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 600;
  letter-spacing: -.02em;
}
.empty__desc {
  margin-top: var(--s-3);
  max-width: 52ch;
  color: var(--fg-mid);
}
.empty__action { margin-top: var(--s-8); }

/* ============================================================
   Manifiesto — prosa, sin numeración decorativa
   ============================================================ */

.principles {
  margin-top: var(--s-12);
  display: grid;
  gap: var(--s-12);
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 19rem), 1fr));
}
.principle__t {
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: -.02em;
}
.principle__d {
  margin-top: var(--s-3);
  color: var(--fg-mid);
  max-width: 46ch;
  text-wrap: pretty;
}

/* ============================================================
   Contacto
   ============================================================ */

.contact { padding-block: var(--s-20); border-top: 1px solid var(--line); }
.contact__title { font-size: clamp(1.7rem, 4.2vw, 2.6rem); }
.contact__desc {
  margin-top: var(--s-4);
  max-width: 46ch;
  color: var(--fg-mid);
}
.contact__mail {
  margin-top: var(--s-8);
  display: inline-block;
  font-family: var(--font-display);
  font-size: clamp(1.3rem, 4vw, 2rem);
  font-weight: 600;
  letter-spacing: -.02em;
  color: var(--accent);
  text-decoration-color: color-mix(in srgb, var(--accent) 40%, transparent);
  text-underline-offset: .18em;
  transition: text-decoration-color var(--t-state) var(--ease);
}
.contact__mail:hover { text-decoration-color: var(--accent); }

/* ============================================================
   Pie
   ============================================================ */

.footer {
  border-top: 1px solid var(--line);
  padding-block: var(--s-10);
}
.footer__inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-4);
  color: var(--fg-dim);
  font-size: .9rem;
}
.footer__links { display: flex; gap: var(--s-8); flex-wrap: wrap; }
.footer__links a {
  text-decoration: none;
  transition: color var(--t-state) var(--ease);
}
.footer__links a:hover { color: var(--fg); }

/* ============================================================
   Movimiento reducido: la convergencia no ocurre, el resultado sí
   ============================================================ */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
  #scene { display: none; }
  .hero > * { opacity: 1; transform: none; }
}

/* ============================================================
   EFECTOS
   Repuestos a petición: capas ambientales, cursor propio,
   inclinación 3D, magnetismo, parallax, marquee y revelados.
   Todo queda desactivado bajo prefers-reduced-motion.
   ============================================================ */

/* ---------- Blobs ambientales ---------- */

.ambient {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}
.ambient__blob {
  position: absolute;
  width: 44rem;
  aspect-ratio: 1;
  border-radius: 50%;
  filter: blur(96px);
  will-change: transform;
}
.ambient__blob--a { background: #3DDC84; opacity: .10; top: -20rem; left: -12rem; }
.ambient__blob--b { background: #5BE8D0; opacity: .07; top: 34%; right: -19rem; }
.ambient__blob--c { background: #1B7A48; opacity: .10; bottom: -22rem; left: 26%; }

@media (prefers-reduced-motion: no-preference) {
  .ambient__blob--a { animation: drift-a 28s ease-in-out infinite alternate; }
  .ambient__blob--b { animation: drift-b 34s ease-in-out infinite alternate; }
  .ambient__blob--c { animation: drift-c 40s ease-in-out infinite alternate; }
}
@keyframes drift-a { to { transform: translate3d(9rem, 5rem, 0) scale(1.14); } }
@keyframes drift-b { to { transform: translate3d(-7rem, -6rem, 0) scale(.88); } }
@keyframes drift-c { to { transform: translate3d(5rem, -7rem, 0) scale(1.1); } }

/* ---------- Grano ---------- */

.grain {
  position: fixed;
  inset: -50%;
  z-index: 3;
  pointer-events: none;
  opacity: .03;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23n)'/%3E%3C/svg%3E");
}
@media (prefers-reduced-motion: no-preference) {
  .grain { animation: grain 700ms steps(4) infinite; }
}
@keyframes grain {
  0%   { transform: translate(0, 0); }
  25%  { transform: translate(-2%, 1%); }
  50%  { transform: translate(1%, -2%); }
  75%  { transform: translate(-1%, -1%); }
  100% { transform: translate(2%, 2%); }
}

/* ---------- Barra de progreso ---------- */

.progress {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 2px;
  z-index: 30;
  transform: scaleX(0);
  transform-origin: 0 50%;
  background: linear-gradient(90deg, var(--accent), #5BE8D0);
  will-change: transform;
  pointer-events: none;
}

/* ---------- Cursor propio ---------- */

.cursor, .cursor-dot {
  position: fixed;
  top: 0; left: 0;
  z-index: 60;
  border-radius: 50%;
  pointer-events: none;
  opacity: 0;
  margin: 0;
  will-change: transform;
  transition: opacity var(--t-state) var(--ease);
}
.cursor {
  width: 36px; height: 36px;
  margin: -18px 0 0 -18px;
  border: 1px solid var(--line-2);
  transition: opacity var(--t-state) var(--ease),
              width var(--t-state) var(--ease),
              height var(--t-state) var(--ease),
              margin var(--t-state) var(--ease),
              background-color var(--t-state) var(--ease),
              border-color var(--t-state) var(--ease);
}
.cursor-dot {
  width: 5px; height: 5px;
  margin: -2.5px 0 0 -2.5px;
  background: var(--accent);
}
body.has-cursor .cursor,
body.has-cursor .cursor-dot { opacity: 1; }

body.cursor-hot .cursor {
  width: 64px; height: 64px;
  margin: -32px 0 0 -32px;
  background: rgba(61, 220, 132, .12);
  border-color: rgba(61, 220, 132, .45);
}
body.cursor-hot .cursor-dot { opacity: 0; }
body.cursor-down .cursor { width: 28px; height: 28px; margin: -14px 0 0 -14px; }

@media (hover: none), (pointer: coarse) {
  .cursor, .cursor-dot { display: none; }
}

/* ---------- Revelado escalonado ---------- */

@media (prefers-reduced-motion: no-preference) {
  .reveal {
    opacity: 0;
    transform: translateY(24px);
    transition: opacity 620ms var(--ease), transform 620ms var(--ease);
  }
  .reveal.is-visible { opacity: 1; transform: none; }
}

/* ---------- Parallax ---------- */

[data-parallax] { will-change: transform; }

/* ---------- Punto vivo ---------- */

.eyebrow {
  display: inline-flex;
  align-self: flex-start;
  align-items: center;
  gap: var(--s-2);
  padding: var(--s-1) var(--s-3);
  border: 1px solid rgba(61, 220, 132, .3);
  border-radius: var(--r-full);
  background: rgba(61, 220, 132, .07);
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: .75rem;
  letter-spacing: .09em;
  text-transform: uppercase;
}
.dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 12px var(--accent);
}
@media (prefers-reduced-motion: no-preference) {
  .dot { animation: pulse 2.4s var(--ease) infinite; }
}
@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%      { opacity: .4;  transform: scale(.68); }
}

/* ---------- Titular con gradiente animado ---------- */

.scramble {
  background: linear-gradient(100deg, var(--accent) 0%, #5BE8D0 48%, var(--accent) 100%);
  background-size: 220% auto;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
@media (prefers-reduced-motion: no-preference) {
  .scramble { animation: shimmer 6s linear infinite; }
}
@keyframes shimmer { to { background-position: 220% center; } }

/* ---------- Indicador de scroll ---------- */

.hero__scroll {
  margin-top: var(--s-16);
  display: inline-flex;
  align-self: flex-start;
  flex-direction: column;
  gap: var(--s-2);
  font-family: var(--font-mono);
  font-size: .7rem;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--fg-dim);
}
.hero__scroll .rail {
  width: 1px; height: 44px;
  background: linear-gradient(var(--line-2), transparent);
  position: relative;
  overflow: hidden;
}
@media (prefers-reduced-motion: no-preference) {
  .hero__scroll .rail::after {
    content: "";
    position: absolute;
    inset-inline: 0;
    height: 14px;
    background: var(--accent);
    animation: rail 2.2s var(--ease) infinite;
  }
}
@keyframes rail {
  0%   { transform: translateY(-16px); opacity: 0; }
  40%  { opacity: 1; }
  100% { transform: translateY(44px); opacity: 0; }
}

/* ---------- Marquee ---------- */

.marquee {
  display: flex;
  overflow: hidden;
  padding-block: var(--s-5);
  border-block: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 60%, transparent);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  mask-image: linear-gradient(90deg, transparent, #000 12%, #000 88%, transparent);
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 12%, #000 88%, transparent);
  user-select: none;
}
.marquee__track {
  display: flex;
  flex: none;
  gap: var(--s-10);
  padding-right: var(--s-10);
  font-family: var(--font-mono);
  font-size: .82rem;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--fg-dim);
  white-space: nowrap;
}
.marquee__track span { display: inline-flex; align-items: center; gap: var(--s-3); }
.marquee__track span::before {
  content: "";
  width: 4px; height: 4px;
  border-radius: 50%;
  background: var(--accent);
  opacity: .6;
}
@media (prefers-reduced-motion: no-preference) {
  .marquee__track { animation: marquee 40s linear infinite; }
  .marquee:hover .marquee__track { animation-play-state: paused; }
}
@keyframes marquee { to { transform: translateX(-100%); } }

/* ---------- Tarjetas con inclinación 3D ---------- */

.cards {
  margin-top: var(--s-12);
  display: grid;
  gap: var(--s-5);
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 18rem), 1fr));
  perspective: 1400px;
}

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
  padding: var(--s-8) var(--s-6);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: linear-gradient(180deg, rgba(255,255,255,.028), rgba(255,255,255,.008));
  box-shadow: var(--e-2);
  overflow: hidden;
  transform-style: preserve-3d;
  will-change: transform;
  transition: border-color var(--t-state) var(--ease),
              box-shadow var(--t-state) var(--ease),
              transform 420ms var(--ease);
}
/* Luz que sigue al cursor */
.card::before {
  content: "";
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  background: radial-gradient(16rem circle at var(--mx, 50%) var(--my, 0%),
                              rgba(61, 220, 132, .15), transparent 62%);
  opacity: 0;
  transition: opacity var(--t-state) var(--ease);
  pointer-events: none;
}
.card:hover::before { opacity: 1; }
.card:hover {
  border-color: rgba(61, 220, 132, .34);
  box-shadow: var(--e-2), 0 0 50px -26px rgba(61, 220, 132, .5);
}
.card > * { transform: translateZ(26px); }

.card__icon {
  width: 44px; height: 44px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(61, 220, 132, .22);
  border-radius: var(--r-md);
  background: rgba(61, 220, 132, .08);
  color: var(--accent);
  transition: transform var(--t-state) var(--ease);
}
.card__icon svg { width: 21px; height: 21px; }
.card:hover .card__icon { transform: translateZ(38px) scale(1.06); }

.card__title { font-family: var(--font-display); font-size: 1.15rem; font-weight: 600; letter-spacing: -.02em; }
.card__desc { color: var(--fg-mid); font-size: .94rem; }

/* ---------- Magnetismo ---------- */

[data-magnetic] { will-change: transform; }
@media (prefers-reduced-motion: no-preference) {
  [data-magnetic] { transition: transform 420ms var(--ease); }
}

/* ---------- Apagado total ---------- */

@media (prefers-reduced-motion: reduce) {
  .ambient, .grain, .progress, .cursor, .cursor-dot, .hero__scroll .rail::after { display: none; }
  .reveal { opacity: 1; transform: none; }
  .marquee__track { animation: none; }
  .scramble {
    background: none;
    -webkit-background-clip: border-box;
    background-clip: border-box;
    color: var(--accent);
  }
  .card, [data-magnetic], [data-parallax] { transform: none !important; }
}
