/*
 * The Notify Me block (src/Blocks/NotifyMe.php), as the boards Demo-*-Product-Notify draw it (tools/mockups/src/notify.ts):
 * a `radius.panel` panel on `surface` in the place of Add to cart, 20px in and 14px apart. The heading in `md` bold
 * and a line in `sm` `muted`; the email field with its label floating inside, 54px high, beside the button in the
 * primary colour, the form's main action; under 400px of panel (a phone, the buybox page's panel) the button stands
 * under the field across the panel. A bad address is said under the field in `sale`; too many requests and a lost
 * connection under the row with an icon, no red ring. Then how the address is used, in `xs` `muted`. The outcome
 * takes the form's place: a round mark (a check on `success`, an envelope on `info` while the address waits for its
 * confirmation), the sentence and Use another address as a text link. The hidden field for bots is off screen.
 */
.wp-block-lanternwp-notify-me {
  container-type: inline-size;
  flex: 1 1 100%;
  box-sizing: border-box;
  min-width: 0;
  padding: calc(var(--wp--preset--spacing--40) + var(--wp--preset--spacing--10));
  border-radius: var(--wp--custom--radius--panel);
  background: var(--wp--preset--color--surface);
  color: var(--wp--preset--color--contrast);
  font-size: var(--wp--preset--font-size--sm);
  line-height: 1.45;

  & p {
    margin: 0;
  }

  & svg {
    fill: none;
    stroke: currentcolor;
    stroke-width: 1.75;
    stroke-linecap: round;
    stroke-linejoin: round;
  }
}

.lanternwp-notify-me__form {
  display: flex;
  flex-direction: column;
  gap: var(--wp--preset--spacing--30);

  &[hidden] {
    display: none;
  }
}

.lanternwp-notify-me__head {
  display: flex;
  flex-direction: column;
  gap: var(--wp--preset--spacing--10);
}

.lanternwp-notify-me__heading {
  font-size: var(--wp--preset--font-size--md);
  font-weight: var(--wp--custom--weight--bold);
  line-height: var(--wp--custom--line-height--snug);
}

.lanternwp-notify-me__lead,
.lanternwp-notify-me__note,
.lanternwp-notify-me__hint {
  color: var(--wp--preset--color--muted);
}

.lanternwp-notify-me__row {
  display: flex;
  align-items: flex-start;
  gap: var(--wp--preset--spacing--20);

  @container (width < 25rem) {
    flex-direction: column;
    align-items: stretch;
  }
}

/* The field, its label inside it: in the middle while empty, small at the top once it has a value or the focus. */
.lanternwp-notify-me__field {
  position: relative;
  display: flex;
  flex: 1 1 0;
  flex-direction: column;
  gap: var(--wp--preset--spacing--10);
  min-width: 0;

  & input[type='email'] {
    box-sizing: border-box;
    width: 100%;
    height: 3.375rem;
    padding: calc(var(--wp--preset--spacing--40) + var(--wp--preset--spacing--10)) var(--wp--preset--spacing--40)
      var(--wp--preset--spacing--10);
    border: 1px solid var(--wp--preset--color--border-strong);
    border-radius: var(--wp--custom--radius--field);
    background: var(--wp--preset--color--base);
    color: var(--wp--preset--color--contrast);
    font: inherit;
    font-size: var(--wp--preset--font-size--base);
    transition: border-color var(--wp--custom--motion--fast) var(--wp--custom--motion--easing);

    &:hover,
    &:focus {
      border-color: var(--wp--preset--color--contrast);
    }

    &:focus {
      outline: none;
      box-shadow: 0 0 0 1px var(--wp--preset--color--contrast);
    }

    &:read-only {
      border-color: var(--wp--preset--color--border-subtle);
      background: var(--wp--preset--color--surface);
      color: var(--wp--custom--color--disabled);
    }

    &[aria-invalid='true'] {
      border-color: var(--wp--preset--color--sale);
      box-shadow: 0 0 0 1px var(--wp--preset--color--sale);
    }
  }

  & label {
    position: absolute;
    top: 1.6875rem;
    left: 1rem;
    max-width: calc(100% - 2rem);
    overflow: hidden;
    color: var(--wp--preset--color--muted);
    font-size: var(--wp--preset--font-size--base);
    line-height: 1;
    white-space: nowrap;
    text-overflow: ellipsis;
    pointer-events: none;
    transform: translateY(-50%);
    transition:
      top var(--wp--custom--motion--fast) var(--wp--custom--motion--easing),
      font-size var(--wp--custom--motion--fast) var(--wp--custom--motion--easing);
  }

  & input:focus + label,
  & input:not(:placeholder-shown) + label {
    top: 0.875rem;
    font-size: var(--wp--preset--font-size--2-xs);
  }

  & input[aria-invalid='true'] + label {
    color: var(--wp--preset--color--sale);
  }
}

.lanternwp-notify-me__hint,
.lanternwp-notify-me__error {
  font-size: var(--wp--preset--font-size--xs);
  line-height: 1.4;

  &[hidden] {
    display: none;
  }
}

.lanternwp-notify-me__error {
  display: flex;
  align-items: center;
  gap: var(--wp--preset--spacing--10);
  color: var(--wp--preset--color--sale);
}

.lanternwp-notify-me__icon {
  flex-shrink: 0;
  width: 1rem;
  height: 1rem;
}

.lanternwp-notify-me__button {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  gap: var(--wp--preset--spacing--20);
  box-sizing: border-box;
  min-height: 3.375rem;
  padding-inline: var(--wp--preset--spacing--50);
  border: 1px solid var(--wp--preset--color--primary);
  border-radius: var(--wp--custom--radius--control);
  background: var(--wp--preset--color--primary);
  color: var(--wp--preset--color--on-primary);
  font: inherit;
  font-size: var(--wp--preset--font-size--md);
  font-weight: var(--wp--custom--weight--semibold);
  line-height: 1.2;
  white-space: nowrap;
  cursor: pointer;

  &:focus-visible {
    outline: 2px solid var(--wp--preset--color--accent);
    outline-offset: 2px;
  }

  &[aria-disabled='true'] {
    cursor: progress;
  }

  @container (width < 25rem) {
    width: 100%;
  }
}

.lanternwp-notify-me__spinner {
  display: none;
  box-sizing: border-box;
  width: 1rem;
  height: 1rem;
  border: 2px solid currentcolor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: lanternwp-notify-spin 0.8s linear infinite;

  .is-sending & {
    display: inline-block;
  }

  @media (prefers-reduced-motion: reduce) {
    animation-duration: 2.4s;
  }
}

.is-sending .lanternwp-notify-me__label {
  opacity: 0.8;
}

@keyframes lanternwp-notify-spin {
  to {
    transform: rotate(1turn);
  }
}

/* Too many requests (a clock in `warning`) and a lost connection (an alert in `sale`), under the row. */
.lanternwp-notify-me__failure {
  display: none;
  align-items: flex-start;
  gap: var(--wp--preset--spacing--20);

  &.is-shown {
    display: flex;
  }

  & .lanternwp-notify-me__icon {
    width: 1.125rem;
    height: 1.125rem;
    color: var(--wp--preset--color--sale);
  }

  & .lanternwp-notify-me__icon--clock {
    color: var(--wp--preset--color--warning);
  }

  &:not([data-kind='limit']) .lanternwp-notify-me__icon--clock,
  &[data-kind='limit'] .lanternwp-notify-me__icon:not(.lanternwp-notify-me__icon--clock) {
    display: none;
  }
}

.lanternwp-notify-me__website {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  overflow: hidden;
  clip-path: inset(50%);
}

/* Turnstile's check, invisible until Cloudflare asks for a challenge. */
.lanternwp-notify-me__check-box:empty {
  display: none;
}

.lanternwp-notify-me__note {
  font-size: var(--wp--preset--font-size--xs);

  & a {
    color: inherit;
  }
}

.lanternwp-notify-me__done {
  display: flex;
  align-items: flex-start;
  gap: var(--wp--preset--spacing--30);

  &[hidden] {
    display: none;
  }

  &:focus {
    outline: none;
  }

  &:focus-visible {
    outline: 2px solid var(--wp--preset--color--accent);
    outline-offset: 4px;
  }
}

.lanternwp-notify-me__mark {
  display: inline-flex;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 50%;
  background: color-mix(in srgb, var(--wp--preset--color--success) 14%, transparent);
  color: var(--wp--preset--color--success);

  & svg {
    width: 1.25rem;
    height: 1.25rem;
    stroke-width: 2;
  }

  & .lanternwp-notify-me__mail {
    display: none;
  }

  [data-kind='inbox'] & {
    background: color-mix(in srgb, var(--wp--preset--color--info) 14%, transparent);
    color: var(--wp--preset--color--info);

    & .lanternwp-notify-me__check {
      display: none;
    }

    & .lanternwp-notify-me__mail {
      display: inline;
    }
  }
}

.lanternwp-notify-me__outcome {
  display: flex;
  flex-direction: column;
  gap: var(--wp--preset--spacing--20);
  min-width: 0;
  padding-top: var(--wp--preset--spacing--20);
  overflow-wrap: anywhere;
}

.lanternwp-notify-me__line {
  font-size: var(--wp--preset--font-size--base);

  [data-kind='inbox'] & {
    font-size: var(--wp--preset--font-size--sm);
  }
}

.lanternwp-notify-me__title {
  font-size: var(--wp--preset--font-size--md);
  font-weight: var(--wp--custom--weight--bold);
}

.lanternwp-notify-me__expiry {
  color: var(--wp--preset--color--muted);
  font-size: var(--wp--preset--font-size--xs);
}

.lanternwp-notify-me__again {
  align-self: flex-start;
  padding: 0;
  border: 0;
  background: none;
  color: var(--wp--preset--color--contrast);
  font: inherit;
  font-size: var(--wp--preset--font-size--sm);
  font-weight: var(--wp--custom--weight--semibold);
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}
