/* BASELINE pending Andrew's look&feel session (Direction A "Clean Nimiq-Native", SPEC §9).
 * Palette + type are CSS vars so Andrew's #22 pick swaps in ONE place.
 *
 * The brand palette is now SOURCED from @nimiq/style's canonical --nimiq-* tokens
 * (loaded in index.html BEFORE this file) so the hexes can never drift from upstream.
 * Each var keeps a literal fallback so the app still renders if the CDN is unreachable.
 *
 * nimiq-ui gotcha: @nimiq/style sets html{font-size:8px} (1rem = 8px). All custom
 * values in this file are in px, so the 8px root does not affect them; nq-* component
 * classes assume the 8px root.
 */

:root {
  /* --- Nimiq palette (sourced from @nimiq/style, literal fallback) --- */
  --navy: var(--nimiq-blue, #1f2348);
  --navy-deep: #171d2e;
  --light-blue: var(--nimiq-light-blue, #0582ca);
  --gold: var(--nimiq-gold, #e9b213);
  --green: var(--nimiq-green, #21bca5);
  --green-deep: #20b29e;
  --red: var(--nimiq-red, #d94432);

  /* --- gradients (sourced from @nimiq/style, literal fallback) --- */
  --navy-bg: var(--nimiq-blue-bg, radial-gradient(100% 100% at bottom right, #260133, #1f2348));
  --light-blue-bg: var(
    --nimiq-light-blue-bg,
    radial-gradient(100% 100% at bottom right, #265dd7, #0582ca)
  );
  --green-bg: var(--nimiq-green-bg, radial-gradient(100% 100% at bottom right, #41a38e, #21bca5));
  --gold-bg: var(--nimiq-gold-bg, radial-gradient(100% 100% at bottom right, #ec991c, #e9b213));

  /* --- surfaces / text --- */
  --bg: var(--navy-bg);
  --card: #ffffff;
  --card-ink: var(--nimiq-blue, #1f2348);
  --card-ink-soft: rgba(31, 35, 72, 0.55);
  --on-dark: #ffffff;
  --on-dark-soft: rgba(255, 255, 255, 0.6);

  /* --- type --- */
  --font: "Mulish", "Muli", system-ui, -apple-system, sans-serif;
  --font-mono: "Fira Mono", ui-monospace, "SF Mono", monospace;

  /* --- spacing (4/8/16/24/32/48/64) --- */
  --s1: 4px;  --s2: 8px;  --s3: 16px; --s4: 24px;
  --s5: 32px; --s6: 48px; --s7: 64px;

  /* --- radii --- */
  --r-card: 16px;
  --r-pill: 500px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  font-family: var(--font);
  background-image: var(--bg);
  background-attachment: fixed;
  color: var(--on-dark);
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
}

#app {
  max-width: 460px;
  margin: 0 auto;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* ---------------- app chrome ---------------- */

.app-header {
  display: flex;
  align-items: center;
  gap: var(--s2);
  padding: var(--s4) var(--s4) var(--s3);
}
.app-header .brand { font-size: 17px; font-weight: 800; letter-spacing: -0.01em; }
.app-header .brand small { font-weight: 600; opacity: 0.6; font-size: 12px; display: block; }
.app-header .logo { height: 22px; }

.legal-banner {
  margin: 0 var(--s4) var(--s3);
  background: rgba(233, 178, 19, 0.1);
  border: 1px solid rgba(233, 178, 19, 0.45);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 12px;
  line-height: 1.5;
  color: rgba(255, 255, 255, 0.75);
}
.legal-banner strong { color: var(--gold); }

/* progress dots across the card stack */
.steps {
  display: flex;
  gap: 6px;
  justify-content: center;
  padding: var(--s2) 0 var(--s4);
}
.steps .dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: rgba(255, 255, 255, 0.22);
  transition: 0.25s;
}
.steps .dot.active { background: var(--green); width: 22px; border-radius: 4px; }
.steps .dot.done { background: rgba(33, 188, 165, 0.55); }

/* ---------------- screen container ---------------- */

.screen-host { flex: 1; position: relative; padding: 0 var(--s4) var(--s6); }

.screen {
  display: none;
  animation: slide-in 0.32s cubic-bezier(0.25, 0, 0, 1);
}
.screen.active { display: block; }

@keyframes slide-in {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ---------------- card ---------------- */

.card {
  background: var(--card);
  color: var(--card-ink);
  border-radius: var(--r-card);
  padding: var(--s5) var(--s4);
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.22);
}
.card + .card { margin-top: var(--s3); }
.eyebrow {
  font-size: 12px; font-weight: 700; letter-spacing: 0.02em;
  color: var(--light-blue); margin-bottom: var(--s2);
}
.card h2 { font-size: 22px; font-weight: 800; line-height: 1.2; letter-spacing: -0.01em; }
.card p { font-size: 14px; line-height: 1.55; color: var(--card-ink-soft); margin-top: var(--s2); }

/* ---------------- buttons (one primary action per screen) ---------------- */

.btn {
  width: 100%;
  border: none;
  border-radius: var(--r-pill);
  padding: 15px 20px;
  font-family: var(--font);
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.01em;
  color: #fff;
  cursor: pointer;
  transition: transform 0.15s cubic-bezier(0.25, 0, 0, 1), box-shadow 0.15s, opacity 0.15s;
  margin-top: var(--s4);
}
.btn:active { transform: translateY(1px); }
.btn:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 8px 22px rgba(0, 0, 0, 0.25); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn--primary { background-image: var(--light-blue-bg); }
.btn--green   { background-image: var(--green-bg); }
.btn--ghost {
  background: transparent; color: var(--on-dark-soft);
  font-weight: 700; font-size: 13px; margin-top: var(--s3);
}
.btn--ghost:hover:not(:disabled) { color: #fff; transform: none; box-shadow: none; }

/* ---------------- inputs ---------------- */

.field { margin-top: var(--s4); }
.field label {
  display: block; font-size: 13px; font-weight: 700;
  color: var(--card-ink-soft); margin-bottom: var(--s2);
}
.amount-input {
  display: flex; align-items: baseline; gap: 8px;
  box-shadow: inset 0 0 0 2px rgba(31, 35, 72, 0.12);
  border-radius: 10px; padding: 14px 16px;
}
.amount-input:focus-within { box-shadow: inset 0 0 0 2px var(--light-blue); }
.amount-input input {
  border: none; outline: none; flex: 1; width: 100%;
  font-family: var(--font-mono); font-size: 26px; font-weight: 700;
  color: var(--card-ink); background: transparent;
}
.amount-input .unit { font-weight: 800; color: var(--card-ink-soft); font-size: 15px; }
.chips { display: flex; gap: 8px; margin-top: var(--s3); }
.chip {
  flex: 1; padding: 9px 0; text-align: center; cursor: pointer;
  background: rgba(31, 35, 72, 0.06); border-radius: 8px;
  font-size: 13px; font-weight: 700; color: var(--card-ink-soft);
  border: 2px solid transparent; transition: 0.15s;
}
.chip.sel { border-color: var(--light-blue); color: var(--light-blue); background: rgba(5, 130, 202, 0.08); }

/* a11y (#26): keyboard focus ring on selectable radios (sits outside the element). */
.chip:focus-visible,
.account:focus-visible,
.cause:focus-visible {
  outline: 2px solid var(--light-blue);
  outline-offset: 2px;
}

/* ---------------- account / identicon ---------------- */

.account {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; border-radius: 12px;
  background: rgba(31, 35, 72, 0.05);
  cursor: pointer; border: 2px solid transparent; transition: 0.15s;
  margin-top: var(--s3);
}
.account.sel { border-color: var(--green); background: rgba(33, 188, 165, 0.07); }
.account .ident {
  width: 40px; height: 40px; border-radius: 50%; flex-shrink: 0;
  display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 15px;
}
.account .meta { flex: 1; min-width: 0; }
.account .meta .name { font-weight: 800; font-size: 15px; }
.account .meta .addr {
  font-family: var(--font-mono); font-size: 11px; color: var(--card-ink-soft);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px;
}
.account .bal { font-family: var(--font-mono); font-weight: 700; font-size: 13px; flex-shrink: 0; }

/* ---------------- cause card ---------------- */

.cause {
  cursor: pointer; border: 2px solid transparent; transition: 0.15s;
}
.cause.sel { border-color: var(--green); }
.cause .top { display: flex; align-items: center; gap: 12px; }
.cause .icon { font-size: 30px; }
.cause .name { font-weight: 800; font-size: 18px; }
.badge-verified {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11px; font-weight: 800; color: var(--green-deep);
  background: rgba(33, 188, 165, 0.12); padding: 3px 8px; border-radius: 500px;
  margin-top: 4px;
}
.cause .ein { font-family: var(--font-mono); font-size: 11px; color: var(--card-ink-soft); }

/* ---------------- impact dashboard ---------------- */

.principal-card { text-align: left; }
.principal-card .num {
  font-family: var(--font-mono); font-size: 40px; font-weight: 700;
  color: var(--navy); letter-spacing: -0.02em; line-height: 1;
}
.principal-card .num .unit { font-size: 18px; color: var(--card-ink-soft); }
.principal-card .safe {
  display: inline-flex; align-items: center; gap: 5px; margin-top: 10px;
  font-size: 12px; font-weight: 700; color: var(--green-deep);
}

.yield-card { background-image: var(--green-bg); color: #fff; }
.yield-card .eyebrow { color: rgba(255, 255, 255, 0.85); }
.yield-card .num {
  font-family: var(--font-mono); font-size: 34px; font-weight: 700;
  letter-spacing: -0.01em; line-height: 1.05;
  font-variant-numeric: tabular-nums;
}
.yield-card .num .unit { font-size: 16px; opacity: 0.85; }
.accel-chip {
  display: inline-block; margin-top: 10px;
  font-size: 11px; font-weight: 800; letter-spacing: 0.01em;
  background: rgba(255, 255, 255, 0.2); color: #fff;
  padding: 4px 10px; border-radius: 500px;
}
.flow-to { font-size: 12px; opacity: 0.9; margin-top: 8px; }
/* #28: subtle reconnect notice on repeated /api/yield failure (no pulsing dot). */
.reconnecting { margin-top: 8px; font-size: 12px; font-weight: 700; color: rgba(255, 255, 255, 0.75); }
.reconnecting[hidden] { display: none; }

/* ---------------- yield projection calendar ---------------- */

.calendar { margin-top: var(--s2); }
.calendar .crow {
  display: flex; align-items: baseline; justify-content: space-between;
  font-size: 13px; padding: 6px 0; border-bottom: 1px solid rgba(31, 35, 72, 0.06);
}
.calendar .crow .lbl { color: var(--card-ink-soft); font-weight: 700; }
.calendar .crow .val { font-family: var(--font-mono); font-weight: 700; }
.calendar-bars {
  display: flex; align-items: flex-end; gap: 3px; height: 64px; margin: var(--s3) 0 var(--s2);
}
.calendar-bars .bar {
  flex: 1; background: var(--light-blue-bg); border-radius: 3px 3px 0 0; min-height: 3px;
  opacity: 0.85;
}
.next-payout {
  display: flex; justify-content: space-between; align-items: center;
  background: rgba(5, 130, 202, 0.08); border-radius: 10px;
  padding: 12px 14px; margin-top: var(--s3); font-size: 13px;
}
.next-payout .pp-amt { font-family: var(--font-mono); font-weight: 800; color: var(--light-blue); }

/* ---------------- disclosure (non-custodial / cooldown) ---------------- */

.disclosure {
  margin-top: var(--s4); padding: 14px;
  background: rgba(31, 35, 72, 0.05); border-radius: 10px;
  font-size: 12px; line-height: 1.55; color: var(--card-ink-soft);
}
.disclosure strong { color: var(--navy); }

/* ---------------- explorer link / receipt ---------------- */

.receipt {
  margin-top: var(--s4); text-align: center;
}
.receipt .done-line { font-size: 16px; font-weight: 800; color: var(--navy); margin-bottom: 6px; }
.giver-badge {
  display: inline-flex; align-items: center; gap: 6px;
  background-image: var(--gold-bg); color: var(--navy);
  font-weight: 800; font-size: 13px; padding: 7px 16px; border-radius: 500px;
  margin: 10px 0; animation: pop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes pop { from { transform: scale(0.4); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.explorer-link {
  display: inline-block; margin-top: 8px; color: var(--light-blue);
  font-weight: 700; font-size: 13px; text-decoration: none;
  word-break: break-all;
}
.explorer-link:hover { text-decoration: underline; }
.tx-hash { font-family: var(--font-mono); font-size: 11px; color: var(--card-ink-soft); margin-top: 6px; }

/* ---------------- cooldown timer ---------------- */

.cooldown-timer {
  font-family: var(--font-mono); font-size: 28px; font-weight: 700;
  color: var(--navy); text-align: center; margin: var(--s3) 0 var(--s2);
}
.cooldown-range { text-align: center; font-size: 12px; color: var(--card-ink-soft); }

/* ---------------- toast + confetti ---------------- */

.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%) translateY(20px);
  background: var(--navy-deep); color: #fff; padding: 12px 20px; border-radius: 500px;
  font-size: 13px; font-weight: 700; opacity: 0; transition: 0.3s; pointer-events: none; z-index: 200;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

#confetti { position: fixed; inset: 0; pointer-events: none; z-index: 150; }

.muted { color: var(--card-ink-soft); }
.spinner {
  width: 18px; height: 18px; border: 2px solid rgba(255,255,255,0.4);
  border-top-color: #fff; border-radius: 50%; display: inline-block;
  animation: spin 0.7s linear infinite; vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------- win-lever plumbing (NEUTRAL — Andrew restyles) ---------------- */

/* Static badge fallback when confetti is suppressed (prefers-reduced-motion). */
.giver-badge--static { animation: none; }

/* "Why only on Nimiq" line (Win-lever 3). */
.why-nimiq {
  font-size: 12px; color: var(--on-dark-soft); line-height: 1.5;
  margin: var(--s3) 0; padding: 0 var(--s1);
}

/* Collective-impact lines (Win-lever 1) — on cause cards + donate receipt. */
.collective { font-size: 12px; color: var(--card-ink-soft); margin-top: var(--s2); }
.receipt .collective { color: var(--navy); font-weight: 700; }

/* 3-step "how it works" strip on connect (Win-lever 2). */
.how-it-works {
  list-style: none; display: flex; gap: var(--s2); counter-reset: step;
  margin: var(--s3) 0; padding: 0; font-size: 11px; color: var(--on-dark-soft);
}
.how-it-works li {
  flex: 1; counter-increment: step; line-height: 1.4;
}
.how-it-works li::before {
  content: counter(step); display: inline-flex; align-items: center; justify-content: center;
  width: 18px; height: 18px; margin-right: 6px; border-radius: 50%;
  background: rgba(255,255,255,0.12); font-weight: 800; font-size: 10px;
}

/* "Get free test NIM" faucet strip (Win-lever 2). */
.faucet-strip {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s2);
  margin-top: var(--s3); padding: var(--s2) var(--s3);
  background: rgba(255,255,255,0.06); border-radius: var(--r-card); font-size: 12px;
}
.faucet-strip .btn { width: auto; margin: 0; padding: 8px 14px; font-size: 12px; }

@media (prefers-reduced-motion: reduce) {
  .giver-badge { animation: none; }
}
