/* Discount popup — desktop modal + mobile bottom sheet */
:root {
  --ph-discount-ease: cubic-bezier(0.22, 1, 0.36, 1);
  --ph-discount-sheet-ease: cubic-bezier(0.32, 0.72, 0, 1);
  --ph-discount-enter: 0.72s;
  --ph-discount-fade: 0.5s;
  --ph-discount-leave-desktop: 0.38s;
  --ph-discount-leave-mobile: 0.42s;
  --ph-discount-dialog-max-h-mobile: 92vh;
  --ph-discount-mint: #5a9a87;
  --ph-discount-mint-light: #7ec8ae;
  --ph-discount-text: #2f413e;
  --ph-discount-text-muted: #566b66;
  --ph-discount-border: #e0e0e0;
  --ph-discount-radius: 20px;
}

/* ── Overlay ── */
.ph-discount-popup {
  position: fixed;
  inset: 0;
  z-index: 10050;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(1rem, 2.5vh, 1.75rem) clamp(1rem, 2.5vw, 2rem);
  background: rgba(47, 65, 62, 0.58);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition:
    opacity var(--ph-discount-fade) ease,
    visibility var(--ph-discount-fade) ease;
}

.ph-discount-popup.is-visible {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.ph-discount-popup.is-visible.is-leaving {
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--ph-discount-leave-desktop) ease-in;
}

/* ── Dialog shell ── */
.ph-discount-popup__dialog {
  position: relative;
  display: flex;
  flex-direction: row;
  align-items: stretch;
  width: min(900px, 100%);
  min-height: 560px;
  max-height: calc(100vh - 2rem);
  background: #fff;
  border-radius: var(--ph-discount-radius);
  overflow: hidden;
  opacity: 0;
  box-shadow:
    0 12px 32px rgba(47, 65, 62, 0.12),
    0 4px 12px rgba(47, 65, 62, 0.06);
  transform: translateY(32px) scale(0.96);
  transition:
    opacity var(--ph-discount-enter) var(--ph-discount-ease),
    transform var(--ph-discount-enter) var(--ph-discount-ease),
    box-shadow var(--ph-discount-enter) var(--ph-discount-ease);
  will-change: transform, opacity;
}

.ph-discount-popup.is-visible .ph-discount-popup__dialog {
  opacity: 1;
  transform: translateY(0) scale(1);
  box-shadow:
    0 24px 64px rgba(47, 65, 62, 0.28),
    0 8px 24px rgba(47, 65, 62, 0.12);
}

.ph-discount-popup.is-visible.is-leaving .ph-discount-popup__dialog {
  opacity: 0;
  transform: translateY(16px) scale(0.97);
  box-shadow:
    0 12px 32px rgba(47, 65, 62, 0.12),
    0 4px 12px rgba(47, 65, 62, 0.06);
  transition:
    opacity var(--ph-discount-leave-desktop) ease-in,
    transform var(--ph-discount-leave-desktop) ease-in,
    box-shadow var(--ph-discount-leave-desktop) ease-in;
}

/* ── Entrance animations ── */
.ph-discount-popup__content > :not(.ph-discount-popup__close) {
  opacity: 0;
  transform: translateY(12px);
  transition:
    opacity 0.52s var(--ph-discount-ease),
    transform 0.52s var(--ph-discount-ease);
}

.ph-discount-popup.is-visible .ph-discount-popup__content > :not(.ph-discount-popup__close) {
  opacity: 1;
  transform: translateY(0);
}

.ph-discount-popup.is-visible .ph-discount-popup__handle { transition-delay: 0.14s; }
.ph-discount-popup.is-visible .ph-discount-popup__eyebrow { transition-delay: 0.22s; }
.ph-discount-popup.is-visible .ph-discount-popup__title { transition-delay: 0.28s; }
.ph-discount-popup.is-visible .ph-discount-popup__desc { transition-delay: 0.34s; }
.ph-discount-popup.is-visible .ph-discount-popup__scroll { transition-delay: 0.4s; }
.ph-discount-popup.is-visible .ph-discount-popup__legal { transition-delay: 0.48s; }

.ph-discount-popup.is-visible.is-leaving .ph-discount-popup__content > :not(.ph-discount-popup__close) {
  opacity: 0;
  transform: translateY(8px);
  transition:
    opacity 0.22s ease-in,
    transform 0.22s ease-in;
  transition-delay: 0s !important;
}

/* ── Image panel (left) ── */
.ph-discount-popup__media {
  position: relative;
  flex: 0 0 45%;
  min-width: 45%;
  min-height: 0;
  overflow: hidden;
  border-radius: var(--ph-discount-radius) 0 0 var(--ph-discount-radius);
  background: linear-gradient(180deg, #f5f5f5 0%, #ffffff 100%);
}

.ph-discount-popup__media img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center center;
}

/* ── Content panel (right) ── */
.ph-discount-popup__content {
  display: flex;
  flex: 1 1 55%;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  padding: 40px;
  font-family: "Montserrat", ui-sans-serif, system-ui, sans-serif;
}

.ph-discount-popup__scroll {
  flex: 0 0 auto;
  overflow: visible;
}

/* ── Close button ── */
.ph-discount-popup__close {
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.92);
  color: #3f5450;
  cursor: pointer;
  opacity: 0;
  box-shadow: 0 4px 16px rgba(47, 65, 62, 0.12);
  transition:
    background 0.2s ease,
    transform 0.2s ease,
    opacity 0.4s var(--ph-discount-ease) 0.2s;
}

.ph-discount-popup.is-visible .ph-discount-popup__close {
  opacity: 1;
}

.ph-discount-popup__close:hover,
.ph-discount-popup__close:focus-visible {
  background: #fff;
  transform: scale(1.04);
  outline: none;
}

.ph-discount-popup__close svg {
  width: 18px;
  height: 18px;
}

/* ── Typography & hierarchy ── */
.ph-discount-popup__eyebrow {
  margin: 0 0 12px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #6a827c;
}

.ph-discount-popup__title {
  margin: 0 0 6px;
  font-size: 28px;
  font-weight: 600;
  line-height: 1.2;
  color: var(--ph-discount-text);
}

.ph-discount-popup__title .ph-discount-popup__offer {
  display: block;
  margin-top: 6px;
  font-size: 32px;
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.02em;
  color: var(--ph-discount-mint);
}

/* Código integrado en el encabezado — sin bloque gris separado */
.ph-discount-popup__title .ph-discount-popup__offer::after {
  content: "Código: PEPTIX10";
  display: block;
  margin-top: 10px;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.1em;
  color: #6a827c;
}

.ph-discount-popup__desc {
  margin: 0 0 24px;
  font-size: 0.875rem;
  line-height: 1.55;
  color: var(--ph-discount-text-muted);
}

/* Ocultar bloque promo separado en desktop; mantiene accesibilidad vía aria-label */
.ph-discount-popup__promo {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ── Form ── */
.ph-discount-popup__form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.ph-discount-popup__row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.ph-discount-popup__field {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.ph-discount-popup__input {
  width: 100%;
  padding: 14px 16px;
  border: 1.5px solid var(--ph-discount-border);
  border-radius: 8px;
  font: inherit;
  font-size: 0.95rem;
  color: var(--ph-discount-text);
  background: #fff;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.ph-discount-popup__input:focus {
  outline: none;
  border-color: var(--ph-discount-mint-light);
  box-shadow: 0 0 0 3px rgba(126, 200, 174, 0.22);
}

.ph-discount-popup__input.is-error {
  border-color: #c75c5c;
}

.ph-discount-popup__age {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin: 0;
  padding: 14px 16px;
  border: 1.5px solid var(--ph-discount-border);
  border-radius: 8px;
  background: #fff;
  font-size: 0.84rem;
  line-height: 1.45;
  color: #3f5450;
  cursor: pointer;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.ph-discount-popup__age.is-error {
  border-color: #c75c5c;
  box-shadow: 0 0 0 2px rgba(199, 92, 92, 0.12);
}

.ph-discount-popup__age-input {
  flex-shrink: 0;
  width: 1rem;
  height: 1rem;
  margin: 0.15rem 0 0;
  accent-color: var(--ph-discount-mint);
  cursor: pointer;
}

.ph-discount-popup__age span {
  flex: 1;
}

select.ph-discount-popup__input {
  cursor: pointer;
}

.ph-discount-popup__error {
  min-height: 0;
  margin: 0;
  font-size: 0.78rem;
  line-height: 1.4;
  color: #b04545;
}

.ph-discount-popup__error:empty {
  display: none;
}

.ph-discount-popup__error:not(:empty) {
  min-height: 1.1rem;
}

.ph-discount-popup__submit {
  width: 100%;
  margin-top: 4px;
  padding: 16px;
  border: 0;
  border-radius: 8px;
  font: inherit;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #fff;
  background: linear-gradient(135deg, #addbca 0%, var(--ph-discount-mint-light) 100%);
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, filter 0.2s ease;
}

.ph-discount-popup__submit:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 10px 24px rgba(126, 200, 174, 0.28);
}

.ph-discount-popup__submit:disabled {
  opacity: 0.72;
  cursor: wait;
}

/* ── Secondary actions ── */
.ph-discount-popup__snooze,
.ph-discount-popup__dismiss {
  margin-top: 12px;
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  font-size: 0.8rem;
  line-height: 1.45;
  text-align: center;
  cursor: pointer;
}

.ph-discount-popup__snooze {
  color: var(--ph-discount-mint);
  text-decoration: none;
}

.ph-discount-popup__snooze:hover,
.ph-discount-popup__snooze:focus-visible {
  color: #3f5450;
  text-decoration: underline;
  text-underline-offset: 0.15em;
}

.ph-discount-popup__dismiss {
  margin-top: 8px;
  margin-bottom: 0;
  color: #6a827c;
  text-decoration: underline;
  text-underline-offset: 0.15em;
}

.ph-discount-popup__dismiss:hover,
.ph-discount-popup__dismiss:focus-visible {
  color: #3f5450;
}

/* ── Legal footer ── */
.ph-discount-popup__legal {
  flex-shrink: 0;
  margin: 20px 0 0;
  padding: 16px 0 0;
  border-top: 1px solid #e8f0ec;
  font-size: 0.68rem;
  line-height: 1.55;
  color: #6a827c;
}

.ph-discount-popup__legal a {
  color: var(--ph-discount-mint);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 0.12em;
}

.ph-discount-popup__legal a:hover,
.ph-discount-popup__legal a:focus-visible {
  color: #3f5450;
}

.ph-discount-popup__handle {
  display: none;
}

/* ── Desktop: imagen con más aire alrededor del frasco ── */
@media (min-width: 769px) {
  .ph-discount-popup__media {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 32px 24px;
    box-sizing: border-box;
  }

  .ph-discount-popup__media img {
    width: 100%;
    height: 100%;
    max-height: 100%;
    object-fit: cover;
    object-position: center center;
    border-radius: 4px;
  }
}

/* ── Pantallas bajas: compactar sin scroll ── */
@media (min-width: 769px) and (max-height: 780px) {
  .ph-discount-popup__dialog {
    min-height: 0;
  }

  .ph-discount-popup__content {
    padding: 32px;
  }

  .ph-discount-popup__title {
    font-size: 24px;
  }

  .ph-discount-popup__title .ph-discount-popup__offer {
    font-size: 28px;
  }

  .ph-discount-popup__desc {
    margin-bottom: 18px;
    font-size: 0.82rem;
  }

  .ph-discount-popup__media {
    padding: 20px 16px;
  }
}

/* ── Mobile: bottom sheet sin scroll (iPhone SE 375×667) ── */
@media (max-width: 768px) {
  .ph-discount-popup {
    align-items: flex-end;
    justify-content: center;
    padding: 0;
    transition:
      opacity var(--ph-discount-fade) ease,
      visibility var(--ph-discount-fade) ease;
  }

  .ph-discount-popup.is-visible.is-leaving {
    transition: opacity var(--ph-discount-leave-mobile) cubic-bezier(0.32, 0, 0.67, 0);
  }

  .ph-discount-popup__dialog {
    display: block;
    width: 100%;
    min-height: 0;
    max-height: 100dvh;
    overflow: hidden !important;
    border-radius: 18px 18px 0 0;
    opacity: 0;
    transform: translateY(100%);
    box-shadow:
      0 -10px 44px rgba(47, 65, 62, 0.16),
      0 -4px 16px rgba(47, 65, 62, 0.08);
    transition:
      opacity var(--ph-discount-enter) var(--ph-discount-sheet-ease),
      transform var(--ph-discount-enter) var(--ph-discount-sheet-ease),
      box-shadow var(--ph-discount-enter) var(--ph-discount-sheet-ease);
  }

  .ph-discount-popup.is-visible .ph-discount-popup__dialog {
    opacity: 1;
    transform: translateY(0);
    box-shadow:
      0 -14px 52px rgba(47, 65, 62, 0.2),
      0 -6px 20px rgba(47, 65, 62, 0.1);
  }

  .ph-discount-popup.is-visible.is-leaving .ph-discount-popup__dialog {
    opacity: 0;
    transform: translateY(100%);
    box-shadow:
      0 -6px 24px rgba(47, 65, 62, 0.1),
      0 -2px 8px rgba(47, 65, 62, 0.06);
    transition:
      opacity var(--ph-discount-leave-mobile) cubic-bezier(0.32, 0, 0.67, 0),
      transform var(--ph-discount-leave-mobile) cubic-bezier(0.32, 0, 0.67, 0),
      box-shadow var(--ph-discount-leave-mobile) cubic-bezier(0.32, 0, 0.67, 0);
  }

  .ph-discount-popup__content > :not(.ph-discount-popup__close) {
    transform: translateY(8px);
  }

  .ph-discount-popup__media {
    display: none;
  }

  .ph-discount-popup__handle {
    display: block;
    width: 36px;
    height: 4px;
    margin: 8px auto 4px;
    border-radius: 999px;
    background: #c5ddd6;
  }

  .ph-discount-popup__content {
    flex: none;
    justify-content: flex-start;
    overflow: hidden;
    padding:
      4px 20px
      calc(14px + env(safe-area-inset-bottom, 0px));
  }

  .ph-discount-popup__scroll {
    overflow: hidden;
  }

  .ph-discount-popup__close {
    top: 10px;
    right: 10px;
    width: 32px;
    height: 32px;
    box-shadow: none;
    background: #f3f9f6;
  }

  .ph-discount-popup__close svg {
    width: 16px;
    height: 16px;
  }

  .ph-discount-popup__eyebrow {
    margin: 0 0 8px;
    padding-right: 38px;
    font-size: 0.625rem;
    letter-spacing: 0.1em;
  }

  .ph-discount-popup__title {
    margin: 0 0 10px;
    padding-right: 38px;
    font-size: 1.0625rem;
    line-height: 1.2;
  }

  .ph-discount-popup__title .ph-discount-popup__offer {
    display: block;
    margin-top: 2px;
    font-size: 1.375rem;
    line-height: 1.08;
  }

  .ph-discount-popup__title .ph-discount-popup__offer::after {
    content: "Código: PEPTIX10";
    display: inline-block;
    margin-top: 6px;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    color: var(--ph-discount-mint);
    background: rgba(90, 154, 135, 0.08);
  }

  .ph-discount-popup__desc {
    margin: 0 0 14px;
    font-size: 0.75rem;
    line-height: 1.35;
  }

  .ph-discount-popup__form {
    gap: 11px;
  }

  .ph-discount-popup__row {
    grid-template-columns: 1fr 1fr;
    gap: 11px;
  }

  .ph-discount-popup__input {
    padding: 10px 12px;
    font-size: 16px;
    border-radius: 8px;
  }

  .ph-discount-popup__age {
    padding: 9px 12px;
    font-size: 0.75rem;
    line-height: 1.35;
    gap: 8px;
    border-radius: 8px;
  }

  .ph-discount-popup__age-input {
    width: 0.875rem;
    height: 0.875rem;
    margin-top: 0.1rem;
  }

  .ph-discount-popup__error {
    min-height: 0;
    margin: 0;
    font-size: 0.7rem;
    line-height: 1.3;
  }

  .ph-discount-popup__error:empty {
    display: none;
  }

  .ph-discount-popup__submit {
    margin-top: 4px;
    padding: 12px 14px;
    font-size: 14px;
    border-radius: 8px;
  }

  .ph-discount-popup__snooze,
  .ph-discount-popup__dismiss {
    font-size: 0.75rem;
    line-height: 1.35;
  }

  .ph-discount-popup__snooze {
    margin-top: 8px;
  }

  .ph-discount-popup__dismiss {
    margin-top: 5px;
    margin-bottom: 0;
  }

  .ph-discount-popup__legal {
    margin-top: 10px;
    padding: 10px 0 0;
    font-size: 0.625rem;
    line-height: 1.35;
  }
}

@media (max-width: 380px) {
  .ph-discount-popup__content {
    padding-left: 18px;
    padding-right: 18px;
  }

  .ph-discount-popup__row {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .ph-discount-popup__title {
    font-size: 1rem;
  }

  .ph-discount-popup__title .ph-discount-popup__offer {
    font-size: 1.3125rem;
  }
}

body.ph-discount-popup-visible .ph-wa-bar {
  opacity: 0 !important;
  pointer-events: none !important;
  transform: translateY(110%) !important;
}

@media (prefers-reduced-motion: reduce) {
  .ph-discount-popup,
  .ph-discount-popup__dialog,
  .ph-discount-popup__content > :not(.ph-discount-popup__close),
  .ph-discount-popup__close,
  .ph-discount-popup__submit {
    transition: none !important;
    transform: none !important;
    opacity: 1 !important;
  }

  .ph-discount-popup.is-visible.is-leaving,
  .ph-discount-popup.is-visible.is-leaving .ph-discount-popup__dialog,
  .ph-discount-popup.is-visible.is-leaving .ph-discount-popup__content > :not(.ph-discount-popup__close) {
    transition: none !important;
    transform: none !important;
    opacity: 1 !important;
  }
}
