/* Floating Deal Widget — styles
   Semantic z-index scale: widget(40) < modal-backdrop(50) < modal(51) < toast(60) */
:root {
  --hns-z-widget: 40;
  --hns-z-modal-backdrop: 50;
  --hns-z-modal: 51;
  --hns-ease-out: cubic-bezier(0.25, 1, 0.5, 1);
  --hns-ink: #f5f5f4;
  --hns-ink-muted: #b8b8bb;
  --hns-surface: #1c1c1e;
  --hns-surface-raised: #232326;
  --hns-border: rgba(255, 255, 255, 0.09);
  --hns-gold: #e8ab5c;
  --hns-orange: #f5821f;
  --hns-orange-deep: #d9690f;
  --hns-green: #4ade80;
  --hns-red: #ff6b6b;

  /* 4pt spacing scale — every gap/padding/margin in this file draws from here */
  --hns-space-1: 4px;
  --hns-space-2: 8px;
  --hns-space-3: 12px;
  --hns-space-4: 16px;
  --hns-space-5: 24px;
  --hns-space-6: 32px;
}

.hns-deal-widget,
.hns-deal-modal-backdrop {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
}

/* ---------- Card ---------- */

.hns-deal-widget {
  position: fixed;
  left: 50%;
  bottom: var(--hns-space-5);
  transform: translate(-50%, 140%);
  width: 344px;
  max-width: calc(100vw - 32px);
  background: linear-gradient(180deg, var(--hns-surface) 0%, #141416 100%);
  border: 1px solid var(--hns-border);
  border-radius: 16px;
  box-shadow: 0 20px 48px -8px rgba(0, 0, 0, 0.55), 0 2px 8px rgba(0, 0, 0, 0.3);
  padding: var(--hns-space-4);
  z-index: var(--hns-z-widget);
  color: var(--hns-ink);
  opacity: 0;
  display: flex;
  flex-direction: column;
  gap: var(--hns-space-4);
  transition: transform 0.4s var(--hns-ease-out), opacity 0.4s var(--hns-ease-out);
  pointer-events: none;
}

.hns-deal-widget.is-visible {
  transform: translate(-50%, 0);
  opacity: 1;
  pointer-events: auto;
}

.hns-deal-widget.is-collapsed {
  transform: translate(-50%, 0);
  opacity: 1;
  pointer-events: auto;
  width: auto;
  padding: var(--hns-space-2) var(--hns-space-4);
  border-radius: 999px;
  cursor: pointer;
}

.hns-deal-widget.is-collapsed .hns-deal-body,
.hns-deal-widget.is-collapsed .hns-deal-header,
.hns-deal-widget.is-collapsed .hns-deal-cta {
  display: none;
}

.hns-deal-pill {
  display: none;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}

.hns-deal-widget.is-collapsed .hns-deal-pill {
  display: flex;
}

.hns-deal-pill .hns-trophy {
  font-size: 15px;
}

.hns-deal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--hns-space-3);
}

.hns-deal-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--hns-gold);
}

.hns-deal-slots {
  font-size: 11px;
  font-weight: 600;
  color: var(--hns-red);
  background: rgba(255, 107, 107, 0.14);
  padding: 3px 9px;
  border-radius: 999px;
  white-space: nowrap;
  flex-shrink: 0;
}

.hns-deal-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.08);
  color: var(--hns-ink-muted);
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.15s var(--hns-ease-out), color 0.15s var(--hns-ease-out);
}

.hns-deal-close:hover,
.hns-deal-close:focus-visible {
  background: rgba(255, 255, 255, 0.18);
  color: var(--hns-ink);
}

.hns-deal-body {
  display: flex;
  align-items: center;
  gap: var(--hns-space-3);
}

.hns-deal-thumb {
  width: 58px;
  height: 58px;
  border-radius: 10px;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--hns-surface-raised);
  border: 1px solid var(--hns-border);
}

.hns-deal-info {
  flex: 1;
  min-width: 0;
}

.hns-deal-project {
  font-size: 16px;
  font-weight: 700;
  color: var(--hns-ink);
  margin: 0 0 var(--hns-space-1);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hns-deal-savings {
  font-size: 13px;
  font-weight: 600;
  color: var(--hns-green);
  margin: 0;
}

.hns-deal-cta {
  width: 100%;
  border: none;
  border-radius: 9px;
  padding: var(--hns-space-3) var(--hns-space-4);
  background: linear-gradient(180deg, #ff9a3d 0%, var(--hns-orange) 100%);
  color: #1a1200;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: filter 0.15s var(--hns-ease-out), transform 0.15s var(--hns-ease-out);
}

.hns-deal-cta:hover {
  filter: brightness(1.08);
}

.hns-deal-cta:active {
  transform: scale(0.98);
}

.hns-deal-cta:focus-visible,
.hns-deal-close:focus-visible {
  outline: 2px solid var(--hns-gold);
  outline-offset: 2px;
}

@media (max-width: 480px) {
  .hns-deal-widget {
    bottom: 84px; /* clear the bottom-left WhatsApp/AI icon stack + bottom-right chat bubble */
    width: calc(100vw - 24px);
  }
}

/* ---------- Modal ---------- */

.hns-deal-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(8, 8, 9, 0.66);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  z-index: var(--hns-z-modal-backdrop);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s var(--hns-ease-out);
}

.hns-deal-modal-backdrop.is-open {
  opacity: 1;
  pointer-events: auto;
}

.hns-deal-modal {
  position: relative;
  width: 100%;
  max-width: 380px;
  background: linear-gradient(180deg, var(--hns-surface) 0%, #141416 100%);
  border: 1px solid var(--hns-border);
  border-radius: 18px;
  box-shadow: 0 24px 64px -12px rgba(0, 0, 0, 0.6);
  padding: var(--hns-space-5);
  color: var(--hns-ink);
  z-index: var(--hns-z-modal);
  transform: translateY(12px) scale(0.98);
  opacity: 0;
  transition: transform 0.3s var(--hns-ease-out), opacity 0.3s var(--hns-ease-out);
}

.hns-deal-modal-backdrop.is-open .hns-deal-modal {
  transform: translateY(0) scale(1);
  opacity: 1;
}

.hns-deal-modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.08);
  color: var(--hns-ink-muted);
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.15s var(--hns-ease-out), color 0.15s var(--hns-ease-out);
}

.hns-deal-modal-close:hover,
.hns-deal-modal-close:focus-visible {
  background: rgba(255, 255, 255, 0.18);
  color: var(--hns-ink);
}

/* Eyebrow + title are grouped tight (one "read" unit); the sub gets a
   generous break before the form (the "act" unit) starts. */
.hns-deal-modal-eyebrow {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--hns-gold);
  margin: 0 0 var(--hns-space-1);
}

.hns-deal-modal-title {
  font-size: 20px;
  font-weight: 700;
  margin: 0 0 var(--hns-space-1);
  line-height: 1.25;
}

.hns-deal-modal-sub {
  font-size: 13px;
  color: var(--hns-ink-muted);
  margin: 0 0 var(--hns-space-5);
  line-height: 1.5;
}

.hns-deal-form {
  display: flex;
  flex-direction: column;
  gap: var(--hns-space-3);
}

.hns-deal-field {
  display: flex;
  flex-direction: column;
  gap: var(--hns-space-1);
}

.hns-deal-field label {
  font-size: 12px;
  font-weight: 600;
  color: var(--hns-ink-muted);
}

.hns-deal-field input {
  width: 100%;
  background: var(--hns-surface-raised);
  border: 1px solid var(--hns-border);
  border-radius: 9px;
  padding: 11px 13px;
  font-size: 14px;
  color: var(--hns-ink);
  transition: border-color 0.15s var(--hns-ease-out), background-color 0.15s var(--hns-ease-out);
  box-sizing: border-box;
}

.hns-deal-field input::placeholder {
  color: #78787c;
}

.hns-deal-field input:focus-visible {
  outline: none;
  border-color: var(--hns-orange);
  background: #28282b;
}

.hns-deal-field input[aria-invalid="true"] {
  border-color: var(--hns-red);
}

.hns-deal-field-error {
  font-size: 11.5px;
  color: var(--hns-red);
  min-height: 14px;
  margin: 0;
}

.hns-deal-form-error {
  font-size: 12.5px;
  color: var(--hns-red);
  background: rgba(255, 107, 107, 0.1);
  border: 1px solid rgba(255, 107, 107, 0.25);
  border-radius: 8px;
  padding: 9px 11px;
  margin: 2px 0 0;
  display: none;
}

.hns-deal-form-error.is-visible {
  display: block;
}

.hns-deal-submit {
  width: 100%;
  border: none;
  border-radius: 9px;
  padding: var(--hns-space-3) var(--hns-space-4);
  background: linear-gradient(180deg, #ff9a3d 0%, var(--hns-orange) 100%);
  color: #1a1200;
  font-size: 14.5px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: filter 0.15s var(--hns-ease-out), opacity 0.15s var(--hns-ease-out);
}

.hns-deal-submit:hover {
  filter: brightness(1.08);
}

.hns-deal-submit:disabled {
  opacity: 0.75;
  cursor: default;
}

.hns-deal-spinner {
  width: 15px;
  height: 15px;
  border-radius: 50%;
  border: 2px solid rgba(26, 18, 0, 0.35);
  border-top-color: #1a1200;
  animation: hns-spin 0.7s linear infinite;
  display: none;
}

.hns-deal-submit.is-loading .hns-deal-spinner {
  display: inline-block;
}

.hns-deal-submit.is-loading .hns-deal-submit-label {
  font-size: 0;
}

.hns-deal-submit.is-loading .hns-deal-submit-label::after {
  content: "Sending…";
  font-size: 14.5px;
}

.hns-deal-privacy {
  font-size: 11px;
  color: #85858a;
  text-align: center;
  margin: var(--hns-space-2) 0 0;
  line-height: 1.4;
}

/* Success state */
.hns-deal-success {
  display: none;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: var(--hns-space-3) var(--hns-space-1) var(--hns-space-1);
}

.hns-deal-modal.is-success .hns-deal-form,
.hns-deal-modal.is-success .hns-deal-modal-eyebrow,
.hns-deal-modal.is-success .hns-deal-modal-title,
.hns-deal-modal.is-success .hns-deal-modal-sub,
.hns-deal-modal.is-success .hns-deal-privacy {
  display: none;
}

.hns-deal-modal.is-success .hns-deal-success {
  display: flex;
}

.hns-deal-success-icon {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: rgba(74, 222, 128, 0.14);
  color: var(--hns-green);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  margin-bottom: var(--hns-space-3);
}

.hns-deal-success-title {
  font-size: 17px;
  font-weight: 700;
  margin: 0 0 var(--hns-space-1);
}

.hns-deal-success-sub {
  font-size: 13px;
  color: var(--hns-ink-muted);
  margin: 0;
  line-height: 1.5;
}

@media (prefers-reduced-motion: reduce) {
  .hns-deal-widget,
  .hns-deal-modal-backdrop,
  .hns-deal-modal,
  .hns-deal-cta,
  .hns-deal-close,
  .hns-deal-submit,
  .hns-deal-spinner {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}
