/* ==========================================================================
   JigSaw Land - Responsive Hub & Subpage Navigation System
   Provides a unified, mobile-first responsive header & navigation drawer
   ========================================================================== */

/* Subpage Header Container */
.hub-header {
  position: relative;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  background: var(--panel-bg, rgba(35, 40, 32, 0.94));
  border: 1px solid var(--panel-border, rgba(255, 255, 255, 0.16));
  border-radius: 40px;
  padding: 10px 24px;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  z-index: 120;
}

/* Brand Link */
.brand-link {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: #ffffff;
  font-weight: 800;
  font-size: 1.15rem;
  flex-shrink: 0;
  z-index: 2;
}

.brand-link:hover span {
  opacity: 0.95;
}

/* Desktop Navigation Links */
.nav-links {
  display: flex;
  gap: 14px;
  align-items: center;
  flex-wrap: wrap;
}

.nav-links a {
  color: var(--text-dim, #dce3d8);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 20px;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.nav-links a:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.08);
}

.nav-links a.active {
  color: #1a2015;
  background: var(--accent-green, #aacc88);
  font-weight: 700;
  box-shadow: 0 2px 10px rgba(170, 204, 136, 0.35);
}

/* Mobile Navigation Hamburger Toggle Button (Hidden on Desktop) */
.hub-nav-toggle {
  display: none;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  transition: all 0.25s ease;
  z-index: 2;
  flex-shrink: 0;
}

.hub-nav-toggle:hover {
  background: rgba(255, 255, 255, 0.16);
  border-color: rgba(255, 255, 255, 0.3);
}

.hub-nav-toggle:active {
  transform: scale(0.95);
}

.hub-nav-toggle svg {
  display: block;
  transition: transform 0.25s ease;
}

.hub-nav-toggle .bar-top,
.hub-nav-toggle .bar-mid,
.hub-nav-toggle .bar-bot {
  transform-origin: center;
  transition: transform 0.25s ease, opacity 0.2s ease;
}

/* Morph Hamburger to Close 'X' when Open */
.hub-nav-toggle.active .bar-top {
  transform: translateY(6px) rotate(45deg);
}

.hub-nav-toggle.active .bar-mid {
  opacity: 0;
}

.hub-nav-toggle.active .bar-bot {
  transform: translateY(-6px) rotate(-45deg);
}

/* Mobile Click-Outside Backdrop */
.hub-nav-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 110;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.hub-nav-backdrop.active {
  opacity: 1;
  pointer-events: auto;
}

/* Mobile Responsive Breakpoint (Tablet & Phone: <= 820px) */
@media (max-width: 820px) {
  .hub-header {
    flex-direction: row !important;
    justify-content: space-between !important;
    align-items: center !important;
    padding: 10px 16px !important;
    border-radius: 24px !important;
  }

  .hub-nav-toggle {
    display: inline-flex !important;
  }

  .nav-links {
    position: absolute;
    top: calc(100% + 10px);
    left: 0;
    right: 0;
    background: rgba(26, 32, 23, 0.98);
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 20px;
    padding: 12px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(28px);
    -webkit-backdrop-filter: blur(28px);
    display: flex !important;
    flex-direction: column !important;
    flex-wrap: nowrap !important;
    gap: 6px !important;
    opacity: 0;
    pointer-events: none;
    transform: translateY(-10px) scale(0.98);
    transition: opacity 0.25s cubic-bezier(0.16, 1, 0.3, 1), transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    z-index: 125;
    max-height: calc(100vh - 120px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .nav-links.open,
  .hub-header.nav-open .nav-links {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0) scale(1);
  }

  .nav-links a {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    box-sizing: border-box;
    padding: 12px 16px;
    font-size: 0.95rem;
    font-weight: 600;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.06);
    color: var(--text-dim, #e2e8df);
  }

  .nav-links a:hover {
    background: rgba(255, 255, 255, 0.12);
    color: #ffffff;
    padding-left: 20px;
  }

  .nav-links a.active {
    background: rgba(170, 204, 136, 0.2);
    border: 1px solid rgba(170, 204, 136, 0.45);
    color: var(--accent-green, #aacc88);
    font-weight: 800;
  }
}

/* Extra small mobile screens (<= 400px) */
@media (max-width: 400px) {
  .hub-header {
    padding: 8px 12px !important;
  }

  .brand-link span {
    font-size: 1rem;
  }

  .hub-nav-toggle {
    width: 38px;
    height: 38px;
  }
}
