/* P2: theme controls. P1 remains owned by styles.css (PR #59).
 * The fallbacks support master until P1 is merged; no legacy token is redefined.
 * Product-card geometry remains owned by P5-A. Plugin/seasonal controls retain
 * their own colors and behavior unless explicitly named below. */
body.haptelle-wc-theme {
  --haptelle-control-compact: 42px;
  --haptelle-control-regular: 52px;
  --haptelle-control-featured: 58px;
}

/* The home hero CTA is part of the linked artwork, not a .tf-btn.
 * Draw inside its clipped image wrapper without changing the link or layout. */
body.haptelle-wc-theme .sld_image .haptelle-hero-image-link:is(:hover, :focus-visible)::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  box-shadow: inset 0 0 0 3px var(--haptelle-brand-oak-hush, var(--bg-wa-zdy-5));
}
body.haptelle-wc-theme .sld_image .haptelle-hero-image-link:focus-visible::after {
  box-shadow: inset 0 0 0 3px var(--haptelle-brand-oak-hush, var(--bg-wa-zdy-5)),
    inset 0 0 0 6px var(--haptelle-brand-blush-whisper, var(--bg-wa-zdy-1));
}

/* Regular actions may grow for translated or long labels. */
body.haptelle-wc-theme .tf-btn:not(:where(.card-product *, .hc-newsletter-submit, .hc-newsletter-above-submit, .haptelle-product-summary *)) {
  height: auto;
  min-height: var(--haptelle-control-regular);
  padding-block: 12px;
  line-height: 1.4;
  white-space: normal;
  text-align: center;
  overflow-wrap: anywhere;
}
body.haptelle-wc-theme .tf-btn.small:not(:where(.card-product *)) {
  min-height: var(--haptelle-control-compact);
  padding-block: 8px;
}
body.haptelle-wc-theme :is(.haptelle-home-section, .haptelle-figma-cta, .hc-buttons) .tf-btn {
  min-height: var(--haptelle-control-featured);
}

/* Woo's generic black/square rule must not override action roles. */
body.haptelle-wc-theme :is(.haptelle-account-form, .haptelle-account-content-card, .woocommerce-ResetPassword, .haptelle-checkout-form, .haptelle-cart-buttons, .haptelle-cart-coupon) :is(.button, .tf-btn),
body.haptelle-wc-theme .tf-btn.btn-fill:not(.hc-newsletter-submit):not(.hc-newsletter-above-submit),
body.haptelle-wc-theme .tf-btn.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--haptelle-control-regular);
  height: auto;
  padding: 12px 24px;
  border: 1px solid var(--haptelle-brand-oak-hush, var(--bg-wa-zdy-5));
  border-radius: 999px;
  background: var(--haptelle-brand-oak-hush, var(--bg-wa-zdy-5));
  color: var(--haptelle-brand-blush-whisper, var(--bg-wa-zdy-1));
  font-family: var(--haptelle-font-body, 'Montserrat', sans-serif);
  font-size: 14px;
  font-weight: 600;
  line-height: 1.4;
  white-space: normal;
  text-align: center;
  overflow-wrap: anywhere;
}
body.haptelle-wc-theme :is(.haptelle-account-form, .haptelle-account-content-card, .woocommerce-ResetPassword, .haptelle-checkout-form, .haptelle-cart-buttons, .haptelle-cart-coupon) :is(.button, .tf-btn):hover:not(:disabled):not(.disabled),
body.haptelle-wc-theme .tf-btn:is(.btn-fill, .btn-primary):not(.hc-newsletter-submit):not(.hc-newsletter-above-submit):hover:not(:disabled):not(.disabled) {
  background: #765a36; /* Approved V1.1 button hover example. */
  border-color: #765a36;
  color: var(--haptelle-brand-blush-whisper, var(--bg-wa-zdy-1));
}
body.haptelle-wc-theme :is(.haptelle-account-form, .haptelle-account-content-card, .haptelle-cart-buttons) .btn-stroke:not(:hover) {
  background: transparent;
  color: var(--haptelle-brand-oak-hush, var(--bg-wa-zdy-5));
}

/* Focus and pending states do not change disabled attributes or click logic. */
body.haptelle-wc-theme :is(.tf-btn, .woocommerce-ResetPassword .button, .haptelle-checkout-form .button, .haptelle-cart-update-button):focus-visible {
  outline: 2px solid var(--haptelle-brand-oak-hush, var(--bg-wa-zdy-5));
  outline-offset: 4px;
}
body.haptelle-wc-theme :is(.tf-btn, .woocommerce-ResetPassword .button, .haptelle-checkout-form .button, .haptelle-cart-update-button):is(:disabled, .disabled, [aria-disabled="true"]) {
  opacity: .42;
  cursor: not-allowed;
}
body.haptelle-wc-theme :is(.tf-btn, .haptelle-checkout-form .button):is(.loading, [aria-busy="true"]) {
  cursor: wait;
}
body.haptelle-wc-theme .tf-btn > span {
  min-width: 0;
  overflow-wrap: anywhere;
}

/* Named theme form containers only; native checkbox/radio semantics remain. */
body.haptelle-wc-theme :is(.haptelle-account-form, .haptelle-account-content-card, .woocommerce-ResetPassword, .haptelle-checkout-form, .haptelle-cart-coupon, .haptelle-blog-search, .haptelle-search-form, .haptelle-contact-form) :is(input[type="text"], input[type="email"], input[type="password"], input[type="search"], input[type="tel"], input[type="url"], select, textarea) {
  box-sizing: border-box;
  min-height: var(--haptelle-control-regular);
  max-width: 100%;
  border: 1px solid #c7b4a7; /* Approved form example, not an official brand color. */
  border-radius: 6px;
  background: #fff;
  color: var(--haptelle-text-primary, #1c1c1c);
  font-family: var(--haptelle-font-body, 'Montserrat', sans-serif);
  font-size: 15px;
  line-height: 1.4;
  padding: 12px 15px;
}
body.haptelle-wc-theme :is(.haptelle-account-form, .haptelle-account-content-card, .woocommerce-ResetPassword, .haptelle-checkout-form, .haptelle-cart-coupon, .haptelle-blog-search, .haptelle-search-form, .haptelle-contact-form) textarea {
  min-height: 120px;
}
body.haptelle-wc-theme :is(.haptelle-account-form, .haptelle-account-content-card, .woocommerce-ResetPassword, .haptelle-checkout-form, .haptelle-cart-coupon, .haptelle-blog-search, .haptelle-search-form, .haptelle-contact-form) :is(input, select, textarea):focus-visible {
  border-color: var(--haptelle-brand-oak-hush, var(--bg-wa-zdy-5));
  outline: 2px solid var(--haptelle-brand-oak-hush, var(--bg-wa-zdy-5));
  outline-offset: 2px;
  box-shadow: none;
}
body.haptelle-wc-theme :is(.haptelle-account-form, .haptelle-account-content-card, .woocommerce-ResetPassword, .haptelle-checkout-form) :is(input[type="checkbox"], input[type="radio"]) {
  accent-color: var(--haptelle-brand-oak-hush, var(--bg-wa-zdy-5));
}
body.haptelle-wc-theme .haptelle-checkout-form .select2-container--default .select2-selection--single {
  min-height: var(--haptelle-control-regular);
  border: 1px solid #c7b4a7;
  border-radius: 6px;
  background: #fff;
  display: flex;
  align-items: center;
}
body.haptelle-wc-theme .haptelle-checkout-form .select2-selection__arrow {
  top: 50%;
  transform: translateY(-50%);
}
body.haptelle-wc-theme .haptelle-checkout-form .woocommerce-invalid :is(.input-text, select, .select2-selection),
body.haptelle-wc-theme :is(.haptelle-account-form, .haptelle-checkout-form) [aria-invalid="true"] {
  border-color: #9b2f2f;
}
/* Quantity inputs retain plugin min/max handlers and their existing layout. */
body.haptelle-wc-theme .haptelle-product-summary .wg-quantity {
  min-height: var(--haptelle-control-regular);
  border-radius: 6px;
}
body.haptelle-wc-theme .haptelle-product-summary .wg-quantity :is(.btn-quantity, .quantity-product) {
  color: var(--haptelle-brand-oak-hush, var(--bg-wa-zdy-5));
}
@media (prefers-reduced-motion: reduce) {
  body.haptelle-wc-theme .tf-btn { transition: none; }
  body.haptelle-wc-theme .tf-btn.animate-btn::after { animation: none; }
}

/* Customizer and preorder adapters: plugin behavior and option panels stay owned
 * by the plugin. Only its named primary/secondary actions are standardized. */
body.haptelle-wc-theme .haptelle-customizer__cart-button.tf-btn,
body.haptelle-wc-theme .haptelle-customizer__stripe-button.tf-btn {
  height: auto;
  min-height: var(--haptelle-control-regular);
  padding: 12px 24px;
  border-radius: 999px;
  line-height: 1.4;
  white-space: normal;
  overflow-wrap: anywhere;
}
body.haptelle-wc-theme .haptelle-customizer__stripe-button.tf-btn {
  border: 1px solid var(--haptelle-brand-oak-hush, var(--bg-wa-zdy-5));
  background: #fff;
  color: var(--haptelle-brand-oak-hush, var(--bg-wa-zdy-5));
}
body.haptelle-wc-theme .haptelle-customizer__stripe-button.tf-btn:hover:not(:disabled) {
  background: var(--haptelle-brand-silk-nude, var(--bg-wa-zdy-2));
}
body.haptelle-wc-theme .haptelle-preorder-reminder__toggle {
  min-height: var(--haptelle-control-compact);
}
body.haptelle-wc-theme .haptelle-factory-final-card .tf-btn {
  min-height: var(--haptelle-control-featured);
}

body.haptelle-wc-theme .haptelle-product-summary :is(.single_add_to_cart_button, .haptelle-buy-now-button, .haptelle-stock-button) {
  height: auto;
  min-height: var(--haptelle-control-regular);
  padding: 12px 20px;
  line-height: 1.4;
  white-space: normal;
  overflow-wrap: anywhere;
}
body.haptelle-wc-theme .haptelle-checkout-form #place_order {
  min-height: var(--haptelle-control-regular);
  background: var(--haptelle-brand-oak-hush, var(--bg-wa-zdy-5));
  color: var(--haptelle-brand-blush-whisper, var(--bg-wa-zdy-1));
  white-space: normal;
}
body.haptelle-wc-theme .haptelle-checkout-form #place_order:hover:not(:disabled) {
  background: #765a36;
}
/* Unclassified shared CTA (e.g. the sign-in prompt) uses the primary role.
 * Explicit white, outline, seasonal and palette classes keep their own role. */
body.haptelle-wc-theme .tf-btn.animate-btn:not([class*="btn-"]) {
  background: var(--haptelle-brand-oak-hush, var(--bg-wa-zdy-5));
  color: var(--haptelle-brand-blush-whisper, var(--bg-wa-zdy-1));
}
body.haptelle-wc-theme :is(.tf-btn-line, .tf-btn-line-2):focus-visible {
  outline: 2px solid var(--haptelle-brand-oak-hush, var(--bg-wa-zdy-5));
  outline-offset: 4px;
}
/* Split-cart owns the coupon row layout; adapt only the existing controls. */
body.haptelle-wc-theme .haptelle-split-cart__actions .haptelle-cart-coupon .input-text {
  height: var(--haptelle-control-regular);
  min-height: var(--haptelle-control-regular);
  border-radius: 6px;
}
body.haptelle-wc-theme .haptelle-split-cart__actions .haptelle-cart-coupon .tf-btn {
  height: auto;
  min-height: var(--haptelle-control-regular);
  padding: 12px 20px;
  border-radius: 999px;
  line-height: 1.4;
  white-space: normal;
}
body.haptelle-wc-theme .haptelle-cart-group__table .wg-quantity {
  min-height: var(--haptelle-control-compact);
}
body.haptelle-wc-theme .haptelle-customizer__quantity {
  min-height: var(--haptelle-control-regular);
  padding-block: 0;
  border-radius: 6px;
}
body.haptelle-wc-theme .haptelle-customizer__quantity :is([data-customizer-quantity-decrease], [data-customizer-quantity-increase]) {
  min-width: var(--haptelle-control-compact);
  min-height: var(--haptelle-control-compact);
}
/* Existing authenticated account fields have a more specific legacy owner. */
body.haptelle-wc-theme .haptelle-account-content-card :is(.form-setting, .account-my_address) .tf-field :is(input, select) {
  min-height: var(--haptelle-control-regular);
}
/* A narrow purchase panel must wrap actions rather than compress a short CTA
 * between the quantity stepper and the panel edge. This is control-group layout. */
body.haptelle-wc-theme .haptelle-customizer__purchase-actions {
  flex-wrap: wrap;
}
body.haptelle-wc-theme .haptelle-customizer__purchase-actions .haptelle-customizer__cart-button {
  flex: 1 1 160px;
  min-width: min(100%, 160px);
}
