*,
*::before,
*::after {
  box-sizing: border-box;
}
html,
body {
  height: 100%;
  padding-bottom: var(--strip-h);
  margin: 0;
}

:root {
  --bg: #0f1114;
  --ink: #e8e3d7;
  --accent: #c7a066;
  --accent-2: #2a2d33;
  --strip-h: 112px;
}

body {
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial,
    "Apple Color Emoji", "Segoe UI Emoji";
  background: var(--bg);
  color: var(--ink);
  line-height: 1.4;
  overflow-x: hidden;
  cursor: none;
}

#bg-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
}

.hero {
  min-height: calc(100vh - var(--strip-h));
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1vh 4vw 6vh;
  gap: 2rem;
  text-align: center;
  position: relative;
  z-index: 1;
}

.hero h1 {
  font-family: "Poiret One", system-ui, sans-serif;
  font-weight: 400;
  font-size: clamp(3rem, 7vw, 6.5rem);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin: 0;
  position: relative;
  padding-block: 0.7rem;
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
}

.letter {
  display: inline-block;
  opacity: 0;
  transform: translateY(20px) rotateX(90deg);
  animation: letterIn 0.6s ease-out forwards, letterFloat 4s ease-in-out infinite;
  animation-delay: calc(var(--i) * 0.08s), calc(var(--i) * 0.08s + 0.6s);
  background: linear-gradient(
    135deg,
    var(--ink) 0%,
    var(--accent) 40%,
    var(--ink) 60%,
    var(--accent) 100%
  );
  background-size: 300% 300%;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.letter:hover {
  animation: letterIn 0.6s ease-out forwards, letterPop 0.4s ease-out, letterFloat 4s ease-in-out infinite;
  animation-delay: 0s, 0s, 0.4s;
}

.letter.space {
  width: 0.3em;
}

@keyframes letterIn {
  to {
    opacity: 1;
    transform: translateY(0) rotateX(0deg);
  }
}

@keyframes letterFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(calc(-3px - var(--i) * 0.3px)); }
}

@keyframes letterPop {
  0% { transform: scale(1); }
  50% { transform: scale(1.3) translateY(-5px); }
  100% { transform: scale(1); }
}

.hero h1::before,
.hero h1::after {
  content: "";
  position: absolute;
  left: 50%;
  width: min(72vw, 820px);
  height: 1px;
  background: linear-gradient(
    to right,
    transparent,
    var(--accent) 20%,
    var(--accent) 80%,
    transparent
  );
  transform: translateX(-50%);
}
.hero h1::before {
  top: 0;
}
.hero h1::after {
  bottom: 0;
}

.hero-image {
  margin: 0;
  perspective: 800px;
}
.hero-image img {
  display: block;
  max-width: min(90vw, 1200px);
  max-height: 60vh;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 8px;
  outline: 1px solid var(--accent-2);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  animation: imgBreathe 6s ease-in-out infinite;
  transition: transform 0.3s ease, box-shadow 0.3s ease, outline-color 0.3s ease;
}
.hero-image img:hover {
  transform: scale(1.02);
  box-shadow: 0 12px 40px rgba(199, 160, 102, 0.25), 0 0 60px rgba(199, 160, 102, 0.08);
  outline-color: var(--accent);
}

@keyframes imgBreathe {
  0%, 100% {
    transform: translateY(0) rotate(0deg);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  }
  50% {
    transform: translateY(-4px) rotate(0.2deg);
    box-shadow: 0 14px 32px rgba(0, 0, 0, 0.4), 0 0 40px rgba(199, 160, 102, 0.06);
  }
}

/* ── custom cursor / mouse trail ──────────────────── */
#mouse-trail {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 999;
  overflow: hidden;
}
.trail-tooth {
  position: absolute;
  width: 12px;
  height: 14px;
  pointer-events: none;
  animation: trailFade 0.8s ease-out forwards;
}
.trail-sparkle {
  position: absolute;
  pointer-events: none;
  animation: trailSparkleFade 0.6s ease-out forwards;
}
@keyframes trailFade {
  0% { opacity: 0.8; transform: scale(1) translateY(0) rotate(0deg); }
  100% { opacity: 0; transform: scale(0.3) translateY(15px) rotate(30deg); }
}
@keyframes trailSparkleFade {
  0% { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: scale(0); }
}

/* ── cursor tooth (replaces system cursor) ────────── */
.custom-cursor {
  position: fixed;
  pointer-events: none;
  z-index: 10000;
  width: 24px;
  height: 28px;
  transform: translate(-50%, -50%);
  transition: transform 0.05s linear;
}

@media (prefers-reduced-motion: reduce) {
  .letter {
    animation: none;
    opacity: 1;
    transform: none;
  }
  .hero-image img {
    animation: none;
  }
  .trail-tooth, .trail-sparkle {
    animation: none;
    display: none;
  }
}

#bottom-strip {
  height: var(--strip-h);
  display: block;
  overflow: hidden;
  pointer-events: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 1000;
}

#bottom-strip::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(var(--accent-2), var(--accent-2)) top/100% 1px
      no-repeat,
    linear-gradient(var(--accent), var(--accent)) top/100% 3px no-repeat;
  pointer-events: none;
  z-index: 2;
}

#parade-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
}

/* ── splash / enter page ─────────────────────────── */
#splash-overlay {
  position: fixed;
  inset: 0;
  z-index: 20000;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: default;
  transition: opacity 0.8s ease, transform 0.8s ease;
}
#splash-overlay.exiting {
  opacity: 0;
  transform: scale(1.05);
  pointer-events: none;
}
#splash-overlay.hidden {
  display: none;
}
.splash-content {
  text-align: center;
  animation: splashFadeIn 1.2s ease-out;
}
.splash-subtitle {
  font-family: "Poiret One", system-ui, sans-serif;
  font-weight: 400;
  font-size: clamp(1.2rem, 3vw, 2rem);
  color: var(--ink);
  letter-spacing: 0.15em;
  text-transform: uppercase;
  margin: 0 0 0.5rem;
  opacity: 0.7;
}
.splash-title {
  font-family: "Poiret One", system-ui, sans-serif;
  font-weight: 400;
  font-size: clamp(3rem, 8vw, 7rem);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin: 0;
  background: linear-gradient(135deg, var(--ink) 0%, var(--accent) 50%, var(--ink) 100%);
  background-size: 300% 300%;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: splashShimmer 3s ease-in-out infinite;
}
.splash-tooth-art {
  margin: 2rem auto;
  opacity: 0.6;
  animation: splashToothFloat 3s ease-in-out infinite;
}
.splash-enter {
  font-family: "Poiret One", system-ui, sans-serif;
  font-size: clamp(1rem, 2.5vw, 1.4rem);
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ink);
  background: transparent;
  border: 1px solid var(--accent);
  padding: 0.8em 2.5em;
  cursor: pointer;
  transition: background 0.3s, color 0.3s, box-shadow 0.3s, transform 0.15s;
}
.splash-enter:hover {
  background: var(--accent);
  color: var(--bg);
  box-shadow: 0 0 30px rgba(199, 160, 102, 0.3);
  transform: scale(1.05);
}
.splash-enter:active {
  transform: scale(0.98);
}

@keyframes splashFadeIn {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes splashShimmer {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}
@keyframes splashToothFloat {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-10px) rotate(2deg); }
}

/* ── click-to-spawn canvas ───────────────────────── */
#spawn-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 2;
  pointer-events: none;
}

/* ── visitor counter ──────────────────────────────── */
.visitor-counter {
  display: flex;
  align-items: baseline;
  gap: 0.4em;
  font-family: "Poiret One", system-ui, sans-serif;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  pointer-events: none;
  opacity: 0;
  animation: counterFadeIn 0.8s ease-out 1.6s forwards;
}
.visitor-counter-label {
  font-size: clamp(0.7rem, 1.5vw, 0.85rem);
  color: var(--ink);
  opacity: 0.5;
}
.visitor-counter-number {
  font-size: clamp(0.8rem, 1.8vw, 1rem);
  color: var(--accent);
  letter-spacing: 0.18em;
  font-variant-numeric: tabular-nums;
}

@keyframes counterFadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ── custom context menu ─────────────────────────── */
.context-menu {
  position: fixed;
  z-index: 15000;
  min-width: 210px;
  background: linear-gradient(180deg, #1a1c20, #12141a);
  border: 1px solid var(--accent-2);
  border-radius: 6px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.6), 0 0 1px rgba(199, 160, 102, 0.2);
  padding: 4px 0;
  font-family: "Poiret One", system-ui, sans-serif;
  font-size: 0.85rem;
  opacity: 0;
  transform: scale(0.95);
  transition: opacity 0.15s ease, transform 0.15s ease;
  pointer-events: none;
}
.context-menu.visible {
  opacity: 1;
  transform: scale(1);
  pointer-events: auto;
}
.context-item {
  display: flex;
  align-items: center;
  gap: 0.5em;
  width: 100%;
  padding: 8px 16px;
  background: none;
  border: none;
  color: var(--ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.context-item:hover {
  background: rgba(199, 160, 102, 0.15);
  color: var(--accent);
}
.context-divider {
  border: none;
  border-top: 1px solid var(--accent-2);
  margin: 4px 8px;
}

/* ── context menu effect keyframes ───────────────── */
@keyframes extractShake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-4px) rotate(-0.5deg); }
  40% { transform: translateX(4px) rotate(0.5deg); }
  60% { transform: translateX(-3px); }
  80% { transform: translateX(2px); }
}
@keyframes msgFloat {
  0% { opacity: 1; transform: translateY(0); }
  100% { opacity: 0; transform: translateY(-30px); }
}
@keyframes flossSlide {
  0% { transform: translateX(-100%); opacity: 0; }
  30% { opacity: 1; }
  100% { transform: translateX(100%); opacity: 0; }
}

/* ── touch device overrides ──────────────────────── */
@media (hover: none) and (pointer: coarse) {
  body {
    cursor: auto;
  }
  .custom-cursor {
    display: none !important;
  }
  .splash-enter,
  .context-item {
    cursor: auto;
  }
}

/* ── mobile layout (small screens) ───────────────── */
@media (max-width: 600px) {
  :root {
    --strip-h: 72px;
  }
  .hero {
    padding: 2vh 3vw 4vh;
    gap: 1.2rem;
  }
  .hero-image img {
    max-height: 45vh;
  }
  .splash-content {
    padding: 0 1.5rem;
  }
  .splash-enter {
    padding: 1em 2.5em;
    font-size: 1.1rem;
    min-height: 48px;
  }
  .context-menu {
    min-width: 180px;
  }
  .context-item {
    padding: 12px 16px;
    font-size: 0.9rem;
  }
}

/* ── reduced motion overrides (additions) ────────── */
@media (prefers-reduced-motion: reduce) {
  #splash-overlay { transition: none; }
  .splash-content { animation: none; }
  .splash-title { animation: none; }
  .splash-tooth-art { animation: none; }
  .visitor-counter { animation: none; opacity: 1; }
  .context-menu { transition: none; }
}
