/* ============================================================
   AI RESYNAPSE — Landing intro (dark + red, scroll-driven)
   Particle-R canvas scrubs on scroll; text beats fade in/out.
   Ends with an "Enter" button → index.html (+ auto-redirect).
   ============================================================ */

:root {
  --black: #050505;
  --ink-on-dark: #f4f2ee;
  --dim: #9a9aa2;
  --red: #e4121f;
  --red-glow: rgba(228,18,31,0.55);
  --font: 'Inter', system-ui, sans-serif;
  --font-tight: 'Inter Tight', 'Inter', sans-serif;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --pad: clamp(1.4rem, 6vw, 6rem);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body {
  background: var(--black);
  color: var(--ink-on-dark);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
::selection { background: var(--red); color: #fff; }
a { color: inherit; text-decoration: none; }

/* ---------- Loader ---------- */
#l-loader {
  position: fixed; inset: 0; z-index: 9999; background: var(--black);
  display: grid; place-items: center; transition: opacity 0.6s var(--ease), visibility 0.6s;
}
#l-loader.done { opacity: 0; visibility: hidden; }
.l-loader-inner { width: min(340px, 76vw); }
.l-loader-brand {
  font-family: var(--font-tight); font-weight: 700; letter-spacing: 0.35em;
  font-size: 1rem; color: var(--ink-on-dark); margin-bottom: 1.1rem; text-align: center;
}
.l-loader-track { height: 2px; background: rgba(255,255,255,0.12); overflow: hidden; }
#l-loader-bar { height: 100%; width: 0; background: linear-gradient(90deg, #7a0a11, var(--red)); box-shadow: 0 0 12px var(--red-glow); transition: width 0.2s linear; }
/* rotating value lines — quiet, one at a time, never competing with the intro */
.l-loader-lines {
  margin-top: 1.1rem; min-height: 1.4em; text-align: center;
  font-family: var(--font); font-size: 0.88rem; line-height: 1.4;
  color: var(--dim); opacity: 0;
}
.l-loader-lines.is-in { animation: lineIn 2.6s var(--ease) both; }
@keyframes lineIn {
  0%   { opacity: 0; transform: translateY(4px); }
  14%  { opacity: 1; transform: translateY(0); }
  84%  { opacity: 1; transform: translateY(0); }
  100% { opacity: 0; transform: translateY(-4px); }
}
@media (prefers-reduced-motion: reduce) {
  .l-loader-lines.is-in { animation: none; opacity: 1; }
}

/* ---------- Top controls ---------- */
.l-top { position: fixed; top: 1.2rem; right: var(--pad); left: var(--pad); z-index: 300; display: flex; justify-content: space-between; align-items: center; }
.l-skip { font-family: var(--font); font-size: 0.8rem; letter-spacing: 0.04em; color: var(--dim); transition: color 0.2s; }
.l-skip:hover { color: var(--ink-on-dark); }
.l-lang { background: none; border: 1px solid rgba(255,255,255,0.16); border-radius: 999px; padding: 0.35rem 0.7rem; cursor: pointer; font-size: 0.78rem; color: var(--dim); display: flex; gap: 0.3rem; }
.l-lang .opt.is-active { color: var(--ink-on-dark); }
.l-lang .sep { opacity: 0.5; }

/* ---------- Canvas ---------- */
.l-canvas-wrap { position: fixed; inset: 0; z-index: 1; }
#l-canvas { width: 100%; height: 100%; display: block; }
.l-vignette {
  position: fixed; inset: 0; z-index: 2; pointer-events: none;
  background: radial-gradient(ellipse 90% 80% at 50% 50%, transparent 40%, rgba(5,5,5,0.75) 100%);
}

/* ---------- Progress rail ---------- */
.l-rail { position: fixed; left: var(--pad); top: 50%; transform: translateY(-50%); width: 2px; height: 34vh; background: rgba(255,255,255,0.1); z-index: 3; border-radius: 2px; }
.l-rail-fill { width: 100%; height: 0%; background: linear-gradient(180deg, var(--red), #ff5964); box-shadow: 0 0 10px var(--red-glow); border-radius: 2px; }

/* ---------- Scroll story ---------- */
#l-scroll { position: relative; z-index: 4; height: 620vh; }
.l-beat {
  position: fixed; inset: 0; z-index: 4;
  display: flex; align-items: center; padding: 0 var(--pad);
  opacity: 0; visibility: hidden; pointer-events: none;
  will-change: opacity, transform;
}
/* the final beat needs to receive clicks (the Enter button) — sit it above the
   canvas and re-enable pointer events on its interactive elements. */
.l-beat[data-final="true"] { z-index: 6; }
.l-beat[data-final="true"] .l-beat-inner,
.l-beat .l-enter { pointer-events: auto; }
.l-beat-inner { max-width: 900px; position: relative; }
.l-beat-inner.center { margin: 0 auto; text-align: center; }
.l-beat-inner.left { margin-right: auto; max-width: 620px; }
.l-beat-inner.right { margin-left: auto; max-width: 620px; text-align: right; }
/* readability scrim directly behind each beat's text */
.l-beat-inner::before {
  content: ""; position: absolute; inset: -8% -12%; z-index: -1; pointer-events: none;
  background: radial-gradient(ellipse 62% 62% at 50% 50%, rgba(5,5,5,0.82), rgba(5,5,5,0) 78%);
}

.l-eyebrow { display: block; font-weight: 600; font-size: 0.8rem; letter-spacing: 0.16em; text-transform: uppercase; color: var(--red); margin-bottom: 1.8rem; }
.l-h1 {
  font-family: var(--font-tight); font-weight: 700;
  font-size: clamp(3rem, 10vw, 8.5rem); line-height: 0.98; letter-spacing: -0.03em;
  color: var(--ink-on-dark); text-shadow: 0 2px 40px rgba(0,0,0,0.6);
}
.l-h2 {
  font-family: var(--font-tight); font-weight: 600;
  font-size: clamp(1.8rem, 4.6vw, 3.6rem); line-height: 1.06; letter-spacing: -0.02em;
  color: var(--ink-on-dark); text-shadow: 0 2px 30px rgba(0,0,0,0.7);
}
.l-h2.big { font-size: clamp(2.2rem, 6vw, 5rem); }
.l-p { margin-top: 1.1rem; font-size: clamp(1.05rem, 1.6vw, 1.35rem); color: var(--dim); line-height: 1.5; }
.red { color: var(--red); }

/* final beat — stronger scrim so text reads over the bright R */
.l-beat-inner.final::before { background: radial-gradient(ellipse 74% 74% at 50% 55%, rgba(5,5,5,0.92) 34%, rgba(5,5,5,0) 84%); }
.l-beat-inner.final { padding-top: 6vh; }
.l-beat-inner.final .l-eyebrow { color: #ff5964; }
.l-mark { width: 64px; height: 64px; margin: 0 auto 1.6rem; display: block; filter: drop-shadow(0 0 20px var(--red-glow)); }
.l-enter {
  display: inline-block; margin-top: 2.2rem;
  font-family: var(--font); font-weight: 600; font-size: 1.05rem;
  padding: 1rem 2.4rem; border-radius: 999px; background: var(--red); color: #fff;
  box-shadow: 0 12px 40px -8px var(--red-glow); transition: transform 0.25s var(--ease), background 0.25s;
}
.l-enter:hover { background: #ff2a37; transform: translateY(-2px); }
.l-auto { margin-top: 1.2rem; font-size: 0.82rem; color: var(--dim); letter-spacing: 0.02em; }

/* scroll hint on first beat */
.l-hint { position: fixed; bottom: 1.6rem; left: 50%; transform: translateX(-50%); z-index: 5; font-size: 0.7rem; letter-spacing: 0.2em; text-transform: uppercase; color: var(--dim); display: flex; flex-direction: column; align-items: center; gap: 0.4rem; }
.l-hint .a { animation: bob 1.8s var(--ease) infinite; }
@keyframes bob { 0%,100%{transform:translateY(0);opacity:.5} 50%{transform:translateY(5px);opacity:1} }

/* ---------- Responsive ---------- */
@media (max-width: 768px) {
  .l-rail { display: none; }
  .l-beat-inner.left, .l-beat-inner.right { text-align: center; margin: 0 auto; }
  #l-scroll { height: 560vh; }
}

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