/* ================================================================
   PIPEWORKS — pneumatic dispatch desk
   Direction: Blueprint Technical, inverted to cream vellum.
   Type: Work Sans (display/body) + IBM Plex Mono (labels/data).
   ================================================================ */

@font-face {
  font-family: 'Work Sans';
  src: url('assets/work-sans.ttf') format('truetype');
  font-weight: 100 900;
  font-display: swap;
}
@font-face {
  font-family: 'IBM Plex Mono';
  src: url('assets/ibm-plex-mono.ttf') format('truetype');
  font-weight: 400;
  font-display: swap;
}

:root {
  --bg: #E7DFC8;
  --paper: #F3EDDC;
  --ink: #20304A;
  --muted: #5D6577;
  --line: rgba(32, 48, 74, 0.28);
  --line-soft: rgba(32, 48, 74, 0.16);
  --accent: #0E6E86;
  --accent-ink: #F3EDDC;

  --todo-ink: #525D6E;      --todo-fill: #8B94A3;
  --prog-ink: #8A5A12;      --prog-fill: #C98A2D;
  --blocked-ink: #A03326;   --blocked-fill: #C24E38;
  --done-ink: #2F5D3C;      --done-fill: #4C8A5C;

  --radius: 2px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

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

body {
  font-family: 'Work Sans', system-ui, -apple-system, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  color: var(--ink);
  background:
    repeating-linear-gradient(0deg,  rgba(32,48,74,0.05) 0 1px, transparent 1px 28px),
    repeating-linear-gradient(90deg, rgba(32,48,74,0.05) 0 1px, transparent 1px 28px),
    var(--bg);
  overflow-x: clip;
}

.mono {
  font-family: 'IBM Plex Mono', ui-monospace, 'SF Mono', Menlo, monospace;
  letter-spacing: 0.06em;
}

.sr {
  position: absolute; width: 1px; height: 1px;
  clip-path: inset(50%); overflow: hidden; white-space: nowrap;
}

/* ---------------- the sheet (drawing frame) ---------------- */

.sheet {
  max-width: 1400px;
  margin: 20px auto 48px;
  border: 2px solid var(--ink);
  background: var(--paper);
  position: relative;
}
.sheet::after {
  content: "";
  position: absolute; inset: 5px;
  border: 1px solid var(--line);
  pointer-events: none;
}
.sheet > * { position: relative; z-index: 1; }

/* ---------------- title block ---------------- */

.tblock {
  display: grid;
  grid-template-columns: minmax(220px, 1.7fr) repeat(5, minmax(96px, auto));
  border-bottom: 2px solid var(--ink);
}
.tcell {
  padding: 16px 18px 14px;
  border-left: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 3px;
  justify-content: center;
  min-width: 0;
}
.tcell:first-child { border-left: none; }
.tlabel { font-size: 10px; color: var(--muted); text-transform: uppercase; }
.tval { font-size: 13px; white-space: nowrap; }

.brand {
  font-size: clamp(24px, 2.4vw, 30px);
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1;
}
.brandSub { font-size: 13px; color: var(--muted); margin-top: 4px; }

/* ---------------- deck grid ---------------- */

.deck {
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
}

.fig {
  border-right: 1px solid var(--line);
  padding: 26px 22px 22px;
}
.figcap {
  font-size: 11px; text-transform: uppercase;
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 14px;
}
.dotLive {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--accent);
  animation: blink 2.4s steps(1) infinite;
}
@keyframes blink { 50% { opacity: 0.25; } }

.schemWrap { position: sticky; top: 18px; }
.schemScroll { overflow-x: auto; scrollbar-width: thin; }
.schemScroll svg { display: block; width: 100%; height: auto; }
.schemHint {
  font-size: 10px; color: var(--muted);
  margin-top: 10px; text-transform: uppercase;
}
.schemHint--mobile { display: none; }

/* dispatch log — lives under the schematic, records reroutes */
.dlog {
  margin-top: 18px;
  border-top: 1px dashed var(--line);
  padding-top: 14px;
}
.dlogTitle {
  font-size: 10px; text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 10px;
}
.dlogList {
  list-style: none;
  display: grid; gap: 8px;
}
.dlogList li {
  font-size: 11px;
  line-height: 1.45;
  color: var(--ink);
  border-left: 2px solid var(--accent);
  padding-left: 9px;
  overflow-wrap: anywhere;
}

/* schematic drawing */
.tube {
  fill: none;
  stroke: var(--ink);
  stroke-width: 3;
  stroke-linecap: round;
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
  animation: draw 0.9s var(--ease) forwards;
}
.tube--lane { animation-delay: 0.25s; }
.laneBin:nth-of-type(2) .tube--lane { animation-delay: 0.35s; }
.laneBin:nth-of-type(3) .tube--lane { animation-delay: 0.45s; }
.laneBin:nth-of-type(4) .tube--lane { animation-delay: 0.55s; }
@keyframes draw { to { stroke-dashoffset: 0; } }

.junction { fill: var(--paper); stroke: var(--ink); stroke-width: 2.5; }

.anno {
  font-family: 'IBM Plex Mono', ui-monospace, monospace;
  font-size: 11px;
  letter-spacing: 0.1em;
  fill: var(--muted);
}
.anno--dim { font-size: 9px; opacity: 0.8; }

.bin {
  fill: var(--paper);
  stroke: var(--ink);
  stroke-width: 2;
  transition: fill 0.18s var(--ease);
}
.binLetter {
  font-family: 'IBM Plex Mono', ui-monospace, monospace;
  font-size: 26px; font-weight: 700;
  fill: var(--ink);
}
.binName {
  font-family: 'IBM Plex Mono', ui-monospace, monospace;
  font-size: 11px; letter-spacing: 0.1em;
  fill: var(--muted);
}
.binCount {
  font-family: 'IBM Plex Mono', ui-monospace, monospace;
  font-size: 16px; font-weight: 700;
  fill: var(--accent);
}

.laneBin { cursor: pointer; }
.laneBin .hit { fill: transparent; }
.laneBin:hover .bin { fill: rgba(14, 110, 134, 0.08); }
.laneBin:focus-visible { outline: none; }
.laneBin:active .bin { stroke-width: 4; }
.laneBin:focus-visible .bin,
.laneBin:focus .bin { stroke: var(--accent); stroke-width: 4; }
.laneBin[aria-pressed="true"] .bin { fill: var(--accent); }
.laneBin[aria-pressed="true"] .binLetter,
.laneBin[aria-pressed="true"] .binName { fill: var(--accent-ink); }
.laneBin[aria-pressed="true"] .binCount { fill: var(--accent-ink); }

.cap { transition: cx 0.3s var(--ease), cy 0.3s var(--ease); }
.capAmb { fill: var(--accent); opacity: 0.7; }

/* ---------------- console ---------------- */

.desk { padding: 26px 30px 34px; min-width: 0; }

.console {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 230px;
  gap: 18px;
}
.lab {
  display: block;
  font-size: 10px; text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 6px;
}
input[type="search"], select {
  width: 100%;
  font-family: 'Work Sans', system-ui, sans-serif;
  font-size: 16px;
  color: var(--ink);
  background: var(--paper);
  border: 1.5px solid var(--ink);
  border-radius: var(--radius);
  padding: 10px 12px;
  min-height: 46px;
}
input[type="search"]::placeholder { color: var(--muted); }
input[type="search"]:focus-visible,
select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.countLine { font-size: 11px; color: var(--muted); margin-top: 12px; }

.secTitle {
  font-size: 12px; text-transform: uppercase;
  margin: 26px 0 6px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--ink);
}

/* ---------------- manifest rows ---------------- */

.manifest { list-style: none; }
.row { border-bottom: 1px solid var(--line-soft); }
.rowBtn {
  width: 100%;
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
  text-align: left;
  background: none;
  border: none;
  font: inherit;
  color: inherit;
  padding: 16px 10px;
  cursor: pointer;
  min-height: 72px;
}
.rowNo {
  font-size: 20px;
  color: var(--muted);
  align-self: start;
  margin-top: 2px;
}
.rowMain { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.rowTitle {
  font-size: 17px;
  font-weight: 600;
  line-height: 1.35;
  text-decoration: underline transparent 2px;
  text-underline-offset: 3px;
  transition: text-decoration-color 0.18s var(--ease);
}
.rowMeta {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  overflow-wrap: anywhere;
}
.rowSide {
  display: flex; flex-direction: column; align-items: flex-end; gap: 8px;
  flex-shrink: 0;
}
.prio { display: flex; align-items: center; gap: 7px; }
.bars { display: inline-flex; gap: 2.5px; }
.bars i {
  width: 4px; height: 12px;
  border: 1px solid var(--muted);
  display: inline-block;
}
.bars i.on { background: var(--ink); border-color: var(--ink); }
.prioTxt { font-size: 10px; color: var(--muted); }

.chip {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  border: 1.5px solid currentColor;
  border-radius: var(--radius);
  padding: 3px 10px 2px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  white-space: nowrap;
}
.chip::before {
  content: "";
  width: 8px; height: 8px; border-radius: 50%;
  background: currentColor;
}
.chip--todo        { color: var(--todo-ink); }
.chip--in-progress { color: var(--prog-ink); }
.chip--blocked     { color: var(--blocked-ink); }
.chip--done        { color: var(--done-ink); }
.chip--in-progress::before,
.chip--done::before { background: transparent; box-shadow: inset 0 0 0 3px currentColor; }
.chip--in-progress::before { box-shadow: inset 0 0 0 2.5px currentColor; }

@media (hover: hover) and (pointer: fine) {
  .rowBtn:hover { background: rgba(14, 110, 134, 0.06); }
  .rowBtn:hover .rowTitle { text-decoration-color: var(--accent); }
  .laneBin:hover .binName { fill: var(--ink); }
}
.rowBtn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}
.rowBtn:active { transform: scale(0.995); }
.rowBtn, .btn, .wbClose, .empty button { transition: background 0.18s var(--ease), transform 0.12s var(--ease); }

/* ---------------- empty state ---------------- */

.empty {
  border: 1.5px dashed var(--line);
  padding: 44px 28px;
  text-align: center;
  margin-top: 18px;
}
.emptyTitle { font-size: 13px; text-transform: uppercase; margin-bottom: 8px; }
.emptyBody {
  color: var(--muted);
  font-size: 15px;
  max-width: 44ch;
  margin: 0 auto 20px;
}
.btn {
  font-family: 'Work Sans', system-ui, sans-serif;
  font-size: 15px;
  font-weight: 600;
  background: var(--accent);
  color: var(--accent-ink);
  border: 1.5px solid var(--accent);
  border-radius: var(--radius);
  padding: 12px 22px;
  cursor: pointer;
  min-height: 46px;
}
.btn:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.btn:active { transform: scale(0.97); }
@media (hover: hover) and (pointer: fine) {
  .btn:hover { background: #0A576B; border-color: #0A576B; }
}

/* ---------------- footer strip ---------------- */

.strip {
  display: flex; align-items: center; gap: 16px;
  border-top: 2px solid var(--ink);
  padding: 14px 22px;
  font-size: 10px;
  text-transform: uppercase;
  color: var(--muted);
  flex-wrap: wrap;
}
.stripRule { flex: 1; border-top: 1px dashed var(--line); min-width: 24px; }

/* ---------------- waybill overlay ---------------- */

.overlay { position: fixed; inset: 0; z-index: 50; }
.scrim {
  position: absolute; inset: 0;
  background: rgba(32, 48, 74, 0.45);
}
.waybill {
  position: absolute; top: 0; right: 0; bottom: 0;
  width: min(620px, 100%);
  background: var(--paper);
  border-left: 2px solid var(--ink);
  overflow-y: auto;
  padding: 26px 30px 56px;
  transform: translateX(103%);
  transition: transform 0.28s var(--ease);
}
.overlay.open .waybill { transform: none; }
body.locked { overflow: hidden; }

.wbHead { position: relative; padding-right: 52px; }
.wbNo { font-size: 11px; color: var(--accent); text-transform: uppercase; margin-bottom: 8px; }
.wbTitle {
  font-size: clamp(22px, 3vw, 30px);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.15;
  padding-bottom: 16px;
  border-bottom: 2px solid var(--ink);
}
.wbClose {
  position: absolute; top: -4px; right: 0;
  width: 44px; height: 44px;
  display: grid; place-items: center;
  background: var(--paper);
  border: 1.5px solid var(--ink);
  border-radius: var(--radius);
  color: var(--ink);
  cursor: pointer;
}
.wbClose:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.wbClose:active { transform: scale(0.94); }
@media (hover: hover) and (pointer: fine) {
  .wbClose:hover { background: var(--ink); color: var(--paper); }
}

/* rubber stamp feedback — in flow, right-aligned, tilted */
.stamp {
  display: table;
  margin: 16px 4px 0 auto;
  transform: rotate(-7deg);
  border: 3px solid currentColor;
  box-shadow: inset 0 0 0 1.5px var(--paper), inset 0 0 0 2.5px currentColor;
  padding: 5px 14px 3px;
  font-size: 14px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--accent);
  pointer-events: none;
  animation: stampIn 0.35s var(--ease);
  background: rgba(243, 237, 220, 0.92);
}
.stamp--todo        { color: var(--todo-ink); }
.stamp--in-progress { color: var(--prog-ink); }
.stamp--blocked     { color: var(--blocked-ink); }
.stamp--done        { color: var(--done-ink); }
@keyframes stampIn {
  0%   { opacity: 0; transform: rotate(-7deg) scale(1.7); }
  70%  { opacity: 1; transform: rotate(-7deg) scale(0.94); }
  100% { opacity: 1; transform: rotate(-7deg) scale(1); }
}

.wbMeta {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border: 1px solid var(--line);
  margin-top: 20px;
}
.wbMeta > div {
  padding: 10px 12px;
  border-right: 1px solid var(--line-soft);
  border-bottom: 1px solid var(--line-soft);
}
.wbMeta > div:nth-child(3n) { border-right: none; }
.wbMeta > div:nth-child(n+4) { border-bottom: none; }
.wbMeta dt { font-size: 9px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.12em; }
.wbMeta dd { font-size: 12.5px; margin-top: 3px; overflow-wrap: anywhere; }

.wbRoute {
  margin-top: 22px;
  border: 1.5px solid var(--ink);
  padding: 16px 16px 12px;
  background: rgba(14, 110, 134, 0.05);
}
.routeHint { font-size: 10px; color: var(--muted); margin-top: 8px; text-transform: uppercase; }
.wbRoute select { background: var(--paper); }

.wbBody { margin-top: 26px; max-width: 58ch; }
.wbBody p { font-size: 16px; line-height: 1.65; }
.wbBody p + p { margin-top: 14px; }
.wbBody .callout {
  border-left: 3px solid var(--accent);
  background: rgba(14, 110, 134, 0.06);
  padding: 12px 16px;
  font-size: 15px;
}
.wbTags { margin-top: 22px; font-size: 11px; color: var(--muted); text-transform: uppercase; }

/* ---------------- toast ---------------- */

.toast {
  position: fixed;
  left: 50%; bottom: 26px;
  transform: translateX(-50%) translateY(80px);
  background: var(--ink);
  color: var(--paper);
  font-size: 12px;
  padding: 11px 18px;
  z-index: 60;
  pointer-events: none;
  opacity: 0;
  transition: transform 0.25s var(--ease), opacity 0.25s var(--ease);
  max-width: min(88vw, 480px);
  text-align: center;
}
.toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }

/* ---------------- entrances ---------------- */

.tblock, .fig, .desk {
  animation: settle 0.6s var(--ease) backwards;
}
.fig { animation-delay: 0.08s; }
.desk { animation-delay: 0.16s; }
@keyframes settle {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: none; }
}

/* ---------------- responsive ---------------- */

@media (max-width: 980px) {
  .deck { grid-template-columns: 1fr; }
  .fig { border-right: none; border-bottom: 1px solid var(--line); padding: 20px 20px 18px; }
  .schemWrap { position: static; }
  .schemScroll svg { width: 640px; max-width: none; }
  .schemHint--mobile { display: block; }
  .schemHint:not(.schemHint--mobile) { display: none; }
  .tblock { grid-template-columns: 1fr 1fr 1fr; }
  .tcell--brand { grid-column: 1 / -1; border-left: none; border-bottom: 1px solid var(--line); }
}
@media (max-width: 640px) {
  body { font-size: 15px; }
  .sheet { margin: 10px 10px 28px; }
  .tblock { grid-template-columns: 1fr 1fr; }
  .tcell { padding: 12px 14px; }
  .tcell--brand { grid-column: 1 / -1; }
  .deck { display: block; }
  .desk { padding: 22px 20px 30px; }
  .console { grid-template-columns: 1fr; gap: 14px; }
  .rowBtn { grid-template-columns: 34px minmax(0, 1fr); padding: 14px 6px; gap: 12px; }
  .rowSide { grid-column: 2; flex-direction: row; align-items: center; justify-content: flex-start; }
  .rowNo { margin-top: 0; }
  .rowTitle { font-size: 16px; }
  .waybill { padding: 20px 20px 48px; width: 100%; }
  .wbMeta { grid-template-columns: 1fr 1fr; }
  .wbMeta > div:nth-child(3n) { border-right: 1px solid var(--line-soft); }
  .wbMeta > div:nth-child(2n) { border-right: none; }
  .wbMeta > div:nth-child(n+4) { border-bottom: 1px solid var(--line-soft); }
  .wbMeta > div:nth-child(n+5) { border-bottom: none; }
  .wbClose { position: absolute; top: 14px; right: 14px; }
  .strip { padding: 12px 16px; }
}

/* ---------------- reduced motion ---------------- */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .tube { stroke-dasharray: none; stroke-dashoffset: 0; }
  .dotLive { animation: none; }
}
