@font-face {
  font-family: 'Space Grotesk';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: local('Space Grotesk Bold'), local('SpaceGrotesk-Bold'),
       url('/fonts/space-grotesk/SpaceGrotesk-Bold.ttf') format('truetype');
}

@font-face {
  font-family: 'Syne';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: local('Syne Bold'), local('Syne-Bold'),
       url('/fonts/syne/Syne-Bold.ttf') format('truetype');
}

@font-face {
  font-family: 'Bebas Neue';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: local('Bebas Neue'), local('BebasNeue-Regular'),
       url('/fonts/bebas-neue/BebasNeue-Regular.ttf') format('truetype');
}

:root {
  --bg-color: #f5f0eb;
  --text-main: #1c1a17;
  --text-muted: #827b72;
  --accent: #d9532f;
  --surface-glass: rgba(255, 255, 255, 0.82);
  --border-glass: rgba(0, 0, 0, 0.08);
  --font-display: 'Space Grotesk', 'Trebuchet MS', 'Arial', sans-serif;
  --font-sans: 'Space Grotesk', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  --meta-title-fill: transparent;
  --meta-title-stroke: rgba(255, 255, 255, 0.95);
  --meta-title-stroke-width: 1.5px;
  --title-blur-radius: 24px;
  --title-blur-opacity: 1;
  --title-blur-tint: rgba(255, 255, 255, 0.22);
}

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

body,
html {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg-color);
  color: var(--text-main);
  font-family: var(--font-sans);
  user-select: none;
  -webkit-font-smoothing: antialiased;
}

/* Subtle background paper grain noise */
.noise-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  opacity: 0.035;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)'/%3E%3C/svg%3E");
  z-index: 50;
}

/* WebGL canvas takes full screen */
#webgl-canvas-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  cursor: grab;
}

#webgl-canvas-container:active {
  cursor: grabbing;
}

/* --- Header --- */
.site-header {
  position: fixed;
  top: 32px;
  left: 40px;
  right: 40px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  z-index: 20;
  pointer-events: none;
}

.artist-brand {
  display: flex;
  flex-direction: column;
}

.artist-name {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  text-transform: uppercase;
}

.artist-role {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-top: 4px;
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 16px;
  pointer-events: auto;
}

.btn-pill {
  background: var(--surface-glass);
  backdrop-filter: blur(14px);
  border: 1px solid var(--border-glass);
  color: var(--text-main);
  padding: 8px 18px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.2, 0.8, 0.2, 1);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.03);
}

.btn-pill:hover {
  background: var(--text-main);
  color: #fff;
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.08);
}

/* --- Active Artwork Metadata (Anchored to Bottom of Active Carousel Card) --- */
.active-meta {
  position: fixed;
  left: 50%;
  bottom: calc(var(--card-bottom-offset, 17.5vh) + 24px);
  transform: translateX(-50%);
  z-index: 20;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 10px;
  width: min(92vw, 680px);
  max-width: min(92vw, 680px);
  perspective: 1000px;
  transform-style: preserve-3d;
}

/* Rolling Odometer Counter */
.counter {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 0.95rem;
  font-weight: 700;
  color: #ffffff;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  height: 30px;
  line-height: 30px;
  background: rgba(255, 255, 255, 0.14);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.32);
  padding: 0 16px;
  border-radius: 20px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.18);
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.4);
}

.counter-slot {
  position: relative;
  display: inline-block;
  overflow: hidden;
  height: 30px;
  width: 28px;
  min-width: 28px;
  vertical-align: middle;
}

.counter-num {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  font-variant-numeric: tabular-nums;
  transform-origin: center center;
  will-change: transform, opacity;
  transition: transform 0.38s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.32s ease;
  color: #ffffff;
  font-weight: 800;
}

.counter-sep {
  opacity: 0.55;
  font-weight: 400;
  margin: 0 2px;
}

.counter-total {
  opacity: 0.75;
  font-variant-numeric: tabular-nums;
}

/* Staggered 3D Page Flap Title & Tags (Zero Layout Shift) */
.title-wrap {
  position: relative;
  overflow: visible;
  perspective: 800px;
  padding: 4px 18px;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  width: auto;
  max-width: 92%;
  height: clamp(2.4rem, 5.2vw, 3.8rem);
  box-sizing: border-box;
}

/* --- Progressive Blur Behind Active Meta Text Only --- */
.title-blur-backdrop {
  position: absolute;
  inset: -10px -28px;
  pointer-events: none;
  z-index: 0;
  border-radius: 40px;
  will-change: opacity, transform;
  transition: opacity 0.35s ease, transform 0.45s cubic-bezier(0.16, 1, 0.3, 1);
  opacity: var(--title-blur-opacity, 1);
}

/* Layer 1: Core progressive blur with radial mask gradient */
.title-blur-backdrop::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 40px;
  backdrop-filter: blur(var(--title-blur-radius, 24px)) saturate(140%);
  -webkit-backdrop-filter: blur(var(--title-blur-radius, 24px)) saturate(140%);
  background: radial-gradient(
    ellipse 86% 72% at 50% 50%,
    var(--title-blur-tint, rgba(255, 255, 255, 0.22)) 0%,
    rgba(255, 255, 255, 0.08) 50%,
    rgba(255, 255, 255, 0) 80%
  );
  mask-image: radial-gradient(
    ellipse 88% 74% at 50% 50%,
    rgba(0, 0, 0, 1) 0%,
    rgba(0, 0, 0, 0.85) 45%,
    rgba(0, 0, 0, 0) 84%
  );
  -webkit-mask-image: radial-gradient(
    ellipse 88% 74% at 50% 50%,
    rgba(0, 0, 0, 1) 0%,
    rgba(0, 0, 0, 0.85) 45%,
    rgba(0, 0, 0, 0) 84%
  );
}

/* Layer 2: Extended wide progressive feather falloff */
.title-blur-backdrop::after {
  content: '';
  position: absolute;
  inset: -8px -18px;
  border-radius: 48px;
  backdrop-filter: blur(calc(var(--title-blur-radius, 24px) * 0.45));
  -webkit-backdrop-filter: blur(calc(var(--title-blur-radius, 24px) * 0.45));
  mask-image: radial-gradient(
    ellipse 94% 82% at 50% 50%,
    rgba(0, 0, 0, 0.6) 0%,
    rgba(0, 0, 0, 0) 92%
  );
  -webkit-mask-image: radial-gradient(
    ellipse 94% 82% at 50% 50%,
    rgba(0, 0, 0, 0.6) 0%,
    rgba(0, 0, 0, 0) 92%
  );
}

.active-title {
  position: relative;
  z-index: 1;
  font-family: var(--font-display);
  font-size: clamp(1.8rem, 4.2vw, 3rem);
  font-weight: 700;
  letter-spacing: -0.015em;
  line-height: 1.15;
  color: var(--meta-title-fill, transparent);
  -webkit-text-stroke: var(--meta-title-stroke-width, 1.5px) var(--meta-title-stroke, rgba(255, 255, 255, 0.95));
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  transform-origin: center center;
  will-change: transform, opacity;
  filter: drop-shadow(0 4px 18px rgba(0, 0, 0, 0.55));
  text-shadow: 0 0 30px rgba(255, 255, 255, 0.25);
  user-select: none;
}

.active-tags {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  height: 32px;
  transform-origin: center center;
  will-change: transform, opacity;
}

.tag {
  background: rgba(255, 255, 255, 0.14);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.32);
  padding: 6px 16px;
  border-radius: 8px;
  font-size: 0.78rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.95);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.18);
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.4);
}

/* --- Carousel Navigation Chevrons --- */
.carousel-arrow {
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--surface-glass);
  backdrop-filter: blur(14px);
  border: 1px solid var(--border-glass);
  color: var(--text-main);
  font-size: 1.4rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 25;
  transition: all 0.25s cubic-bezier(0.2, 0.8, 0.2, 1);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.05);
}

.carousel-arrow:hover {
  background: var(--text-main);
  color: #fff;
  transform: translateY(-50%) scale(1.08);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.12);
}

.carousel-arrow-prev {
  left: 36px;
}

.carousel-arrow-next {
  right: 36px;
}

/* --- Floating Controls (Bottom Right) --- */
.controls-dock {
  position: fixed;
  bottom: 40px;
  right: 40px;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--surface-glass);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border-glass);
  padding: 10px 18px;
  border-radius: 999px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.06);
}

.dock-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.val-num {
  font-family: var(--font-mono);
  font-size: 0.76rem;
  color: var(--accent);
  background: rgba(217, 83, 47, 0.08);
  padding: 2px 6px;
  border-radius: 4px;
  min-width: 34px;
  display: inline-block;
  text-align: center;
}

.dock-item input[type="range"] {
  width: 75px;
  height: 4px;
  accent-color: var(--accent);
  cursor: pointer;
}

.dock-btn {
  background: var(--text-main);
  color: #fff;
  border: none;
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  cursor: pointer;
  transition: all 0.2s ease;
}

.dock-btn:hover {
  background: var(--accent);
  transform: translateY(-1px);
}

/* --- Progress Bar --- */
.progress-rail {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 4px;
  background: rgba(0, 0, 0, 0.04);
  z-index: 30;
}

.progress-fill {
  height: 100%;
  width: 100%;
  background: var(--accent);
  transform-origin: left;
  transform: scaleX(0);
  transition: transform 0.08s linear;
}

/* --- Drag Hint --- */
.drag-hint {
  position: fixed;
  bottom: 95px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  pointer-events: none;
  z-index: 15;
}

.pulse-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 10px var(--accent);
  animation: pulseAnim 2s infinite;
}

@keyframes pulseAnim {
  0% {
    transform: scale(0.9);
    opacity: 0.7;
  }

  50% {
    transform: scale(1.4);
    opacity: 1;
  }

  100% {
    transform: scale(0.9);
    opacity: 0.7;
  }
}

/* --- Lightbox Modal --- */
.lightbox-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(18, 17, 16, 0.88);
  backdrop-filter: blur(20px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  padding: 40px;
}

.lightbox-modal.is-open {
  opacity: 1;
  pointer-events: auto;
}

.lightbox-content {
  position: relative;
  max-width: 90vw;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.lightbox-content img {
  max-width: 85vw;
  max-height: 72vh;
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.4);
}

.lightbox-details {
  margin-top: 16px;
  text-align: center;
  color: #fff;
}

.lightbox-details h2 {
  font-size: 1.3rem;
  font-weight: 700;
}

.lightbox-details p {
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.65);
  margin-top: 4px;
}

.lightbox-close {
  position: absolute;
  top: -45px;
  right: 0;
  background: transparent;
  border: none;
  color: #fff;
  font-size: 1.8rem;
  cursor: pointer;
  padding: 8px;
  line-height: 1;
}

/* --- Archive Drawer --- */
.archive-drawer {
  position: fixed;
  top: 0;
  right: 0;
  width: 100%;
  max-width: 600px;
  height: 100%;
  background: #fff;
  z-index: 110;
  box-shadow: -10px 0 40px rgba(0, 0, 0, 0.15);
  transform: translateX(100%);
  transition: transform 0.4s cubic-bezier(0.2, 0.8, 0.2, 1);
  display: flex;
  flex-direction: column;
}

.archive-drawer.is-open {
  transform: translateX(0);
}

.archive-header {
  padding: 28px 32px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

.archive-header h2 {
  font-size: 1.3rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: -0.02em;
}

.archive-close {
  background: none;
  border: none;
  font-size: 1.8rem;
  cursor: pointer;
  color: var(--text-main);
  line-height: 1;
}

.archive-grid {
  flex: 1;
  overflow-y: auto;
  padding: 24px 32px;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

.archive-item {
  position: relative;
  aspect-ratio: 1;
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  background: #eee;
}

.archive-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}

.archive-item:hover img {
  transform: scale(1.05);
}

.archive-item-info {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.7));
  color: #fff;
  padding: 8px 12px;
  font-size: 0.75rem;
  font-weight: 600;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.archive-item:hover .archive-item-info {
  opacity: 1;
}

@media (max-width: 768px) {
  .site-header {
    top: 20px;
    left: 20px;
    right: 20px;
  }

  .active-meta {
    top: auto;
    bottom: calc(var(--card-bottom-offset, 14vh) + 16px);
    left: 50%;
    transform: translateX(-50%);
    max-width: 92vw;
    width: 92vw;
    gap: 8px;
  }

  .title-wrap {
    height: clamp(2rem, 7vw, 2.8rem);
    padding: 2px 8px;
  }

  .active-title {
    font-size: clamp(1.3rem, 4.5vw, 1.6rem);
  }

  .controls-dock {
    bottom: 20px;
    right: 20px;
    padding: 8px 14px;
    gap: 8px;
  }

  .dock-item label {
    display: none;
  }

  .dock-item input[type="range"] {
    width: 50px;
  }

  .drag-hint {
    display: none;
  }
}

/* Lil-GUI Studio Suite Styling */
.lil-gui {
  --background-color: rgba(250, 246, 240, 0.94);
  --text-color: #2b2824;
  --title-background-color: #ede4d8;
  --widget-color: rgba(225, 217, 206, 0.7);
  --hover-color: rgba(215, 204, 190, 0.9);
  --focus-color: #d9532f;
  --number-color: #d9532f;
  --string-color: #287271;
  font-family: var(--font-sans) !important;
  font-size: 11px !important;
  border-radius: 14px !important;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.12), 0 2px 6px rgba(0, 0, 0, 0.04) !important;
  backdrop-filter: blur(20px) !important;
  -webkit-backdrop-filter: blur(20px) !important;
  border: 1px solid rgba(0, 0, 0, 0.08) !important;
  top: 90px !important;
  right: 40px !important;
  max-height: calc(100vh - 120px) !important;
  overflow-y: auto !important;
  z-index: 900 !important;
}

.lil-gui .title {
  font-weight: 700 !important;
  letter-spacing: 0.04em !important;
  text-transform: uppercase !important;
  font-size: 11px !important;
  padding: 8px 12px !important;
}

.lil-gui::-webkit-scrollbar {
  width: 5px;
}

.lil-gui::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.18);
  border-radius: 4px;
}