/**
 * voucher.css
 * Gift vouchers: the card (product page preview, /nos-vins, printable page),
 * the options form of the product page and the printable page itself.
 * Loaded on the shop's pages (porta_enqueue_assets()) and linked directly by
 * template-parts/voucher-print.php. Cart and checkout rows: woocommerce.css.
 *
 * @package astra-child
 */

/* ── The card ───────────────────────────────────────────────────────────── */

.porta-voucher-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  box-sizing: border-box;
  width: 100%;
  padding: 2.5rem 1.5rem;
  background-color: var(--color-bg);
  border: var(--btn-border-width) solid var(--color-accent);
  /* A second, thin frame inside the first: the look of a printed voucher. */
  outline: 1px solid var(--color-gold);
  outline-offset: -0.5rem;
  color: var(--color-text);
  text-align: center;
}

.porta-voucher-card p {
  margin: 0;
}

.porta-voucher-card__logo {
  width: 7.5rem;
  height: auto;
  margin-bottom: 0.5rem;
}

.porta-voucher-card__title {
  font-family: var(--font-heading);
  font-size: var(--text-3xl);
  line-height: 1.2;
  color: var(--color-accent);
}

.porta-voucher-card__value {
  font-family: var(--font-heading);
  font-size: var(--text-2xl);
  line-height: 1.2;
}

.porta-voucher-card__value:empty {
  display: none;
}

.porta-voucher-card__rule {
  display: block;
  width: 40px;
  height: 2px;
  margin: 0.5rem 0;
  background-color: var(--color-gold);
}

.porta-voucher-card__line {
  max-width: 28rem;
  font-size: var(--text-sm);
  line-height: 1.5;
}

.porta-voucher-card__code {
  margin-top: 0.75rem;
  padding: 0.5rem 1rem;
  background-color: var(--color-bg-alt);
  /* A code is read letter by letter: monospace, widely spaced. */
  font-family: ui-monospace, 'Courier New', monospace;
  font-size: var(--text-xl);
  letter-spacing: var(--tracking-widest);
}

.porta-voucher-card__valid {
  font-size: var(--eyebrow-size);
  font-weight: var(--eyebrow-weight);
  letter-spacing: var(--eyebrow-tracking);
  text-transform: uppercase;
  color: var(--color-gold-text);
}

.porta-voucher-card__small {
  max-width: 30rem;
  font-size: var(--text-xs);
  line-height: 1.5;
  color: var(--color-text-light);
}

/* /nos-vins: the card stands where a wine has its bottle photo. */
.porta-wine-card__image .porta-voucher-card--mini {
  height: 100%;
  justify-content: center;
  padding: 1.5rem 1rem;
  /* The catalogue card has no frame of its own: the voucher's is drawn inside the photo box. */
  border: 0;
  outline-offset: -0.75rem;
}

.porta-wine-card__image .porta-voucher-card--mini .porta-voucher-card__logo {
  /* Undo the bottle photo's box rules (.porta-wine-card__image img). */
  width: 6rem;
  height: auto;
  padding: 0;
  object-fit: initial;
}

.porta-voucher-card--mini .porta-voucher-card__title {
  font-size: var(--text-2xl);
}

/* ── Product page ───────────────────────────────────────────────────────── */

.porta-voucher-preview {
  align-self: start;
}

.porta-voucher-form {
  width: 100%;
}

.porta-voucher-form__group {
  width: 100%;
  margin: 0 0 0.5rem;
  padding: 0;
  border: 0;
}

.porta-voucher-form__legend {
  display: block;
  margin-bottom: 0.5rem;
  padding: 0;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-text);
}

.porta-voucher-form__choices {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.porta-voucher-form__choices--stacked {
  flex-direction: column;
}

/* A choice is a radio drawn as a pill (amounts) or a row (formules): the input
   stays in the page for keyboards and screen readers, only hidden from sight. */
.porta-voucher-choice {
  position: relative;
  display: inline-flex;
  cursor: pointer;
}

.porta-voucher-choice--block {
  display: flex;
}

.porta-voucher-choice input {
  position: absolute;
  opacity: 0;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  cursor: pointer;
}

.porta-voucher-choice__label {
  display: inline-flex;
  align-items: center;
  box-sizing: border-box;
  min-height: var(--tap-size);
  padding: 0.5rem 1.25rem;
  background-color: var(--color-white);
  border: 1px solid var(--color-text-muted);
  border-radius: var(--border-radius);
  font-size: var(--text-sm);
  color: var(--color-text);
  transition: border-color var(--duration-fast) ease, background-color var(--duration-fast) ease;
}

.porta-voucher-choice--block .porta-voucher-choice__label {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.125rem 1rem;
  width: 100%;
  padding: 0.75rem 1rem;
}

.porta-voucher-choice__name {
  font-family: var(--font-heading);
  font-size: var(--text-lg);
}

.porta-voucher-choice__price {
  font-weight: 500;
  white-space: nowrap;
}

.porta-voucher-choice__desc {
  grid-column: 1 / -1;
  font-size: var(--text-xs);
  line-height: 1.5;
  color: var(--color-text-light);
}

.porta-voucher-choice:hover .porta-voucher-choice__label {
  border-color: var(--color-accent);
}

.porta-voucher-choice input:checked + .porta-voucher-choice__label {
  border-color: var(--color-accent);
  /* 1px border + 1px ring = the 2px of a selected control, without moving the text. */
  box-shadow: inset 0 0 0 1px var(--color-accent);
  background-color: var(--color-bg);
}

.porta-voucher-choice input:focus-visible + .porta-voucher-choice__label {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

/* What is on each planchette, under the choices. */
.porta-voucher-form__hint {
  margin: 0.5rem 0 0;
  font-size: var(--text-xs);
  color: var(--color-text-light);
}

.porta-voucher-form__total {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  margin: 0.5rem 0 0;
}

.porta-voucher-form__total-label {
  font-size: var(--text-sm);
  color: var(--color-text-light);
}

.porta-voucher-form__total-value {
  font-family: var(--font-heading);
  font-size: var(--text-2xl);
  font-weight: 400;
  color: var(--color-text);
}

.porta-voucher-facts {
  margin: 1.5rem 0 0;
  padding: 0;
  list-style: none;
  font-size: var(--text-sm);
  color: var(--color-text-light);
}

.porta-voucher-facts li {
  position: relative;
  padding-left: 1.25rem;
  line-height: 1.6;
}

/* The gold dash of the section headings, as a bullet. */
.porta-voucher-facts li::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0.75em;
  width: 0.625rem;
  height: 2px;
  background-color: var(--color-gold);
}

.porta-voucher-how__steps {
  display: grid;
  gap: 2rem;
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: porta-voucher-step;
}

@media (min-width: 768px) {
  .porta-voucher-how__steps {
    grid-template-columns: repeat(3, 1fr);
  }
}

.porta-voucher-how__steps li {
  counter-increment: porta-voucher-step;
}

.porta-voucher-how__steps li::before {
  content: counter(porta-voucher-step);
  display: block;
  margin-bottom: 0.25rem;
  font-family: var(--font-heading);
  font-size: var(--text-3xl);
  line-height: 1;
  color: var(--color-gold-text);
}

.porta-voucher-how__title {
  margin: 0 0 0.5rem;
  font-family: var(--font-heading);
  font-size: var(--text-xl);
  font-weight: 400;
  color: var(--color-text);
}

.porta-voucher-how__steps p {
  margin: 0;
  font-size: var(--text-sm);
  line-height: 1.6;
  color: var(--color-text-light);
}

.porta-voucher-how__more {
  margin: 2rem 0 0;
  font-size: var(--text-sm);
}

/* ── Printable page (template-parts/voucher-print.php) ──────────────────── */

.porta-voucher-print {
  margin: 0;
  background-color: var(--color-bg-alt);
  font-family: var(--font-body);
}

.porta-voucher-print__page {
  box-sizing: border-box;
  /* A5 landscape, the card's printed size. */
  max-width: 210mm;
  margin: 0 auto;
  padding: 1.5rem 1rem;
}

.porta-voucher-print .porta-voucher-card {
  min-height: 128mm;
  justify-content: center;
}

.porta-voucher-print__state {
  margin: 0 0 1rem;
  padding: 0.75rem 1rem;
  background-color: var(--color-white);
  border-left: 3px solid var(--color-accent);
  font-size: var(--text-sm);
}

.porta-voucher-print__actions {
  margin: 1.5rem 0 0;
  text-align: center;
}

@page {
  size: A5 landscape;
  margin: 8mm;
}

@media print {
  .porta-voucher-print {
    background-color: var(--color-white);
  }

  .porta-voucher-print__page {
    padding: 0;
  }

  .porta-voucher-print__actions,
  .porta-voucher-print__state {
    display: none;
  }

  .porta-voucher-print .porta-voucher-card {
    /* Browsers drop backgrounds when printing unless asked to keep them. */
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
  }
}
