/* FORME app shell: mobile bottom tab bar, app-style top bar, PWA/standalone tweaks.
   Loads after forme.css. Everything below 1040px only; desktop is untouched. */

:root { --tabbar-h: 0px; }
.tabbar, .install-hint { display: none; }

@media (max-width: 1039.98px) {
  /* --tabbar-h: height of the visible bottom bar incl. safe area. 0 when no bar is rendered (checkout)
     or while the product page's add-to-bag bar replaces it. Other fixed bottom UI should sit at bottom: var(--tabbar-h). */
  html:has(.tabbar) { --tabbar-h: calc(60px + env(safe-area-inset-bottom, 0px)); }
  html:has(.tabbar):has(.mobile-buy.is-visible) { --tabbar-h: 0px; }
  body:has(.tabbar) { padding-bottom: calc(var(--tabbar-h) + 0px); }
  html:has(.tabbar):has(.mobile-buy.is-visible) body { padding-bottom: 5rem; }

  /* ---------- tab bar ---------- */
  .tabbar { display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; inset: auto 0 0 0; z-index: 70;
    padding-bottom: env(safe-area-inset-bottom, 0px); height: calc(60px + env(safe-area-inset-bottom, 0px));
    background: color-mix(in srgb, var(--ivory) 88%, transparent); backdrop-filter: blur(16px) saturate(1.2); -webkit-backdrop-filter: blur(16px) saturate(1.2);
    border-top: 1px solid var(--line); transition: transform .35s var(--ease-out); }
  html:has(.mobile-buy.is-visible) .tabbar { transform: translateY(110%); }
  .tabbar__item { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    min-height: 44px; padding: 6px 0 4px; background: none; border: 0; color: var(--ink-2); text-decoration: none; font: inherit; cursor: pointer; }
  .tabbar__item[aria-current="page"] { color: var(--olive-dark); }
  .tabbar__item[aria-current="page"]::before { content: ""; position: absolute; top: -1px; left: 50%; width: 22px; height: 2px; margin-left: -11px; background: var(--olive); border-radius: 0 0 2px 2px; }
  .tabbar__item:focus-visible { outline: 2px solid var(--olive); outline-offset: -4px; border-radius: 8px; }
  .tabbar__icon { position: relative; display: grid; place-items: center; width: 26px; height: 26px; }
  .tabbar__icon svg { width: 23px; height: 23px; }
  .tabbar__item[aria-current="page"] .tabbar__icon svg { stroke-width: 1.8; }
  .tabbar__icon .badge { top: -5px; right: -9px; }
  .tabbar__label { font-size: 10.5px; line-height: 1; letter-spacing: .02em; font-weight: 500; }

  /* lift other fixed bottom UI */
  .toast { bottom: calc(var(--tabbar-h) + 1rem); }
  html:has(.mobile-buy.is-visible) .toast { bottom: calc(5rem + env(safe-area-inset-bottom, 0px)); }

  /* ---------- app-style top bar ---------- */
  :root { --header-h: 56px; }
  .site-header { padding-top: env(safe-area-inset-top, 0px); }
  .site-header .header-bar { height: 56px; }
  .logo { font-size: 1.45rem; }
  .header-account { display: inline-grid; }
  /* search/wishlist/bag live in the tab bar when it is present */
  html:has(.tabbar) .header-search,
  html:has(.tabbar) .header-actions a:has([data-wishlist-count]),
  html:has(.tabbar) .header-actions a:has([data-cart-count]) { display: none; }
  .announce { font-size: 11px; padding: .4rem var(--gutter); }
  .announce { transition: margin-top .3s, opacity .3s; }
  body.is-scrolled .announce { display: none; }
  .menu-toggle[hidden], .back-btn[hidden] { display: none; }
  .back-btn { justify-self: start; }
  .back-btn svg { width: 22px; height: 22px; }

  /* ---------- app feel ---------- */
  html { -webkit-tap-highlight-color: transparent; }
  body { overscroll-behavior-y: none; }
  a, button, summary, label, input, select, textarea { touch-action: manipulation; }
  a, button { -webkit-tap-highlight-color: transparent; }
  .btn, .icon-btn, .tabbar__item, .chip, .card, .product-card, .nav-drawer a, summary { transition: transform .15s var(--ease-out), background-color .3s, opacity .15s; }
  .btn:active, .icon-btn:active, .chip:active, .card:active, .product-card:active, .nav-drawer nav a:active { transform: scale(.97); }
  .tabbar__item:active .tabbar__icon { transform: scale(.88); }
  .tabbar__icon { transition: transform .15s var(--ease-out); }

  /* swipeable chip rows */
  .chips, .chip-row { overflow-x: auto; flex-wrap: nowrap; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
  .chips::-webkit-scrollbar, .chip-row::-webkit-scrollbar { display: none; }

  /* ---------- install hint ---------- */
  .install-hint { position: fixed; left: .75rem; right: .75rem; bottom: calc(var(--tabbar-h) + .6rem); z-index: 65; align-items: center; gap: .75rem;
    background: var(--charcoal); color: var(--ivory); padding: .6rem .6rem .6rem 1rem; font-size: var(--fs-sm); box-shadow: 0 10px 30px rgba(0,0,0,.18); }
  .install-hint[hidden] { display: none; }
  .install-hint:not([hidden]) { display: flex; }
  .install-hint span { flex: 1; }
  .install-hint button { min-height: 44px; padding: 0 1rem; border: 0; font: inherit; cursor: pointer; background: var(--ivory); color: var(--charcoal); }
  .install-hint button[data-install-dismiss] { background: none; color: var(--stone); padding: 0 .75rem; }
  .install-hint button:focus-visible { outline: 2px solid var(--stone); outline-offset: 2px; }

  /* ---------- page enter ---------- */
  @media (prefers-reduced-motion: no-preference) {
    main { animation: shell-enter .35s var(--ease-out) both; }
  }
}
@keyframes shell-enter { from { opacity: 0; } to { opacity: 1; } }

@media (max-width: 1039.98px) and (display-mode: standalone) {
  body { user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
  input, textarea, [contenteditable], .selectable { user-select: text; -webkit-user-select: text; }
  .site-footer { padding-bottom: 1rem; }
}

@media (prefers-reduced-motion: reduce) {
  .tabbar, .tabbar__icon, .btn, .icon-btn { transition: none; }
  .btn:active, .icon-btn:active, .chip:active, .card:active, .product-card:active, .tabbar__item:active .tabbar__icon { transform: none; }
}
@media print { .tabbar, .install-hint { display: none !important; } }
