/* vtw-email-capture.css */
/* VendTheWeb Section Library — vendtheweb.com */
/* Version: 1.0.0 */

/* ── Variable resolution ─────────────────────────────── */
.vtw-email-capture {
  --_bg:           var(--vtw-section-bg-override,
                   var(--vtw-section-bg,     var(--vtw-brand-bg,     #f0ede8)));
  --_text:         var(--vtw-section-text,   var(--vtw-brand-text,   #1a1a1a));
  --_accent:       var(--vtw-section-accent, var(--vtw-brand-accent, #5c6b3a));
  --_accent-text:  var(--vtw-section-accent-text,
                   var(--vtw-brand-accent-text, #ffffff));
  --_heading-font: var(--vtw-section-heading-font,
                   var(--vtw-brand-heading-font, Georgia, serif));
  --_body-font:    var(--vtw-section-body-font,
                   var(--vtw-brand-body-font, 'Assistant', Georgia, serif));
  --_padding:      var(--vtw-section-padding,
                   var(--vtw-brand-section-padding, 60px));
  --_gap:          var(--vtw-brand-element-gap, 24px);
  --_radius:       var(--vtw-brand-radius-md, 8px);
  --_input-radius:  var(--vtw-brand-input-radius, var(--_radius));
  --_button-radius: var(--vtw-brand-button-radius, var(--_radius));
  --_max-width:    var(--vtw-brand-container-width, 1280px);
  --_speed:        var(--vtw-brand-speed, 250ms);
  --_border:       var(--vtw-brand-border, #e8e3dc);
  --_surface:      var(--vtw-brand-surface, #f0ede8);

  /* Input tokens — their own chain so they stay readable even when --_text
     is inverted (e.g. white text over background image). Defaults guarantee
     an opaque field with dark text regardless of section mode. */
  --_input-bg:     var(--vtw-section-input-bg,     #ffffff);
  --_input-text:   var(--vtw-section-input-text,   #1a1a1a);
  --_input-border: var(--vtw-section-input-border, var(--_border));

  --_error:        var(--vtw-brand-error, #cc4444);
}

/* ── Base layout ─────────────────────────────────────── */
.vtw-email-capture {
  background-color: var(--_bg);
  color: var(--_text);
  padding-top: var(--_padding);
  padding-bottom: var(--_padding);
  position: relative;
  overflow: hidden;
}

.vtw-email-capture .vtw-container {
  max-width: var(--_max-width);
  margin-inline: auto;
  padding-inline: clamp(24px, 4vw, 48px);
  position: relative;
  z-index: 1;
}

.vtw-email-capture[data-width="full"] .vtw-container {
  max-width: none;
  padding-inline: clamp(24px, 6vw, 80px);
}

/* ── Background image ───────────────────────────────── */
.vtw-email-capture__bg-image {
  position: absolute;
  inset: 0;
  z-index: 0;
}

.vtw-email-capture__bg-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.vtw-email-capture__overlay {
  position: absolute;
  inset: 0;
  /* Gradient stops are emitted inline from Liquid so the opacity setting
     controls true darkness rather than multiplying against hardcoded alphas. */
}

/* When background image is present, force light text for headings/body —
   but NOT for the input, which has its own token chain that stays opaque
   and dark-on-light regardless of section text color. */
.vtw-email-capture:has(.vtw-email-capture__bg-image) {
  --_text: #ffffff;
}

.vtw-email-capture:has(.vtw-email-capture__bg-image) .vtw-email-capture__subheading {
  color: rgba(255, 255, 255, 0.9);
}

.vtw-email-capture:has(.vtw-email-capture__bg-image) .vtw-email-capture__heading,
.vtw-email-capture:has(.vtw-email-capture__bg-image) .vtw-email-capture__body {
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
}

/* ── Inner layout ───────────────────────────────────── */
.vtw-email-capture__inner {
  max-width: 560px;
  margin-inline: auto;
}

/* Split layout */
.vtw-email-capture[data-layout="split"] .vtw-email-capture__inner {
  max-width: none;
  display: grid;
  grid-template-columns: 55fr 45fr;
  gap: clamp(32px, 5vw, 64px);
  align-items: center;
}

.vtw-email-capture[data-layout="split"] .vtw-email-capture__content,
.vtw-email-capture[data-layout="split"] .vtw-email-capture__form-wrapper {
  min-width: 0;
}

/* ── Icon ────────────────────────────────────────────── */
.vtw-email-capture__icon {
  width: var(--_icon-size, 56px);
  height: var(--_icon-size, 56px);
  margin-bottom: 16px;
}

.vtw-email-capture__icon-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

/* ── Typography ──────────────────────────────────────── */
.vtw-email-capture__subheading {
  font-family: var(--_body-font);
  font-size: 13px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--_accent);
  margin: 0 0 12px;
}

.vtw-email-capture__heading {
  font-family: var(--_heading-font);
  font-size: clamp(26px, 4vw, 40px);
  font-weight: 700;
  line-height: 1.2;
  color: var(--_text);
  margin: 0 0 16px;
}

.vtw-email-capture__body {
  font-family: var(--_body-font);
  font-size: 16px;
  line-height: 1.65;
  color: var(--_text);
  opacity: 0.85;
  margin: 0 0 24px;
  max-width: 480px;
}

.vtw-email-capture__body p {
  margin: 0;
}

/* ── Form ─────────────────────────────────────────────── */
.vtw-email-capture__form-wrapper {
  width: var(--_form-width, 100%);
  max-width: 560px;
}

.vtw-email-capture__form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Input group — inline input + button */
.vtw-email-capture__input-group {
  display: flex;
  align-items: stretch;
}

/* Double-class selector — specificity (0,2,0) beats host-theme input[type="email"]
   which sits at (0,1,1). Horizon applies a 0.78-alpha background to all email
   inputs globally; without this bump, our --_input-bg token loses the cascade. */
.vtw-email-capture .vtw-email-capture__input {
  flex: 1;
  min-width: 0;
  font-family: var(--_body-font);
  font-size: 16px;
  line-height: 1.4;
  padding: 14px 20px;
  background-color: var(--_input-bg);
  color: var(--_input-text);
  border: 1.5px solid var(--_input-border);
  border-right: none;
  border-radius: var(--_input-radius) 0 0 var(--_input-radius);
  transition: border-color var(--_speed) ease;
  -webkit-appearance: none;
  appearance: none;
}

.vtw-email-capture .vtw-email-capture__input::placeholder {
  color: var(--_input-text);
  opacity: 0.5;
}

.vtw-email-capture .vtw-email-capture__input:focus {
  outline: none;
  border-color: var(--_accent);
}

/* ── Input border styles ─────────────────────────────── */
/* Double-class scoping throughout — (0,3,0) and (0,3,1) to beat host-theme input rules */

/* Underline — no border-right-none on the input (there's no right border at all) */
.vtw-email-capture[data-input-border="underline"] .vtw-email-capture__input {
  border: none;
  border-bottom: 1.5px solid var(--_input-border);
  border-radius: 0;
  padding-inline: 4px;
  background-color: transparent;
  color: var(--_text); /* underline variant uses section text color, not input box text */
}

.vtw-email-capture[data-input-border="underline"] .vtw-email-capture__input::placeholder {
  color: var(--_text);
}

.vtw-email-capture[data-input-border="underline"] .vtw-email-capture__input:focus {
  border-bottom-color: var(--_accent);
}

.vtw-email-capture[data-input-border="underline"] .vtw-email-capture__button {
  border-radius: 0;
}

/* None — filled field, no visible border */
.vtw-email-capture[data-input-border="none"] .vtw-email-capture__input {
  border: none;
  border-radius: var(--_input-radius) 0 0 var(--_input-radius);
  background-color: var(--_input-bg);
  color: var(--_input-text);
}

.vtw-email-capture[data-input-border="none"] .vtw-email-capture__input:focus {
  box-shadow: inset 0 0 0 1.5px var(--_accent);
}

/* ── Button styles ───────────────────────────────────── */
.vtw-email-capture__button {
  font-family: var(--_body-font);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.02em;
  padding: 14px 28px;
  border: none;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color var(--_speed) ease,
              color var(--_speed) ease,
              border-color var(--_speed) ease,
              opacity var(--_speed) ease;
}

/* Primary */
.vtw-email-capture__button--primary {
  background-color: var(--_accent);
  color: var(--_accent-text);
  border-radius: 0 var(--_button-radius) var(--_button-radius) 0;
}

.vtw-email-capture__button--primary:hover {
  opacity: 0.9;
}

.vtw-email-capture__button--primary:focus-visible {
  outline: 2px solid var(--_accent);
  outline-offset: 2px;
}

/* Secondary */
.vtw-email-capture__button--secondary {
  background-color: transparent;
  color: var(--_accent);
  border: 1.5px solid var(--_accent);
  border-radius: 0 var(--_button-radius) var(--_button-radius) 0;
}

.vtw-email-capture__button--secondary:hover {
  background-color: var(--_accent);
  color: var(--_accent-text);
}

.vtw-email-capture__button--secondary:focus-visible {
  outline: 2px solid var(--_accent);
  outline-offset: 2px;
}

/* Subtle */
.vtw-email-capture__button--subtle {
  background-color: transparent;
  color: var(--_accent);
  border-radius: 0;
  padding-inline: 20px;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.vtw-email-capture__button--subtle:hover {
  opacity: 0.7;
}

.vtw-email-capture__button--subtle:focus-visible {
  outline: 2px solid var(--_accent);
  outline-offset: 2px;
}

/* ── Consent ─────────────────────────────────────────── */
.vtw-email-capture__consent {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.vtw-email-capture__consent-label {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-family: var(--_body-font);
  font-size: 13px;
  line-height: 1.5;
  color: var(--_text);
  opacity: 0.7;
  cursor: pointer;
}

.vtw-email-capture__consent-checkbox {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  margin-top: 2px;
  accent-color: var(--_accent);
}

.vtw-email-capture__consent-text p {
  margin: 0;
  display: inline;
}

.vtw-email-capture__privacy-link {
  font-family: var(--_body-font);
  font-size: 12px;
  color: var(--_accent);
  text-decoration: underline;
  text-underline-offset: 2px;
  margin-left: 24px;
}

.vtw-email-capture__privacy-link:hover {
  opacity: 0.7;
}

/* ── Messages (error + success) ──────────────────────── */
.vtw-email-capture__message {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--_body-font);
  font-size: 14px;
  line-height: 1.5;
  padding: 8px 0;
}

.vtw-email-capture__message--error {
  color: var(--_error);
}

.vtw-email-capture__message--success {
  color: var(--_accent);
}

/* JS success state — hide form, show message */
.vtw-email-capture__form.vtw-is-success .vtw-email-capture__input-group,
.vtw-email-capture__form.vtw-is-success .vtw-email-capture__consent {
  display: none;
}

.vtw-email-capture__form .vtw-email-capture__success-inline {
  display: none;
}

.vtw-email-capture__form.vtw-is-success .vtw-email-capture__success-inline {
  display: flex;
}

/* ── Scroll-entry reveal ─────────────────────────────── */
.vtw-email-capture[data-animate="true"].vtw-animate-ready .vtw-email-capture__content,
.vtw-email-capture[data-animate="true"].vtw-animate-ready .vtw-email-capture__form-wrapper {
  opacity: 0;
  transform: translateY(16px);
}

.vtw-email-capture[data-animate="true"].vtw-animate-ready.vtw-is-visible .vtw-email-capture__content {
  animation: vtw-email-rise 500ms ease forwards;
}

.vtw-email-capture[data-animate="true"].vtw-animate-ready.vtw-is-visible .vtw-email-capture__form-wrapper {
  animation: vtw-email-rise 500ms ease 80ms forwards;
}

@keyframes vtw-email-rise {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ── Text alignment — desktop ────────────────────────── */
@media (min-width: 769px) {
  [data-text-align="center"] .vtw-email-capture__content {
    text-align: center;
  }

  [data-text-align="center"] .vtw-email-capture__icon {
    margin-inline: auto;
  }

  [data-text-align="center"] .vtw-email-capture__body {
    margin-inline: auto;
  }

  [data-text-align="center"] .vtw-email-capture__form-wrapper {
    margin-inline: auto;
  }

  [data-text-align="left"] .vtw-email-capture__content {
    text-align: left;
  }

  /* Split layout always left-aligns the content side on desktop */
  [data-layout="split"] .vtw-email-capture__content {
    text-align: left;
  }

  [data-layout="split"] .vtw-email-capture__icon {
    margin-inline: 0;
  }

  [data-layout="split"] .vtw-email-capture__body {
    margin-inline: 0;
  }
}

/* ── Text alignment — mobile ─────────────────────────── */
@media (max-width: 768px) {
  [data-text-align-mobile="center"] .vtw-email-capture__content {
    text-align: center;
  }

  [data-text-align-mobile="center"] .vtw-email-capture__icon {
    margin-inline: auto;
  }

  [data-text-align-mobile="center"] .vtw-email-capture__body {
    margin-inline: auto;
  }

  [data-text-align-mobile="left"] .vtw-email-capture__content {
    text-align: left;
  }
}

/* ── Responsive ──────────────────────────────────────── */
@media (max-width: 768px) {
  .vtw-email-capture[data-layout="split"] .vtw-email-capture__inner {
    grid-template-columns: 1fr;
    gap: 24px;
  }

  .vtw-email-capture__form-wrapper {
    width: 100%;
  }

  .vtw-email-capture__input-group {
    flex-direction: column;
    gap: 10px;
  }

  .vtw-email-capture .vtw-email-capture__input {
    border-radius: var(--_input-radius);
    border-right: 1.5px solid var(--_input-border);
  }

  .vtw-email-capture__button {
    border-radius: var(--_button-radius);
    width: 100%;
    padding: 14px 20px;
  }

  /* Secondary button on mobile — gets its own full border back since
     it's no longer sharing a border with the input above it */
  .vtw-email-capture__button--secondary {
    border: 1.5px solid var(--_accent);
  }

  /* Underline on mobile still needs flat radii */
  [data-input-border="underline"] .vtw-email-capture__input {
    border-radius: 0;
  }

  [data-input-border="underline"] .vtw-email-capture__button {
    border-radius: 0;
  }

  .vtw-email-capture__heading {
    font-size: clamp(24px, 6vw, 32px);
  }
}

/* ── Motion ──────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .vtw-email-capture * {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }

  .vtw-email-capture[data-animate="true"].vtw-animate-ready .vtw-email-capture__content,
  .vtw-email-capture[data-animate="true"].vtw-animate-ready .vtw-email-capture__form-wrapper {
    opacity: 1;
    transform: none;
  }
}
