/* ============================================================
   HAULADAY — "Waybill" design language
   Industrial dispatch board: kraft ground, ink-navy panels,
   safety-orange wayfinding, cargo-yellow signal, mono manifest
   numerals, dashed route strokes, rubber-stamp moments.
   Estate collision note: nearest palettes are Ink & Manila
   (Unfiled) and Slate & Mustard (Macromic) — neither carries
   the hi-vis orange wayfinding system used here.
   ============================================================ */

:root {
  --paper: #F3EDE2;      /* kraft ground */
  --paper-2: #EAE1CF;
  --ink: #14263B;        /* navy ink */
  --ink-2: #31465E;
  --line: #D9CFBA;       /* street ruling */
  --accent: #FF6A13;     /* safety orange — wayfinding */
  --accent-deep: #D5550C;
  --cargo: #FFC53D;      /* cargo yellow — signal */
  --ok: #3E8E5A;
  --shadow: 0 2px 0 rgba(20, 38, 59, .18);
  --radius: 10px;
  --mono: ui-monospace, "Cascadia Mono", Consolas, "SF Mono", Menlo, monospace;
}

* { box-sizing: border-box; }

/* author display rules must never resurrect a hidden element */
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background:
    radial-gradient(1200px 500px at 50% -10%, rgba(255, 197, 61, .10), transparent 60%),
    repeating-linear-gradient(0deg, transparent 0 27px, rgba(20, 38, 59, .035) 27px 28px),
    repeating-linear-gradient(90deg, transparent 0 27px, rgba(20, 38, 59, .035) 27px 28px),
    var(--paper);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  line-height: 1.45;
  min-height: 100vh;
}

.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }

/* hazard stripe — the estate signature strip */
.hazard {
  height: 10px;
  background: repeating-linear-gradient(-45deg, var(--cargo) 0 12px, var(--ink) 12px 24px);
}
.hazard-thin { height: 6px; margin: -1rem -1.25rem 1rem; }

/* ---------- header ---------- */
.top {
  max-width: 560px;
  margin: 0 auto;
  padding: 14px 16px 6px;
}
.brand { display: flex; align-items: center; gap: 12px; }
.mark { width: 46px; height: 46px; flex: none; border-radius: 10px; box-shadow: var(--shadow); }
.word {
  margin: 0;
  font-size: 1.45rem;
  font-weight: 900;
  letter-spacing: .14em;
  line-height: 1;
}
.tag { margin: 3px 0 0; font-size: .78rem; color: var(--ink-2); font-weight: 600; }

.chips { display: flex; gap: 8px; margin: 12px 0 4px; flex-wrap: wrap; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #fff;
  border: 1.5px solid var(--ink);
  border-radius: 999px;
  padding: 3px 12px;
  font-size: .8rem;
  font-weight: 700;
  box-shadow: var(--shadow);
}
.chip-strong { background: var(--ink); color: var(--paper); }
.chip-fire { background: var(--cargo); border-color: var(--ink); }

.controls {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 8px 0 2px;
  justify-content: flex-end;
}
.lang-label { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-2); }
.lang-select {
  font: inherit;
  font-size: .82rem;
  font-weight: 700;
  border: 1.5px solid var(--ink);
  border-radius: 8px;
  background: #fff;
  padding: 4px 6px;
  color: var(--ink);
}

/* ---------- board ---------- */
main { max-width: 560px; margin: 0 auto; padding: 6px 16px 24px; }
.board-wrap {
  background: var(--paper-2);
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  box-shadow: 0 3px 0 rgba(20, 38, 59, .25);
  padding: 8px;
}
#board { display: block; width: 100%; height: auto; touch-action: manipulation; }
.board-meta { display: flex; gap: 8px; padding: 6px 4px 2px; flex-wrap: wrap; }
.badge {
  font-size: .68rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .07em;
  padding: 2px 8px;
  border-radius: 4px;
  border: 1.5px solid var(--ink);
  background: #fff;
}
.badge-depot { background: var(--ink); color: var(--paper); }
.badge-pick { background: var(--accent); color: #fff; }
.badge-drop { background: #fff; color: var(--ink); }

/* SVG markers */
.street { stroke: var(--line); stroke-width: 1.5; }
.route-path {
  fill: none;
  stroke: var(--accent);
  stroke-width: 4;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 8 7;
  animation: march 1.2s linear infinite;
}
.route-path.draw { animation: march 1.2s linear infinite; }
@keyframes march { to { stroke-dashoffset: -30; } }

.stop { cursor: pointer; outline-offset: 3px; }
.stop:focus-visible { outline: 3px solid var(--accent); }
.stop.locked { cursor: not-allowed; opacity: .45; }
.stop.visited { cursor: default; opacity: .8; }
.crate { fill: var(--accent); stroke: var(--ink); stroke-width: 2; }
.crate-tape { stroke: var(--ink); stroke-width: 1.4; opacity: .55; }
.warehouse { fill: #fff; stroke: var(--ink); stroke-width: 2; }
.stop.delivered .warehouse { fill: var(--cargo); }
.stop.delivered .check { display: block; }
.check { display: none; stroke: var(--ink); stroke-width: 3.2; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.depot-c { fill: var(--ink); stroke: var(--paper); stroke-width: 2.5; }
.stop-num {
  font-family: var(--mono);
  font-size: 9.5px;
  font-weight: 700;
  fill: var(--ink);
  paint-order: stroke;
  stroke: #fff;
  stroke-width: 3px;
  pointer-events: none;
}
.shake { animation: shake .35s ease; }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-3px); }
  50% { transform: translateX(3px); }
  75% { transform: translateX(-2px); }
}

/* ---------- route panel ---------- */
.panel {
  background: #fff;
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  box-shadow: 0 3px 0 rgba(20, 38, 59, .25);
  margin-top: 14px;
  padding: 12px 14px;
}
.panel-row { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.panel-title { margin: 0; font-size: .95rem; font-weight: 900; text-transform: uppercase; letter-spacing: .1em; }
.served { font-size: .85rem; font-weight: 700; color: var(--accent-deep); }
.route-list { margin: 10px 0 6px; padding: 0; list-style: none; display: flex; flex-wrap: wrap; gap: 6px; }
.route-list li {
  font-family: var(--mono);
  font-size: .74rem;
  font-weight: 700;
  border: 1.5px solid var(--ink);
  border-radius: 6px;
  padding: 2px 7px;
  background: var(--paper);
}
.route-list li.d { background: var(--cargo); }
.route-list .empty { border: 1.5px dashed var(--ink-2); background: transparent; color: var(--ink-2); }
.hint { margin: 6px 0 0; font-size: .82rem; color: var(--ink-2); }
.hint.dim { font-size: .74rem; opacity: .8; }
.actions { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }

/* ---------- buttons ---------- */
.btn {
  font: inherit;
  font-size: .85rem;
  font-weight: 800;
  letter-spacing: .03em;
  border-radius: 8px;
  padding: 9px 16px;
  cursor: pointer;
  border: 2px solid var(--ink);
  box-shadow: var(--shadow);
  transition: transform .06s ease;
}
.btn:active { transform: translateY(2px); box-shadow: none; }
.btn.primary { background: var(--ink); color: var(--paper); }
.btn.primary:disabled {
  background: transparent;
  color: var(--ink-2);
  border-style: dashed;
  box-shadow: none;
  cursor: not-allowed;
}
.btn.ghost { background: #fff; color: var(--ink); }
.btn.small { font-size: .74rem; padding: 5px 10px; }
.btn.primary:not(:disabled) { background: var(--accent); border-color: var(--accent-deep); color: #fff; }

/* ---------- stats ---------- */
.stats { margin-top: 18px; }
.stats-title { font-size: .9rem; font-weight: 900; text-transform: uppercase; letter-spacing: .1em; margin: 0 0 8px; }
.stat-row { display: flex; gap: 8px; }
.stat {
  flex: 1;
  background: #fff;
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 8px 6px;
  text-align: center;
}
.stat-num { display: block; font-size: 1.3rem; font-weight: 700; }
.stat-label { font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: var(--ink-2); }
.dist { margin-top: 12px; display: grid; gap: 5px; }
.dist-row { display: flex; align-items: center; gap: 8px; font-size: .78rem; }
.dist-bar { flex: 1; height: 12px; background: #fff; border: 1.5px solid var(--ink); border-radius: 4px; overflow: hidden; }
.dist-bar i { display: block; height: 100%; background: var(--accent); width: 0; min-width: 0; transition: width .4s ease; }
.dist-n { width: 2.2em; text-align: end; }
.next { margin: 14px 0 0; font-size: .82rem; font-weight: 600; color: var(--ink-2); }

/* ---------- footer ---------- */
.foot { max-width: 560px; margin: 0 auto; padding: 8px 16px 28px; font-size: .78rem; }
.foot-links { display: flex; gap: 8px; align-items: center; }
.foot-links a { color: var(--ink); font-weight: 700; }
.rights { color: var(--ink-2); margin: 6px 0 0; }

/* ---------- toast ---------- */
.toast {
  position: fixed;
  inset-inline: 0;
  bottom: max(18px, env(safe-area-inset-bottom));
  margin-inline: auto;
  width: max-content;
  max-width: 88vw;
  background: var(--cargo);
  color: var(--ink);
  border: 2px solid var(--ink);
  border-radius: 8px;
  padding: 8px 14px;
  font-size: .84rem;
  font-weight: 800;
  box-shadow: 0 3px 0 rgba(20, 38, 59, .3);
  z-index: 60;
}

/* ---------- dialogs ---------- */
.dlg {
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  background: var(--paper);
  color: var(--ink);
  padding: 1rem 1.25rem;
  max-width: 420px;
  width: calc(100vw - 40px);
  box-shadow: 0 8px 0 rgba(20, 38, 59, .25);
}
.dlg::backdrop { background: rgba(20, 38, 59, .62); }
.dlg h2 { margin: .2rem 0 .6rem; font-size: 1.05rem; text-transform: uppercase; letter-spacing: .08em; }
.help-list { margin: 0 0 1rem; padding-inline-start: 1.2rem; display: grid; gap: 8px; font-size: .9rem; }
.dlg-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: .4rem; }

.stamp {
  border: 3px double var(--ink);
  border-radius: 8px;
  padding: 12px 10px;
  text-align: center;
  background: #fff;
  transform: rotate(-2deg);
  margin: 4px 2px 14px;
}
.stamp-word { display: block; font-weight: 900; text-transform: uppercase; letter-spacing: .12em; font-size: 1.05rem; }
.stamp-stars { display: block; font-size: 1.5rem; letter-spacing: .3em; color: var(--accent-deep); margin-top: 2px; }
.dlg-result .stamp.pop { animation: stamp .38s cubic-bezier(.2, 1.4, .4, 1); }
@keyframes stamp {
  0% { transform: rotate(-2deg) scale(1.7); opacity: 0; }
  60% { transform: rotate(-2deg) scale(.95); opacity: 1; }
  100% { transform: rotate(-2deg) scale(1); }
}
.result-rows { display: grid; gap: 4px; margin-bottom: .6rem; }
.r-row { display: flex; justify-content: space-between; font-size: .92rem; font-weight: 600; padding: 6px 10px; background: #fff; border: 1.5px solid var(--ink); border-radius: 6px; }
.r-opt { background: var(--paper); }

/* ---------- reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  .route-path, .route-path.draw { animation: none; }
  .shake, .dlg-result .stamp.pop { animation: none; }
  .dist-bar i { transition: none; }
  .btn { transition: none; }
}

@media (min-width: 560px) {
  .top, main, .foot { max-width: 620px; }
}
