/*
 * NLM Mobile Shell — Norman Lamps mobile app-like UI
 * ----------------------------------------------------------------------------
 * Every selector is gated by [data-nlm-mobile="1"] on <html>. With the
 * attribute absent the entire file is inert — no rendered effect on any
 * element. See /docs/MOBILE_OPTIMIZATION_PLAN.md for the full architecture.
 *
 * Conventions
 *   - 8px-grid spacing
 *   - Tap targets >= 48px square
 *   - System font stack for native feel
 *   - dvh / svh for full-screen UI (avoids iOS Safari address-bar bounce)
 *   - env(safe-area-inset-*) on every fixed element near the edges
 *   - All transitions: 200ms cubic-bezier(0.4, 0, 0.2, 1)
 */

/* =============================================================================
   1. DESIGN TOKENS
   ============================================================================= */
:root {
  --nlm-c-bg: #ffffff;
  --nlm-c-surface: #ffffff;
  --nlm-c-surface-alt: #f9fafb;
  --nlm-c-text: #1f2937;
  --nlm-c-text-muted: #6b7280;
  --nlm-c-text-inverse: #ffffff;
  --nlm-c-border: #e5e7eb;
  --nlm-c-border-strong: #d1d5db;
  --nlm-c-primary: #2d5c88;
  --nlm-c-primary-hover: #1f4566;
  --nlm-c-accent: #f59e0b;
  --nlm-c-danger: #dc2626;
  --nlm-c-success: #16a34a;

  --nlm-h-topbar: 56px;
  --nlm-h-tabbar: 64px;
  --nlm-h-sticky-cta: 64px;

  --nlm-radius-sm: 6px;
  --nlm-radius: 10px;
  --nlm-radius-lg: 16px;

  --nlm-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.06);
  --nlm-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  --nlm-shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.16);

  --nlm-ease: cubic-bezier(0.4, 0, 0.2, 1);
  --nlm-dur: 220ms;

  --nlm-z-bar: 10000;
  --nlm-z-backdrop: 10400;
  --nlm-z-drawer: 10500;
  --nlm-z-overlay: 10600;
  --nlm-z-cart: 10700;
  --nlm-z-toast: 11000;
}

/* =============================================================================
   2. SHELL ON: hide legacy chrome, reset layout
   ============================================================================= */
[data-nlm-mobile="1"] body {
  /* Override the OpenCart default body styles for mobile shell mode */
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif !important;
  font-size: 15px !important;
  line-height: 1.5 !important;
  color: var(--nlm-c-text);
  background: var(--nlm-c-bg);
  /* Reserve space for the fixed top bar and bottom tab bar so page content
     never hides behind them. */
  padding-top: var(--nlm-h-topbar) !important;
  padding-bottom: calc(var(--nlm-h-tabbar) + env(safe-area-inset-bottom, 0px)) !important;
  margin: 0;
  overflow-x: hidden;
}

/* Hide the legacy OpenCart header/footer/nav/banner-bar on mobile. Server
   still renders them (Googlebot sees them, schema unchanged) — we just
   visually suppress for the mobile UI.
   IMPORTANT: `:not(.nlm-topbar)` and `:not(.nlm-tabbar)` are critical —
   our new mobile chrome uses <header class="nlm-topbar"> and
   <nav class="nlm-tabbar">, both of which are direct body children
   matching `body > header` / `nav#menu` otherwise. */
[data-nlm-mobile="1"] #bottom-message,
[data-nlm-mobile="1"] body > header:not(.nlm-topbar),
[data-nlm-mobile="1"] body > #menu,
[data-nlm-mobile="1"] body > footer,
[data-nlm-mobile="1"] body > .container > #menu,
[data-nlm-mobile="1"] nav#menu:not(.nlm-tabbar) {
  display: none !important;
}

/* Lock body scroll when a drawer/overlay is open. Class toggled by nlm-shell.js. */
[data-nlm-mobile="1"].nlm-lock,
[data-nlm-mobile="1"] body.nlm-lock {
  overflow: hidden !important;
  position: fixed;
  width: 100%;
  height: 100%;
}

/* =============================================================================
   3. TOP BAR (sticky, 56px)
   ============================================================================= */
.nlm-topbar {
  display: none;
}
[data-nlm-mobile="1"] .nlm-topbar {
  display: flex;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: calc(var(--nlm-h-topbar) + env(safe-area-inset-top, 0px));
  padding: env(safe-area-inset-top, 0px) max(12px, env(safe-area-inset-left, 0px)) 0 max(12px, env(safe-area-inset-right, 0px));
  background: var(--nlm-c-surface);
  border-bottom: 1px solid var(--nlm-c-border);
  z-index: var(--nlm-z-bar);
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  box-shadow: var(--nlm-shadow-sm);
}

[data-nlm-mobile="1"] .nlm-topbar__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border: none;
  background: transparent;
  color: var(--nlm-c-text);
  font-size: 20px;
  cursor: pointer;
  position: relative;
  touch-action: manipulation;
  padding: 0;
  border-radius: var(--nlm-radius-sm);
  -webkit-tap-highlight-color: transparent;
}
[data-nlm-mobile="1"] .nlm-topbar__btn:active {
  background: var(--nlm-c-surface-alt);
}
[data-nlm-mobile="1"] .nlm-topbar__btn .fa {
  font-size: 20px;
}

[data-nlm-mobile="1"] .nlm-topbar__logo {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  text-decoration: none;
  overflow: hidden;
}
[data-nlm-mobile="1"] .nlm-topbar__logo img {
  max-height: 36px;
  width: auto;
  object-fit: contain;
}

[data-nlm-mobile="1"] .nlm-topbar__actions {
  display: flex;
  gap: 4px;
}

/* Cart badge on top bar */
[data-nlm-mobile="1"] .nlm-topbar__badge,
[data-nlm-mobile="1"] .nlm-tabbar__badge {
  position: absolute;
  top: 4px;
  right: 4px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  background: var(--nlm-c-danger);
  color: #fff;
  border-radius: 9px;
  font-size: 11px;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
  pointer-events: none;
}
[data-nlm-mobile="1"] .nlm-topbar__badge:empty,
[data-nlm-mobile="1"] .nlm-tabbar__badge:empty,
[data-nlm-mobile="1"] .nlm-topbar__badge[data-count="0"],
[data-nlm-mobile="1"] .nlm-tabbar__badge[data-count="0"] {
  display: none;
}

/* =============================================================================
   4. BOTTOM TAB BAR (sticky, 64px + safe-area)
   ============================================================================= */
.nlm-tabbar {
  display: none;
}
[data-nlm-mobile="1"] .nlm-tabbar {
  display: flex;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: calc(var(--nlm-h-tabbar) + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  padding-left: env(safe-area-inset-left, 0px);
  padding-right: env(safe-area-inset-right, 0px);
  background: var(--nlm-c-surface);
  border-top: 1px solid var(--nlm-c-border);
  z-index: var(--nlm-z-bar);
  box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.04);
}

[data-nlm-mobile="1"] .nlm-tabbar__item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: var(--nlm-c-text-muted);
  text-decoration: none;
  font-size: 11px;
  font-weight: 500;
  background: transparent;
  border: none;
  cursor: pointer;
  position: relative;
  touch-action: manipulation;
  padding: 4px 2px;
  min-height: 48px;
  -webkit-tap-highlight-color: transparent;
}
[data-nlm-mobile="1"] .nlm-tabbar__item .fa {
  font-size: 20px;
  line-height: 1;
}
[data-nlm-mobile="1"] .nlm-tabbar__item:active {
  background: var(--nlm-c-surface-alt);
}
[data-nlm-mobile="1"] .nlm-tabbar__item--active {
  color: var(--nlm-c-primary);
}
[data-nlm-mobile="1"] .nlm-tabbar__item--active::before {
  content: "";
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 32px;
  height: 3px;
  background: var(--nlm-c-primary);
  border-radius: 0 0 3px 3px;
}

/* =============================================================================
   5. BACKDROP
   ============================================================================= */
[data-nlm-mobile="1"] .nlm-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  z-index: var(--nlm-z-backdrop);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--nlm-dur) var(--nlm-ease);
}
[data-nlm-mobile="1"] .nlm-backdrop--visible {
  opacity: 1;
  pointer-events: auto;
}

/* =============================================================================
   6. DRAWER MENU (slide-in from left, 84vw)
   ============================================================================= */
[data-nlm-mobile="1"] .nlm-drawer {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  width: min(84vw, 360px);
  max-width: 100%;
  background: var(--nlm-c-surface);
  z-index: var(--nlm-z-drawer);
  transform: translateX(-100%);
  transition: transform var(--nlm-dur) var(--nlm-ease);
  display: flex;
  flex-direction: column;
  box-shadow: var(--nlm-shadow-lg);
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}
[data-nlm-mobile="1"] .nlm-drawer--open {
  transform: translateX(0);
}

[data-nlm-mobile="1"] .nlm-drawer__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: max(12px, env(safe-area-inset-top, 0px)) 16px 12px 16px;
  border-bottom: 1px solid var(--nlm-c-border);
  background: var(--nlm-c-primary);
  color: var(--nlm-c-text-inverse);
}
[data-nlm-mobile="1"] .nlm-drawer__title {
  font-size: 18px;
  font-weight: 600;
  margin: 0;
}
[data-nlm-mobile="1"] .nlm-drawer__close {
  width: 44px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: inherit;
  font-size: 24px;
  cursor: pointer;
  touch-action: manipulation;
  border-radius: var(--nlm-radius-sm);
  -webkit-tap-highlight-color: transparent;
}

[data-nlm-mobile="1"] .nlm-drawer__body {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

[data-nlm-mobile="1"] .nlm-drawer__account {
  padding: 16px;
  background: var(--nlm-c-surface-alt);
  border-bottom: 1px solid var(--nlm-c-border);
}
[data-nlm-mobile="1"] .nlm-drawer__account-name {
  font-weight: 600;
  font-size: 15px;
  margin: 0 0 8px;
}
[data-nlm-mobile="1"] .nlm-drawer__account-links {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
[data-nlm-mobile="1"] .nlm-drawer__account-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  min-height: 48px;
  padding: 12px 18px;
  border: 1px solid var(--nlm-c-border-strong);
  border-radius: var(--nlm-radius);
  background: var(--nlm-c-surface);
  color: var(--nlm-c-text);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  min-height: 40px;
  touch-action: manipulation;
}
[data-nlm-mobile="1"] .nlm-drawer__account-link--primary {
  background: var(--nlm-c-primary);
  color: var(--nlm-c-text-inverse);
  border-color: var(--nlm-c-primary);
}

[data-nlm-mobile="1"] .nlm-drawer__section-title {
  padding: 16px 16px 4px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--nlm-c-text-muted);
  margin: 0;
}

[data-nlm-mobile="1"] .nlm-drawer__list {
  list-style: none;
  margin: 0;
  padding: 0;
}
[data-nlm-mobile="1"] .nlm-drawer__list li {
  border-bottom: 1px solid var(--nlm-c-border);
}
[data-nlm-mobile="1"] .nlm-drawer__list a,
[data-nlm-mobile="1"] .nlm-drawer__list .nlm-drawer__expandable {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  color: var(--nlm-c-text);
  text-decoration: none;
  font-size: 15px;
  min-height: 48px;
  cursor: pointer;
  background: transparent;
  border: none;
  width: 100%;
  text-align: left;
  font: inherit;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
[data-nlm-mobile="1"] .nlm-drawer__list a:active,
[data-nlm-mobile="1"] .nlm-drawer__list .nlm-drawer__expandable:active {
  background: var(--nlm-c-surface-alt);
}
[data-nlm-mobile="1"] .nlm-drawer__chev {
  font-size: 14px;
  color: var(--nlm-c-text-muted);
  transition: transform var(--nlm-dur) var(--nlm-ease);
}
[data-nlm-mobile="1"] .nlm-drawer__expandable[aria-expanded="true"] .nlm-drawer__chev {
  transform: rotate(90deg);
}

[data-nlm-mobile="1"] .nlm-drawer__sublist {
  list-style: none;
  margin: 0;
  padding: 0;
  background: var(--nlm-c-surface-alt);
  max-height: 0;
  overflow: hidden;
  transition: max-height var(--nlm-dur) var(--nlm-ease);
}
[data-nlm-mobile="1"] .nlm-drawer__expandable[aria-expanded="true"] + .nlm-drawer__sublist {
  max-height: 2000px;
}
[data-nlm-mobile="1"] .nlm-drawer__sublist a {
  padding-left: 36px;
  font-size: 14px;
  color: var(--nlm-c-text-muted);
}

[data-nlm-mobile="1"] .nlm-drawer__footer {
  padding: 16px;
  border-top: 1px solid var(--nlm-c-border);
  background: var(--nlm-c-surface);
  padding-bottom: max(16px, env(safe-area-inset-bottom, 0px));
}
[data-nlm-mobile="1"] .nlm-drawer__call {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 16px;
  background: var(--nlm-c-success);
  color: var(--nlm-c-text-inverse);
  text-decoration: none;
  border-radius: var(--nlm-radius);
  font-size: 16px;
  font-weight: 600;
  min-height: 48px;
  touch-action: manipulation;
}
[data-nlm-mobile="1"] .nlm-drawer__call .fa {
  font-size: 18px;
}

/* =============================================================================
   7. CART DRAWER (slide-up from bottom, full-screen on phones)
   ============================================================================= */
[data-nlm-mobile="1"] .nlm-cartdrawer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: 100dvh;
  height: 100vh; /* fallback */
  max-height: 100dvh;
  background: var(--nlm-c-bg);
  z-index: var(--nlm-z-cart);
  transform: translateY(100%);
  transition: transform 280ms var(--nlm-ease);
  display: flex;
  flex-direction: column;
  box-shadow: var(--nlm-shadow-lg);
  overscroll-behavior: contain;
}
@supports (height: 100dvh) {
  [data-nlm-mobile="1"] .nlm-cartdrawer { height: 100dvh; max-height: 100dvh; }
}
[data-nlm-mobile="1"] .nlm-cartdrawer--open {
  transform: translateY(0);
}

[data-nlm-mobile="1"] .nlm-cartdrawer__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: max(12px, env(safe-area-inset-top, 0px)) 16px 12px;
  border-bottom: 1px solid var(--nlm-c-border);
  background: var(--nlm-c-surface);
  flex-shrink: 0;
}
[data-nlm-mobile="1"] .nlm-cartdrawer__title {
  font-size: 18px;
  font-weight: 600;
  margin: 0;
  color: var(--nlm-c-text);
}
[data-nlm-mobile="1"] .nlm-cartdrawer__close {
  width: 44px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: var(--nlm-c-text);
  font-size: 22px;
  cursor: pointer;
  touch-action: manipulation;
  border-radius: var(--nlm-radius-sm);
  -webkit-tap-highlight-color: transparent;
}

[data-nlm-mobile="1"] .nlm-cartdrawer__body {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: 8px 0;
}
[data-nlm-mobile="1"] .nlm-cartdrawer__empty {
  padding: 48px 24px;
  text-align: center;
  color: var(--nlm-c-text-muted);
}
[data-nlm-mobile="1"] .nlm-cartdrawer__empty-icon {
  font-size: 48px;
  color: var(--nlm-c-border-strong);
  margin-bottom: 12px;
}

[data-nlm-mobile="1"] .nlm-cartitem {
  display: grid;
  grid-template-columns: 72px 1fr auto;
  gap: 12px;
  align-items: start;
  padding: 16px;
  border-bottom: 1px solid var(--nlm-c-border);
}
[data-nlm-mobile="1"] .nlm-cartitem__img {
  width: 72px;
  height: 72px;
  border: 1px solid var(--nlm-c-border);
  border-radius: var(--nlm-radius-sm);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--nlm-c-surface);
}
[data-nlm-mobile="1"] .nlm-cartitem__img img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}
[data-nlm-mobile="1"] .nlm-cartitem__name {
  font-size: 14px;
  font-weight: 500;
  color: var(--nlm-c-text);
  text-decoration: none;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
}
[data-nlm-mobile="1"] .nlm-cartitem__opts {
  font-size: 12px;
  color: var(--nlm-c-text-muted);
  margin-top: 2px;
}
[data-nlm-mobile="1"] .nlm-cartitem__price {
  font-size: 15px;
  font-weight: 600;
  color: var(--nlm-c-text);
  margin-top: 6px;
}
[data-nlm-mobile="1"] .nlm-cartitem__right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}
[data-nlm-mobile="1"] .nlm-cartitem__remove {
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: var(--nlm-c-text-muted);
  font-size: 18px;
  cursor: pointer;
  border-radius: var(--nlm-radius-sm);
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
[data-nlm-mobile="1"] .nlm-cartitem__remove:active {
  color: var(--nlm-c-danger);
  background: rgba(220, 38, 38, 0.08);
}

/* Qty stepper (shared across cart drawer, cart page, product page) */
[data-nlm-mobile="1"] .nlm-stepper {
  display: inline-flex;
  align-items: stretch;
  border: 1px solid var(--nlm-c-border-strong);
  border-radius: var(--nlm-radius);
  overflow: hidden;
  background: var(--nlm-c-surface);
  height: 40px;
}
[data-nlm-mobile="1"] .nlm-stepper__btn {
  width: 40px;
  height: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: var(--nlm-c-text);
  font-size: 18px;
  font-weight: 600;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
[data-nlm-mobile="1"] .nlm-stepper__btn:active {
  background: var(--nlm-c-surface-alt);
}
[data-nlm-mobile="1"] .nlm-stepper__btn:disabled {
  color: var(--nlm-c-border-strong);
  cursor: not-allowed;
}
[data-nlm-mobile="1"] .nlm-stepper__val {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  padding: 0 4px;
  font-size: 15px;
  font-weight: 600;
  color: var(--nlm-c-text);
  border-left: 1px solid var(--nlm-c-border);
  border-right: 1px solid var(--nlm-c-border);
  background: var(--nlm-c-surface-alt);
}
[data-nlm-mobile="1"] .nlm-stepper input.nlm-stepper__val {
  border-top: none;
  border-bottom: none;
  width: 44px;
  text-align: center;
  font: inherit;
  appearance: none;
  -moz-appearance: textfield;
}
[data-nlm-mobile="1"] .nlm-stepper input.nlm-stepper__val::-webkit-outer-spin-button,
[data-nlm-mobile="1"] .nlm-stepper input.nlm-stepper__val::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

/* Cart drawer footer with totals + CTA */
[data-nlm-mobile="1"] .nlm-cartdrawer__footer {
  flex-shrink: 0;
  border-top: 1px solid var(--nlm-c-border);
  background: var(--nlm-c-surface);
  padding: 12px 16px max(12px, env(safe-area-inset-bottom, 0px));
}
[data-nlm-mobile="1"] .nlm-cartdrawer__totals {
  margin: 0 0 12px;
  font-size: 14px;
  color: var(--nlm-c-text);
}
[data-nlm-mobile="1"] .nlm-cartdrawer__totals dl {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px 12px;
  margin: 0;
}
[data-nlm-mobile="1"] .nlm-cartdrawer__totals dt {
  margin: 0;
  font-weight: 400;
  color: var(--nlm-c-text-muted);
}
[data-nlm-mobile="1"] .nlm-cartdrawer__totals dd {
  margin: 0;
  text-align: right;
  font-weight: 500;
}
[data-nlm-mobile="1"] .nlm-cartdrawer__totals .nlm-cartdrawer__grand {
  font-size: 18px;
  font-weight: 700;
  color: var(--nlm-c-text);
  border-top: 1px solid var(--nlm-c-border);
  padding-top: 8px;
  margin-top: 4px;
}

/* Big buttons (shared) */
[data-nlm-mobile="1"] .nlm-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 52px;
  padding: 12px 20px;
  border: 1px solid transparent;
  border-radius: var(--nlm-radius);
  background: var(--nlm-c-primary);
  color: var(--nlm-c-text-inverse);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  font-family: inherit;
}
[data-nlm-mobile="1"] .nlm-btn:active {
  background: var(--nlm-c-primary-hover);
}
[data-nlm-mobile="1"] .nlm-btn--block { width: 100%; }
[data-nlm-mobile="1"] .nlm-btn--ghost {
  background: transparent;
  color: var(--nlm-c-text);
  border-color: var(--nlm-c-border-strong);
}
[data-nlm-mobile="1"] .nlm-btn--ghost:active {
  background: var(--nlm-c-surface-alt);
}
[data-nlm-mobile="1"] .nlm-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

/* =============================================================================
   8. SEARCH OVERLAY
   ============================================================================= */
[data-nlm-mobile="1"] .nlm-search {
  position: fixed;
  inset: 0;
  background: var(--nlm-c-bg);
  z-index: var(--nlm-z-overlay);
  display: flex;
  flex-direction: column;
  transform: translateY(-100%);
  opacity: 0;
  transition: transform var(--nlm-dur) var(--nlm-ease), opacity var(--nlm-dur) var(--nlm-ease);
  pointer-events: none;
}
[data-nlm-mobile="1"] .nlm-search--open {
  transform: translateY(0);
  opacity: 1;
  pointer-events: auto;
}

[data-nlm-mobile="1"] .nlm-search__bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: max(12px, env(safe-area-inset-top, 0px)) 12px 12px;
  background: var(--nlm-c-surface);
  border-bottom: 1px solid var(--nlm-c-border);
}
[data-nlm-mobile="1"] .nlm-search__close {
  width: 44px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: var(--nlm-c-text);
  font-size: 22px;
  cursor: pointer;
  touch-action: manipulation;
  border-radius: var(--nlm-radius-sm);
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
}
[data-nlm-mobile="1"] .nlm-search__input {
  flex: 1;
  height: 44px;
  padding: 0 14px;
  border: 1px solid var(--nlm-c-border-strong);
  border-radius: var(--nlm-radius);
  font-size: 16px;
  background: var(--nlm-c-surface);
  color: var(--nlm-c-text);
  -webkit-appearance: none;
  appearance: none;
}
[data-nlm-mobile="1"] .nlm-search__input:focus {
  outline: none;
  border-color: var(--nlm-c-primary);
  box-shadow: 0 0 0 3px rgba(45, 92, 136, 0.15);
}
[data-nlm-mobile="1"] .nlm-search__clear {
  display: none;
  width: 44px;
  height: 44px;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: var(--nlm-c-text-muted);
  font-size: 18px;
  cursor: pointer;
  touch-action: manipulation;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
}
[data-nlm-mobile="1"] .nlm-search--has-value .nlm-search__clear {
  display: inline-flex;
}
[data-nlm-mobile="1"] .nlm-search__submit {
  height: 44px;
  padding: 0 16px;
  border: none;
  background: var(--nlm-c-primary);
  color: var(--nlm-c-text-inverse);
  font-size: 14px;
  font-weight: 600;
  border-radius: var(--nlm-radius);
  cursor: pointer;
  touch-action: manipulation;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
}

[data-nlm-mobile="1"] .nlm-search__body {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: 12px;
}

[data-nlm-mobile="1"] .nlm-search__section-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--nlm-c-text-muted);
  margin: 16px 4px 8px;
}
[data-nlm-mobile="1"] .nlm-search__section-title:first-child {
  margin-top: 4px;
}

[data-nlm-mobile="1"] .nlm-search__recent {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 4px;
}
[data-nlm-mobile="1"] .nlm-search__recent-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: var(--nlm-c-surface-alt);
  border: 1px solid var(--nlm-c-border);
  border-radius: 999px;
  font-size: 14px;
  color: var(--nlm-c-text);
  cursor: pointer;
  text-decoration: none;
  touch-action: manipulation;
  min-height: 36px;
  -webkit-tap-highlight-color: transparent;
}
[data-nlm-mobile="1"] .nlm-search__recent-clear {
  background: transparent;
  border: none;
  color: var(--nlm-c-text-muted);
  font-size: 12px;
  padding: 4px 8px;
  cursor: pointer;
  text-decoration: underline;
  touch-action: manipulation;
}

[data-nlm-mobile="1"] .nlm-search__suggestions {
  list-style: none;
  margin: 0;
  padding: 0;
}
[data-nlm-mobile="1"] .nlm-search__suggestions li a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 4px;
  border-bottom: 1px solid var(--nlm-c-border);
  text-decoration: none;
  color: var(--nlm-c-text);
  min-height: 56px;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
[data-nlm-mobile="1"] .nlm-search__suggestions li a:active {
  background: var(--nlm-c-surface-alt);
}
[data-nlm-mobile="1"] .nlm-search__suggestions img {
  width: 44px;
  height: 44px;
  object-fit: contain;
  border: 1px solid var(--nlm-c-border);
  border-radius: var(--nlm-radius-sm);
  background: var(--nlm-c-surface);
  flex-shrink: 0;
}
[data-nlm-mobile="1"] .nlm-search__suggestions-name {
  font-size: 14px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* =============================================================================
   9. NORMAN AI WIDGET — INTEGRATED INTO BOTTOM TAB BAR
   ============================================================================= */
/* On mobile, the floating Norman AI bubble is REPLACED by a dedicated
   "Ask Norman" tab in the bottom navigation (the 5th slot, where Account
   used to live — Account is fully accessible via the drawer). Tapping the
   tab opens the chat panel; closing/minimizing the chat returns the user
   to a clean tab bar with no floating chrome. The chat panel itself is
   reused as-is, just lifted above the tab bar.

   Elements hidden:
     #norman-bubble        — floating chat bubble
     #norman-minimized     — floating minimized button
     #norman-tryme         — "Try me!" callout (when bubble is shown)
     #norman-tryme-min     — "Try me!" callout (when minimized)
     #norman-widget-container's empty space when chat is closed

   The shell.js layer wires the tab's click to the same openChat function
   the bubble used to call, and a MutationObserver mirrors the chat's
   open/closed state into the tab's active/badge UI. */

/* Hide all floating Norman triggers; the tab bar is the only entry now. */
[data-nlm-mobile="1"] #norman-bubble,
[data-nlm-mobile="1"] #norman-minimized,
[data-nlm-mobile="1"] #norman-tryme,
[data-nlm-mobile="1"] #norman-tryme-min {
  display: none !important;
}

/* The chat panel stays anchored to its container, but on the mobile shell
   we want it sitting flush above the tab bar (so when it opens the visual
   relationship between tab and panel is clear, like a popover). */
[data-nlm-mobile="1"] #norman-widget-container {
  bottom: calc(var(--nlm-h-tabbar) + env(safe-area-inset-bottom, 0px)) !important;
  left: 0 !important;
  right: 0 !important;
  width: 100% !important;
  pointer-events: none; /* container itself is just a positioning frame */
}
[data-nlm-mobile="1"] #norman-widget-container > * {
  pointer-events: auto;
}
[data-nlm-mobile="1"] #norman-chat {
  bottom: calc(var(--nlm-h-tabbar) + env(safe-area-inset-bottom, 0px)) !important;
  left: 0 !important;
  right: 0 !important;
}
@media (max-width: 700px) {
  [data-nlm-mobile="1"] #norman-chat {
    bottom: calc(var(--nlm-h-tabbar) + env(safe-area-inset-bottom, 0px)) !important;
    height: calc(70dvh - var(--nlm-h-tabbar)) !important;
    max-height: calc(70dvh - var(--nlm-h-tabbar)) !important;
    border-bottom-left-radius: 0 !important;
    border-bottom-right-radius: 0 !important;
  }
  [data-nlm-mobile="1"] #norman-chat.norman-expanded {
    height: calc(88dvh - var(--nlm-h-tabbar)) !important;
  }
}

/* Hide the widget completely when a drawer / cart / search is open
   (lock class on <html>) — avoids peek-through. */
[data-nlm-mobile="1"].nlm-lock #norman-widget-container,
[data-nlm-mobile="1"].nlm-lock #norman-chat {
  display: none !important;
}

/* --- Chat tab in the bottom bar ----------------------------------------- */
/* When the Norman chat panel is OPEN, the chat tab gets an active state
   identical to other --active tabs (handled by the shared --active rule
   in section 4). We also style the unread-message badge here. */
[data-nlm-mobile="1"] .nlm-tabbar__item--chat .nlm-tabbar__badge--chat {
  /* Inherit base .nlm-tabbar__badge styling; just override color so
     unread Norman replies are visually distinct from cart-count badges. */
  background: #ef4444; /* red-500 — attention-grabbing for unread */
  color: #ffffff;
  /* When data-count > 0, the badge text is the count; when "•" we show
     a simple dot for "active but unread count unknown" states. */
}
[data-nlm-mobile="1"] .nlm-tabbar__item--chat[data-chat-state="open"] {
  /* When chat is open, treat the tab like an --active tab. */
  color: var(--nlm-c-primary);
}
[data-nlm-mobile="1"] .nlm-tabbar__item--chat[data-chat-state="open"]::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 28px;
  height: 3px;
  background: var(--nlm-c-primary);
  border-radius: 0 0 3px 3px;
}

/* =============================================================================
   10. UTILITY HELPERS
   ============================================================================= */
[data-nlm-mobile="1"] .nlm-visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Spinner used by JS while content is loading */
[data-nlm-mobile="1"] .nlm-spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2px solid var(--nlm-c-border-strong);
  border-top-color: var(--nlm-c-primary);
  border-radius: 50%;
  animation: nlm-spin 0.8s linear infinite;
}
@keyframes nlm-spin { to { transform: rotate(360deg); } }

/* Skeleton placeholder shimmer */
[data-nlm-mobile="1"] .nlm-skel {
  background: linear-gradient(90deg, var(--nlm-c-surface-alt) 0%, var(--nlm-c-border) 50%, var(--nlm-c-surface-alt) 100%);
  background-size: 200% 100%;
  animation: nlm-skel 1.3s ease-in-out infinite;
  border-radius: var(--nlm-radius-sm);
}
@keyframes nlm-skel {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* =============================================================================
   11. REDUCED MOTION & PRINT
   ============================================================================= */
@media (prefers-reduced-motion: reduce) {
  [data-nlm-mobile="1"] .nlm-drawer,
  [data-nlm-mobile="1"] .nlm-cartdrawer,
  [data-nlm-mobile="1"] .nlm-search,
  [data-nlm-mobile="1"] .nlm-backdrop {
    transition: none !important;
  }
  [data-nlm-mobile="1"] .nlm-skel,
  [data-nlm-mobile="1"] .nlm-spinner {
    animation: none !important;
  }
}

@media print {
  [data-nlm-mobile="1"] .nlm-topbar,
  [data-nlm-mobile="1"] .nlm-tabbar,
  [data-nlm-mobile="1"] .nlm-drawer,
  [data-nlm-mobile="1"] .nlm-backdrop,
  [data-nlm-mobile="1"] .nlm-cartdrawer,
  [data-nlm-mobile="1"] .nlm-search {
    display: none !important;
  }
  [data-nlm-mobile="1"] body {
    padding-top: 0 !important;
    padding-bottom: 0 !important;
  }
}
