@font-face { font-family: "Big Shoulders"; font-weight: 800; font-display: swap; src: url("../../assets/fonts/big-shoulders-display-latin-800-normal.woff2") format("woff2"); }
@font-face { font-family: "Big Shoulders"; font-weight: 900; font-display: swap; src: url("../../assets/fonts/big-shoulders-display-latin-900-normal.woff2") format("woff2"); }
@font-face { font-family: "Barlow"; font-weight: 400; font-display: swap; src: url("../../assets/fonts/barlow-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Barlow"; font-weight: 500; font-display: swap; src: url("../../assets/fonts/barlow-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "Barlow"; font-weight: 600; font-display: swap; src: url("../../assets/fonts/barlow-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "Barlow Condensed"; font-weight: 500; font-display: swap; src: url("../../assets/fonts/barlow-condensed-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "Barlow Condensed"; font-weight: 600; font-display: swap; src: url("../../assets/fonts/barlow-condensed-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "Barlow Condensed"; font-weight: 700; font-display: swap; src: url("../../assets/fonts/barlow-condensed-latin-700-normal.woff2") format("woff2"); }

:root {
  /* machine shop palette */
  --shop: #26342f;        /* room, deep machine green */
  --paint: #4e6b60;       /* machine-tool green */
  --paint-hi: #6f8e81;
  --paint-lo: #3a524a;
  --enamel: #efe8d6;      /* nameplates, paper */
  --paper-line: #d9cfb6;
  --ink: #1f2a27;
  --ink-soft: #5a6661;
  --safety: #f2b705;
  --signal: #d23a2a;
  --stamp-ok: #2f7a4f;

  --display: "Big Shoulders", "Arial Narrow", sans-serif;
  --cond: "Barlow Condensed", "Arial Narrow", sans-serif;
  --body: "Barlow", system-ui, sans-serif;

  --step: 8px;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  min-height: 100vh;
  font-family: var(--body);
  font-size: 16px;
  color: var(--enamel);
  background-color: var(--shop);
  /* hammertone paint texture */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1  0 0 0 0 1  0 0 0 0 1  0 0 0 .07 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

:focus-visible { outline: 3px solid var(--safety); outline-offset: 2px; }

/* ---------- top bar ---------- */
.topbar {
  display: flex; align-items: center; gap: calc(var(--step) * 3);
  padding: calc(var(--step) * 2) calc(var(--step) * 3);
}

.nameplate {
  display: inline-flex; align-items: stretch;
  font-family: var(--display); font-weight: 900;
  font-size: 34px; line-height: 1; letter-spacing: 0.01em;
  border: 3px solid var(--enamel); border-radius: 6px;
  box-shadow: inset 0 0 0 2px var(--shop);
}
.np-main { padding: 6px 10px 4px 12px; color: var(--enamel); }
.np-ret {
  padding: 6px 12px 4px 10px;
  background: var(--enamel); color: var(--shop);
  display: inline-block;
}


/* ---------- buttons ---------- */
.btn {
  font-family: var(--cond); font-weight: 700; font-size: 18px; letter-spacing: 0.02em;
  border: 0; cursor: pointer; border-radius: 8px;
  display: inline-flex; align-items: center; gap: 8px;
  transition: transform 80ms ease, box-shadow 80ms ease;
}
.btn:disabled { opacity: 0.4; cursor: default; }
.btn-run {
  margin-left: auto;
  padding: 12px 22px;
  background: var(--safety); color: var(--ink);
  box-shadow: 0 4px 0 #a47b00;
}
.btn-run:active { transform: translateY(3px); box-shadow: 0 1px 0 #a47b00; }

/* chunky machine keys */
.btn-key {
  padding: 10px 16px;
  background: var(--paint); color: var(--enamel);
  box-shadow: 0 4px 0 var(--paint-lo), inset 0 1px 0 rgba(255,255,255,.15);
}
.btn-key:not(:disabled):active, .btn-key[aria-pressed="true"] { transform: translateY(3px); box-shadow: 0 1px 0 var(--paint-lo), inset 0 1px 0 rgba(255,255,255,.1); }
.btn-key svg { width: 18px; height: 18px; fill: currentColor; }
#play .i-pause { display: none; }
#play[aria-pressed="true"] .i-pause { display: block; }
#play[aria-pressed="true"] .i-play { display: none; }

/* ---------- layout ---------- */
.shop {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: calc(var(--step) * 3);
  padding: 0 calc(var(--step) * 3) calc(var(--step) * 3);
}

.stage {
  position: relative;
  border-radius: 14px; overflow: hidden;
  background: #1c2723;
  box-shadow: 0 0 0 3px var(--paint-lo), 0 18px 40px rgba(0,0,0,.35);
  aspect-ratio: 16 / 9;
}
.stage canvas { display: block; width: 100%; height: 100%; }

/* ---------- deck: transport + strip + speed ---------- */
.deck {
  display: grid; grid-template-columns: auto 1fr auto; align-items: center;
  gap: calc(var(--step) * 2);
  margin-top: calc(var(--step) * 2);
}
.transport { display: flex; gap: var(--step); }

.strip {
  position: relative; height: 44px;
  border-radius: 8px; background: #1c2723;
  box-shadow: inset 0 2px 6px rgba(0,0,0,.5);
  cursor: ew-resize; touch-action: none;
  padding: 6px;
}
.segments { display: flex; height: 100%; gap: 3px; }
.seg {
  position: relative; height: 100%; border-radius: 4px; min-width: 6px;
  background: repeating-linear-gradient(135deg, #33443e 0 6px, #2c3b36 6px 12px);
  font-family: var(--cond); font-weight: 600; font-size: 13px;
  color: var(--paint-hi); display: flex; align-items: center; justify-content: center;
  overflow: hidden; white-space: nowrap;
}
.seg.ran { background: var(--paint); color: var(--enamel); }
.seg.ran.fail { background: var(--signal); color: var(--enamel); }
.seg.now { box-shadow: inset 0 0 0 2px var(--safety); }
.needle {
  position: absolute; top: -4px; bottom: -4px; width: 4px; margin-left: -2px;
  left: 6px; border-radius: 2px;
  background: var(--safety);
  box-shadow: 0 0 0 2px var(--shop);
  pointer-events: none;
}

.speed { display: flex; background: #1c2723; border-radius: 8px; padding: 4px; gap: 2px; }
.spd {
  font-family: var(--cond); font-weight: 700; font-size: 16px;
  border: 0; border-radius: 6px; padding: 6px 10px; cursor: pointer;
  background: transparent; color: var(--paint-hi);
}
.spd[aria-checked="true"] { background: var(--paint); color: var(--enamel); }

/* ---------- job card (paper traveler) ---------- */
.side { display: flex; flex-direction: column; gap: calc(var(--step) * 3); }

.jobcard {
  position: relative;
  background: var(--enamel); color: var(--ink);
  border-radius: 4px;
  padding: calc(var(--step) * 2.5) calc(var(--step) * 2.5) calc(var(--step) * 2);
  box-shadow: 0 10px 24px rgba(0,0,0,.3);
}
.jc-head {
  display: flex; justify-content: space-between; align-items: flex-start;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--ink);
}
.jc-head h2 { margin: 0; font-family: var(--display); font-weight: 900; font-size: 32px; line-height: 1; }
.jc-meta { margin: 4px 0 0; font-family: var(--cond); font-weight: 500; font-size: 15px; color: var(--ink-soft); }
.jc-worker { text-align: center; border: 2px solid var(--ink); border-radius: 6px; padding: 2px 8px 4px; }
.jc-worker-id { display: block; font-family: var(--display); font-weight: 900; font-size: 24px; line-height: 1.1; }
.jc-worker-lbl { display: block; font-family: var(--cond); font-weight: 600; font-size: 12px; color: var(--ink-soft); }

.steps { list-style: none; margin: 0; padding: 0; }
.step {
  position: relative;
  display: grid; grid-template-columns: 34px 1fr 64px; align-items: center; gap: 8px;
  min-height: 44px; padding: 8px 4px;
  border-bottom: 1px solid var(--paper-line);
  font-size: 15px; line-height: 1.25;
  cursor: pointer; border-radius: 3px;
}
.step:hover { background: rgba(31, 42, 39, .05); }
.step.now { background: rgba(242, 183, 5, .28); }
.step .sid { font-family: var(--cond); font-weight: 700; color: var(--ink-soft); }
.step .verb { font-family: var(--cond); font-weight: 700; font-size: 17px; margin-right: 4px; }
.step.pending .txt { color: var(--ink-soft); }

/* ink stamps */
.stamp {
  justify-self: center;
  font-family: var(--display); font-weight: 900; font-size: 15px; letter-spacing: 0.06em;
  padding: 1px 6px 0; border: 2.5px solid currentColor; border-radius: 4px;
  opacity: 0; transform: scale(1.6) rotate(var(--rot, -6deg));
}
.stamp.ok { color: var(--stamp-ok); }
.stamp.fail { color: var(--signal); }
.stamp.on { opacity: .9; transform: scale(1) rotate(var(--rot, -6deg)); transition: transform 140ms cubic-bezier(.2,1.6,.4,1), opacity 80ms; }

.jc-seed {
  display: flex; align-items: center; gap: 8px; justify-content: flex-end;
  margin-top: calc(var(--step) * 1.5);
  font-family: var(--cond); font-weight: 600; font-size: 14px; color: var(--ink-soft);
}
.jc-seed input {
  width: 64px; font: inherit; color: var(--ink);
  background: transparent; border: 0; border-bottom: 2px solid var(--ink-soft); padding: 2px 4px;
}

/* ---------- incident tag ---------- */
.incident { position: relative; padding-left: 28px; }
.incident::before { /* the tag's string */
  content: ""; position: absolute; left: 0; top: 30px; width: 40px; height: 2px;
  background: var(--signal); transform: rotate(-18deg); transform-origin: left;
}
.tag {
  position: relative;
  background: var(--enamel); color: var(--ink);
  padding: 18px 20px 18px 34px;
  clip-path: polygon(16px 0, 100% 0, 100% 100%, 16px 100%, 0 calc(100% - 16px), 0 16px);
  box-shadow: 0 10px 24px rgba(0,0,0,.3);
}
.tag::before { /* grommet */
  content: ""; position: absolute; left: 12px; top: 18px; width: 12px; height: 12px; border-radius: 50%;
  background: var(--shop); box-shadow: 0 0 0 3px #b9c2bf;
}
.inc-title { margin: 0 0 10px; font-family: var(--display); font-weight: 900; font-size: 26px; line-height: 1; color: var(--signal); }
.tag dl { margin: 0; display: grid; gap: 2px; }
.tag dt { font-family: var(--cond); font-weight: 600; font-size: 14px; color: var(--ink-soft); margin-top: 6px; }
.tag dd { margin: 0; font-size: 16px; line-height: 1.35; }
.incident.drop .tag { animation: swing 520ms cubic-bezier(.3,1.5,.5,1); transform-origin: 0 24px; }
@keyframes swing { 0% { transform: rotate(-9deg); opacity: 0; } 100% { transform: rotate(0); opacity: 1; } }

.done {
  background: var(--stamp-ok); color: var(--enamel);
  border-radius: 8px; padding: 14px 18px;
  font-family: var(--cond); font-weight: 700; font-size: 20px;
}
.done p { margin: 0; }

/* ---------- responsive ---------- */
@media (max-width: 980px) {
  .shop { grid-template-columns: 1fr; }
  .side { display: grid; grid-template-columns: 1fr 1fr; align-items: start; }
  .side > .incident, .side > .done { order: -1; }
}
@media (max-width: 640px) {
  .topbar { flex-wrap: wrap; gap: 12px; padding: 12px 14px; }
  .nameplate { font-size: 26px; }
  .shop { padding: 0 14px 14px; }
  .side { grid-template-columns: 1fr; }
  .incident, .done { order: -1; }
  .deck { grid-template-columns: 1fr auto; }
  .strip { grid-column: 1 / -1; grid-row: 1; }
  .btn-key span { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .stamp.on { transition: none; }
  .incident.drop .tag { animation: none; }
}
