/**
 * PKSoft Newsletter – default styles.
 *
 * Every selector is wrapped in :where(), so these rules have zero specificity and any theme rule
 * wins without !important. Fonts and colours inherit from the theme; the button and inputs also
 * carry the theme's own classes (.button .wp-element-button, .input-text).
 *
 * Quick theming via custom properties, e.g.:
 *   .pkn { --pkn-accent: #556b2f; --pkn-radius: 0; }
 * Or turn this file off entirely in PKSoft → Newsletter → Form.
 */
:where(.pkn, .pkn-checkout) {
  --pkn-gap: 0.75rem;
  --pkn-radius: 4px;
  --pkn-border: 1px solid currentColor;
  --pkn-border-opacity: 0.35;
  --pkn-input-bg: transparent;
  --pkn-input-padding: 0.6em 0.8em;
  --pkn-accent: currentColor;
  --pkn-success: #2e7d32;
  --pkn-warning: #b26a00;
  --pkn-error: #c62828;
  --pkn-small: 0.875em;
  --pkn-max-width: 36rem;
  --pkn-inactive-opacity: 0.5;
}

/* [hidden] always hides, whatever display a theme (or a rule below) gives the element. */
:is(.pkn, .pkn-checkout)[hidden],
:is(.pkn, .pkn-checkout) [hidden] {
  display: none !important;
}

:where(.pkn) {
  max-width: var(--pkn-max-width);
  margin-block: 1.5rem;
}

:where(.pkn__title) {
  margin: 0 0 0.25em;
}

:where(.pkn__text) {
  margin: 0 0 var(--pkn-gap);
}

:where(.pkn__message) {
  margin: 0 0 var(--pkn-gap);
  padding: 0.75em 1em;
  border-radius: var(--pkn-radius);
  border-inline-start: 4px solid currentColor;
}

:where(.pkn__message--success) {
  color: var(--pkn-success);
}

:where(.pkn__message--error) {
  color: var(--pkn-error);
}

:where(.pkn-form) {
  margin: 0;
}

:where(.pkn-form__fields) {
  display: flex;
  flex-wrap: wrap;
  gap: var(--pkn-gap);
  align-items: flex-end;
}

:where(.pkn-form__field) {
  display: flex;
  flex-direction: column;
  gap: 0.25em;
  flex: 1 1 12rem;
  min-width: 0;
  margin: 0;
}

:where(.pkn-form__field--submit) {
  flex: 0 0 auto;
}

:where(.pkn-form__label) {
  font-size: var(--pkn-small);
}

:where(.pkn-form__input) {
  box-sizing: border-box;
  width: 100%;
  padding: var(--pkn-input-padding);
  font: inherit;
  color: inherit;
  background: var(--pkn-input-bg);
  border: var(--pkn-border);
  border-color: color-mix(
    in srgb,
    currentColor calc(var(--pkn-border-opacity) * 100%),
    transparent
  );
  border-radius: var(--pkn-radius);
}

:where(.pkn-form__input[aria-invalid="true"]) {
  border-color: var(--pkn-error);
}

:where(.pkn-form__button) {
  cursor: pointer;
  border-radius: var(--pkn-radius);
  white-space: nowrap;
}

:where(.pkn-form__button[disabled]) {
  opacity: 0.6;
  cursor: progress;
}

:where(.pkn-form__consent) {
  margin: var(--pkn-gap) 0 0;
  font-size: var(--pkn-small);
}

:where(.pkn-form__consent label) {
  display: flex;
  gap: 0.5em;
  align-items: flex-start;
  cursor: pointer;
}

:where(.pkn-form__consent input) {
  flex: 0 0 auto;
  margin: 0.2em 0 0;
  accent-color: var(--pkn-accent);
}

/* Honeypot: off-screen, not display:none (some bots skip hidden fields). */
:where(.pkn-form__hp) {
  position: absolute !important;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

:where(.pkn-form__captcha) {
  flex: 1 1 100%;
}

:where(.pkn-form__captcha:empty) {
  display: none;
}

/* WooCommerce checkout checkbox. */
:where(.pkn-checkout) {
  margin: 1em 0;
}

:where(.pkn-checkout__subscribed) {
  display: block;
  margin-inline-start: 1.75em;
}

/* The checkbox, its consent text and the SMS checkbox read as one group. Class-level specificity
   (not :where) so a theme's generic "p { margin }" doesn't pull them apart; themes can still
   override with their own class rule or --pkn-consent-gap. */
.pkn-checkout .pkn-checkout__row {
  margin-bottom: var(--pkn-consent-gap, 0.25em);
}

.pkn-checkout .pkn-checkout__consent {
  margin: 0 0 var(--pkn-consent-gap, 0.5em);
}

:where(.pkn-checkout__admin-note) {
  margin: 0.25em 0 0.5em;
  padding: 0.4em 0.6em;
  border: 1px dashed currentColor;
  opacity: 0.8;
}

:where(.pkn-checkout__sms) {
  margin-inline-start: 1.75em;
}

/* Live status under the gift picker: what is still missing (hidden once the gift is in the order). */
:where(.pkn-checkout__status) {
  margin: 0.5em 0 1em;
  padding: 0.6em 0.8em;
  border-inline-start: 4px solid;
  font-size: var(--pkn-small, 0.875em);
  background: rgb(0 0 0 / 0.03);
}

:where(.pkn-checkout__status--todo) {
  border-color: var(--pkn-warning, #b26a00);
}

/* Free sample picker. Tune with --pkn-cards-visible, --pkn-accent, --pkn-radius on .pkn-checkout. */
:where(.pkn-choice--carousel) {
  min-width: 0;
  margin: 0.75em 0;
}

:where(.pkn-choice__title) {
  font-weight: 600;
}

/* Class-level, like the other gaps: a theme's generic "p { margin }" must not push the cards away. */
.pkn-choice .pkn-choice__title {
  margin: 0 0 var(--pkn-search-gap, 0.25em);
}

/* Class-level, like the consent spacing: a theme's generic "p { margin }" must not push the cards away. */
.pkn-choice .pkn-choice__search {
  margin: var(--pkn-search-gap, 0.25em) 0 0;
}

:where(.pkn-choice__search-input) {
  width: 100%;
  box-sizing: border-box;
}

/* Search field with its clear (×) button. Size and position are layout, so class-level specificity:
   theme input / button styles must not move or stretch them. */
.pkn-choice .pkn-choice__search-wrap {
  position: relative;
  display: block;
}

.pkn-checkout .pkn-choice .pkn-choice__search input.pkn-choice__search-input {
  padding-inline-end: 2.5em; /* room for the × */
}

/* Only our own ×, not the browser's built-in one as well. */
.pkn-choice .pkn-choice__search-input::-webkit-search-cancel-button {
  -webkit-appearance: none;
  appearance: none;
}

.pkn-choice .pkn-choice__search-clear {
  position: absolute;
  top: 50%;
  inset-inline-end: 0.5em;
  box-sizing: border-box;
  display: grid;
  place-items: center;
  width: 1.75em;
  height: 1.75em;
  min-width: 0;
  min-height: 0;
  margin: 0;
  padding: 0;
  font-size: 1.1em;
  line-height: 1;
  color: inherit;
  background: transparent;
  border: 0;
  border-radius: 50%;
  box-shadow: none;
  cursor: pointer;
  transform: translateY(-50%);
}

.pkn-choice .pkn-choice__search-clear:hover,
.pkn-choice .pkn-choice__search-clear:focus-visible {
  background: rgb(0 0 0 / 0.08);
}

/* Shown in the middle of the (kept-height) carousel area. */
.pkn-choice .pkn-choice__empty {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: grid;
  place-items: center;
  margin: 0;
  padding: 1em;
  text-align: center;
  font-size: var(--pkn-small, 0.875em);
  font-style: italic;
  pointer-events: none;
}

/* Already had the gift: the picker is not shown at all. */
.pkn-choice.pkn-choice--used {
  display: none;
}

/* Not selectable yet: requirements not met (see the status line). Browsing still works. */

:where(
  .pkn-choice--disabled .pkn-choice__card,
  .pkn-choice--disabled input,
  .pkn-choice--disabled select
) {
  cursor: not-allowed;
}

:where(.pkn-choice--disabled .pkn-choice__card:hover) {
  border-color: rgb(0 0 0 / 0.12);
}

:where(.pkn-choice__viewport) {
  position: relative;
}

:where(.pkn-choice__track) {
  display: flex;
  gap: var(--pkn-gap, 0.75rem);
  padding: var(--pkn-track-padding, 0.5em) 0.125em;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scroll-snap-type: x mandatory;
  scroll-padding-inline: 0.125em;
  /* No scrollbar: the arrows, swipe and trackpad scroll it, and the arrows stay centred on the cards. */
  scrollbar-width: none;
}

:where(.pkn-choice__track::-webkit-scrollbar) {
  display: none;
}

:where(.pkn-choice__item) {
  /* Exactly --pkn-cards-visible cards fill the row (default 2); the rest scroll in. */
  flex: 0 0
    calc(
      (100% - (var(--pkn-cards-visible, 2) - 1) * var(--pkn-gap, 0.75rem)) /
        var(--pkn-cards-visible, 2)
    );
  min-width: 0;
  scroll-snap-align: start;
}

:where(.pkn-choice__card) {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.4em;
  height: 100%;
  box-sizing: border-box;
  padding: 0.5em;
  border: 2px solid rgb(0 0 0 / 0.12);
  border-radius: var(--pkn-radius, 4px);
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s;
}

:where(.pkn-choice__card:hover) {
  border-color: rgb(0 0 0 / 0.3);
}

:where(.pkn-choice__card:has(.pkn-choice__radio:checked)) {
  border-color: var(--pkn-accent, currentColor);
}

:where(.pkn-choice__card:has(.pkn-choice__radio:focus-visible)) {
  outline: 2px solid var(--pkn-accent, currentColor);
  outline-offset: 2px;
}

/* The radio stays in the page for keyboards and screen readers; the card shows the state. */
:where(.pkn-choice__radio) {
  position: absolute;
  top: 0.5em;
  left: 0.5em;
  margin: 0;
  accent-color: var(--pkn-accent, currentColor);
}

:where(.pkn-choice__image img) {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 1;
  object-fit: cover;
  margin: 0;
  border-radius: calc(var(--pkn-radius, 4px) / 2);
}

:where(.pkn-choice__name) {
  font-size: var(--pkn-small, 0.875em);
  line-height: 1.3;
  overflow-wrap: anywhere;
}

:where(.pkn-choice__nav) {
  position: absolute;
  top: 50%;
  z-index: 1;
  margin: 0;
  font-size: 1rem;
  color: #222;
  background: #fff;
  border: 1px solid rgb(0 0 0 / 0.15);
  border-radius: 50%;
  box-shadow: 0 1px 4px rgb(0 0 0 / 0.15);
  cursor: pointer;
  transform: translateY(-50%);
}

/* Size and shape of the arrows are layout, not decoration: normal specificity, so a theme's global
   button padding / min-width (e.g. Storefront) can't stretch them. Colours and corners stay themeable. */
.pkn-choice .pkn-choice__nav {
  box-sizing: border-box;
  width: var(--pkn-nav-size, 2.25rem);
  height: var(--pkn-nav-size, 2.25rem);
  min-width: 0;
  min-height: 0;
  aspect-ratio: 1;
  padding: 0;
  line-height: 1;
  display: grid;
  place-items: center;
}

:where(.pkn-choice__nav--prev) {
  left: -0.5em;
}

:where(.pkn-choice__nav--next) {
  right: -0.5em;
}

@media (prefers-reduced-motion: reduce) {
  :where(.pkn-choice__card) {
    transition: none;
  }
}

/* Stand-alone confirmation page. */
:where(.pkn-page) {
  margin: 0;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1rem;
  box-sizing: border-box;
  font-family:
    system-ui,
    -apple-system,
    "Segoe UI",
    Roboto,
    sans-serif;
  line-height: 1.5;
  color: #222;
  background: #f4f4f4;
}

:where(.pkn-page__box) {
  max-width: 32rem;
  padding: 2rem;
  background: #fff;
  border-radius: 6px;
  box-shadow: 0 1px 4px rgb(0 0 0 / 0.08);
}

:where(.pkn-page__site) {
  margin: 0 0 1rem;
  font-weight: 700;
}

:where(.pkn-page__site a) {
  color: inherit;
  text-decoration: none;
}

:where(.pkn-page__title) {
  margin: 0 0 0.5rem;
  font-size: 1.5rem;
}

:where(.pkn-page .pkn-form__button) {
  display: inline-block;
  padding: 0.7em 1.4em;
  font: inherit;
  font-weight: 700;
  color: #fff;
  text-decoration: none;
  background: #222;
  border: 0;
}

/* Greyed out: the gift left without a paid product in the cart, and the gift picker while its
   requirements aren't met. Themes with their own cart markup don't always apply the row class (no
   woocommerce_cart_item_class filter), so a cart row containing the gift's note counts too. */
:where(
  .pkn-gift-inactive,
  .cart_item:has(.pkn-gift-inactive__note),
  .mini_cart_item:has(.pkn-gift-inactive__note),
  .pkn-choice--disabled .pkn-choice__item,
  .pkn-choice--disabled .pkn-choice__search,
  .pkn-choice--disabled select
) {
  opacity: var(--pkn-inactive-opacity, 0.5);
}

:where(
  .pkn-gift-inactive img,
  .cart_item:has(.pkn-gift-inactive__note) img,
  .pkn-choice--disabled .pkn-choice__item img
) {
  filter: grayscale(1);
}

:where(.pkn-gift-inactive__note) {
  display: block;
  font-style: italic;
}
