/**
 * Gift voucher front-end styles.
 *
 * Deliberately low-specificity so the parent theme's typography shows through.
 * Colours come from the tokens below rather than being repeated inline, so the
 * brand value lives in exactly one place.
 */

:root {
  /* Grape Secrets primary. */
  --gsgv-primary: #890c58;

  /*
	 * Secondary text used to be dimmed with `opacity`, which washes it out
	 * against a white page and gets worse on a tinted panel. These are real
	 * greys instead: --gsgv-muted is 6.9:1 on white and --gsgv-faint 5.1:1,
	 * so both clear WCAG AA for body text.
	 */
  --gsgv-text: #2b2b2b;
  --gsgv-muted: #5a5a5a;
  --gsgv-faint: #6e6e6e;

  --gsgv-border: rgba(0, 0, 0, 0.18);
  --gsgv-border-hover: rgba(0, 0, 0, 0.4);
  --gsgv-border-soft: rgba(0, 0, 0, 0.12);
}

/* ---------- Option cards ---------- */

.gsgv-options {
  margin: 0 0 1.75em;
}

.gsgv-options[hidden] {
  display: none;
}

.gsgv-options__legend {
  display: block;
  margin: 0 0 0.75em;
  font-size: 0.8125rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--gsgv-muted);
}

.gsgv-options__list {
  display: grid;
  gap: 0.75em;
  grid-template-columns: 1fr;
}

@media (min-width: 600px) {
  .gsgv-options__list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.gsgv-option {
  position: relative;
  display: block;
  margin: 0;
  padding: 1.125em 1.25em;
  border: 1px solid var(--gsgv-border);
  border-radius: 3px;
  cursor: pointer;
  transition:
    border-color 0.15s ease,
    box-shadow 0.15s ease;
}

.gsgv-option:hover {
  border-color: var(--gsgv-border-hover);
}

.gsgv-option.is-selected {
  border-color: var(--gsgv-primary);
  box-shadow: inset 0 0 0 1px var(--gsgv-primary);
}

/* Visually hidden, but still focusable and announced. */
.gsgv-option__input {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: 0;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.gsgv-option__input:focus-visible + .gsgv-option__body {
  outline: 2px solid var(--gsgv-primary);
  outline-offset: 4px;
}

.gsgv-option__body {
  display: block;
}

.gsgv-option__head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.25em 0.75em;
}

.gsgv-option__name {
  font-weight: 500;
  line-height: 1.3;
  color: var(--gsgv-primary);
}

.gsgv-option__price {
  font-weight: 500;
  white-space: nowrap;
  color: var(--gsgv-text);
}

.gsgv-option__price del {
  color: var(--gsgv-faint);
  font-weight: 400;
}

.gsgv-option__blurb {
  display: block;
  margin-top: 0.5em;
  font-size: 0.875rem;
  line-height: 1.55;
  color: var(--gsgv-muted);
}

/* ---------- Selected variation price ---------- */

/*
 * WooCommerce drops the chosen variation's price in here, under the cards.
 * It arrives inheriting the theme's body colour (#ababab, set on `body` in
 * modules.min.css), which is far too faint for the one number the buyer most
 * needs to read -- so it becomes a full-width brand banner instead.
 *
 * Already display:block at the container's width, so this is padding and
 * colour only. This stylesheet loads on gift voucher pages alone, so the
 * unprefixed WooCommerce class cannot reach another product.
 */
.woocommerce-variation-price {
  box-sizing: border-box;
  margin: 0 0 1.25em;
  padding: 0.7em 1.125em;
  background: var(--gsgv-primary);
  text-align: left;
}

/* Beats the theme's `body` colour, which would otherwise win by inheritance. */
.woocommerce-variation-price,
.woocommerce-variation-price .price,
.woocommerce-variation-price .price * {
  color: #fff;
}

/* The element is rendered even with nothing in it; no empty purple bar. */
.woocommerce-variation-price:empty {
  display: none;
}

/* ---------- Recipient block ---------- */

.gsgv-recipient {
  margin: 0 0 1.75em;
  padding: 1.25em 1.375em;
  border: 1px solid var(--gsgv-border-soft);
  border-radius: 3px;
  background: rgba(0, 0, 0, 0.015);
  color: var(--gsgv-text);
}

.gsgv-recipient__title {
  margin: 0 0 1em;
  font-size: 1.0625rem;
  color: var(--gsgv-primary);
}

.gsgv-field {
  margin: 0 0 1.125em;
}

.gsgv-field:last-child {
  margin-bottom: 0;
}

.gsgv-field[hidden] {
  display: none;
}

/*
 * The delivery date is hidden until scheduling is requested.
 *
 * Done three ways on purpose, because this field is unreachable if it fails:
 * :has() handles it with no JavaScript at all; the .is-open class covers
 * browsers without :has() support, where the script adds it; and if this
 * stylesheet never loads the field is simply visible, which is untidy but
 * still works.
 */
.gsgv-recipient:has(#gsgv_schedule:not(:checked)) .gsgv-field--schedule {
  display: none;
}

.gsgv-field--schedule.is-open {
  display: block;
}

.gsgv-field > label {
  display: block;
  margin-bottom: 0.3em;
  font-weight: 500;
  font-size: 0.9375rem;
}

.gsgv-field input[type="text"],
.gsgv-field input[type="email"],
.gsgv-field input[type="datetime-local"],
.gsgv-field textarea {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

.gsgv-field textarea {
  resize: vertical;
}

.gsgv-field__help {
  display: block;
  margin-top: 0.4em;
  font-size: 0.8125rem;
  line-height: 1.5;
  color: var(--gsgv-muted);
}

.gsgv-field__optional {
  font-weight: 400;
  color: var(--gsgv-faint);
}

.gsgv-field--checkbox > label {
  display: flex;
  align-items: flex-start;
  gap: 0.5em;
  font-weight: 500;
  cursor: pointer;
}

.gsgv-field--checkbox input[type="checkbox"] {
  flex: 0 0 auto;
  margin-top: 0.2em;
}

/* ---------- Thank-you page and order view ---------- */

.gsgv-thankyou {
  margin: 2.5em 0;
}

.gsgv-thankyou__title {
  margin: 0 0 0.75em;
}

.gsgv-thankyou__list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.gsgv-thankyou__item {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75em;
  margin: 0 0 0.625em;
  padding: 1em 1.125em;
  border: 1px solid var(--gsgv-border-soft);
  border-radius: 3px;
}

.gsgv-thankyou__for {
  flex: 1 1 16em;
}

.gsgv-thankyou__note {
  flex: 1 1 100%;
  font-size: 0.875rem;
  line-height: 1.5;
  color: var(--gsgv-muted);
}

.gsgv-thankyou__download {
  flex: 0 0 auto;
}

/* ---------- Order item meta ---------- */

.gsgv-item-meta {
  margin: 0.4em 0 0;
  padding: 0;
  list-style: none;
  font-size: 0.8125rem;
  line-height: 1.6;
  color: var(--gsgv-muted);
}

.gsgv-item-meta li {
  margin: 0;
}

/* ---------- Placement in the theme's left-hand column ---------- */

/*
 * On a gift voucher page the recipient block is rendered at the foot of
 * .course-form, under the product image, rather than inside the add-to-cart
 * form. Its fields are bound to the form by id, so this is purely visual.
 */
.course-form .gsgv-recipient {
  margin-top: 30px;
}

/* The theme spaces the Register Interest form; ours is a div, so match it. */
@media only screen and (max-width: 767px) {
  .course-form .gsgv-recipient {
    margin-top: 20px;
  }

  /*
	 * Below this width the two columns stack, so the script moves the block
	 * into the form, under the gift options. Give it room there.
	 */
  form.cart .gsgv-recipient {
    margin-top: 1.5em;
  }
}

/* The placeholder the script leaves behind to mark the desktop position. */
.gsgv-recipient-home {
  display: none;
}

/* ---------- Quantity ---------- */

/*
 * Gift vouchers are sold one per line so each gets its own recipient. The
 * theme renders its stepper regardless, readonly at 1, which just invites
 * clicks that do nothing. Scoped to the add-to-cart form (WooCommerce nests
 * it inside .woocommerce-variation-add-to-cart, so this cannot be a direct
 * child selector), and the readonly input still posts quantity=1.
 */
.single-product form.cart .quantity {
  display: none;
}
