/* components/newsletter-page.css — layout for page-newsletters.hbs's visitor
   form and partials/newsletter-option.hbs: centred pitch and email row, then
   the newsletters 1 / 2 / 3 up with rules between.
   (The signed-in view: components/email-preferences.css.)
   Toggles: the checkbox is .sr-only but focusable; its <label> is the
   control, showing a plus or a check. Column rules are a ::before in the
   gutter, restated per breakpoint (as in membership.css).
   Form state: Ghost's .loading/.success; data-invalid from
   assets/js/newsletter-choices.js. */

/* Hero */

.newsletter-page__hero {
  display: grid;
  justify-items: center;
  gap: var(--space-4);
  padding-block: var(--space-16);
  text-align: center;
}

/* max-inline-size breaks the headline over two lines, as in the design. */
.newsletter-page__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;
}

/* Same size as the signup box's headline; too big on a phone. */
@media (width >= 48rem) {
  .newsletter-page__title {
    font-size: var(--newsletter-signup-title-size);
  }
}

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

/* The button matches the field's height; centred once it wraps on a phone. */
.newsletter-page__row {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  justify-content: center;
  gap: var(--space-4);
  inline-size: 100%;
  max-inline-size: 26rem;
  margin-block-start: var(--space-8);
}

.newsletter-page__field {
  display: flex;
  flex: 1 1 12rem;
  min-width: 0;
}

.newsletter-page__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-page__form.loading .newsletter-page__row .button {
  opacity: var(--card-hover-opacity);
  pointer-events: none;
}

/* Messages */

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

/* Every message but success is empty until Ghost or the JS writes into it. */
.newsletter-page__message--success,
.newsletter-page__message:empty {
  display: none;
}

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

.newsletter-page__form.success .newsletter-page__row {
  display: none;
}

.newsletter-page__form.success .newsletter-page__message--success {
  display: block;
}

/* The six newsletters */

.newsletter-page__choices {
  padding-block-end: var(--space-16);
}

.newsletter-page__options {
  min-inline-size: 0;
  margin: 0;
  padding: 0;
  border: 0;
  border-block-start: var(--border-width) solid var(--color-border-soft);
}

.newsletter-page__grid {
  display: grid;
  column-gap: var(--space-10);
}

.newsletter-option {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
  padding-block: var(--space-8);
}

/* Each row after the first gets a rule across its cards, not the gutter. */
.newsletter-page__grid > .newsletter-option + .newsletter-option {
  border-block-start: var(--border-width) solid var(--color-border-soft);
}

/* The column rule, switched on per breakpoint by setting content. Inset by
   the card's padding, so it spans the content and stops short of the rows'
   rules, as in the design. */
.newsletter-page__grid > .newsletter-option::before {
  position: absolute;
  inset-block: var(--space-8);
  inset-inline-start: calc(var(--space-10) / -2);
  border-inline-start: var(--border-width) solid var(--color-border-soft);
}

@media (width >= 48rem) {
  .newsletter-page__grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .newsletter-page__grid > .newsletter-option:nth-child(2) {
    border-block-start: none;
  }

  .newsletter-page__grid > .newsletter-option:nth-child(2n)::before {
    content: "";
  }
}

@media (width >= 64rem) {
  .newsletter-page__grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .newsletter-page__grid > .newsletter-option:nth-child(3) {
    border-block-start: none;
  }

  .newsletter-page__grid > .newsletter-option:nth-child(2n)::before {
    content: none;
  }

  .newsletter-page__grid > .newsletter-option:not(:nth-child(3n + 1))::before {
    content: "";
  }
}

/* One newsletter */

.newsletter-option__name {
  margin: 0;
  font-family: var(--font-heading);
  font-size: var(--text-2xl);
  font-weight: var(--weight-heading);
  line-height: var(--leading-tight);
  letter-spacing: var(--tracking-snug);
}

.newsletter-option__description {
  margin: 0;
  font-family: var(--font-body);
  font-size: var(--text-lg);
  line-height: var(--leading-snug);
}

/* Pinned to the bottom so Read Preview and the toggles line up across a row. */
.newsletter-option__footer {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  margin-block-start: auto;
  padding-block-start: var(--space-6);
}

.newsletter-option__preview {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
  color: var(--color-fg-muted);
  font-family: var(--font-ui);
  font-size: var(--text-base);
  line-height: var(--leading-snug);
  text-decoration: none;
  transition: color var(--transition);
}

.newsletter-option__preview:hover {
  color: var(--color-fg);
}

/* The arrow: a mask over currentColor, as on .section-header__link. */
.newsletter-option__preview::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;
}

/* The box itself is .check-toggle (components/check-toggle.css). Auto margin
   keeps it right-aligned when there's no Read Preview link. */
.newsletter-option__toggle {
  margin-inline-start: auto;
}

.newsletter-page__form[data-invalid] .newsletter-page__options .newsletter-option__toggle {
  border-color: var(--color-danger);
}

/* Page body below the options; collapses when empty. */

.newsletter-page__body {
  padding-block-end: var(--space-16);
}

.newsletter-page__body:empty {
  display: none;
}
