/* --np-accent is set inline from Settings → Accent color. */
.newsletter-plugin-form {
  --np-accent: #4f46e5;
  --np-accent-soft: color-mix(in srgb, var(--np-accent) 14%, transparent);
  --np-accent-hover: color-mix(in srgb, var(--np-accent) 85%, #000);
  --np-text: #0f172a;
  --np-muted: #64748b;
  --np-border: #e2e8f0;
  --np-field-bg: #fff;
  --np-radius: 12px;

  position: relative;
  box-sizing: border-box;
  max-width: 520px;
  container-type: inline-size;
  color: var(--np-text);
  font-size: 1rem;
  line-height: 1.5;
  scroll-margin-top: 80px;
}

.newsletter-plugin-form *,
.newsletter-plugin-form *::before,
.newsletter-plugin-form *::after {
  box-sizing: border-box;
}

/* Card: boxed with a soft accent glow at the top. */
.newsletter-plugin-form--card,
.newsletter-plugin-form--inline {
  padding: 2rem;
  background:
    radial-gradient(120% 60% at 0% 0%, var(--np-accent-soft), transparent 60%),
    #fff;
  border: 1px solid var(--np-border);
  border-radius: 20px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 12px 32px -12px rgba(15, 23, 42, 0.12);
}

.newsletter-plugin-form--inline {
  max-width: 640px;
  padding: 1.75rem;
}

/* Minimal: no box, inherits the theme's colors. */
.newsletter-plugin-form--minimal {
  --np-text: inherit;
  --np-field-bg: transparent;
  --np-border: color-mix(in srgb, currentColor 22%, transparent);
  --np-muted: color-mix(in srgb, currentColor 65%, transparent);
}

/* Heading */
.newsletter-plugin-head {
  margin-bottom: 1.25rem;
}

.newsletter-plugin-form .newsletter-plugin-head h3 {
  margin: 0;
  color: inherit;
  font-size: 1.375rem;
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -0.015em;
}

.newsletter-plugin-head p {
  margin: 0.4rem 0 0;
  color: var(--np-muted);
  font-size: 0.95rem;
}

/* Fields */
.newsletter-plugin-fields {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.875rem;
  margin-bottom: 1rem;
}

@container (min-width: 440px) {
  .newsletter-plugin-form--card .newsletter-plugin-fields,
  .newsletter-plugin-form--minimal .newsletter-plugin-fields {
    grid-template-columns: 1fr 1fr;
  }

  .newsletter-plugin-form--inline .newsletter-plugin-fields {
    grid-template-columns: 1fr auto;
    align-items: end;
  }
}

.newsletter-plugin-field label {
  display: block;
  margin-bottom: 0.375rem;
  font-size: 0.85rem;
  font-weight: 600;
}

.newsletter-plugin-optional {
  font-weight: 400;
  color: var(--np-muted);
}

.newsletter-plugin-form input[type="text"],
.newsletter-plugin-form input[type="email"] {
  display: block;
  width: 100%;
  min-height: 48px;
  margin: 0;
  padding: 0.75rem 0.95rem;
  color: inherit;
  font: inherit;
  background: var(--np-field-bg);
  border: 1px solid var(--np-border);
  border-radius: var(--np-radius);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.newsletter-plugin-form input::placeholder {
  color: var(--np-muted);
  opacity: 0.7;
}

.newsletter-plugin-form input[type="text"]:focus,
.newsletter-plugin-form input[type="email"]:focus {
  outline: none;
  border-color: var(--np-accent);
  box-shadow: 0 0 0 4px var(--np-accent-soft);
}

/* Consent */
.newsletter-plugin-consent {
  margin-bottom: 1.25rem;
}

.newsletter-plugin-consent label {
  display: flex;
  gap: 0.625rem;
  align-items: flex-start;
  color: var(--np-muted);
  font-size: 0.85rem;
  line-height: 1.45;
  cursor: pointer;
}

.newsletter-plugin-consent input {
  flex-shrink: 0;
  width: 1.05rem;
  height: 1.05rem;
  margin: 0.1rem 0 0;
  accent-color: var(--np-accent);
}

.newsletter-plugin-consent a {
  color: var(--np-accent);
}

/* Button */
.newsletter-plugin-form .newsletter-plugin-submit {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
  min-height: 48px;
  margin: 0;
  padding: 0.75rem 1.5rem;
  color: #fff;
  font: inherit;
  font-weight: 600;
  white-space: nowrap;
  background: var(--np-accent);
  border: 0;
  border-radius: var(--np-radius);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.1), 0 6px 16px -6px var(--np-accent);
  cursor: pointer;
  transition: background-color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}

.newsletter-plugin-form .newsletter-plugin-submit:hover {
  background: var(--np-accent-hover);
  transform: translateY(-1px);
}

.newsletter-plugin-form .newsletter-plugin-submit:focus-visible {
  outline: none;
  box-shadow: 0 0 0 4px var(--np-accent-soft);
}

.newsletter-plugin-submit svg {
  transition: transform 0.15s ease;
}

.newsletter-plugin-submit:hover svg {
  transform: translateX(3px);
}

@container (min-width: 440px) {
  .newsletter-plugin-form--inline .newsletter-plugin-submit {
    width: auto;
  }
}

/* Messages */
.newsletter-plugin-message {
  margin: 0 0 1rem;
  padding: 0.75rem 1rem;
  font-size: 0.9rem;
  font-weight: 500;
  border-radius: var(--np-radius);
}

.newsletter-plugin-message--error {
  color: #991b1b;
  background: #fef2f2;
  border: 1px solid #fecaca;
}

/* Success state replaces the form. */
.newsletter-plugin-done {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0;
  text-align: center;
  animation: newsletter-plugin-pop 0.35s ease-out;
}

.newsletter-plugin-done-icon {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  color: var(--np-accent);
  background: var(--np-accent-soft);
  border-radius: 50%;
}

.newsletter-plugin-done p {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
}

@keyframes newsletter-plugin-pop {
  from { opacity: 0; transform: translateY(6px) scale(0.98); }
  to { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  .newsletter-plugin-form *,
  .newsletter-plugin-done {
    animation: none !important;
    transition: none !important;
  }
}

/* Visually hidden but read by screen readers. */
.newsletter-plugin-sr {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  overflow: hidden !important;
  clip: rect(0 0 0 0) !important;
  white-space: nowrap !important;
}

/* Honeypot: hidden from people, visible to bots. */
.newsletter-plugin-hp {
  position: absolute !important;
  left: -9999px !important;
  width: 1px;
  height: 1px;
  overflow: hidden;
}
