/* ==========================================================================
   Karakoram — Cinematic layer styles (index.html, signup.html, login.html)
   Loading screen, custom cursor, sound toggle, hero WebGL canvas.
   Uses the shared design tokens from tokens.css — no new palette here.
   ========================================================================== */

/* ---- Loading screen -------------------------------------------------- */
body.loading { overflow: hidden; }
.loader {
  position: fixed;
  inset: 0;
  background: var(--bg-primary);
  z-index: 10000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-4);
}
.loader-line {
  width: 1px;
  height: 60px;
  background: linear-gradient(to bottom, transparent, var(--accent));
  margin-bottom: var(--space-4);
  animation: loaderLineGrow 1s ease-out forwards;
  transform-origin: bottom;
}
@keyframes loaderLineGrow {
  from { transform: scaleY(0); }
  to { transform: scaleY(1); }
}
.loader-text {
  font-size: var(--text-sm);
  letter-spacing: 0.3em;
  color: var(--accent);
  font-weight: 600;
}
.loader-sub {
  font-size: var(--text-xs);
  color: var(--text-dim);
  letter-spacing: 0.1em;
}
.loader-progress {
  width: 200px;
  height: 1px;
  background: var(--border);
  overflow: hidden;
  margin-top: var(--space-2);
}
.loader-bar {
  height: 100%;
  background: var(--accent);
  width: 0%;
  transition: width 50ms linear;
}

/* ---- Custom cursor (desktop / pointer-fine only) ---------------------- */
body.has-custom-cursor,
body.has-custom-cursor a,
body.has-custom-cursor button,
body.has-custom-cursor input {
  cursor: none;
}
.cursor-dot,
.cursor-ring {
  position: fixed;
  top: 0;
  left: 0;
  pointer-events: none;
  z-index: 9999;
  transition: opacity var(--transition-base);
}
.cursor-dot {
  width: 6px;
  height: 6px;
  background: var(--accent);
  border-radius: 50%;
}
.cursor-ring {
  width: 32px;
  height: 32px;
  border: 1px solid rgba(0, 200, 255, 0.5);
  border-radius: 50%;
  z-index: 9998;
  transition: width var(--transition-base), height var(--transition-base),
    border-color var(--transition-base), background var(--transition-base), opacity var(--transition-base);
}
.cursor-ring.hovering {
  width: 56px;
  height: 56px;
  border-color: var(--accent);
  background: rgba(0, 200, 255, 0.06);
}
.cursor-ring.clicking {
  width: 20px;
  height: 20px;
  background: rgba(0, 200, 255, 0.2);
}
@media (max-width: 768px), (hover: none) {
  .cursor-dot, .cursor-ring { display: none; }
  body.has-custom-cursor,
  body.has-custom-cursor a,
  body.has-custom-cursor button,
  body.has-custom-cursor input {
    cursor: auto;
  }
}

/* ---- Hero WebGL canvas (index.html) ------------------------------------ */
#heroCanvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
}
.hero > .container { position: relative; z-index: 1; }

/* Lenis takes over — avoid double smooth-scroll with the native CSS one. */
html.lenis-active { scroll-behavior: auto; }

@media (prefers-reduced-motion: reduce) {
  .loader-line { animation: none; transform: scaleY(1); }
}

/* ==========================================================================
   SOUND toggle — ambient audio is opt-in and remembered across visits.
   ========================================================================== */
.sound-toggle {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: 6px 10px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  color: var(--text-secondary, #9a9a9a);
  font-family: inherit;
  font-size: var(--text-xs);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  transition: color 160ms ease, border-color 160ms ease, background 160ms ease;
}
.sound-toggle:hover {
  color: var(--text-primary);
  border-color: rgba(0, 200, 255, 0.35);
  background: rgba(0, 200, 255, 0.06);
}
.sound-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sound-toggle .sound-status { color: var(--text-dim); font-variant-numeric: tabular-nums; }
.sound-toggle[aria-pressed="true"] { color: var(--text-primary); border-color: rgba(0, 200, 255, 0.4); }
.sound-toggle[aria-pressed="true"] .sound-status { color: var(--accent); }

/* Four bars: flat when off, equalising when on. */
.sound-bars { display: flex; align-items: flex-end; gap: 2px; height: 12px; }
.sound-bars span {
  width: 2px;
  height: 3px;
  background: currentColor;
  border-radius: 1px;
  opacity: 0.5;
  transition: opacity 160ms ease;
}
.sound-toggle[aria-pressed="true"] .sound-bars span {
  opacity: 1;
  background: var(--accent);
  animation: sound-bar 900ms ease-in-out infinite;
}
.sound-toggle[aria-pressed="true"] .sound-bars span:nth-child(2) { animation-delay: 150ms; }
.sound-toggle[aria-pressed="true"] .sound-bars span:nth-child(3) { animation-delay: 300ms; }
.sound-toggle[aria-pressed="true"] .sound-bars span:nth-child(4) { animation-delay: 450ms; }

@keyframes sound-bar {
  0%, 100% { height: 3px; }
  50%      { height: 12px; }
}

/* Marketing auth pages have no nav bar — pin it opposite the Back link. */
.auth-sound-toggle { position: fixed; top: 24px; right: 24px; z-index: 40; }

@media (max-width: 640px) {
  .sound-toggle .sound-label { display: none; }
  .auth-sound-toggle { top: 16px; right: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  .sound-toggle[aria-pressed="true"] .sound-bars span { animation: none; height: 8px; }
}
