/* =========================================
   Base Setup
   ========================================= */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html, body {
  height: 100%;
  margin: 0;
  background: #fff;
  color: #000;
  font-family: "Bitcount Prop Double Ink", system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
  font-weight: 300;
  overflow: auto;
}

/* =========================================
   Background Gallery
   ========================================= */
:root {
  --g-pad-top: 140px;   /* space below the menu */
  --g-pad-x: 28px;
  --g-pad-bottom: 220px;
  --g-gap: 28px;        /* space between columns and items */
}

.bg-gallery {
  position: relative;
  z-index: 1;                 /* bottom layer */
  padding: var(--g-pad-top) var(--g-pad-x) var(--g-pad-bottom);
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(286px, 1fr));
  gap: var(--g-gap);
  pointer-events: auto;
  transition: transform 260ms ease-out;
}

.bg-gallery img {
  width: 100%;
  height: auto;
  display: block;
  margin: 0 0 var(--g-gap);
  break-inside: avoid;
  border-radius: 0;
  transition: outline 150ms ease, transform 150ms ease, filter 150ms ease;
  position: relative;
}

/* Direct hover on images – glow effect (no scale to avoid multicol bug) */
.bg-gallery img:hover {
  outline: 2px solid rgb(0, 0, 255);
  filter: brightness(1.15);
  z-index: 10;
}

/* =========================================
   Sticky Top Menu
   ========================================= */
.menu {
  position: fixed;
  top: 0; left: 0; right: 0;
  padding: 12px 20px;
  z-index: 4;                 /* top layer */
  background: transparent;
}

.menu ul {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  align-items: center;
  gap: 24px;
  max-width: 1200px;
  margin-inline: auto;
}

.menu li {
  position: relative;
  padding-top: 10px;
  text-align: left;
}

.menu li::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: currentColor;
  opacity: 0.6;
}

/* Base menu link */
.menu a {
  font-family: "Geologica", ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
  font-weight: 400;
  letter-spacing: 0.01em;
  text-decoration: none;
  color: #000;
  transition: color 0.25s ease, text-shadow 0.25s ease;
  position: relative;
  display: inline-block;
  overflow: hidden;
}

/* =========================================
   Electric Blue Shine on Stick Hit
   ========================================= */
.menu a.hit {
  color: rgb(0, 0, 255);
  text-shadow:
    0 0 6px rgba(0, 209, 255, 0.8),
    0 0 12px rgba(0, 209, 255, 0.6),
    0 0 24px rgba(0, 209, 255, 0.4);
  animation: shine 1.5s linear infinite;
}

/* Subtle shine sweep effect */
@keyframes shine {
  0% {
    background: linear-gradient(
      120deg,
      transparent 0%,
      rgba(255, 255, 255, 0.4) 40%,
      transparent 80%
    );
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: rgb(0, 0, 255);
    background-size: 200% 100%;
    background-position: -120% 0;
  }
  100% {
    background-position: 120% 0;
  }
}

/* =========================================
   p5.js Canvas Layer (title + stick)
   ========================================= */
.artboard {
  position: fixed;
  inset: 0;
  z-index: 2;                   /* above gallery, below menu */
  display: grid;
  place-items: center;
  pointer-events: none;         /* allows clicks/scrolls through */
}

#sketch-container, canvas {
  width: 100%;
  height: 100%;
  display: block;
  pointer-events: none;
}

/* =========================================
   Optional Debug   
   ========================================= */
/*
.bg-gallery { outline: 1px solid magenta; }
.artboard   { outline: 1px solid cyan; }
.menu       { outline: 1px solid lime; }
*/
/* When the stick is highlighting something, show a pointer cursor */
/* Fade helpers during shuffle */
.g-item {
  opacity: 1;
  transition: opacity 180ms ease-in-out;
  will-change: opacity;
  position: relative;
}
.g-item.fade-out { opacity: 0.15; }
.g-item.fade-in  { opacity: 1; }

/* Stick-based highlight (activated via JS) */
.g-item.hit img {
  outline: 3px solid rgb(0, 0, 255);
  filter: brightness(1.2);
  z-index: 10;
}

/* Pointer cursor anywhere when a link is activatable via stick */
body.can-activate { cursor: pointer; }

/* Optional: active menu state */
.menu a.active {
  color: #00d1ff;
  text-shadow:
    0 0 6px rgba(0, 209, 255, 0.8),
    0 0 12px rgba(0, 209, 255, 0.6),
    0 0 24px rgba(0, 209, 255, 0.4);
}

/* =========================================
   Image Lightbox Overlay
   ========================================= */
.lightbox-overlay {
  position: fixed;
  inset: 0;
  background: #f5f5f5; /* light product-page style background */
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10; /* above menu and canvas */
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease-in-out;
}

.lightbox-overlay.is-visible {
  opacity: 1;
  pointer-events: auto;
}

.lightbox-overlay__inner {
  position: relative;
  width: 100%;
  height: 100%;
  max-width: 1400px;
  margin: 0 auto;
  padding: 48px 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 64px;
  box-sizing: border-box;
}

.lightbox-overlay__image-wrap {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1; /* sits behind the text meta */
}

.lightbox-overlay__image-wrap img {
  max-width: 100%;
  max-height: 80vh;
  border-radius: 0;
  object-fit: contain;
}

.lightbox-overlay__close {
  position: absolute;
  top: 24px;
  right: 32px;
  font-family: "Geologica", ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
  font-size: 0.85rem;
  color: #111;
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.lightbox-overlay__meta {
  position: absolute;
  left: 6px;
  top: 85%;
  transform: translateY(-50%);
  max-width: 15vw; /* text box reaches over the image */
  z-index: 2;      /* above the image */
  font-family: "Geologica", ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
  font-size: 1 rem;
  line-height: 1.2;
  color: #111;
}

.lightbox-overlay__meta h2 {
  margin: 0 0 0.5rem;
  font-size: 1rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.lightbox-overlay__meta p {
  margin: 0;
}

@media (max-width: 800px) {
  .lightbox-overlay__inner {
    padding: 24px 20px;
    flex-direction: column;
    gap: 24px;
  }

  .lightbox-overlay__meta {
    position: static;
    max-width: none;
    width: 100%;
  }

  .lightbox-overlay__close {
    top: 16px;
    right: 20px;
  }
}

/* =========================================
   Footer Menu (mirrored + smaller)
   ========================================= */
.footer-menu {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 600px;
  padding: 8px 0;
  z-index: 4;
  background: transparent;
}

.footer-menu ul {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  align-items: center;
  text-align: center;
  gap: 16px;
}

.footer-menu a {
  font-family: "Geologica", ui-sans-serif, system-ui;
  font-size: 0.65rem;   /* 50% smaller */
  font-weight: 400;
  letter-spacing: 0.01em;
  text-decoration: none;
  color: #000;
  opacity: 0.8;
  transition: opacity 0.25s ease, text-shadow 0.25s ease;
}

.footer-menu a:hover {
  opacity: 1;
}

/* =========================================
   FORCE CENTER TITLE ABOVE LIGHTBOX
   ========================================= */
#sketch-container canvas {
  position: fixed !important;
  top: 0;
  left: 0;
  width: 100vw !important;
  height: 100vh !important;
  z-index: 9999 !important;   /* ABOVE LIGHTBOX */
  pointer-events: none !important;   /* allow clicking through */
}

/* =========================================
   Mobile: dock main menu to bottom
   ========================================= */
@media (max-width: 720px) {
  /* Reduce top padding and reserve space for the bottom menu */
  :root {
    --g-pad-top: 28px;
    --g-pad-bottom: 140px;
  }

  .menu {
    top: auto;
    bottom: 0;
    padding: 10px 12px;
    padding-bottom: calc(10px + env(safe-area-inset-bottom));
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
  }

  .menu ul {
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
  }

  .menu li {
    padding-top: 0;
    text-align: center;
  }

  /* The top underline doesn’t make sense as a bottom dock */
  .menu li::before {
    display: none;
  }

  .menu a {
    display: block;
    padding: 10px 0;
  }

  /* Prevent content from being covered by the fixed bottom menu */
  body {
    padding-bottom: calc(72px + env(safe-area-inset-bottom));
  }

  /* Hide the mirrored footer menu on mobile (main menu now sits at bottom) */
  .footer-menu {
    display: none;
  }
}