/* ==========================================================================
   Browser Guard — styles
   Namespaced with `bg-guard-` so it can be dropped into ANY existing app
   without colliding with the host site's CSS. Colors/sizes are exposed as
   CSS custom properties on :root so the host app can re-theme without
   touching this file.
   ========================================================================== */

:root {
  --bg-guard-accent: var(--brand-primary, #1A73E8);
  --bg-guard-warn-bg: #fff3cd;
  --bg-guard-warn-border: #ffc107;
  --bg-guard-danger: #dc3545;
  --bg-guard-success: #28a745;
  --bg-guard-text: #1f2937;
  --bg-guard-radius: 12px;
  --bg-guard-z: 999999; /* sits above everything in the host app */
}

.bg-guard-hidden {
  display: none !important;
}

/* ---- Verifying overlay (shown for a beat on load while we check) ---- */
.bg-guard-verifying {
  position: fixed;
  inset: 0;
  z-index: var(--bg-guard-z);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #1a1a1a;
  color: #fff;
  transition: opacity 0.25s ease;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.bg-guard-spinner {
  width: 36px;
  height: 36px;
  border: 4px solid rgba(255, 255, 255, 0.15);
  border-left-color: #fff;
  border-radius: 50%;
  animation: bg-guard-spin 1s linear infinite;
  margin-bottom: 14px;
}

@keyframes bg-guard-spin {
  to { transform: rotate(360deg); }
}

.bg-guard-check svg {
  width: 36px;
  height: 36px;
  margin-bottom: 14px;
  color: var(--bg-guard-success);
}

/* ---- Unsupported-browser banner + full-screen blur/lock ---- */
.bg-guard-blur > *:not(.bg-guard-banner):not(.bg-guard-offline):not(.bg-guard-toast):not(.bg-guard-popup):not(.bg-guard-root) {
  filter: blur(6px);
  pointer-events: none;
  user-select: none;
}

.bg-guard-banner {
  position: fixed;
  inset: 0;
  z-index: var(--bg-guard-z);
  background: var(--bg-guard-warn-bg);
  border-bottom: 2px solid var(--bg-guard-warn-border);
  overflow-y: auto;
  padding: 20px 16px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.bg-guard-banner-inner {
  max-width: 600px;
  margin: 0 auto;
}

.bg-guard-banner-head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 14px;
}

.bg-guard-banner-icon {
  font-size: 26px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
}

.bg-guard-banner-icon svg {
  width: 28px;
  height: 28px;
  color: #856404;
}

.bg-guard-banner-title {
  display: block;
  font-size: 16px;
  font-weight: 700;
  color: var(--bg-guard-text);
  margin-bottom: 4px;
}

.bg-guard-banner-sub {
  font-size: 13px;
  color: #666;
  line-height: 1.4;
  margin: 0;
}

.bg-guard-detected {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--bg-guard-text);
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 8px;
  padding: 8px 12px;
  margin-bottom: 14px;
}

.bg-guard-detected svg,
.bg-guard-detected img {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.bg-guard-buttons {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 8px;
  margin-bottom: 14px;
}

.bg-guard-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 0;
  text-align: center;
  padding: 10px 12px;
  background: #fff;
  color: #1f2937;
  text-decoration: none;
  border-radius: 10px;
  border: 1.5px solid #e2e2e2;
  font-size: 13px;
  font-weight: 600;
  white-space: normal;
  line-height: 1.2;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
  transition: border-color 0.15s, transform 0.1s, background-color 0.15s;
  cursor: pointer;
}

.bg-guard-btn:hover {
  background: #f9fafb;
  border-color: #cbd5e1;
}

.bg-guard-btn:active {
  transform: scale(0.97);
}

.bg-guard-btn svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.bg-guard-icon-img {
  width: 20px;
  height: 20px;
  object-fit: contain;
  flex-shrink: 0;
}

.bg-guard-fallback {
  text-align: center;
  font-size: 12px;
  color: #666;
  border-top: 1px solid #ffeeba;
  padding-top: 10px;
}

.bg-guard-fallback .bg-guard-store-hint {
  margin-top: 8px;
  font-style: italic;
  color: #888;
}

.bg-guard-copy-btn {
  background: #fff;
  border: 1px solid var(--bg-guard-accent);
  color: var(--bg-guard-accent);
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.bg-guard-copy-btn:hover {
  background: var(--bg-guard-accent);
  color: #ffffff;
}

/* ---- Offline overlay ---- */
.bg-guard-offline {
  position: fixed;
  inset: 0;
  z-index: var(--bg-guard-z);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  text-align: center;
  background: rgba(15, 23, 42, 0.7);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.bg-guard-offline-card {
  max-width: 340px;
  width: 100%;
  background: #fff;
  border-radius: 20px;
  padding: 28px 22px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
  border: 1px solid #fecdd3;
}

.bg-guard-offline-card svg {
  width: 44px;
  height: 44px;
  margin: 0 auto 12px;
  color: var(--bg-guard-danger);
  display: block;
}

.bg-guard-offline-card h2 {
  margin: 8px 0;
  font-size: 18px;
  font-weight: 800;
  color: var(--bg-guard-text);
}

.bg-guard-offline-card p {
  font-size: 13px;
  color: #4b5563;
  line-height: 1.5;
  margin: 0;
}

/* ---- Toasts (online / slow connection) ---- */
.bg-guard-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-guard-success);
  color: #fff;
  padding: 10px 20px;
  border-radius: 9999px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
  z-index: var(--bg-guard-z);
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.bg-guard-toast svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.bg-guard-toast.bg-guard-slow {
  background: #d97706;
}

/* ---- Pop-up blocked banner (non-blocking, dismissible) ---- */
.bg-guard-popup {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  max-width: 92%;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-guard-warn-bg);
  border: 1px solid var(--bg-guard-warn-border);
  color: var(--bg-guard-text);
  padding: 10px 16px;
  border-radius: 12px;
  font-size: 13px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
  z-index: var(--bg-guard-z);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.bg-guard-popup svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  color: #b45309;
}

.bg-guard-popup-close {
  margin-left: 6px;
  background: none;
  border: none;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  color: #4b5563;
  padding: 2px 6px;
  border-radius: 4px;
}

.bg-guard-popup-close:hover {
  background: rgba(0, 0, 0, 0.05);
  color: #111827;
}

@media (max-width: 480px) {
  .bg-guard-banner-head {
    flex-direction: column;
  }
}
