/*
 * trioni/gift-cards (port of prototype/css/components/gift.css) — ink panel that stands out within
 * the palette. One portrait card photo per amount at a time: the chosen amount slides in from its
 * side while two blank sheets behind it hint at the set. Amount picker + purchase link (external shop).
 * Coming soon adds a text badge, cards that cross-fade every 5 s (with a stop button) and the email
 * notice form (Gift\Notice\View). Contrast on --ink: --on-ink 15.1:1, #d9d4c7 11.9:1, --gold-on-ink
 * 8.0:1 (also the reward figure of the lead); the email field is dark (--on-ink on --ink-deep
 * 16.1:1) with a --gold-ui edge (4.6:1 against the panel, 5.0:1 against its fill; --gold-on-ink on
 * hover and focus, --closed-on-ink 8.4:1 when the email is refused); the stop button's ring #6d695d
 * is 3.2:1 (WCAG 1.4.11).
 */
.gift {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
  align-items: center;
  gap: clamp(var(--s-6), 5vw, var(--s-8));
  padding: clamp(var(--s-6), 4vw, 56px) clamp(var(--s-5), 5vw, var(--s-8));
  overflow: hidden;
  border-radius: 10px;
  background:
    radial-gradient(60% 80% at 24% 50%, rgba(201, 171, 112, 0.2), transparent 70%),
    var(--ink);
  color: var(--on-ink);
}

.gift::after {
  content: '';
  position: absolute;
  inset: 12px;
  border: 1px solid rgba(201, 171, 112, 0.22);
  border-radius: 6px;
  pointer-events: none;
}

/* ---------- Card stack ---------- */
.gift__stage {
  display: grid;
  justify-items: center;
  gap: var(--s-6);
}

.gift-stack {
  --tilt-x: 0deg;
  --tilt-y: 0deg;
  position: relative;
  width: min(100%, 300px);
  aspect-ratio: 3 / 4;
  perspective: 1200px;
}

/* Two blank sheets suggest the four amounts without showing four photos at once. */
.gift-stack::before,
.gift-stack::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 0;
  border-radius: 12px;
  background: #f4f1ea;
}

.gift-stack::before {
  opacity: 0.12;
  transform: translate(22px, 12px) rotate(6deg);
}

.gift-stack::after {
  opacity: 0.26;
  transform: translate(11px, 6px) rotate(3deg);
}

.gift-stack__card {
  --offset: 0;
  position: absolute;
  inset: 0;
  z-index: 1;
  margin: 0;
  overflow: hidden;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 40px 60px -32px rgba(0, 0, 0, 0.85);
  opacity: 0;
  transform: translateX(calc(var(--offset) * 16%)) rotate(calc(var(--offset) * 3deg)) scale(0.94);
  transition: opacity 420ms var(--ease), transform 640ms var(--ease);
}

.gift-stack__card.is-active {
  z-index: 2;
  opacity: 1;
  transform: rotateX(var(--tilt-x)) rotateY(var(--tilt-y));
}

/* While the pointer moves over the card the tilt follows it closely. */
.gift-stack.is-tilting .gift-stack__card.is-active {
  transition: opacity 420ms var(--ease), transform 140ms linear;
}

.gift-stack__card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.gift__caption {
  color: var(--gold-on-ink);
  font-size: var(--fs-2xs);
  font-weight: 600;
  letter-spacing: var(--tracking-caps);
  text-transform: uppercase;
}

/* ---------- Copy ---------- */
.gift__copy h2 em {
  color: var(--gold-on-ink);
}

.gift__lead {
  max-width: 44ch;
  margin-top: var(--s-4);
  color: #d9d4c7;
  font-size: var(--fs-md);
}

/* Coming soon: the reward of the lead (Gift\Notice\View::soon_lead()), once, in the serif of the prices. */
.gift__reward {
  color: var(--gold-on-ink);
  font-family: var(--font-serif);
  font-size: 1.15em;
  font-variant-numeric: lining-nums;
  font-weight: 400;
  line-height: 1;
  white-space: nowrap;
}

.gift__amounts {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--s-2);
  margin: var(--s-6) 0 var(--s-5);
  padding: 0;
  border: 0;
}

.gift__amounts legend {
  margin-bottom: var(--s-3);
  color: var(--on-ink-muted);
  font-size: var(--fs-sm);
  font-weight: 600;
}

/* Scoped: WooCommerce prices also carry the class «amount» (it boxed the € of product prices). */
.gift__amounts .amount {
  position: relative;
}

.gift__amounts .amount input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.gift__amounts .amount span {
  display: grid;
  place-items: center;
  min-height: 64px;
  border: 1px solid #5b584e;
  border-radius: 8px;
  color: #d9d4c7;
  font-size: var(--fs-sm);
  transition: border-color var(--dur-fast) var(--ease), background-color var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
}

.gift__amounts .amount b {
  color: var(--on-ink);
  font-family: var(--font-serif);
  font-size: 1.75rem;
  font-weight: 400;
  line-height: 1;
}

.gift__amounts .amount:hover span {
  border-color: var(--gold-on-ink);
  transform: translateY(-2px);
}

.gift__amounts .amount input:checked + span {
  border-color: var(--gold);
  background: var(--gold);
  color: var(--ink);
}

.gift__amounts .amount input:checked + span b {
  color: var(--ink);
}

.gift__amounts .amount input:focus-visible + span {
  outline: 2px solid var(--gold-on-ink);
  outline-offset: 3px;
}

.gift__facts {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-2) var(--s-5);
  margin-bottom: var(--s-5);
  color: #d9d4c7;
  font-size: var(--fs-sm);
}

.gift__facts li {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
}

.gift__facts svg {
  width: 18px;
  height: 18px;
  color: var(--gold-on-ink);
}

.gift__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s-3) var(--s-5);
}

.gift__where {
  color: var(--on-ink-muted);
  font-size: var(--fs-xs);
}

/* «Muy pronto»: text, not colour only. Beside the eyebrow on wide screens, under it on phones. */
.gift__badge {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  margin: 0 0 var(--s-3);
  padding: 4px 12px;
  border: 1px solid var(--gold-on-ink);
  border-radius: 999px;
  color: var(--gold-on-ink);
  font-size: var(--fs-2xs);
  font-weight: 600;
  letter-spacing: var(--tracking-caps);
  text-transform: uppercase;
}

.gift__badge::before {
  content: '';
  width: 8px;
  height: 8px;
  flex-shrink: 0;
  border-radius: 50%;
  background: currentColor;
  /* Two pulses (4.8 s): it stops on its own before 5 s (WCAG 2.2.2), then stays still. */
  animation: gift-pulse 2.4s ease-in-out 2;
}

.eyebrow + .gift__badge {
  margin-left: var(--s-3);
}

@keyframes gift-pulse {
  50% {
    opacity: 0.5;
    transform: scale(0.8);
  }
}

/* ---------- Coming soon: cards that change by themselves ---------- */

/* A plain cross-fade (no sliding) while the cards rotate; opacity and transform only. */
.gift--soon .gift-stack__card {
  transform: scale(0.98);
  transition: opacity 900ms var(--ease), transform 900ms var(--ease);
}

.gift--soon .gift-stack__card.is-active {
  transform: rotateX(var(--tilt-x)) rotateY(var(--tilt-y));
}

.gift__toggle {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  margin-top: calc(-1 * var(--s-3));
  padding: 0;
  border: 1px solid #6d695d;
  border-radius: 50%;
  background: transparent;
  color: var(--on-ink);
  cursor: pointer;
  transition: border-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}

.gift__toggle:hover {
  border-color: var(--gold-on-ink);
  color: var(--gold-on-ink);
}

.gift__toggle[hidden] {
  display: none;
}

.gift__toggle svg {
  width: 14px;
  height: 14px;
}

/* ---------- Coming soon: email notice ---------- */
.gift-notice {
  max-width: 30rem;
  margin-top: var(--s-5);
}

.gift-notice__status {
  color: var(--on-ink);
  font-size: var(--fs-md);
  font-weight: 600;
}

.gift-notice__status:empty {
  display: none;
}

/* The line takes focus only so screen readers land on the outcome (tabindex -1): not a control, no ring. */
.gift-notice__status:focus {
  outline: none;
}

.gift-notice__status.is-problem {
  padding-left: var(--s-3);
  border-left: 2px solid var(--gold-on-ink);
  font-weight: 400;
}

.gift-notice__status + * {
  margin-top: var(--s-4);
}

/* No outcome yet: the empty (hidden) line leaves no gap above the form. */
.gift-notice__status:empty + * {
  margin-top: 0;
}

/* Coming soon: a finished outcome or an email-link question reads in the heading's serif. */
.gift--soon .gift-notice__status:not(.is-problem) {
  font-family: var(--font-serif);
  font-size: var(--fs-lg);
  font-weight: 400;
  line-height: var(--lh-snug);
}

.gift-notice__label {
  display: block;
  margin-bottom: var(--s-2);
  color: var(--on-ink-muted);
  font-size: var(--fs-xs);
  font-weight: 600;
}

/* Field and button share one line; the button drops under the field, full width, only when the
   field would be narrower than 8rem (long labels on small phones). */
.gift-notice__row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-2);
}

/* A dark field with a gold edge, not a light box on the ink. */
.gift-notice__input {
  flex: 999 1 8rem;
  min-width: 0;
  min-height: 48px;
  padding: 0 var(--s-4);
  border: 1px solid var(--gold-ui);
  border-radius: var(--radius);
  background: var(--ink-deep);
  color: var(--on-ink);
  caret-color: var(--gold-on-ink);
  font: inherit;
  font-size: 1rem;
  transition: border-color var(--dur-fast) var(--ease);
}

/* Focus keeps the house ring (.on-ink: 2 px --gold-on-ink, offset 3 px); the edge brightens too. */
.gift-notice__input:hover,
.gift-notice__input:focus {
  border-color: var(--gold-on-ink);
}

/* Chrome and Safari autofill would paint a light box under the light text. */
.gift-notice__input:-webkit-autofill {
  -webkit-text-fill-color: var(--on-ink);
  box-shadow: inset 0 0 0 48px var(--ink-deep);
}

/* Refused email: the «closed» red of the ink panels, always next to the status text that says why. */
.gift-notice__input[aria-invalid='true'] {
  border-color: var(--closed-on-ink);
  box-shadow: inset 0 0 0 1px var(--closed-on-ink), inset 0 0 0 48px var(--ink-deep);
}

.gift-notice__row .btn {
  flex: 1 0 auto;
}

/* While the request runs the button keeps its focus (aria-disabled, not disabled) and takes the
   deeper gold (--ink on --gold-ui 4.6:1). */
.gift-notice__row .btn[aria-disabled='true'] {
  background: var(--gold-ui);
  cursor: progress;
}

.gift-notice__note {
  margin-top: var(--s-3);
  color: var(--on-ink-muted);
  font-size: var(--fs-xs);
}

.gift-notice__note a {
  color: var(--gold-on-ink);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.gift-notice__note a:hover {
  color: var(--on-ink);
}

/* Honeypot: off screen and out of the accessibility tree; people never see it, bots fill it. */
.gift-notice__trap {
  position: absolute;
  left: -10000px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

/* Buttons of the email links: «Sí, avísame» / «No, borrar mi correo», or «Darme de baja». */
.gift-notice__actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-2);
}

/* .btn--line-on-ink is drawn for links: a <button> would keep the light browser background. */
.gift-notice__actions .btn--line-on-ink {
  background: transparent;
}

@media (prefers-reduced-motion: reduce) {
  .gift__badge::before {
    animation: none;
  }

  .gift-stack__card,
  .gift-stack__card.is-active,
  .gift--soon .gift-stack__card,
  .gift--soon .gift-stack__card.is-active {
    transform: none;
    transition: opacity 420ms var(--ease);
  }
}

@media (max-width: 959px) {
  .gift {
    grid-template-columns: 1fr;
  }

  .gift-stack {
    width: min(100%, 260px);
  }
}

/*
 * Phones: a compact horizontal card. The active card photo (96 × 128, no fan) sits beside the
 * heading; the amounts (one row), the button and the shop line run full width under both. The
 * caption, the three facts and the visible legend stay for wider screens.
 */
@media (max-width: 559px) {
  .gift {
    grid-template-columns: 96px minmax(0, 1fr);
    grid-template-rows: auto auto auto 1fr;
    align-items: start;
    gap: 0 var(--s-4);
    padding: 20px;
  }

  .gift::after {
    inset: 8px;
  }

  .gift__copy {
    display: contents;
  }

  .gift__stage {
    grid-row: 1 / span 4;
    grid-column: 1;
    gap: 0;
  }

  .gift__copy > :is(.eyebrow, .gift__badge, h2, .gift__lead) {
    grid-column: 2;
  }

  .gift__copy > :is(.gift__amounts, .gift__actions, .gift-notice) {
    grid-column: 1 / -1;
  }

  .gift__copy > .gift__badge {
    justify-self: start;
    margin: 0 0 var(--s-2);
    padding: 3px 10px;
    font-size: 0.6875rem;
    letter-spacing: 0.08em;
    white-space: nowrap;
  }

  .gift-notice {
    margin-top: var(--s-4);
  }

  .gift-notice__input {
    padding: 0 var(--s-3);
  }

  .gift-notice__row .btn {
    padding: 0 var(--s-4);
  }

  .gift-notice__note {
    margin-top: 10px;
    font-size: var(--fs-2xs);
  }

  .gift__toggle {
    margin-top: var(--s-2);
  }

  .gift h2 {
    font-size: 1.75rem;
  }

  .gift__lead {
    margin-top: 6px;
    font-size: 0.9375rem;
    line-height: 1.45;
  }

  .gift-stack {
    width: 96px;
  }

  .gift-stack::before,
  .gift-stack::after,
  .gift-stack__card:not(.is-active),
  .gift__caption,
  .gift__facts {
    display: none;
  }

  /* Coming soon: every card stays in the box (transparent) so the next one fades in loaded. */
  .gift--soon .gift-stack__card:not(.is-active) {
    display: block;
  }

  .gift-stack__card {
    border-radius: 6px;
    box-shadow: 0 16px 28px -18px rgba(0, 0, 0, 0.85);
  }

  .gift__amounts {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 6px;
    margin: var(--s-4) 0 var(--s-3);
  }

  .gift__amounts legend {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }

  .gift__amounts .amount span {
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 3px;
    min-height: 44px;
    padding-top: 11px;
    border-radius: 6px;
    white-space: nowrap;
  }

  .gift__amounts .amount b {
    font-size: 1.125rem;
  }

  .gift__actions {
    gap: var(--s-2);
  }

  .gift__actions .btn {
    width: 100%;
    justify-content: space-between;
  }

  /*
   * Coming soon: a smaller photo (80 × 107) beside the eyebrow, the badge and the heading only;
   * the lead and the notice run full width under them. The stop button sits on the photo's
   * corner, so it adds no height. The sale layout keeps the rules above.
   */
  .gift.gift--soon {
    grid-template-columns: 80px minmax(0, 1fr);
    grid-template-rows: auto auto 1fr;
  }

  .gift--soon .gift__stage {
    position: relative;
    grid-row: 1 / span 3;
  }

  .gift--soon .gift-stack {
    width: 80px;
  }

  .gift--soon .gift__toggle {
    position: absolute;
    right: -8px;
    bottom: -8px;
    width: 36px;
    height: 36px;
    margin: 0;
    background: var(--ink);
  }

  /* An ink halo keeps the gold focus ring off the white photo. */
  .gift--soon .gift__toggle:focus-visible {
    outline-offset: 1px;
    box-shadow: 0 0 0 4px var(--ink);
  }

  .gift--soon .gift__toggle svg {
    width: 12px;
    height: 12px;
  }

  .gift--soon .gift__copy > .gift__lead {
    grid-column: 1 / -1;
    max-width: none;
    margin-top: var(--s-3);
  }
}
