/* barter.game — clean-neobank skin
   Space Grotesk (display) / Hanken Grotesk (body) / JetBrains Mono (data) */

:root {
  --bg: #F3F1EC;
  --fg: #1A1712;
  /* --muted/--faint darkened for WCAG AA contrast on the page background */
  --muted: #6B665D;
  --faint: #6E685E;
  --accent: #3D34D6;
  --accent-soft: #ECEBFB;
  /* border that reads as "accent-tinted" on --accent-soft fills */
  --accent-line: #D8D5F5;
  --accent2: #1C7C54;
  --green-soft: #E6F1EA;
  --danger: #C0492E;
  --danger-soft: #F7E9E3;
  --amber: #A9761A;
  --amber-soft: #F5EDDB;
  --card: #FFFFFF;
  --border: #EAE7DF;
  --hair: #F1EEE7;
  --header-bg: rgba(255, 255, 255, 0.86);
  --display: 'Space Grotesk', sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: 'Hanken Grotesk', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: radial-gradient(120% 100% at 50% -10%, #F6F4EF 0%, #F3F1EC 55%, #EDEAE2 100%) fixed;
  color: var(--fg);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
::selection { background: #d7d4f7; }
#app { min-height: 100vh; }
.container { max-width: 900px; margin: 0 auto; padding: 1.25rem 1rem; }
h1, h2, h3, h4 {
  font-family: var(--display);
  letter-spacing: -0.02em;
  color: var(--fg);
}
h1 { font-size: 2.1rem; line-height: 1.1; letter-spacing: -0.03em; }
h3 { font-size: 1.05rem; margin: 0 0 0.6rem; }
a { color: var(--accent); font-weight: 600; text-decoration: none; }
a:hover { text-decoration: underline; }
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1rem 1.1rem;
  margin-bottom: 1rem;
  box-shadow: 0 1px 2px rgba(20, 18, 12, 0.04);
}
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.65rem 1rem;
  border: none;
  border-radius: 12px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  box-shadow: 0 12px 26px -12px rgba(61, 52, 214, 0.8);
  transition: background 0.15s ease, box-shadow 0.15s ease;
}
.btn:hover { background: #332BB8; text-decoration: none; }
.btn.secondary {
  background: var(--card);
  color: var(--fg);
  border: 1px solid var(--border);
  box-shadow: 0 1px 2px rgba(20, 18, 12, 0.04);
}
.btn.secondary:hover { background: #FAF9F6; }
.btn.danger { background: var(--danger-soft); color: var(--danger); box-shadow: none; }
.btn.danger:hover { background: #F2DDD4; }
.btn:disabled { background: #CFCBF3; color: #fff; cursor: not-allowed; box-shadow: none; }
input, textarea, select {
  width: 100%;
  padding: 0.7rem 0.85rem;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  background: var(--card);
  color: var(--fg);
  font: inherit;
  font-size: 0.95rem;
  transition: border-color 0.15s ease;
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent); }
input::placeholder, textarea::placeholder { color: var(--faint); }
/* Checkboxes and radios must not stretch to full width — otherwise the box
   centers itself and its label wraps to the next line. Keep them inline with
   their label text. */
input[type="checkbox"], input[type="radio"] {
  width: auto;
  margin: 0 0.5rem 0 0;
  padding: 0;
  vertical-align: middle;
  accent-color: var(--accent);
}
label { display: block; margin: 0.85rem 0 0.35rem; color: var(--muted); font-size: 0.83rem; font-weight: 600; }
/* A label that wraps a checkbox/radio reads as a single inline row. */
label:has(> input[type="checkbox"]), label:has(> input[type="radio"]) {
  display: flex;
  align-items: center;
  gap: 0.15rem;
  color: var(--fg);
  font-weight: 500;
  cursor: pointer;
}
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  padding: 0.7rem 1rem;
  background: var(--header-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand { display: flex; align-items: center; gap: 0.6rem; min-width: 0; }
.brand strong { font-family: var(--display); font-size: 1rem; letter-spacing: -0.02em; }
.logo-mark {
  width: 30px; height: 30px; flex-shrink: 0;
  border-radius: 8px;
  background: var(--accent);
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 14px -4px rgba(61, 52, 214, 0.6);
}
.logo-mark span {
  width: 11px; height: 11px;
  border: 2.2px solid #fff; border-radius: 3px;
  transform: rotate(45deg); display: block;
}
.logo-mark.large { width: 60px; height: 60px; border-radius: 17px; box-shadow: 0 14px 30px -10px rgba(61, 52, 214, 0.6); }
.logo-mark.large span { width: 22px; height: 22px; border-width: 3.4px; border-radius: 6px; }
.brand { flex: 1; }
.header-actions { display: flex; gap: 0.5rem; align-items: center; }
.nav-toggle { display: none; }
/* Desktop: nav laid out inline. Below 1100px it collapses into the Menu drawer
   (see the media query lower down), replacing the old 3-row wrap. */
.nav { display: flex; gap: 0.15rem; flex-wrap: wrap; }
@media (min-width: 1100px) {
  .nav { flex: 1; flex-basis: auto; justify-content: flex-end; }
  .brand { flex: 0 1 auto; }
}
.nav a {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.82rem;
  font-weight: 600;
  padding: 0.35rem 0.6rem;
  border-radius: 9px;
  transition: background 0.15s ease, color 0.15s ease;
}
.nav a:hover { color: var(--fg); text-decoration: none; }
.nav a.active { color: var(--accent); background: var(--accent-soft); }
/* Log out sits in the same nav list, so mark it as the one destructive item. */
.nav a.logout { color: var(--danger); }
.nav a.logout:hover { color: var(--danger); background: var(--accent-soft); }
.mono { font-family: var(--mono); font-size: 0.8rem; overflow-wrap: anywhere; }
.small { font-size: 0.85rem; color: var(--muted); }
.error { color: var(--danger); }
.success { color: var(--accent2); }
.chip {
  display: inline-block;
  padding: 0.18rem 0.55rem;
  border-radius: 9999px;
  background: var(--bg);
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  margin-right: 0.5rem;
}
.chip.state-created { background: var(--bg); color: var(--muted); }
.chip.state-ready { background: var(--accent-soft); color: var(--accent); }
.chip.state-held { background: var(--amber-soft); color: var(--amber); }
.chip.state-settled { background: var(--green-soft); color: var(--accent2); }
.chip.state-rejected { background: var(--danger-soft); color: var(--danger); }
/* in-progress states between created and settled */
.chip.state-open { background: var(--accent-soft); color: var(--accent); }
.chip.state-approved, .chip.state-mandated, .chip.state-pending { background: var(--amber-soft); color: var(--amber); }
.grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.flex { display: flex; gap: 1rem; align-items: center; }
/* let long mono content (URLs, pubkeys) shrink/wrap instead of forcing overflow */
.flex > * { min-width: 0; }
.flex.col { flex-direction: column; align-items: stretch; }
.scan { width: 100%; max-width: 320px; aspect-ratio: 1; background: white; padding: 0.5rem; border-radius: 12px; }
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(14, 13, 11, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 1rem;
}
.modal {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 1.25rem;
  max-width: 420px;
  width: 100%;
  text-align: center;
  box-shadow: 0 40px 80px -40px rgba(20, 18, 12, 0.4);
}
.modal .qr {
  width: 100%;
  max-width: 320px;
  image-rendering: pixelated;
  background: white;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 14px;
}
.modal .flex { justify-content: center; margin-top: 0.75rem; }

/* welcome hero */
.welcome { max-width: 420px; padding-top: 10vh; text-align: left; }
.welcome h1 { margin: 1.4rem 0 0; }
.welcome .lede { font-size: 0.97rem; color: var(--muted); line-height: 1.55; margin: 0.9rem 0 0; }
.welcome .lede b { color: var(--fg); }
.bank-pill {
  display: flex; align-items: center; gap: 0.7rem;
  padding: 0.85rem 1rem; margin-top: 1.5rem;
  background: var(--card); border: 1px solid var(--border);
  border-radius: 15px; box-shadow: 0 1px 2px rgba(20, 18, 12, 0.04);
  text-align: left;
}
.bank-pill .ic {
  width: 34px; height: 34px; flex-shrink: 0;
  border-radius: 9px; background: var(--accent-soft);
  display: flex; align-items: center; justify-content: center;
  color: var(--accent); font-weight: 700; font-family: var(--display);
}
.stack { display: flex; flex-direction: column; gap: 0.7rem; margin-top: 1.6rem; }
.stack .btn { width: 100%; padding: 0.95rem; font-size: 1rem; border-radius: 14px; }
.footnote { font-family: var(--mono); font-size: 0.75rem; color: var(--faint); line-height: 1.5; }

/* install ("add to home screen") offer — a tinted card, dismissible */
.install-card {
  display: flex;
  align-items: flex-start;
  gap: 0.85rem;
  position: relative;
  background: var(--accent-soft);
  border-color: var(--accent-line);
}
.welcome .install-card { margin-top: 1.6rem; text-align: left; }
/* Room on the right so no text ever sits under the close button's hit area. */
.install-body { flex: 1; min-width: 0; padding-right: 2.25rem; }
.install-card h3 { margin: 0.1rem 0 0.3rem; }
.install-card p { margin: 0 0 0.75rem; }
.install-card .logo-mark { margin-top: 0.15rem; }
.install-close {
  position: absolute; top: 0.15rem; right: 0.2rem;
  width: 40px; height: 40px; padding: 0; /* 40px touch target */
  display: flex; align-items: center; justify-content: center;
  border: none; border-radius: 10px; background: transparent;
  color: var(--muted); font-size: 1.15rem; line-height: 1; cursor: pointer;
}
.install-close:hover { background: var(--hair); color: var(--fg); }
.install-steps {
  margin: 0 0 0.8rem;
  padding-left: 1.15rem;
  font-size: 0.85rem;
  color: var(--muted);
}
.install-steps li { margin: 0.2rem 0; }
.install-steps b { color: var(--fg); }

@media (max-width: 640px) {
  input, textarea, select { font-size: 16px; } /* stops iOS zoom on focus */
}

/* ---- mobile navigation: Menu drawer (< 1100px) + bottom bar (<= 760px) ---- */

/* Bottom bar + New sheet are desktop-hidden; shown only on phones. */
.bottomnav, .sheet-overlay { display: none; }

@media (max-width: 1099px) {
  /* The header nav collapses behind the Menu button and opens as a drawer. */
  .nav {
    display: none;
    position: absolute;
    top: 100%; left: 0; right: 0;
    flex-direction: column;
    flex-wrap: nowrap;
    gap: 0.15rem;
    padding: 0.5rem;
    background: var(--card);
    border-bottom: 1px solid var(--border);
    box-shadow: 0 24px 40px -22px rgba(20, 18, 12, 0.4);
    max-height: 72vh;
    overflow-y: auto;
  }
  .nav.open { display: flex; }
  .nav a { padding: 0.8rem 0.85rem; font-size: 1rem; border-radius: 10px; }
  .nav-toggle { display: inline-flex; }
}

@media (max-width: 760px) {
  /* Fixed quick-access bar. */
  .bottomnav {
    display: flex;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    z-index: 40;
    justify-content: space-around;
    align-items: stretch;
    background: var(--header-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid var(--border);
    padding: 0.3rem 0.4rem calc(0.3rem + env(safe-area-inset-bottom));
  }
  .bn-item {
    flex: 1;
    display: flex; flex-direction: column; align-items: center; justify-content: flex-end;
    gap: 0.15rem;
    min-height: 54px;
    padding: 0.35rem 0.2rem;
    background: none; border: none;
    color: var(--muted);
    font: inherit; font-size: 0.66rem; font-weight: 600;
    text-decoration: none; cursor: pointer; border-radius: 10px;
  }
  .bn-item svg { width: 24px; height: 24px; }
  .bn-item.active { color: var(--accent); }
  /* the New (+) button reads as the primary action */
  .bn-new { color: var(--accent); }
  .bn-new svg {
    width: 38px; height: 38px; padding: 7px;
    background: var(--accent); color: #fff;
    border-radius: 13px;
    box-shadow: 0 10px 20px -8px rgba(61, 52, 214, 0.85);
    margin-top: -14px; /* lift above the bar */
  }
  /* clear the fixed bar so it never covers page content */
  #app { padding-bottom: 74px; }

  /* "New" bottom sheet */
  .sheet-overlay { position: fixed; inset: 0; z-index: 45; background: rgba(14, 13, 11, 0.45); }
  .sheet-overlay.open { display: block; }
  .sheet {
    position: absolute; bottom: 0; left: 0; right: 0;
    background: var(--bg);
    border-top-left-radius: 20px; border-top-right-radius: 20px;
    padding: 0.75rem 0.75rem calc(0.9rem + env(safe-area-inset-bottom));
    box-shadow: 0 -24px 48px -24px rgba(20, 18, 12, 0.5);
  }
  .sheet-title { font-family: var(--display); font-weight: 600; font-size: 0.95rem; margin: 0.2rem 0.3rem 0.6rem; }
  .sheet-item {
    display: flex; flex-direction: column; align-items: flex-start; gap: 0.1rem;
    width: 100%; margin-bottom: 0.5rem;
    padding: 0.8rem 0.9rem; border-radius: 13px;
    background: var(--card); border: 1px solid var(--border);
    color: var(--fg); font: inherit; font-weight: 600; text-align: left;
    text-decoration: none; cursor: pointer;
  }
  .sheet-item .small { font-weight: 400; }
  .sheet-item.cancel { align-items: center; justify-content: center; margin-top: 0.15rem; background: none; border: none; color: var(--muted); }
}

/* loading shell */
.skeleton { display: flex; align-items: center; gap: 0.6rem; color: var(--muted); font-size: 0.9rem; padding: 1.2rem 0; }
.spinner {
  width: 16px; height: 16px; flex-shrink: 0;
  border: 2.5px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  display: inline-block;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation: none; } }

/* visually hidden but available to screen readers and programmatic focus */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0; border: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

/* skip link — hidden until keyboard-focused */
.skip-link {
  position: absolute;
  left: 0.5rem;
  top: -3rem;
  z-index: 60;
  background: var(--accent);
  color: #fff;
  padding: 0.5rem 0.85rem;
  border-radius: 10px;
  font-size: 0.85rem;
  transition: top 0.15s ease;
}
.skip-link:focus { top: 0.5rem; text-decoration: none; outline: 2px solid #fff; }
/* a heading focused by the router should not draw a persistent outline */
h1:focus, h2:focus, h3:focus { outline: none; }

/* Dark theme — follows the OS setting; placed last so its body-background
   override wins over the base rule. QR/scan surfaces stay light on purpose
   (a QR must be dark-on-light to scan). */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15130E;
    --fg: #ECE9E1;
    --muted: #A8A399;
    --faint: #928C7F;
    --accent: #9089F0;
    --accent-soft: #262349;
    --accent-line: #383464;
    --accent2: #6FCF97;
    --green-soft: #1C3025;
    --danger: #E58A72;
    --danger-soft: #38231C;
    --amber: #D8AA5A;
    --amber-soft: #342A17;
    --card: #201D17;
    --border: #322E25;
    --hair: #262219;
    --header-bg: rgba(28, 25, 19, 0.86);
  }
  body {
    background: radial-gradient(120% 100% at 50% -10%, #1D1A13 0%, #15130E 55%, #100E0A 100%) fixed;
  }
  ::selection { background: #3a356b; }
  .btn.secondary:hover { background: #2A2620; }
}
