/* ============================================================
   FOLD-GATE — inline email-capture overlay used everywhere
   content is gated (reader past ch 3, wiki past ch 2, the map).
   Paper-tone aesthetic to feel like a colony intake form, not
   a marketing popup. Always sits at the top of the z-stack.
   ============================================================ */

body.fg-open { overflow: hidden; }

.fg-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 40px 16px;
  overflow-y: auto;
  opacity: 0;
  transition: opacity 0.32s cubic-bezier(0.22, 1, 0.36, 1);
}
/* Center the card on tall viewports (when nothing scrolls), top-align on
   short viewports so the form is always reachable. */
@media (min-height: 760px) {
  .fg-overlay { align-items: center; }
}
.fg-overlay.fg-in { opacity: 1; }

.fg-backdrop {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse at 50% 30%, rgba(139,58,47,0.18), transparent 60%),
    rgba(6, 14, 16, 0.78);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  cursor: pointer;
}

.fg-card {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 460px;
  padding: 36px 32px 28px;
  background:
    radial-gradient(ellipse at 50% 0%, rgba(139,58,47,0.06), transparent 60%),
    #f4efe1;
  border: 1px solid rgba(45,40,32,0.18);
  border-top: 2px solid #1a1a1a;
  border-bottom: 2px solid #1a1a1a;
  border-radius: 2px;
  box-shadow: 0 24px 60px rgba(0,0,0,0.5);
  transform: translateY(12px);
  transition: transform 0.32s cubic-bezier(0.22, 1, 0.36, 1);
  font-family: Georgia, "Times New Roman", serif;
  color: #1a1a1a;
  line-height: 1.6;
}
.fg-overlay.fg-in .fg-card { transform: none; }

.fg-eyebrow {
  font-family: ui-monospace, "SF Mono", Menlo, Monaco, Consolas, monospace;
  font-size: 11px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: #8b3a2f;
  margin-bottom: 14px;
}
.fg-heading {
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 400;
  font-size: clamp(1.4rem, 3.5vw, 1.7rem);
  line-height: 1.2;
  color: #1a1a1a;
  margin: 0 0 14px;
}
.fg-body {
  font-family: Georgia, serif;
  font-size: 1rem;
  line-height: 1.6;
  color: #2d2820;
  margin: 0 0 24px;
}

/* ── Discord button (preferred path) ── */
.fg-discord-btn {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 13px 20px;
  background: #5865F2;
  border: 1px solid #5865F2;
  color: #fff;
  font-family: ui-monospace, monospace;
  font-size: 0.72rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-weight: 600;
  border-radius: 2px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}
.fg-discord-btn:hover  { background: #4752c4; border-color: #4752c4; }
.fg-discord-btn:active { transform: translateY(1px); }
.fg-discord-btn:focus-visible { outline: 2px solid #5865F2; outline-offset: 3px; }
.fg-discord-icon {
  font-size: 1rem;
  line-height: 1;
  transform: translateY(-1px);
}

.fg-or {
  position: relative;
  text-align: center;
  margin: 22px 0 6px;
  font-family: ui-monospace, monospace;
  font-size: 0.6rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: #8a826f;
}
.fg-or::before, .fg-or::after {
  content: "";
  position: absolute;
  top: 50%;
  width: 36%;
  height: 1px;
  background: rgba(45,40,32,0.18);
}
.fg-or::before { left: 0; }
.fg-or::after  { right: 0; }
.fg-or span { background: transparent; padding: 0 6px; }
@media (prefers-color-scheme: dark) {
  .fg-or::before, .fg-or::after { background: rgba(232,227,214,0.16); }
}

/* ── Discord callback banner (visible during the round-trip) ── */
.fg-discord-banner {
  position: fixed;
  top: 18px;
  left: 50%;
  transform: translate(-50%, -12px);
  z-index: 10001;
  padding: 12px 22px;
  background: #5865F2;
  color: #fff;
  font-family: ui-monospace, monospace;
  font-size: 0.66rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  border-radius: 30px;
  box-shadow: 0 12px 32px rgba(0,0,0,0.4);
  opacity: 0;
  transition: opacity 0.2s, transform 0.2s;
}
.fg-discord-banner.fg-discord-banner--in { opacity: 1; transform: translate(-50%, 0); }
.fg-discord-banner.fg-discord-banner--error { background: #c72f63; }

/* ── Form ── */
.fg-form { display: flex; flex-direction: column; gap: 4px; }
.fg-label {
  font-family: ui-monospace, monospace;
  font-size: 0.66rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: #6b6358;
  margin: 14px 0 6px;
}
.fg-label .req { color: #8b3a2f; margin-left: 4px; }
.fg-input {
  width: 100%;
  background: #fbf8f2;
  border: 1px solid rgba(45,40,32,0.25);
  border-radius: 2px;
  padding: 11px 13px;
  color: #1a1a1a;
  font-family: Georgia, serif;
  font-size: 1rem;
  line-height: 1.4;
  transition: border-color 0.15s, background 0.15s;
}
.fg-input::placeholder { color: rgba(107,99,88,0.6); }
.fg-input:hover  { border-color: rgba(45,40,32,0.5); }
.fg-input:focus  {
  outline: none;
  border-color: #8b3a2f;
  background: #fffdf6;
  box-shadow: 0 0 0 3px rgba(139,58,47,0.1);
}

/* ── Reader-state radio pills (matches /enter form structure) ── */
.fg-state { border: none; padding: 0; margin: 10px 0 0; }
.fg-state legend.fg-label { padding: 0; }
.fg-state-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
}
.fg-pill {
  display: inline-flex;
  align-items: center;
  padding: 8px 12px;
  border: 1px solid rgba(45,40,32,0.25);
  border-radius: 2px;
  background: #fbf8f2;
  font-family: Georgia, serif;
  font-size: 0.92rem;
  color: #2d2820;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
}
.fg-pill:hover { border-color: rgba(45,40,32,0.5); }
.fg-pill input[type="radio"] {
  position: absolute;
  opacity: 0;
  width: 1px; height: 1px;
  pointer-events: none;
}
.fg-pill:has(input:checked) {
  background: #1a1a1a;
  border-color: #1a1a1a;
  color: #fbf8f2;
}
.fg-pill input:focus-visible + span {
  outline: 2px solid #8b3a2f;
  outline-offset: 3px;
}
@media (prefers-color-scheme: dark) {
  .fg-pill {
    background: #0f0d0b;
    border-color: rgba(232,227,214,0.22);
    color: #e8e3d6;
  }
  .fg-pill:hover { border-color: rgba(232,227,214,0.5); }
  .fg-pill:has(input:checked) {
    background: #d97559;
    border-color: #d97559;
    color: #1a1815;
  }
}

.fg-submit {
  margin-top: 22px;
  width: 100%;
  padding: 13px 22px;
  background: #1a1a1a;
  border: 1px solid #1a1a1a;
  color: #fbf8f2;
  font-family: ui-monospace, monospace;
  font-size: 0.72rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  font-weight: 500;
  border-radius: 2px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}
.fg-submit:hover  { background: #8b3a2f; border-color: #8b3a2f; }
.fg-submit:active { transform: translateY(1px); }
.fg-submit:focus-visible { outline: 2px solid #8b3a2f; outline-offset: 3px; }
.fg-submit[disabled] {
  background: rgba(26,26,26,0.5);
  border-color: rgba(26,26,26,0.5);
  cursor: not-allowed;
}

.fg-status {
  min-height: 22px;
  margin-top: 14px;
  font-family: ui-monospace, monospace;
  font-size: 0.66rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  text-align: center;
}
.fg-status[data-tone="loading"] { color: #6b6358; }
.fg-status[data-tone="error"]   { color: #c72f63; }
.fg-status[data-tone="success"] { color: #4f7f57; }

/* Second OR separator — sits between the signup form and the skip option,
   so the soft-gate escape has its own visual lane. */
.fg-or--escape { margin: 26px 0 12px; }

/* Skip — soft-gate opt-out. Bigger and clearer than the dismiss link
   below it, so returning citizens don't feel like they have to type
   their email again. Sentence-case serif for readability; ember on hover. */
.fg-skip {
  display: block;
  margin: 0 auto 14px;
  background: none;
  border: none;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 0.96rem;
  font-weight: 500;
  letter-spacing: 0.01em;
  text-transform: none;
  color: #1a1a1a;
  cursor: pointer;
  text-decoration: underline;
  text-decoration-color: rgba(26,26,26,0.5);
  text-underline-offset: 3px;
  padding: 6px 8px;
  transition: color 0.15s, text-decoration-color 0.15s;
}
.fg-skip:hover {
  color: #8b3a2f;
  text-decoration-color: #8b3a2f;
}
.fg-skip:focus-visible { outline: 2px solid #8b3a2f; outline-offset: 3px; }

/* Dismiss — quieter than skip. "I want to leave" rather than "I'm already in". */
.fg-dismiss {
  display: block;
  margin: 0 auto;
  background: none;
  border: none;
  font-family: ui-monospace, monospace;
  font-size: 0.6rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: #8a826f;
  cursor: pointer;
  text-decoration: underline;
  text-decoration-color: rgba(138,130,111,0.4);
  padding: 4px 6px;
}
.fg-dismiss:hover { color: #1a1a1a; }

.fg-frequency {
  font-family: Georgia, serif;
  font-style: italic;
  font-size: 0.82rem;
  color: #8a826f;
  text-align: center;
  margin: 14px 0 0;
}

/* ── Success state — citizen ID reveal ── */
.fg-id-card {
  position: relative;
  border: 1px solid rgba(45,40,32,0.18);
  border-radius: 2px;
  padding: 22px 18px;
  background: #efe9dd;
  text-align: center;
  margin: 6px 0 18px;
}
.fg-id-card::before {
  content: "✓ ISSUED";
  position: absolute;
  top: -10px;
  left: 50%;
  transform: translateX(-50%);
  background: #4f7f57;
  color: #f4efe1;
  font-family: ui-monospace, monospace;
  font-size: 0.58rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 2px;
}
.fg-id-label {
  font-family: ui-monospace, monospace;
  font-size: 0.6rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: #6b6358;
  margin-bottom: 8px;
}
.fg-id {
  font-family: ui-monospace, monospace;
  font-size: clamp(1.2rem, 4vw, 1.6rem);
  font-weight: 500;
  letter-spacing: 0.08em;
  color: #1a1a1a;
}
.fg-success-note {
  text-align: center;
  font-style: italic;
  color: #4f7f57;
  margin-bottom: 0;
}

/* ── Inline "locked" surface that each gated page can render
   in place of the gated content. Triggers the gate when clicked. ── */
.fg-lock {
  border: 1px dashed rgba(244,234,217,0.28);
  border-radius: 4px;
  padding: 36px 28px;
  text-align: center;
  background: rgba(6,22,25,0.45);
  margin: 28px auto;
  max-width: 540px;
}
.fg-lock-eyebrow {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 0.62rem;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: #e94a7c;
  margin-bottom: 14px;
}
.fg-lock-heading {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-weight: 300;
  font-size: clamp(1.4rem, 3vw, 1.9rem);
  line-height: 1.2;
  color: #f4ead9;
  margin: 0 0 12px;
}
.fg-lock-body {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-style: italic;
  color: #f4ead9;
  font-size: 1.25rem;
  line-height: 1.6;
  margin: 0 0 28px;
  max-width: 480px;
  margin-left: auto;
  margin-right: auto;
}
.fg-lock-cta {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 13px 24px;
  background: #e94a7c;
  border: 1px solid #e94a7c;
  color: #2a0814;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 0.72rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-weight: 500;
  border-radius: 3px;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s;
}
.fg-lock-cta:hover { background: #c72f63; border-color: #c72f63; }

@media (max-width: 520px) {
  .fg-card { padding: 28px 22px 22px; }
  .fg-heading { font-size: 1.3rem; }
  .fg-lock { padding: 28px 20px; }
}

/* Dark scheme support for the paper card (matches the email template) */
@media (prefers-color-scheme: dark) {
  .fg-card {
    background:
      radial-gradient(ellipse at 50% 0%, rgba(217,117,89,0.10), transparent 60%),
      #1a1815;
    border-color: rgba(232,227,214,0.18);
    border-top-color: #d97559;
    border-bottom-color: #d97559;
    color: #e8e3d6;
  }
  .fg-eyebrow { color: #d97559; }
  .fg-heading, .fg-body { color: #f0ead9; }
  .fg-label   { color: #8f8676; }
  .fg-input   { background: #0f0d0b; border-color: rgba(232,227,214,0.18); color: #e8e3d6; }
  .fg-input::placeholder { color: rgba(143,134,118,0.6); }
  .fg-input:focus { background: #14110f; }
  .fg-submit { background: #d97559; border-color: #d97559; color: #1a1815; }
  .fg-submit:hover { background: #c25c43; border-color: #c25c43; }
  .fg-id-card { background: #14110f; }
  .fg-id-label, .fg-dismiss, .fg-frequency { color: #8f8676; }
  .fg-dismiss:hover { color: #f0ead9; }
  /* Skip stays bright in dark mode so it doesn't lose the visual weight
     we just added; ember tint on hover for consistency with light mode. */
  .fg-skip {
    color: #f0ead9;
    text-decoration-color: rgba(240,234,217,0.5);
  }
  .fg-skip:hover {
    color: #d97559;
    text-decoration-color: #d97559;
  }
  .fg-id { color: #f0ead9; }
}

@media (prefers-reduced-motion: reduce) {
  .fg-overlay, .fg-card { transition: none; }
}
