/* ============================================================
   DESIGN TOKENS — Sage & Cream
   ============================================================ */
:root {
  --primary: #7A9D8C;
  --primary-dark: #5C8273;
  --primary-rgb: 122, 157, 140;
  --bg: #FCFBF8;
  --bg-cream: #f5f1ee;
  --text: #2B3B34;
  --text-muted: #64748B;
  --glass-bg: rgba(255, 255, 255, 0.65);
  --glass-border: rgba(255, 255, 255, 0.8);
  --glass-blur: 12px;
  --radius-card: 20px;
  --radius-pill: 24px;
  --nav-height: 70px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html {
  height: 100%;
  overflow: visible;
  -webkit-tap-highlight-color: transparent;
}
body {
  height: 100%;
  overflow: visible;
  -webkit-tap-highlight-color: transparent;
  font-family: 'Poppins', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

/* ============================================================
   SLIDER — horizontal scroll snap storytelling
   ============================================================ */
.slider {
  display: flex;
  flex-direction: row;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  scroll-behavior: smooth;
  height: 100dvh;
  height: var(--tg-viewport-stable-height, 100dvh);
  width: 100%;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.slider::-webkit-scrollbar { display: none; width: 0; height: 0; }

/* ============================================================
   SCREEN — each slide
   ============================================================ */
.screen {
  flex: 0 0 100vw;
  width: 100vw;
  height: 100dvh;
  height: var(--tg-viewport-stable-height, 100dvh);
  scroll-snap-align: start;
  scroll-snap-stop: always;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  padding: 20px 20px 90px 20px; /* bottom padding keeps content above bottom-nav */
  overflow: hidden;
}

.screen-catalog {
  display: flex !important;
  flex-direction: column !important;
  width: 100vw !important;
  max-width: 100vw !important;
  flex: 0 0 100vw !important;
  align-items: stretch !important;
  justify-content: flex-start !important;
  overflow-y: auto !important;
  overflow-x: visible !important;
  padding: 0 !important;
  padding-bottom: 120px !important;
  box-sizing: border-box !important;
  background: var(--bg-cream);
}

.catalog-content {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  width: 100% !important;
  padding: 8px !important;
  gap: 16px;
  box-sizing: border-box !important;
}

.product-card {
  width: 100%;
  max-width: none;
  background: #ffffff;
  border-radius: 20px;
  padding: 16px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* ============================================================
   SCREEN 1 — HERO
   ============================================================ */
.screen-hero {
  background: var(--bg-cream);
}

.hero-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 12px;
  width: 100%;
  max-width: 400px;
}

/* fixed-height media container prevents layout shift while 3D/image loads */
.hero-media {
  width: 100%;
  min-height: 250px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.hero-logo {
  width: 100%;
  max-width: 240px;
  max-height: 35vh;
  height: auto;
  object-fit: contain;
  display: block;
  will-change: transform, opacity;
  transform: translateZ(0);
  opacity: 0;
  animation: fadeInUp 0.7s cubic-bezier(0.34, 1.56, 0.64, 1) 0.1s forwards;
}

.hero-title {
  font-size: 32px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
  max-width: 300px;
  overflow-wrap: break-word;
  opacity: 0;
  animation: fadeInUp 0.7s cubic-bezier(0.34, 1.56, 0.64, 1) 0.25s forwards;
}

.hero-subtitle {
  font-size: 16px;
  color: var(--text-muted);
  overflow-wrap: break-word;
  opacity: 0;
  animation: fadeInUp 0.7s cubic-bezier(0.34, 1.56, 0.64, 1) 0.4s forwards;
}

/* ============================================================
   SCREEN 2 — INTRO
   ============================================================ */
.screen-intro {
  background: var(--bg-cream);
}

.intro-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 16px;
  width: 100%;
  max-width: 400px;
}

.intro-media {
  width: 100%;
  min-height: 250px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.intro-image {
  width: 80%;
  max-width: 280px;
  max-height: 50vh;
  height: auto;
  object-fit: contain;
  display: block;
  will-change: transform, opacity;
  transform: translateZ(0);
  opacity: 0;
  animation: fadeInUp 0.7s cubic-bezier(0.34, 1.56, 0.64, 1) 0.1s forwards;
}

.intro-title {
  font-size: clamp(24px, 6vw, 32px);
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
  overflow-wrap: break-word;
  opacity: 0;
  animation: fadeInUp 0.7s cubic-bezier(0.34, 1.56, 0.64, 1) 0.25s forwards;
}

.intro-subtitle {
  font-size: 16px;
  color: var(--text-muted);
  overflow-wrap: break-word;
  opacity: 0;
  animation: fadeInUp 0.7s cubic-bezier(0.34, 1.56, 0.64, 1) 0.4s forwards;
}

.intro-btn {
  margin-top: 8px;
  padding: 14px 32px;
  background: var(--primary);
  color: #ffffff;
  border: none;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s, transform 0.2s;
  opacity: 0;
  animation: fadeInUp 0.7s cubic-bezier(0.34, 1.56, 0.64, 1) 0.55s forwards;
}
.intro-btn:hover { background: var(--primary-dark); transform: translateY(-2px); }
.intro-btn:active { transform: translateY(0); }

/* ============================================================
   SCREEN 3 — CATALOG (glassmorphism banners)
   ============================================================ */
.screen-catalog .catalog-content {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.store-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px; background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur)); -webkit-backdrop-filter: blur(var(--glass-blur));
  border-bottom: 1px solid var(--glass-border);
  position: sticky; top: 0; z-index: 10;
  gap: 12px;
  border-radius: 0 0 16px 16px;
}
.logo { font-size: 18px; font-weight: 700; color: var(--primary-dark); white-space: nowrap; }

.store-logo {
  height: 44px;
  width: auto;
  object-fit: contain;
  display: block;
}
.header-actions { display: flex; align-items: center; gap: 12px; }
.client-name { font-size: 13px; font-weight: 600; color: var(--text); white-space: nowrap; }

.categories-bar {
  display: flex; gap: 8px; padding: 14px 20px; overflow-x: auto;
  scrollbar-width: none;
}
.categories-bar::-webkit-scrollbar { display: none; }
.cat-pill {
  padding: 8px 18px; border-radius: 24px; border: 1px solid rgba(122,157,140,0.15);
  background: #ffffff; color: var(--text); font-size: 13px; font-weight: 500;
  cursor: pointer; white-space: nowrap; transition: all 0.2s; flex-shrink: 0;
}
.cat-pill:hover { border-color: var(--primary); color: var(--primary); }
.cat-pill.active { background: var(--primary); color: #ffffff; border-color: var(--primary); }

.products-container { padding: 12px 0 20px 0; width: 100%; }

/* Product cards */
.products-grid {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 12px 0 20px 0 !important;
  width: 100% !important;
  align-items: stretch !important;
}

.product-card {
  width: 100% !important;
  max-width: 100% !important;
  background: #ffffff;
  border-radius: 20px;
  padding: 16px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-sizing: border-box;
}

.card-image-wrapper {
  width: 100%;
  height: 180px;
  overflow: hidden;
  border-radius: 12px;
  background: #f5f1ee;
}

.card-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.card-content {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.card-title {
  font-family: 'Poppins', sans-serif;
  font-size: 16px;
  font-weight: 600;
  color: #2B3B34;
  margin: 0;
  overflow-wrap: break-word;
}

.card-subtitle {
  font-size: 12px;
  color: #64748B;
  margin: 0;
  overflow-wrap: break-word;
}

.card-price {
  font-size: 18px;
  font-weight: 700;
  color: #2B3B34;
  margin: 4px 0;
}

.card-promo {
  font-size: 12px;
  color: #9D7A8B;
  background: rgba(157, 122, 139, 0.08);
  padding: 6px 10px;
  border-radius: 8px;
  display: inline-block;
}

.card-btn {
  width: 100%;
  background: #7A9D8C;
  color: #ffffff;
  border: none;
  border-radius: 12px;
  padding: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
  margin-top: 4px;
}

.card-btn:hover {
  background: #5C8273;
}

.promo-banner {
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-card);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: 0 8px 24px rgba(122, 157, 140, 0.12);
  transition: transform 0.2s, box-shadow 0.2s;
}
.promo-banner:hover { transform: translateY(-2px); box-shadow: 0 12px 32px rgba(122, 157, 140, 0.18); }

.promo-banner-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.3;
  overflow-wrap: break-word;
}

.promo-banner-desc {
  font-size: 14px;
  color: var(--text-muted);
  line-height: 1.5;
  overflow-wrap: break-word;
}

.promo-banner-action {
  align-self: flex-start;
  margin-top: 4px;
  padding: 10px 20px;
  background: var(--primary);
  color: #ffffff;
  border: none;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}
.promo-banner-action:hover { background: var(--primary-dark); }

.loading { text-align: center; padding: 40px; color: var(--text-muted); }

/* ============================================================
   STICKY CART BAR
   ============================================================ */
.sticky-cart {
  position: fixed;
  bottom: 90px;
  left: 16px;
  right: 16px;
  z-index: 100;
  background: #ffffff;
  border-radius: 16px;
  box-shadow: 0 4px 15px rgba(0,0,0,0.1);
  padding: 16px;
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  transition: transform 0.3s ease;
}
.sticky-cart.show { display: flex; transform: translateY(0); }
.sticky-cart-info { display: flex; flex-direction: column; }
.sticky-cart-label { font-size: 12px; color: #6b7280; }
.sticky-cart-total { font-size: 18px; font-weight: 700; color: var(--text); }
.sticky-checkout {
  padding: 12px 24px; background: var(--primary); color: #ffffff;
  border: none; border-radius: 12px; font-size: 15px; font-weight: 600; cursor: pointer;
  transition: background 0.2s; white-space: nowrap;
}
.sticky-checkout:hover { background: var(--primary-dark); }

/* ============================================================
   FLOATING BOTTOM NAV (fixed, above everything except modals)
   ============================================================ */
.bottom-nav {
  position: fixed !important;
  bottom: calc(16px + env(safe-area-inset-bottom, 0px)) !important;
  left: 16px !important;
  right: 16px !important;
  background: rgba(43, 59, 52, 0.6) !important;
  border-radius: 24px !important;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25) !important;
  border: 1px solid rgba(255, 255, 255, 0.1) !important;
  display: flex !important;
  justify-content: space-around !important;
  align-items: center !important;
  z-index: 9999 !important;
  height: 70px !important;
  padding: 0 8px !important;
  isolation: isolate !important;
  overflow: visible !important;
}

.bottom-nav::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: inherit;
  -webkit-backdrop-filter: blur(12px) saturate(180%);
  backdrop-filter: blur(12px) saturate(180%);
}

@supports (backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px)) {
  .bottom-nav::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    border-radius: inherit;
    -webkit-backdrop-filter: blur(12px) saturate(180%);
    backdrop-filter: blur(12px) saturate(180%);
  }
}

.nav-btn {
  color: #ffffff !important;
  opacity: 0.85 !important;
  background: transparent !important;
  border: none !important;
  display: flex !important;
  flex-direction: column !important;
  justify-content: center !important;
  align-items: center !important;
  gap: 4px !important;
  position: relative !important;
  z-index: 1 !important;
}

.nav-btn svg,
.nav-btn span {
  position: relative !important;
  z-index: 1 !important;
}

.nav-btn svg {
  stroke: #ffffff !important;
  color: #ffffff !important;
}

.nav-btn span {
  font-size: 11px !important;
  line-height: 1 !important;
  margin-top: 2px !important;
}

.nav-btn.active {
  color: #2B3B34 !important;
  opacity: 1 !important;
  font-weight: 600 !important;
}

.nav-btn.active::before {
  content: "";
  position: absolute;
  top: 4px;
  left: 50%;
  transform: translateX(-50%);
  width: 48px;
  height: 32px;
  background: rgba(43, 59, 52, 0.1) !important;
  border-radius: 12px;
  z-index: 0 !important;
}

.cart-icon-wrapper {
  position: relative !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  width: 24px !important;
  height: 24px !important;
  overflow: visible !important;
}

.cart-badge {
  position: absolute !important;
  top: 0 !important;
  right: 0 !important;
  transform: translate(50%, -50%) !important;
  background: #9D7A8B !important;
  color: #ffffff !important;
  font-size: 10px !important;
  font-weight: 700 !important;
  min-width: 18px !important;
  height: 18px !important;
  padding: 0 4px !important;
  border-radius: 9px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  border: 1.5px solid #FCFBF8 !important;
  box-sizing: border-box !important;
  z-index: 10 !important;
}

.cart-badge.show { display: flex !important; }

/* ============================================================
   MODALS (cart / chat) — unchanged logic, restyled lightly
   ============================================================ */
.cart-overlay, .chat-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 10000;
  display: none; backdrop-filter: blur(4px);
}
.cart-overlay.open, .chat-overlay.open { display: block; }

.cart-modal, .chat-modal {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 10001;
  background: #ffffff; border-radius: 20px 20px 0 0;
  max-height: 85vh; display: flex; flex-direction: column;
  transform: translateY(100%); transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 -8px 32px rgba(0,0,0,0.1);
}
.cart-modal.open, .chat-modal.open { transform: translateY(0); }

.cart-modal-header, .chat-modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 24px; border-bottom: 1px solid rgba(122,157,140,0.1);
}
.cart-modal-header h2, .chat-modal-header h2 { font-size: 18px; font-weight: 600; color: var(--text); }
.cart-modal-close, .chat-modal-close {
  background: transparent; border: none; cursor: pointer;
  font-size: 24px; color: var(--text); padding: 4px 8px; border-radius: 8px;
}
.cart-modal-items { flex: 1; overflow-y: auto; padding: 16px 24px; }
.cart-modal-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 0; border-bottom: 1px solid rgba(122,157,140,0.06); gap: 12px;
}
.cart-modal-item-info { flex: 1; }
.cart-modal-item-name { font-size: 14px; font-weight: 500; color: var(--text); }
.cart-modal-item-detail { font-size: 12px; color: #6b7280; margin-top: 2px; }
.cart-modal-item-actions { display: flex; align-items: center; gap: 12px; }
.cart-modal-item-price { font-size: 14px; font-weight: 700; color: var(--primary); min-width: 80px; text-align: right; }
.cart-modal-qty { display: flex; align-items: center; border: 1px solid rgba(122,157,140,0.2); border-radius: 8px; overflow: hidden; }
.cart-modal-qty button { width: 28px; height: 28px; border: none; background: rgba(122,157,140,0.08); color: var(--primary); font-size: 14px; font-weight: 700; cursor: pointer; }
.cart-modal-qty span { width: 28px; text-align: center; font-size: 13px; font-weight: 600; }
.cart-modal-footer { padding: 20px 24px; border-top: 1px solid rgba(122,157,140,0.1); }
.cart-modal-total { display: flex; justify-content: space-between; margin-bottom: 16px; font-size: 18px; font-weight: 700; color: var(--text); }
.cart-modal-checkout { width: 100%; padding: 14px; background: var(--primary); color: #ffffff; border: none; border-radius: 12px; font-size: 16px; font-weight: 600; cursor: pointer; transition: background 0.2s; }
.cart-modal-checkout:hover { background: var(--primary-dark); }
.empty-cart { text-align: center; padding: 40px; color: var(--text-muted); }

.chat-modal-messages { flex: 1; overflow-y: auto; padding: 16px 24px; display: flex; flex-direction: column; gap: 10px; }
.chat-msg { max-width: 80%; padding: 10px 14px; border-radius: 12px; font-size: 14px; line-height: 1.4; white-space: pre-wrap; }
.chat-msg-user { align-self: flex-end; background: var(--primary); color: #ffffff; border-bottom-right-radius: 4px; }
.chat-msg-assistant { align-self: flex-start; background: rgba(122,157,140,0.08); color: var(--text); border-bottom-left-radius: 4px; }
.chat-modal-buttons { padding: 8px 24px; display: flex; flex-wrap: wrap; gap: 8px; }
.chat-btn { padding: 8px 14px; background: #ffffff; border: 1px solid rgba(122,157,140,0.2); border-radius: 20px; font-size: 13px; cursor: pointer; color: var(--primary); }
.chat-btn:hover { background: rgba(122,157,140,0.08); }
.chat-modal-form { display: flex; gap: 8px; padding: 16px 24px; border-top: 1px solid rgba(122,157,140,0.1); }
.chat-modal-form input { flex: 1; padding: 10px 14px; border: 1px solid rgba(122,157,140,0.15); border-radius: 12px; font-size: 14px; outline: none; font-family: inherit; pointer-events: auto; z-index: 10002; position: relative; }
.chat-modal-form input:focus { border-color: var(--primary); }
.chat-send-btn { padding: 10px 18px; background: var(--primary); color: #ffffff; border: none; border-radius: 12px; font-weight: 600; cursor: pointer; }

/* ============================================================
   ANIMATIONS
   ============================================================ */
.fade-in-up {
  opacity: 0;
  transform: translateY(24px);
  animation: fadeInUp 0.7s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(24px) translateZ(0); }
  to   { opacity: 1; transform: translateY(0) translateZ(0); }
}

/* skeleton loader for heavy media */
.skeleton {
  background: linear-gradient(90deg, rgba(122,157,140,0.08) 0%, rgba(122,157,140,0.18) 50%, rgba(122,157,140,0.08) 100%);
  background-size: 200% 100%;
  animation: skeletonShimmer 1.4s ease-in-out infinite;
  border-radius: 12px;
}
@keyframes skeletonShimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ============================================================
   SWIPE ARROW HINT
   ============================================================ */
.swipe-arrow {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    color: #7A9D8C;
    opacity: 0.6;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: nudgeRight 2s infinite ease-in-out;
    pointer-events: none;
    z-index: 10;
}

@keyframes nudgeRight {
    0%, 100% { transform: translateY(-50%) translateX(0); }
    50% { transform: translateY(-50%) translateX(4px); }
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (min-width: 720px) {
  .hero-title { font-size: 36px; }
  .intro-title { font-size: 36px; }
}
