/* ============================================================
   On the Road Again Lending — BASE
   Reset, typography, layout helpers, utilities, print.
   Depends on tokens.css. Ports to Next.js as app/globals.css.
   ============================================================ */

/* ---------- Reset & base ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  font-size: var(--fs-body);
  line-height: 1.6;
  color: var(--text-primary);
  background: var(--gray-50);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

img, svg { display: block; max-width: 100%; }
button { font: inherit; cursor: pointer; background: none; border: none; color: inherit; }
input, select, textarea { font: inherit; color: inherit; }
a { color: var(--blue-700); text-decoration: none; }
a:hover { text-decoration: underline; }
ul[class], ol[class] { list-style: none; }

::selection { background: var(--blue-100); color: var(--navy-900); }

h1, h2, h3, .display {
  font-family: var(--font-display);
  font-weight: 600;
  line-height: 1.14;
  letter-spacing: -0.015em;
  color: var(--navy-900);
}
h1, h2, .display { letter-spacing: -0.022em; }
h1 { font-size: var(--fs-h1); }
h2 { font-size: var(--fs-h2); }
h3 { font-size: var(--fs-h3); }
h4 { font-size: var(--fs-h4); font-weight: 600; letter-spacing: -0.01em; }

.money, .num { font-variant-numeric: tabular-nums; font-feature-settings: 'tnum'; }

.eyebrow {
  font-size: var(--fs-xs);
  font-weight: 650;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--blue-600);
}

.text-secondary { color: var(--text-secondary); }
.text-tertiary { color: var(--text-tertiary); }
.text-sm { font-size: var(--fs-sm); }
.text-xs { font-size: var(--fs-xs); }

/* ---------- Layout helpers ---------- */
.container { max-width: var(--container); margin: 0 auto; padding: 0 var(--sp-6); }
.container-narrow { max-width: var(--container-narrow); margin: 0 auto; padding: 0 var(--sp-6); }

.grid { display: grid; gap: var(--sp-6); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

/* Utilities wrap by default — a row of buttons must never run off a phone. */
.flex { display: flex; flex-wrap: wrap; }
.flex-between { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--sp-4); }
.flex-center { display: flex; align-items: center; gap: var(--sp-3); }
.stack-2 > * + * { margin-top: var(--sp-2); }
.stack-4 > * + * { margin-top: var(--sp-4); }
.stack-6 > * + * { margin-top: var(--sp-6); }

@media (max-width: 900px) {
  .grid-3, .grid-4 { grid-template-columns: repeat(2, 1fr); }
}
/* Two-column page layout. The POC defined this inline in each page's own
   <style> block; it belongs here, used by the hero, offer and detail screens. */
.two-col { display: grid; grid-template-columns: minmax(0,1.05fr) minmax(0,0.95fr); gap: var(--sp-10); }

/* Main content + sticky aside, used across the officer console. */
.detail-layout { display: grid; grid-template-columns: minmax(0,1fr) 340px; gap: var(--sp-6); align-items: start; }

@media (max-width: 1040px) { .grid-4 { grid-template-columns: repeat(2, 1fr); } .detail-layout { grid-template-columns: 1fr; } }
@media (max-width: 900px)  { .two-col { grid-template-columns: 1fr; gap: var(--sp-8); } .grid-3 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 640px)  { .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; } }
/* A label and a figure do not need a whole phone width each: four stacked
   tiles pushed the content they summarise most of a screen down. */
@media (max-width: 640px)  { .grid:has(> .stat-tile) { grid-template-columns: repeat(2, 1fr); } }

/* ---------- Reveal on scroll ---------- */
/* Reveal on scroll is an enhancement on a visible default. Nothing is hidden
   unless the shell has confirmed it can show it again: it sets .js-reveal on
   the root only with an observer present and the page visible, and drops it
   if the page goes hidden, because a hidden tab gets no frames and a
   transition there never finishes. Reduced motion gets no movement at all. */
.js-reveal .reveal { opacity: 0; transform: translateY(18px); transition: opacity 560ms ease-out, transform 700ms var(--ease-out); }
.js-reveal .reveal.in { opacity: 1; transform: translateY(0); }
.js-reveal .reveal-d1 { transition-delay: 70ms; }
.js-reveal .reveal-d2 { transition-delay: 140ms; }
.js-reveal .reveal-d3 { transition-delay: 210ms; }
@media (prefers-reduced-motion: reduce) { .js-reveal .reveal { opacity: 1; transform: none; transition: none; } }

/* ---------- Misc ---------- */
.divider { height: 1px; background: var(--gray-200); border: none; margin: var(--sp-6) 0; }
.pill-icon {
  width: 44px; height: 44px; border-radius: var(--r-md);
  display: grid; place-items: center; flex-shrink: 0;
  background: var(--blue-050); color: var(--blue-700);
}
.pill-icon.amber { background: var(--amber-050); color: var(--amber-600); }
.pill-icon.navy { background: var(--navy-050); color: var(--navy-700); }
.pill-icon.danger { background: var(--status-danger-bg); color: var(--status-danger); }

.kbd-hint {
  font-size: var(--fs-2xs); background: var(--gray-100);
  border: 1px solid var(--gray-200); border-radius: 6px;
  padding: 2px 7px; color: var(--text-secondary); font-weight: 600;
}

.noise::before {
  content: '';
  position: absolute; inset: 0;
  opacity: 0.35;
  pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0.05 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  border-radius: inherit;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
  html { scroll-behavior: auto; }
}

/* ---------- Print (statements) ---------- */
@media print {
  .site-header, .site-footer, .app-sidebar, .app-topbar, .no-print { display: none !important; }
  body { background: #fff; }
}
