/* =====================================================================
   CandyApple — mobile.css
   Mobile experience designed to feel like a native app (max-width: 768px)
   - app top bar, slide-in drawer, bottom tab navigation
   - thumb-first touch targets, snap carousels, safe-area support
   ===================================================================== */

@media (max-width: 768px) {
  :root {
    --gutter: 16px;
    --header-h: 60px;
    --announce-h: 34px;
    --bottomnav-h: 62px;
  }

  body {
    font-size: 15.5px;
    padding-bottom: calc(var(--bottomnav-h) + env(safe-area-inset-bottom, 0px));
    -webkit-tap-highlight-color: transparent;
  }

  h1 { font-size: 28px; }
  h2 { font-size: 23px; }

  .section { padding: 46px 0; }
  .section-tight { padding: 34px 0; }
  .section-head { margin-bottom: 26px; }

  /* ---------- announcement: compact, notch-safe, single line ---------- */
  .announce-bar {
    font-size: 12px;
    letter-spacing: 0.03em;
    padding: 7px 14px;
    padding-top: calc(7px + env(safe-area-inset-top, 0px));
    min-height: var(--announce-h);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* ---------- app top bar ---------- */
  .site-header {
    top: env(safe-area-inset-top, 0px); /* stick below notch / Dynamic Island */
    box-shadow: 0 6px 24px rgba(74, 44, 29, 0.18);
  }
  /* cream filler above the stuck header, covering the safe-area gap */
  .site-header::before { content: none; }
  .site-header.is-stuck::before {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: 100%;
    height: env(safe-area-inset-top, 0px);
    background: #FAF5EC;
  }
  .site-header.is-stuck { box-shadow: 0 12px 30px rgba(40, 23, 12, 0.22); }

  .header-inner {
    min-height: var(--header-h);
    gap: 6px;
  }
  .brand { gap: 6px; margin: 0 auto; }
  /* logo scales with the viewport, always fits beside the 3 icon buttons */
  .site-header .brand-logo {
    width: clamp(116px, 34vw, 150px);
    height: auto;
    padding: 0;
    border-radius: 10px;
  }
  .brand-name { font-size: 20px; }
  .brand-tag { font-size: 8px; letter-spacing: 0.24em; margin-top: 2px; }

  .menu-btn {
    order: -1;
    margin-left: -6px;
    flex: 0 0 auto;
  }
  .header-actions { margin-left: 0; gap: 2px; flex: 0 0 auto; }
  .header-actions .icon-btn { width: 44px; height: 44px; } /* full touch target */
  .header-actions .lang-btn { width: 40px; min-width: 40px; padding: 0; justify-content: center; }
  .lang-switch .lang-label { display: none; } /* icon-only on phones — keeps the row from crowding */
  .account-btn { display: none; }

  /* press feedback — feels like a native app */
  .icon-btn:active,
  .menu-btn:active {
    background: rgba(74, 44, 29, 0.14);
    transform: scale(0.93);
  }
  .icon-btn,
  .menu-btn { transition: background 0.15s var(--ease), transform 0.15s var(--ease); }

  /* ---------- search sheet ---------- */
  .search-bar form { padding: 10px 0; gap: 8px; }
  .search-bar input {
    padding: 12px 18px;
    font-size: 16px; /* 16px prevents iOS zoom-on-focus */
    background: var(--cream);
  }
  .search-bar .btn { padding-left: 20px; padding-right: 20px; }

  /* ---------- drawer: full-screen app menu ---------- */
  .drawer {
    width: min(88vw, 350px);
    border-radius: 0 var(--r-l) var(--r-l) 0;
    overscroll-behavior: contain;
  }
  .drawer-head {
    padding: 18px;
    padding-top: calc(18px + env(safe-area-inset-top, 0px));
  }
  .drawer-nav a,
  .drawer-nav .drawer-group {
    padding: 14px 20px;
    font-size: 15.5px;
    min-height: 52px;
  }
  .drawer-nav a:active { background: var(--pistachio-soft); }
  .drawer-sub a { padding: 12px 20px 12px 52px; }
  .drawer-contact { margin: 14px 16px 6px; }

  /* ---------- hero ---------- */
  .hero-inner {
    padding: 40px 0 46px;
    gap: 30px;
    text-align: center;
  }
  .hero-sub { margin-left: auto; margin-right: auto; }
  .hero-ctas { justify-content: center; }
  .hero-ctas .btn { flex: 1; min-width: 150px; }
  .hero-stats {
    justify-content: space-around;
    gap: 14px;
    margin-top: 32px;
    padding-top: 22px;
  }
  .hero-stat b { font-size: 25px; }
  .hero-art {
    order: -1;
    /* definite width + grid centering: image box is centered in the
       viewport and never wider than 360px (or the column, whichever is
       smaller) — kills the old shrink-to-fit left alignment */
    width: min(100%, 360px);
    justify-self: center;
  }
  .hero-art img {
    display: block;
    width: 100%;      /* fills the wrapper exactly — wrapper edges = image edges */
    height: auto;     /* original aspect ratio kept, no stretch, no crop */
    margin: 0 auto;
  }
  .hero-chip-1 { top: 2%; left: 0; font-size: 12px; padding: 9px 13px; }
  .hero-chip-2 { bottom: 6%; right: 0; font-size: 12px; padding: 9px 13px; }

  /* ---------- category cards ---------- */
  .cat-grid { gap: 12px; }
  .cat-card-body { padding: 13px 14px 15px; }
  .cat-card-name { font-size: 16px; }
  .cat-card-arrow { width: 34px; height: 34px; }

  /* ---------- product cards: dense app grid ---------- */
  .grid-products { gap: 11px; }
  .product-body { padding: 11px 12px 13px; gap: 6px; }
  .product-cat { font-size: 10.5px; }
  .product-name { font-size: 14.5px; }
  .product-desc { display: none; }
  .price { font-size: 15.5px; }
  .price-old { font-size: 12.5px; }
  .product-actions .btn {
    padding: 9px 8px;
    font-size: 12.5px;
    gap: 5px;
  }
  .product-flag { top: 7px; left: 7px; }
  .product-flag .badge { padding: 3px 9px; font-size: 10.5px; }

  /* ---------- rails: snap carousels ---------- */
  .rail {
    grid-auto-columns: minmax(168px, 62%);
    gap: 11px;
    margin: 0 calc(var(--gutter) * -1);
    padding: 0 var(--gutter) 12px;
  }

  /* ---------- USP ---------- */
  .usp-strip { gap: 11px; }
  .usp-item { padding: 16px 14px; gap: 7px; }
  .usp-icon { width: 40px; height: 40px; border-radius: 12px; }
  .usp-item h3 { font-size: 15px; }
  .usp-item p { font-size: 12.5px; }

  /* ---------- promo band ---------- */
  .promo-band {
    padding: 30px 22px;
    border-radius: var(--r);
    text-align: center;
  }
  .promo-band p { margin-left: auto; margin-right: auto; }
  .promo-band .btn { width: 100%; }
  .grid-quotes { gap: 12px; }

  /* ---------- page hero ---------- */
  .page-hero { padding: 34px 0 38px; }

  /* ---------- catalog toolbar ---------- */
  .catalog-toolbar {
    gap: 12px;
    margin-bottom: 20px;
  }
  /* stack: full-width search first, then the count + sort meta row */
  .toolbar-row {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }
  .search-form-inline {
    width: 100%;
    min-width: 0;
  }
  .search-form-inline input {
    font-size: 16px; /* prevents iOS zoom on focus */
    padding: 12px 16px;
  }
  .search-form-inline .btn {
    flex: 0 0 auto;
    padding: 12px 16px;
    min-height: 46px;
  }

  /* meta row: product count left, sort dropdown right — never overlaps */
  .toolbar-row .gap {
    width: 100%;
    justify-content: space-between;
    gap: 10px;
  }
  .result-count {
    font-size: 14px;
    white-space: nowrap;
  }
  .toolbar-row .gap form { margin-left: auto; }
  .sort-select {
    margin-left: auto;
    min-height: 44px; /* comfortable touch target */
    padding: 10px 40px 10px 16px;
    font-size: 15px;
    max-width: 100%;
  }

  /* ---------- category chips: horizontal scroll ---------- */
  .chip-row {
    gap: 8px;
    padding-bottom: 8px;
    scroll-snap-type: x proximity;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
  }
  .chip {
    padding: 10px 16px;
    font-size: 13.5px;
    min-height: 44px; /* full touch target */
    scroll-snap-align: start;
  }

  .cat-hero { margin-bottom: 22px; border-radius: var(--r); }
  .cat-hero-media { aspect-ratio: 16 / 10; }
  .cat-hero-body { padding: 20px 18px 22px; }
  .subcat-row { gap: 7px; margin-bottom: 20px; }
  .subcat-row .chip { font-size: 13px; }

  /* ---------- product detail ---------- */
  .pdp { gap: 22px; }
  /* grid children may shrink below their content size — a long title or a
     wide button row must never widen the column past the screen */
  .pdp > * { min-width: 0; }

  /* main image: fits the column, square ratio kept, contained (no crop) */
  .pdp-main-img { border-radius: var(--r); }
  .pdp-main-img img { padding: 6%; }

  /* thumbnails: aligned horizontal scroller for any number of images */
  .pdp-thumbs {
    flex-wrap: nowrap;
    overflow-x: auto;
    scroll-snap-type: x proximity;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 4px;
  }
  .pdp-thumbs::-webkit-scrollbar { display: none; }
  .pdp-thumb {
    width: 60px;
    height: 60px;
    flex: 0 0 auto;
    scroll-snap-align: start;
  }

  /* title wraps naturally — never overflows the right edge */
  .pdp-title {
    font-size: 25px;
    overflow-wrap: anywhere;
    word-break: normal;
  }

  .pdp-price {
    margin-top: 14px;
    padding: 13px 0;
    flex-wrap: wrap;
    row-gap: 8px;
  }
  .pdp-price .price,
  .pdp-price .price-old { white-space: nowrap; }
  .pdp-price .price { font-size: 26px; }

  /* buy box — two-row responsive layout:
     row 1: quantity stepper + Add to Cart (button absorbs the width)
     row 2: Order on WhatsApp, full width
     (single row only if there is genuinely room — wrap decides) */
  .pdp-buy {
    flex-wrap: wrap;
    gap: 10px;
  }
  .pdp-buy .qty-stepper {
    flex: 0 0 auto;
  }
  .pdp-buy .qty-stepper input { width: 46px; }
  .pdp-buy .btn-primary {
    flex: 1 1 140px;
    min-width: 0; /* label may wrap to 2 lines on very narrow phones instead of clipping */
  }
  .pdp-buy .btn-accent {
    flex: 1 0 100%; /* always its own full-width row */
  }
  .qty-stepper button { width: 42px; height: 48px; }

  /* benefits: text wraps naturally inside the card */
  .pdp-assurance div { min-width: 0; }
  .pdp-assurance { overflow: hidden; }

  /* ---------- cart ---------- */
  .cart-item {
    grid-template-columns: 76px 1fr;
    padding: 12px;
    gap: 12px;
  }
  .cart-item-media { width: 76px; height: 76px; }
  .cart-item-name { font-size: 15px; }
  .cart-item-row { margin-top: 9px; }
  .cart-item .qty-stepper button { width: 36px; height: 36px; }
  .cart-item .qty-stepper input { width: 38px; }
  .summary-card { padding: 18px 16px; border-radius: var(--r); }
  .cart-layout .btn-block-mobile { width: 100%; }

  /* ---------- checkout / forms ---------- */
  .form-card { padding: 20px 16px; }
  .form-card h3 { font-size: 17.5px; }
  .form-row { grid-template-columns: 1fr; gap: 0; }
  .pay-option { padding: 14px; }
  .bank-box dt { min-width: 100px; }

  .field input,
  .field select,
  .field textarea,
  .input { font-size: 16px; } /* prevents iOS zoom on focus */

  .phone-input input[type="tel"] { font-size: 16px; } /* keep iOS zoom guard (higher specificity than .field input) */

  .btn {
    padding: 14px 24px;
    font-size: 15px;
    min-height: 48px;
  }
  .btn-sm { padding: 11px 18px; min-height: 42px; font-size: 14px; }
  .btn-lg { padding: 15px 26px; min-height: 52px; }

  /* ---------- auth ---------- */
  .auth-wrap {
    padding: 30px 16px 46px;
    align-items: start;
  }
  .auth-card {
    padding: 30px 20px;
    border-radius: var(--r-l);
    max-width: 420px;
  }
  .auth-brand .brand-logo { height: 36px; }
  .auth-card h1 { font-size: 24px; }

  .otp-inputs input {
    width: 46px;
    height: 56px;
    font-size: 22px;
  }

  /* ---------- account / orders ---------- */
  .account-menu {
    margin: 0 calc(var(--gutter) * -1);
    padding: 8px var(--gutter);
    border-radius: 0;
    border-left: 0;
    border-right: 0;
    scrollbar-width: none;
  }
  .account-menu::-webkit-scrollbar { display: none; }
  .account-menu a,
  .account-menu button { padding: 10px 14px; min-height: 42px; }

  .profile-card { padding: 20px 16px; }
  .profile-avatar { width: 56px; height: 56px; font-size: 22px; }
  .order-card-head { padding: 13px 15px; }
  .order-card-body { padding: 14px 15px; }
  .order-card-foot { padding: 13px 15px; }

  /* ---------- about / contact ---------- */
  .stat-band {
    padding: 30px 18px;
    gap: 20px 12px;
    border-radius: var(--r);
  }
  .value-card { padding: 22px 18px; }
  .contact-line { padding: 14px 15px; }
  .contact-line .icon { width: 40px; height: 40px; padding: 9px; }
  .map-frame iframe { height: 260px; }

  /* ---------- footer ---------- */
  .site-footer { margin-top: 46px; }
  .footer-grid {
    gap: 0;
    padding: 0 0 26px;
  }
  .footer-col {
    border-bottom: 1px solid rgba(250, 245, 236, 0.14);
  }
  .footer-col:last-child { border-bottom: 0; }
  .footer-col h4 {
    font-size: 15.5px;
    margin-bottom: 0;
    padding: 17px 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
  }
  .footer-col h4::after { display: none; }
  .footer-col h4 .icon {
    transition: transform 0.3s var(--ease);
    color: var(--pistachio);
  }
  .footer-col.is-collapsed h4 .icon { transform: rotate(-90deg); }
  .footer-col .footer-inner {
    padding-bottom: 20px;
    display: grid;
    gap: 14px;
  }
  .footer-col.is-collapsed .footer-inner { display: none; }
  .footer-about { gap: 12px; }
  .footer-bottom { padding: 18px 0; font-size: 12.5px; }

  /* ---------- whatsapp widget ---------- */
  .wa-widget {
    right: 14px;
    bottom: calc(var(--bottomnav-h) + 14px + env(safe-area-inset-bottom, 0px));
  }
  .wa-fab { width: 54px; height: 54px; }
  .wa-panel { width: min(86vw, 300px); }

  /* ---------- bottom tab bar ---------- */
  .bottom-nav {
    display: block;
    -webkit-backdrop-filter: saturate(1.4);
    backdrop-filter: saturate(1.4);
  }
  .bottom-nav a {
    gap: 3px;
    font-size: 11px;
    letter-spacing: 0.02em;
    transition: color 0.18s var(--ease), background 0.18s var(--ease);
  }
  .bottom-nav a:active {
    background: rgba(168, 198, 134, 0.16);
  }
  .bottom-nav .icon {
    transition: transform 0.18s var(--ease);
  }
  .bottom-nav a:active .icon { transform: scale(0.88); }
  .bottom-nav a.is-active {
    color: var(--chocolate-deep);
    font-weight: 700;
  }
  .bottom-nav a.is-active .icon {
    color: var(--apple-deep);
    transform: translateY(-1px);
  }
  .bottom-nav .cart-badge {
    top: 6px;
    right: calc(50% - 24px);
    min-width: 17px;
    height: 17px;
    font-size: 10px;
    line-height: 17px;
  }

  /* ---------- pagination ---------- */
  .pagination { margin-top: 30px; gap: 6px; }
  .page-link { min-width: 40px; height: 40px; padding: 0 12px; font-size: 14px; }

  /* ---------- misc polish ---------- */
  .empty-state { padding: 44px 18px; }
  .empty-state .empty-icon { width: 68px; height: 68px; }
  .success-hero { padding: 40px 0 16px; }

  /* sticky mobile CTA bar for PDP handled by normal flow */
  .flash-stack { margin-top: 16px; }
}

/* small phones */
@media (max-width: 380px) {
  .brand-name { font-size: 18px; }
  .site-header .brand-logo { width: clamp(92px, 30vw, 150px); } /* make room for the language button */
  .grid-products { gap: 9px; }
  .product-name { font-size: 13.5px; }
  .hero-stats { gap: 10px; }
  .otp-inputs { gap: 6px; }
  .otp-inputs input { width: 42px; height: 52px; font-size: 20px; }
}
