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

* { box-sizing: border-box; }

@font-face {
  font-family: "HomepageBaukasten Bold";
  src: url("/fonts/HomepagebaukastenBold.ttf") format("truetype");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "HomepageBaukasten Book";
  src: url("/fonts/HomepagebaukastenBook.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  --font-header-nav: "HomepageBaukasten Book", "HomepagebaukastenBook", "Helvetica Neue", Arial, sans-serif;
}

/* 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-color: #fff;
  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 */
  opacity: 0;
  animation: mel-page-fade-in 900ms cubic-bezier(0.16, 1, 0.3, 1) 120ms forwards;
}

@keyframes mel-page-fade-in {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  body {
    animation: none;
    opacity: 1;
  }
}

.viewport {
  width: min(100%, 100vw);
  max-width: 1920px;
  margin: 0 auto;
  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: Site Header Background */
/* Fixed decorative banner for the top of the site; sits under brand/menu */
.site-header {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: clamp(96px, 9vw, 172px);
  z-index: 2200; /* Above stage (20/40/1000) and bits (10) */
  pointer-events: none; /* allow children to handle interactions */
}
.site-header > * {
  pointer-events: auto;
}

.site-header-bg {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: clamp(96px, 9vw, 172px); /* 1920x172 asset scales with viewport */
  background-image: url("/header/header_background_Orange.png");
  background-size: cover;
  background-position: center top;
  background-repeat: no-repeat;
  z-index: 8;
  pointer-events: none;
}

/* Component: Header Brand (top-left logo) */
/* All brand styles grouped; adjust sizes or shadows here */
.brand {
  position: fixed;
  top: calc(clamp(96px, 9vw, 172px) / 2); /* vertically center on header banner */
  left: clamp(8px, 2vmin, 16px);
  z-index: 2000 !important; /* Above stage (20/40/1000) and bits (10) */
  display: inline-block;
  line-height: 0;
  transform: translateY(-50%);
  cursor: pointer;
}
.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));
  transition: transform 180ms ease, filter 180ms ease, opacity 150ms ease;
}
.brand:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 4px;
  border-radius: 8px;
}
.brand:hover img,
.brand:focus-visible img {
  transform: translateY(-2px) scale(1.02);
  filter: drop-shadow(0 3px 6px rgba(0,0,0,.4));
}

/* Component: Header Contact Button (top-right) */
.header-contact {
  position: fixed;
  top: calc(clamp(96px, 9vw, 172px) / 2); /* vertically center within header banner */
  right: clamp(8px, 2vmin, 16px);
  z-index: 2000 !important; /* Above stage (20/40/1000) and bits (10) */
  display: inline-block;
  line-height: 0;
  transform: translateY(-50%);
  cursor: pointer;
}
.header-contact img {
  display: block;
  width: clamp(140px, 14vmin, 259px);
  height: auto;
  object-fit: contain;
  user-select: none;
  -webkit-user-drag: none;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,.25));
  transition: transform 150ms ease, filter 150ms ease;
}
.header-contact:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 4px;
  border-radius: 8px;
}
.header-contact:hover img,
.header-contact:focus-visible img {
  transform: scale(1.04);
  filter: drop-shadow(0 2px 4px rgba(0,0,0,.35));
}

/* Component: Header Navigation (centered within header banner) */
.header-nav {
  position: fixed;
  top: calc(clamp(96px, 9vw, 172px) / 2);
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 2000;
  display: flex;
  align-items: center;
  pointer-events: auto;
}
.header-nav ul {
  display: flex;
  align-items: center;
  gap: clamp(8px, 1.4vw, 18px);
  margin: 0;
  padding: 0;
  list-style: none;
}
.header-nav li {
  display: flex;
  align-items: center;
}
.header-nav a {
  display: inline-block;
  padding: 6px 4px;
  font-family: var(--font-header-nav);
  font-size: clamp(12.1px, 1.08vw, 18.6px); /* ~2% smaller */
  font-weight: 300; /* lighter weight */
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #fff;
  text-decoration: none;
  line-height: 1;
  text-shadow: 0 1px 2px rgba(0,0,0,.35);
  transition: color 140ms ease, transform 140ms ease, text-shadow 140ms ease;
  cursor: pointer;
}
.header-nav a:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 4px;
  border-radius: 6px;
}
.header-nav a:hover,
.header-nav a:focus-visible {
  color: #ffe0c2;
  text-shadow: 0 2px 4px rgba(0,0,0,.4);
  transform: translateY(-1px);
}
.header-nav__sep {
  display: block;
  width: clamp(76.8px, 5.19vw, 121px); /* ~2% smaller */
  height: auto;
  flex-shrink: 0;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,.35));
}

.mobile-menu-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 4px;
  width: 48px;
  height: 48px;
  position: fixed;
  top: clamp(12px, 3vmin, 18px);
  right: clamp(10px, 3vmin, 16px);
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  background: rgba(0, 0, 0, 0.52);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.35);
  z-index: 2001;
  cursor: pointer;
  transition: transform 160ms ease, background-color 160ms ease, border-color 160ms ease;
  pointer-events: auto;
}
.mobile-menu-toggle:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 3px;
}
.mobile-menu-toggle:hover {
  transform: translateY(-1px);
  background: rgba(0, 0, 0, 0.64);
  border-color: rgba(255, 255, 255, 0.55);
}
.mobile-menu-toggle__bar {
  display: block;
  width: 22px;
  height: 2px;
  border-radius: 999px;
  background: #fff;
  transition: transform 180ms ease, opacity 180ms ease;
}
.mobile-menu-toggle.is-open .mobile-menu-toggle__bar:nth-child(1) {
  transform: translateY(6px) rotate(45deg);
}
.mobile-menu-toggle.is-open .mobile-menu-toggle__bar:nth-child(2) {
  opacity: 0;
}
.mobile-menu-toggle.is-open .mobile-menu-toggle__bar:nth-child(3) {
  transform: translateY(-6px) rotate(-45deg);
}

.mobile-nav {
  display: none;
}

/* Component: Header Entrance Animations */
/* Slides the logo, nav, and contact button into view on load */
body.header-animate .brand,
body.header-animate .header-nav,
body.header-animate .header-contact {
  opacity: 0;
}
body.header-animate .brand {
  animation: mel-header-slide-down 640ms cubic-bezier(0.16, 1, 0.3, 1) 80ms forwards;
}
body.header-animate .header-nav {
  animation: mel-header-nav-in 720ms cubic-bezier(0.16, 1, 0.3, 1) 160ms forwards;
}
body.header-animate .header-contact {
  animation: mel-header-slide-down 640ms cubic-bezier(0.16, 1, 0.3, 1) 240ms forwards;
}

@keyframes mel-header-slide-down {
  from {
    opacity: 0;
    transform: translateY(calc(-50% - 12px));
  }

  to {
    opacity: 1;
    transform: translateY(-50%);
  }
}

@keyframes mel-header-nav-in {
  from {
    opacity: 0;
    transform: translate(-50%, -68%);
  }

  to {
    opacity: 1;
    transform: translate(-50%, -50%);
  }
}

@media (prefers-reduced-motion: reduce) {
  body.header-animate .brand,
  body.header-animate .header-nav,
  body.header-animate .header-contact {
    animation: none;
    opacity: 1;
  }
}

/* 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; }

/* Debug Utility: Clear Cookies button (hidden easter egg) */
#debug-clear-cookies {
  position: fixed;
  top: clamp(8px, 2vmin, 16px);
  left: clamp(8px, 2vmin, 16px);
  z-index: 9999;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 14px;
  border: none;
  border-radius: 999px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.4px;
  color: #111;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.35);
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
}

#debug-clear-cookies:hover {
  transform: translateY(-1px);
  box-shadow: 0 16px 32px rgba(232, 111, 23, 0.45);
  background: rgba(232, 111, 23, 0.95);
}

#debug-clear-cookies:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 3px;
}

#debug-clear-cookies[hidden] {
  display: none !important;
}

/* 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));
}

/* Footer social links (tethered inside footer) */
.footer-social {
  display: flex;
  align-items: center;
  gap: clamp(10px, 1.8vw, 18px);
  flex-wrap: wrap;
  justify-content: center;
}

.footer-social a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 0;
  transition: transform 160ms cubic-bezier(0.16, 1, 0.3, 1),
    filter 160ms ease;
}

.footer-social img {
  width: clamp(32px, 4vw, 52px);
  height: auto;
  object-fit: contain;
  filter: drop-shadow(0 1px 3px rgba(0,0,0,0.3));
}

.footer-social a:hover img,
.footer-social a:focus-visible img {
  transform: scale(1.08);
  filter: drop-shadow(0 3px 8px rgba(0,0,0,0.45));
}

.footer-social a:focus-visible {
  outline: 2px solid rgba(255, 255, 255, 0.9);
  outline-offset: 4px;
  border-radius: 8px;
}

/* 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 */
/* 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: #ffffff;       /* 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: scroll;
    background-repeat: no-repeat;
    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;
  }

  /* Header tweaks for mobile */
  .site-header,
  .site-header-bg {
    height: clamp(82px, 18vw, 120px);
  }

  .brand {
    top: calc(clamp(82px, 18vw, 120px) / 2);
    left: clamp(10px, 4vmin, 18px);
    transform: translateY(-50%);
  }

  .brand img {
    width: clamp(46.4px, 19.2vmin, 105.6px);
    height: auto;
  }

  .header-nav {
    display: none;
  }

  .header-contact {
    display: none;
  }

  .mobile-menu-toggle {
    display: inline-flex;
    top: calc(clamp(82px, 18vw, 120px) / 2);
    transform: translateY(-50%);
    width: 52px;
    height: 52px;
    gap: 6px;
    border-radius: 50%;
    background: #ffffff;
    border: 2px solid #ff8a2c;
    box-shadow: none;
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }

  .mobile-menu-toggle:hover {
    transform: translateY(calc(-50% - 1px));
    background: #ffffff;
    border-color: #ff9e50;
  }

  .mobile-menu-toggle:focus-visible {
    outline: 2px solid #ff8a2c;
    outline-offset: 3px;
  }

  .mobile-menu-toggle__bar {
    background: #f17906;
    width: 22px;
    height: 3px;
  }

  .mobile-nav {
    position: fixed;
    top: clamp(82px, 18vw, 120px);
    left: 0;
    right: 0;
    display: flex;
    flex-direction: column;
    gap: clamp(16px, 3vw, 24px);
    padding: clamp(18px, 6vw, 32px) clamp(18px, 7vw, 36px) clamp(24px, 8vw, 40px);
    background: rgba(10, 10, 10, 0.94);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    box-shadow: 0 18px 42px rgba(0, 0, 0, 0.36);
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
    transform: translateY(-8px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 180ms ease, transform 180ms ease;
    z-index: 2000;
  }

  .mobile-nav.is-open {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
  }

  .mobile-nav__list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: clamp(12px, 3vw, 18px);
  }

  .mobile-nav__list a {
    display: inline-block;
    padding: 10px 4px;
    font-family: var(--font-header-nav);
    font-size: clamp(14px, 3.6vw, 18px);
    letter-spacing: 0.12em;
    color: #ffffff;
    text-decoration: none;
    text-transform: uppercase;
    text-align: left;
  }

  .mobile-nav__list a:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 4px;
    border-radius: 6px;
  }

  .mobile-nav__contact {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 16px;
    font-family: var(--font-header-nav);
    font-size: clamp(14px, 3.4vw, 17px);
    letter-spacing: 0.12em;
    text-transform: uppercase;
    text-decoration: none;
    color: #111;
    background: #ff8a2c;
    border-radius: 10px;
    box-shadow: 0 8px 22px rgba(0, 0, 0, 0.35);
    font-weight: 700;
    text-align: center;
  }

  .mobile-nav__contact:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 4px;
  }

  body.menu-open {
    overflow: hidden;
  }
}
