/* ============================================================
   Woolland — YITH Gift Card product form
   ------------------------------------------------------------
   Loaded ONLY on gift-card products, from
   template-parts/single-product.php.

   Everything is scoped under .product__gift-card (the wrapper the
   theme puts around do_action('woocommerce_gift-card_add_to_cart'))
   so none of this can leak onto a normal product page.

   Two things this file has to undo:
     1. main.css resets `input { background:none; border:none }`
        globally — YITH never sets its own borders, so its fields
        render invisible. Every field below re-declares them.
     2. ywgc-frontend.css lays the form out with `float:right;
        width:70%`. All of that is replaced with flex/grid.

   Specificity is deliberately high in places: the plugin ships
   inline CSS generated from the `ywgc_plugin_main_color` option,
   and one rule (.selected_image_parent) is !important.
   ============================================================ */

/* ---------- Outer card ---------- */

.product__gift-card {
  /* A deeper shade of the theme's terracotta --border-1 (#eebaa9). Every
     control here sits on a white fill inside a near-white card, where
     #eebaa9 is only 1.66:1 — below the 3:1 WCAG 1.4.11 needs for a control
     boundary, and (for the amount chips) weaker than the green border the
     plugin's own inline CSS was already drawing. #b8785e is 3.57:1 on
     white, stays in the same hue family, and keeps the green hover and
     selected states reading as a clear change. Kept local to this
     component so the site-wide --border-1 is untouched. */
  --wl-gc-border: #b8785e;
}

.product__gift-card .gift-cards_form {
  counter-reset: gcstep;
  padding: 24px;
  background: rgba(255, 255, 255, 0.6);
  border: 1px solid rgba(0, 0, 0, 0.07);
  border-radius: 16px;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.05);
}

/* ---------- Numbered step headings ----------
   Three <h3>s render in document order: "choose a design",
   "set an amount", "delivery info". The counter walks them in DOM
   order, so if the design picker is ever switched off in the YITH
   settings the numbering re-flows to 1-2 on its own. */

.product__gift-card .gift-cards_form h3 {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 0 14px;
  font-size: 18px;
  font-weight: 700;
  line-height: 1.3;
  color: var(--font-1);
}

.product__gift-card .gift-cards_form h3::before {
  counter-increment: gcstep;
  content: counter(gcstep);
  flex: 0 0 26px;
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: var(--accent-1);
  border-radius: 50%;
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
  color: var(--font-3);
}

/* Vertical rhythm between steps. `:first-of-type` keeps the top of
   the card flush whichever section happens to come first. */
.product__gift-card .gift-cards_form > h3,
.product__gift-card .gift-cards-list {
  margin-top: 32px;
}

.product__gift-card .gift-cards_form > h3:first-of-type,
.product__gift-card .gift-cards_form > .gift-cards-list:first-of-type {
  margin-top: 0;
}

/* ...but "delivery info" always needs its gap after the amounts. */
.product__gift-card .gift-cards_form > .gift-cards-list + h3 {
  margin-top: 32px;
}

/* ============================================================
   STEP 1 — design picker
   ============================================================ */

/* With no images in the YITH design gallery the plugin still renders the
   step, containing one tile: the product's own featured image, already
   selected. That is a non-choice, and it duplicates the product gallery
   on the left, so the whole step is hidden while only one tile exists.
   display:none also suppresses counter-increment, so the two remaining
   steps renumber themselves to 1 and 2. Add designs under
   YITH > Gift Cards > Design and the step reappears on its own. */
.product__gift-card .gift-cards_form > h3:has(+ .gift-card-content-editor.step-appearance .ywgc-design-list ul > li:only-child),
.product__gift-card .gift-card-content-editor.step-appearance:has(.ywgc-design-list ul > li:only-child) {
  display: none;
}

.product__gift-card .gift-cards_form:has(.ywgc-design-list ul > li:only-child) > .gift-cards-list {
  margin-top: 0;
}

.product__gift-card .gift-card-content-editor.step-appearance {
  margin: 0;
}

.product__gift-card .ywgc-choose-design-preview {
  margin-bottom: 0;
}

.product__gift-card .gift-card-content-editor.step-appearance .ywgc-design-list {
  display: block;
}

/* The plugin sets `font-size:0` here as an inline-block gap hack.
   It has to be reset — the selected-tile checkmark is a ::after
   glyph and would inherit a 0px font size. */
.product__gift-card .gift-card-content-editor.step-appearance .ywgc-design-list ul {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 14px;
}

.product__gift-card .gift-card-content-editor.step-appearance .ywgc-design-list ul li {
  flex: 0 0 auto;
  width: 116px;
  padding: 0;
  display: block;
}

.product__gift-card .ywgc-preset-image,
.product__gift-card .ywgc-preset-image:not(.ywgc-default-product-image) {
  position: relative;
  display: block;
  padding: 0;
  background-color: #fff;
  border: 2px solid var(--wl-gc-border);
  border-radius: 10px;
  cursor: pointer;
  transition: var(--transition);
}

.product__gift-card .ywgc-preset-image:hover {
  border-color: var(--accent-1);
}

/* Plugin inline CSS forces `border: 2px dashed <main colour>
   !important` on the selected tile — this is the one place a
   counter-!important is unavoidable. */
.product__gift-card .ywgc-preset-image.selected_image_parent,
.product__gift-card .ywgc-preset-image.selected_image_parent:not(.ywgc-default-product-image) {
  border: 2px solid var(--accent-1) !important;
  box-shadow: 0 0 0 3px rgba(72, 91, 72, 0.12);
}

.product__gift-card .gift-card-content-editor.step-appearance .ywgc-design-list .ywgc-preset-image img {
  width: 100%;
  height: auto;
  aspect-ratio: 1 / 1;
  display: block;
  object-fit: cover;
  object-position: center;
  border-radius: 8px;
}

/* Selected badge. The plugin's ::after is a grey circle with a
   bitmap icon; swapped for a green disc with a real checkmark and
   inset so it can't be clipped. */
.product__gift-card .ywgc-preset-image.selected_image_parent::after {
  content: "\2713";
  top: 8px;
  right: 8px;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: var(--accent-1);
  background-image: none;
  border-radius: 50%;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  color: var(--font-3);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
}

/* ============================================================
   STEP 2 — amount chips
   ============================================================ */

.product__gift-card .gift-cards-list {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.product__gift-card .gift-cards-list > h3 {
  flex: 0 0 100%;
  margin: 0 0 4px;
}

/* YITH prints a hidden <input> carrying the same classes straight
   after each <button>; keep the chip rules on the button only. */
.product__gift-card .gift-cards-list button.ywgc-amount-buttons {
  margin: 0;
  min-width: 104px;
  padding: 15px 22px;
  background-color: #fff;
  border: 1px solid var(--wl-gc-border);
  border-radius: 4px;
  font-family: "DM Sans", sans-serif;
  font-size: 15px;
  font-weight: 500;
  line-height: 1;
  /* --font-2 (#828282) is only 3.84:1 on white — too low for the form's
     primary control, so the resting chip uses the body ink instead. */
  color: var(--font-1);
  cursor: pointer;
  transition: var(--transition);
}

/* The label is a wc_price() blob, not a bare string — stop WooCommerce's
   own price styling from overriding the chip's type. */
.product__gift-card .gift-cards-list button.ywgc-amount-buttons .woocommerce-Price-amount,
.product__gift-card .gift-cards-list button.ywgc-amount-buttons .woocommerce-Price-currencySymbol {
  font-family: inherit;
  font-size: inherit;
  font-weight: inherit;
  color: inherit;
  text-decoration: none;
}

.product__gift-card .gift-cards-list button.ywgc-amount-buttons:hover {
  border-color: var(--accent-1);
  color: var(--font-1);
}

.product__gift-card .gift-cards-list button.ywgc-amount-buttons:focus-visible {
  outline: 2px solid var(--accent-1);
  outline-offset: 2px;
}

/* Selected chip is an outline + tint rather than a solid fill, so
   the only solid green on the page stays the add-to-cart button.
   Padding drops 1px to absorb the thicker border. */
.product__gift-card .gift-cards-list button.ywgc-amount-buttons.selected_button {
  padding: 14px 21px;
  background-color: rgba(72, 91, 72, 0.08);
  border: 2px solid var(--accent-1);
  font-weight: 700;
  color: var(--font-1);
}

.product__gift-card .ywgc-manual-amount-error {
  flex: 0 0 100%;
  margin: 0;
  font-size: 13px;
  color: #c0392b;
}

/* ============================================================
   STEP 3 — delivery info
   ============================================================ */

.product__gift-card .gift-card-content-editor.step-content {
  margin: 0;
}

.product__gift-card .gift-card-content-editor.step-content h5 {
  margin: 26px 0 12px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  /* Darker than --font-2: at 12px uppercase this shouldn't be the
     faintest text on the card. */
  color: #6b6b6b;
}

.product__gift-card .gift-card-content-editor.step-content h5:first-child {
  margin-top: 0;
}

/* Recipient name + email side by side. Sized off the container rather
   than the viewport: the product column is at its NARROWEST (~472px) at
   a 1024px viewport, because the theme only goes full-width below
   1023px. A viewport-keyed breakpoint would miss exactly that case. */
.product__gift-card .ywgc-single-recipient {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
}

/* Each field: label stacked above its input (the plugin floats
   them apart at 30/70). min-width:0 lets the grid tracks shrink past
   the inputs' intrinsic `size=20` width instead of overflowing. */
.product__gift-card .gift-card-content-editor.step-content .ywgc-recipient-name,
.product__gift-card .gift-card-content-editor.step-content .ywgc-recipient-email,
.product__gift-card .gift-card-content-editor.step-content .ywgc-sender-name,
.product__gift-card .gift-card-content-editor.step-content .ywgc-message {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 0;
  min-width: 0;
}

/* These wrappers carry the plugin's .clearfix class, whose ::after would
   otherwise become a real flex item and add a 6px gap under every field. */
.product__gift-card .gift-card-content-editor.step-content .clearfix::after {
  content: none;
}

/* Tracks the recipient grid's column width so the three fields line up,
   but never squeezes below a usable size once the grid drops to one column. */
.product__gift-card .gift-card-content-editor.step-content .ywgc-sender-name {
  max-width: calc(50% - 8px);
  min-width: 200px;
}

.product__gift-card .gift-card-content-editor.step-content .ywgc-message {
  margin-top: 20px;
}

.product__gift-card .gift-card-content-editor.step-content label {
  display: block;
  line-height: 1.3;
  text-align: left;
  vertical-align: baseline;
  font-size: 13px;
  font-weight: 500;
  color: var(--font-1);
}

/* ---------- Fields ----------
   These re-declare border/background that main.css strips off
   every input on the site. */
.product__gift-card .gift-card-content-editor.step-content input[type="text"],
.product__gift-card .gift-card-content-editor.step-content input[type="email"],
.product__gift-card .gift-card-content-editor.step-content textarea {
  float: none;
  width: 100%;
  max-width: 100%;
  height: 48px;
  padding: 0 14px;
  background-color: #fff;
  border: 1px solid var(--wl-gc-border);
  border-radius: 4px;
  outline: none;
  font-family: "DM Sans", sans-serif;
  /* 16px, not 15px: anything smaller makes iOS Safari zoom the viewport
     on focus. That applies on iPad too, which sits above any sensible
     "mobile" breakpoint, so it belongs on the base rule. */
  font-size: 16px;
  line-height: 1.4;
  color: var(--font-1);
  transition: var(--transition);
}

.product__gift-card .gift-card-content-editor.step-content textarea {
  height: auto;
  min-height: 120px;
  padding: 12px 14px;
  resize: vertical;
}

.product__gift-card .gift-card-content-editor.step-content input[type="text"]:focus,
.product__gift-card .gift-card-content-editor.step-content input[type="email"]:focus,
.product__gift-card .gift-card-content-editor.step-content textarea:focus {
  border-color: var(--accent-1);
  box-shadow: 0 0 0 3px rgba(72, 91, 72, 0.14);
  /* Invisible normally; Windows High Contrast / forced-colors repaints it,
     where the border and box-shadow above are both discarded. */
  outline: 2px solid transparent;
  outline-offset: 2px;
}

.product__gift-card .gift-card-content-editor.step-content input::placeholder,
.product__gift-card .gift-card-content-editor.step-content textarea::placeholder {
  font-size: 14px;
  color: #757575;
  opacity: 1;
}

/* :user-invalid only fires after the visitor has actually
   interacted with or submitted the field, so untouched required
   fields never start out red. */
.product__gift-card .gift-card-content-editor.step-content input:user-invalid {
  border-color: #c0392b;
}

/* Must come after the :focus rule above, or focusing a field the browser
   has just flagged as invalid would repaint it with the green valid ring. */
.product__gift-card .gift-card-content-editor.step-content input:user-invalid:focus {
  border-color: #c0392b;
  box-shadow: 0 0 0 3px rgba(192, 57, 43, 0.14);
}

/* Injected by the plugin's JS after the email input on submit. */
.product__gift-card .ywgc-bad-email-format {
  display: block;
  margin-top: 2px;
  font-size: 13px;
  color: #c0392b;
}

/* ============================================================
   Add to cart
   ============================================================ */

.product__gift-card .gift_card_template_button {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: 28px;
}

.product__gift-card .gift_card_template_button .quantity {
  flex: 0 0 auto;
  margin: 0;
  float: none;
}

/* WooCommerce's quantity template ships a visually-hidden <label>, but the
   theme never defines .screen-reader-text — without this the label text
   ("produkto kiekis: ...") renders in full next to the field. */
.product__gift-card .screen-reader-text {
  position: absolute !important;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.product__gift-card .gift_card_template_button .quantity input.qty {
  width: 100px;
  height: 48px;
  padding: 0 4px 0 10px;
  background-color: #fff;
  border: 1px solid var(--wl-gc-border);
  border-radius: 2px;
  outline: none;
  font-family: "DM Sans", sans-serif;
  font-size: 16px;
  font-weight: 600;
  text-align: center;
  color: var(--font-1);
}

.product__gift-card .gift_card_template_button .quantity input.qty:focus {
  border-color: var(--accent-1);
  box-shadow: 0 0 0 3px rgba(72, 91, 72, 0.14);
}

.product__gift-card .gift_card_template_button .single_add_to_cart_button {
  flex: 1 1 auto;
  width: auto;
  height: 48px;
  padding: 0 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background-color: var(--accent-1);
  border: none;
  border-radius: 2px;
  box-shadow: var(--button-shadow);
  font-family: "DM Sans", sans-serif;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--font-3);
  cursor: pointer;
  transition: var(--transition);
}

.product__gift-card .gift_card_template_button .single_add_to_cart_button:hover {
  background-color: #3b4c3b;
}

.product__gift-card .gift_card_template_button .single_add_to_cart_button:focus-visible {
  outline: 2px solid var(--font-1);
  outline-offset: 2px;
}

.product__gift-card .gift-card-not-valid {
  margin: 0;
  padding: 14px 16px;
  background-color: rgba(192, 57, 43, 0.08);
  border-radius: 8px;
  font-size: 14px;
  color: #c0392b;
}

/* ============================================================
   Mobile
   ============================================================ */

@media screen and (max-width: 767px) {
  .product__gift-card .gift-cards_form {
    padding: 18px 16px;
    border-radius: 12px;
  }

  .product__gift-card .gift-cards_form > h3,
  .product__gift-card .gift-cards-list,
  .product__gift-card .gift-cards_form > .gift-cards-list + h3 {
    margin-top: 26px;
  }

  .product__gift-card .gift-cards_form h3 {
    font-size: 17px;
  }

  /* Chips share the row two-up. max-width stops them stretching to ~345px
     each at the top of this range, where the column is still ~700px wide. */
  .product__gift-card .gift-cards-list button.ywgc-amount-buttons {
    flex: 1 1 calc(50% - 5px);
    min-width: 0;
    max-width: 200px;
  }

  .product__gift-card .gift_card_template_button {
    flex-wrap: wrap;
    gap: 12px;
  }

  .product__gift-card .gift_card_template_button .quantity {
    flex: 0 0 96px;
  }

  .product__gift-card .gift_card_template_button .quantity input.qty {
    width: 100%;
  }

  .product__gift-card .gift_card_template_button .single_add_to_cart_button {
    flex: 1 1 auto;
    min-width: 0;
    padding: 0 16px;
  }
}

@media screen and (max-width: 419px) {
  .product__gift-card .gift-card-content-editor.step-appearance .ywgc-design-list ul li {
    width: calc((100% - 24px) / 3);
  }

  /* Keep quantity and CTA on one row even here — stacking them would
     stretch a number spinner across the full screen width. 88 + 12 + the
     remainder still leaves a comfortable button at 320px. */
  .product__gift-card .gift_card_template_button .quantity {
    flex: 0 0 88px;
  }

  .product__gift-card .gift_card_template_button .single_add_to_cart_button {
    padding: 0 10px;
    font-size: 14px;
  }
}
