/* Newsletter sign-up form (site/snippets/newsletter-form.php,
   components/newsletter.js), under the news overview and in the menu.
   It takes the text colour of where it sits (black in the news, red in
   the menu); the button is the red .news-button (components/news.css). */

/* The field on its own line, the button below it. */
.newsletter-form__fields {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1.25rem;
}

/* A line to write on, like a form in the newspaper. */
.newsletter-form__input {
  width: 100%;
  padding: 0.6rem 0;
  border: 0;
  border-bottom: 1px solid currentColor;
  border-radius: 0;
  background: transparent;
  color: inherit;
  font: inherit;
}

.newsletter-form__input::placeholder {
  color: inherit;
  opacity: 0.55;
}

.newsletter-form__input:focus-visible {
  outline: none;
  border-bottom-color: var(--color-text-primary);
}

/* Right under the field: what the address is used for, and the privacy
   statement. Small and quiet, close to the field. */
.newsletter-form__privacy {
  margin-top: -0.9rem;
  font-size: 0.6875rem;
  line-height: 1.5;
  opacity: 0.6;
}

.newsletter-form__privacy a {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.newsletter-form__privacy a:hover {
  opacity: 1;
  color: var(--color-text-primary);
}

.newsletter-form[aria-busy='true'] .newsletter-form__button {
  opacity: 0.6;
  cursor: progress;
}

/* ---------- A problem ---------- */

/* Only there when something went wrong: a red warning icon and the
   message on a light red background, right under the field (which turns
   red too). Typing again clears it (components/newsletter.js). */
.newsletter-form__error {
  display: none;
  align-items: flex-start;
  gap: 0.6rem;
  width: 100%;
  margin-top: -0.5rem;
  padding: 0.65rem 0.8rem;
  background: color-mix(in srgb, var(--color-text-primary) 8%, transparent);
  border-left: 3px solid var(--color-text-primary);
  color: var(--color-text-primary);
  font-size: 0.875rem;
  line-height: 1.45;
}

.newsletter-form.has-error .newsletter-form__error {
  display: flex;
}

.newsletter-form__error svg {
  flex-shrink: 0;
  margin-top: 0.05rem;
}

.newsletter-form.has-error .newsletter-form__input {
  border-bottom-color: var(--color-text-primary);
}

/* ---------- Signed up ---------- */

/* Always in the page (it's the live region screen readers listen to);
   empty until someone has signed up. */
.newsletter-form__result {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
}

.newsletter-form__lead:empty,
.newsletter-form__message:empty,
.newsletter-form__check {
  display: none;
}

/* Signed up: the field makes way for a check mark, a heading and the
   message -- clearly different from the block's own title and text. */
.newsletter-form.is-done .newsletter-form__fields {
  display: none;
}

.newsletter-form.is-done .newsletter-form__result {
  padding: 1.25rem;
  border: 2px solid var(--color-text-primary);
  animation: newsletter-done 0.5s var(--ease-enter);
}

.newsletter-form.is-done .newsletter-form__check {
  display: block;
  flex-shrink: 0;
  color: var(--color-text-primary);
}

.newsletter-form__lead {
  font-size: 1.5rem;
  line-height: 1.15;
  color: var(--color-text-primary);
}

.newsletter-form.is-done .newsletter-form__message {
  margin-top: 0.5rem;
  font-size: 0.875rem;
  line-height: 1.6;
  color: inherit;
}

@keyframes newsletter-done {
  from { opacity: 0; }
  to { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .newsletter-form.is-done .newsletter-form__result {
    animation: none;
  }
}

/* Spam trap: off screen, not just invisible, so bots still "see" it. */
.newsletter-form__trap {
  position: absolute;
  left: -10000px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

/* ---------- In the menu (site/snippets/nav.php) ---------- */

/* Smaller than the menu's 1.25rem text, with room for the focus ring. */
.nav-newsletter {
  font-size: 1rem;
  margin-top: 1rem;
  padding-bottom: 0.25rem;
}

/* Red text gets too pale to read at the news block's 60%. */
.nav-newsletter .newsletter-form__privacy {
  opacity: 0.85;
}

.nav-newsletter .newsletter-form__lead {
  font-size: 1.25rem;
}
