/* ─── Reset ──────────────────────────────────────────────────────────────────── */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

/* ─── Base ───────────────────────────────────────────────────────────────────── */
html {
  background: #000;
}
html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: system-ui, -apple-system, 'Helvetica Neue', sans-serif;
  color: #fff;
}
body {
  background: transparent;
}

/* ─── Inline text styles (used by parseLinks) ────────────────────────────────── */
.ty-white { color: #fff; }

/* ─── Nav ────────────────────────────────────────────────────────────────────── */
nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 50;
  padding: 0 36px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  pointer-events: none;
}

.nav-name {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.24em;
  color: rgba(255, 255, 255, 0.9);
  text-transform: uppercase;
  transition: color 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: var(--nav-logo-top, 24px);
}

.nav-logo {
  height: 1em;
  width: auto;
  display: none;
  opacity: 0; /* invisible spacer — visual comes from #nav-logo-bg */
  transform-origin: top left;
  transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

/* navMode rules via data-nav-mode on <nav> */
nav[data-nav-mode="name-logo"] .nav-logo { display: block; }
nav[data-nav-mode="logo"] .nav-name-text  { display: none; }
nav[data-nav-mode="logo"] .nav-logo       { display: block; }
nav[data-nav-mode="logo-name"] .nav-logo      { display: block; order: -1; }
nav[data-nav-mode="logo-name"] .nav-name-text { order: 0; }

/* ─── Background video ───────────────────────────────────────────────────────── */
#bg-video {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: -1; /* behind everything */
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.6s ease;
  will-change: opacity, transform; /* own compositing layer — isolates from canvas repaints */
  transform: translateZ(0);        /* GPU promotion hint */
}
#bg-video.active { opacity: var(--bg-video-opacity, 0.4); }

@media (prefers-reduced-motion: reduce) {
  #bg-video { opacity: 0 !important; }
}

/* ─── Background logo layer (behind canvas — particles float in front) ──────── */
#nav-logo-bg {
  position: fixed;
  top: var(--nav-logo-top, 24px);
  left: 36px; /* matches nav padding */
  height: 1em;
  font-size: 0.7rem; /* matches .nav-name */
  width: auto;
  opacity: 0.9;
  mix-blend-mode: screen; /* black bg transparent in all browsers, incl. Safari */
  z-index: 0; /* behind canvas (1) and noise (2) */
  pointer-events: none;
  display: none;
  transform-origin: top left;
  transition: opacity 0.2s, transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  object-fit: contain;
}
/* Show background logo for modes that include a logo */
nav[data-nav-mode="logo"]      ~ #nav-logo-bg,
nav[data-nav-mode="name-logo"] ~ #nav-logo-bg,
nav[data-nav-mode="logo-name"] ~ #nav-logo-bg { display: block; }
/* Dim on nav button hover (mirrors the old .nav-logo hover) */
nav:has(#nav-name-btn.clickable:hover) ~ #nav-logo-bg { opacity: 0.6; }

/* Right-side nav button group */
.nav-actions,
#nav-right {
  display: flex;
  align-items: center;
  gap: 10px;
  pointer-events: auto;
  transition: margin-right 0.35s ease;
  margin-top: var(--nav-about-top, 24px);
}

/* Logo back-link state */
#nav-name-btn.clickable {
  cursor: pointer;
  pointer-events: auto;
}
#nav-name-btn.clickable:hover { color: rgba(255, 255, 255, 0.6); }

/* PLY file loader — subtle button in top-right */
.nav-ply {
  pointer-events: auto;
  cursor: pointer;
  font-size: 0.6rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.15);
  padding: 6px 12px;
  transition: color 0.2s, border-color 0.2s;
  user-select: none;
}
.nav-ply:hover {
  color: rgba(255, 255, 255, 0.8);
  border-color: rgba(255, 255, 255, 0.5);
}
.nav-ply input[type="file"] {
  display: none;
}

/* Generic nav button (About, motion trail toggle, gyro enable) */
.nav-btn {
  pointer-events: auto;
  cursor: pointer;
  font-family: var(--ty-nav-btn-font, 'Big Shoulders Display', sans-serif);
  font-size: var(--ty-nav-btn-size, 0.75rem);
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ty-nav-btn-color, rgba(255, 255, 255, 0.4));
  border: none;
  padding: 6px 12px;
  transition: color 0.2s;
  user-select: none;
  background: none;
}
.nav-btn:hover,
.nav-btn--active {
  color: rgba(255, 255, 255, 0.9);
}

/* ─── Canvas ─────────────────────────────────────────────────────────────────── */
#canvas {
  position: fixed;
  inset: 0;
  z-index: 1; /* above logo (0), below noise (2) and labels (20) */
  pointer-events: none;
  display: block;
}

/* ─── Background noise overlay ───────────────────────────────────────────────── */
.grid-lines {
  position: fixed;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background-image: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' width='200' height='200'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.70' numOctaves='4' stitchTiles='stitch'/><feColorMatrix type='saturate' values='0'/></filter><rect width='200' height='200' filter='url(%23n)'/></svg>");
  background-size: 200px 200px;
  opacity: 0.05;
}

/* ─── Floating label container ───────────────────────────────────────────────── */
#label-container {
  position: fixed;
  inset: 0;
  z-index: 20;
  pointer-events: none;   /* individual labels opt back in */
}
