/* ==========================================================================
   LAYOUT — canvas, preloader, header, navigation HUD, cursor, toast, footer
   ========================================================================== */

/* WebGL canvas: fixed behind content, sized to the large viewport so mobile
   toolbars showing/hiding never trigger a resize. */
.webgl {
  position: fixed;
  top: 0; left: 0;
  width: 100%;
  height: 100vh;
  height: 100lvh;
  z-index: 0;
  display: block;
  pointer-events: none;
}
main, .site-footer { position: relative; z-index: 1; overflow-x: clip; }

.no-webgl body {
  background:
    radial-gradient(60vw 50vw at 80% 20%, rgba(143, 61, 255, 0.18), transparent 70%),
    radial-gradient(50vw 40vw at 10% 70%, rgba(68, 96, 255, 0.16), transparent 70%),
    radial-gradient(40vw 40vw at 90% 90%, rgba(255, 42, 85, 0.12), transparent 70%),
    var(--ink-0);
  background-attachment: fixed;
}
.no-webgl .webgl, .no-webgl .hero__hint { display: none; }

/* Preloader -------------------------------------------------------------- */
.preloader {
  position: fixed; inset: 0; z-index: 500;
  display: grid; place-items: center;
  background: radial-gradient(60% 60% at 50% 45%, #0b0e22 0%, var(--ink-0) 70%);
  clip-path: inset(0 0 0 0);
  transition: clip-path 1.1s var(--ease-in-out), visibility 0s 1.1s;
  animation: preloader-failsafe 0.6s 7s forwards;
}
.preloader.is-done { clip-path: inset(0 0 100% 0); visibility: hidden; }
.preloader.is-done .preloader__core { opacity: 0; transform: translateY(-30px) scale(0.96); }
@keyframes preloader-failsafe { to { opacity: 0; visibility: hidden; } }

.preloader__core {
  display: grid; justify-items: center; gap: 0.9rem;
  transition: opacity 0.6s var(--ease-out), transform 0.8s var(--ease-out);
}
.preloader__mark {
  width: 92px; height: 92px;
  fill: url(#grad-brand);
  fill-opacity: 0;
  stroke: url(#grad-brand);
  stroke-width: 22;
  stroke-dasharray: 14000;
  stroke-dashoffset: 14000;
  animation: mark-draw 1.6s var(--ease-in-out) forwards, mark-fill 0.7s 1.1s var(--ease-out) forwards;
  filter: drop-shadow(0 0 24px rgba(143, 61, 255, 0.45));
}
@keyframes mark-draw { to { stroke-dashoffset: 0; } }
@keyframes mark-fill { to { fill-opacity: 1; } }

.preloader__brand {
  font: 500 0.72rem/1 var(--font-mono);
  letter-spacing: 0.42em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-top: 0.6rem;
}
.preloader__count {
  font: 300 clamp(3rem, 8vw, 5.5rem)/1 var(--font-display);
  letter-spacing: -0.04em;
  color: var(--text-hi);
  font-variant-numeric: tabular-nums;
}
.preloader__count small { font-size: 0.35em; color: var(--text-muted); margin-left: 0.2em; }
.preloader__status {
  min-height: 1.4em;
  font: 400 0.78rem/1.4 var(--font-mono);
  color: var(--text-dim);
  letter-spacing: 0.04em;
}
.preloader__bar {
  position: absolute; left: 0; right: 0; bottom: 0;
  height: 2px; background: rgba(255, 255, 255, 0.05);
}
.preloader__bar span {
  display: block; height: 100%;
  background: var(--grad);
  transform-origin: left;
  transform: scaleX(var(--p, 0));
  transition: transform 0.4s var(--ease-out);
}

/* Scroll progress -------------------------------------------------------- */
.scroll-progress {
  position: fixed; top: 0; left: 0; right: 0; height: 2px; z-index: 60;
  pointer-events: none;
}
.scroll-progress span {
  display: block; height: 100%;
  background: var(--grad);
  transform-origin: left;
  transform: scaleX(var(--progress, 0));
  box-shadow: 0 0 12px rgba(143, 61, 255, 0.8);
}

/* Header ----------------------------------------------------------------- */
.site-header {
  position: fixed; top: 0; left: 0; right: 0; z-index: 50;
  height: var(--header-h);
  transition: transform 0.6s var(--ease-out), background-color 0.4s, border-color 0.4s, -webkit-backdrop-filter 0.4s, backdrop-filter 0.4s;
  border-bottom: 1px solid transparent;
}
.site-header.is-scrolled {
  background: rgba(3, 4, 11, 0.55);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
  backdrop-filter: blur(16px) saturate(140%);
  border-bottom-color: var(--line);
}
.site-header.is-hidden { transform: translateY(-100%); }
/* Keyboard focus inside the header always brings it back on screen. */
.site-header:focus-within { transform: none; }
.js .site-header { opacity: 0; }
.is-loaded .site-header { opacity: 1; transition: opacity 1s 0.4s var(--ease-out), transform 0.6s var(--ease-out), background-color 0.4s; }

.site-header__inner {
  height: 100%;
  display: flex; align-items: center; justify-content: space-between; gap: 2rem;
}
.brand img { height: 38px; width: auto; }

.nav__list { display: flex; gap: 2.2rem; }
.nav__link {
  position: relative;
  font: 400 0.92rem/1 var(--font-display);
  color: var(--text-muted);
  transition: color 0.3s;
  padding: 0.5rem 0;
}
.nav__link::after {
  content: '';
  position: absolute; left: 0; right: 0; bottom: 0; height: 1px;
  background: var(--grad);
  transform: scaleX(0); transform-origin: right;
  transition: transform 0.5s var(--ease-out);
}
.nav__link:hover, .nav__link.is-active { color: var(--text-hi); }
.nav__link:hover::after, .nav__link.is-active::after { transform: scaleX(1); transform-origin: left; }

.site-header__actions { display: flex; align-items: center; gap: 0.75rem; }

.menu-toggle {
  display: none;
  width: 44px; height: 44px;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  position: relative;
}
.menu-toggle__bar {
  position: absolute; left: 13px; right: 13px; height: 1.5px;
  background: var(--text-hi);
  transition: transform 0.4s var(--ease-out), top 0.4s var(--ease-out);
}
.menu-toggle__bar:nth-child(1) { top: 17px; }
.menu-toggle__bar:nth-child(2) { top: 25px; }
.menu-toggle[aria-expanded='true'] .menu-toggle__bar:nth-child(1) { top: 21px; transform: rotate(45deg); }
.menu-toggle[aria-expanded='true'] .menu-toggle__bar:nth-child(2) { top: 21px; transform: rotate(-45deg); }

.mobile-menu {
  position: fixed; inset: 0; z-index: 45;
  background: rgba(3, 4, 11, 0.94);
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
  display: grid; align-items: center;
  padding: calc(var(--header-h) + 1rem) var(--gutter) 2rem;
}
.mobile-menu[hidden] { display: none; }
.mobile-menu__inner { display: grid; gap: 0.4rem; }
.mobile-menu__link {
  display: flex; align-items: baseline; gap: 1rem;
  font: 500 clamp(2rem, 9vw, 3rem)/1.25 var(--font-display);
  letter-spacing: -0.03em;
  color: var(--text-hi);
  padding: 0.35rem 0;
  border-bottom: 1px solid var(--line);
}
.mobile-menu__link span { font: 500 0.75rem/1 var(--font-mono); color: var(--text-dim); letter-spacing: 0.1em; }
.mobile-menu__meta { margin-top: 1.5rem; font: 400 0.8rem/1.6 var(--font-mono); color: var(--text-muted); }

/* Scene navigation HUD --------------------------------------------------- */
.scene-dots {
  position: fixed; right: 22px; top: 50%; z-index: 40;
  transform: translateY(-50%);
  display: grid; gap: 4px;
  opacity: 0; transition: opacity 1s var(--ease-out);
}
.is-loaded .scene-dots { opacity: 1; }
.scene-dots__item {
  position: relative;
  display: flex; justify-content: flex-end; align-items: center;
  width: 36px; height: 16px;
}
.scene-dots__item::before {
  content: '';
  width: 10px; height: 2px; border-radius: 2px;
  background: rgba(200, 205, 255, 0.28);
  transition: width 0.5s var(--ease-out), background-color 0.3s;
}
.scene-dots__item:hover::before { background: rgba(200, 205, 255, 0.7); width: 16px; }
.scene-dots__item.is-active::before { width: 28px; background: var(--grad); }
.scene-dots__label {
  position: absolute; right: 44px; top: 50%;
  transform: translate(8px, -50%);
  white-space: nowrap;
  font: 500 0.7rem/1 var(--font-mono);
  letter-spacing: 0.08em;
  color: var(--text-hi);
  padding: 0.45rem 0.7rem;
  border-radius: 999px;
  background: var(--glass-strong);
  border: 1px solid var(--line);
  opacity: 0; pointer-events: none;
  transition: opacity 0.3s, transform 0.4s var(--ease-out);
}
.scene-dots__item:hover .scene-dots__label,
.scene-dots__item:focus-visible .scene-dots__label { opacity: 1; transform: translate(0, -50%); }

.scene-hud {
  position: fixed; left: var(--gutter); bottom: 26px; z-index: 40;
  display: flex; align-items: center; gap: 0.8rem;
  font: 500 0.7rem/1 var(--font-mono);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
  pointer-events: none;
  opacity: 0; transition: opacity 0.8s var(--ease-out);
}
.scene-hud.is-visible { opacity: 1; }
.scene-hud__index { color: var(--text-hi); font-variant-numeric: tabular-nums; }
.scene-hud__line { width: 36px; height: 1px; background: var(--grad); }

/* Custom cursor (fine pointers only) ------------------------------------ */
.cursor { position: fixed; top: 0; left: 0; z-index: 600; pointer-events: none; display: none; }
.has-cursor .cursor { display: block; }
.cursor__dot, .cursor__ring {
  position: fixed; top: 0; left: 0;
  border-radius: 50%;
  transform: translate3d(var(--x, -100px), var(--y, -100px), 0) translate(-50%, -50%);
}
.cursor__dot { width: 6px; height: 6px; background: #fff; box-shadow: 0 0 12px rgba(185, 140, 255, 0.9); }
.cursor__ring {
  width: 38px; height: 38px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  transition: width 0.4s var(--ease-out), height 0.4s var(--ease-out), background-color 0.3s, border-color 0.3s, opacity 0.3s;
}
.cursor.is-hover .cursor__ring { width: 64px; height: 64px; background: rgba(155, 92, 255, 0.12); border-color: rgba(185, 140, 255, 0.6); }
.cursor.is-down .cursor__ring { width: 28px; height: 28px; }
.cursor.is-text .cursor__ring, .cursor.is-hidden { opacity: 0; }

/* Toast ------------------------------------------------------------------ */
.toast {
  position: fixed; left: 50%; bottom: 28px; z-index: 450;
  display: flex; align-items: center; gap: 0.75rem;
  max-width: min(560px, calc(100vw - 2rem));
  padding: 0.95rem 1.3rem;
  border-radius: 18px;
  background: var(--glass-strong);
  border: 1px solid var(--line-strong);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
  box-shadow: 0 24px 60px -20px rgba(0, 0, 0, 0.8);
  color: var(--text-hi);
  font-size: 0.92rem;
  transform: translate(-50%, 160%);
  transition: transform 0.6s var(--ease-out);
}
.toast.is-visible { transform: translate(-50%, 0); }
.toast .icon { color: var(--mint); width: 1.4em; height: 1.4em; }
.toast.is-error .icon { color: var(--crimson); }

/* Footer ----------------------------------------------------------------- */
.site-footer {
  padding: clamp(4rem, 8vw, 7rem) 0 2rem;
  border-top: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(3, 4, 11, 0.84), rgba(3, 4, 11, 0.97));
  overflow: hidden;
}
.site-footer__grid {
  display: grid;
  grid-template-columns: 1.5fr 1fr 1fr 1fr;
  gap: 2.5rem;
}
.site-footer__brand img { height: 42px; width: auto; }
.site-footer__brand p { margin-top: 1.25rem; max-width: 26rem; color: var(--text-muted); font-size: 0.94rem; }
.site-footer__col h4 {
  font: 500 0.72rem/1 var(--font-mono);
  letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 1.2rem;
}
.site-footer__col ul { display: grid; gap: 0.7rem; font-size: 0.94rem; color: var(--text-muted); }
.site-footer__col a { transition: color 0.3s; }
.site-footer__col a:hover { color: var(--text-hi); }
.site-footer__wordmark {
  margin: clamp(3rem, 6vw, 5rem) 0 1.5rem;
  font: 700 clamp(4.5rem, 21vw, 19rem)/0.8 var(--font-display);
  letter-spacing: -0.06em;
  text-align: center;
  background: linear-gradient(180deg, rgba(185, 140, 255, 0.28), rgba(185, 140, 255, 0) 85%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  user-select: none;
}
.site-footer__bottom {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 1rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--line);
  font-size: 0.85rem; color: var(--text-dim);
}
.site-footer__tagline { font-family: var(--font-mono); font-size: 0.72rem; letter-spacing: 0.08em; }
.to-top { display: inline-flex; align-items: center; gap: 0.5rem; color: var(--text-muted); transition: color 0.3s; }
.to-top:hover { color: var(--text-hi); }

/* Responsive ------------------------------------------------------------- */
@media (max-width: 1100px) {
  .scene-dots { display: none; }
}
@media (max-width: 900px) {
  :root { --header-h: 66px; }
  .nav { display: none; }
  .menu-toggle { display: block; }
  .site-header__actions .btn { display: none; }
  .brand img { height: 32px; }
  .scene-hud { display: none; }
  .site-footer__grid { grid-template-columns: 1fr 1fr; }
  .site-footer__brand { grid-column: 1 / -1; }
}
@media (max-width: 520px) {
  .site-footer__grid { grid-template-columns: 1fr; }
  .site-footer__bottom { flex-direction: column; align-items: flex-start; }
}

/* Hide the native pointer only once our cursor is tracking a mouse. */
.has-cursor body, .has-cursor a, .has-cursor button, .has-cursor label { cursor: none; }
.has-cursor input, .has-cursor textarea { cursor: text; }

/* Once the bundle runs it drives the preloader itself (see src/main.js). */
.preloader.is-js { animation: none; }
.site-footer__bottom p a { color: var(--text-muted); text-decoration: underline; text-decoration-color: rgba(143, 148, 186, 0.4); text-underline-offset: 3px; transition: color 0.3s; }
.site-footer__bottom p a:hover { color: var(--text-hi); }
