/* cargo.css — WayDispatch design system (Cargo · Cobalt) */

:root {
  --font-sans: 'Geist', ui-sans-serif, system-ui, sans-serif;
  --font-mono: 'Geist Mono', ui-monospace, monospace;
  --font-accent: 'Instrument Serif', serif;
  --bg: #f5f3ee;
  --bg-2: #ebe9e2;
  --fg: #0c0c0e;
  --fg-60: rgba(12, 12, 14, 0.72);
  /* Text tone for small labels/kickers. Was 0.55, which composited to #79797a
     on --card and #757473 on --bg — 4.35:1 and 4.21:1, under the 4.5:1 WCAG AA
     minimum, and axe flagged it on all nine authenticated pages. 0.57 is the
     break-even alpha; 0.60 is used instead so the tone keeps a real margin
     (5.17:1 on --card, 5.01:1 on --bg) rather than sitting on the threshold.
     Enforced by frontend/token-contrast.test.js. */
  --fg-45: rgba(12, 12, 14, 0.6);
  /* Deliberately NOT contrast-checked: this is the disabled/decorative tone
     (2.0:1), which WCAG 1.4.3 exempts. Never use it for meaningful text. */
  --fg-30: rgba(12, 12, 14, 0.3);
  --rule: rgba(0, 0, 0, 0.08);
  --rule-strong: rgba(0, 0, 0, 0.14);
  --card: #ffffff;
  --dark: #0c0c0e;
  --dark-fg: #f5f3ee;
  --dark-fg-60: rgba(245, 243, 238, 0.6);
  /* Dark-surface counterpart to --fg-45, and it failed AA the same way: at
     0.45 it composited to #757473 on --dark (4.4:1) and #858483 on the
     lightest dark surface #29292b (3.6:1). The lightest surface binds, needing
     alpha >= 0.50; 0.55 is used for margin (5.8:1 on --dark, 5.1:1 on
     #29292b). Enforced by frontend/token-contrast.test.js. */
  --dark-fg-45: rgba(245, 243, 238, 0.55);
  --dark-rule: rgba(255, 255, 255, 0.08);
  --acc: #0066ff;
  --acc-text: #0052cc;
  --acc-bg: rgba(0, 102, 255, 0.1);
  --acc-glow: rgba(0, 102, 255, 0.35);

  --danger: #d92d20;
  --danger-dark: #b42318;
  --warning: #f59e0b;
  --success: #16835b;

  /* Status badge tones — one shared 4-state palette (success/warning/danger/
     pending) for any status indicator in the app (orders, routes, drivers,
     EDI, communications). Always pair with a text label, never color alone. */
  --badge-success-fg: #166534;
  --badge-success-bg: #ecfdf3;
  --badge-success-border: #bbf7d0;
  --badge-warning-fg: #92400e;
  --badge-warning-bg: #fffbeb;
  --badge-warning-border: #fde68a;
  --badge-danger-fg: #991b1b;
  --badge-danger-bg: #fff1f2;
  --badge-danger-border: #fecdd3;
  --badge-pending-fg: #475569;
  --badge-pending-bg: #f8fafc;
  --badge-pending-border: #cbd5e1;
  /* Two extra escalation tiers above warning/danger, for domains that need
     genuine 3+ severity granularity (EDI triage: warning < error < fatal).
     Not part of the core 4-tone set — only use these where the extra
     distinction is operationally meaningful, not decorative. */
  --badge-error-fg: #9a3412;
  --badge-error-bg: #ffedd5;
  --badge-error-border: #fed7aa;
  --badge-fatal-fg: #991b1b;
  --badge-fatal-bg: #fee2e2;
  --badge-fatal-border: #fecaca;

  --r-sm: 8px;
  --r: 14px;
  --r-lg: 20px;
  --r-xl: 24px;
  --maxw: 1280px;

  /* Breakpoint reference (documented convention, not a live CSS value —
     media query widths can't reference custom properties). New/touched CSS
     should converge on these two widths instead of introducing new ones:
     mobile ≤720px · tablet 721–900px · desktop >900px.
     See docs/product/FRONTEND_DESIGN_TOKENS.md. */
}

* {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  padding: 0;
}
body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-sans);
  font-feature-settings:
    'ss01' on,
    'cv11' on;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
a {
  color: inherit;
  text-decoration: none;
}
p {
  margin: 0;
}
img {
  display: block;
  max-width: 100%;
}

/* Leaflet layout fallback. Keeps maps usable when the CDN stylesheet is unavailable. */
.leaflet-container {
  position: relative;
  overflow: hidden;
  outline: 0;
  font-family: 'Geist', ui-sans-serif, system-ui, sans-serif;
}
.leaflet-pane,
.leaflet-tile,
.leaflet-marker-icon,
.leaflet-marker-shadow,
.leaflet-tile-container,
.leaflet-pane > svg,
.leaflet-pane > canvas,
.leaflet-zoom-box,
.leaflet-image-layer {
  position: absolute;
  left: 0;
  top: 0;
}
.leaflet-container img.leaflet-tile {
  width: 256px !important;
  height: 256px !important;
  max-width: none !important;
  max-height: none !important;
}
.leaflet-map-pane {
  z-index: 2;
}
.leaflet-tile-pane {
  z-index: 200;
}
.leaflet-overlay-pane {
  z-index: 400;
}
.leaflet-shadow-pane {
  z-index: 500;
}
.leaflet-marker-pane {
  z-index: 600;
}
.leaflet-tooltip-pane {
  z-index: 650;
}
.leaflet-popup-pane {
  z-index: 700;
}
.leaflet-control {
  position: relative;
  z-index: 800;
  pointer-events: auto;
}
.leaflet-top,
.leaflet-bottom {
  position: absolute;
  z-index: 1000;
  pointer-events: none;
}
.leaflet-top {
  top: 0;
}
.leaflet-right {
  right: 0;
}
.leaflet-bottom {
  bottom: 0;
}
.leaflet-left {
  left: 0;
}
.leaflet-control-zoom,
.leaflet-control-attribution {
  margin: 10px;
}

@media (max-width: 800px) {
  .route-demo-layout {
    grid-template-columns: 1fr !important;
  }
  .route-demo-map {
    min-height: 340px !important;
  }
  .route-demo-layout > :last-child {
    border-left: 0 !important;
    border-top: 1px solid rgba(0, 0, 0, 0.08);
  }
}
.leaflet-control-zoom a {
  display: block;
  width: 30px;
  height: 30px;
  background: #fff;
  border-bottom: 1px solid rgba(0, 0, 0, 0.12);
  color: #111;
  font:
    600 20px/30px Arial,
    sans-serif;
  text-align: center;
}
.leaflet-control-zoom a:first-child {
  border-radius: 5px 5px 0 0;
}
.leaflet-control-zoom a:last-child {
  border: 0;
  border-radius: 0 0 5px 5px;
}
.route-demo-map .leaflet-control-attribution a {
  text-decoration: underline;
}
.leaflet-control-attribution {
  padding: 2px 5px;
  background: rgba(255, 255, 255, 0.82);
  color: #555;
  font-size: 10px;
}

.italic {
  font-family: var(--font-accent);
  font-style: italic;
  font-weight: 400;
}
.mono {
  font-family: var(--font-mono);
}
.acc {
  color: var(--acc-text);
}

/* ─── LAYOUT ────────────────────────────────────────────── */
.container {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 64px;
}
.section {
  padding: 96px 0;
}
.section-tight {
  padding: 64px 0;
}
.rule {
  height: 1px;
  background: var(--rule);
  border: 0;
}

/* ─── NAV ───────────────────────────────────────────────── */
.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px 48px;
  position: static;
  background: rgba(245, 243, 238, 0.8);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--rule);
}
.nav-left {
  display: flex;
  align-items: center;
  gap: 40px;
}
.home-nav .nav-right .link {
  white-space: nowrap;
}

.nav-links {
  display: flex;
  gap: 28px;
}
.nav-right {
  display: flex;
  align-items: center;
  gap: 12px;
}
.logo {
  display: inline-flex;
  align-items: center;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--fg);
}
.site-logo {
  display: block;
  height: 32px;
  width: auto;
  max-width: min(100%, 220px);
}

.link {
  color: var(--fg-60);
  font-size: 14px;
  transition: color 0.15s;
}
.link:hover {
  color: var(--fg);
}
.link.current {
  color: var(--fg);
  font-weight: 500;
}
.link-arrow {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.link-arrow:hover .arrow {
  transform: translateX(2px);
}
.arrow {
  transition: transform 0.15s;
  display: inline-block;
}

/* ─── BUTTONS ───────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 16px;
  border-radius: 999px;
  font:
    500 14px/1 'Geist',
    sans-serif;
  cursor: pointer;
  transition: all 0.18s;
  border: 1px solid transparent;
  white-space: nowrap;
}
.btn-primary {
  background: var(--dark);
  color: var(--dark-fg);
}
.btn-primary:hover {
  background: #1f1f22;
  transform: translateY(-1px);
}
.btn-ghost {
  background: transparent;
  color: var(--fg);
  border-color: var(--rule-strong);
}
.btn-ghost:hover {
  background: rgba(0, 0, 0, 0.04);
}
.btn-light {
  background: var(--dark-fg);
  color: var(--dark);
}
.btn-light:hover {
  background: #fff;
  transform: translateY(-1px);
}
.btn-on-dark-ghost {
  background: transparent;
  color: var(--dark-fg);
  border-color: rgba(255, 255, 255, 0.2);
}
.btn-on-dark-ghost:hover {
  background: rgba(255, 255, 255, 0.06);
}
.btn-acc {
  background: var(--acc);
  color: #fff;
}
.btn-acc:hover {
  transform: translateY(-1px);
  filter: brightness(1.08);
  box-shadow: 0 0 24px var(--acc-glow);
}
.btn-sm {
  min-height: 34px;
  padding: 6px 12px;
  font-size: 12px;
}
.btn-danger {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
}
.btn-danger:hover {
  background: var(--danger-dark);
  border-color: var(--danger-dark);
  transform: translateY(-1px);
}
.btn-outline {
  background: transparent;
  color: var(--fg);
  border: 1px solid var(--rule-strong);
}
.btn-outline:hover {
  background: rgba(0, 0, 0, 0.04);
}

/* ─── HIT TARGET EXPANSION (WCAG 2.2 AA SC 2.5.8) ───────── */
/* Injects an invisible boundary expanding tap/click targets to 44x44 (48x48 on coarse pointers)
   without altering visible line heights or table cell geometry. */
.btn-sm,
.btn-icon,
.mini-button,
.delete-order,
.order-review-action,
.modal-close,
.map-fit-control,
.view-plan-btn,
.table-action-btn {
  position: relative;
}

.btn-sm::after,
.btn-icon::after,
.mini-button::after,
.delete-order::after,
.order-review-action::after,
.modal-close::after,
.map-fit-control::after,
.view-plan-btn::after,
.table-action-btn::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  min-width: 44px;
  min-height: 44px;
  width: 100%;
  height: 100%;
  pointer-events: auto;
}

@media (pointer: coarse) {
  .btn-sm::after,
  .btn-icon::after,
  .mini-button::after,
  .delete-order::after,
  .order-review-action::after,
  .modal-close::after,
  .map-fit-control::after,
  .view-plan-btn::after,
  .table-action-btn::after {
    min-width: 48px;
    min-height: 48px;
  }
}

/* ─── EYEBROWS / TAGS ───────────────────────────────────── */
.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: 'Geist Mono', monospace;
  font-size: 11.5px;
  color: var(--fg-60);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.04);
  border: 1px solid var(--rule);
}
.eyebrow::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 99px;
  background: var(--acc);
  box-shadow: 0 0 10px var(--acc-glow);
}
.eyebrow.on-dark {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.1);
  color: var(--dark-fg-60);
}
.pill {
  font-family: 'Geist Mono', monospace;
  font-size: 10.5px;
  padding: 3px 8px;
  border-radius: 999px;
  letter-spacing: 0.04em;
  border: 1px solid var(--rule-strong);
  color: var(--fg-60);
  background: rgba(255, 255, 255, 0.5);
  display: inline-block;
}
.pill-acc {
  background: var(--acc-bg);
  border-color: transparent;
  color: var(--acc-text);
}
.pill.on-dark {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 255, 255, 0.12);
  color: var(--dark-fg-60);
}
.pill-acc.on-dark {
  background: var(--acc-bg);
  border-color: transparent;
  color: var(--acc);
}

/* ─── TYPE SCALE ────────────────────────────────────────── */
.h1 {
  font-size: 92px;
  line-height: 0.94;
  letter-spacing: -0.045em;
  font-weight: 500;
  margin: 0;
}
.h2 {
  font-size: 56px;
  line-height: 1;
  letter-spacing: -0.035em;
  font-weight: 500;
  margin: 0;
}
.h3 {
  font-size: 26px;
  line-height: 1.15;
  letter-spacing: -0.02em;
  font-weight: 600;
  margin: 0;
}
.h4 {
  font-size: 20px;
  line-height: 1.25;
  letter-spacing: -0.015em;
  font-weight: 600;
  margin: 0;
}
.lead {
  font-size: 19px;
  line-height: 1.5;
  color: var(--fg-60);
}
.body {
  font-size: 15px;
  line-height: 1.6;
  color: var(--fg-60);
}

/* ─── CARDS ─────────────────────────────────────────────── */
.card {
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: var(--r);
  padding: 28px;
  transition: all 0.2s;
}
.card:hover {
  border-color: var(--rule-strong);
  box-shadow: 0 16px 36px -22px rgba(0, 0, 0, 0.18);
  transform: translateY(-2px);
}
.card-dark {
  background: var(--dark);
  color: var(--dark-fg);
  border-radius: var(--r);
  padding: 28px;
  border: 1px solid var(--dark-rule);
}
.card-flat {
  background: transparent;
  border: 1px solid var(--rule);
  border-radius: var(--r);
  padding: 28px;
}

/* ─── DARK BAND ─────────────────────────────────────────── */
.dark-band {
  background: var(--dark);
  color: var(--dark-fg);
  position: relative;
  overflow: hidden;
}
.dark-band-glow {
  position: absolute;
  pointer-events: none;
  background: radial-gradient(circle, var(--acc-glow), transparent 65%);
  filter: blur(60px);
}
.dark-band .h2,
.dark-band h2 {
  color: var(--dark-fg);
}
.dark-band .body,
.dark-band .lead {
  color: var(--dark-fg-60);
}

/* ─── FOOTER ────────────────────────────────────────────── */
.footer {
  padding: 56px 64px 36px;
  border-top: 1px solid var(--rule);
}
.footer-grid {
  max-width: var(--maxw);
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1.6fr repeat(4, 1fr);
  gap: 32px;
}
.footer-col-title {
  font-family: 'Geist Mono', monospace;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--fg);
  text-transform: uppercase;
}
.footer-col ul {
  list-style: none;
  padding: 0;
  margin: 14px 0 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.footer-bottom {
  max-width: var(--maxw);
  margin: 40px auto 0;
  padding-top: 24px;
  border-top: 1px solid var(--rule);
  display: flex;
  justify-content: space-between;
  font-family: 'Geist Mono', monospace;
  font-size: 12px;
  color: rgba(12, 12, 14, 0.72);
  letter-spacing: 0.02em;
}

/* ─── UTILITIES ─────────────────────────────────────────── */
.flex {
  display: flex;
}
.flex-col {
  display: flex;
  flex-direction: column;
}
.items-center {
  align-items: center;
}
.justify-between {
  justify-content: space-between;
}
.gap-2 {
  gap: 8px;
}
.gap-3 {
  gap: 12px;
}
.gap-4 {
  gap: 16px;
}
.gap-6 {
  gap: 24px;
}
.gap-8 {
  gap: 32px;
}
.mt-1 {
  margin-top: 4px;
}
.mt-2 {
  margin-top: 8px;
}
.mt-3 {
  margin-top: 12px;
}
.mt-4 {
  margin-top: 16px;
}
.mt-6 {
  margin-top: 24px;
}
.mt-8 {
  margin-top: 32px;
}
.mt-12 {
  margin-top: 48px;
}
.mt-16 {
  margin-top: 64px;
}
.grid {
  display: grid;
}
.grid-2 {
  grid-template-columns: repeat(2, 1fr);
}
.grid-3 {
  grid-template-columns: repeat(3, 1fr);
}
.grid-4 {
  grid-template-columns: repeat(4, 1fr);
}
.text-center {
  text-align: center;
}
.stack {
  display: flex;
  flex-direction: column;
}
.stack > * {
  margin: 0;
}
.stack > * + * {
  margin-top: var(--stack-gap, 16px);
}
.cluster {
  display: flex;
  flex-wrap: wrap;
  gap: var(--cluster-gap, 12px);
  align-items: center;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Responsive production defaults. The exploration canvas intentionally keeps
   its fixed artboard dimensions and does not use this stylesheet. */
@media (max-width: 980px) {
  .nav {
    padding: 18px 24px;
  }
  .nav-left {
    gap: 20px;
  }
  .nav-links {
    display: none;
  }
  .container {
    padding: 0 28px;
  }
  .section {
    padding: 72px 0;
  }
  .section-tight {
    padding: 48px 0;
  }
  .h1 {
    font-size: 68px;
  }
  .h2 {
    font-size: 44px;
  }
  .grid-3,
  .grid-4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .footer {
    padding: 44px 28px 28px;
  }
  .footer-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .footer-grid > :first-child {
    grid-column: 1 / -1;
  }
  .hero,
  .page-hero {
    padding: 48px 28px 56px !important;
  }
  .hero-grid,
  .feat-row2,
  .featured-case,
  .faq-row,
  .dark-band .container > .grid,
  .cta-block {
    grid-template-columns: 1fr !important;
  }
  .logo-strip {
    padding: 24px 28px !important;
  }
  .logo-strip-inner {
    flex-wrap: wrap;
    justify-content: flex-start !important;
    gap: 18px 28px;
  }
  .dark-stats-grid,
  .tier-grid,
  .customer-grid,
  .ind-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }
  .uc-grid,
  .provider-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }
  .feat-layout {
    grid-template-columns: 1fr !important;
    gap: 24px !important;
    padding: 20px 28px 72px !important;
  }
  .feat-layout .toc {
    display: none;
  }
  .compare-section,
  .faq-section,
  .ind-strip,
  .logo-wall {
    padding-left: 28px !important;
    padding-right: 28px !important;
  }
}

@media (max-width: 680px) {
  .nav {
    padding: 14px 18px;
  }
  .nav-right .link {
    display: none;
  }
  .container {
    padding: 0 18px;
  }
  .section {
    padding: 56px 0;
  }
  .h1 {
    font-size: 48px;
    line-height: 0.98;
  }
  .h2 {
    font-size: 36px;
    line-height: 1.04;
  }
  .h3 {
    font-size: 23px;
  }
  .lead {
    font-size: 17px;
  }
  .grid-2,
  .grid-3,
  .grid-4 {
    grid-template-columns: 1fr;
  }
  .card,
  .card-dark,
  .card-flat {
    padding: 22px;
  }
  .footer {
    padding: 36px 18px 24px;
  }
  .footer-grid {
    grid-template-columns: 1fr 1fr;
    gap: 28px 18px;
  }
  .footer-bottom {
    flex-direction: column;
    gap: 8px;
  }
  .hero,
  .page-hero {
    padding: 38px 18px 44px !important;
  }
  .hero-grid {
    gap: 28px !important;
  }
  .logo-strip {
    padding: 20px 18px !important;
  }
  .dark-stats-grid,
  .tier-grid,
  .customer-grid,
  .ind-grid,
  .uc-grid,
  .provider-grid,
  .logo-grid {
    grid-template-columns: 1fr !important;
  }
  .cta-block {
    padding: 42px 24px !important;
  }
  .feat-layout {
    padding: 12px 18px 56px !important;
  }
  .next-prev {
    grid-template-columns: 1fr !important;
  }
  .compare-section,
  .faq-section,
  .ind-strip,
  .logo-wall {
    padding-left: 18px !important;
    padding-right: 18px !important;
  }
}

/* Cargo + Cobalt production layer */
html {
  background: var(--bg);
}

body {
  min-height: 100vh;
  min-height: 100dvh;
}

::selection {
  background: var(--acc);
  color: #fff;
}

button,
input,
select,
textarea {
  font-family: var(--font-sans);
}

h1,
h2,
h3,
h4,
h5,
h6,
p,
a,
label,
table {
  font-family: inherit;
}

.italic {
  font-family: var(--font-accent);
}

.mono {
  font-family: var(--font-mono);
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

:focus-visible {
  outline: 3px solid rgba(0, 102, 255, 0.28);
  outline-offset: 3px;
}

.nav {
  border-top: 3px solid var(--dark);
}

.btn {
  min-height: 42px;
  justify-content: center;
}

.btn:active {
  transform: translateY(0);
}

.btn[disabled] {
  cursor: not-allowed;
  opacity: 0.48;
  transform: none;
}

.card,
.card-dark,
.card-flat {
  isolation: isolate;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}

/* Prevent flash of unauthenticated / unstyled content before auth/page initialization */
body[data-auth-page],
body[data-app-page],
body.auth-page,
body.app-page {
  visibility: hidden;
}

/* Fitts's Law: 44px+ invisible hit area for text links on touch devices */
@media (pointer: coarse) {
  .nav-right .link {
    position: relative;
  }
  .nav-right .link::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    min-width: 44px;
    min-height: 44px;
    width: 100%;
    height: 100%;
  }
}
