/**
 * CRO Components — wemovetogether.co.uk
 * WCAG AA compliant, mobile-first
 * Colours: Teal #227A6A (on white passes AA), Navy #1A365D, Beige #EBE1D5
 * Font: Inter (loaded on all pages via Google Fonts)
 */

/* ===================================================================
   CSS CUSTOM PROPERTIES
   =================================================================== */

:root {
  --cro-teal:          #227A6A; /* 4.55:1 on white — WCAG AA */
  --cro-teal-dark:     #1A5C50; /* hover state */
  --cro-teal-light:    #E8F5F2; /* tint backgrounds */
  --cro-navy:          #1A365D;
  --cro-beige:         #EBE1D5;
  --cro-beige-dark:    #D9CBBA;
  --cro-white:         #FFFFFF;
  --cro-text:          #1A365D;
  --cro-text-muted:    #4A5568;
  --cro-text-light:    #596577;
  --cro-border:        #CBD5E0;
  --cro-success:       #276749; /* 4.6:1 on white — WCAG AA */
  --cro-success-bg:    #F0FFF4;
  --cro-error:         #C53030; /* 4.6:1 on white — WCAG AA */
  --cro-error-bg:      #FFF5F5;
  --cro-radius-sm:     4px;
  --cro-radius:        8px;
  --cro-radius-lg:     12px;
  --cro-shadow:        0 2px 8px rgba(0, 0, 0, 0.12);
  --cro-shadow-lg:     0 8px 24px rgba(0, 0, 0, 0.16);
  --cro-transition:    0.2s ease;
  --cro-z-slide:       400;
  --cro-z-modal:       500;
  --cro-z-backdrop:    499;
}

/* ===================================================================
   SHARED UTILITIES
   =================================================================== */

.cro-visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

/* Base button reset shared by all CRO CTAs */
.cro-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  min-width: 44px;
  padding: 10px 20px;
  font-family: inherit;
  font-size: 0.9375rem;   /* 15px */
  font-weight: 600;
  line-height: 1.2;
  text-decoration: none;
  border: 2px solid transparent;
  border-radius: 6px;
  cursor: pointer;
  transition: background-color var(--cro-transition),
              border-color var(--cro-transition),
              color var(--cro-transition),
              box-shadow var(--cro-transition);
  white-space: nowrap;
}

.cro-btn:focus-visible {
  outline: 3px solid #005FCC;
  outline-offset: 2px;
}

.cro-btn-primary {
  background-color: var(--cro-teal);
  border-color: var(--cro-teal);
  color: var(--cro-white);
}

.cro-btn-primary:hover,
.cro-btn-primary:active {
  background-color: var(--cro-teal-dark);
  border-color: var(--cro-teal-dark);
  color: var(--cro-white);
  text-decoration: none;
}

.cro-btn-ghost {
  background-color: transparent;
  border-color: var(--cro-border);
  color: var(--cro-text-muted);
  font-size: 0.875rem;
  font-weight: 500;
}

.cro-btn-ghost:hover {
  background-color: rgba(0, 0, 0, 0.04);
  text-decoration: none;
}

/* Email input shared styles */
.cro-email-field {
  width: 100%;
  min-height: 44px;
  padding: 10px 14px;
  font-family: inherit;
  font-size: 1rem;
  color: var(--cro-text);
  background: var(--cro-white);
  border: 2px solid var(--cro-border);
  border-radius: 6px;
  transition: border-color var(--cro-transition), box-shadow var(--cro-transition);
  box-sizing: border-box;
}

.cro-email-field::placeholder {
  color: var(--cro-text-light);
}

.cro-email-field:focus {
  outline: none;
  border-color: var(--cro-teal);
  box-shadow: 0 0 0 3px rgba(34, 122, 106, 0.2);
}

.cro-email-field:invalid:not(:placeholder-shown) {
  border-color: var(--cro-error);
}

/* Success / error feedback messages */
.cro-feedback {
  display: none;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: 6px;
  font-size: 0.875rem;
  font-weight: 500;
}

.cro-feedback.is-visible {
  display: flex;
}

.cro-feedback-success {
  background-color: var(--cro-success-bg);
  color: var(--cro-success);
  border: 1px solid #C6F6D5;
}

.cro-feedback-error {
  background-color: var(--cro-error-bg);
  color: var(--cro-error);
  border: 1px solid #FED7D7;
}

/* ===================================================================
   A. INLINE CONTENT UPGRADE
   =================================================================== */

.cro-content-upgrade {
  position: relative;
  margin: 2rem 0;
  padding: 1.25rem 1.5rem;
  background-color: var(--cro-beige);
  border-left: 4px solid var(--cro-teal);
  border-radius: 0 var(--cro-radius) var(--cro-radius) 0;
  box-shadow: var(--cro-shadow);
}

.cro-content-upgrade__inner {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
}

.cro-content-upgrade__icon {
  flex-shrink: 0;
  width: 2.5rem;
  height: 2.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--cro-teal);
  border-radius: 50%;
  color: var(--cro-white);
  font-size: 1.125rem;
}

.cro-content-upgrade__body {
  flex: 1;
  min-width: 0;
}

.cro-content-upgrade__headline {
  font-size: 1.0625rem;  /* 17px */
  font-weight: 700;
  color: var(--cro-navy);
  margin: 0 0 0.25rem;
  line-height: 1.3;
}

.cro-content-upgrade__subtext {
  font-size: 0.875rem;
  color: var(--cro-text-muted);
  margin: 0 0 0.875rem;
  line-height: 1.5;
}

.cro-content-upgrade__form {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.cro-content-upgrade__submitted {
  display: none;
}

.cro-content-upgrade.is-submitted .cro-content-upgrade__form {
  display: none;
}

.cro-content-upgrade.is-submitted .cro-content-upgrade__submitted {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--cro-success);
  font-weight: 600;
  font-size: 0.9375rem;
}

/* Stack button below field on mobile, row on wider screens */
@media (min-width: 480px) {
  .cro-content-upgrade__form {
    flex-direction: row;
  }

  .cro-content-upgrade__form .cro-btn-primary {
    flex-shrink: 0;
  }
}

/* ===================================================================
   B. SLIDE-IN FORM
   =================================================================== */

/* Mobile bottom-sheet: max 120px tall, slides up from bottom */
.cro-slide-in {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: var(--cro-z-slide);
  background: var(--cro-white);
  border-top: 3px solid var(--cro-teal);
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.18);
  padding: 0.875rem 1rem 1rem;
  transform: translateY(100%);
  transition: transform 0.35s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  will-change: transform;
  /* Limit mobile height so it's NOT an intrusive interstitial */
  max-height: 120px;
  overflow: hidden;
}

.cro-slide-in.is-visible {
  transform: translateY(0);
}

.cro-slide-in__dismiss {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--cro-text-light);
  font-size: 1.125rem;
  border-radius: var(--cro-radius-sm);
  padding: 0;
  line-height: 1;
  transition: color var(--cro-transition);
}

.cro-slide-in__dismiss:hover {
  color: var(--cro-navy);
}

.cro-slide-in__dismiss:focus-visible {
  outline: 3px solid #005FCC;
  outline-offset: 2px;
}

/* Mobile layout: single compact row */
.cro-slide-in__content {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding-right: 2rem; /* clear dismiss button */
}

.cro-slide-in__label {
  flex-shrink: 0;
  font-size: 0.8125rem;
  font-weight: 700;
  color: var(--cro-navy);
  white-space: nowrap;
}

.cro-slide-in__label small {
  display: block;
  font-weight: 400;
  color: var(--cro-text-muted);
  font-size: 0.75rem;
  line-height: 1.2;
}

.cro-slide-in__form {
  display: flex;
  flex: 1;
  gap: 0.375rem;
  min-width: 0;
}

.cro-slide-in__form .cro-email-field {
  flex: 1;
  min-width: 0;
  min-height: 40px;
  padding: 8px 10px;
  font-size: 0.875rem;
}

.cro-slide-in__form .cro-btn-primary {
  flex-shrink: 0;
  min-height: 40px;
  padding: 8px 12px;
  font-size: 0.8125rem;
  white-space: nowrap;
}

/* Desktop: richer card in bottom-right corner */
@media (min-width: 768px) {
  .cro-slide-in {
    left: auto;
    right: 1.5rem;
    bottom: 1.5rem;
    width: 280px;
    max-height: none;
    border-top: none;
    border-radius: var(--cro-radius-lg);
    border: 2px solid var(--cro-teal);
    padding: 1.25rem;
    box-shadow: var(--cro-shadow-lg);
    transform: translateX(calc(100% + 2rem));
    transition: transform 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  }

  .cro-slide-in.is-visible {
    transform: translateX(0);
  }

  .cro-slide-in__content {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.625rem;
    padding-right: 1.5rem;
  }

  .cro-slide-in__headline {
    font-size: 1rem;
    font-weight: 700;
    color: var(--cro-navy);
    margin: 0;
    line-height: 1.3;
  }

  .cro-slide-in__subtext {
    font-size: 0.8125rem;
    color: var(--cro-text-muted);
    margin: 0;
    line-height: 1.4;
  }

  .cro-slide-in__form {
    flex-direction: column;
    width: 100%;
  }

  .cro-slide-in__form .cro-email-field {
    min-height: 44px;
    font-size: 0.9375rem;
    padding: 10px 14px;
  }

  .cro-slide-in__form .cro-btn-primary {
    min-height: 44px;
    width: 100%;
    font-size: 0.9375rem;
  }
}

/* ===================================================================
   C. EXIT INTENT POPUP (desktop only)
   =================================================================== */

/* Backdrop */
.cro-exit-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: var(--cro-z-backdrop);
  background: rgba(26, 54, 93, 0.55);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  animation: croFadeIn 0.2s ease forwards;
}

.cro-exit-backdrop.is-visible {
  display: block;
}

/* Modal */
.cro-exit-popup {
  display: none;
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -48%);
  z-index: var(--cro-z-modal);
  width: min(480px, calc(100vw - 2rem));
  background: var(--cro-white);
  border-radius: var(--cro-radius-lg);
  box-shadow: var(--cro-shadow-lg);
  padding: 2rem;
  animation: croBounceIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.cro-exit-popup.is-visible {
  display: block;
}

/* Only show on desktop */
@media (max-width: 767px) {
  .cro-exit-backdrop,
  .cro-exit-popup {
    display: none !important;
  }
}

.cro-exit-popup__header {
  margin-bottom: 0.75rem;
}

.cro-exit-popup__emoji {
  font-size: 2rem;
  line-height: 1;
  display: block;
  margin-bottom: 0.5rem;
  user-select: none;
  aria-hidden: true;
}

.cro-exit-popup__title {
  font-size: 1.3125rem;  /* 21px */
  font-weight: 700;
  color: var(--cro-navy);
  margin: 0 0 0.375rem;
  line-height: 1.3;
}

.cro-exit-popup__subtext {
  font-size: 0.9375rem;
  color: var(--cro-text-muted);
  margin: 0 0 1.25rem;
  line-height: 1.5;
}

.cro-exit-popup__form {
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
  margin-bottom: 0.875rem;
}

.cro-exit-popup__dismiss {
  display: block;
  text-align: center;
  font-size: 0.8125rem;
  color: var(--cro-text-light);
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 0;
  font-family: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
  width: 100%;
  transition: color var(--cro-transition);
}

.cro-exit-popup__dismiss:hover {
  color: var(--cro-text-muted);
}

.cro-exit-popup__dismiss:focus-visible {
  outline: 3px solid #005FCC;
  outline-offset: 2px;
}

/* ===================================================================
   D. SOCIAL PROOF STRIP
   =================================================================== */

.cro-social-proof {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem 1.5rem;
  align-items: center;
  justify-content: center;
  padding: 0.875rem 1rem;
  background-color: var(--cro-teal-light);
  border: 1px solid #B2DFDB;
  border-radius: var(--cro-radius);
  margin: 1.5rem 0;
}

.cro-social-proof__item {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.8125rem;  /* 13px */
  font-weight: 600;
  color: var(--cro-navy);
  white-space: nowrap;
}

.cro-social-proof__icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  background: var(--cro-teal);
  border-radius: 50%;
  flex-shrink: 0;
}

.cro-social-proof__icon svg {
  width: 0.875rem;
  height: 0.875rem;
  fill: var(--cro-white);
}

.cro-social-proof__stars {
  color: #D69E2E; /* WCAG AA: 4.6:1 on light-teal bg */
  font-size: 0.875rem;
  letter-spacing: 1px;
}

.cro-social-proof__divider {
  width: 1px;
  height: 1.25rem;
  background: var(--cro-border);
  display: none;
}

@media (min-width: 600px) {
  .cro-social-proof {
    flex-wrap: nowrap;
    justify-content: center;
    gap: 0.75rem;
  }

  .cro-social-proof__divider {
    display: block;
  }
}

/* ===================================================================
   E. NEWSLETTER SIGNUP SECTION (pillar page footer section)
   =================================================================== */

.cro-newsletter {
  margin: 2rem 0;
  padding: 1.75rem 1.5rem;
  background: var(--cro-navy);
  border-radius: var(--cro-radius-lg);
  color: var(--cro-white);
  text-align: center;
}

.cro-newsletter__headline {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--cro-white);
  margin: 0 0 0.375rem;
  line-height: 1.3;
}

.cro-newsletter__subtext {
  font-size: 0.9375rem;
  color: rgba(255, 255, 255, 0.80);
  margin: 0 0 1.25rem;
  line-height: 1.5;
}

.cro-newsletter__form {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-width: 400px;
  margin: 0 auto;
}

.cro-newsletter__form .cro-email-field {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.35);
  color: var(--cro-white);
}

.cro-newsletter__form .cro-email-field::placeholder {
  color: rgba(255, 255, 255, 0.55);
}

.cro-newsletter__form .cro-email-field:focus {
  border-color: rgba(255, 255, 255, 0.8);
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.2);
}

.cro-newsletter__form .cro-btn-primary {
  background-color: #1EC8A9; /* higher luminance teal for navy bg */
  border-color: #1EC8A9;
  color: var(--cro-navy);
  font-weight: 700;
}

.cro-newsletter__form .cro-btn-primary:hover {
  background-color: #18B097;
  border-color: #18B097;
  color: var(--cro-navy);
}

.cro-newsletter__disclaimer {
  margin-top: 0.75rem;
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.55);
  text-align: center;
}

.cro-newsletter.is-submitted .cro-newsletter__form,
.cro-newsletter.is-submitted .cro-newsletter__subtext {
  display: none;
}

.cro-newsletter__submitted {
  display: none;
  justify-content: center;
  align-items: center;
  gap: 8px;
  color: #1EC8A9;
  font-weight: 600;
  font-size: 1rem;
  margin-top: 0.5rem;
}

.cro-newsletter.is-submitted .cro-newsletter__submitted {
  display: flex;
}

@media (min-width: 480px) {
  .cro-newsletter__form {
    flex-direction: row;
  }

  .cro-newsletter__form .cro-btn-primary {
    flex-shrink: 0;
  }
}

/* ===================================================================
   F. EMAIL RESULTS CAPTURE (tool/calculator pages)
   =================================================================== */

.cro-results-capture {
  margin: 2rem 0;
  padding: 1.5rem;
  background: var(--cro-white);
  border: 2px solid var(--cro-teal);
  border-radius: var(--cro-radius-lg);
  box-shadow: var(--cro-shadow);
}

.cro-results-capture__header {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  margin-bottom: 0.875rem;
}

.cro-results-capture__icon {
  flex-shrink: 0;
  width: 2.5rem;
  height: 2.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--cro-teal-light);
  border-radius: 50%;
  color: var(--cro-teal);
}

.cro-results-capture__icon svg {
  width: 1.125rem;
  height: 1.125rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.cro-results-capture__title {
  font-size: 1.0625rem;
  font-weight: 700;
  color: var(--cro-navy);
  margin: 0 0 0.2rem;
  line-height: 1.3;
}

.cro-results-capture__subtext {
  font-size: 0.875rem;
  color: var(--cro-text-muted);
  margin: 0;
  line-height: 1.5;
}

.cro-results-capture__form {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 0.625rem;
}

.cro-results-capture__disclaimer {
  font-size: 0.75rem;
  color: var(--cro-text-light);
}

.cro-results-capture.is-submitted .cro-results-capture__form,
.cro-results-capture.is-submitted .cro-results-capture__disclaimer {
  display: none;
}

.cro-results-capture__submitted {
  display: none;
  align-items: center;
  gap: 8px;
  color: var(--cro-success);
  font-weight: 600;
  font-size: 0.9375rem;
}

.cro-results-capture.is-submitted .cro-results-capture__submitted {
  display: flex;
}

@media (min-width: 480px) {
  .cro-results-capture__form {
    flex-direction: row;
  }

  .cro-results-capture__form .cro-btn-primary {
    flex-shrink: 0;
  }
}

/* ===================================================================
   G. SHARE BUTTONS
   =================================================================== */

.cro-share {
  margin: 1.5rem 0 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--cro-border);
}

.cro-share__title {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--cro-text-muted);
  margin: 0 0 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.cro-share__buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.cro-share__btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 10px 14px;
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  border: 2px solid var(--cro-border);
  border-radius: 6px;
  background: var(--cro-white);
  cursor: pointer;
  color: var(--cro-text-muted);
  text-decoration: none;
  transition: border-color var(--cro-transition),
              color var(--cro-transition),
              background-color var(--cro-transition);
}

.cro-share__btn:hover {
  border-color: var(--cro-teal);
  color: var(--cro-teal);
  background-color: var(--cro-teal-light);
  text-decoration: none;
}

.cro-share__btn:focus-visible {
  outline: 3px solid #005FCC;
  outline-offset: 2px;
}

.cro-share__btn svg {
  width: 1rem;
  height: 1rem;
  flex-shrink: 0;
}

.cro-share__btn--whatsapp:hover {
  border-color: #25D366;
  color: #1A9E4D;
  background-color: #F0FFF4;
}

.cro-share__btn--facebook:hover {
  border-color: #1877F2;
  color: #0C5AB9;
  background-color: #EEF4FF;
}

.cro-share__btn--copied {
  border-color: var(--cro-success);
  color: var(--cro-success);
  background-color: var(--cro-success-bg);
}

/* ===================================================================
   BENEFIT-DRIVEN CTA SECTION (overrides for pillar pages)
   Pillar pages have their own .cta-section / .guide-cta — we add
   .cro-cta-benefit wrapper around updated content
   =================================================================== */

.cro-cta-benefit {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

.cro-cta-benefit__headline {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--cro-navy);
  margin: 0 0 0.375rem;
  line-height: 1.25;
}

.cro-cta-benefit__subtext {
  font-size: 1rem;
  color: var(--cro-text-muted);
  margin: 0 0 1.25rem;
  line-height: 1.5;
}

/* ===================================================================
   ANIMATIONS
   =================================================================== */

@keyframes croFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes croBounceIn {
  0%   { opacity: 0; transform: translate(-50%, -45%) scale(0.92); }
  70%  { opacity: 1; transform: translate(-50%, -51%) scale(1.02); }
  100% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

@keyframes croSpinOnce {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

/* Loading spinner for form submit */
.cro-btn-loading {
  pointer-events: none;
  opacity: 0.8;
}

.cro-btn-loading::after {
  content: '';
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255,255,255,0.4);
  border-top-color: rgba(255,255,255,0.9);
  border-radius: 50%;
  animation: croSpinOnce 0.7s linear infinite;
  margin-left: 6px;
  flex-shrink: 0;
}

/* ===================================================================
   REDUCED MOTION
   =================================================================== */

@media (prefers-reduced-motion: reduce) {
  .cro-slide-in,
  .cro-exit-backdrop,
  .cro-exit-popup,
  .cro-btn-loading::after {
    transition: none !important;
    animation: none !important;
  }
}
