/*
 * Web-push soft-prompt banner — initiative 058.
 *
 * In-page opt-in banner shown to authenticated users whose notification
 * permission is still 'default'. The real browser prompt only fires on the
 * CTA click (a user gesture); this banner exists purely to raise opt-in.
 *
 * Theming is automatic: every colour is derived from the project's CSS custom
 * properties (--color-primary, --color-bg-primary, --color-text-primary, …),
 * which flip between dark (:root) and light (html[data-theme="light"]). No
 * theme-specific selectors needed here — the variables carry it.
 *
 * Show/hide is driven by web-push-register.js toggling the [hidden] attribute
 * and the .is-visible class; the class drives the entrance transition.
 */

.kc-wp-banner {
  position: fixed;
  z-index: 55; /* above bottom-nav (z-40), below toasts (z-60) and modals */
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  justify-content: center;
  pointer-events: none; /* the card re-enables pointer events */
}

.kc-wp-banner[hidden] {
  display: none;
}

.kc-wp-banner__card {
  pointer-events: auto;
  position: relative;
  box-sizing: border-box;
  width: 100%;
  display: flex;
  align-items: flex-start;
  gap: 0.875rem;
  padding: 1rem 1.125rem;
  /* Mobile: full-width bottom sheet, edge-to-edge, safe-area aware. The extra
     bottom clearance keeps the CTA off the home indicator on notched phones. */
  padding-bottom: calc(1.35rem + env(safe-area-inset-bottom));
  background: var(--color-bg-secondary, #121212);
  color: var(--color-text-primary, #fff);
  border-top: 1px solid var(--color-primary, #ff0050);
  box-shadow:
    0 -8px 30px rgba(0, 0, 0, 0.35),
    0 -1px 0 var(--color-glow, rgba(255, 0, 80, 0.15));

  /* Entrance: start translated down + transparent. */
  opacity: 0;
  transform: translateY(16px);
  transition:
    opacity 280ms cubic-bezier(0.16, 1, 0.3, 1),
    transform 320ms cubic-bezier(0.16, 1, 0.3, 1);
}

.kc-wp-banner.is-visible .kc-wp-banner__card {
  opacity: 1;
  transform: translateY(0);
}

/* Desktop: floating rounded card pinned to the bottom-right. */
@media (min-width: 768px) {
  .kc-wp-banner {
    justify-content: flex-end;
    padding: 0 1.25rem 1.25rem;
  }

  /* Desktop has room: restore the inline CTA + "Not now" row. */
  .kc-wp-banner__actions {
    flex-direction: row;
    align-items: center;
    gap: 0.625rem;
  }

  .kc-wp-banner__cta {
    width: auto;
  }

  .kc-wp-banner__dismiss {
    align-self: auto;
  }

  .kc-wp-banner__card {
    max-width: 440px;
    padding-bottom: 1.25rem;
    border: 1px solid color-mix(in srgb, var(--color-primary, #ff0050) 35%, transparent);
    border-radius: 16px;
    box-shadow:
      0 18px 50px rgba(0, 0, 0, 0.45),
      0 0 0 1px color-mix(in srgb, var(--color-primary, #ff0050) 12%, transparent),
      0 8px 40px color-mix(in srgb, var(--color-primary, #ff0050) 22%, transparent);
  }
}

/* Brand-tinted circular icon chip. */
.kc-wp-banner__chip {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  color: var(--color-primary, #ff0050);
  background: color-mix(in srgb, var(--color-primary, #ff0050) 16%, transparent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--color-primary, #ff0050) 30%, transparent);
}

.kc-wp-banner__chip svg {
  width: 22px;
  height: 22px;
}

.kc-wp-banner__body {
  flex: 1 1 auto;
  min-width: 0;
}

.kc-wp-banner__title {
  margin: 0;
  font-size: 0.975rem;
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -0.01em;
  color: var(--color-text-primary, #fff);
}

.kc-wp-banner__subtitle {
  margin: 0.25rem 0 0;
  font-size: 0.8125rem;
  line-height: 1.4;
  color: var(--color-text-secondary, #b0b0b0);
}

.kc-wp-banner__actions {
  /* Mobile-first: stack so the CTA is full-width + single-line (a side-by-side
     row squeezes "Enable notifications" into an ugly wrap at ~360px). */
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.5rem;
  margin-top: 0.875rem;
}

/* Primary CTA — filled hot-pink gradient. */
.kc-wp-banner__cta {
  flex: 1 1 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
  white-space: nowrap;
  min-height: 44px;
  padding: 0.5rem 1.1rem;
  border: 0;
  border-radius: 999px;
  font: inherit;
  font-size: 0.875rem;
  font-weight: 700;
  color: #fff;
  cursor: pointer;
  background: linear-gradient(
    135deg,
    var(--color-primary, #ff0050) 0%,
    color-mix(in srgb, var(--color-primary, #ff0050) 75%, #000) 100%
  );
  box-shadow: 0 4px 16px color-mix(in srgb, var(--color-primary, #ff0050) 40%, transparent);
  transition:
    transform 120ms ease,
    box-shadow 160ms ease,
    filter 160ms ease;
}

.kc-wp-banner__cta:hover {
  filter: brightness(1.06);
  box-shadow: 0 6px 22px color-mix(in srgb, var(--color-primary, #ff0050) 55%, transparent);
}

.kc-wp-banner__cta:active {
  transform: translateY(1px);
  box-shadow: 0 2px 10px color-mix(in srgb, var(--color-primary, #ff0050) 40%, transparent);
}

.kc-wp-banner__cta:disabled {
  cursor: default;
  opacity: 0.85;
  filter: none;
}

/* Quiet secondary "Not now". */
.kc-wp-banner__dismiss {
  flex: 0 0 auto;
  align-self: center; /* centered text button under the full-width CTA on mobile */
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0.5rem 1.25rem;
  border: 0;
  border-radius: 999px;
  background: transparent;
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--color-text-tertiary, #888);
  cursor: pointer;
  transition: color 140ms ease, background 140ms ease;
}

.kc-wp-banner__dismiss:hover {
  color: var(--color-text-primary, #fff);
  background: color-mix(in srgb, var(--color-text-primary, #fff) 8%, transparent);
}

/* Top-right × close. */
.kc-wp-banner__close {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--color-text-tertiary, #888);
  cursor: pointer;
  transition: color 140ms ease, background 140ms ease;
}

.kc-wp-banner__close:hover {
  color: var(--color-text-primary, #fff);
  background: color-mix(in srgb, var(--color-text-primary, #fff) 10%, transparent);
}

.kc-wp-banner__close svg {
  width: 15px;
  height: 15px;
}

/* Inline spinner shown on the CTA while subscribing. */
.kc-wp-banner__spinner {
  width: 15px;
  height: 15px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-top-color: #fff;
  animation: kc-wp-spin 0.7s linear infinite;
}

@keyframes kc-wp-spin {
  to {
    transform: rotate(360deg);
  }
}

/* Shared visible focus ring for keyboard users. */
.kc-wp-banner__cta:focus-visible,
.kc-wp-banner__dismiss:focus-visible,
.kc-wp-banner__close:focus-visible {
  outline: 2px solid var(--color-primary, #ff0050);
  outline-offset: 2px;
}

/* Success state — swap the chip + copy to a confirmation look. */
.kc-wp-banner.is-success .kc-wp-banner__chip {
  color: var(--color-success, #00ff88);
  background: color-mix(in srgb, var(--color-success, #00ff88) 16%, transparent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--color-success, #00ff88) 30%, transparent);
}

.kc-wp-banner__live {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* Respect reduced-motion: no transform animation, fade only, no spinner spin. */
@media (prefers-reduced-motion: reduce) {
  .kc-wp-banner__card {
    transform: none;
    transition: opacity 200ms ease;
  }

  .kc-wp-banner.is-visible .kc-wp-banner__card {
    transform: none;
  }

  .kc-wp-banner__spinner {
    animation: none;
  }
}
