/* ── Subscribe widget ───────────────────────────────
   Fixed bottom-right floating launcher that expands
   into a small dialog. Loaded on every public page
   except /dashboard. Markup is injected by subscribe.js.
*/

.sub-widget {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 9000;
  font-family: var(--font-sans, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif);
  pointer-events: none;
}

.sub-widget > * {
  pointer-events: auto;
}

/* ── Launcher ───────────────────────────────────── */

.sub-widget-trigger {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  height: 52px;
  padding: 0 18px 0 16px;
  border-radius: 999px;
  border: 0;
  background: var(--ink, #0c0c0e);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.005em;
  cursor: pointer;
  box-shadow: 0 12px 28px -12px rgba(0, 0, 0, 0.55), 0 2px 6px -2px rgba(0, 0, 0, 0.3);
  transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

.sub-widget-trigger:hover {
  transform: translateY(-1px);
  background: #000;
  box-shadow: 0 16px 32px -12px rgba(0, 0, 0, 0.65), 0 2px 8px -2px rgba(0, 0, 0, 0.4);
}

.sub-widget-trigger:focus-visible {
  outline: 2px solid var(--accent, #4a9eff);
  outline-offset: 2px;
}

.sub-widget-trigger svg {
  flex-shrink: 0;
}

.sub-widget-pulse {
  position: absolute;
  top: -3px;
  right: -3px;
  width: 12px;
  height: 12px;
  border-radius: 999px;
  background: var(--positive, #22c55e);
  box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.55);
  animation: sub-pulse 2.4s ease-out infinite;
}

@keyframes sub-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.55); }
  70%  { box-shadow: 0 0 0 10px rgba(34, 197, 94, 0); }
  100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); }
}

/* ── Panel ──────────────────────────────────────── */

.sub-widget-panel {
  position: absolute;
  right: 0;
  bottom: 64px;
  width: min(340px, calc(100vw - 40px));
  display: grid;
  gap: 14px;
  padding: 22px 20px 18px;
  border-radius: 16px;
  background: #ffffff;
  color: #111;
  border: 1px solid rgba(0, 0, 0, 0.08);
  box-shadow: 0 24px 60px -16px rgba(0, 0, 0, 0.35), 0 4px 14px -4px rgba(0, 0, 0, 0.18);
  transform-origin: bottom right;
  animation: sub-pop 0.22s ease-out;
}

@keyframes sub-pop {
  0%   { transform: scale(0.92) translateY(8px); opacity: 0; }
  100% { transform: scale(1) translateY(0); opacity: 1; }
}

@media (prefers-color-scheme: dark) {
  .sub-widget-panel {
    background: #101012;
    color: #f5f5f7;
    border-color: rgba(255, 255, 255, 0.08);
  }
}

.sub-widget-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.sub-widget-title {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.2;
}

.sub-widget-close {
  background: transparent;
  border: 0;
  color: inherit;
  opacity: 0.55;
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  cursor: pointer;
  font-size: 22px;
  line-height: 1;
  transition: opacity 0.15s ease, background 0.15s ease;
}

.sub-widget-close:hover {
  opacity: 1;
  background: rgba(0, 0, 0, 0.06);
}

@media (prefers-color-scheme: dark) {
  .sub-widget-close:hover { background: rgba(255, 255, 255, 0.08); }
}

.sub-widget-body {
  margin: 0;
  font-size: 13.5px;
  line-height: 1.5;
  opacity: 0.78;
}

.sub-widget-form {
  display: grid;
  gap: 8px;
}

.sub-widget-input {
  width: 100%;
  height: 44px;
  padding: 0 14px;
  border-radius: 10px;
  border: 1px solid rgba(0, 0, 0, 0.14);
  background: rgba(0, 0, 0, 0.03);
  color: inherit;
  font: inherit;
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s ease, background 0.15s ease;
}

@media (prefers-color-scheme: dark) {
  .sub-widget-input {
    background: rgba(255, 255, 255, 0.04);
    border-color: rgba(255, 255, 255, 0.12);
  }
}

.sub-widget-input::placeholder { opacity: 0.5; }

.sub-widget-input:focus {
  border-color: #111;
  background: #fff;
}

@media (prefers-color-scheme: dark) {
  .sub-widget-input:focus {
    border-color: #f5f5f7;
    background: rgba(255, 255, 255, 0.06);
  }
}

.sub-widget-submit {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 44px;
  width: 100%;
  border: 0;
  border-radius: 10px;
  background: #0c0c0e;
  color: #fff;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.005em;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease;
}

@media (prefers-color-scheme: dark) {
  .sub-widget-submit {
    background: #f5f5f7;
    color: #0c0c0e;
  }
}

.sub-widget-submit:hover { transform: translateY(-1px); }
.sub-widget-submit:disabled { opacity: 0.55; cursor: progress; transform: none; }

.sub-widget-arrow {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 15px;
}

.sub-widget-status {
  margin: 4px 0 0;
  min-height: 16px;
  font-size: 12.5px;
  line-height: 1.4;
  opacity: 0.8;
}

.sub-widget-status[data-state="error"] { color: #c62828; opacity: 1; }
.sub-widget-status[data-state="success"] { color: #1b9b51; opacity: 1; font-weight: 600; }

.sub-widget-foot {
  margin: 0;
  font-size: 11.5px;
  line-height: 1.4;
  opacity: 0.55;
}

/* ── Success state ──────────────────────────────── */

.sub-widget-success {
  display: grid;
  gap: 10px;
  padding: 12px 0 4px;
  text-align: center;
}

.sub-widget-success-icon {
  display: block;
  margin: 0 auto;
  width: 44px;
  height: 44px;
  border-radius: 999px;
  background: var(--positive-soft, rgba(34, 197, 94, 0.18));
  color: var(--positive, #16a34a);
  display: grid;
  place-items: center;
  font-size: 22px;
  font-weight: 700;
}

.sub-widget-success-title {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.005em;
}

.sub-widget-success-body {
  margin: 0;
  font-size: 13px;
  line-height: 1.5;
  opacity: 0.7;
}

/* ── Mobile ─────────────────────────────────────── */

@media (max-width: 480px) {
  .sub-widget {
    right: 12px;
    bottom: 12px;
  }
  .sub-widget-trigger {
    height: 48px;
    padding: 0 16px 0 14px;
    font-size: 13.5px;
  }
  .sub-widget-panel {
    bottom: 60px;
    padding: 18px 16px 14px;
    width: calc(100vw - 24px);
    max-width: 340px;
  }
  .sub-widget-title { font-size: 15.5px; }
  .sub-widget-body { font-size: 13px; }
}

@media (prefers-reduced-motion: reduce) {
  .sub-widget-pulse { animation: none; }
  .sub-widget-panel { animation: none; }
  .sub-widget-trigger,
  .sub-widget-submit { transition: none; }
  .sub-widget-trigger:hover,
  .sub-widget-submit:hover { transform: none; }
}
