/* ==========================================================================
   MADAM — mobile "app" experience (phones & installed app).
   Compact app bar, bottom tab bar, "more" sheet, touch polish.
   Loaded after style.css on every public page.
   ========================================================================== */
.app-tabs, .app-sheet, .app-sheet-ov{ display: none; }

/* ---- touch polish (all sizes) ---- */
a, button, input, select, textarea, label{ touch-action: manipulation; }
html{ -webkit-text-size-adjust: 100%; }

@media (max-width: 860px){
  :root{ --header-h: 58px; --tabs-h: 64px; }
  html{ -webkit-tap-highlight-color: transparent; }
  body{
    padding-bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom));
    animation: appIn .3s ease-out;
  }
  @keyframes appIn{ from{ opacity: 0; } }

  /* ---------- app bar ---------- */
  #site-header{
    background: rgba(245,240,227,.94) !important;
    backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
    box-shadow: 0 1px 0 rgba(47,49,34,.09) !important;
    height: calc(var(--header-h) + env(safe-area-inset-top));
    padding-top: env(safe-area-inset-top);
  }
  body.has-bar #site-header{ top: var(--bar-h, 38px); }
  .header-inner{ position: relative; height: var(--header-h); padding-inline: 14px; }
  #site-header .brand{ position: absolute; inset-inline: 0; margin-inline: auto; width: max-content; top: 50%; transform: translateY(-50%); z-index: 1; }
  #site-header .brand img{ height: 38px; width: auto; display: block; }
  .main-nav, .nav-toggle{ display: none !important; }
  .header-actions{ display: contents; }
  .lang-toggle{
    position: absolute; inset-inline-start: 14px; top: 50%; transform: translateY(-50%);
    width: 40px; height: 40px; padding: 0; justify-content: center; border-radius: 50%;
    font-size: 12px; background: rgba(47,49,34,.06); border-color: transparent;
  }
  .cart-btn{ position: absolute; inset-inline-end: 14px; top: 50%; transform: translateY(-50%); width: 40px; height: 40px; }
  .cart-btn svg{ width: 18px; height: 18px; }
  .cart-count{ top: -5px; inset-inline-end: -5px; border-color: var(--cream-soft); }

  /* the cart lives in the tab bar now */
  .floating-cart{ display: none !important; }
  .toast{ bottom: calc(var(--tabs-h) + 18px + env(safe-area-inset-bottom)); inset-inline: 16px; margin-inline: auto; width: max-content; max-width: calc(100% - 32px); text-align: center; }
  #installBar{ bottom: calc(var(--tabs-h) + 14px + env(safe-area-inset-bottom)) !important; }

  /* ---------- forms: no iOS zoom-on-focus, comfortable targets ---------- */
  input, select, textarea{ font-size: 16px !important; }
  .btn{ min-height: 48px; }
  .btn:active, .product-card:active, .tile:active{ transform: scale(.97); transition-duration: .08s; }

  /* ---------- bottom tab bar ---------- */
  .app-tabs{
    display: grid; grid-template-columns: repeat(5, 1fr); align-items: end;
    position: fixed; inset-inline: 0; bottom: 0; z-index: 480;
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
    background: rgba(250,247,238,.97); backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
    border-top: 1px solid rgba(47,49,34,.1);
    box-shadow: 0 -10px 30px -18px rgba(47,49,34,.35);
  }
  .app-tab{
    position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    min-height: 50px; padding: 4px 2px; border: 0; background: none; text-decoration: none; cursor: pointer;
    color: #8A8A72; font-family: var(--font-ar-body); font-size: 11px; font-weight: 700; line-height: 1.2;
    transition: color .2s;
  }
  html[lang="en"] .app-tab{ font-family: var(--font-en-body); }
  .app-tab svg{ width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; transition: transform .2s; }
  .app-tab:active svg{ transform: scale(.88); }
  .app-tab.on{ color: var(--olive-dark); }
  .app-tab.on::before{ content: ""; position: absolute; top: -7px; width: 26px; height: 3px; border-radius: 0 0 4px 4px; background: var(--gold); }
  .app-tab.cart .ic{
    width: 54px; height: 54px; margin-top: -26px; border-radius: 50%;
    display: grid; place-items: center; position: relative; color: var(--cream-soft);
    background: linear-gradient(135deg, var(--olive), var(--olive-dark));
    border: 4px solid #FAF7EE; box-shadow: 0 10px 22px -8px rgba(47,49,34,.6);
  }
  .app-tab.cart.on .ic{ background: linear-gradient(135deg, var(--tan), var(--gold-deep)); }
  .app-tab.cart.on::before{ display: none; }
  .app-badge{
    position: absolute; top: -4px; inset-inline-end: -4px; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 99px;
    background: var(--gold); color: #fff; font-size: 11px; font-weight: 800; display: grid; place-items: center; border: 2px solid #FAF7EE;
  }
  .app-badge[data-n="0"]{ display: none; }

  /* ---------- "more" bottom sheet ---------- */
  .app-sheet-ov{ display: block; position: fixed; inset: 0; z-index: 490; background: rgba(38,40,25,.5); opacity: 0; pointer-events: none; transition: opacity .25s; }
  .app-sheet{
    display: block; position: fixed; inset-inline: 0; bottom: 0; z-index: 495; background: var(--cream-soft);
    border-radius: 24px 24px 0 0; padding: 10px 18px calc(22px + env(safe-area-inset-bottom));
    transform: translateY(105%); transition: transform .3s cubic-bezier(.2,.8,.2,1);
    box-shadow: 0 -20px 50px -14px rgba(0,0,0,.4);
  }
  body.sheet-open .app-sheet-ov{ opacity: 1; pointer-events: auto; }
  body.sheet-open .app-sheet{ transform: none; }
  body.sheet-open{ overflow: hidden; }
  .app-sheet .grab{ width: 42px; height: 5px; border-radius: 9px; background: var(--beige); margin: 2px auto 14px; }
  .app-sheet h3{ font-size: 18px; margin: 0 4px 12px; color: var(--brown-dark); }
  .sheet-grid{ display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
  .sheet-grid a, .sheet-grid button{
    display: flex; align-items: center; gap: 12px; padding: 14px; border-radius: 16px; border: 1px solid var(--beige);
    background: #fff; color: var(--brown-dark); font-family: inherit; font-size: 14.5px; font-weight: 700; text-decoration: none; text-align: start; cursor: pointer; min-height: 56px;
  }
  .sheet-grid a:active, .sheet-grid button:active{ background: var(--beige); }
  .sheet-grid svg{ width: 22px; height: 22px; fill: none; stroke: var(--gold-deep); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
  .sheet-grid .wide{ grid-column: 1 / -1; }
}

/* ---------- phone hero: compact so the title and buttons are visible without scrolling ---------- */
@media (max-width: 860px){
  .hero-v2{ min-height: auto; }
  .hero-v2-grid{ padding: 18px 18px 26px; gap: 20px; }
  .hero-v2-visual{ height: 30vh; min-height: 200px; max-height: 280px; }
  .hero-v2-text::before{ display: none; }
  .hero-v2-title{ font-size: clamp(30px, 9vw, 42px); line-height: 1.25; }
  .hero-v2-sub{ font-size: 15px; line-height: 1.8; }
  .hero-v2 .hero-actions{ flex-direction: column; align-items: stretch; gap: 10px; }
  .hero-v2 .hero-actions .btn{ width: 100%; }
  .hero-v2-stats{ gap: 14px; }
  .page-header{ padding-bottom: 28px; }
  section{ scroll-margin-top: calc(var(--header-h) + 8px); }
}
@media (max-width: 860px){
  /* keep the floating decorations inside the screen */
  .hero-badge-ring{ top: -14px; inset-inline-end: 6px; }
  .hero-floating-chip{ bottom: -20px; inset-inline-start: 10px; max-width: calc(100% - 20px); }
}
@media (max-width: 860px){
  #home{ padding: 0; }   /* the app bar is opaque, so the hero starts right under it */
}
@media (max-width: 860px){
  /* the app bar is always cream, so the logo keeps its real colours on inner pages too */
  body:has(.page-header) #site-header:not(.scrolled) .brand img{ filter: none; }
  .page-header{ min-height: 0; }
}
