/* ============================================================
   Aeroflow Dynamics — Engage layer: discount popup + chat widget
   Loaded on every page via chrome.js
   ============================================================ */

/* ============= POPUP ============= */
.popup-scrim {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(11,15,20,.78);
  backdrop-filter: blur(10px);
  opacity: 0; visibility: hidden;
  transition: opacity .5s cubic-bezier(.2,.7,.2,1), visibility 0s .5s;
}
.popup-scrim[data-open] {
  opacity: 1; visibility: visible;
  transition: opacity .5s cubic-bezier(.2,.7,.2,1);
}

.popup {
  position: fixed; left: 50%; top: 50%; z-index: 201;
  transform: translate(-50%, -48%) scale(.94);
  width: min(900px, 92vw);
  max-height: 92vh; overflow: hidden;
  background: var(--ink);
  border: 1px solid var(--edge-strong);
  box-shadow: 0 60px 120px -20px rgba(0,0,0,.8),
              0 0 0 1px rgba(217,255,59,.04);
  opacity: 0; visibility: hidden;
  transition: opacity .55s cubic-bezier(.2,.7,.2,1),
              transform .55s cubic-bezier(.2,.7,.2,1),
              visibility 0s .55s;
  display: grid; grid-template-columns: 0.9fr 1.1fr;
}
.popup[data-open] {
  opacity: 1; visibility: visible;
  transform: translate(-50%, -50%) scale(1);
  transition: opacity .55s cubic-bezier(.2,.7,.2,1),
              transform .55s cubic-bezier(.2,.7,.2,1);
}

.popup__close {
  position: absolute; top: 14px; right: 14px; z-index: 4;
  width: 36px; height: 36px;
  background: rgba(11,15,20,.5);
  backdrop-filter: blur(8px);
  border: 1px solid var(--edge-strong);
  border-radius: 50%;
  color: var(--bone); font-size: 16px;
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: background .25s var(--ease), transform .25s var(--ease);
}
.popup__close:hover { background: var(--volt); color: var(--ink); border-color: var(--volt); transform: rotate(90deg); }

/* Left media panel */
.popup__media {
  position: relative; overflow: hidden;
  background:
    radial-gradient(ellipse 80% 60% at 50% 40%, rgba(217,255,59,.18), transparent 60%),
    linear-gradient(180deg, #14191F 0%, #06090C 100%);
  display: flex; flex-direction: column; justify-content: space-between;
  padding: 40px;
  isolation: isolate;
}
.popup__media::after {
  content: ""; position: absolute; inset: 0; z-index: 0;
  background-image:
    linear-gradient(rgba(255,255,255,.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.05) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(ellipse 70% 90% at 50% 50%, #000 0%, transparent 80%);
  -webkit-mask-image: radial-gradient(ellipse 70% 90% at 50% 50%, #000 0%, transparent 80%);
  opacity: .5;
}
.popup__media > * { position: relative; z-index: 2; }
.popup__discount {
  display: flex; flex-direction: column; gap: 8px;
}
.popup__discount-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px; letter-spacing: 0.24em;
  color: var(--volt); text-transform: uppercase;
  display: inline-flex; align-items: center; gap: 8px;
}
.popup__discount-label::before {
  content: ""; width: 28px; height: 1px; background: var(--volt);
}
.popup__discount-num {
  font-size: clamp(96px, 12vw, 168px);
  font-weight: 600; letter-spacing: -0.06em; line-height: .85;
  color: var(--bone);
}
.popup__discount-num em {
  color: var(--volt); font-style: normal;
}
.popup__discount-foot {
  font-size: var(--t-3); color: var(--alloy-2);
  max-width: 30ch; line-height: 1.45;
}
.popup__trust {
  display: flex; flex-direction: column; gap: 12px;
  padding-top: 24px; border-top: 1px solid var(--edge);
}
.popup__trust-item {
  display: flex; align-items: center; gap: 10px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px; letter-spacing: 0.18em; color: var(--alloy-2);
  text-transform: uppercase;
}
.popup__trust-item::before { content: "✓"; color: var(--volt); font-weight: 700; }

/* Right content panel */
.popup__content {
  padding: 48px 44px;
  display: flex; flex-direction: column; gap: 22px;
  overflow-y: auto;
}
.popup__eyebrow {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px; letter-spacing: 0.22em; text-transform: uppercase;
  color: var(--alloy);
  display: inline-flex; align-items: center; gap: 10px;
}
.popup__eyebrow::before { content: ""; width: 24px; height: 1px; background: var(--alloy); }
.popup__pulse {
  display: inline-flex; width: 8px; height: 8px; border-radius: 50%;
  background: var(--volt);
  animation: pulse 1.6s ease-in-out infinite;
}
.popup__title {
  font-size: clamp(28px, 3.4vw, 44px);
  letter-spacing: -0.028em; line-height: 1.05;
  max-width: 18ch;
}
.popup__title span { color: var(--volt); }
.popup__body {
  color: var(--alloy-2);
  font-size: var(--t-3); line-height: 1.55;
  max-width: 42ch;
}
.popup__benefits {
  display: flex; flex-direction: column; gap: 10px;
}
.popup__benefit {
  display: flex; align-items: center; gap: 12px;
  font-size: var(--t-3); color: var(--bone);
}
.popup__benefit::before {
  content: ""; flex-shrink: 0;
  width: 18px; height: 18px;
  background: var(--volt);
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--ink); font-weight: 700; font-size: 11px;
}
.popup__benefit[data-i]::before { content: attr(data-i); }

.popup__form {
  display: flex; flex-direction: column; gap: 8px;
  margin-top: 6px;
}
.popup__form-row {
  display: flex; gap: 0;
  background: var(--carbon);
  border: 1px solid var(--edge-strong);
  transition: border-color .25s var(--ease), transform .25s var(--ease), box-shadow .25s var(--ease);
}
.popup__form-row:focus-within {
  border-color: var(--volt);
  transform: translateY(-2px);
  box-shadow: 0 20px 50px -16px rgba(217,255,59,.22);
}
.popup__form-row input {
  flex: 1; min-width: 0;
  padding: 18px 20px;
  font: inherit; font-size: var(--t-3);
  background: transparent; border: 0; color: var(--bone);
  outline: none;
}
.popup__form-row input::placeholder { color: var(--alloy); }
.popup__form-row button {
  padding: 18px 26px;
  font-size: var(--t-3); font-weight: 600;
  background: var(--volt); color: var(--ink);
  border: 0; cursor: pointer; white-space: nowrap;
  position: relative; overflow: hidden;
  transition: background .3s var(--ease), letter-spacing .3s var(--ease);
}
.popup__form-row button:hover { background: var(--pure); letter-spacing: 0.005em; }
.popup__form-hint {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px; letter-spacing: 0.18em; text-transform: uppercase;
  color: var(--alloy);
}
.popup__divider {
  display: flex; align-items: center; gap: 14px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px; letter-spacing: 0.2em; text-transform: uppercase;
  color: var(--alloy);
}
.popup__divider::before, .popup__divider::after {
  content: ""; flex: 1; height: 1px; background: var(--edge);
}
.popup__chat-link {
  display: inline-flex; align-items: center; gap: 10px;
  font-size: var(--t-3); color: var(--bone);
  padding: 14px 0;
  cursor: pointer; background: transparent; border: 0;
  align-self: flex-start;
  font: inherit;
  transition: color .2s var(--ease);
}
.popup__chat-link:hover { color: var(--volt); }
.popup__chat-link svg { width: 18px; height: 18px; flex-shrink: 0; }
.popup__chat-link strong { color: var(--volt); }

.popup__decline {
  background: transparent; border: 0; padding: 8px 0;
  font: inherit; font-size: var(--t-2);
  color: var(--alloy);
  cursor: pointer;
  align-self: flex-start;
  text-decoration: underline;
  text-underline-offset: 4px; text-decoration-color: var(--edge-strong);
  transition: color .2s var(--ease), text-decoration-color .2s var(--ease);
}
.popup__decline:hover { color: var(--bone); text-decoration-color: var(--alloy); }

/* SUCCESS state */
.popup[data-state="success"] .popup__form,
.popup[data-state="success"] .popup__benefits,
.popup[data-state="success"] .popup__body,
.popup[data-state="success"] .popup__title,
.popup[data-state="success"] .popup__divider,
.popup[data-state="success"] .popup__chat-link,
.popup[data-state="success"] .popup__decline { display: none; }
.popup__success { display: none; flex-direction: column; gap: 22px; }
.popup[data-state="success"] .popup__success { display: flex; }
.popup__success h3 {
  font-size: clamp(28px, 3.4vw, 44px);
  letter-spacing: -0.028em; line-height: 1.05;
}
.popup__success h3 span { color: var(--volt); }
.popup__success p { color: var(--alloy-2); font-size: var(--t-3); line-height: 1.5; }
.popup__code {
  display: flex; align-items: stretch; gap: 0;
  border: 1px dashed var(--volt);
  background: rgba(217,255,59,.06);
}
.popup__code-label {
  padding: 18px 22px;
  font-family: 'JetBrains Mono', monospace;
  font-size: var(--t-1); letter-spacing: 0.2em; color: var(--alloy);
  text-transform: uppercase;
  border-right: 1px dashed var(--edge);
  display: inline-flex; align-items: center;
}
.popup__code-value {
  flex: 1; padding: 18px 22px;
  font-family: 'JetBrains Mono', monospace;
  font-size: clamp(20px, 2.5vw, 28px); font-weight: 500;
  color: var(--volt); letter-spacing: 0.06em;
  display: inline-flex; align-items: center;
}
.popup__code-copy {
  padding: 0 22px;
  background: var(--volt); color: var(--ink);
  border: 0; cursor: pointer;
  font: inherit; font-size: var(--t-2); font-weight: 600;
  white-space: nowrap;
  transition: background .25s var(--ease);
}
.popup__code-copy:hover { background: var(--pure); }
.popup__code-copy[data-copied] { background: var(--ink); color: var(--volt); }

@media (max-width: 760px) {
  .popup { grid-template-columns: 1fr; max-height: 94vh; overflow-y: auto; }
  .popup__media { padding: 28px; min-height: 220px; flex-direction: row; align-items: center; justify-content: space-between; gap: 20px; }
  .popup__discount-num { font-size: clamp(72px, 18vw, 112px); }
  .popup__trust { display: none; }
  .popup__content { padding: 28px; }
}

/* ============= CHAT WIDGET ============= */
.chat-bubble {
  position: fixed; right: 24px; bottom: 24px; z-index: 90;
  width: 60px; height: 60px;
  background: var(--volt); color: var(--ink);
  border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer; border: 0;
  box-shadow: 0 20px 50px -12px rgba(217,255,59,.45),
              0 0 0 0 rgba(217,255,59,.45);
  transition: transform .35s cubic-bezier(.2,.7,.2,1),
              box-shadow .35s cubic-bezier(.2,.7,.2,1);
  animation: chatPulse 2.4s ease-in-out infinite;
}
.chat-bubble:hover { transform: scale(1.08); }
.chat-bubble svg { width: 26px; height: 26px; }
.chat-bubble[data-open] {
  background: var(--ink); color: var(--bone);
  animation: none;
}
.chat-bubble[data-open] .chat-bubble__icon { display: none; }
.chat-bubble[data-open] .chat-bubble__close { display: block; }
.chat-bubble__close { display: none; font-size: 22px; line-height: 1; }
.chat-bubble__count {
  position: absolute; top: -2px; right: -2px;
  min-width: 20px; height: 20px;
  padding: 0 6px;
  background: var(--ember); color: var(--pure);
  border-radius: 12px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px; font-weight: 700;
  display: none; align-items: center; justify-content: center;
}
.chat-bubble[data-badge] .chat-bubble__count { display: inline-flex; }
@keyframes chatPulse {
  0%, 100% { box-shadow: 0 20px 50px -12px rgba(217,255,59,.45), 0 0 0 0 rgba(217,255,59,.4); }
  50%      { box-shadow: 0 20px 50px -12px rgba(217,255,59,.45), 0 0 0 14px rgba(217,255,59,0); }
}

.chat-panel {
  position: fixed; right: 24px; bottom: 100px; z-index: 91;
  width: 380px; max-width: calc(100vw - 32px);
  height: min(580px, calc(100vh - 140px));
  background: var(--ink);
  border: 1px solid var(--edge-strong);
  display: flex; flex-direction: column;
  overflow: hidden;
  opacity: 0; visibility: hidden;
  transform: translateY(16px) scale(.98);
  transform-origin: bottom right;
  transition: opacity .35s cubic-bezier(.2,.7,.2,1),
              transform .35s cubic-bezier(.2,.7,.2,1),
              visibility 0s .35s;
  box-shadow: 0 30px 80px -20px rgba(0,0,0,.7);
}
.chat-panel[data-open] {
  opacity: 1; visibility: visible;
  transform: translateY(0) scale(1);
  transition: opacity .35s cubic-bezier(.2,.7,.2,1),
              transform .35s cubic-bezier(.2,.7,.2,1);
}
.chat-panel__head {
  padding: 20px 22px;
  background:
    radial-gradient(ellipse 80% 100% at 0% 100%, rgba(217,255,59,.15), transparent 60%),
    var(--carbon);
  border-bottom: 1px solid var(--edge);
  display: flex; align-items: center; gap: 14px;
  position: relative;
}
.chat-panel__avatar {
  width: 40px; height: 40px;
  background: var(--volt); color: var(--ink);
  border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px;
  position: relative;
  flex-shrink: 0;
}
.chat-panel__avatar::after {
  content: ""; position: absolute; right: -2px; bottom: -2px;
  width: 12px; height: 12px;
  background: #2ECC71; border-radius: 50%;
  border: 2px solid var(--carbon);
  animation: pulse 2s ease-in-out infinite;
}
.chat-panel__name { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.chat-panel__name strong { font-size: var(--t-3); }
.chat-panel__name span {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px; letter-spacing: 0.18em; text-transform: uppercase;
  color: var(--alloy);
}
.chat-panel__name span em { color: #2ECC71; font-style: normal; }

.chat-panel__body {
  flex: 1; overflow-y: auto;
  padding: 20px;
  display: flex; flex-direction: column; gap: 10px;
  scroll-behavior: smooth;
}
.chat-msg {
  max-width: 86%;
  padding: 12px 14px;
  font-size: var(--t-3); line-height: 1.45;
  border-radius: 2px;
  animation: chatMsgIn .35s cubic-bezier(.2,.7,.2,1) both;
}
.chat-msg--bot {
  background: var(--carbon);
  color: var(--bone);
  border: 1px solid var(--edge);
  align-self: flex-start;
}
.chat-msg--user {
  background: var(--volt);
  color: var(--ink);
  align-self: flex-end;
  font-weight: 500;
}
.chat-msg__meta {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px; letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--alloy); margin-bottom: 4px;
}
.chat-msg__meta--user { color: rgba(11,15,20,.6); }
@keyframes chatMsgIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}

.chat-typing {
  display: inline-flex; gap: 4px;
  padding: 14px 16px;
  background: var(--carbon);
  border: 1px solid var(--edge);
  align-self: flex-start;
}
.chat-typing span {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--alloy);
  animation: chatDots 1.2s ease-in-out infinite;
}
.chat-typing span:nth-child(2) { animation-delay: .15s; }
.chat-typing span:nth-child(3) { animation-delay: .3s; }
@keyframes chatDots {
  0%, 100% { transform: translateY(0); opacity: .4; }
  50%      { transform: translateY(-4px); opacity: 1; }
}

.chat-quick {
  display: flex; flex-wrap: wrap; gap: 6px;
  padding: 0 20px 12px;
}
.chat-quick button {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px; letter-spacing: 0.16em; text-transform: uppercase;
  padding: 8px 12px;
  background: var(--ink); color: var(--alloy-2);
  border: 1px solid var(--edge-strong);
  cursor: pointer;
  transition: all .2s var(--ease);
}
.chat-quick button:hover { border-color: var(--volt); color: var(--volt); }

.chat-panel__foot {
  border-top: 1px solid var(--edge);
  padding: 14px 18px;
  display: flex; gap: 10px; align-items: center;
  background: var(--carbon);
}
.chat-panel__foot input {
  flex: 1; min-width: 0;
  padding: 10px 0;
  font: inherit; font-size: var(--t-3);
  background: transparent; border: 0; color: var(--bone);
  outline: none;
}
.chat-panel__foot input::placeholder { color: var(--alloy); }
.chat-panel__send {
  width: 36px; height: 36px;
  background: var(--volt); color: var(--ink);
  border: 0; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: background .25s var(--ease), transform .25s var(--ease);
  flex-shrink: 0;
}
.chat-panel__send:hover { background: var(--pure); transform: scale(1.06); }
.chat-panel__send svg { width: 16px; height: 16px; }

.chat-panel__legal {
  padding: 0 20px 12px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px; letter-spacing: 0.14em; color: var(--alloy);
  text-align: center;
}

@media (max-width: 540px) {
  .chat-bubble { right: 16px; bottom: 16px; width: 54px; height: 54px; }
  .chat-panel { right: 8px; left: 8px; bottom: 84px; width: auto; }
}

@media (prefers-reduced-motion: reduce) {
  .popup, .popup-scrim, .chat-panel, .chat-bubble { transition: opacity .15s; }
  .chat-bubble { animation: none; }
  .chat-panel__avatar::after { animation: none; }
}
