/* ==========================================================================
   MATEREX BAKERY — HIGH-MOTION EDITORIAL MOBILE RESPONSIVE & SCENE LOCK ENGINE
   Domain: materex.com.ng
   ========================================================================== */

/* --------------------------------------------------------------------------
   0. ROOT & CANVAS VIEWPORT LOCKDOWN ENGINE (ZERO HORIZONTAL DRIFT)
   -------------------------------------------------------------------------- */
html, body {
  width: 100% !important;
  max-width: 100% !important;
  overflow-x: hidden !important;
  position: relative;
}

body.body-menu-open {
  overflow: hidden !important;
  touch-action: pan-y;
  height: 100vh;
}

.site-header, main, footer, section, .container {
  max-width: 100%;
  box-sizing: border-box;
}

img, svg, video, iframe {
  max-width: 100%;
}

/* --------------------------------------------------------------------------
   1. DESKTOP DEFAULT HEADER & ACTIONS (min-width: 1025px)
   -------------------------------------------------------------------------- */
@media (min-width: 1025px) {
  .materex-menu-toggle {
    display: none !important;
  }
}

/* --------------------------------------------------------------------------
   2. STAGGERED EDITORIAL MOBILE MENU DRAWER OVERLAY
   -------------------------------------------------------------------------- */
.materex-menu-overlay {
  position: fixed;
  inset: 0;
  z-index: 2500;
  pointer-events: none;
  visibility: hidden;
  display: none;
  overflow: hidden;
  width: 100vw;
  max-width: 100%;
}

.materex-menu-overlay.is-active {
  pointer-events: auto;
  visibility: visible;
  display: block;
}

/* Layer 1: Dark Onyx Background Backing */
.materex-menu-layer-black {
  position: absolute;
  inset: 0;
  background: var(--dark-void);
  transform: translateX(100%);
  transition: transform 0.5s cubic-bezier(0.22, 1, 0.36, 1);
  opacity: 0.95;
}

/* Layer 2: Materex Orange Accent Streak */
.materex-menu-layer-orange {
  position: absolute;
  top: 0;
  bottom: 0;
  right: 0;
  width: 100%;
  max-width: 480px;
  background: var(--primary-orange);
  transform: translateX(100%);
  transition: transform 0.5s cubic-bezier(0.22, 1, 0.36, 1) 0.08s;
}

/* Layer 3: Main Editorial White/Cream Surface Panel */
.materex-menu-panel {
  position: absolute;
  top: 0;
  bottom: 0;
  right: 0;
  width: 88%;
  max-width: 420px;
  background: var(--bg-warm-cream);
  box-shadow: -20px 0 50px rgba(0, 0, 0, 0.3);
  transform: translateX(100%);
  transition: transform 0.5s cubic-bezier(0.22, 1, 0.36, 1) 0.16s;
  display: flex;
  flex-direction: column;
  padding: 2.5rem 2rem;
  overflow-y: auto;
}

.materex-menu-overlay.is-active .materex-menu-layer-black {
  transform: translateX(0);
}

.materex-menu-overlay.is-active .materex-menu-layer-orange {
  transform: translateX(0);
}

.materex-menu-overlay.is-active .materex-menu-panel {
  transform: translateX(0);
}

/* Menu Item Links with Index Numbers & Stagger Motion */
.materex-nav-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  margin: 2.5rem 0;
}

.materex-nav-item {
  opacity: 0;
  transform: translateX(30px) rotate(3deg);
  transition: opacity 0.4s var(--ease-fluid), transform 0.4s var(--ease-fluid);
}

.materex-menu-overlay.is-active .materex-nav-item {
  opacity: 1;
  transform: translateX(0) rotate(0deg);
}

.materex-menu-overlay.is-active .materex-nav-item:nth-child(1) { transition-delay: 0.25s; }
.materex-menu-overlay.is-active .materex-nav-item:nth-child(2) { transition-delay: 0.30s; }
.materex-menu-overlay.is-active .materex-nav-item:nth-child(3) { transition-delay: 0.35s; }
.materex-menu-overlay.is-active .materex-nav-item:nth-child(4) { transition-delay: 0.40s; }
.materex-menu-overlay.is-active .materex-nav-item:nth-child(5) { transition-delay: 0.45s; }
.materex-menu-overlay.is-active .materex-nav-item:nth-child(6) { transition-delay: 0.50s; }
.materex-menu-overlay.is-active .materex-nav-item:nth-child(7) { transition-delay: 0.55s; }

.materex-nav-link {
  display: flex;
  align-items: baseline;
  gap: 1rem;
  font-family: var(--font-serif);
  font-size: 1.85rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--dark-onyx);
  transition: color var(--transition-fast), transform var(--transition-fast);
}

.materex-nav-link:hover {
  color: var(--primary-orange);
  transform: translateX(8px);
}

.materex-nav-idx {
  font-family: var(--font-sans);
  font-size: 0.85rem;
  font-weight: 800;
  color: var(--amber-gold-dark);
  letter-spacing: 0.1em;
}

/* Custom Animated Menu Toggle Button */
.materex-menu-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--bg-warm-surface);
  border: 1px solid rgba(28, 25, 23, 0.12);
  padding: 0.5rem 1rem;
  border-radius: var(--radius-pill);
  cursor: pointer;
  font-family: var(--font-sans);
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--dark-onyx);
  transition: all var(--transition-fast);
  white-space: nowrap;
  flex-shrink: 0;
  min-height: 38px;
}

.materex-menu-toggle:hover {
  background: var(--primary-orange-alpha);
  color: var(--primary-orange);
  border-color: var(--primary-orange);
}

.materex-toggle-icon {
  position: relative;
  width: 16px;
  height: 16px;
  display: inline-block;
  flex-shrink: 0;
}

.materex-toggle-icon span {
  position: absolute;
  background: currentColor;
  border-radius: 2px;
  transition: transform 0.3s ease;
}

.materex-toggle-icon span:nth-child(1) {
  top: 7px;
  left: 0;
  width: 16px;
  height: 2px;
}

.materex-toggle-icon span:nth-child(2) {
  top: 0;
  left: 7px;
  width: 2px;
  height: 16px;
}

.materex-menu-toggle.is-open .materex-toggle-icon span:nth-child(1) {
  transform: rotate(45deg);
}

.materex-menu-toggle.is-open .materex-toggle-icon span:nth-child(2) {
  transform: rotate(45deg);
}

/* --------------------------------------------------------------------------
   3. TABLET VIEWPORT ENGINE (max-width: 1024px)
   -------------------------------------------------------------------------- */
@media (max-width: 1024px) {
  .nav-menu {
    display: none !important;
  }

  .materex-menu-toggle {
    display: inline-flex !important;
  }

  .phone-pill {
    font-size: 0.825rem;
    padding: 0.4rem 0.75rem;
  }

  .header-actions {
    gap: 0.75rem;
    margin-left: auto;
  }

  .header-actions .btn-pill {
    padding: 0.5rem 1rem !important;
    font-size: 0.85rem !important;
    width: auto !important;
  }

  /* Universal Single-Column Mobile Stack for all Grids (Calculator, B2B, About Us Origin, etc.) */
  .calculator-grid,
  .b2b-grid,
  .about-origin-grid,
  .footer-grid,
  div[style*="grid-template-columns: 1.1fr 0.9fr"],
  div[style*="grid-template-columns:1.1fr 0.9fr"],
  div[style*="grid-template-columns: 1fr 1fr"],
  div[style*="grid-template-columns:1fr 1fr"],
  div[style*="grid-template-columns: 1fr 1.2fr"],
  div[style*="grid-template-columns:1fr 1.2fr"],
  div[style*="grid-template-columns: 1.1fr 1fr"],
  div[style*="grid-template-columns:1.1fr 1fr"],
  div[style*="grid-template-columns:1fr 1.1fr"],
  div[style*="grid-template-columns: 1fr 1.1fr"] {
    grid-template-columns: 1fr !important;
    gap: 2rem !important;
  }

  .hero-liquid-bg .container {
    grid-template-columns: 1fr !important;
    text-align: center;
    gap: 2.5rem !important;
  }

  .hero-liquid-bg .reveal-on-scroll {
    display: flex;
    flex-direction: column;
    align-items: center;
  }

  .hero-liquid-bg p {
    margin-left: auto;
    margin-right: auto;
  }

  .hero-liquid-bg div[style*="display:flex"] {
    justify-content: center;
  }
}

/* --------------------------------------------------------------------------
   4. MOBILE VIEWPORT ENGINE (max-width: 767px)
   -------------------------------------------------------------------------- */
@media (max-width: 767px) {
  html {
    font-size: 15px;
  }

  .container {
    padding: 0 1.25rem !important;
  }

  .section-padding {
    padding: 2.5rem 0 !important;
  }

  /* Compact Hero Section & Page Main Breathing Room below Fixed Header */
  .hero-liquid-bg {
    padding-top: 4.75rem !important;
  }

  main {
    padding-top: 4.75rem !important;
  }

  h1 {
    font-size: 2.15rem !important;
    line-height: 1.15 !important;
  }

  h2 {
    font-size: 1.65rem !important;
    line-height: 1.2 !important;
  }

  /* Header Layout Alignment & Centering on Mobile */
  .site-header {
    padding: 0.5rem 0 !important;
  }

  .site-header.scrolled {
    padding: 0.4rem 0 !important;
  }

  /* Header Mobile Dual Logo Switch: Show Icon Logo, Hide Desktop Wordmark */
  .logo-desktop {
    display: none !important;
  }

  .logo-mobile {
    display: block !important;
    height: 38px !important;
    width: 38px !important;
    object-fit: contain !important;
    border-radius: 8px;
    flex-shrink: 0;
  }

  .nav-container {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    width: 100% !important;
  }

  /* Hide Phone Pill in Mobile Header Bar to eliminate crowding */
  .header-actions .phone-pill {
    display: none !important;
  }

  .header-actions {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    flex: 1 !important;
    margin-left: 0.75rem !important;
    gap: 0.5rem !important;
  }

  /* Center Order Now button in the mobile header bar */
  .header-actions .btn-pill {
    margin: 0 auto !important;
    padding: 0.45rem 0.85rem !important;
    font-size: 0.8rem !important;
    height: 36px;
    width: auto !important;
    justify-content: center;
    align-items: center !important;
  }

  .materex-menu-toggle {
    margin-left: auto !important;
    padding: 0.45rem 0.75rem !important;
    font-size: 0.8rem !important;
    height: 36px;
    gap: 0.4rem;
    align-items: center !important;
    flex-shrink: 0;
  }

  /* Glass Cards Mobile Spacing & Containment */
  .glass-card, .glass-card-dark, .glass-story-card, .glass-story-card-dark {
    padding: 1.25rem !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
  }

  /* Footer Mobile Professional Centered Alignment & Edge Spacing */
  .site-footer {
    padding-top: 3.5rem !important;
    padding-bottom: 2rem !important;
    padding-left: 1.5rem !important;
    padding-right: 1.5rem !important;
    border-top-left-radius: 40px !important;
    border-top-right-radius: 40px !important;
  }

  .footer-grid {
    grid-template-columns: 1fr !important;
    gap: 2.25rem !important;
    text-align: center !important;
    justify-items: center !important;
  }

  .footer-brand {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    text-align: center !important;
  }

  .footer-brand p {
    max-width: 320px !important;
    margin: 0.75rem auto 0 !important;
    text-align: center !important;
    line-height: 1.6 !important;
  }

  .footer-column {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    text-align: center !important;
    width: 100% !important;
  }

  .footer-column h4 {
    text-align: center !important;
    margin-bottom: 1rem !important;
    font-size: 0.95rem !important;
  }

  .footer-links {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    text-align: center !important;
    gap: 0.75rem !important;
    width: 100% !important;
  }

  .footer-links a {
    font-size: 0.9rem !important;
    text-align: center !important;
  }

  .footer-bottom {
    flex-direction: column !important;
    text-align: center !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 0.75rem !important;
    padding-top: 1.5rem !important;
    padding-left: 1rem !important;
    padding-right: 1rem !important;
  }

  .allergen-footer-banner {
    flex-direction: column !important;
    text-align: center !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 1.25rem 1.25rem !important;
    margin-bottom: 2.5rem !important;
  }

  /* 360 Carousel Mobile Fit */
  #carousel-360-stage {
    padding: 2rem 1rem !important;
  }

  /* Checkout Drawer Mobile Width */
  .checkout-drawer {
    max-width: 100% !important;
  }
}

/* --------------------------------------------------------------------------
   5. SMALL MOBILE VIEWPORT ENGINE (max-width: 480px)
   -------------------------------------------------------------------------- */
@media (max-width: 480px) {
  .container {
    padding: 0 1rem !important;
  }

  .hero-liquid-bg {
    padding-top: 4.5rem !important;
  }

  main {
    padding-top: 4.5rem !important;
  }

  h1 {
    font-size: 1.95rem !important;
  }

  h2 {
    font-size: 1.55rem !important;
  }

  .logo-mobile {
    height: 36px !important;
    width: 36px !important;
  }

  .header-actions {
    margin-left: 0.5rem !important;
    gap: 0.35rem !important;
  }

  .header-actions .btn-pill {
    padding: 0.4rem 0.65rem !important;
    font-size: 0.775rem !important;
    height: 36px;
    gap: 0.35rem !important;
  }

  .materex-menu-toggle {
    padding: 0.4rem 0.65rem !important;
    font-size: 0.775rem !important;
    height: 36px;
    gap: 0.35rem !important;
  }

  .materex-menu-panel {
    width: 92% !important;
    padding: 2rem 1.25rem !important;
  }

  .materex-nav-link {
    font-size: 1.45rem !important;
  }
}
