/**
 * NORDAN WoodMart compatibility UI | 1.1.0 draft
 * Components use shared semantic tokens; no changes to parent theme.
 * Avoid blanket backgrounds for widgets, columns or product images.
 */

/* PAGE FOUNDATIONS */
html[data-theme="light"] body,
html[data-theme="dark"] body {
  color:var(--nd-text-secondary);
  background-color:var(--nd-bg);
}
html[data-theme="dark"] :is(.main-page-wrapper,.wd-page-wrapper,.site-content,.wd-content-layout) {
  color:var(--nd-text-secondary);
  background-color:var(--nd-bg);
}
html[data-theme="dark"] :is(.wd-footer,.footer-container,.footer-sidebar) {
  background-color:var(--nd-bg-alt);
  color:var(--nd-text-secondary);
}
html[data-theme="dark"] :is(h1,h2,h3,h4,h5,h6,.wd-entities-title,.wd-post-title,.entry-title,.widget-title,.widgettitle) {
  color:var(--nd-text);
}
html[data-theme="dark"] :is(.wd-page-title,.page-title) {
  background-color:var(--nd-bg-alt);
  color:var(--nd-text);
}
html[data-theme="dark"] .wd-page-title :is(h1,h2,h3,h4,h5,h6,a,.breadcrumbs,.woocommerce-breadcrumb) {
  color:var(--nd-text);
}
html[data-theme="dark"] :is(hr,table th,table td,fieldset,.wd-divider) {
  border-color:var(--nd-border);
}
html[data-theme="dark"] :is(.woocommerce-Price-amount,.price,.amount) {
  color:var(--nd-primary);
}
html[data-theme="dark"] :is(.woocommerce-Price-amount,.price,.amount) del .amount {
  color:var(--nd-text-muted);
}

/* WOODMART HEADER: fix white rows and near-invisible links from light preset. */
html[data-theme="dark"] .whb-main-header .whb-color-dark:not(.whb-with-bg),
html[data-theme="dark"] .whb-main-header .whb-color-dark.whb-with-bg,
html[data-theme="dark"] .whb-general-header,
html[data-theme="dark"] .whb-header-bottom {
  background-color:var(--nd-bg-alt);
}
html[data-theme="dark"] .whb-main-header :is(.wd-tools-element,.wd-header-text,.wd-nav) {
  --wd-header-el-color:var(--nd-text);
  --wd-header-el-color-hover:var(--nd-primary);
  --nav-color:var(--nd-text);
  --nav-color-hover:var(--nd-primary);
}
html[data-theme="dark"] .whb-main-header :is(.wd-tools-element>a,.wd-nav>a,.wd-nav>li>a,.wd-header-text,.wd-header-html) {
  color:var(--nd-text);
}
html[data-theme="dark"] .whb-main-header :is(.wd-tools-element>a,.wd-nav>li>a):hover {
  color:var(--nd-primary);
}
/* Until a proper NORDAN light-on-dark logo is supplied, invert the old black wordmark. */
html[data-theme="dark"] .whb-main-header .site-logo img {
  filter:brightness(0) invert(1);
}
html[data-theme="dark"] .whb-main-header :is(.whb-row,.wd-nav,.whb-header-bottom) {
  border-color:var(--nd-border);
}
/* Glass only when the header is floating/sticky, never every header row. */
.whb-sticked .whb-general-header:not(.whb-with-bg),
.whb-sticked .whb-general-header.whb-with-bg {
  background-color:var(--nd-glass-bg);
  border-bottom:1px solid var(--nd-glass-border);
}

/* DROPDOWNS, MENUS AND MOBILE NAV */
html[data-theme="dark"] :is(.wd-dropdown,.wd-dropdown-menu,.wd-search-dropdown,.wd-search-results,.wd-nav-mobile,.mobile-nav,.wd-side-hidden) {
  background-color:var(--nd-elevated);
  color:var(--nd-text-secondary);
  border-color:var(--nd-border);
}
html[data-theme="dark"] :is(.wd-dropdown,.wd-dropdown-menu,.wd-search-results,.wd-nav-mobile,.mobile-nav) :is(a,li,span) {
  color:var(--nd-text-secondary);
}
html[data-theme="dark"] :is(.wd-dropdown,.wd-nav-mobile,.mobile-nav) a:hover {
  color:var(--nd-primary);
}
html[data-theme="dark"] :is(.wd-dropdown,.wd-search-dropdown,.wd-nav-mobile) :is(.wd-title,.wd-entities-title,h3,h4) {
  color:var(--nd-text);
}

/* BLOG CARDS AND SIDEBAR: use WoodMart's existing 25px padding, no blanket widget boxes. */
html[data-theme="dark"] .blog-style-bg :is(.wd-post-content,.wd-post-inner),
html[data-theme="dark"] .blog-design-default.blog-style-bg .wd-post-content,
html[data-theme="dark"] .blog-design-default-alt.blog-style-bg .wd-post-content {
  background-color:var(--nd-surface);
  color:var(--nd-text-secondary);
  border-color:var(--nd-border);
}
html[data-theme="dark"] .wd-post :is(.wd-post-title,.wd-post-title a,.wd-post-excerpt,.wd-post-meta,.wd-post-meta a) {
  color:var(--nd-text-secondary);
}
html[data-theme="dark"] .wd-post :is(.wd-post-title,.wd-post-title a) {
  color:var(--nd-text);
}
html[data-theme="dark"] :is(.widget,.wd-widget) {
  color:var(--nd-text-secondary);
  border-color:var(--nd-border);
  background-color:transparent;
}
html[data-theme="dark"] :is(.widget,.wd-widget) :is(a,.widget-title,.widgettitle) {
  color:var(--nd-text);
}

/* PRODUCTS: keep photography unfiltered and avoid per-product backdrop-filter. */
html[data-theme="dark"] :is(.wd-product,.product-grid-item) {
  --wd-prod-bg:var(--nd-surface);
  color:var(--nd-text-secondary);
}
html[data-theme="dark"] :is(.wd-product-wrapper,.wd-product-card-hover,.product-element-bottom,.wd-product .wrapp-swatches,.quick-shop-wrapper) {
  background-color:var(--nd-surface);
  color:var(--nd-text-secondary);
  border-color:var(--nd-border);
}
html[data-theme="dark"] :is(.wd-product,.product-grid-item) :is(.wd-entities-title,.wd-entities-title a,.wd-product-title,.product-title) {
  color:var(--nd-text);
}
html[data-theme="dark"] :is(.wd-product,.product-grid-item) :is(.price,.amount) {
  color:var(--nd-primary);
}
html[data-theme="dark"] :is(.wd-product,.product-grid-item) :is(del,del .amount) {
  color:var(--nd-text-muted);
}
html[data-theme="dark"] :is(.wd-product,.product-grid-item) :is(img,.product-image-link) {
  filter:none;
}
.wd-product.wd-hover-base .product-element-bottom {
  padding-inline:14px;
}
html[data-theme="dark"] :is(.wd-shop-tools,.shop-loop-head,.wd-products-per-page,.wd-products-shop-view,.woocommerce-ordering) {
  color:var(--nd-text-secondary);
}
html[data-theme="dark"] .woocommerce-ordering select,
html[data-theme="dark"] :is(.wd-products-per-page a,.wd-products-shop-view a) {
  color:var(--nd-text-secondary);
}
html[data-theme="dark"] :is(.woocommerce-pagination,.wd-pagination) :is(a,span,.page-numbers) {
  color:var(--nd-text-secondary);
  border-color:var(--nd-border);
}
html[data-theme="dark"] :is(.woocommerce-pagination,.wd-pagination) :is(.current,.current-variation) {
  color:var(--nd-on-primary);
  background-color:var(--nd-primary);
  border-radius:var(--nd-radius-sm);
}
html[data-theme="dark"] :is(.wd-product-label,.onsale,.wd-label) {
  border-radius:var(--nd-radius-sm);
}

/* QUICK VIEW: fix white-on-white popup text and its separate inner surfaces. */
html[data-theme="dark"] :is(.wd-popup-quick-view-wrap .mfp-content,.wd-popup-quick-view-wrap .popup-quick-view,.popup-quick-view,.wd-popup,.wd-popup .wd-scroll-content) {
  background-color:var(--nd-elevated);
  color:var(--nd-text-secondary);
}
html[data-theme="dark"] .popup-quick-view :is(.entry-summary,.summary-inner,.product-image-summary,.wd-scroll-content) {
  color:var(--nd-text-secondary);
}
html[data-theme="dark"] .popup-quick-view :is(.product_title,.wd-entities-title,h1,h2,h3,h4) {
  color:var(--nd-text);
}
html[data-theme="dark"] .popup-quick-view :is(.woocommerce-product-details__short-description,.product_meta,p,li) {
  color:var(--nd-text-secondary);
}
html[data-theme="dark"] .popup-quick-view :is(.price,.amount) {
  color:var(--nd-primary);
}
html[data-theme="dark"] .popup-quick-view :is(.woocommerce-product-gallery,img) {
  filter:none;
}
html[data-theme="dark"] .popup-quick-view :is(hr,.wd-divider,.product_meta) {
  border-color:var(--nd-border);
}

/* Mobile RTL menu: mirror only the collapsed-arrow direction, not its position. */
.wd-nav-mobile > li > .wd-nav-opener:not(.wd-active)::after {
  transform:rotate(180deg);
}
/* SIDE CART: heading, empty icon, message, CTA and separators. */
html[data-theme="dark"] :is(.cart-widget-side,.cart-widget-side .widget_shopping_cart_content,.cart-widget-side .wd-heading,.wd-side-hidden.cart-widget-side) {
  background-color:var(--nd-elevated);
  color:var(--nd-text-secondary);
  border-color:var(--nd-border);
}
html[data-theme="dark"] .cart-widget-side :is(h2,h3,.title,.wd-entities-title,.wd-heading a,.wd-heading .title) {
  color:var(--nd-text);
}
html[data-theme="dark"] .cart-widget-side :is(.wd-empty-mini-cart,.wd-empty-mini-cart:before,.woocommerce-mini-cart__empty-message,.woocommerce-mini-cart__total,.woocommerce-mini-cart__total strong) {
  color:var(--nd-text-secondary);
}
html[data-theme="dark"] .cart-widget-side :is(.wd-empty-mini-cart .btn,.woocommerce-mini-cart__buttons .checkout) {
  color:var(--nd-on-primary);
  background-color:var(--nd-primary);
}
html[data-theme="dark"] .cart-widget-side :is(.wd-heading,.woocommerce-mini-cart__total,.woocommerce-mini-cart>li) {
  border-color:var(--nd-border);
}
/* Floating demo switcher must never block quick view or the side cart. */
body:has(.cart-widget-side.wd-opened) .nd-theme-control,
body:has(.wd-popup-quick-view-wrap.mfp-ready) .nd-theme-control {
  opacity:0;
  pointer-events:none;
}

/* MY ACCOUNT: keep WoodMart's built-in grid/spacing, fix tile and menu states. */
html[data-theme="dark"] :is(.woocommerce-MyAccount-content,.woocommerce-MyAccount-navigation,.wd-my-account-links) {
  color:var(--nd-text-secondary);
}
html[data-theme="dark"] .woocommerce-MyAccount-content :is(.wd-nav-my-acc>li>a,.woocommerce-Address,.woocommerce-orders-table,.wd-wishlist-product) {
  color:var(--nd-text);
  border-color:var(--nd-border);
  background-color:var(--nd-surface);
  border-radius:var(--nd-radius-md);
}
html[data-theme="dark"] .wd-builder-off .woocommerce-MyAccount-navigation ul>li>a {
  color:var(--nd-text);
}
html[data-theme="dark"] .wd-builder-off .woocommerce-MyAccount-navigation ul>li:is(.is-active,:hover)>a {
  color:var(--nd-primary);
  background-color:var(--nd-surface-muted);
}
html[data-theme="dark"] .wd-nav-my-acc>li>a .wd-nav-icon {
  color:var(--nd-primary);
}
html[data-theme="dark"] .woocommerce-MyAccount-content :is(p,a,span,.woocommerce-message) {
  color:var(--nd-text-secondary);
}

/* CART, CHECKOUT, FORMS: solid elevated surfaces for legibility/security. */
html[data-theme="dark"] :is(.woocommerce-cart-form,.cart-totals-inner,.checkout-order-review,.woocommerce-checkout-review-order,.woocommerce-checkout-payment,.woocommerce-billing-fields,.woocommerce-shipping-fields,.woocommerce-form-login,.woocommerce-form-coupon) {
  color:var(--nd-text-secondary);
  border-color:var(--nd-border);
}
html[data-theme="dark"] :is(.woocommerce-checkout-payment,.cart_totals,.woocommerce-checkout-review-order,.woocommerce-form-login,.woocommerce-form-coupon) {
  background-color:var(--nd-surface);
}
html[data-theme="dark"] :is(.woocommerce-cart,.woocommerce-checkout,.woocommerce-account) :is(table,td,th,tr,fieldset) {
  color:var(--nd-text-secondary);
  border-color:var(--nd-border);
}
html[data-theme="dark"] :is(input:not([type="checkbox"]):not([type="radio"]),textarea,select,.select2-selection,.select2-dropdown) {
  color:var(--nd-text);
  background-color:var(--nd-surface);
  border-color:var(--nd-control-border);
}
html[data-theme="dark"] :is(input,textarea)::placeholder {
  color:var(--nd-text-muted);
}
html[data-theme="dark"] :is(.select2-results__option,.select2-selection__rendered,.select2-container) {
  color:var(--nd-text-secondary);
}
html[data-theme="dark"] :is(.woocommerce-message,.woocommerce-info,.wc-block-components-notice-banner) {
  color:var(--nd-text);
  border-color:var(--nd-border);
  background-color:var(--nd-surface-muted);
}
html[data-theme="dark"] :is(.woocommerce-error,.woocommerce-invalid) {
  color:var(--nd-error);
  border-color:var(--nd-error);
}
html[data-theme="dark"] :is(.wc-block-cart,.wc-block-checkout,.wc-block-components-sidebar,.wc-block-components-totals-wrapper) {
  color:var(--nd-text-secondary);
  border-color:var(--nd-border);
}
html[data-theme="dark"] :is(.wc-block-components-text-input input,.wc-block-components-combobox-control input,.wc-block-components-form .wc-block-components-text-input input) {
  color:var(--nd-text);
  background-color:var(--nd-surface);
}
html[data-theme="dark"] :is(.wc-block-components-totals-item__label,.wc-block-components-totals-item__value,.wc-block-components-product-name) {
  color:var(--nd-text);
}

/* QA ROUND 3 — specific WoodMart components; avoid blanket color overrides. */

/* Single product tabs: default WoodMart nav depends on an RGB navigation
   token originally designed for light-only pages. */
html[data-theme="dark"] .product-tabs-wrapper {
  background-color:var(--nd-bg);
  border-color:var(--nd-border);
}
html[data-theme="dark"] .product-tabs-wrapper .wd-nav-tabs {
  --nav-color:var(--nd-text-secondary);
  --nav-color-hover:var(--nd-text);
  --nav-color-active:var(--nd-primary);
  gap:clamp(12px,2.5vw,30px);
  border-bottom:1px solid var(--nd-border);
}
html[data-theme="dark"] .product-tabs-wrapper .wd-nav-tabs>li>a {
  color:var(--nd-text-secondary);
  opacity:1;
  min-height:48px;
}
html[data-theme="dark"] .product-tabs-wrapper .wd-nav-tabs>li:is(.wd-active,.active,.current-menu-item)>a,
html[data-theme="dark"] .product-tabs-wrapper .wd-nav-tabs>li>a[aria-selected="true"] {
  color:var(--nd-primary);
}
html[data-theme="dark"] .product-tabs-wrapper .wd-nav-tabs>li>a:hover,
html[data-theme="dark"] .product-tabs-wrapper .wd-nav-tabs>li>a:focus-visible {
  color:var(--nd-text);
}
html[data-theme="dark"] .product-tabs-wrapper .wd-nav-tabs .nav-link-text:after {
  background-color:var(--nd-primary);
}
html[data-theme="dark"] .product-tabs-wrapper .wd-accordion-title {
  color:var(--nd-text);
  border-color:var(--nd-border);
}
.product-tabs-wrapper .woocommerce-Tabs-panel--description {
  max-width:94ch;
  margin-inline:auto;
  line-height:1.95;
  text-align:start;
}
.product-tabs-wrapper .woocommerce-Tabs-panel--description p {
  margin-bottom:var(--nd-space-5);
}

/* Product meta/share: WoodMart's default social icon preset hardcodes black. */
html[data-theme="dark"] .single-product .wd-social-icons.wd-style-default {
  --wd-social-color:var(--nd-text-secondary);
  --wd-social-color-hover:var(--nd-primary);
}
html[data-theme="dark"] .single-product .wd-social-icons.wd-style-simple {
  --wd-social-color:var(--nd-text-secondary);
  --wd-social-color-hover:var(--nd-on-primary);
  --wd-social-bg:var(--nd-surface-muted);
  --wd-social-bg-hover:var(--nd-primary);
}
html[data-theme="dark"] .single-product .product_meta :is(a,.meta-label) {
  color:var(--nd-text-secondary);
}

/* Filter and sorting: consistent compact control, keep WoodMart mobile icon. */
.woocommerce-ordering.wd-style-underline select {
  min-height:42px;
  max-width:100%;
  border:1px solid var(--nd-border);
  border-radius:var(--nd-radius-md);
  background-color:var(--nd-surface);
  color:var(--nd-text);
  padding-block:8px;
  padding-inline-start:14px;
  padding-inline-end:34px;
  background-position:left 12px center;
  font-size:13px;
  font-weight:600;
}
.woocommerce-ordering.wd-style-underline select:focus-visible {
  border-color:var(--nd-focus);
  outline:2px solid var(--nd-focus);
  outline-offset:2px;
}
html[data-theme="dark"] .woocommerce-ordering select option {
  background-color:var(--nd-elevated);
  color:var(--nd-text);
}
@media(max-width:768.98px) {
  /* Preserve WoodMart's compact ordering icon on small screens. */
  .woocommerce-ordering.wd-ordering-mb-icon select {
    min-height:30px;
    background:transparent;
    border:0;
    padding:0;
  }
}

/* Product hover/fade panel: preserve original popup mechanics; improve
   surfaces, edges and action separation without clipping overlays. */
html[data-theme="dark"] .wd-loop-builder-off .wd-product.wd-hover-with-fade .wd-product-card-bg {
  background-color:var(--nd-surface);
  border:1px solid var(--nd-border);
  border-radius:var(--nd-radius-lg);
  box-shadow:0 12px 30px rgba(0,0,0,.22);
}
html[data-theme="dark"] .wd-loop-builder-off .wd-product.wd-hover-with-fade .wd-product-card-hover {
  color:var(--nd-text-secondary);
  border-color:var(--nd-border);
}
html[data-theme="dark"] .wd-product .wd-buttons {
  color:var(--nd-text);
  border:1px solid var(--nd-border);
  background-color:var(--nd-elevated);
  box-shadow:0 6px 22px rgba(0,0,0,.18);
}
html[data-theme="dark"] .wd-product :is(.wd-buttons,.wd-product-card-hover,.wd-bottom-actions) :is(a,button) {
  color:var(--nd-text);
}
html[data-theme="dark"] .wd-product :is(.wd-bottom-actions,.wd-product-card-hover) .wd-add-btn>a {
  color:var(--nd-on-primary);
  background-color:var(--nd-primary);
}
html[data-theme="dark"] .wd-product :is(.wd-bottom-actions,.wd-product-card-hover) .wd-add-btn>a:hover {
  background-color:var(--nd-primary-hover);
}
html[data-theme="dark"] .wd-product .wd-product-card-hover :is(.hover-content,.wd-product-stock,.wd-product-cats) {
  color:var(--nd-text-secondary);
}
html[data-theme="dark"] .wd-product .wd-product-card-hover :is(.wd-action-btn,.wd-bottom-actions) {
  border-color:var(--nd-border);
}

/* Buttons and quantity on single product should remain crisp and consistent. */
html[data-theme="dark"] .single-product :is(.quantity,.quantity input,.quantity button,.wd-quantity) {
  color:var(--nd-text);
  border-color:var(--nd-control-border);
}
html[data-theme="dark"] .single-product .single_add_to_cart_button {
  min-height:44px;
  padding-inline:18px;
  border-radius:var(--nd-radius-md);
}
html[data-theme="dark"] .single-product .wd-single-action-btn>a {
  color:var(--nd-text-secondary);
}
@media(max-width:600px) {
  .product-tabs-wrapper .woocommerce-Tabs-panel--description {
    padding-inline:var(--nd-space-2);
    line-height:1.85;
  }
  .woocommerce-ordering.wd-style-underline select {
    max-width:min(100%,240px);
  }
}

/* BUTTONS AND FOCUS */
html[data-theme="dark"] :is(.single_add_to_cart_button,.checkout-button,button[name="woocommerce_checkout_place_order"],.btn.btn-accent,.woocommerce-mini-cart__buttons .checkout) {
  background-color:var(--nd-primary);
  color:var(--nd-on-primary);
  border-color:var(--nd-primary);
}
html[data-theme="dark"] :is(.single_add_to_cart_button,.checkout-button,button[name="woocommerce_checkout_place_order"],.btn.btn-accent):hover {
  background-color:var(--nd-primary-hover);
  color:var(--nd-on-primary);
  border-color:var(--nd-primary-hover);
}
body :is(a,button,input,select,textarea,[tabindex]):focus-visible {
  outline:2px solid var(--nd-focus);
  outline-offset:3px;
}

/* OPT-IN GLASS: only floating UI, not product grids or checkout inputs. */
.nd-glass,.nd-theme-control {
  background:var(--nd-glass-bg);
  border:1px solid var(--nd-glass-border);
  box-shadow:var(--nd-glass-shadow);
}
.nd-glass {border-radius:var(--nd-radius-lg);}
:where(.whb-sticked .whb-general-header,.wd-dropdown,.wd-dropdown-menu) {
  background-color:var(--nd-glass-bg);
}
@supports ((backdrop-filter:blur(1px)) or (-webkit-backdrop-filter:blur(1px))) {
  :where(.whb-sticked .whb-general-header,.wd-dropdown,.wd-dropdown-menu,.nd-glass,.nd-theme-control) {
    -webkit-backdrop-filter:blur(12px) saturate(130%);
    backdrop-filter:blur(12px) saturate(130%);
  }
}
@media (prefers-reduced-transparency: reduce) {
  .nd-glass,.nd-theme-control,
  :where(.whb-sticked .whb-general-header,.wd-dropdown,.wd-dropdown-menu) {
    -webkit-backdrop-filter:none;
    backdrop-filter:none;
    background-color:var(--nd-elevated);
  }
}

/* THEME DEMO CONTROL — will move into WoodMart header after QA. */
.nd-theme-control {
  position:fixed;
  inset-inline-end:16px;
  bottom:16px;
  z-index:1090;
  display:flex;
  gap:3px;
  padding:4px;
  border-radius:999px;
  color:var(--nd-text);
}
.nd-theme-choice {
  appearance:none;
  border:0;
  background:transparent;
  color:var(--nd-text);
  font:inherit;
  font-size:12px;
  font-weight:600;
  line-height:1.4;
  cursor:pointer;
  border-radius:999px;
  min-height:38px;
  min-width:52px;
  padding:6px 10px;
}
.nd-theme-choice[aria-pressed="true"] {
  background-color:var(--nd-primary);
  color:var(--nd-on-primary);
}
.nd-theme-choice:focus-visible {
  outline:2px solid var(--nd-focus);
  outline-offset:2px;
}
/* In WPVibe preview the banner covers the bottom, so move the test control. */
body:has(#wpvibe-preview-banner) .nd-theme-control {
  bottom:88px;
  z-index:1000000;
}
@media (max-width:600px) {
  body:has(#wpvibe-preview-banner) .nd-theme-control {
    bottom:150px;
  }
}
@media (max-width:480px) {
  .nd-theme-control {inset-inline-end:10px;}
  .nd-theme-choice {min-width:45px;padding-inline:7px;}
}
@media (prefers-reduced-motion: reduce) {
  html[data-theme] body {transition:none;}
  .nd-theme-control,.nd-glass {
    -webkit-backdrop-filter:none;
    backdrop-filter:none;
  }
}
