/**
 * Modern MA5 Mobile Menu & Responsive Header Styling
 * Book Writers Canada Brand System
 */

/* ============================================================
   1. OVERFLOW & BACKDROP
   ============================================================ */

html.ma5menu--overflow {
  overflow-x: hidden !important;
}

html.ma5menu--active {
  overflow: hidden !important;
}

.ma5menu__backdrop {
  position: fixed !important;
  inset: 0 !important;
  background: rgba(3, 8, 18, 0.72) !important;
  backdrop-filter: blur(8px) !important;
  -webkit-backdrop-filter: blur(8px) !important;
  z-index: 100001 !important;
  opacity: 0 !important;
  visibility: hidden !important;
  pointer-events: none !important;
  transition: opacity 0.32s ease, visibility 0.32s ease !important;
}

html.ma5menu--active .ma5menu__backdrop {
  opacity: 1 !important;
  visibility: visible !important;
  pointer-events: auto !important;
}

/* ============================================================
   2. DRAWER CONTAINER (BULLETPROOF OFF-SCREEN POSITIONING)
   ============================================================ */

.ma5menu__container {
  position: fixed !important;
  top: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  left: auto !important;
  width: min(340px, 86vw) !important;
  max-width: 100% !important;
  height: 100vh !important;
  height: 100dvh !important;
  background: #08111e !important;
  transform: translate3d(105%, 0, 0) !important;
  visibility: hidden !important;
  pointer-events: none !important;
  box-shadow: none !important;
  z-index: 100002 !important;
  transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.35s ease, box-shadow 0.35s ease !important;
  display: flex !important;
  flex-direction: column !important;
  overflow: hidden !important;
  font-family: 'Poppins', sans-serif !important;
  border-left: 1px solid rgba(255, 255, 255, 0.08) !important;
}

html.ma5menu--active .ma5menu__container {
  transform: translate3d(0, 0, 0) !important;
  visibility: visible !important;
  pointer-events: auto !important;
  box-shadow: -12px 0 45px rgba(0, 0, 0, 0.65) !important;
}

/* ============================================================
   3. DRAWER HEADER (LOGO & DEDICATED CLOSE BUTTON)
   ============================================================ */

.ma5menu__head {
  height: 68px !important;
  min-height: 68px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  padding: 0 18px !important;
  background: #040910 !important;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08) !important;
  z-index: 20 !important;
  position: relative !important;
}

.ma5menu__home {
  display: flex !important;
  align-items: center !important;
  text-decoration: none !important;
}

.ma5menu__brand-logo {
  width: 145px !important;
  height: auto !important;
  max-height: 38px !important;
  display: block !important;
}

.ma5menu__close-btn {
  width: 38px !important;
  height: 38px !important;
  border-radius: 50% !important;
  background: rgba(255, 255, 255, 0.08) !important;
  border: 1px solid rgba(255, 255, 255, 0.14) !important;
  color: #ffffff !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  font-size: 16px !important;
  cursor: pointer !important;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1) !important;
  padding: 0 !important;
  outline: none !important;
}

.ma5menu__close-btn:hover,
.ma5menu__close-btn:active {
  background: #ee8130 !important;
  border-color: #ee8130 !important;
  color: #ffffff !important;
  transform: rotate(90deg) scale(1.08) !important;
}

/* ============================================================
   4. SLIDING PANELS & TRANSITIONS
   ============================================================ */

.ma5menu__panel {
  position: absolute !important;
  top: 68px !important;
  left: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  width: 100% !important;
  height: calc(100% - 68px) !important;
  overflow-x: hidden !important;
  overflow-y: auto !important;
  -webkit-overflow-scrolling: touch !important;
  display: none !important;
  background: #08111e !important;
  scrollbar-width: thin !important;
  scrollbar-color: #1e293b #08111e !important;
}

.ma5menu__panel::-webkit-scrollbar {
  width: 5px !important;
}

.ma5menu__panel::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.12) !important;
  border-radius: 4px !important;
}

.ma5menu__panel--active {
  display: flex !important;
  flex-direction: column !important;
  justify-content: space-between !important;
  z-index: 10 !important;
}

.ma5menu__panel--active-enter {
  display: flex !important;
  flex-direction: column !important;
  justify-content: space-between !important;
  z-index: 12 !important;
  animation: ma5SlideInRight 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards !important;
}

.ma5menu__panel--parent-enter {
  display: flex !important;
  flex-direction: column !important;
  justify-content: space-between !important;
  z-index: 10 !important;
  animation: ma5SlideOutLeft 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards !important;
}

.ma5menu__panel--active-leave {
  display: flex !important;
  flex-direction: column !important;
  justify-content: space-between !important;
  z-index: 12 !important;
  animation: ma5SlideOutRight 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards !important;
}

.ma5menu__panel--parent-leave {
  display: flex !important;
  flex-direction: column !important;
  justify-content: space-between !important;
  z-index: 10 !important;
  animation: ma5SlideInLeft 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards !important;
}

@keyframes ma5SlideInRight {
  from { transform: translate3d(100%, 0, 0); opacity: 0.5; }
  to { transform: translate3d(0, 0, 0); opacity: 1; }
}

@keyframes ma5SlideOutLeft {
  from { transform: translate3d(0, 0, 0); opacity: 1; }
  to { transform: translate3d(-25%, 0, 0); opacity: 0; }
}

@keyframes ma5SlideInLeft {
  from { transform: translate3d(-25%, 0, 0); opacity: 0; }
  to { transform: translate3d(0, 0, 0); opacity: 1; }
}

@keyframes ma5SlideOutRight {
  from { transform: translate3d(0, 0, 0); opacity: 1; }
  to { transform: translate3d(100%, 0, 0); opacity: 0.5; }
}

/* ============================================================
   5. BACK LEAVE BAR (SUBPANEL HEADER)
   ============================================================ */

.ma5menu__leave {
  display: flex !important;
  align-items: center !important;
  gap: 12px !important;
  padding: 14px 20px !important;
  background: rgba(255, 255, 255, 0.04) !important;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08) !important;
  color: #ee8130 !important;
  font-size: 14px !important;
  font-weight: 600 !important;
  cursor: pointer !important;
  transition: all 0.2s ease !important;
  flex-shrink: 0 !important;
}

.ma5menu__leave:hover,
.ma5menu__leave:active {
  background: rgba(238, 129, 48, 0.12) !important;
  color: #ff9f1c !important;
}

.ma5menu__btn--leave {
  width: 28px !important;
  height: 28px !important;
  border-radius: 50% !important;
  background: rgba(238, 129, 48, 0.18) !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  flex-shrink: 0 !important;
}

.ma5menu__btn--leave::after {
  content: "\f053";
  font-family: "Font Awesome 6 Free" !important;
  font-weight: 900 !important;
  font-size: 11px !important;
  color: #ee8130 !important;
}

/* ============================================================
   6. MENU ITEMS & LISTS
   ============================================================ */

.ma5menu__panel > ul {
  list-style: none !important;
  margin: 0 !important;
  padding: 6px 0 16px !important;
  flex-grow: 1 !important;
}

.ma5menu__panel > ul li {
  margin: 0 !important;
  padding: 0 !important;
  position: relative !important;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05) !important;
}

.ma5menu__panel > ul li a {
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  padding: 13px 20px !important;
  color: #f1f5f9 !important;
  font-size: 14.5px !important;
  font-weight: 500 !important;
  text-decoration: none !important;
  transition: all 0.2s ease !important;
  min-height: 50px !important;
  background: transparent !important;
}

.ma5menu__panel > ul li a:hover,
.ma5menu__panel > ul li a:active {
  color: #ee8130 !important;
  background: rgba(238, 129, 48, 0.08) !important;
  padding-left: 24px !important;
}

.ma5menu__panel > ul li a .ma5menu__link-text {
  display: inline-flex !important;
  align-items: center !important;
  gap: 12px !important;
}

.ma5menu__panel > ul li a i {
  color: #ee8130 !important;
  font-size: 14px !important;
  width: 18px !important;
  text-align: center !important;
  flex-shrink: 0 !important;
  transition: transform 0.2s ease, color 0.2s ease !important;
}

.ma5menu__panel > ul li a:hover i {
  color: #ff9f1c !important;
  transform: scale(1.15) !important;
}

.ma5menu__badge {
  font-size: 11px !important;
  font-weight: 600 !important;
  background: rgba(238, 129, 48, 0.15) !important;
  border: 1px solid rgba(238, 129, 48, 0.3) !important;
  color: #ee8130 !important;
  padding: 2px 9px !important;
  border-radius: 20px !important;
  letter-spacing: 0.2px !important;
  margin-right: 36px !important;
  transition: all 0.2s ease !important;
}

.ma5menu__panel > ul li:hover .ma5menu__badge {
  background: #ee8130 !important;
  color: #ffffff !important;
}

.ma5menu__panel.lvl-1 > ul li a {
  padding: 12px 20px !important;
  font-size: 14px !important;
  justify-content: flex-start !important;
  gap: 12px !important;
}

.ma5menu__btn--enter {
  position: absolute !important;
  right: 16px !important;
  top: 50% !important;
  transform: translateY(-50%) !important;
  width: 28px !important;
  height: 28px !important;
  border-radius: 50% !important;
  background: rgba(255, 255, 255, 0.06) !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  transition: all 0.2s ease !important;
  cursor: pointer !important;
  pointer-events: none !important;
}

.ma5menu__btn--enter::after {
  content: "\f054";
  font-family: "Font Awesome 6 Free" !important;
  font-weight: 900 !important;
  font-size: 10px !important;
  color: #cbd5e1 !important;
}

.ma5menu__panel > ul li:hover .ma5menu__btn--enter {
  background: #ee8130 !important;
}

.ma5menu__panel > ul li:hover .ma5menu__btn--enter::after {
  color: #ffffff !important;
}

/* ============================================================
   7. FOOTER TOOLS (PINNED ACTIONS)
   ============================================================ */

.ma5menu__footer {
  margin-top: auto !important;
  padding: 16px 20px 20px !important;
  background: linear-gradient(180deg, rgba(8, 17, 30, 0.95) 0%, #040910 100%) !important;
  backdrop-filter: blur(12px) !important;
  -webkit-backdrop-filter: blur(12px) !important;
  border-top: 1px solid rgba(255, 255, 255, 0.08) !important;
  flex-shrink: 0 !important;
}

.ma5-tools-wrap {
  display: flex !important;
  flex-direction: column !important;
  gap: 10px !important;
  width: 100% !important;
}

.ma5-phone-btn {
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 8px !important;
  padding: 11px 16px !important;
  border-radius: 10px !important;
  background: rgba(255, 255, 255, 0.06) !important;
  border: 1px solid rgba(255, 255, 255, 0.12) !important;
  color: #ffffff !important;
  font-size: 13.5px !important;
  font-weight: 600 !important;
  text-decoration: none !important;
  transition: all 0.25s ease !important;
}

.ma5-phone-btn i {
  color: #ee8130 !important;
  font-size: 14px !important;
}

.ma5-phone-btn:hover {
  background: #ee8130 !important;
  border-color: #ee8130 !important;
  color: #ffffff !important;
}

.ma5-phone-btn:hover i {
  color: #ffffff !important;
}

.ma5-cta-btn {
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 8px !important;
  padding: 12px 16px !important;
  border-radius: 10px !important;
  background: linear-gradient(135deg, #ee8130 0%, #ff9f1c 100%) !important;
  color: #ffffff !important;
  font-size: 13.5px !important;
  font-weight: 600 !important;
  text-decoration: none !important;
  box-shadow: 0 4px 14px rgba(238, 129, 48, 0.35) !important;
  transition: all 0.25s ease !important;
}

.ma5-cta-btn:hover {
  transform: translateY(-2px) !important;
  box-shadow: 0 6px 20px rgba(238, 129, 48, 0.5) !important;
  color: #ffffff !important;
}

/* ============================================================
   8. HEADER HAMBURGER TOGGLE BUTTON
   ============================================================ */

.header-main .ma5menu__toggle,
.ma5menu__toggle-btn {
  display: none;
  cursor: pointer;
  width: 42px;
  height: 38px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.18);
  padding: 0;
  position: relative;
  vertical-align: middle;
  transition: all 0.25s ease;
  align-items: center;
  justify-content: center;
  outline: none;
}

.header-main .ma5menu__toggle:hover,
.header-main .ma5menu__toggle:active {
  background: #ee8130 !important;
  border-color: #ee8130 !important;
}

.ma5menu__icon-toggle {
  display: inline-block;
  position: absolute;
  margin: auto;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
  width: 20px;
  height: 20px;
  background-image: url("data:image/svg+xml;charset=utf8,%3Csvg%20xmlns%3D%22http://www.w3.org/2000/svg%22%20fill%3D%22%23ffffff%22%20viewBox%3D%220%200%2024%2024%22%3E%3Cpath%20d%3D%22M3%2018h18v-2H3v2zm0-5h18v-2H3v2zm0-7v2h18V6H3z%22/%3E%3C/svg%3E");
  background-position: center;
  background-size: contain;
  background-repeat: no-repeat;
}

header.header-main.showmenu .ma5menu__toggle,
header.showmenu .ma5menu__toggle {
  background: #f1f5f9 !important;
  border-color: #cbd5e1 !important;
}

header.header-main.showmenu .ma5menu__toggle .ma5menu__icon-toggle,
header.showmenu .ma5menu__toggle .ma5menu__icon-toggle {
  background-image: url("data:image/svg+xml;charset=utf8,%3Csvg%20xmlns%3D%22http://www.w3.org/2000/svg%22%20fill%3D%22%230f172a%22%20viewBox%3D%220%200%2024%2024%22%3E%3Cpath%20d%3D%22M3%2018h18v-2H3v2zm0-5h18v-2H3v2zm0-7v2h18V6H3z%22/%3E%3C/svg%3E") !important;
}

header.header-main.showmenu .ma5menu__toggle:hover,
header.showmenu .ma5menu__toggle:hover {
  background: #ee8130 !important;
  border-color: #ee8130 !important;
}

header.header-main.showmenu .ma5menu__toggle:hover .ma5menu__icon-toggle,
header.showmenu .ma5menu__toggle:hover .ma5menu__icon-toggle {
  background-image: url("data:image/svg+xml;charset=utf8,%3Csvg%20xmlns%3D%22http://www.w3.org/2000/svg%22%20fill%3D%22%23ffffff%22%20viewBox%3D%220%200%2024%2024%22%3E%3Cpath%20d%3D%22M3%2018h18v-2H3v2zm0-5h18v-2H3v2zm0-7v2h18V6H3z%22/%3E%3C/svg%3E") !important;
}

.ma5menu__sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ============================================================
   9. RESPONSIVE HEADER MEDIA QUERIES
   ============================================================ */

@media (max-width: 991px) {
  .header-topbar,
  header .header-topbar,
  .topbar-inner {
    display: none !important;
  }

  header,
  header.header-main,
  header.showmenu {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    z-index: 9999 !important;
  }

  .header-navbar,
  header.showmenu .header-navbar,
  header.header-main.showmenu .header-navbar {
    padding: 10px 0 !important;
  }

  .navbar-inner {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 12px !important;
  }

  .header-main .logowrp {
    flex-shrink: 0 !important;
  }

  .header-main .logowrp img {
    width: 155px !important;
    max-width: 155px !important;
    height: auto !important;
    display: block !important;
  }

  .header-main .navwrp,
  .navwrp {
    display: none !important;
  }

  .header-actions {
    display: flex !important;
    align-items: center !important;
    gap: 10px !important;
  }

  .header-actions .hdr-phone {
    display: none !important;
  }

  .header-actions .hdr-chat-btn {
    padding: 7px 13px !important;
    font-size: 12.5px !important;
    gap: 6px !important;
  }

  .header-actions .hdr-cta-btn {
    padding: 8px 16px !important;
    font-size: 13px !important;
    white-space: nowrap !important;
  }

  .header-main .ma5menu__toggle,
  .ma5menu__toggle {
    display: inline-flex !important;
  }

  .mobile-nav-btn,
  .mobile-nav {
    display: none !important;
    visibility: hidden !important;
    pointer-events: none !important;
  }
}

@media (max-width: 575px) {
  .header-navbar,
  header.showmenu .header-navbar,
  header.header-main.showmenu .header-navbar {
    padding: 8px 0 !important;
  }

  .header-main .logowrp img {
    width: 130px !important;
    max-width: 130px !important;
  }

  .header-actions {
    gap: 8px !important;
  }

  .header-actions .hdr-chat-btn {
    display: none !important;
  }

  .header-actions .hdr-cta-btn {
    padding: 7px 12px !important;
    font-size: 12px !important;
    border-radius: 20px !important;
  }

  .header-main .ma5menu__toggle {
    width: 38px !important;
    height: 36px !important;
    border-radius: 6px !important;
  }

  .ma5menu__icon-toggle {
    width: 18px !important;
    height: 18px !important;
  }
}

@media (max-width: 380px) {
  .header-main .logowrp img {
    width: 110px !important;
    max-width: 110px !important;
  }

  .header-actions .hdr-cta-btn {
    padding: 6px 9px !important;
    font-size: 11px !important;
  }

  .header-actions .hdr-cta-btn i {
    display: none !important;
  }
}
