/* ============================================================
   Sidebar + mobile bar
   ============================================================ */

.mobile-top-bar {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 3000;
  height: 64px;
  padding: 0 1rem;
  align-items: center;
  justify-content: space-between;
  background: rgba(6, 8, 16, 0.92);
  border-bottom: 1px solid var(--border);
}

.mobile-brand {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.05rem;
  color: #fff;
  letter-spacing: -0.02em;
}

.mobile-brand:hover {
  color: #fff;
}

.menu-toggle {
  width: 48px;
  height: 48px;
  min-width: 48px;
  min-height: 48px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.12);
  display: grid;
  place-items: center;
  cursor: pointer;
  color: #fff;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  appearance: none;
}

.menu-toggle:active {
  background: rgba(255, 255, 255, 0.22);
}

.navbar-toggler-icon-custom,
.navbar-toggler-icon-custom::before,
.navbar-toggler-icon-custom::after {
  display: block;
  width: 18px;
  height: 2px;
  background: #fff;
  border-radius: 2px;
  position: relative;
}

.navbar-toggler-icon-custom::before,
.navbar-toggler-icon-custom::after {
  content: "";
  position: absolute;
  left: 0;
}

.navbar-toggler-icon-custom::before { top: -6px; }
.navbar-toggler-icon-custom::after { top: 6px; }

.sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  z-index: 3100;
}

.sidebar-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-w);
  height: 100vh;
  z-index: 3200;
  display: flex;
  flex-direction: column;
  padding: 1.4rem 1.1rem 1.2rem;
  background:
    linear-gradient(180deg, rgba(12, 6, 6, 0.38) 0%, rgba(10, 5, 5, 0.22) 45%, rgba(8, 4, 4, 0.48) 100%),
    url("/images/sidebar-bricks.webp") center / cover no-repeat;
  border-right: 1px solid rgba(70, 22, 18, 0.55);
  box-shadow:
    inset -1px 0 0 rgba(255, 180, 160, 0.08),
    16px 0 40px rgba(0, 0, 0, 0.28);
}

.sidebar::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse at 50% 0%, rgba(0, 0, 0, 0.2), transparent 46%),
    linear-gradient(90deg, rgba(0, 0, 0, 0.12), rgba(0, 0, 0, 0.28));
}

.sidebar > *:not(.menu-close) {
  position: relative;
  z-index: 1;
}

.menu-close {
  display: none;
  position: absolute;
  top: 0.8rem;
  right: 0.8rem;
  width: 40px;
  height: 40px;
  border: 0;
  background: transparent;
  color: #fff;
  font-size: 2rem;
  line-height: 1;
  cursor: pointer;
}

.sidebar-header {
  text-align: center;
  padding: 0.85rem 0.7rem 1rem;
  margin-bottom: 0.35rem;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 14px;
  background: rgba(8, 6, 8, 0.72);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.sidebar-brand {
  margin: 0.15rem 0 0.15rem;
  font-size: 1.15rem;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.7);
}

.sidebar-logo a {
  display: block;
}

#logo-3d {
  width: 168px;
  height: 168px;
  margin: 0 auto 0.35rem;
  position: relative;
}

.logo-fallback {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 50%;
  filter: drop-shadow(0 0 18px rgba(78, 168, 255, 0.35));
  transition: opacity 0.4s ease;
}

#logo-3d canvas {
  position: absolute;
  inset: 0;
  width: 100% !important;
  height: 100% !important;
}

.sidebar-subtitle {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #ffd7c4;
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.6);
}

.sidebar-menu {
  padding: 1.1rem 0 0.4rem;
  overflow-y: auto;
  flex-shrink: 0;
}

.sidebar-menu .nav {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.sidebar-menu .nav-link {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.78rem 0.9rem;
  border-radius: 12px;
  color: #f4f6ff;
  font-weight: 600;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(10, 8, 10, 0.82);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.38);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

.sidebar-menu .nav-link svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  opacity: 1;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sidebar-menu .nav-link:hover {
  color: #fff;
  background: rgba(22, 12, 12, 0.92);
  border-color: rgba(255, 186, 150, 0.4);
  transform: translateX(3px);
}

.sidebar-menu .nav-link.is-active {
  color: #fff;
  background: rgba(14, 10, 10, 0.94);
  border-color: rgba(255, 210, 180, 0.5);
  box-shadow:
    0 8px 18px rgba(0, 0, 0, 0.4),
    0 0 18px rgba(255, 100, 70, 0.22);
}

.sidebar-footer {
  margin-top: 0;
  padding: 0.9rem 0.7rem 0.75rem;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 14px;
  background: rgba(8, 6, 8, 0.72);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.sidebar-bricks {
  flex: 1;
  min-height: 7rem;
  position: relative;
  margin: 0.45rem 0;
  overflow: hidden;
  border-radius: 12px;
  border: 0;
  background: transparent;
  box-shadow: none;
  --bx: -180px;
  --by: -180px;
}

.brick-wall {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 3px 0;
  pointer-events: none;
}

.brick-row {
  display: flex;
  gap: 3px;
  height: 17px;
  flex-shrink: 0;
}

.brick-row:nth-child(even) {
  transform: translateX(-22px);
}

.brick {
  flex: 1 0 44px;
  height: 100%;
  border-radius: 1px;
  background: transparent;
  border: 1px solid transparent;
  transition: background 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease;
}

.brick.is-lit {
  background: rgba(255, 92, 64, 0.22);
  border-color: rgba(255, 210, 170, 0.42);
  box-shadow:
    0 0 16px rgba(255, 110, 70, 0.45),
    inset 0 0 10px rgba(255, 230, 180, 0.18);
}

.brick-lamp {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(
    circle 130px at var(--bx) var(--by),
    rgba(255, 236, 210, 0.38) 0%,
    rgba(255, 140, 90, 0.16) 36%,
    transparent 70%
  );
  mix-blend-mode: screen;
}

@media (prefers-reduced-motion: reduce) {
  .brick {
    transition: none;
  }

  .brick-lamp {
    background: none;
  }
}

.sidebar-icons {
  display: flex;
  justify-content: center;
  gap: 0.85rem;
  margin-bottom: 0.7rem;
}

.sidebar-icons svg {
  width: 22px;
  height: 22px;
}

.sidebar-copy {
  text-align: center;
  color: var(--faint);
  font-size: 0.75rem;
}

@media (max-width: 991px) {
  .mobile-top-bar {
    display: flex;
  }

  .menu-close {
    display: grid;
    place-items: center;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
  }

  .sidebar {
    transform: translate3d(-100vw, 0, 0);
    visibility: hidden;
    pointer-events: none;
    overflow: hidden;
    contain: paint;
    width: min(320px, 86vw);
    box-shadow: none !important;
    filter: none;
    background-image: none;
    background-color: #120808;
    transition:
      transform 0.2s ease-out,
      visibility 0s linear 0.2s;
  }

  .sidebar.active {
    transform: translate3d(0, 0, 0);
    visibility: visible;
    pointer-events: auto;
    box-shadow: 18px 0 40px rgba(0, 0, 0, 0.45) !important;
    background:
      linear-gradient(180deg, rgba(12, 6, 6, 0.45) 0%, rgba(10, 5, 5, 0.28) 45%, rgba(8, 4, 4, 0.55) 100%),
      url("/images/sidebar-bricks.webp") center / cover no-repeat;
    transition:
      transform 0.2s ease-out,
      visibility 0s linear 0s;
  }

  .logo-fallback {
    filter: none;
  }

  .sidebar-header,
  .sidebar-footer,
  .sidebar-menu .nav-link {
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }

  .sidebar-bricks,
  .brick-lamp {
    display: none;
  }

  #logo-3d {
    width: 128px;
    height: 128px;
  }

  .sidebar-menu .nav-link:hover {
    transform: none;
  }
}
