/*
 * Guide Gate — shared popup overlay for /guide/ and /sourcing-guide/
 *
 * Activated by /assets/guide-gate.js when no confirmed-token is found
 * in localStorage. Blurs the guide content underneath, locks scroll,
 * and asks for email. Dismisses itself after Acumbamail confirmation
 * round-trip (?confirmed=1 in URL).
 *
 * Uses the same design tokens as the host page (set on :root in each
 * guide's <style>), so theme toggle (dark/light) propagates here.
 */

/* === Body lock (set by JS) ============================================= */
body.qg-locked {
  overflow: hidden !important;
  /* Keep scrollbar gutter to prevent layout shift when lock applies */
  scrollbar-gutter: stable;
}

/* === Blurred guide content behind the popup =========================== */
body.qg-locked .qg-blurred {
  filter: blur(8px) saturate(0.9) brightness(1.05);
  pointer-events: none;
  user-select: none;
  transition: filter 0.25s ease;
}

[data-theme="light"] body.qg-locked .qg-blurred {
  filter: blur(8px) saturate(0.85) brightness(0.97);
}

/* === Overlay backdrop =================================================
   Dark mode: very light tint so the blurred content stays visible
   (dark content under a dark overlay disappears entirely). The popup's
   drop-shadow + the content blur do the lock-signaling work, not the
   overlay opacity.
   Light mode: deeper purple tint for contrast against the light page.
*/
.qg-overlay {
  position: fixed;
  inset: 0;
  background: radial-gradient(ellipse at center,
    rgba(26, 14, 46, 0.55) 0%,
    rgba(11, 15, 31, 0.78) 100%);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  z-index: 9000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  opacity: 0;
  animation: qg-fade-in 0.3s ease forwards;
}

[data-theme="light"] .qg-overlay {
  background: radial-gradient(ellipse at center,
    rgba(46, 16, 101, 0.40) 0%,
    rgba(46, 16, 101, 0.65) 100%);
}

@keyframes qg-fade-in {
  to { opacity: 1; }
}

/* === Popup card ====================================================== */
.qg-popup {
  position: relative;
  max-width: 520px;
  width: 100%;
  background: var(--bg-panel, #1A0E2E);
  border: 1px solid var(--border-strong, rgba(196, 74, 255, 0.28));
  border-radius: 20px;
  padding: 40px 36px 32px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.5),
              0 0 0 1px rgba(196, 74, 255, 0.12);
  font-family: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  color: var(--text, #f5f3ff);
  transform: translateY(12px) scale(0.98);
  opacity: 0;
  animation: qg-pop-in 0.35s cubic-bezier(0.2, 0.8, 0.2, 1) 0.1s forwards;
  max-height: calc(100vh - 48px);
  overflow-y: auto;
}

[data-theme="light"] .qg-popup {
  background: #ffffff;
  border-color: var(--border-strong, rgba(164, 2, 247, 0.3));
  box-shadow: 0 24px 64px rgba(46, 16, 101, 0.22),
              0 0 0 1px rgba(164, 2, 247, 0.1);
}

@keyframes qg-pop-in {
  to {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
}

/* === Eyebrow / category label ======================================== */
.qg-eyebrow {
  font-family: 'IBM Plex Mono', 'SF Mono', Menlo, monospace;
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--qiklists-glow, #D279FF);
  font-weight: 600;
  margin-bottom: 12px;
}

[data-theme="light"] .qg-eyebrow {
  color: var(--qiklists, #A402F7);
}

/* === Title ============================================================ */
.qg-title {
  font-size: 26px;
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: -0.02em;
  margin: 0 0 8px;
  color: var(--text, #f5f3ff);
}

[data-theme="light"] .qg-title {
  color: var(--text, #2e1065);
}

.qg-subtitle {
  font-size: 15px;
  color: var(--text-dim, #c4b5fd);
  line-height: 1.5;
  margin: 0 0 20px;
}

[data-theme="light"] .qg-subtitle {
  color: var(--text-dim, #6b21a8);
}

/* === Bullets ========================================================= */
.qg-bullets {
  list-style: none;
  padding: 0;
  margin: 0 0 24px;
}

.qg-bullets li {
  position: relative;
  padding: 8px 0 8px 28px;
  font-size: 14.5px;
  line-height: 1.5;
  color: var(--text, #f5f3ff);
  border-bottom: 1px dashed var(--border-soft, rgba(196, 74, 255, 0.15));
}

.qg-bullets li:last-child {
  border-bottom: none;
}

.qg-bullets li::before {
  content: '✓';
  position: absolute;
  left: 0;
  top: 8px;
  color: var(--qiklists-glow, #D279FF);
  font-weight: 700;
  font-size: 16px;
}

[data-theme="light"] .qg-bullets li::before {
  color: var(--qiklists, #A402F7);
}

/* === Form ============================================================ */
.qg-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 14px;
}

.qg-input {
  width: 100%;
  padding: 14px 16px;
  font-size: 16px;
  font-family: inherit;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-strong, rgba(196, 74, 255, 0.28));
  border-radius: 10px;
  color: var(--text, #f5f3ff);
  transition: border-color 0.15s, background 0.15s;
  box-sizing: border-box;
}

[data-theme="light"] .qg-input {
  background: rgba(164, 2, 247, 0.04);
  color: var(--text, #2e1065);
}

.qg-input::placeholder {
  color: var(--text-faint, #8b7ec8);
}

.qg-input:focus {
  outline: none;
  border-color: var(--qiklists, #A402F7);
  background: rgba(255, 255, 255, 0.06);
}

[data-theme="light"] .qg-input:focus {
  background: rgba(164, 2, 247, 0.06);
}

.qg-submit {
  width: 100%;
  padding: 14px 20px;
  font-size: 16px;
  font-weight: 700;
  font-family: inherit;
  color: white;
  background: linear-gradient(135deg, var(--qiklists, #A402F7), var(--qiklists-bright, #C44AFF));
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s, opacity 0.15s;
  box-shadow: 0 8px 24px rgba(164, 2, 247, 0.35);
}

.qg-submit:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 12px 32px rgba(164, 2, 247, 0.45);
}

.qg-submit:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

/* === Microcopy + magic link ========================================== */
.qg-microcopy {
  font-size: 12px;
  color: var(--text-faint, #8b7ec8);
  text-align: center;
  line-height: 1.5;
  margin: 0 0 10px;
}

/* === "Already signed up?" collapsible helper ========================
   Native <details>/<summary> dropdown shown under the form. Closed by
   default so the popup stays compact. Expands to show two recovery
   paths: find the original email, or use a different email.
*/
.qg-already-details {
  margin-top: 14px;
  border: 1px solid var(--border-soft, rgba(196, 74, 255, 0.15));
  border-radius: 10px;
  background: rgba(164, 2, 247, 0.06);
  overflow: hidden;
}

[data-theme="light"] .qg-already-details {
  background: rgba(164, 2, 247, 0.04);
}

.qg-already-summary {
  cursor: pointer;
  padding: 12px 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text, #f5f3ff);
  list-style: none;
  user-select: none;
  position: relative;
  padding-right: 36px;
  line-height: 1.4;
  transition: background 0.15s;
}

.qg-already-summary:hover {
  background: rgba(164, 2, 247, 0.08);
}

[data-theme="light"] .qg-already-summary {
  color: var(--text, #2e1065);
}

[data-theme="light"] .qg-already-summary:hover {
  background: rgba(164, 2, 247, 0.06);
}

/* Hide native disclosure triangle (Webkit + Firefox) */
.qg-already-summary::-webkit-details-marker { display: none; }
.qg-already-summary::marker { content: ''; }

/* Custom chevron */
.qg-already-summary::after {
  content: '▾';
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 12px;
  color: var(--qiklists-glow, #D279FF);
  transition: transform 0.2s;
}

[data-theme="light"] .qg-already-summary::after {
  color: var(--qiklists, #A402F7);
}

.qg-already-details[open] .qg-already-summary::after {
  transform: translateY(-50%) rotate(180deg);
}

.qg-already-body {
  padding: 4px 14px 14px;
  border-top: 1px solid var(--border-soft, rgba(196, 74, 255, 0.15));
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-dim, #c4b5fd);
}

[data-theme="light"] .qg-already-body {
  color: var(--text-dim, #6b21a8);
}

.qg-already-step {
  margin: 10px 0 0;
}

.qg-already-step strong {
  color: var(--text, #f5f3ff);
  font-weight: 700;
}

[data-theme="light"] .qg-already-step strong {
  color: var(--text, #2e1065);
}

.qg-search-subject {
  display: inline-block;
  font-family: 'IBM Plex Mono', 'SF Mono', Menlo, monospace;
  font-size: 12px;
  padding: 4px 10px;
  background: rgba(164, 2, 247, 0.18);
  color: var(--qiklists-glow, #D279FF);
  border-radius: 4px;
  margin-top: 6px;
  word-break: break-word;
  user-select: all;
}

[data-theme="light"] .qg-search-subject {
  background: rgba(164, 2, 247, 0.12);
  color: var(--qiklists, #A402F7);
}

/* === Status messages (success / error / pending) ===================== */
.qg-status {
  font-size: 14px;
  line-height: 1.5;
  padding: 12px 14px;
  border-radius: 10px;
  margin-bottom: 14px;
  display: none;
}

.qg-status.show {
  display: block;
}

.qg-status.success {
  background: rgba(15, 157, 88, 0.12);
  border: 1px solid rgba(15, 157, 88, 0.35);
  color: #6ee7b7;
}

[data-theme="light"] .qg-status.success {
  color: #047857;
  background: rgba(15, 157, 88, 0.08);
}

.qg-status.error {
  background: rgba(220, 38, 38, 0.12);
  border: 1px solid rgba(220, 38, 38, 0.35);
  color: #fca5a5;
}

[data-theme="light"] .qg-status.error {
  color: #b91c1c;
  background: rgba(220, 38, 38, 0.08);
}

.qg-status.info {
  background: rgba(164, 2, 247, 0.10);
  border: 1px solid rgba(164, 2, 247, 0.30);
  color: var(--text, #f5f3ff);
}

[data-theme="light"] .qg-status.info {
  color: var(--text, #2e1065);
}

/* === Confirmed banner (after returning from email link) ============== */
.qg-confirmed-banner {
  position: fixed;
  top: 70px;
  left: 50%;
  transform: translateX(-50%);
  background: linear-gradient(135deg, #0F9D58, #047857);
  color: white;
  padding: 12px 22px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  font-family: 'IBM Plex Sans', sans-serif;
  box-shadow: 0 10px 32px rgba(15, 157, 88, 0.35);
  z-index: 8000;
  animation: qg-banner-in 0.4s ease, qg-banner-out 0.4s ease 4.6s forwards;
  letter-spacing: 0.02em;
}

@keyframes qg-banner-in {
  from { opacity: 0; transform: translate(-50%, -16px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

@keyframes qg-banner-out {
  to { opacity: 0; transform: translate(-50%, -16px); }
}

/* === Responsive (phones) ============================================ */
@media (max-width: 540px) {
  .qg-popup {
    padding: 32px 24px 24px;
    border-radius: 16px;
    max-height: calc(100vh - 24px);
  }
  .qg-title { font-size: 22px; }
  .qg-bullets li { font-size: 14px; }
}
