/* Tokens lifted from javiercarnicer.com/assets/styles.css so the two sites read
   as one brand, minus the web fonts — see index.html for why. */
:root {
  --bg: #0a0a0c;
  --text: #ECEAE3;
  --muted: #9b9b92;
  --dim: #6a6a63;
  --accent: #ff7a2f;
  --border: rgba(255, 255, 255, 0.09);
  --sans: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --mono: ui-monospace, 'SF Mono', SFMono-Regular, Menlo, monospace;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

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

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  /* The whole page is a viewport onto the world; nothing here ever scrolls,
     and on iOS this is also what stops a drag on the canvas bouncing the page. */
  overflow: hidden;
  overscroll-behavior: none;
}

body { -webkit-text-size-adjust: 100%; }

#scene {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  /* Steering is a drag gesture, so the browser must not claim it as a scroll. */
  touch-action: none;
}

/* ── Loader ─────────────────────────────────────────────────────────────── */

.loader {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  background: var(--bg);
  transition: opacity 0.6s var(--ease);
}

/* Faded out rather than removed, so the world is already rendering behind it. */
.loader.is-done { opacity: 0; pointer-events: none; }

.loader-inner { width: min(420px, 82vw); text-align: center; }

.loader-kicker {
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--dim);
  margin-bottom: 0.6rem;
}

.loader-title {
  font-size: clamp(2.4rem, 9vw, 3.6rem);
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1;
  margin-bottom: 1.6rem;
}

.loader-bar {
  height: 2px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}

.loader-bar span {
  display: block;
  height: 100%;
  width: 0%;
  background: var(--accent);
  transition: width 0.3s var(--ease);
}

.loader-status {
  margin-top: 0.9rem;
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--muted);
  min-height: 1.2em;
}

.loader-status.is-error { color: var(--accent); }

/* ── Fallbacks ──────────────────────────────────────────────────────────── */

.fallback {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  align-content: center;
  justify-items: start;
  gap: 0.9rem;
  padding: 2rem clamp(1.5rem, 8vw, 6rem);
  background: var(--bg);
}

.fallback[hidden] { display: none; }
.fallback h1 { font-size: clamp(2rem, 7vw, 3rem); font-weight: 600; letter-spacing: -0.02em; }
.fallback p { max-width: 46ch; color: var(--muted); line-height: 1.6; }
.fallback a { color: var(--accent); }

/* ── Chrome ─────────────────────────────────────────────────────────────── */

.home-link {
  position: fixed;
  z-index: 10;
  left: max(1rem, env(safe-area-inset-left));
  bottom: max(1rem, env(safe-area-inset-bottom));
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--dim);
  text-decoration: none;
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: rgba(10, 10, 12, 0.5);
  backdrop-filter: blur(6px);
  transition: color 0.2s var(--ease), border-color 0.2s var(--ease);
}

.home-link:hover { color: var(--text); border-color: rgba(255, 255, 255, 0.2); }

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