/* ============================================
   Lyvora - Responsive (Refactored)
   Mobile-first, no overflow, touch-friendly
   ============================================ */

/* Prevent horizontal overflow globally */
html, body { max-width: 100%; overflow-x: hidden; }
img, video, iframe { max-width: 100%; height: auto; }

/* ---------- Ultra-wide ---------- */
@media (min-width: 1600px) {
  .container { max-width: 1480px; }
}

/* ---------- Large desktop ---------- */
@media (max-width: 1280px) {
  .container { padding: 0 1.5rem; }
  .footer-grid { grid-template-columns: 1.4fr 1fr 1fr 1fr 1.3fr; gap: 2rem; }
  .nav-search { max-width: 280px; }
}

/* ---------- Tablet large ---------- */
@media (max-width: 1024px) {
  .section { padding: 4.5rem 0; }
  .hero { padding: 5rem 0 4rem; }
  .products { grid-template-columns: repeat(3, 1fr); }
  .cats { grid-template-columns: repeat(3, 1fr); }
  .blog-grid { grid-template-columns: repeat(2, 1fr); }
  .benefits { grid-template-columns: repeat(2, 1fr); }
  .story-grid { grid-template-columns: 1fr; gap: 3rem; }
  .story-img { max-width: 500px; margin: 0 auto; }
  .footer-grid { grid-template-columns: 1.4fr 1fr 1fr; }
  .footer-col:nth-child(4) { grid-column: span 1; }
  .footer-col:nth-child(5) { grid-column: span 3; max-width: 480px; }
  .shop-layout { grid-template-columns: 1fr !important; }
  .cart-layout, .checkout-layout { grid-template-columns: 1fr; }
  .summary { position: static; }
  .account { grid-template-columns: 220px 1fr; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .pd-grid { grid-template-columns: 1fr; gap: 2rem; }
  .auth { grid-template-columns: 1fr; }
  .auth-side { display: none; }
  .contact-grid { grid-template-columns: 1fr; }
  .nav-search { max-width: 220px; }
  .nav-menu a { padding: 0.5rem 0.7rem; font-size: 0.88rem; }
  .nav-row { gap: 1.25rem; }
}

/* ---------- Tablet / Mobile transition ---------- */
@media (max-width: 768px) {
  .nav { display: none; }
  .nav-mobile { display: flex; }
  .bottom-nav { display: block; }
  body { padding-bottom: 96px; }

  .container { padding: 0 1rem; }
  .section { padding: 3rem 0; }
  .section-sm { padding: 2.5rem 0; }
  .hero { padding: 2.5rem 0 2.5rem; }
  .hero-meta { gap: 1.5rem; flex-wrap: wrap; }
  .hero-meta .stat { text-align: center; }

  .section-head { margin-bottom: 2rem; flex-direction: column; align-items: flex-start; }
  .section-head > a, .section-head > .carousel-nav { width: 100%; }
  .section-head > a.btn { justify-content: center; }

  .products { grid-template-columns: repeat(2, 1fr); gap: 0.85rem; }
  .product-body { padding: 0.85rem; gap: 0.3rem; }
  .product-name { font-size: 0.85rem; line-height: 1.35; }
  .product-cat { font-size: 0.65rem; }
  .product-rating { font-size: 0.72rem; }
  .product-rating .stars { font-size: 0.75rem; }
  .price { font-size: 0.98rem; }
  .price-old { font-size: 0.75rem; }
  .product-badges { top: 8px; left: 8px; gap: 4px; }
  .badge { padding: 0.22rem 0.55rem; font-size: 0.6rem; }
  .wish { width: 32px; height: 32px; top: 8px; right: 8px; font-size: 0.85rem; }
  .product-quick { display: none; } /* hide hover-only on touch */
  .product-price-row { padding-top: 0.25rem; gap: 0.35rem; flex-wrap: wrap; }

  .cats { grid-template-columns: 1fr 1fr; gap: 0.7rem; }
  .cat { aspect-ratio: 4/5; }
  .cat-body { padding: 1rem; }
  .cat-name { font-size: 0.95rem; }
  .cat-count { font-size: 0.75rem; }

  .blog-grid { grid-template-columns: 1fr; gap: 1rem; }
  .blog-body { padding: 1.25rem; }
  .blog-title { font-size: 1rem; }
  .benefits {
    grid-template-columns: 1fr;
    padding: 1.1rem;
    gap: 0.85rem;
  }
  .benefit-ico { width: 40px; height: 40px; font-size: 1rem; }
  .benefit-t { font-size: 0.88rem; }
  .benefit-s { font-size: 0.72rem; }

  .footer { padding: 3rem 0 1.5rem; margin-top: 3rem; }
  .footer-grid { grid-template-columns: 1fr; gap: 1.75rem; margin-bottom: 2rem; }
  .footer-col:first-child,
  .footer-col:last-child,
  .footer-col:nth-child(4) { grid-column: span 1; max-width: 100%; }
  .footer .brand { font-size: 1.8rem; }
  .footer-about { max-width: 100%; }
  .footer-bottom { flex-direction: column; align-items: flex-start; font-size: 0.78rem; }

  /* PRODUCT DETAIL */
  .pd-wrap { padding: 1.25rem; border-radius: var(--r-md); }
  .pd-title { font-size: 1.4rem; }
  .pd-price { font-size: 1.6rem; }
  .pd-actions { flex-direction: column; gap: 0.5rem; }
  .pd-actions .btn { min-width: 100%; width: 100%; }
  .pd-actions .wish { width: 100%; height: 48px; border-radius: var(--r-full); position: static !important; }
  .pd-info-list { grid-template-columns: 1fr; gap: 0.6rem; font-size: 0.82rem; }
  .pd-tabs { padding: 1.25rem; }
  .tab-nav { gap: 1rem; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .tab-btn { padding: 0.7rem 0; font-size: 0.85rem; white-space: nowrap; flex-shrink: 0; }
  .qty-row { flex-direction: column; align-items: flex-start; gap: 0.85rem; }

  /* CART - completely revised mobile */
  .cart-items { padding: 1rem; border-radius: var(--r); }
  .cart-item {
    display: grid;
    grid-template-columns: 72px 1fr;
    grid-template-areas:
      "img info"
      "img info"
      "qty remove";
    gap: 0.65rem 0.85rem;
    padding: 1rem 0;
  }
  .cart-item-img { width: 72px; height: 72px; grid-area: img; }
  .cart-item-info { grid-area: info; min-width: 0; }
  .cart-item-info h6 { font-size: 0.92rem; }
  .cart-item-info h6 a { word-break: break-word; }
  .cart-item-info .opts { font-size: 0.75rem; }
  .cart-item-info .price { font-size: 0.92rem; }
  .cart-item .qty-control {
    grid-area: qty;
    width: max-content;
  }
  .cart-item .qty-control button { width: 36px; height: 36px; }
  .cart-item .qty-control input { width: 32px; font-size: 0.85rem; }
  .cart-remove {
    grid-area: remove;
    justify-self: end;
    align-self: center;
    width: 36px;
    height: 36px;
    margin: 0 !important;
  }
  .cart-item > div:last-child { /* item total */
    display: contents;
  }

  .summary { padding: 1.25rem; border-radius: var(--r); }
  .summary h5 { font-size: 1rem; margin-bottom: 1rem; }
  .summary-row { font-size: 0.88rem; padding: 0.45rem 0; }
  .summary-row.total { font-size: 1.05rem; }
  .coupon-row { flex-direction: column; gap: 0.5rem; }
  .coupon-row input { width: 100%; }
  .coupon-row button { width: 100%; padding: 0.65rem 1rem; }

  /* SHOP page mobile */
  .shop-layout { grid-template-columns: 1fr !important; gap: 1rem !important; }
  .mobile-filter-toggle { display: block !important; }
  .filter-sidebar {
    position: fixed;
    top: 0; left: 0;
    width: 320px; max-width: 90vw;
    height: 100vh; height: 100dvh;
    z-index: 200;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    border-radius: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 1.25rem 1.25rem 6rem;
    background: var(--bg-100);
    border-right: 1px solid var(--border-2);
  }
  .filter-sidebar.show { transform: translateX(0); box-shadow: var(--shadow-lg); }
  .toolbar {
    flex-direction: column;
    align-items: stretch;
    padding: 0.85rem 1rem;
    gap: 0.6rem;
  }
  .toolbar > div { width: 100%; }
  .toolbar > div:last-child { justify-content: space-between; }
  .toolbar select { width: 100%; }
  .view-switch { flex-shrink: 0; }
  .pagination { gap: 0.3rem; flex-wrap: wrap; }
  .page-btn { min-width: 38px; height: 38px; padding: 0 0.75rem; font-size: 0.85rem; }

  /* CHECKOUT */
  .checkout-block { padding: 1.25rem; }
  .checkout-block h5 { font-size: 1rem; }
  .form-row { gap: 0.75rem; }
  .form-row.cols-2,
  .form-row.cols-3 { grid-template-columns: 1fr; }
  .form input, .form select, .form textarea { font-size: 16px; /* prevent iOS zoom */ }

  .account { grid-template-columns: 1fr; }
  .account-side { padding: 1.25rem; }
  .account-nav { display: flex; flex-direction: column; gap: 2px; }
  .stats { grid-template-columns: 1fr 1fr; gap: 0.65rem; }
  .stat { padding: 1rem; }
  .stat .val { font-size: 1.35rem; }
  .account-main { padding: 1.25rem; }
  .order-row {
    grid-template-columns: auto 1fr;
    grid-template-areas:
      "ico name"
      "ico meta"
      "price status";
    gap: 0.35rem 0.85rem;
    padding: 0.85rem;
  }
  .order-row > i { grid-area: ico; align-self: center; font-size: 1.2rem; }
  .order-row > div:nth-of-type(1) { grid-area: name; min-width: 0; }
  .order-row .order-name { font-size: 0.88rem; }
  .order-row .order-meta { font-size: 0.75rem; }
  .order-row .order-price { grid-area: price; font-size: 0.95rem; }
  .order-row .pill { grid-area: status; justify-self: end; font-size: 0.68rem; padding: 0.25rem 0.6rem; }

  .auth-form-wrap { padding: 1.5rem 1rem; }
  .auth-form-inner h1 { font-size: 1.6rem; }

  .article-body { padding: 1.5rem 1.25rem; }
  .article-body h1 { font-size: 1.6rem; }
  .article-body h2 { font-size: 1.25rem; }
  .article-body h3 { font-size: 1.1rem; }
  .article-hero { aspect-ratio: 16/10; margin-bottom: 1.5rem; }

  .toasts { top: 70px; right: 12px; left: 12px; }
  .toast { min-width: auto; width: 100%; }

  .contact-info, .contact-form { padding: 1.5rem; }

  .page-head { padding: 1.5rem 0 2rem; }
  .page-head h1 { font-size: 1.75rem; }
  .page-head p { font-size: 0.95rem; }

  .breadcrumb { padding: 1.25rem 0 0; font-size: 0.8rem; }

  /* Bottom nav doesn't overlap content */
  .bottom-nav { left: 8px; right: 8px; bottom: 8px; padding: 0.35rem; }
  .bottom-nav-item { padding: 0.45rem 0.25rem; font-size: 0.65rem; }
  .bottom-nav-item i { font-size: 1rem; }

  /* Touch targets - minimum 44px */
  .btn { min-height: 44px; padding: 0.85rem 1.5rem; }
  .btn-sm { min-height: 38px; padding: 0.55rem 1.1rem; }
  .icon-btn { min-width: 44px; min-height: 44px; }

  /* Drawer */
  .drawer { width: 88vw; max-width: 320px; }
  .drawer-nav a { padding: 1rem 1rem; font-size: 1rem; min-height: 48px; }

  /* Eyebrow + Section titles */
  .section-title { font-size: 1.6rem; }
  .section-sub { font-size: 0.9rem; }
  .eyebrow { font-size: 0.7rem; padding: 0.3rem 0.7rem; }
}

/* ---------- Small mobile ---------- */
@media (max-width: 480px) {
  .container { padding: 0 0.85rem; }
  .hero-title { font-size: 2.1rem; line-height: 1.05; }
  .hero-sub { font-size: 0.95rem; }
  .hero-cta { flex-direction: column; width: 100%; }
  .hero-cta .btn { width: 100%; justify-content: center; }
  .hero-meta { gap: 1rem; }
  .hero-meta .num { font-size: 1.5rem; }
  .hero-meta .lbl { font-size: 0.7rem; }

  .not-found h2 { font-size: 1.5rem; }
  .not-found .actions { flex-direction: column; width: 100%; }
  .not-found .actions .btn { width: 100%; justify-content: center; }

  .stats { grid-template-columns: 1fr; }
  .auth-stats { gap: 1rem; flex-wrap: wrap; }

  .pd-wrap { padding: 1rem; }
  .pd-title { font-size: 1.25rem; }
  .pd-price { font-size: 1.45rem; }
  .pd-price-row { flex-wrap: wrap; gap: 0.5rem; }
  .pd-tabs { padding: 1rem; }

  .article-body { padding: 1.25rem 1rem; }
  .article-body h1 { font-size: 1.4rem; }

  .cart-items { padding: 0.85rem; }
  .cart-item-img { width: 64px; height: 64px; }
  .cart-item { grid-template-columns: 64px 1fr; }

  .summary { padding: 1rem; }

  .checkout-block { padding: 1rem; }
  .checkout-block h5 { font-size: 0.95rem; gap: 0.5rem; }
  .step-num { width: 24px; height: 24px; font-size: 0.75rem; }

  .pay-opt { padding: 0.85rem; gap: 0.65rem; }
  .pay-opt .name { font-size: 0.88rem; }
  .pay-opt .desc { font-size: 0.72rem; }

  .blog-img { aspect-ratio: 16/9; }
  .blog-body { padding: 1rem; }
  .blog-meta { gap: 0.5rem; font-size: 0.72rem; flex-wrap: wrap; }

  .ci-row { padding: 0.85rem 0; gap: 0.85rem; }
  .ci-row .ico { width: 36px; height: 36px; }
  .ci-row .val { font-size: 0.92rem; }

  .filter-sidebar { width: 88vw; padding: 1rem 1rem 5rem; }
  .filter-block { padding: 1rem 0; }
  .filter-t { font-size: 0.8rem; }

  .pagination { gap: 0.25rem; }
  .page-btn { min-width: 34px; height: 34px; padding: 0 0.5rem; font-size: 0.8rem; }
}

/* ---------- Landscape phones ---------- */
@media (max-width: 768px) and (orientation: landscape) {
  .hero { padding: 2rem 0; }
  .hero-title { font-size: 2rem; }
}

/* ---------- Hover capability detection ---------- */
@media (hover: none) {
  /* Touch devices: keep product-quick visible at bottom */
  .product:hover .product-img-wrap img,
  .product:hover { transform: none !important; }
}

/* ---------- Reduce motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
  .reveal { opacity: 1; transform: none; }
}
