/* ============================================================================
   EOH — Mobile Optimization (India-first, all viewports, v12.5)
   Adds: bottom nav, sticky add-to-cart, WhatsApp, tap targets, fluid type
   99% of visitors are on phones (Apple + Android), some on tablets.
   Don't break the desktop aesthetic.
   ============================================================================ */

/* ============================================================
   GLOBAL MOBILE PRIMITIVES
   ============================================================ */

/* Disable 300ms tap delay on touch devices */
html { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
body { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

/* Prevent text from being selected accidentally (esp. on labels) */
.no-select { -webkit-user-select: none; user-select: none; }

/* Smooth, native-feeling scroll */
html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

/* ============================================================
   FLUID TYPE SCALE — base size scales with viewport
   12px (smallest) on 320px → 14px on 1280px+
   ============================================================ */
:root {
  --mobile-base: clamp(0.95rem, 0.85rem + 0.4vw, 1rem);
  --mobile-sm:   clamp(0.78rem, 0.72rem + 0.3vw, 0.85rem);
  --mobile-xs:   clamp(0.72rem, 0.68rem + 0.2vw, 0.78rem);
}

/* Force minimum readable size on small viewports */
@media (max-width: 480px) {
  .trust-strip span, .trust-strip__text, .footer small, .footer .ja--sm,
  .breadcrumb a, .breadcrumb span, .modal small, .nav__meta {
    font-size: var(--mobile-xs) !important;
  }
  .trust-strip__pill, .pill, .badge, .tag {
    font-size: var(--mobile-sm) !important;
  }
}

/* ============================================================
   TAP TARGETS — 44px minimum (Apple HIG), 48dp+ (Material)
   Applied to footer links + small content links on mobile
   ============================================================ */
@media (max-width: 768px) {
  .footer a,
  .footer-link,
  .nav a[href],
  .breadcrumb a,
  .trust-strip a,
  .account-link,
  .meta a,
  .back-link,
  .return-link {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    padding: 8px 0;
  }
  /* Buttons get a 48px height */
  button.btn, .btn {
    min-height: 48px;
    padding-top: 14px;
    padding-bottom: 14px;
  }
  /* Mobile menu burger (already 36-40px, bump to 48px) */
  .nav__burger {
    width: 48px;
    height: 48px;
  }
  /* Cart icon button */
  [data-cart-toggle], .nav__cart {
    min-width: 48px;
    min-height: 48px;
  }
  /* Form inputs — no iOS zoom on focus when font-size ≥ 16px */
  input, textarea, select {
    font-size: 16px !important;
  }
}

/* ============================================================
   MOBILE BOTTOM NAV — thumb-driven primary actions
   Hides on desktop (≥900px). 56px + safe-area-inset-bottom.
   Order: Home · Search · Cart (with badge) · Account
   ============================================================ */
.mobile-bottom-nav {
  display: none;
}
@media (max-width: 899px) {
  .mobile-bottom-nav {
    display: grid;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 9990;
    grid-template-columns: repeat(4, 1fr);
    background: #FFFCF5;
    border-top: 1px solid rgba(176, 139, 87, 0.25);
    box-shadow: 0 -4px 16px rgba(31, 58, 46, 0.12);
    padding-bottom: env(safe-area-inset-bottom, 0);
    height: calc(64px + env(safe-area-inset-bottom, 0px));
  }
  .mbn-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    color: var(--ink, #1A1A1A);
    text-decoration: none;
    font-size: 0.7rem;
    font-weight: 500;
    letter-spacing: 0.04em;
    padding: 6px 0 8px;
    min-height: 56px;
    position: relative;
    transition: color 0.15s ease, background 0.15s ease;
    -webkit-tap-highlight-color: transparent;
  }
  .mbn-item:active { background: rgba(176, 139, 87, 0.08); }
  .mbn-item.is-active { color: #2A7050; }
  .mbn-item.is-active::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 24px;
    height: 3px;
    background: #2A7050;
    border-radius: 0 0 3px 3px;
  }
  .mbn-item svg { width: 24px; height: 24px; stroke-width: 1.6; }
  .mbn-item__badge {
    position: absolute;
    top: 4px; right: 18px;
    background: #C84F4F;
    color: #FFFCF5;
    font-size: 0.62rem;
    font-weight: 600;
    line-height: 1;
    padding: 3px 5px;
    border-radius: 8px;
    min-width: 14px;
    text-align: center;
    display: none;
  }
  .mbn-item__badge.is-visible { display: block; }
  .mbn-item__label {
    font-size: 0.65rem;
    line-height: 1;
    margin-top: 1px;
  }
  /* Body padding so content doesn't hide behind the nav */
  body.has-bottom-nav { padding-bottom: calc(64px + env(safe-area-inset-bottom, 0px)); }
}

/* ============================================================
   STICKY ADD-TO-CART — product page mobile
   56px bar at bottom: name + price + button. Hides when "Add" is in view.
   ============================================================ */
.sticky-atc {
  display: none;
}
@media (max-width: 899px) {
  .sticky-atc {
    display: flex;
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 9985;
    align-items: center;
    gap: 12px;
    padding: 10px 14px calc(10px + env(safe-area-inset-bottom, 0px));
    background: #FFFCF5;
    border-top: 1px solid rgba(176, 139, 87, 0.25);
    box-shadow: 0 -2px 12px rgba(31, 58, 46, 0.12);
  }
  /* Account for bottom nav above it */
  body.has-bottom-nav .sticky-atc {
    bottom: calc(64px + env(safe-area-inset-bottom, 0px));
  }
  .sticky-atc__info {
    flex: 1;
    min-width: 0;
  }
  .sticky-atc__name {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--ink, #1A1A1A);
    line-height: 1.2;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .sticky-atc__price {
    font-size: 0.95rem;
    font-weight: 600;
    color: #2A7050;
    font-family: var(--serif, 'Cormorant Garamond', serif);
    line-height: 1.2;
    margin-top: 2px;
  }
  .sticky-atc__btn {
    flex-shrink: 0;
    padding: 14px 22px;
    background: #2A7050;
    color: #FFFCF5;
    border: 0;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    cursor: pointer;
    min-height: 48px;
    -webkit-tap-highlight-color: transparent;
  }
  .sticky-atc__btn:active { background: #1F4F3D; }
  .sticky-atc__btn:disabled { background: #999; cursor: not-allowed; }
}

/* ============================================================
   WHATSAPP FAB — India-specific floating button
   56px circle, bottom-right above bottom nav, hides on admin pages
   ============================================================ */
.whatsapp-fab {
  display: none;
}
@media (max-width: 899px) {
  body.has-whatsapp .whatsapp-fab {
    display: flex;
    position: fixed;
    right: 14px;
    bottom: calc(80px + env(safe-area-inset-bottom, 0px));
    z-index: 9980;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: #25D366;
    color: white;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    box-shadow: 0 4px 16px rgba(37, 211, 102, 0.4), 0 0 0 4px rgba(37, 211, 102, 0.12);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    -webkit-tap-highlight-color: transparent;
  }
  body.has-whatsapp.has-bottom-nav .whatsapp-fab {
    bottom: calc(140px + env(safe-area-inset-bottom, 0px));
  }
  .whatsapp-fab:active {
    transform: scale(0.95);
  }
  .whatsapp-fab svg { width: 28px; height: 28px; }
  .whatsapp-fab__pulse {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 2px solid #25D366;
    animation: whatsapp-pulse 2s ease-out infinite;
    pointer-events: none;
  }
  @keyframes whatsapp-pulse {
    0% { transform: scale(1); opacity: 0.8; }
    100% { transform: scale(1.6); opacity: 0; }
  }
}

/* ============================================================
   HERO — better mobile composition
   ============================================================ */
@media (max-width: 768px) {
  .hero {
    min-height: auto !important;
    padding: 32px var(--gutter, 18px) 48px !important;
  }
  .hero h1 {
    font-size: clamp(2rem, 8vw, 2.8rem) !important;
    line-height: 1.1 !important;
    margin-bottom: 14px !important;
  }
  .hero .sub, .hero p {
    font-size: 0.95rem !important;
    line-height: 1.55 !important;
  }
  .hero__image, .hero__media {
    aspect-ratio: 4 / 5 !important;
    object-position: center bottom !important;
    margin: 0 calc(-1 * var(--gutter, 18px)) 24px !important;
    width: calc(100% + var(--gutter, 18px) * 2) !important;
    max-height: 60vh !important;
  }
  .hero__ctas, .hero .ctas {
    display: flex !important;
    flex-direction: column !important;
    gap: 10px !important;
    width: 100% !important;
  }
  .hero__ctas a, .hero .ctas a, .hero__ctas button {
    width: 100% !important;
    min-height: 48px !important;
  }
}

/* ============================================================
   TOP BAR + NAV — mobile adjustments
   ============================================================ */
@media (max-width: 768px) {
  /* Top bar shows only search on mobile (announcements hidden) */
  .topbar__announcements { display: none !important; }
  .topbar__search { flex: 1 1 100% !important; }
  /* Reduce nav padding on small screens */
  .nav {
    padding: 10px 14px !important;
  }
  .nav__brand { font-size: 0.95rem !important; }
  .nav__brand .ja { font-size: 0.6rem !important; }
  /* Nav search-link icon (≥1750px) — still hidden on mobile */
  .nav__search-link { display: none !important; }
}

/* ============================================================
   FORMS — mobile-friendly inputs
   ============================================================ */
@media (max-width: 768px) {
  .field__input, .field__textarea, .field__select,
  input[type="text"], input[type="email"], input[type="tel"],
  input[type="number"], input[type="password"], textarea, select {
    font-size: 16px !important;  /* prevent iOS zoom on focus */
    min-height: 48px;
    padding: 12px 14px !important;
  }
  .field__checkbox, .checkbox, [type="checkbox"], [type="radio"] {
    transform: scale(1.2);
    margin-right: 8px;
  }
  /* form-grid → single column on mobile */
  .form-grid, .form-grid--2, .form-grid--3, .form-grid--4 {
    grid-template-columns: 1fr !important;
    gap: 12px !important;
  }
  .field__label {
    font-size: 0.78rem !important;
  }
  /* Field help text */
  .field__help, .field small {
    font-size: 0.78rem !important;
  }
}

/* ============================================================
   TABLES → CARDS on mobile
   ============================================================ */
@media (max-width: 768px) {
  .admin-table, .data-table, table.responsive {
    border: 0;
  }
  .admin-table thead, .data-table thead, table.responsive thead {
    display: none;
  }
  .admin-table tr, .data-table tr, table.responsive tr {
    display: block;
    border: 1px solid rgba(176, 139, 87, 0.2);
    border-radius: 6px;
    margin-bottom: 12px;
    padding: 12px;
  }
  .admin-table td, .data-table td, table.responsive td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0 !important;
    border: 0 !important;
    text-align: right;
  }
  .admin-table td::before, .data-table td::before, table.responsive td::before {
    content: attr(data-label);
    font-weight: 600;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--muted, #6B6B6B);
    text-align: left;
  }
}

/* ============================================================
   CARDS — product grid on mobile
   ============================================================ */
@media (max-width: 480px) {
  .product-cards, .products-grid, .card-grid {
    grid-template-columns: 1fr !important;
    gap: 16px !important;
  }
  .product-card__img, .card__img, .card-image {
    aspect-ratio: 1 / 1 !important;
  }
  .product-card__title, .card__title {
    font-size: 1.05rem !important;
  }
  .product-card__price, .card__price {
    font-size: 1.1rem !important;
  }
}

@media (min-width: 481px) and (max-width: 768px) {
  .product-cards, .products-grid, .card-grid {
    grid-template-columns: repeat(2, 1fr) !important;
  }
}

/* ============================================================
   HERO IMAGE — never cut off the hand (v10.7 fix preserved)
   ============================================================ */
@media (max-width: 768px) {
  .hero__image img, .hero__media img, .hero img {
    object-position: center bottom !important;
  }
}

/* ============================================================
   CART DRAWER — full screen on mobile
   ============================================================ */
@media (max-width: 768px) {
  .cart-drawer {
    width: 100% !important;
    max-width: 100% !important;
  }
  .cart-drawer__close {
    width: 44px !important;
    height: 44px !important;
    font-size: 24px !important;
  }
  .cart-drawer__qty button {
    min-width: 44px;
    min-height: 44px;
  }
}

/* ============================================================
   MODAL — full screen on mobile
   ============================================================ */
@media (max-width: 768px) {
  .modal-card, .modal-content {
    max-width: 100% !important;
    max-height: 100vh !important;
    border-radius: 0 !important;
    width: 100% !important;
    height: 100% !important;
  }
  .modal-overlay {
    padding: 0 !important;
  }
}

/* ============================================================
   FILTERS + SORTING — sticky bar on mobile
   ============================================================ */
@media (max-width: 768px) {
  .shop-toolbar, .filters, .filter-bar {
    position: sticky;
    top: var(--nav-offset, 96px);
    z-index: 40;
    background: var(--cream, #FFFCF5);
    padding: 10px 14px;
    border-bottom: 1px solid rgba(176, 139, 87, 0.2);
  }
  .filters-toggle, .sort-toggle {
    min-height: 44px;
    min-width: 44px;
  }
}

/* ============================================================
   CHECKOUT — single column on mobile
   ============================================================ */
@media (max-width: 768px) {
  .checkout-grid, .cart-checkout {
    grid-template-columns: 1fr !important;
    gap: 16px !important;
  }
  .checkout-summary {
    position: sticky !important;
    bottom: calc(64px + env(safe-area-inset-bottom, 0px)) !important;
    z-index: 40 !important;
    background: #FFFCF5;
    border-top: 1px solid rgba(176, 139, 87, 0.2);
    padding: 12px 14px !important;
    box-shadow: 0 -2px 12px rgba(31, 58, 46, 0.08);
  }
  /* Account for bottom nav on cart/checkout */
  body.has-bottom-nav .checkout-summary,
  body.has-bottom-nav .cart-summary {
    bottom: calc(64px + env(safe-area-inset-bottom, 0px)) !important;
  }
  /* Mobile checkout place-order button = full width sticky */
  .place-order, .checkout-place-order {
    width: 100% !important;
    min-height: 52px !important;
  }
}

/* ============================================================
   COOKIE BANNER — non-blocking on mobile
   ============================================================ */
@media (max-width: 768px) {
  .cookie-banner, .privacy-banner {
    padding: 12px 14px !important;
    font-size: 0.82rem !important;
  }
  .cookie-banner a, .privacy-banner a {
    min-height: 32px;
    display: inline-flex;
    align-items: center;
  }
}

/* ============================================================
   IMAGES — responsive by default
   ============================================================ */
img {
  max-width: 100%;
  height: auto;
}
img[loading="lazy"] {
  /* Native lazy load + blur-up effect */
  background: rgba(176, 139, 87, 0.05);
}

/* ============================================================
   SCROLLBAR — nicer on mobile (when visible)
   ============================================================ */
@media (max-width: 768px) {
  body {
    -webkit-overflow-scrolling: touch;
  }
}

/* ============================================================
   REDUCED MOTION — respect user preference
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ============================================================
   PRINT — print styles (separate from screen)
   ============================================================ */
@media print {
  .mobile-bottom-nav, .sticky-atc, .whatsapp-fab, .topbar, .nav,
  .cookie-banner, .privacy-banner, .cart-drawer, .modal-overlay {
    display: none !important;
  }
  body { padding-bottom: 0 !important; background: white; color: black; }
}

/* ============================================================
   SAFE AREA — iPhone notch support
   ============================================================ */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  .mobile-bottom-nav, .sticky-atc, .whatsapp-fab {
    padding-bottom: env(safe-area-inset-bottom);
  }
}

/* ============================================================
   DARK MODE — opt-in support (future)
   ============================================================ */
@media (prefers-color-scheme: dark) {
  /* Placeholder — site stays cream/warm even in dark mode (intentional) */
}
