/* ==========================================================================
   Newsletter popup
   --------------------------------------------------------------------------
   Enqueued by terrago_newsletter_popup_assets() in inc/newsletter.php, not by
   terrago_screen_stylesheets(). It is not a screen sheet: it loads on nearly
   every page and is gated on the Brevo constants rather than on a template.
   Do not add it to that helper's list — it has no marker class to key off,
   because the markup is appended to the footer rather than living in the
   page's content.

   Everything here is scoped under .terrago-nlpop. The popup sits above the
   page but BELOW the Complianz cookie banner on purpose: on a first EU visit
   both are on screen, and the banner is the one that has to be answerable
   first. That is also why the markup is a <div role="dialog"> and not a
   <dialog> — showModal() puts an element in the top layer, above everything,
   banner included.

   All colour comes from theme.json presets. Note the CLAUDE.md warning about
   `mint` and `mint-tint`: since the palette went warm those slugs hold sand
   and bone, so read them as "the tinted background", not as a colour.
   ========================================================================== */

.terrago-nlpop {
  position: fixed;
  inset: 0;
  z-index: 9000; /* Above the site's own sticky header; Complianz sits higher. */
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.24s ease, visibility 0.24s ease;
}

.terrago-nlpop.is-open {
  opacity: 1;
  visibility: visible;
}

/* `hidden` has to be stated: the rules above set `display: flex`, and a bare
   [hidden] is only `display: none` at the user-agent level, which any author
   `display` beats. Without this the dialog would be laid out and focusable
   before the script ever shows it. */
.terrago-nlpop[hidden] {
  display: none;
}

.terrago-nlpop__scrim {
  position: absolute;
  inset: 0;
  background: color-mix(in srgb, var(--wp--preset--color--base) 62%, transparent);
  cursor: pointer;
}

/* Lock the page behind the dialog. `overflow: hidden` on the root rather than
   on body, so iOS Safari honours it. */
.terrago-nlpop-open {
  overflow: hidden;
}

/* ------------------------------------------------------------------ card -- */

.terrago-nlpop__card {
  position: relative;
  width: 100%;
  max-width: 34rem;
  max-height: calc(100dvh - 2.5rem); /* 100vh on iOS is the LARGE viewport. */
  overflow-y: auto;
  padding: 2.75rem 2.5rem 2.25rem;
  border-radius: 20px; /* The site's media radius. */
  background: var(--wp--preset--color--mint-tint);
  box-shadow: 0 24px 60px rgba(43, 31, 23, 0.22);
  text-align: center;
  transform: translateY(14px) scale(0.985);
  transition: transform 0.28s cubic-bezier(0.2, 0.7, 0.3, 1);
}

.terrago-nlpop.is-open .terrago-nlpop__card {
  transform: none;
}

.terrago-nlpop__close {
  position: absolute;
  top: 0.85rem;
  right: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: center;
  /* 44px: the minimum comfortable touch target, and the size the mobile pass
     settled on for every other control on the site. */
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--wp--preset--color--muted);
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
  transition: background 0.18s ease, color 0.18s ease;
}

.terrago-nlpop__close:hover,
.terrago-nlpop__close:focus-visible {
  background: color-mix(in srgb, var(--wp--preset--color--primary) 10%, transparent);
  color: var(--wp--preset--color--base);
}

/* ------------------------------------------------------------------ copy -- */

/* The coral badge pill, same construction as .terrago-eyebrow: the pill is on
   an inner span so the <p> can stay a full-width block. */
.terrago-nlpop__eyebrow {
  margin: 0 0 1rem;
  font-size: var(--wp--preset--font-size--small);
  font-weight: 500;
}

.terrago-nlpop__eyebrow > span {
  display: inline-block;
  padding: 0.5rem 1.1rem;
  border-radius: 999px;
  background: color-mix(in srgb, var(--wp--preset--color--accent) 14%, transparent);
  color: var(--wp--preset--color--accent);
}

.terrago-nlpop__title {
  margin: 0 0 0.75rem;
  color: var(--wp--preset--color--base);
  font-family: var(--wp--preset--font-family--display);
  font-size: var(--wp--preset--font-size--x-large);
  font-weight: 600;
  line-height: 1.15;
}

/* The house treatment: the closing word in coral, upright rather than italic. */
.terrago-nlpop__title em {
  color: var(--wp--preset--color--accent);
  font-style: normal;
}

.terrago-nlpop__text {
  margin: 0 0 1.5rem;
  color: var(--wp--preset--color--muted);
  font-size: var(--wp--preset--font-size--base);
  line-height: 1.6;
}

/* ------------------------------------------------------------------ form -- */

.terrago-nlpop__form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin: 0;
}

.terrago-nlpop__form[hidden] {
  display: none;
}

.terrago-nlpop__email {
  width: 100%;
  /* 16px minimum, or iOS Safari zooms the whole page on focus. `base` is 19px,
     so the preset is already safe — stated here because a future tightening of
     the type scale would silently reintroduce the zoom. */
  padding: 0.9rem 1.2rem;
  border: 1px solid var(--wp--preset--color--border);
  border-radius: 999px;
  background: var(--wp--preset--color--contrast);
  color: var(--wp--preset--color--base);
  font-family: var(--wp--preset--font-family--body);
  font-size: var(--wp--preset--font-size--base);
}

.terrago-nlpop__email::placeholder {
  color: var(--wp--preset--color--muted-soft);
}

.terrago-nlpop__email:focus {
  border-color: var(--wp--preset--color--primary);
  outline: 2px solid var(--wp--preset--color--accent);
  outline-offset: 2px;
}

.terrago-nlpop__submit {
  width: 100%;
  padding: 0.9rem 1.5rem;
  border: 0;
  border-radius: 999px;
  background: var(--wp--preset--color--primary);
  color: var(--wp--preset--color--contrast);
  font-family: var(--wp--preset--font-family--body);
  font-size: var(--wp--preset--font-size--base);
  font-weight: 600;
  cursor: pointer;
  transition: background 0.18s ease;
}

/* Espresso on hover, not coral. Measured: white on coral is 2.74:1, which is
   below AA even for large text, where white on bark is 6.23:1. Coral is held
   to the header's "Book Now", the same rule the retreat page's buttons
   follow. */
.terrago-nlpop__submit:hover {
  background: var(--wp--preset--color--base);
}

.terrago-nlpop__submit:disabled {
  opacity: 0.6;
  cursor: default;
}

/* The honeypot. Off screen rather than display:none — a form-filling bot
   treats display:none as the tell it is, and skips the field. It stays out of
   the accessibility tree via aria-hidden and out of tab order via
   tabindex="-1", both set in the markup. */
.terrago-nlpop__hp {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

/* Visually hidden, still announced. The theme's own, because core's
   .screen-reader-text arrives with wp-block-library's common stylesheet and
   inc/performance.php is in the business of dropping core CSS. */
.terrago-nlpop__srt {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* --------------------------------------------------------------- message -- */

/* Empty until the script writes to it, and an empty live region announces
   nothing — so it must collapse rather than hold a line of blank space. */
.terrago-nlpop__message:empty {
  display: none;
}

.terrago-nlpop__message {
  margin: 0.9rem 0 0;
  font-size: var(--wp--preset--font-size--small);
  line-height: 1.5;
}

.terrago-nlpop__message.is-info {
  color: var(--wp--preset--color--muted);
}

/* Both states carry the site's own colours rather than a green and a red.
   Measured against the card's bone background AND against sand, since sand is
   the binding one in this palette: primary is 5.84:1 on bone and 5.00:1 on
   sand; the error red below is 5.59:1 and 4.78:1. Both clear AA on either. */
.terrago-nlpop__message.is-success {
  color: var(--wp--preset--color--primary);
  font-weight: 600;
}

.terrago-nlpop__message.is-error {
  /* A hardcoded hex, against the usual rule, because the palette has no red:
     accent is the coral badge colour and reads as 2.57:1 here. This is that
     coral darkened until it clears AA on both tinted backgrounds. Promote it
     to a theme.json preset if a second error state ever needs it. */
  color: #B23A25;
  font-weight: 600;
}

.terrago-nlpop__fine {
  margin: 1.1rem 0 0;
  color: var(--wp--preset--color--muted);
  font-size: var(--wp--preset--font-size--caption);
  line-height: 1.5;
}

.terrago-nlpop__fine a {
  color: inherit;
  text-underline-offset: 2px;
}

/* ------------------------------------------------------------- narrow -- */

@media (max-width: 600px) {
  .terrago-nlpop {
    /* Bottom sheet on a phone: a centred dialog fights the on-screen keyboard,
       which shrinks the viewport the moment the field takes focus. */
    align-items: flex-end;
    padding: 0;
  }

  .terrago-nlpop__card {
    max-width: none;
    max-height: 88dvh;
    padding: 2.5rem 1.5rem 1.75rem;
    border-radius: 20px 20px 0 0;
    transform: translateY(100%);
  }

  .terrago-nlpop__title {
    font-size: var(--wp--preset--font-size--large);
  }
}

/* ------------------------------------------------------ reduced motion -- */

/* No slide, no scale — but still a fade, so the dialog does not simply appear
   with no indication that anything changed. Reduced motion is not no motion. */
@media (prefers-reduced-motion: reduce) {
  .terrago-nlpop__card {
    transform: none;
    transition: none;
  }
}
