/* Phase 10J — automatic system theme, contrast and stacking consistency */

/* The account menu must remain above catalogue, menu and hero stacking contexts. */
body.ff-storefront .ff-topbar {
  position: relative !important;
  z-index: 1400 !important;
  overflow: visible !important;
}
body.ff-storefront .ff-topbar .container,
body.ff-storefront .ff-topbar .row,
body.ff-storefront .ff-topbar .dropdown,
body.ff-storefront .ff-topbar .list-inline,
body.ff-storefront .ff-topbar .list-inline-item { overflow: visible !important; }
body.ff-storefront .ff-topbar .dropdown-menu {
  z-index: 1450 !important;
  min-width: 220px;
}
body.ff-storefront .ff-topbar .dropdown-menu.show { display: block !important; }

/* Mobile cart quantity is rendered by the cart fragment, so AJAX refreshes it. */
.ff-header-cart-count { display: none; }
.ff-mini-cart-toggle { position: relative; }

/* Product descriptions should never inherit faint catalogue copy colours. */
body.ff-storefront #tab-description,
body.ff-storefront #tab-description :where(p, div, span, li, strong, b, em, blockquote, td, th) {
  color: #111714 !important;
}
body.ff-storefront #tab-description a { color: #0f7540 !important; }
body.ff-storefront #tab-description table { border-color: rgba(17,23,20,.16); }

@media (max-width: 767.98px) {
  body.ff-storefront .ff-header #cart .ff-mini-cart-toggle .ff-header-cart-count {
    position: absolute;
    z-index: 2;
    top: -6px;
    right: -6px;
    display: grid !important;
    min-width: 22px;
    height: 22px;
    padding: 0 6px;
    place-items: center;
    border: 2px solid #fff;
    border-radius: 999px;
    color: #101711;
    background: #ffca00;
    box-shadow: 0 7px 18px rgba(61,48,0,.25);
    font-size: .64rem;
    font-weight: 950;
    line-height: 1;
  }
  body.ff-storefront .ff-header #cart .ff-mini-cart-toggle .ff-header-cart-count[hidden] { display: none !important; }
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --ff-ice: #17251f;
    --ff-ice-soft: #111b17;
    --ff-yellow: #ffcf24;
    --ff-yellow-deep: #f1bc00;
    --ff-ink: #eef6f1;
    --ff-muted: #b2c1b9;
    --ff-blue: #83cbe5;
    --ff-line: rgba(221,239,229,.14);
    --ff-glass: rgba(22,33,28,.86);
    --ff-shadow: 0 22px 60px rgba(0,0,0,.35);
    --ff-green: #3bc574;
    --ff-green-deep: #177447;
    --ff-green-soft: #183c29;
    --ff-orange: #ffcf24;
    --ff-surface: #0b120f;
    --ff-card: rgba(21,32,27,.9);
    --ff-card-solid: #17211c;
    --ff-neutral-line: rgba(221,239,229,.14);
    --ff-neutral-shadow: 0 18px 54px rgba(0,0,0,.28);
    --ff-home-green: #238a55;
    --ff-home-green-bright: #65d28d;
    --ff-home-ink: #f0f7f3;
    --ff-home-muted: #b4c4bb;
    --ff-home-pastel: #173b29;
    --ff-home-pastel-blue: #18333b;
    --ff-home-line: rgba(224,241,232,.14);
  }

  html { background: #0b120f !important; }
  body.ff-storefront {
    --bs-body-color: #edf5f0;
    --bs-body-bg: #0b120f;
    --bs-secondary-color: #b2c0b8;
    --bs-tertiary-bg: #17211c;
    --bs-border-color: #35453d;
    color: #edf5f0 !important;
    background:
      radial-gradient(circle at 8% 3%, rgba(33,91,62,.24), transparent 30rem),
      radial-gradient(circle at 94% 16%, rgba(255,207,36,.07), transparent 26rem),
      #0b120f !important;
  }
  body.ff-storefront #container,
  body.ff-storefront #ff-main-content { background: transparent; }
  body.ff-storefront h1,
  body.ff-storefront h2,
  body.ff-storefront h3,
  body.ff-storefront h4,
  body.ff-storefront h5,
  body.ff-storefront h6 { color: #f2f8f4 !important; }
  body.ff-storefront a { color: #78d89a; }
  body.ff-storefront a:hover { color: #a4ebbb; }
  body.ff-storefront hr { border-color: rgba(224,241,232,.15); opacity: 1; }

  body.ff-storefront .ff-topbar {
    border-color: rgba(224,241,232,.1) !important;
    background: rgba(11,18,15,.9) !important;
  }
  body.ff-storefront .ff-topbar a { color: #c2d0c8 !important; }
  body.ff-storefront .ff-topbar a:hover { color: #79d99b !important; }
  body.ff-storefront .ff-header { background: rgba(13,21,17,.86) !important; }
  body.ff-storefront .ff-brand-image-link {
    padding: 5px 9px;
    border: 1px solid rgba(255,255,255,.8);
    border-radius: 16px;
    background: rgba(255,255,255,.94);
    box-shadow: 0 10px 28px rgba(0,0,0,.2);
  }

  body.ff-storefront .ff-search-form,
  body.ff-storefront .ff-search-suggestions {
    border-color: rgba(224,241,232,.16) !important;
    color: #edf5f0;
    background: rgba(24,36,30,.94) !important;
    box-shadow: 0 12px 34px rgba(0,0,0,.25) !important;
  }
  body.ff-storefront .ff-search-form .form-control {
    color: #f1f7f3 !important;
    background: transparent !important;
  }
  body.ff-storefront .ff-search-form .form-control::placeholder { color: #91a39a !important; opacity: 1; }
  body.ff-storefront .ff-search-icon { color: #9db0a6; }
  body.ff-storefront .ff-search-submit { border-color: #3caa6d !important; background: #207c4d !important; color: #fff !important; }
  body.ff-storefront .ff-search-submit:hover { background: #29955e !important; }

  body.ff-storefront #menu {
    border-color: rgba(224,241,232,.13) !important;
    background: rgba(20,31,26,.9) !important;
    box-shadow: 0 14px 40px rgba(0,0,0,.24) !important;
  }
  body.ff-storefront #category,
  body.ff-storefront #menu .navbar-toggler i,
  body.ff-storefront #menu .navbar-nav > li > a,
  body.ff-storefront #menu .navbar-nav > li > .dropdown-item { color: #e7f1eb !important; }
  body.ff-storefront #menu .navbar-nav > li > a:hover,
  body.ff-storefront #menu .navbar-nav > li > a.show,
  body.ff-storefront #menu .navbar-nav > li > .dropdown-item:hover { color: #ecfff3 !important; background: #205338 !important; }

  body.ff-storefront #menu .dropdown-menu,
  body.ff-storefront .ff-mini-cart-panel,
  body.ff-storefront .ff-topbar .dropdown-menu,
  body.ff-storefront .dropdown-menu,
  body.ff-storefront .modal-content {
    border-color: rgba(224,241,232,.18) !important;
    color: #edf5f0 !important;
    background: linear-gradient(145deg, rgba(28,42,35,.98), rgba(17,27,22,.98)) !important;
    box-shadow: inset 0 1px 0 rgba(255,255,255,.06), 0 30px 85px rgba(0,0,0,.5) !important;
  }
  body.ff-storefront #menu .dropdown-menu .dropdown-item,
  body.ff-storefront .dropdown-menu .dropdown-item { color: #e4eee8 !important; text-shadow: none !important; }
  body.ff-storefront #menu .dropdown-menu .dropdown-item:hover,
  body.ff-storefront .dropdown-menu .dropdown-item:hover { color: #fff !important; background: #23553a !important; }
  body.ff-storefront .dropdown-divider { border-color: rgba(224,241,232,.14); }

  body.ff-storefront .breadcrumb {
    border-color: rgba(224,241,232,.12) !important;
    color: #b7c7be;
    background: rgba(23,34,29,.78) !important;
  }
  body.ff-storefront .breadcrumb a { color: #8bdca6; }

  /* A shared dark glass treatment prevents each page from feeling unrelated. */
  body.ff-storefront :is(
    .ff-home-intro,
    .ff-home-slide,
    .ff-home-metrics,
    .ff-home-metrics > div,
    .ff-home-slide-points > div,
    .ff-home-local-grid > div,
    .ff-home-seller,
    .ff-home-confidence > div,
    .ff-category-hero,
    .ff-search-hero,
    .ff-seller-directory-hero,
    .ff-discovery-toolbar,
    .product-thumb.ff-product-card,
    .ff-product-stage,
    .ff-product-details,
    .ff-buy-panel,
    .ff-product-seller-card,
    .ff-cart-intro,
    .ff-cart-item,
    .ff-cart-summary,
    .ff-checkout-header,
    .ff-checkout-details,
    .ff-checkout-method,
    .ff-checkout-confirm,
    .ff-checkout-security,
    .ff-auth-shell,
    .ff-auth-form,
    .ff-account-hero,
    .ff-account-stats > a,
    .ff-account-grid > section,
    .ff-account-extra,
    .ff-wishlist-card,
    .ff-order-card,
    .ff-success-card,
    .ff-register-form,
    .ff-seller-about,
    .ff-seller-trust,
    .ff-seller-product,
    .ff-seller-directory-card,
    .ff-information-card,
    .card
  ) {
    border-color: rgba(224,241,232,.13) !important;
    color: #edf5f0 !important;
    background-color: rgba(22,33,28,.92) !important;
    box-shadow: inset 0 1px 0 rgba(255,255,255,.045), 0 17px 48px rgba(0,0,0,.26) !important;
  }

  body.ff-storefront .ff-home-slide-intro { background: linear-gradient(130deg, rgba(27,41,34,.96), rgba(15,31,23,.96)) !important; }
  body.ff-storefront .ff-home-slide-sellers { background: linear-gradient(130deg, rgba(21,38,29,.97), rgba(20,39,45,.94)) !important; }
  body.ff-storefront .ff-home-slide-local { background: linear-gradient(130deg, rgba(27,40,33,.97), rgba(43,39,21,.9)) !important; }
  body.ff-storefront .ff-home-slide::after { border-color: rgba(101,210,141,.08); }
  body.ff-storefront .ff-home-slide .ff-eyebrow,
  body.ff-storefront .ff-kicker { border-color: rgba(101,210,141,.15); color: #89dda6; background: rgba(27,74,45,.55); }
  body.ff-storefront .ff-home-slide-copy > p,
  body.ff-storefront .ff-home-heading p,
  body.ff-storefront .ff-home-confidence small,
  body.ff-storefront .ff-home-seller-body small,
  body.ff-storefront .ff-home-seller-body em { color: #b1c1b8 !important; }
  body.ff-storefront .ff-home-metrics > p { background: #17673f !important; }
  body.ff-storefront .ff-home-slide-points i,
  body.ff-storefront .ff-home-confidence > div > i { color: #8ae0a7; background: #183e2a; }
  body.ff-storefront .ff-home-local-grid i { color: #76d99b; }
  body.ff-storefront .ff-home-secondary,
  body.ff-storefront .ff-seller-directory-link { border-color: rgba(110,211,148,.25) !important; color: #a2e8ba !important; background: linear-gradient(135deg,#173b29,#18333b) !important; }
  body.ff-storefront .ff-home-secondary i:first-child { color: #9ae5b4; background: #22523a; }

  body.ff-storefront .ff-product-card .image,
  body.ff-storefront .ff-wishlist-image,
  body.ff-storefront .ff-main-image,
  body.ff-storefront .ff-gallery-thumbs a,
  body.ff-storefront .ff-mini-cart-image,
  body.ff-storefront .ff-cart-item-image { background: #f3f5f2 !important; }
  body.ff-storefront .ff-product-card .description h4 a,
  body.ff-storefront .ff-product-card .description h4,
  body.ff-storefront .ff-product-card .price,
  body.ff-storefront .ff-product-card .price-new,
  body.ff-storefront .ff-product-purchase h1,
  body.ff-storefront .ff-related-heading h2,
  body.ff-storefront .ff-seller-products-heading h2 { color: #f2f8f4 !important; }
  body.ff-storefront .ff-product-card .description > p,
  body.ff-storefront .ff-product-card .price-tax,
  body.ff-storefront .ff-product-meta,
  body.ff-storefront .ff-mini-cart-copy small { color: #aebdb5 !important; }
  body.ff-storefront .ff-product-card .button button:not(.ff-add-cart) { border-color: rgba(224,241,232,.13) !important; color: #dce8e1 !important; background: #24342c !important; }

  /* Product-page description: high contrast, including imported inline colours. */
  body.ff-storefront #tab-description,
  body.ff-storefront #tab-description :where(p, div, span, li, strong, b, em, blockquote, td, th) { color: #edf5f0 !important; }
  body.ff-storefront #tab-description a { color: #8ee1aa !important; }
  body.ff-storefront #tab-description table { border-color: rgba(224,241,232,.18); background: transparent !important; }
  body.ff-storefront .ff-product-tabs .nav-link { border-color: rgba(224,241,232,.14) !important; color: #c7d5cd !important; background: #24342c !important; }
  body.ff-storefront .ff-product-tabs .nav-link.active { border-color: #4bc47b !important; color: #fff !important; background: #257c4e !important; }

  body.ff-storefront :is(input, select, textarea, .form-control, .form-select) {
    border-color: rgba(224,241,232,.16) !important;
    color: #eef5f1 !important;
    background-color: #18251f !important;
  }
  body.ff-storefront :is(input, textarea, .form-control)::placeholder { color: #8fa198 !important; opacity: 1; }
  body.ff-storefront :is(input, select, textarea, .form-control, .form-select):focus {
    border-color: #4cc77d !important;
    box-shadow: 0 0 0 4px rgba(76,199,125,.16) !important;
  }
  body.ff-storefront .form-check-input:checked { border-color: #42bd73 !important; background-color: #2b995c !important; }

  body.ff-storefront :is(.table, table) { --bs-table-color: #e9f2ed; --bs-table-bg: transparent; --bs-table-border-color: rgba(224,241,232,.14); color: #e9f2ed; }
  body.ff-storefront :is(.list-group-item, .accordion-item, .accordion-button) { border-color: rgba(224,241,232,.13) !important; color: #e8f1ec !important; background: #18251f !important; }
  body.ff-storefront .accordion-button:not(.collapsed) { color: #a0e6b7 !important; background: #1c3828 !important; }

  /* Orange remains the purchase accent, with black text for WCAG contrast. */
  body.ff-storefront :is(
    .ff-add-cart,
    .ff-buy-panel #button-cart,
    .ff-mobile-buybar button,
    .ff-wishlist-actions button,
    .ff-auth-submit,
    .btn-warning
  ) {
    border-color: #ffe169 !important;
    color: #11170f !important;
    background: #ffcf24 !important;
    box-shadow: 0 11px 27px rgba(255,207,36,.19) !important;
  }
  body.ff-storefront :is(
    .ff-add-cart,
    .ff-buy-panel #button-cart,
    .ff-mobile-buybar button,
    .ff-wishlist-actions button,
    .ff-auth-submit,
    .btn-warning
  ):hover { color: #0d120d !important; background: #ffdc55 !important; }
  body.ff-storefront .ff-out-of-stock,
  body.ff-storefront button:disabled { border-color: #45534c !important; color: #a5b1aa !important; background: #2a342f !important; box-shadow: none !important; }

  body.ff-storefront .ff-whatsapp-enquiry { border-color: #16a34a; color: #fff !important; background: #16a34a; }
  body.ff-storefront .ff-whatsapp-enquiry:hover, body.ff-storefront .ff-whatsapp-enquiry:focus { border-color: #22b957; color: #fff !important; background: #12813d; }
  body.ff-storefront .ff-mini-cart-product,
  body.ff-storefront .ff-mini-cart-totals { border-color: rgba(224,241,232,.12); background: rgba(36,52,44,.86); }
  body.ff-storefront .ff-mini-cart-copy > a,
  body.ff-storefront .ff-mini-cart-copy strong,
  body.ff-storefront .ff-mini-cart-heading strong { color: #eff6f2; }
  body.ff-storefront .ff-mini-view { border-color: rgba(224,241,232,.14); color: #dce8e1; background: #24342c; }
  body.ff-storefront .ff-mini-checkout { color: #fff; background: #238653; }

  body.ff-storefront .ff-mobile-dock,
  body.ff-storefront .ff-mobile-buybar,
  body.ff-storefront .ff-mobile-checkout {
    border-color: rgba(224,241,232,.17) !important;
    color: #dfeae4;
    background: rgba(20,31,26,.9) !important;
    box-shadow: 0 18px 55px rgba(0,0,0,.45), inset 0 1px 0 rgba(255,255,255,.06) !important;
  }
  body.ff-storefront .ff-mobile-dock::before { background: linear-gradient(125deg,rgba(255,255,255,.035),rgba(61,197,116,.08)) !important; }
  body.ff-storefront .ff-mobile-dock a { color: #9eafa6; }
  body.ff-storefront .ff-mobile-dock a:hover,
  body.ff-storefront .ff-mobile-dock a.ff-active { color: #a3e8ba; background: rgba(45,91,63,.5); }
  body.ff-storefront .ff-mobile-dock a.ff-active::after { background: #69d790; }
  body.ff-storefront .ff-header #cart .ff-mini-cart-toggle .ff-header-cart-count { border-color: #14201a; color: #101710; background: #ffcf24; }

  body.ff-storefront .pagination .page-link { border-color: rgba(224,241,232,.13); color: #b9d8c6; background: rgba(24,37,30,.9); }
  body.ff-storefront .pagination .active .page-link,
  body.ff-storefront .pagination .page-link:hover { border-color: #318f5b; color: #fff; background: #23784c; }
  body.ff-storefront .ff-footer { border-top: 1px solid rgba(224,241,232,.1); background: #08100c !important; }
}

@media (prefers-color-scheme: dark) and (prefers-contrast: more) {
  body.ff-storefront { color: #fff !important; }
  body.ff-storefront :is(.product-thumb.ff-product-card,.ff-product-details,.ff-cart-item,.ff-checkout-details,.ff-account-grid > section) { border-color: rgba(255,255,255,.3) !important; }
  body.ff-storefront :is(.ff-add-cart,.ff-buy-panel #button-cart,.ff-mobile-buybar button) { background: #ffdc46 !important; }
}
