/* GOOD CHIPS — newsletter popup.
   Colours resolve from the section's own settings first and fall back to the
   global --gc-* tokens emitted by components/theme-css-var.html, so the popup
   still looks right if a merchant clears a colour in the editor. */

/* The popup renders on templates that never load gc-base.css, so it carries its
   own box model rather than assuming a global border-box reset. */
.gc-news,
.gc-news *,
.gc-news *::before,
.gc-news *::after {
  box-sizing: border-box;
}

.gc-news {
  --gc-news-card-fallback: rgb(var(--gc-cream-rgb, 241, 235, 217));
  --gc-news-radius: 26px;

  position: fixed;
  z-index: 1500;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  visibility: hidden;
  opacity: 0;
  background: var(--gc-news-backdrop, rgba(63, 58, 44, 0.55));
  backdrop-filter: blur(2px);
  transition: opacity 0.32s ease, visibility 0.32s;
}

.gc-news.is-open {
  visibility: visible;
  opacity: 1;
}

.gc-news-backdrop {
  position: absolute;
  inset: 0;
}

/* Self-contained rather than reusing .sr-only: that class lives in gc-base.css,
   which only loads on GOOD CHIPS story pages, and this popup runs sitewide. */
.gc-news-visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  border: 0;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

.gc-news-dialog {
  position: relative;
  box-sizing: border-box;
  width: min(94vw, 600px);
  max-height: min(92svh, 760px);
  overflow-y: auto;
  padding: clamp(38px, 4.4vw, 58px) clamp(26px, 3.6vw, 52px) clamp(26px, 3vw, 36px);
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: var(--gc-news-radius);
  background: var(--gc-news-card, var(--gc-news-card-fallback));
  box-shadow: 0 34px 90px rgba(38, 31, 18, 0.34), inset 0 1px rgba(255, 255, 255, 0.9);
  text-align: center;
  transform: translateY(16px) scale(0.98);
  transition: transform 0.34s cubic-bezier(0.22, 1, 0.36, 1);
}

.gc-news.is-open .gc-news-dialog {
  transform: none;
}

/* ---- close ---- */

.gc-news-close {
  position: absolute;
  top: clamp(14px, 1.6vw, 22px);
  right: clamp(14px, 1.6vw, 22px);
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--gc-ink, #1c1c1c);
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
}

.gc-news-close svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentcolor;
  stroke-width: 1.7;
  stroke-linecap: round;
}

.gc-news-close:hover {
  background: rgba(var(--gc-ink-rgb, 28, 28, 28), 0.07);
  color: var(--gc-news-accent, var(--gc-teal, #0e6e8b));
}

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

.gc-news-eyebrow {
  margin: 0 0 clamp(10px, 1.2vw, 16px);
  color: var(--gc-news-eyebrow, var(--gc-cheddar, #c8941f));
  font: 700 calc(12px * var(--gc-type-scale, 1)) / 1.2 var(--gc-sans, sans-serif);
  letter-spacing: 0.22em;
  text-transform: uppercase;
}

.gc-news-title {
  margin: 0 0 clamp(14px, 1.6vw, 20px);
  color: var(--gc-ink, #1c1c1c);
  font: 400 calc(clamp(38px, 5.4vw, 58px) * var(--gc-type-scale, 1)) / 1.02
    var(--gc-display, Georgia, serif);
  letter-spacing: -0.005em;
  text-transform: none;
  word-break: normal;
}

.gc-news-title strong {
  font-weight: 700;
}

/* Keeps the highlighted word and the words after it on one line, so the
   headline breaks as "Stay in the / GOOD loop." rather than orphaning the tail.
   Released on narrow screens where the line genuinely will not fit. */
.gc-news-title-tail {
  white-space: nowrap;
}

.gc-news-copy {
  max-width: 34ch;
  margin: 0 auto clamp(20px, 2.4vw, 28px);
  color: var(--gc-body-color, #444);
  font: 400 calc(clamp(15px, 1.15vw, 17px) * var(--gc-type-scale, 1)) / 1.5
    var(--gc-sans, sans-serif);
}

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

/* The form element itself is emitted by the platform's customer_form helper,
   so it is addressed through the wrapper rather than by a class of ours. */
.gc-news-form-wrap form {
  display: grid;
  gap: 14px;
  margin: 0;
  text-align: left;
}

.gc-news-field {
  display: block;
}

.gc-news-input {
  box-sizing: border-box;
  width: 100%;
  padding: 18px 20px;
  border: 2px solid var(--gc-news-accent, var(--gc-teal, #0e6e8b));
  border-radius: 12px;
  outline: 0;
  background: rgba(255, 255, 255, 0.42);
  color: var(--gc-ink, #1c1c1c);
  font: 400 calc(16px * var(--gc-type-scale, 1)) / 1.2 var(--gc-sans, sans-serif);
  transition: box-shadow 0.2s ease, background 0.2s ease;
  appearance: none;
}

.gc-news-input::placeholder {
  color: rgba(var(--gc-ink-rgb, 28, 28, 28), 0.45);
}

.gc-news-input:focus {
  background: rgba(255, 255, 255, 0.75);
  box-shadow: 0 0 0 4px rgba(var(--gc-teal-rgb, 14, 110, 139), 0.16);
}

.gc-news-input:user-invalid {
  border-color: #c0392b;
}

.gc-news-submit {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 19px 22px;
  border: 2px solid var(--gc-news-accent, var(--gc-teal, #0e6e8b));
  border-radius: 12px;
  background: var(--gc-news-accent, var(--gc-teal, #0e6e8b));
  color: #fff;
  cursor: pointer;
  font: 700 calc(14px * var(--gc-type-scale, 1)) / 1 var(--gc-sans, sans-serif);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  transition: filter 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

.gc-news-submit:hover {
  box-shadow: 0 14px 30px rgba(var(--gc-teal-rgb, 14, 110, 139), 0.28);
  filter: brightness(1.08);
  transform: translateY(-1px);
}

.gc-news-submit:active {
  transform: translateY(0);
}

.gc-news-submit[disabled] {
  cursor: progress;
  opacity: 0.66;
  transform: none;
  box-shadow: none;
}

.gc-news-submit-arrow {
  flex: 0 0 auto;
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentcolor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform 0.2s ease;
}

.gc-news-submit:hover .gc-news-submit-arrow {
  transform: translateX(4px);
}

/* ---- status + fine print ---- */

.gc-news-status {
  margin: 2px 0 0;
  color: var(--gc-news-accent, var(--gc-teal, #0e6e8b));
  font: 500 calc(14px * var(--gc-type-scale, 1)) / 1.45 var(--gc-sans, sans-serif);
  text-align: center;
}

.gc-news-status--error {
  color: #c0392b;
}

.gc-news-fine-print {
  margin: clamp(16px, 1.8vw, 22px) 0 0;
  color: var(--gc-body-color, #444);
  font: 400 calc(14px * var(--gc-type-scale, 1)) / 1.4 var(--gc-sans, sans-serif);
  text-align: center;
}

.gc-news-heart {
  margin: 8px 0 0;
  color: var(--gc-news-eyebrow, var(--gc-cheddar, #c8941f));
  font-size: calc(14px * var(--gc-type-scale, 1));
  line-height: 1;
  text-align: center;
}

/* Between the click and the page coming back, the button reads as busy. */
.gc-news.is-sending .gc-news-submit {
  cursor: progress;
  opacity: 0.7;
}

.gc-news.is-sending .gc-news-submit-arrow {
  animation: gc-news-nudge 0.9s ease-in-out infinite;
}

@keyframes gc-news-nudge {
  0%,
  100% {
    transform: translateX(0);
  }

  50% {
    transform: translateX(5px);
  }
}

/* The thank-you state swaps the form out for the message alone. */
.gc-news.is-subscribed .gc-news-field,
.gc-news.is-subscribed .gc-news-submit {
  display: none;
}

.gc-news.is-subscribed .gc-news-status--success {
  margin-top: 6px;
  font-size: calc(17px * var(--gc-type-scale, 1));
}

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

@media (max-width: 599px) {
  .gc-news {
    padding: 14px;
  }

  .gc-news-dialog {
    width: 100%;
    max-height: calc(100svh - 28px);
    padding: 54px 20px 24px;
    border-radius: 20px;
  }

  .gc-news-title {
    font-size: calc(clamp(32px, 10.5vw, 44px) * var(--gc-type-scale, 1));
  }

  .gc-news-title-tail {
    white-space: normal;
  }

  .gc-news-input,
  .gc-news-submit {
    padding: 16px 18px;
  }

  /* iOS zooms the page when a focused field is under 16px. */
  .gc-news-input {
    font-size: max(16px, calc(16px * var(--gc-type-scale, 1)));
  }
}

@media (prefers-reduced-motion: reduce) {
  .gc-news,
  .gc-news-dialog,
  .gc-news-submit,
  .gc-news-submit-arrow {
    transition: none;
  }

  .gc-news.is-sending .gc-news-submit-arrow {
    animation: none;
  }

  .gc-news-dialog {
    transform: none;
  }
}
