/**
 * HeadCode Theme - Navigation CSS
 * Accessible desktop and mobile responsive navigation, search overlay, and theme toggle.
 * Supports Light Mode (Default) and Dark Mode.
 * @package HeadCode
 */

.hc-site-header {
  position: sticky;
  top: 0;
  z-index: 1000;
  background-color: var(--hc-header-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--hc-border-subtle);
  transition: var(--hc-transition-fast);
}

.hc-header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--hc-header-height);
  gap: var(--hc-space-4);
}

/* ==========================================================================
   Brand & Logo
   ========================================================================== */

.hc-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  flex-shrink: 0;
}

.hc-brand__logo-img {
  max-height: 38px;
  width: auto;
}

.hc-brand__icon {
  width: 34px;
  height: 34px;
  background: linear-gradient(135deg, var(--hc-accent-cyan) 0%, var(--hc-accent-blue) 100%);
  border-radius: var(--hc-radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  font-family: var(--hc-font-mono);
  font-weight: 800;
  font-size: 15px;
  box-shadow: 0 2px 8px rgba(2, 132, 199, 0.3);
}

.hc-brand__text {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--hc-text-primary);
  letter-spacing: -0.02em;
}

.hc-brand__text span {
  color: var(--hc-accent-cyan);
}

/* ==========================================================================
   Desktop Navigation
   ========================================================================== */

.hc-nav-desktop {
  display: none;
}

@media (min-width: 860px) {
  .hc-nav-desktop {
    display: flex;
    align-items: center;
    gap: var(--hc-space-1);
  }
}

.hc-menu-primary {
  display: flex;
  align-items: center;
  list-style: none;
  padding: 0;
  margin: 0;
  gap: 2px;
}

.hc-menu-primary > li {
  position: relative;
  margin-bottom: 0;
}

.hc-menu-primary > li > a {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.5rem 0.75rem;
  color: var(--hc-text-secondary);
  font-size: var(--hc-text-sm);
  font-weight: 600;
  text-decoration: none;
  border-radius: var(--hc-radius-md);
  transition: var(--hc-transition-fast);
  min-height: 40px;
}

.hc-menu-primary > li > a:hover,
.hc-menu-primary > li:hover > a,
.hc-menu-primary > li:focus-within > a {
  color: var(--hc-accent-cyan);
  background-color: var(--hc-bg-surface-2);
}

.hc-menu-primary > li.current-menu-item > a,
.hc-menu-primary > li.current_page_item > a {
  color: var(--hc-accent-blue);
  background-color: var(--hc-bg-surface-2);
  font-weight: 700;
}

/* Desktop Dropdown Menus */
.hc-menu-primary .sub-menu {
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 220px;
  background-color: var(--hc-bg-surface-1);
  border: 1px solid var(--hc-border-strong);
  border-radius: var(--hc-radius-md);
  box-shadow: var(--hc-shadow-lg);
  padding: var(--hc-space-2);
  list-style: none;
  margin: 0;
  opacity: 0;
  visibility: hidden;
  transform: translateY(8px);
  transition: var(--hc-transition-fast);
  z-index: 1010;
}

.hc-menu-primary li:hover > .sub-menu,
.hc-menu-primary li:focus-within > .sub-menu {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.hc-menu-primary .sub-menu li {
  margin-bottom: 0;
}

.hc-menu-primary .sub-menu a {
  display: block;
  padding: 0.5rem 0.75rem;
  font-size: var(--hc-text-sm);
  color: var(--hc-text-secondary);
  text-decoration: none;
  border-radius: var(--hc-radius-sm);
  transition: var(--hc-transition-fast);
}

.hc-menu-primary .sub-menu a:hover,
.hc-menu-primary .sub-menu a:focus {
  background-color: var(--hc-bg-surface-2);
  color: var(--hc-accent-cyan);
}

/* ==========================================================================
   Header Actions (Theme Toggle, Search, Cart, CTA)
   ========================================================================== */

.hc-header-actions {
  display: flex;
  align-items: center;
  gap: var(--hc-space-2);
  flex-shrink: 0;
}

.hc-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: var(--hc-radius-md);
  background-color: transparent;
  border: 1px solid var(--hc-border-subtle);
  color: var(--hc-text-secondary);
  cursor: pointer;
  transition: var(--hc-transition-fast);
  text-decoration: none;
  position: relative;
}

.hc-icon-btn:hover,
.hc-icon-btn:focus-visible {
  background-color: var(--hc-bg-surface-2);
  border-color: var(--hc-border-strong);
  color: var(--hc-accent-cyan);
}

/* Light / Dark Mode Toggle Button */
.hc-theme-toggle {
  color: var(--hc-text-primary);
}

/* Light mode (default): show moon, hide sun */
html[data-theme="light"] .hc-theme-toggle .hc-icon-sun,
:root:not([data-theme="dark"]) .hc-theme-toggle .hc-icon-sun {
  display: none !important;
}

html[data-theme="light"] .hc-theme-toggle .hc-icon-moon,
:root:not([data-theme="dark"]) .hc-theme-toggle .hc-icon-moon {
  display: block !important;
}

/* Dark mode: show sun, hide moon */
html[data-theme="dark"] .hc-theme-toggle .hc-icon-sun {
  display: block !important;
}

html[data-theme="dark"] .hc-theme-toggle .hc-icon-moon {
  display: none !important;
}

/* Header Get Started CTA button */
.hc-header-cta-btn,
.hc-header-store-btn {
  display: none;
  font-weight: 700;
  letter-spacing: -0.01em;
  background: linear-gradient(135deg, var(--hc-accent-blue) 0%, var(--hc-accent-purple) 100%);
  color: #ffffff !important;
  border: none;
  box-shadow: 0 4px 14px rgba(59, 130, 246, 0.35);
  transition: var(--hc-transition-fast);
}

.hc-header-cta-btn:hover,
.hc-header-store-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(59, 130, 246, 0.45);
  filter: brightness(1.1);
}

@media (min-width: 600px) {
  .hc-header-cta-btn,
  .hc-header-store-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
  }
}

/* EDD Cart Trigger */
.hc-cart-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: var(--hc-radius-md);
  border: 1px solid var(--hc-border-subtle);
  color: var(--hc-text-secondary);
  position: relative;
  text-decoration: none;
  transition: var(--hc-transition-fast);
}

.hc-cart-trigger:hover {
  background-color: var(--hc-bg-surface-2);
  color: var(--hc-accent-cyan);
}

.hc-cart-trigger__count {
  position: absolute;
  top: 4px;
  right: 4px;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  border-radius: var(--hc-radius-full);
  background-color: var(--hc-accent-blue);
  color: #ffffff;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

/* ==========================================================================
   Mobile Menu Toggle & Drawer (Positioned outside header)
   ========================================================================== */

.hc-menu-toggle {
  display: inline-flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  background: transparent;
  border: 1px solid var(--hc-border-strong);
  border-radius: var(--hc-radius-md);
  cursor: pointer;
  gap: 5px;
  transition: var(--hc-transition-fast);
  color: var(--hc-text-primary);
  z-index: 1001;
}

@media (min-width: 860px) {
  .hc-menu-toggle {
    display: none;
  }
}

.hc-menu-toggle__line {
  width: 22px;
  height: 2px;
  background-color: currentColor;
  border-radius: 2px;
  transition: transform 0.25s ease, opacity 0.25s ease;
}

.hc-menu-toggle[aria-expanded="true"] .hc-menu-toggle__line:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}

.hc-menu-toggle[aria-expanded="true"] .hc-menu-toggle__line:nth-child(2) {
  opacity: 0;
}

.hc-menu-toggle[aria-expanded="true"] .hc-menu-toggle__line:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

/* Mobile Offcanvas Drawer (Root viewport fixed) */
.hc-drawer-backdrop {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  background-color: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 99998;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.hc-drawer-backdrop.is-active {
  opacity: 1;
  visibility: visible;
}

.hc-nav-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 320px;
  max-width: 85vw;
  height: 100vh;
  background-color: var(--hc-bg-surface-1);
  border-left: 1px solid var(--hc-border-strong);
  box-shadow: -4px 0 25px rgba(0, 0, 0, 0.25);
  z-index: 99999;
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.3s ease;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: var(--hc-space-6);
  visibility: hidden;
  pointer-events: none;
}

.hc-nav-drawer.is-active {
  transform: translateX(0);
  visibility: visible;
  pointer-events: auto;
}

.hc-drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--hc-space-6);
  padding-bottom: var(--hc-space-4);
  border-bottom: 1px solid var(--hc-border-subtle);
}

.hc-drawer-close {
  width: 44px;
  height: 44px;
  background: transparent;
  border: 1px solid var(--hc-border-strong);
  border-radius: var(--hc-radius-md);
  color: var(--hc-text-primary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--hc-transition-fast);
}

.hc-drawer-close:hover {
  background-color: var(--hc-bg-surface-2);
  color: var(--hc-accent-cyan);
}

.hc-drawer-menu {
  list-style: none;
  padding: 0;
  margin: 0 0 var(--hc-space-6) 0;
  display: flex;
  flex-direction: column;
  gap: var(--hc-space-2);
}

.hc-drawer-menu li {
  margin-bottom: 0;
}

.hc-drawer-menu a {
  display: block;
  padding: 0.75rem 1rem;
  font-size: var(--hc-text-base);
  font-weight: 600;
  color: var(--hc-text-primary);
  text-decoration: none;
  border-radius: var(--hc-radius-md);
  transition: var(--hc-transition-fast);
}

.hc-drawer-menu a:hover,
.hc-drawer-menu a:focus {
  background-color: var(--hc-bg-surface-2);
  color: var(--hc-accent-cyan);
}

.hc-drawer-menu .sub-menu {
  list-style: none;
  padding-left: var(--hc-space-4);
  margin-top: var(--hc-space-1);
}

.hc-drawer-menu .sub-menu a {
  font-size: var(--hc-text-sm);
  color: var(--hc-text-secondary);
  padding: 0.5rem 0.75rem;
}

/* ==========================================================================
   Search Modal Overlay
   ========================================================================== */

.hc-search-modal {
  position: fixed;
  inset: 0;
  background-color: rgba(15, 23, 42, 0.75);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 100000;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 80px var(--hc-space-4) var(--hc-space-4);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, visibility 0.25s ease;
}

.hc-search-modal.is-active {
  opacity: 1;
  visibility: visible;
}

.hc-search-modal__inner {
  width: 100%;
  max-width: 640px;
  background-color: var(--hc-bg-surface-1);
  border: 1px solid var(--hc-border-strong);
  border-radius: var(--hc-radius-xl);
  padding: var(--hc-space-6);
  box-shadow: var(--hc-shadow-lg);
  transform: translateY(-20px);
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.hc-search-modal.is-active .hc-search-modal__inner {
  transform: translateY(0);
}

.hc-search-modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--hc-space-4);
}

.hc-search-modal__title {
  font-size: var(--hc-text-base);
  font-weight: 700;
  color: var(--hc-text-primary);
  margin: 0;
}

.hc-search-form {
  position: relative;
  display: flex;
  gap: var(--hc-space-2);
}

.hc-search-form input[type="search"] {
  flex-grow: 1;
  padding-left: 2.75rem;
  font-size: var(--hc-text-base);
  height: 50px;
}

.hc-search-form__icon {
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--hc-text-muted);
  pointer-events: none;
}
