/* iPay shared foundation: tokens, type, background, buttons, emblem. */

:root {
  --paper: #f3f1ea;
  --paper-2: #ebe8de;
  --card: #fbfaf6;
  --ink: #161613;
  --ink-2: #4c4a44;
  --ink-3: #85827a;
  --rule: #d8d4c7;
  --rule-2: #e5e1d6;
  --accent: #1d6b47;
  --accent-ink: #f6f4ee;
  --accent-soft: #dbeadf;
  --amber: #9a5c0c;
  --amber-soft: #f2e4c9;
  --red: #ad362c;
  --red-soft: #f3dad5;
  --grid: rgba(22, 22, 19, 0.05);
  --shadow: 0 1px 0 rgba(22, 22, 19, 0.04), 0 12px 32px -18px rgba(22, 22, 19, 0.28);

  --sans: 'Geist', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'Geist Mono', ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace;
  --serif: 'Instrument Serif', 'Iowan Old Style', Georgia, serif;

  --r-sm: 6px;
  --r: 10px;
  --r-lg: 16px;
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
  --gutter: clamp(16px, 4vw, 40px);

  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #0f100e;
    --paper-2: #161714;
    --card: #1a1b18;
    --ink: #ecebe4;
    --ink-2: #b4b2a9;
    --ink-3: #7d7b73;
    --rule: #2c2d29;
    --rule-2: #222320;
    --accent: #5cc48e;
    --accent-ink: #0d0f0c;
    --accent-soft: #15301f;
    --amber: #e3a650;
    --amber-soft: #2f2412;
    --red: #ee7b6f;
    --red-soft: #351b17;
    --grid: rgba(236, 235, 228, 0.045);
    --shadow: 0 1px 0 rgba(0, 0, 0, 0.3), 0 16px 40px -20px rgba(0, 0, 0, 0.8);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #0f100e; --paper-2: #161714; --card: #1a1b18; --ink: #ecebe4; --ink-2: #b4b2a9; --ink-3: #7d7b73;
  --rule: #2c2d29; --rule-2: #222320; --accent: #5cc48e; --accent-ink: #0d0f0c; --accent-soft: #15301f;
  --amber: #e3a650; --amber-soft: #2f2412; --red: #ee7b6f; --red-soft: #351b17; --grid: rgba(236, 235, 228, 0.045);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--paper);
  color: var(--ink);
  font: 400 15px/1.55 var(--sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

/* Ledger grid, fixed behind everything, fading toward the edges. */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 44px 44px;
  background-position: -1px -1px;
  -webkit-mask-image: radial-gradient(ellipse 90% 70% at 50% 0%, #000 30%, transparent 100%);
          mask-image: radial-gradient(ellipse 90% 70% at 50% 0%, #000 30%, transparent 100%);
}

img, svg { display: block; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
::selection { background: var(--accent); color: var(--accent-ink); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.mono { font-family: var(--mono); font-feature-settings: 'tnum' 1, 'zero' 1; letter-spacing: -0.01em; }
.serif { font-family: var(--serif); font-weight: 400; letter-spacing: -0.01em; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--ink-3); }

/* Emblem: two-tone vault mark, colors follow the theme. */
.emblem { width: 26px; height: 26px; flex: none; }
.emblem .e-ink { fill: var(--ink); }
.emblem .e-acc { fill: var(--accent); }
.wordmark { display: inline-flex; align-items: center; gap: 9px; font-weight: 600; font-size: 17px; letter-spacing: -0.02em; }

/* Buttons */
.btn {
  --b-bg: var(--card);
  --b-fg: var(--ink);
  --b-bd: var(--rule);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 40px; padding: 0 16px;
  border: 1px solid var(--b-bd); border-radius: 999px;
  background: var(--b-bg); color: var(--b-fg);
  font-size: 14px; font-weight: 500; white-space: nowrap;
  transition: transform 0.18s var(--ease), background 0.18s, border-color 0.18s, color 0.18s;
}
.btn:hover { border-color: var(--ink-3); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn-ink { --b-bg: var(--ink); --b-fg: var(--paper); --b-bd: var(--ink); }
.btn-ink:hover { --b-bg: var(--ink-2); --b-bd: var(--ink-2); }
.btn-accent { --b-bg: var(--accent); --b-fg: var(--accent-ink); --b-bd: var(--accent); }
.btn-accent:hover { filter: brightness(1.08); border-color: var(--accent); }
.btn-ghost { --b-bg: transparent; --b-bd: transparent; }
.btn-ghost:hover { --b-bg: var(--paper-2); --b-bd: transparent; }
.btn-sm { min-height: 32px; padding: 0 12px; font-size: 13px; }
.btn-lg { min-height: 48px; padding: 0 22px; font-size: 15px; }
.btn .arrow { transition: transform 0.2s var(--ease); }
.btn:hover .arrow { transform: translateX(3px); }

.icon-btn {
  display: inline-grid; place-items: center;
  width: 36px; height: 36px; border-radius: 999px;
  border: 1px solid var(--rule); background: var(--card); color: var(--ink-2);
  transition: color 0.15s, border-color 0.15s;
}
.icon-btn:hover { color: var(--ink); border-color: var(--ink-3); }

/* Small status chip */
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 24px; padding: 0 10px; border-radius: 999px;
  border: 1px solid var(--rule); background: var(--card);
  font: 500 12px/1 var(--sans); color: var(--ink-2); white-space: nowrap;
}
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ink-3); flex: none; }
.dot.live { background: var(--accent); box-shadow: 0 0 0 0 var(--accent); animation: ping 2.4s var(--ease) infinite; }
.dot.warn { background: var(--amber); }
.dot.bad { background: var(--red); }
@keyframes ping {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 55%, transparent); }
  70%, 100% { box-shadow: 0 0 0 7px transparent; }
}

/* Form fields */
.field { display: grid; gap: 6px; font-size: 13px; font-weight: 500; color: var(--ink-2); }
.field .hint { font-weight: 400; color: var(--ink-3); font-size: 12px; }
.input {
  width: 100%; min-height: 44px; padding: 10px 12px;
  border: 1px solid var(--rule); border-radius: var(--r-sm);
  background: var(--card); color: var(--ink);
  font-size: 15px; font-weight: 400;
  transition: border-color 0.15s, box-shadow 0.15s;
}
textarea.input { resize: vertical; min-height: 88px; line-height: 1.5; }
.input::placeholder { color: var(--ink-3); }
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input.mono { font-size: 14px; }

/* Scroll reveal: elements start slightly low and faded, JS adds .in */
.reveal { opacity: 0; transform: translateY(14px); transition: opacity 0.7s var(--ease), transform 0.7s var(--ease); transition-delay: var(--d, 0s); }
.reveal.in { opacity: 1; transform: none; }
.no-js .reveal { opacity: 1; transform: none; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; scroll-behavior: auto !important; }
  .reveal { opacity: 1; transform: none; }
}
