/* ============================================================================
   ENTRÉNATE · NEWSLETTER.CSS
   Modal flotante de suscripción a la newsletter
   ============================================================================ */

/* ----------------------------------------------------------------------------
   OVERLAY + CONTENEDOR
   ---------------------------------------------------------------------------- */
.newsletter-modal {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal, 400);
  display: grid;
  place-items: center;
  padding: var(--space-4);
  opacity: 0;
  transition: opacity var(--duration-base) var(--ease-out);
}

.newsletter-modal[hidden] {
  display: none !important;
}

.newsletter-modal.is-open {
  opacity: 1;
}

/* Overlay: fondo cálido + blur */
.newsletter-modal__overlay {
  position: absolute;
  inset: 0;
  background: rgba(63, 47, 35, 0.65);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

/* ----------------------------------------------------------------------------
   DIALOG
   ---------------------------------------------------------------------------- */
.newsletter-modal__dialog {
  position: relative;
  width: 100%;
  max-width: 520px;
  max-height: calc(100vh - var(--space-8));
  background: var(--bg-base);
  border: var(--border-width-thin) solid var(--border-subtle);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  overflow-y: auto;
  transform: scale(0.95) translateY(8px);
  opacity: 0;
  transition:
    transform var(--duration-base) var(--ease-out),
    opacity var(--duration-base) var(--ease-out);
}

.newsletter-modal.is-open .newsletter-modal__dialog {
  transform: scale(1) translateY(0);
  opacity: 1;
}

/* Botón X */
.newsletter-modal__close {
  position: absolute;
  top: var(--space-3);
  right: var(--space-3);
  width: 40px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  background: color-mix(in srgb, var(--color-earth-500) 8%, transparent);
  color: var(--text-body);
  transition:
    background var(--duration-fast) var(--ease-out),
    color var(--duration-fast) var(--ease-out);
  z-index: 2;
}
.newsletter-modal__close:hover {
  background: color-mix(in srgb, var(--color-camel-500) 15%, transparent);
  color: var(--color-camel-600);
}
.newsletter-modal__close:focus-visible {
  outline: none;
  box-shadow: var(--shadow-focus);
}
.newsletter-modal__close svg {
  width: 20px;
  height: 20px;
}

/* ----------------------------------------------------------------------------
   BODY
   ---------------------------------------------------------------------------- */
.newsletter-modal__body {
  padding: var(--space-8);
}

@media (max-width: 767px) {
  .newsletter-modal {
    padding: 0;
  }
  .newsletter-modal__dialog {
    max-width: 100%;
    max-height: 100vh;
    height: 100%;
    border-radius: 0;
    border: 0;
  }
  .newsletter-modal__body {
    padding: var(--space-6) var(--space-5);
  }
}

/* ----------------------------------------------------------------------------
   HEADER
   ---------------------------------------------------------------------------- */
.newsletter-modal__header {
  margin-bottom: var(--space-6);
  padding-right: var(--space-8);
}

.newsletter-modal__badge {
  display: inline-block;
  padding: 6px 14px;
  background: color-mix(in srgb, var(--color-camel-500) 12%, transparent);
  color: var(--color-camel-600);
  border-radius: var(--radius-pill);
  font-size: var(--fs-caption);
  font-weight: var(--fw-semibold);
  letter-spacing: var(--ls-wide);
  margin-bottom: var(--space-3);
}

.newsletter-modal__title {
  font-size: var(--fs-h3);
  font-weight: var(--fw-bold);
  line-height: var(--lh-heading);
  letter-spacing: var(--ls-snug);
  color: var(--text-primary);
  margin: 0 0 var(--space-3) 0;
  text-wrap: balance;
}

.newsletter-modal__desc {
  font-size: var(--fs-body-sm);
  line-height: var(--lh-relaxed);
  color: var(--text-muted);
  margin: 0;
}

/* ----------------------------------------------------------------------------
   FORMULARIO
   ---------------------------------------------------------------------------- */
.newsletter-modal__form {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
}

.newsletter-modal__row {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-5);
}
@media (min-width: 480px) {
  .newsletter-modal__row {
    grid-template-columns: 1fr 1fr;
  }
}

.newsletter-modal__field {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.newsletter-modal__label {
  font-size: var(--fs-caption);
  font-weight: var(--fw-semibold);
  color: var(--text-primary);
  letter-spacing: var(--ls-wide);
}

.newsletter-modal__input,
.newsletter-modal__select {
  width: 100%;
  height: 48px;
  padding: 0 var(--space-4);
  font-family: inherit;
  font-size: var(--fs-body-sm);
  color: var(--text-body);
  background: var(--bg-subtle);
  border: var(--border-width-thin) solid var(--border-default);
  border-radius: var(--radius-md);
  transition:
    border-color var(--duration-fast) var(--ease-out),
    box-shadow var(--duration-fast) var(--ease-out),
    background var(--duration-fast) var(--ease-out);
}

.newsletter-modal__select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%235a4a3b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 16px center;
  background-size: 18px;
  padding-right: 44px;
  cursor: pointer;
}

.newsletter-modal__input::placeholder {
  color: var(--text-muted);
}

.newsletter-modal__input:hover,
.newsletter-modal__select:hover {
  border-color: var(--border-strong);
}

.newsletter-modal__input:focus,
.newsletter-modal__select:focus {
  outline: none;
  border-color: var(--color-camel-500);
  background: var(--color-white);
  box-shadow: var(--shadow-focus);
}

.newsletter-modal__input.is-error,
.newsletter-modal__select.is-error {
  border-color: var(--color-error);
}

/* Mensajes de error por campo */
.newsletter-modal__error {
  font-size: var(--fs-micro);
  color: var(--color-error);
  font-weight: var(--fw-semibold);
  line-height: var(--lh-snug);
}

/* ----------------------------------------------------------------------------
   CHECKBOX DE CONSENTIMIENTO
   ---------------------------------------------------------------------------- */
.newsletter-modal__consent {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  cursor: pointer;
  font-size: var(--fs-caption);
  line-height: var(--lh-snug);
  color: var(--text-body);
}

.newsletter-modal__consent input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.newsletter-modal__consent-box {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  margin-top: 1px;
  border: var(--border-width-thin) solid var(--border-strong);
  border-radius: var(--radius-xs);
  background: var(--bg-subtle);
  position: relative;
  transition:
    background var(--duration-fast) var(--ease-out),
    border-color var(--duration-fast) var(--ease-out);
}

.newsletter-modal__consent:hover .newsletter-modal__consent-box {
  border-color: var(--color-camel-500);
}

.newsletter-modal__consent input[type="checkbox"]:checked + .newsletter-modal__consent-box {
  background: var(--color-camel-500);
  border-color: var(--color-camel-500);
}

.newsletter-modal__consent input[type="checkbox"]:checked + .newsletter-modal__consent-box::after {
  content: "";
  position: absolute;
  left: 6px;
  top: 2px;
  width: 6px;
  height: 11px;
  border: solid var(--color-white);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.newsletter-modal__consent input[type="checkbox"]:focus-visible + .newsletter-modal__consent-box {
  box-shadow: var(--shadow-focus);
}

.newsletter-modal__consent.is-error .newsletter-modal__consent-box {
  border-color: var(--color-error);
}

.newsletter-modal__consent-text a {
  color: var(--color-camel-500);
  font-weight: var(--fw-semibold);
  text-decoration: underline;
}
.newsletter-modal__consent-text a:hover {
  color: var(--color-camel-600);
}

/* ----------------------------------------------------------------------------
   FEEDBACK GLOBAL (duplicado / error de red / etc.)
   ---------------------------------------------------------------------------- */
.newsletter-modal__feedback {
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  font-size: var(--fs-caption);
  line-height: var(--lh-snug);
  border-left: 3px solid currentColor;
}
.newsletter-modal__feedback.is-error {
  background: color-mix(in srgb, var(--color-error) 10%, transparent);
  color: var(--color-error);
}
.newsletter-modal__feedback.is-info {
  background: color-mix(in srgb, var(--color-info) 10%, transparent);
  color: var(--color-info);
}

/* ----------------------------------------------------------------------------
   BOTÓN SUBMIT
   ---------------------------------------------------------------------------- */
.newsletter-modal__submit {
  margin-top: var(--space-2);
}

.newsletter-modal__submit.is-loading {
  opacity: 0.7;
  cursor: wait;
  pointer-events: none;
  position: relative;
}
.newsletter-modal__submit.is-loading::after {
  content: "";
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-top-color: var(--color-white);
  border-radius: 50%;
  animation: newsletter-spin 0.8s linear infinite;
  margin-left: var(--space-2);
}
@keyframes newsletter-spin {
  to { transform: rotate(360deg); }
}

/* ----------------------------------------------------------------------------
   ESTADO DE ÉXITO
   ---------------------------------------------------------------------------- */
.newsletter-modal__success {
  text-align: center;
  padding: var(--space-6) 0;
}

.newsletter-modal__success-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 72px;
  height: 72px;
  margin: 0 auto var(--space-5);
  border-radius: var(--radius-circle);
  background: color-mix(in srgb, var(--color-success) 15%, transparent);
  color: var(--color-success);
}
.newsletter-modal__success-icon svg {
  width: 36px;
  height: 36px;
}

.newsletter-modal__success-title {
  font-size: var(--fs-h4);
  font-weight: var(--fw-bold);
  color: var(--text-primary);
  margin: 0 0 var(--space-2) 0;
  letter-spacing: var(--ls-snug);
}

.newsletter-modal__success-text {
  font-size: var(--fs-body-sm);
  color: var(--text-muted);
  line-height: var(--lh-relaxed);
  margin: 0;
}

/* ----------------------------------------------------------------------------
   ANIMACIONES
   ---------------------------------------------------------------------------- */
@keyframes newsletter-fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.newsletter-modal__success:not([hidden]) {
  animation: newsletter-fade-in var(--duration-base) var(--ease-out);
}

/* ----------------------------------------------------------------------------
   PREFERS-REDUCED-MOTION
   ---------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  .newsletter-modal,
  .newsletter-modal__dialog,
  .newsletter-modal__success:not([hidden]),
  .newsletter-modal__submit.is-loading::after {
    transition: none !important;
    animation: none !important;
  }

  .newsletter-modal__dialog {
    transform: none;
  }
  .newsletter-modal.is-open .newsletter-modal__dialog {
    transform: none;
  }
}

/* El atributo [hidden] debe ganar a cualquier display explícito */
.newsletter-modal__form[hidden],
.newsletter-modal__success[hidden],
.newsletter-modal__feedback[hidden],
.newsletter-modal__error[hidden] {
  display: none !important;
}