/* components/newsletter-signup.css — layout for partials/newsletter-signup.hbs,
   on the homepage or pasted into an article as a snippet. A column that
   centres its pitch and keeps the form at the foot.
   The headline always uses the default (sans) voice, even inside an
   article whose editorial voice switched --font-heading to the serif.
   .loading/.success/.error are Ghost's classes on the <form>;
   [data-invalid] is assets/js/newsletter-choices.js's (nothing ticked).
   The newsletter toggles are partials/newsletter-choices.hbs, styled in
   components/newsletter-choices.css. */

.newsletter-signup {
  --font-heading: var(--font-heading-default);
  --weight-heading: var(--weight-heading-default);

  display: flex;
  flex-direction: column;
  gap: var(--space-10);
  padding: var(--space-6);
  border: var(--border-width) solid var(--color-border-soft);
  text-align: center;
}

@media (width >= 48rem) {
  .newsletter-signup {
    padding: var(--space-10);
  }
}

/* Auto margins centre the pitch in any spare height. */
.newsletter-signup__intro {
  display: grid;
  justify-items: center;
  gap: var(--space-3);
  margin-block: auto;
}

/* max-inline-size breaks the headline over two lines, as in the design. */
.newsletter-signup__title {
  max-inline-size: 14em;
  margin: 0;
  font-family: var(--font-heading);
  font-size: var(--text-3xl);
  font-weight: var(--weight-heading);
  line-height: var(--leading-tight);
  letter-spacing: var(--tracking-snug);
  text-wrap: balance;
}

/* The design's 36px from --bp-md; too big on a phone. */
@media (width >= 48rem) {
  .newsletter-signup__title {
    font-size: var(--newsletter-signup-title-size);
  }
}

.newsletter-signup__text {
  max-inline-size: 20em;
  margin: 0;
  font-family: var(--font-body);
  font-size: var(--text-lg);
  line-height: var(--leading-snug);
  text-wrap: balance;
}

/* Signed in: "Your account" — name and email, then the two links, all
   centred under the heading; the plan sits at the foot. */

.newsletter-signup__profile {
  display: grid;
  gap: var(--space-1);
  margin-block-start: var(--space-6);
}

.newsletter-signup__name,
.newsletter-signup__email,
.newsletter-signup__plan-label,
.newsletter-signup__plan-name {
  margin: 0;
  font-family: var(--font-ui);
  line-height: var(--leading-snug);
}

.newsletter-signup__name {
  color: var(--color-fg);
  font-size: var(--text-lg);
  font-weight: var(--weight-medium);
}

.newsletter-signup__email {
  color: var(--color-fg-muted);
  font-size: var(--text-sm);
}

.newsletter-signup__links {
  display: grid;
  justify-items: center;
  gap: var(--space-2);
  margin: var(--space-6) 0 0;
  padding: 0;
  list-style: none;
}

/* The plan: its own section at the foot of the box, where visitors get the
   form. Plan left, Update Plan right; the button wraps under on a phone. */
.newsletter-signup__plan {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding-block-start: var(--space-6);
  border-block-start: var(--border-width) solid var(--color-border-soft);
  text-align: start;
}

.newsletter-signup__plan-detail {
  display: grid;
  gap: var(--space-1);
}

.newsletter-signup__plan-label {
  color: var(--color-fg-muted);
  font-size: var(--text-sm);
}

.newsletter-signup__plan-name {
  color: var(--color-fg);
  font-size: var(--text-base);
  font-weight: var(--weight-medium);
}

/* The form */

.newsletter-signup__form {
  display: grid;
  gap: var(--space-3);
}

/* The button matches the field's height; centred once it wraps on a phone. */
.newsletter-signup__row {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  justify-content: center;
  gap: var(--space-4);
}

/* The field takes the remaining width and can shrink below its intrinsic size. */
.newsletter-signup__field {
  display: flex;
  flex: 1 1 12rem;
  min-width: 0;
}

.newsletter-signup__input {
  flex: 1;
  min-width: 0;
  padding: var(--space-2) var(--space-4);
  border: var(--border-width) solid var(--color-border-soft);
  background-color: transparent;
  font: inherit;
  font-family: var(--font-ui);
  font-size: var(--text-base);
  color: inherit;
  text-align: start;
}

.newsletter-signup__form.loading .button {
  opacity: var(--card-hover-opacity);
  pointer-events: none;
}

.newsletter-signup__message {
  margin: 0;
  font-family: var(--font-ui);
  font-size: var(--text-sm);
  line-height: var(--leading-snug);
}

/* Left, under the left-aligned checkboxes (homepage); the snippet, which
   has none, keeps them centred. */
.newsletter-choices ~ .newsletter-signup__message {
  text-align: start;
}

/* The error <p>s are empty until Ghost or newsletter-choices.js writes in. */
.newsletter-signup__message--success,
.newsletter-signup__message:empty {
  display: none;
}

.newsletter-signup__message--error,
.newsletter-signup__message--required {
  color: var(--color-danger);
}

.newsletter-signup__form.success :is(.newsletter-signup__row, .newsletter-choices) {
  display: none;
}

.newsletter-signup__form.success .newsletter-signup__message--success {
  display: block;
}

/* Text-and-arrow links: "Explore all our newsletters" under the form (left,
   like the checkboxes), and a member's "Edit profile" / "Email settings"
   (centred by .newsletter-signup__links). */
.newsletter-signup__more {
  display: inline-flex;
  align-items: center;
  align-self: flex-start;
  gap: var(--space-2);
  font-family: var(--font-ui);
  font-size: var(--text-sm);
  text-decoration: none;
}

/* The arrow: a mask over currentColor, as on .section-header__link. */
.newsletter-signup__more::after {
  content: "";
  inline-size: var(--icon-arrow-size);
  aspect-ratio: 13 / 12;
  flex-shrink: 0;
  background-color: currentColor;
  -webkit-mask: var(--icon-arrow) no-repeat center / contain;
  mask: var(--icon-arrow) no-repeat center / contain;
}

/* As an article snippet: extra spacing, and hidden from members (a static
   snippet can't branch on @member, so [data-member] on <body> does it). */

.post-content > .newsletter-signup {
  margin-block: var(--space-12);
}

:is([data-member="free"], [data-member="paid"]) .post-content > .newsletter-signup {
  display: none;
}
