/* Global Resets and Base Styles */
/* Site-wide defaults, backgrounds, and utilities. Modify here for broad changes. */

* { box-sizing: border-box; }

/* Global non-scrollable canvas */
html, body {
  height: 100%;
  margin: 0;
  padding: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
}

/* Full-viewport responsive background */
body {
  background-image: url("/images/BACKGROUND-desktop.png");
  /* IMPORTANT: JS sets --bg-locked-size after load; fallback is natural 'cover' */
  background-size: var(--bg-locked-size, cover);
  background-position: left top;     /* keep the composition anchored */
  background-attachment: fixed;      /* explicit for clarity */
  background-repeat: no-repeat;
  z-index: 0; /* Background at z-index 0 */
}

.viewport {
  width: min(100%, 100vw);
  min-height: 100dvh; /* dynamic viewport height for mobile chrome */
  padding: env(safe-area-inset-top) env(safe-area-inset-right)
           env(safe-area-inset-bottom) env(safe-area-inset-left);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20 !important; /* Ensure main container is above bits (10) */
}

/* Debug mode for testing */
/* Applies to bits or other elements; modify here for global debug tweaks */
.bit.debug {
  background: red !important;
  animation: none !important;
}

/* Component: Header Brand (top-right logo) */
/* All brand styles grouped; adjust sizes or shadows here */
.brand {
  position: fixed;
  top: clamp(8px, 2vmin, 16px);
  right: clamp(8px, 2vmin, 16px);
  z-index: 20 !important; /* Above bits (10) */
  display: inline-block;
  line-height: 0;
}
.brand img {
  display: block;
  width: clamp(40px, 16vmin, 200px);
  height: clamp(40px, 16vmin, 200px);
  object-fit: contain;
  user-select: none;
  -webkit-user-drag: none;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,.25));
}
.brand:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 4px;
  border-radius: 8px;
}

/* Component: Header Menu (top-left hover menu) */
/* All menu styles grouped; tweak dropdown or hover effects here */
.menu {
  position: fixed;
  top: clamp(8px, 2vmin, 16px);
  left: clamp(8px, 2vmin, 16px);
  z-index: 20 !important; /* Above bits (10) */
}
.menu__toggle { display: inline-block; line-height: 0; }
.menu__toggle img {
  display: block;
  width: 101px;
  height: 55px;
  object-fit: contain;
}

.menu__dropdown {
  position: absolute;
  left: 0;
  margin-top: 0px;
  min-width: 180px;
  padding: 8px 0;
  list-style: none;
  background: rgba(255, 255, 255, 0.92);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(197, 123, 53, 0.849);
  display: none;
  z-index: 20 !important; /* Above bits (10) */
}
.menu:hover .menu__dropdown,
.menu:focus-within .menu__dropdown {
  display: block;
}
.menu__dropdown a {
  display: block;
  padding: 10px 14px;
  text-decoration: none;
  color: #111;
  font-weight: 500;
  letter-spacing: .2px;
}
.menu__dropdown a:hover,
.menu__dropdown a:focus {
  background: #e86f17;
  outline: none;
  border-radius: 8px;
}
.menu__dropdown a.is-active { font-weight: 700; }

/* Component: Social Links (fixed icon column) */
.social-links {
  position: fixed;
  bottom: clamp(10px, 2vmin, 16px);
  right: clamp(10px, 2vmin, 16px);
  z-index: 20;
}

.social-links ul {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: clamp(8px, 2vmin, 16px);
}

.social-links a {
  display: block;
  line-height: 0;
}

.social-links img {
  width: clamp(40px, 4vmin, 64px);
  height: auto;
  object-fit: contain;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,.25));
}

/* Component: Bits Overlay (random black bits) */
/* All bits styles grouped, including shapes, colors, animation; adjust animation or shapes here */
#bits {
  position: fixed;
  inset: 0;
  pointer-events: none;   /* don't block clicks */
  z-index: 10; /* Bits at z-index 10 */
}

.bit {
  position: absolute;
  display: block !important;
  background: #000; 
  opacity: 1;
  transform: scale(.9);
  border-radius: 2px;
  animation: bit-pop 5s ease-in-out infinite;
  will-change: transform, opacity;
  z-index: 10 !important; /* Bits at z-index 10 */
}

/* Shapes */
.bit.square  { width: 20px; height: 20px; border-radius: 2px; }
.bit.dash    { width: 45px; height: 5px;  border-radius: 2px; }
.bit.circle  { width: 20px; height: 20px; border-radius: 50%; }

/* Triangle uses borders for shape (reliable cross-browser, no clip-path issues) */
.bit.triangle {
  width: 0;
  height: 0;
  background: none;
  border-left: 11px solid transparent;
  border-right: 11px solid transparent;
  border-bottom: 20px solid #000;
  border-radius: 0;
}

/* Color toggle */
.bit.is-orange { background: #e86f17 !important; }
.bit.triangle.is-orange { border-bottom-color: #e86f17 !important; }
.bit.triangle.is-black { border-bottom-color: #000; }

/* Fade/flash animation */
@keyframes bit-pop {
  0%   { opacity: 0.9; transform: scale(.9); }
  10%  { opacity: 1; transform: scale(1); }
  25%  { opacity: 1; }
  40%  { opacity: 0.9; }
  100% { opacity: 0.9; transform: scale(.95); }
}

/* Global Fallbacks */
/* Disable body background when stage is present (avoid duplication) */
body:has(#stage) {
  background-image: none !important;
}

/* Consolidated Media Queries */
/* All desktop adjustments in one block, grouped by component/category */
@media (min-width: 1087px) {
  /* Background - Desktop */
  body {
    background-size: var(--bg-locked-size, cover) !important;
    background-position: left top;
    background-repeat: no-repeat;
    background-attachment: fixed;
    background-color: #0b0b0b;       /* fill any uncovered area */
    z-index: 0; /* Background at z-index 0 */
  }
}

/* All mobile adjustments in one block, grouped by component/category */
@media (max-width: 1086px) {
  /* Background - Mobile (portrait & small screens) */
  body {
    background-image: url("/images/BACKGROUND-mobile.jpg");
    background-position: left top;   /* keep artwork anchored */
    background-size: var(--bg-locked-size, cover);
    background-attachment: fixed;
    z-index: 0; /* Background at z-index 0 */
  }

  .social-links {
    bottom: clamp(8px, 2vmin, 12px);
    right: clamp(8px, 2vmin, 12px);
  }

  .social-links img {
    width: clamp(32px, 3vmin, 48px);
    height: auto;
  }
}