/* ==========================================================================
   BUTTER LILY - COMPREHENSIVE RESPONSIVE DESIGN SYSTEM
   Full device coverage:
   - Small Mobile: 320px, 360px, 375px
   - Standard / Large Mobile: 390px, 414px, 430px, 480px
   - Tablet: 600px, 768px, 820px, 900px, 1024px
   - Laptop: 1280px, 1366px, 1440px, 1536px
   - Large Desktop: 1600px, 1920px+
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. GLOBAL FLUID & OVERFLOW GUARDS
   -------------------------------------------------------------------------- */
html, body {
  width: 100%;
  max-width: 100vw;
  overflow-x: hidden;
  box-sizing: border-box;
}

*, *::before, *::after {
  box-sizing: border-box;
}

img, video, canvas, svg {
  max-width: 100%;
  height: auto;
}

iframe, embed, object {
  max-width: 100%;
}

.container {
  width: 100%;
  max-width: var(--container-max, 1320px);
  margin-left: auto;
  margin-right: auto;
  padding-left: clamp(14px, 3.5vw, 32px);
  padding-right: clamp(14px, 3.5vw, 32px);
}

/* --------------------------------------------------------------------------
   2. TOUCH & INTERACTION ACCESSIBILITY (Mobile-friendly)
   -------------------------------------------------------------------------- */
@media (hover: none) and (pointer: coarse) {
  button, .btn, .nav-link, .drawer-link, .header-action-btn, 
  .shade-filter-chip, .shade-pill-btn, .product-wishlist-btn,
  .qty-btn, .accordion-header {
    min-height: 42px;
    touch-action: manipulation;
  }
}

/* --------------------------------------------------------------------------
   3. MOBILE NAVIGATION DRAWER & BACKDROP
   -------------------------------------------------------------------------- */
.mobile-nav-drawer {
  position: fixed;
  inset: 0;
  background-color: rgba(17, 18, 23, 0.65);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.mobile-nav-drawer.active {
  opacity: 1;
  visibility: visible;
}

.drawer-panel {
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  width: clamp(280px, 82vw, 360px);
  background-color: var(--brand-white, #FFFFFF);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
  display: flex;
  flex-direction: column;
  transform: translateX(-100%);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  z-index: 1001;
}

.mobile-nav-drawer.active .drawer-panel {
  transform: translateX(0);
}

.drawer-header {
  padding: 18px 20px;
  border-bottom: 1px solid var(--border-light, #ECE8E1);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--brand-cream, #FDFBF7);
}

.drawer-links {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex-grow: 1;
}

.drawer-link {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-dark, #222328);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 4px;
  border-bottom: 1px solid var(--border-subtle, #F0ECE6);
  transition: color 0.2s ease, padding-left 0.2s ease;
}

.drawer-link:hover, .drawer-link.active {
  color: var(--primary-pink, #D64562);
  padding-left: 6px;
}

.drawer-sublink {
  font-size: 0.9rem;
  color: var(--text-muted, #66676E);
  padding: 6px 12px;
  border-radius: 4px;
  display: block;
  transition: all 0.2s ease;
}

.drawer-sublink:hover, .drawer-sublink.active {
  background-color: var(--primary-light, #FCECEF);
  color: var(--primary-pink, #D64562);
  font-weight: 600;
}

/* --------------------------------------------------------------------------
   4. MODALS & POPUPS RESPONSIVENESS
   -------------------------------------------------------------------------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background-color: rgba(17, 18, 23, 0.65);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  z-index: 1100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  opacity: 0;
  visibility: hidden;
  transition: all 0.25s ease;
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal-card {
  background-color: #FFFFFF;
  border-radius: 12px;
  box-shadow: 0 15px 45px rgba(0, 0, 0, 0.2);
  width: 100%;
  max-width: 650px;
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  position: relative;
  transform: scale(0.95);
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-overlay.active .modal-card {
  transform: scale(1);
}

.modal-close-btn {
  position: absolute;
  top: 14px;
  right: 16px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background-color: #F4F5F7;
  color: #555;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 10;
  transition: background 0.2s;
}

.modal-close-btn:hover {
  background-color: #E2E8F0;
  color: #111;
}

/* --------------------------------------------------------------------------
   5. RESPONSIVE BREAKPOINT TIERS
   -------------------------------------------------------------------------- */

/* === Tier 1: Large Desktop Screens (1440px - 1920px+) === */
@media (min-width: 1440px) {
  .container {
    max-width: 1380px;
  }
  
  .product-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 28px;
  }
  
  .hero-section {
    min-height: 560px;
  }
}

/* === Tier 2: Standard Desktop & Laptops (1024px - 1439px) === */
@media (max-width: 1439px) and (min-width: 1024px) {
  .product-grid {
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 22px;
  }
  
  .main-nav {
    gap: 20px;
  }
}

/* === Tier 3: Tablet & Small Laptops (769px - 1023px) === */
@media (max-width: 1023px) {
  :root {
    --header-height: 74px;
  }

  .main-nav {
    display: none !important;
  }

  .mobile-menu-btn {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 6px;
    background: transparent;
    color: var(--text-dark, #222);
    font-size: 1.4rem;
  }

  .brand-logo-img {
    height: 38px;
    max-width: 180px;
  }

  .header-actions {
    gap: 10px;
  }

  .header-action-btn {
    width: 36px;
    height: 36px;
    font-size: 1rem;
  }

  /* Homepage Sections */
  .hero-heading {
    font-size: clamp(2rem, 4vw, 2.75rem);
  }

  .benefits-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 18px;
  }

  .collections-grid {
    grid-template-columns: 1fr 1fr;
    gap: 20px;
  }

  .testimonials-grid {
    grid-template-columns: 1fr 1fr;
    gap: 18px;
  }

  .product-grid {
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 18px;
  }

  /* Product Details */
  .product-details-grid {
    grid-template-columns: 1fr !important;
    gap: 36px !important;
  }

  /* Shop Layout */
  .shop-layout {
    grid-template-columns: 1fr !important;
    gap: 24px !important;
  }

  .filter-sidebar {
    display: none;
  }

  .mobile-filter-trigger {
    display: flex !important;
  }

  /* Cart & Checkout */
  .cart-grid {
    grid-template-columns: 1fr !important;
    gap: 28px !important;
  }

  .checkout-grid {
    grid-template-columns: 1fr !important;
    gap: 28px !important;
  }

  .order-summary-box {
    position: static !important;
    width: 100% !important;
  }

  /* Account Layout */
  .account-layout {
    grid-template-columns: 1fr !important;
    gap: 24px !important;
  }

  .account-sidebar-card nav {
    flex-direction: row !important;
    flex-wrap: wrap !important;
    gap: 8px !important;
  }

  .account-nav-link {
    margin-bottom: 0 !important;
  }

  /* Story / About */
  .editorial-story-grid {
    grid-template-columns: 1fr !important;
    gap: 32px !important;
  }

  .philosophy-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
  }

  /* Footer */
  .footer-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 32px !important;
  }
}

/* === Tier 4: Tablets & Large Phones (577px - 768px) === */
@media (max-width: 768px) {
  :root {
    --header-height: 68px;
  }

  .announcement-bar {
    font-size: 0.75rem;
    padding: 7px 12px;
  }

  .hero-section {
    min-height: 420px;
    padding: 48px 0;
  }

  .hero-heading {
    font-size: clamp(1.85rem, 5.5vw, 2.35rem);
    line-height: 1.2;
  }

  .hero-sub {
    font-size: 0.95rem;
    margin-bottom: 24px;
  }

  .promo-banner {
    padding: 36px 20px;
  }

  .promo-heading {
    font-size: clamp(1.5rem, 4vw, 2rem);
  }

  .promo-mascot {
    width: 110px;
    opacity: 0.8;
  }

  .floating-butterfly-img {
    display: none;
  }

  .section-title {
    font-size: clamp(1.5rem, 3.5vw, 2rem);
  }

  .product-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 14px;
  }

  .product-details {
    padding: 12px 8px;
  }

  .product-title {
    font-size: 0.875rem;
    line-height: 1.3;
  }

  .product-add-btn {
    padding: 10px;
    font-size: 0.813rem;
  }

  .collections-grid {
    grid-template-columns: 1fr;
    gap: 18px;
  }

  .testimonials-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .philosophy-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .offers-grid {
    grid-template-columns: 1fr 1fr;
    gap: 16px;
  }

  .footer-grid {
    grid-template-columns: 1fr !important;
    gap: 28px !important;
  }

  .footer-bottom {
    flex-direction: column;
    gap: 12px;
    text-align: center;
  }

  .newsletter-form {
    flex-direction: column;
  }

  .newsletter-input, .newsletter-btn {
    width: 100%;
  }

  /* Auth Forms */
  .auth-card {
    padding: clamp(20px, 4vw, 32px) !important;
    margin: 20px auto !important;
  }
}

/* === Tier 5: Standard & Small Mobile (320px - 576px) === */
@media (max-width: 576px) {
  :root {
    --header-height: 62px;
  }

  .container {
    padding-left: 14px;
    padding-right: 14px;
  }

  .brand-logo-img {
    height: 32px;
    max-width: 140px;
  }

  .header-actions {
    gap: 6px;
  }

  .header-action-btn {
    width: 32px;
    height: 32px;
    font-size: 0.9rem;
  }

  .action-badge {
    width: 16px;
    height: 16px;
    font-size: 0.625rem;
    top: 2px;
    right: 2px;
  }

  /* Hero adjustments */
  .hero-section {
    min-height: 380px;
    padding: 36px 0;
  }

  .hero-heading {
    font-size: 1.75rem;
  }

  .hero-ctas {
    flex-direction: column;
    width: 100%;
    gap: 10px;
  }

  .hero-ctas .btn {
    width: 100%;
  }

  .benefits-grid {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  /* Product Card Grid */
  .product-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }

  .product-card {
    border-radius: 6px;
  }

  .product-badges .badge {
    padding: 2px 6px;
    font-size: 0.65rem;
  }

  .product-wishlist-btn {
    width: 32px;
    height: 32px;
    font-size: 0.85rem;
  }

  .product-quick-btn {
    display: none; /* Hide hover quick-view on touch devices */
  }

  .product-title {
    font-size: 0.813rem;
    height: auto;
    margin: 4px 0;
  }

  .product-category {
    font-size: 0.65rem;
  }

  .current-price {
    font-size: 0.938rem;
  }

  .old-price {
    font-size: 0.75rem;
  }

  .product-actions-bar {
    flex-direction: column;
    gap: 10px;
  }

  .product-actions-bar .btn {
    width: 100%;
  }

  /* Cart Items on Mobile */
  .cart-item-row {
    display: grid !important;
    grid-template-columns: 70px 1fr !important;
    gap: 12px !important;
    padding: 14px 0 !important;
    align-items: start !important;
  }

  .cart-item-thumb {
    width: 70px !important;
    height: 70px !important;
  }

  .cart-item-actions {
    grid-column: 1 / -1;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px dashed var(--border-light, #ECE8E1);
  }

  /* Checkout Steps on Mobile */
  .checkout-card {
    padding: 18px 14px !important;
  }

  .form-row, .admin-form-row, .admin-form-row-3 {
    grid-template-columns: 1fr !important;
    gap: 12px !important;
  }

  .offers-grid {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .countdown-timer-box {
    padding: 24px 14px;
  }

  .timer-units {
    gap: 8px;
  }

  .timer-block {
    min-width: 60px;
    padding: 8px;
  }

  .timer-val {
    font-size: 1.4rem;
  }

  /* Modals */
  .modal-card {
    padding: 20px 16px !important;
  }

  /* Breadcrumbs */
  .breadcrumbs {
    font-size: 0.75rem;
    overflow-x: auto;
    white-space: nowrap;
    padding-bottom: 4px;
  }
}

/* === Tier 6: Extra Small Mobile (320px - 360px) === */
@media (max-width: 360px) {
  .hero-heading {
    font-size: 1.5rem;
  }

  .product-grid {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .product-thumb {
    aspect-ratio: 1/1;
  }

  .brand-logo-img {
    height: 28px;
    max-width: 120px;
  }

  .header-actions {
    gap: 4px;
  }

  .btn {
    padding: 11px 18px;
    font-size: 0.875rem;
  }
}
