/* ═══════════════════════════════════════════════
   BASE — Variables, reset, body, typography
   Shared across all pages of the Letterverse
   ═══════════════════════════════════════════════ */

:root {
  --bg-deep: #06060e;
  --bg: #0a0a14;
  --bg-elevated: #0f0f1e;
  --bg-code: #0c0c18;
  --text: #ddd5c4;
  --text-dim: #9e9684;
  --text-bright: #f0e8d8;
  --gold: #c9a96e;
  --gold-bright: #e4c98a;
  --gold-dim: #8b6914;
  --gold-glow: rgba(201, 169, 110, 0.12);
  --sacred: rgba(201, 169, 110, 0.08);
  --border: #1e1e30;
  --border-subtle: #16162a;
  --accent-crimson: #8b3a3a;
  --sidebar-w: 300px;
  --content-max: 72ch;
  --font-body: 'Crimson Pro', 'Georgia', serif;
  --font-heading: 'Cormorant Garamond', 'Palatino', serif;
  /* Playfair Display — grand editorial serif for hero titles and book covers */
  --font-display: 'Playfair Display', 'Palatino', serif;
  /* Ubuntu — humanist sans designed with African language support as a core goal
     (Ubuntu = Nguni Bantu: "I am because we are"). Clean, warm, purpose-built. */
  --font-ui: 'Ubuntu', system-ui, sans-serif;
  --font-code: 'JetBrains Mono', 'Consolas', monospace;
  /* Aliases for compatibility */
  --font-mono: 'JetBrains Mono', 'Consolas', monospace;
  --surface: #0f0f1e; /* same as --bg-elevated */
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }

html {
  scroll-behavior: smooth;
  scrollbar-width: thin;
  scrollbar-color: var(--gold-dim) var(--bg);
  overflow-x: hidden;
  max-width: 100vw;
}
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--gold-dim); border-radius: 3px; }

body {
  font-family: var(--font-body);
  font-size: var(--font-size, 19px);
  line-height: var(--line-height, 1.85);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  max-width: 100vw;
  overflow-wrap: break-word;
  word-wrap: break-word;
  min-height: 100vh;
}

::selection { background: var(--gold); color: var(--bg-deep); }

@keyframes heroIn {
  to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
  to { opacity: 1; }
}

.footer {
  text-align: center;
  padding: 2rem;
  font-family: var(--font-body);
  font-size: 0.8rem;
  color: var(--text-dim);
  font-style: italic;
  position: relative;
  z-index: 1;
}

.footer a { color: var(--gold-dim); text-decoration: none; transition: color 0.2s; }
.footer a:hover { color: var(--gold); }

/* ═══════════════════════════════════════════════
   SKELETON — Loading placeholders
   Visible instantly from CSS, no JS required.
   Replaced by real content when app boots.
   ═══════════════════════════════════════════════ */
@keyframes shimmer {
  to { background-position: -200% 0; }
}

.skeleton-card {
  height: 280px;
  border-radius: 16px;
  background: linear-gradient(90deg,
    var(--bg-elevated, #0f0f1e) 25%,
    rgba(255,255,255,0.03) 50%,
    var(--bg-elevated, #0f0f1e) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
  border: 1px solid var(--border, #1e1e30);
}

.skeleton-line {
  height: 1em;
  border-radius: 4px;
  margin-bottom: 0.5em;
  background: linear-gradient(90deg,
    var(--border, #1e1e30) 25%,
    rgba(255,255,255,0.04) 50%,
    var(--border, #1e1e30) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
}

/* ═══════════════════════════════════════════════
   CONNECT OVERLAY — Shared inline GATE auth dialog
   Used by reader + community pages (connect.js)
   ═══════════════════════════════════════════════ */

#lv-connect-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(6, 6, 14, 0.90);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.lv-connect-modal {
  position: relative;
  background: var(--bg-elevated);
  border: 1px solid rgba(201, 169, 110, 0.22);
  border-radius: 1rem;
  padding: 2rem 1.75rem 1.75rem;
  width: 100%;
  max-width: 300px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.6);
}

.lv-connect-close {
  position: absolute;
  top: 0.7rem; right: 0.9rem;
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 1.3rem;
  cursor: pointer;
  padding: 0.2rem;
  line-height: 1;
  transition: color 0.2s;
}
.lv-connect-close:hover { color: var(--text); }

.lv-connect-badge {
  font-family: var(--font-ui);
  font-size: 0.58rem;
  letter-spacing: 0.2em;
  color: var(--gold-dim);
}

.lv-connect-title {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--gold-bright);
  letter-spacing: 0.08em;
  margin-top: -0.2rem;
}

.lv-connect-sub {
  font-family: var(--font-heading);
  font-size: 0.85rem;
  font-style: italic;
  color: var(--text-dim);
  line-height: 1.45;
  margin: 0;
}

.lv-connect-qr {
  image-rendering: pixelated;
  width: 180px;
  height: 180px;
  border-radius: 8px;
  display: none;
  margin: 0.3rem 0;
}

.lv-connect-open {
  display: inline-block;
  padding: 0.4rem 1.25rem;
  background: rgba(201, 169, 110, 0.1);
  border: 1px solid rgba(201, 169, 110, 0.35);
  border-radius: 99px;
  color: var(--gold-bright);
  font-family: var(--font-ui);
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  text-decoration: none;
  transition: background 0.2s;
}
.lv-connect-open:hover { background: rgba(201, 169, 110, 0.2); }
.lv-connect-open[hidden] { display: none; }

.lv-connect-status {
  font-family: var(--font-code);
  font-size: 0.65rem;
  color: var(--text-dim);
  letter-spacing: 0.04em;
  margin: 0;
  min-height: 1em;
}

.lv-connect-get-wallet {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  padding-top: 0.6rem;
  border-top: 1px solid var(--border-subtle);
  width: 100%;
}

.lv-connect-get-label {
  font-family: var(--font-code);
  font-size: 0.56rem;
  color: var(--text-dim);
  letter-spacing: 0.04em;
  opacity: 0.6;
}

.lv-connect-get-link {
  font-family: var(--font-ui);
  font-size: 0.68rem;
  font-weight: 500;
  color: var(--gold-bright);
  text-decoration: none;
  letter-spacing: 0.04em;
  transition: opacity 0.2s;
}
.lv-connect-get-link:hover { opacity: 0.75; }

/* ── Lightning payment dialog ────────────────── */
#lv-lightning-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(6, 6, 14, 0.90);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.lv-lightning-modal {
  position: relative;
  background: var(--bg-elevated);
  border: 1px solid rgba(201, 169, 110, 0.22);
  border-radius: 1rem;
  padding: 2rem 1.5rem 1.5rem;
  width: 100%;
  max-width: 300px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.9rem;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.6);
}

.lv-lightning-close {
  position: absolute;
  top: 0.65rem; right: 0.85rem;
  background: none; border: none;
  color: var(--text-dim); font-size: 1.3rem;
  cursor: pointer; padding: 0.2rem; line-height: 1;
  transition: color 0.2s;
}
.lv-lightning-close:hover { color: var(--text); }

.lv-lightning-title {
  font-family: var(--font-ui);
  font-size: 0.58rem;
  letter-spacing: 0.18em;
  color: var(--gold-dim);
}

/* Address block — primary action */
.lv-lightning-addr-block {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
}

.lv-lightning-addr-text {
  font-family: var(--font-code);
  font-size: 0.78rem;
  color: var(--gold-bright);
  letter-spacing: 0.02em;
  word-break: break-all;
  line-height: 1.4;
}

/* Big primary copy button */
.lv-lightning-copy-btn {
  width: 100%;
  padding: 0.7rem 1.5rem;
  background: rgba(201, 169, 110, 0.15);
  border: 1px solid rgba(201, 169, 110, 0.45);
  border-radius: 8px;
  color: var(--gold-bright);
  font-family: var(--font-ui);
  font-size: 0.82rem;
  font-weight: 500;
  letter-spacing: 0.06em;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.lv-lightning-copy-btn:hover { background: rgba(201, 169, 110, 0.28); border-color: rgba(201,169,110,0.7); }

/* MUUN bolt11 section */
.lv-lightning-muun-section {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border-subtle);
}

.lv-lightning-muun-label {
  font-family: var(--font-ui);
  font-size: 0.58rem;
  letter-spacing: 0.12em;
  color: var(--gold-dim);
  text-align: center;
}

.lv-lightning-muun-amts {
  display: flex;
  gap: 0.4rem;
}

.lv-ln-amt {
  padding: 0.3rem 0.7rem;
  background: rgba(201,169,110,0.08);
  border: 1px solid rgba(201,169,110,0.25);
  border-radius: 6px;
  color: var(--gold-dim);
  font-family: var(--font-code);
  font-size: 0.65rem;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.lv-ln-amt:hover,
.lv-ln-amt.active {
  background: rgba(201,169,110,0.2);
  border-color: rgba(201,169,110,0.6);
  color: var(--gold-bright);
}

.lv-lightning-muun-status {
  font-family: var(--font-code);
  font-size: 0.6rem;
  color: var(--text-dim);
  letter-spacing: 0.03em;
  margin: 0;
  min-height: 1em;
  text-align: center;
}

/* Wallet recommendation hint */
.lv-lightning-muun-hint {
  font-family: var(--font-heading);
  font-size: 0.72rem;
  font-style: italic;
  color: var(--text-dim);
  text-align: center;
  line-height: 1.6;
  margin: 0;
}
.lv-lightning-muun-hint strong {
  color: var(--gold-bright);
  font-style: normal;
}

/* Open in wallet — visible button on mobile */
.lv-lightning-open-btn {
  display: block;
  width: 100%;
  padding: 0.55rem 1rem;
  background: transparent;
  border: 1px solid rgba(201, 169, 110, 0.2);
  border-radius: 8px;
  color: var(--text-dim);
  font-family: var(--font-ui);
  font-size: 0.78rem;
  letter-spacing: 0.05em;
  text-decoration: none;
  transition: border-color 0.15s, color 0.15s;
  box-sizing: border-box;
}
.lv-lightning-open-btn:hover { border-color: rgba(201,169,110,0.4); color: var(--gold-bright); }

/* QR section */
.lv-lightning-qr-section {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

.lv-lightning-qr-label {
  font-family: var(--font-code);
  font-size: 0.55rem;
  color: var(--text-dim);
  letter-spacing: 0.05em;
  opacity: 0.6;
}

.lv-lightning-qr {
  image-rendering: pixelated;
  width: 150px;
  height: 150px;
  border-radius: 8px;
  display: none;
}

/* ═══════════════════════════════════════════════
   SITE NAV — Slim fixed top bar (index + community)
   ═══════════════════════════════════════════════ */

.site-nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 300;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0 1.25rem;
  height: 40px;
  background: rgba(6, 6, 14, 0.92);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border-subtle);
  font-family: var(--font-ui);
  font-size: 0.68rem;
  letter-spacing: 0.08em;
}

.site-nav-brand {
  color: var(--gold);
  font-weight: 700;
  letter-spacing: 0.1em;
  margin-right: auto;
  text-decoration: none;
}

.site-nav-link {
  color: var(--text-dim);
  text-decoration: none;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  transition: color 0.2s, background 0.2s;
}

.site-nav-link:hover { color: var(--gold-bright); background: rgba(201,169,110,0.08); }
.site-nav-link.active { color: var(--gold-bright); }

.site-nav-sep { color: var(--border); user-select: none; }

.site-nav-identity {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  background: none;
  border: 1px solid rgba(201,169,110,0.25);
  border-radius: 99px;
  color: var(--gold-dim);
  font-family: var(--font-ui);
  font-size: 0.65rem;
  letter-spacing: 0.06em;
  padding: 0.18rem 0.65rem;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s;
  max-width: 160px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.site-nav-identity:hover { border-color: rgba(201,169,110,0.6); color: var(--gold-bright); }
.site-nav-identity .nav-dot-live { color: #4ade80; flex-shrink: 0; }

/* ═══════════════════════════════════════════════
   REDUCED MOTION — Respect vestibular preferences
   ═══════════════════════════════════════════════ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .chapter > * { opacity: 1 !important; transform: none !important; transition: none !important; }
  .book-card { opacity: 1 !important; transform: none !important; }
  canvas { display: none !important; }
}

/* Auth + Zap UX animations */
@keyframes lv-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.45; } }
.zap-amt:disabled { opacity: 0.35; cursor: not-allowed; }
