/**
 * Alavi mobile shell — header drawer + footer + site-wide responsive.
 * Breakpoint: 899px (tablet/phone).
 */

/* —— Hide redundant Elementor/theme search in header (keep Alavi icon search) —— */
.alavi-site-header .elementor-widget-search-form,
.alavi-site-header .elementor-search-form,
.elementor-location-header .elementor-widget-search-form,
.elementor-location-header form.search-form:not(.alavi-header-search__form),
.alavi-site-header form.search-form:not(.alavi-header-search__form),
.alavi-site-header .search-field:not(.alavi-header-search__input),
.elementor-location-header input[type="search"]:not(.alavi-header-search__input) {
  display: none !important;
}

/* —— Mobile nav toggle (hidden on desktop) —— */
.alavi-mobile-nav-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  margin: 0;
  padding: 0;
  border: 1px solid rgba(201, 162, 39, 0.35);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
  color: #f5f5f5;
  cursor: pointer;
  flex: 0 0 auto;
  z-index: 30;
  transition: border-color 200ms ease, background 200ms ease, color 200ms ease;
}

.alavi-mobile-nav-toggle:hover,
.alavi-mobile-nav-toggle:focus-visible {
  border-color: rgba(201, 162, 39, 0.8);
  background: rgba(201, 162, 39, 0.14);
  color: #c9a227;
  outline: none;
}

.alavi-mobile-nav-toggle__bars {
  display: flex;
  flex-direction: column;
  gap: 5px;
  width: 18px;
}

.alavi-mobile-nav-toggle__bars span {
  display: block;
  height: 2px;
  width: 100%;
  border-radius: 2px;
  background: currentColor;
  transition: transform 220ms ease, opacity 220ms ease;
  transform-origin: center;
}

html.alavi-mobile-nav-open .alavi-mobile-nav-toggle__bars span:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}

html.alavi-mobile-nav-open .alavi-mobile-nav-toggle__bars span:nth-child(2) {
  opacity: 0;
}

html.alavi-mobile-nav-open .alavi-mobile-nav-toggle__bars span:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

.alavi-mobile-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1100;
  background: rgba(0, 0, 0, 0.55);
  opacity: 0;
  pointer-events: none;
  transition: opacity 240ms ease;
}

html.alavi-mobile-nav-open .alavi-mobile-backdrop {
  opacity: 1;
  pointer-events: auto;
}

.alavi-mobile-backdrop[hidden] {
  display: none !important;
}

.alavi-mobile-drawer {
  position: fixed;
  top: 0;
  bottom: 0;
  inset-inline-start: 0;
  width: min(86vw, 340px);
  z-index: 1101;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: max(16px, env(safe-area-inset-top)) 18px max(20px, env(safe-area-inset-bottom));
  background:
    linear-gradient(165deg, rgba(22, 20, 16, 0.99) 0%, rgba(8, 8, 8, 0.99) 100%);
  border-inline-end: 1px solid rgba(201, 162, 39, 0.28);
  box-shadow: 12px 0 40px rgba(0, 0, 0, 0.45);
  color: #f5f5f5;
  transform: translateX(-104%);
  transition: transform 280ms cubic-bezier(0.22, 1, 0.36, 1);
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  font-family: var(--alavi-font, Vazirmatn, Tahoma, sans-serif);
}

[dir="rtl"] .alavi-mobile-drawer,
.rtl .alavi-mobile-drawer {
  transform: translateX(104%);
}

html.alavi-mobile-nav-open .alavi-mobile-drawer {
  transform: translateX(0) !important;
}

.alavi-mobile-drawer[hidden] {
  display: none !important;
}

html.alavi-mobile-nav-open .alavi-mobile-drawer[hidden] {
  display: flex !important;
}

.alavi-mobile-drawer__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.alavi-mobile-drawer__brand {
  font-size: 1.15rem;
  font-weight: 700;
  color: #c9a227;
  text-decoration: none;
}

.alavi-mobile-drawer__close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 12px;
  background: transparent;
  color: #f5f5f5;
  cursor: pointer;
}

.alavi-mobile-drawer__close:hover,
.alavi-mobile-drawer__close:focus-visible {
  border-color: rgba(201, 162, 39, 0.6);
  color: #c9a227;
  outline: none;
}

.alavi-mobile-menu {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.alavi-mobile-menu a {
  display: block;
  padding: 12px 14px;
  border-radius: 12px;
  color: #f0f0f0;
  text-decoration: none;
  font-size: 1rem;
  font-weight: 600;
  transition: background 180ms ease, color 180ms ease;
}

.alavi-mobile-menu a:hover,
.alavi-mobile-menu a:focus-visible,
.alavi-mobile-menu .current-menu-item > a,
.alavi-mobile-menu .current_page_item > a {
  background: rgba(201, 162, 39, 0.14);
  color: #c9a227;
  outline: none;
}

.alavi-mobile-menu .sub-menu {
  list-style: none;
  margin: 0 0 6px;
  padding: 0 10px 0 0;
}

.alavi-mobile-menu .sub-menu a {
  font-size: 0.92rem;
  font-weight: 500;
  padding: 10px 12px;
  color: rgba(245, 245, 245, 0.78);
}

.alavi-mobile-drawer__foot {
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.alavi-mobile-drawer__cta {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 16px;
  border-radius: 12px;
  background: #c9a227;
  color: #111 !important;
  font-weight: 700;
  text-decoration: none;
  transition: filter 180ms ease, transform 180ms ease;
}

.alavi-mobile-drawer__cta:hover,
.alavi-mobile-drawer__cta:focus-visible {
  filter: brightness(1.05);
  transform: translateY(-1px);
  outline: none;
}

html.alavi-mobile-nav-open {
  overflow: hidden;
}

/* —— Bottom mobile tab bar (5 icons) —— */
.alavi-mobile-tabbar {
  display: none;
  position: fixed;
  inset-inline: 0;
  bottom: 0;
  z-index: 1050;
  align-items: stretch;
  justify-content: space-around;
  gap: 2px;
  min-height: 58px;
  padding: 6px 4px max(8px, env(safe-area-inset-bottom));
  background: rgba(10, 10, 10, 0.94);
  backdrop-filter: blur(16px) saturate(140%);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
  border-top: 1px solid rgba(201, 162, 39, 0.28);
  box-shadow: 0 -8px 28px rgba(0, 0, 0, 0.28);
  font-family: var(--alavi-font, Vazirmatn, Tahoma, sans-serif);
}

.alavi-mobile-tabbar__item {
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-width: 0;
  padding: 4px 2px;
  border-radius: 12px;
  color: rgba(245, 245, 245, 0.62);
  text-decoration: none;
  transition: color 180ms ease, background 180ms ease;
}

.alavi-mobile-tabbar__item:hover,
.alavi-mobile-tabbar__item:focus-visible {
  color: #c9a227;
  outline: none;
}

.alavi-mobile-tabbar__item.is-active {
  color: #c9a227;
  background: rgba(201, 162, 39, 0.12);
}

.alavi-mobile-tabbar__icon {
  display: flex;
  line-height: 0;
}

.alavi-mobile-tabbar__label {
  font-size: 0.68rem;
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

@media (max-width: 899px) {
  .alavi-mobile-nav-toggle {
    display: inline-flex;
  }

  /* Search + account + hamburger clustered on visual LEFT */
  .alavi-mobile-header-tools {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    align-items: center !important;
    justify-content: flex-end !important;
    gap: 6px !important;
    margin-inline-start: auto !important;
    order: 99;
    flex: 0 0 auto !important;
    max-width: none !important;
  }

  .alavi-mobile-header-tools > .elementor-element,
  .alavi-mobile-header-tools > .alavi-header-actions,
  .alavi-mobile-header-tools .alavi-header-auth-widget {
    width: auto !important;
    max-width: none !important;
    margin: 0 !important;
    flex: 0 0 auto !important;
  }

  .alavi-mobile-nav-toggle--left {
    margin-inline-start: 0 !important;
    order: 0;
  }

  .alavi-mobile-tabbar {
    display: flex !important;
  }

  body {
    padding-bottom: calc(64px + env(safe-area-inset-bottom)) !important;
  }

  /* Compact sticky header row */
  .alavi-site-header .alavi-header-inner,
  .alavi-site-header .alavi-header-inner.e-con,
  .alavi-site-header > .e-con.alavi-header-inner,
  .alavi-site-header .alavi-header-inner > .e-con-inner {
    min-height: 56px !important;
    gap: 10px !important;
    padding-inline: 10px !important;
  }

  .alavi-site-header .elementor-widget-theme-site-logo img,
  .alavi-site-header .elementor-widget-theme-site-logo .elementor-widget-container,
  .alavi-site-header .elementor-widget-theme-site-logo a {
    max-width: 96px !important;
    max-height: 40px !important;
  }

  /* Hide desktop nav — drawer replaces it */
  .alavi-site-header .elementor-widget-nav-menu,
  .alavi-site-header .elementor-nav-menu--main,
  .alavi-site-header nav.elementor-nav-menu--dropdown {
    display: none !important;
  }

  /* Compact search + auth next to hamburger */
  .alavi-site-header .alavi-header-actions,
  .alavi-mobile-header-tools .alavi-header-actions {
    display: flex !important;
    align-items: center !important;
    gap: 6px !important;
    margin: 0 !important;
    order: 0;
  }

  .alavi-header-search__toggle {
    width: 40px;
    height: 40px;
  }

  .alavi-mobile-header-tools .alavi-header-auth__label,
  .alavi-mobile-header-tools .alavi-header-auth--eh .eh-modal-button-text,
  .alavi-mobile-header-tools .alavi-header-auth--eh .eh-modal-account-button-text {
    display: none !important;
  }

  .alavi-mobile-header-tools .alavi-header-auth__chevron {
    display: none !important;
  }

  /* —— Site footer (above tab bar) —— */
  .alavi-site-footer,
  .elementor-location-footer .alavi-site-footer,
  .elementor-location-footer {
    padding-block: 36px 28px !important;
    margin-bottom: 0 !important;
  }

  .alavi-site-footer .e-con,
  .alavi-site-footer .e-con-inner,
  .elementor-location-footer .e-con,
  .elementor-location-footer .e-con-inner {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 22px !important;
    text-align: center !important;
  }

  .alavi-site-footer .elementor-widget-heading,
  .alavi-site-footer .elementor-heading-title,
  .alavi-site-footer .elementor-widget-text-editor,
  .elementor-location-footer .elementor-heading-title,
  .elementor-location-footer .elementor-widget-text-editor {
    text-align: center !important;
  }

  .alavi-site-footer .elementor-nav-menu,
  .elementor-location-footer .elementor-nav-menu,
  .alavi-site-footer .elementor-nav-menu--main,
  .elementor-location-footer .elementor-nav-menu--main {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    gap: 8px !important;
  }

  .alavi-site-footer .elementor-nav-menu a,
  .elementor-location-footer .elementor-nav-menu a {
    padding: 8px 12px !important;
    font-size: 0.95rem !important;
  }

  .alavi-site-footer .elementor-button-wrapper,
  .elementor-location-footer .elementor-button-wrapper {
    justify-content: center !important;
  }

  .alavi-site-footer .elementor-button,
  .elementor-location-footer .elementor-button {
    width: 100%;
    max-width: 280px;
    justify-content: center;
  }

  /* —— Site-wide content —— */
  .elementor-section,
  .e-con.e-parent {
    --padding-inline: 16px;
  }

  /* Hero: keep brand text above photo; kill empty photo min-height */
  body.home .alavi-hero-split,
  .alavi-hero-split {
    padding-inline: 0 !important;
  }

  .alavi-hero-split .alavi-hero-inner,
  .alavi-hero-split .e-con-inner,
  body.home .alavi-hero-split > .e-con {
    flex-direction: column !important;
  }

  .alavi-hero-split .alavi-hero-photo {
    min-height: 0 !important;
  }

  .alavi-page-band,
  .alavi-injected-band {
    padding-inline: 16px !important;
  }

  .alavi-articles-carousel,
  .alavi-books-carousel,
  .alavi-podcasts {
    padding-inline: 0;
  }

  body {
    overflow-x: clip;
  }

  .elementor img,
  .site-main img {
    max-width: 100%;
    height: auto;
  }

  .alavi-podcast-single,
  .alavi-iv-article {
    padding-inline: 16px;
  }

  .tutor-course-list,
  .etlms-course-list-col {
    grid-template-columns: 1fr !important;
  }
}

@media (max-width: 639px) {
  .alavi-mobile-drawer {
    width: min(92vw, 320px);
  }

  .alavi-site-header .elementor-widget-theme-site-logo img,
  .alavi-site-header .elementor-widget-theme-site-logo a {
    max-width: 84px !important;
    max-height: 36px !important;
  }

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

  .elementor-location-footer {
    padding-inline: 16px !important;
  }

  .alavi-mobile-tabbar__label {
    font-size: 0.62rem;
  }
}

@media (min-width: 900px) {
  .alavi-mobile-nav-toggle,
  .alavi-mobile-backdrop,
  .alavi-mobile-drawer,
  .alavi-mobile-tabbar {
    display: none !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  .alavi-mobile-drawer,
  .alavi-mobile-backdrop,
  .alavi-mobile-nav-toggle__bars span,
  .alavi-mobile-tabbar__item {
    transition: none !important;
  }
}
