/* ============================================================
   SIDINGS — team task yard
   Freight-office print craft: kraft paper, ink rules, stamps.
   ============================================================ */

@font-face { font-family:'Oswald'; src:url('assets/oswald.ttf') format('truetype'); font-weight:400 700; font-display:swap; }
@font-face { font-family:'IBM Plex Mono'; src:url('assets/ibm-plex-mono.ttf') format('truetype'); font-weight:400 700; font-display:swap; }
@font-face { font-family:'Literata'; src:url('assets/literata.ttf') format('truetype'); font-weight:400 700; font-display:swap; }

:root {
  --paper: #e7ddc4;
  --paper-lift: #f2ead5;
  --paper-dim: #d9cca9;
  --ink: #241f15;
  --ink-soft: #57503c;
  --line-soft: #8a7f63;
  --oxide: #a83a22;
  --focus: #1d5f8a;
  --ballast: #3b3526;
  --ballast-dim: #4c4531;
  --steel: #cabd93;
  --st-todo: #7b6f4e;
  --st-progress: #2e6f8e;
  --st-blocked: #a83a22;
  --st-done: #57703f;
  --placard-high-bg: #a83a22;   --placard-high-fg: #fdf6e3;
  --placard-med-bg: #d9a53f;    --placard-med-fg: #241f15;
  --placard-low-bg: #6d7b4a;    --placard-low-fg: #fdf6e3;
  --font-display: 'Oswald', 'Arial Narrow', Impact, sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, 'Courier New', monospace;
  --font-body: 'Literata', Georgia, 'Times New Roman', serif;
}

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

[hidden] { display: none !important; }

html { scroll-behavior: smooth; }

body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
}

/* paper grain */
body::before {
  content: '';
  position: fixed; inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    repeating-linear-gradient(0deg, rgba(36,31,21,.028) 0 1px, transparent 1px 3px),
    repeating-linear-gradient(90deg, rgba(36,31,21,.02) 0 1px, transparent 1px 4px);
}

body > * { position: relative; z-index: 1; }

::selection { background: var(--oxide); color: var(--paper-lift); }

/* ---------- focus ---------- */
:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
  border-radius: 1px;
}

/* ============================================================
   MASTHEAD
   ============================================================ */
.masthead {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 24px;
  padding: 20px clamp(20px, 4vw, 48px) 12px;
  border-bottom: 3px solid var(--ink);
}

.masthead-main { display: flex; align-items: center; gap: 22px; }

.roundel {
  width: 66px; height: 66px;
  color: var(--ink);
  flex: none;
  animation: roundel-spin 26s linear infinite;
}
@keyframes roundel-spin { to { transform: rotate(360deg); } }

.masthead h1 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(44px, 5.4vw, 72px);
  line-height: .92;
  letter-spacing: .045em;
}

.tagline {
  font-family: var(--font-mono);
  font-size: 11.5px;
  letter-spacing: .16em;
  color: var(--ink-soft);
  border-top: 2px solid var(--ink);
  display: inline-block;
  padding-top: 6px;
  margin-top: 8px;
}

.masthead-side {
  text-align: right;
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: .1em;
  flex: none;
}

.yard-clock { font-weight: 700; }
.yard-clock span { color: var(--oxide); }

.occupancy {
  margin-top: 6px;
  color: var(--ink-soft);
  font-size: 11px;
  border: 2px solid var(--line-soft);
  padding: 4px 8px;
  background: var(--paper-lift);
}
.occ-seg b { color: var(--ink); font-weight: 700; }
.occ-dot { display: inline-block; width: 9px; height: 9px; margin-right: 4px; vertical-align: baseline; }

/* ============================================================
   CONTROL STRIP (ticket window)
   ============================================================ */
.control-strip {
  display: flex;
  align-items: flex-end;
  gap: 18px;
  padding: 14px clamp(20px, 4vw, 48px) 16px;
  border-bottom: 2px solid var(--ink);
  background: var(--paper-dim);
}

.field { display: flex; flex-direction: column; gap: 5px; }
.field-search { flex: 1 1 320px; min-width: 220px; }
.field-filter { flex: 0 0 auto; }

.field label {
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .22em;
  color: var(--ink-soft);
}

.field input, .field select {
  font-family: var(--font-mono);
  font-size: 15px;
  color: var(--ink);
  background: var(--paper-lift);
  border: 2px solid var(--ink);
  padding: 9px 12px;
  min-height: 44px;
  border-radius: 0;
  appearance: none;
}

.field select {
  padding-right: 34px;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--ink) 50%),
    linear-gradient(135deg, var(--ink) 50%, transparent 50%);
  background-position: calc(100% - 18px) 55%, calc(100% - 12px) 55%;
  background-size: 6px 6px;
  background-repeat: no-repeat;
  cursor: pointer;
}

.field input::placeholder { color: var(--line-soft); }

/* telex */
.telex {
  flex: 1 1 240px;
  min-width: 200px;
  display: flex;
  align-items: center;
  gap: 10px;
  border: 2px dashed var(--ink-soft);
  background: var(--paper-lift);
  padding: 10px 12px;
  min-height: 44px;
  overflow: hidden;
}
.telex-tag {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 10.5px;
  letter-spacing: .2em;
  background: var(--ink);
  color: var(--paper-lift);
  padding: 3px 7px;
  flex: none;
}
.telex-msg {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: .04em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.telex-msg.flash { animation: telex-flash .4s ease; }
@keyframes telex-flash {
  0% { color: var(--oxide); }
  100% { color: var(--ink); }
}
.telex-caret {
  color: var(--oxide);
  animation: caret-blink 1.1s steps(1) infinite;
}
@keyframes caret-blink { 50% { opacity: 0; } }

/* ============================================================
   THE YARD — four sidings
   ============================================================ */
.yard {
  padding: 18px clamp(20px, 4vw, 48px) 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.track-header {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--ink);
}
.track-chip {
  width: 15px; height: 15px;
  border: 2px solid var(--ink);
  align-self: center;
  flex: none;
}
.track-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 21px;
  letter-spacing: .07em;
  text-transform: uppercase;
}
.track-count {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .18em;
  color: var(--ink-soft);
}
.track-count b { color: var(--oxide); font-size: 15px; }

/* the rail bed */
.lane {
  --lane-color: var(--st-todo);
}
.lane[data-status="todo"] { --lane-color: var(--st-todo); }
.lane[data-status="in-progress"] { --lane-color: var(--st-progress); }
.lane[data-status="blocked"] { --lane-color: var(--st-blocked); }
.lane[data-status="done"] { --lane-color: var(--st-done); }

.lane-body {
  position: relative;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 18px 26px 8px;
  background:
    repeating-linear-gradient(90deg,
      var(--ballast) 0 46px, var(--ballast-dim) 46px 92px);
  border-left: 3px solid var(--ink);
  border-right: 3px solid var(--ink);
  border-bottom: 3px solid var(--ink);
  min-height: 158px;
  scrollbar-width: thin;
  scrollbar-color: var(--ink) var(--ballast);
}

/* sleepers + rail */
.lane-body::after {
  content: '';
  position: absolute; left: 0; right: 0; bottom: 8px; height: 15px;
  background: repeating-linear-gradient(90deg,
    #5b5138 0 9px, transparent 9px 38px);
  pointer-events: none;
}
.lane-body::before {
  content: '';
  position: absolute; left: 0; right: 0; bottom: 23px; height: 4px;
  background: linear-gradient(var(--steel), #8d8264);
  border-top: 1px solid #171309;
  z-index: 3;
  pointer-events: none;
}

.cars-row {
  display: flex;
  align-items: flex-end;
  gap: 30px;
  min-height: 128px;
  position: relative;
  z-index: 2;
  width: max-content;
  min-width: 100%;
}

.vacancy {
  align-self: center;
  font-family: var(--font-mono);
  font-size: 11.5px;
  letter-spacing: .28em;
  color: var(--steel);
  padding: 14px 4px;
  white-space: nowrap;
}

/* ============================================================
   FREIGHT CARS
   ============================================================ */
.car-wrap {
  flex: none;
  margin-bottom: 26px; /* wheels land on the rail */
}

.car {
  --car-bg: var(--paper-lift);
  width: 252px;
  display: block;
  text-align: left;
  background: var(--car-bg);
  border: 2.5px solid var(--ink);
  border-radius: 0;
  position: relative;
  padding: 0 0 10px;
  cursor: pointer;
  font-family: inherit;
  color: var(--ink);
  transition: transform .16s ease, box-shadow .16s ease, background .16s ease;
}

.car:hover {
  transform: translateY(-4px);
  box-shadow: 0 6px 0 -1px rgba(23,19,9,.45);
  background: #f7f0dd;
}
.car:hover .car-couplers { transform: translateY(-4px); }

/* couplers */
.car-couplers {
  position: absolute;
  top: 54%; height: 8px; width: 12px;
  background: var(--car-bg);
  border: 2px solid var(--ink);
  z-index: -1;
  transition: transform .16s ease;
}
.car-couplers.l { left: -12px; }
.car-couplers.r { right: -12px; }

/* status band along the roof */
.car-band {
  display: block;
  height: 9px;
  background: var(--lane-color);
  border-bottom: 2px solid var(--ink);
}

.car-no-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 8px 10px 2px;
  gap: 8px;
}

.car-no {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 23px;
  letter-spacing: .04em;
  line-height: 1;
  border-bottom: 2px dashed var(--line-soft);
}

.placard {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 9.5px;
  letter-spacing: .14em;
  padding: 3px 6px;
  border: 1.5px solid var(--ink);
  flex: none;
}
.placard.prio-high { background: var(--placard-high-bg); color: var(--placard-high-fg); }
.placard.prio-medium { background: var(--placard-med-bg); color: var(--placard-med-fg); }
.placard.prio-low { background: var(--placard-low-bg); color: var(--placard-low-fg); }

.car-title {
  display: block;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 15.5px;
  line-height: 1.22;
  letter-spacing: .02em;
  text-transform: uppercase;
  padding: 4px 10px 8px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 44px;
}

.car-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  padding: 0 10px 4px;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: .03em;
  color: var(--ink-soft);
}
.car-meta b { font-weight: 700; color: var(--ink); margin-right: 4px; }

/* wheels */
.car-wheels { position: absolute; left: 0; right: 0; bottom: -12px; height: 22px; pointer-events: none; }
.car-wheels i {
  position: absolute; bottom: 0;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: #2c2618;
  border: 3px solid #171309;
  box-shadow: inset 3px 3px 0 rgba(202,189,147,.55);
}
.car-wheels i:nth-child(1) { left: 26px; }
.car-wheels i:nth-child(2) { left: 54px; }
.car-wheels i:nth-child(3) { right: 54px; }
.car-wheels i:nth-child(4) { right: 26px; }

/* per-status car furniture */
.car-wrap.is-blocked .car::after {
  content: 'HELD';
  position: absolute; top: -13px; left: 10px;
  font-family: var(--font-mono);
  font-weight: 700; font-size: 9.5px; letter-spacing: .2em;
  background: var(--oxide); color: var(--paper-lift);
  border: 1.5px solid var(--ink);
  padding: 2px 6px;
}
.car-wrap.is-done .car { filter: grayscale(.55); opacity: .82; }
.car-wrap.is-done .delivered {
  position: absolute; top: 46%; left: 50%;
  transform: translate(-50%,-50%) rotate(-9deg);
  font-family: var(--font-display);
  font-weight: 700; font-size: 20px; letter-spacing: .18em;
  color: var(--st-done);
  border: 3px solid var(--st-done);
  padding: 1px 8px;
  opacity: .75;
  pointer-events: none;
}
.car-wrap.is-in-progress .car-band::after {
  content: 'EN ROUTE';
  float: right;
  font-family: var(--font-mono);
  font-size: 8.5px; font-weight: 700; letter-spacing: .18em;
  color: var(--paper-lift);
  margin: 1px 6px 0 0;
}

/* re-route arrival animation */
@keyframes car-roll-in {
  from { transform: translateX(-46px); opacity: 0; }
  to   { transform: translateX(0); opacity: 1; }
}
.car-wrap.just-routed { animation: car-roll-in .5s cubic-bezier(.2,.8,.3,1); }

/* ============================================================
   EMPTY STATE
   ============================================================ */
.empty {
  padding: 64px 24px 84px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}
.semaphore { width: 96px; color: var(--ink); opacity: .85; }
.empty h2 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(28px, 4vw, 42px);
  letter-spacing: .06em;
}
.empty p {
  max-width: 46ch;
  font-size: 17px;
  line-height: 1.55;
  color: var(--ink-soft);
}
.btn-recover {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 12.5px;
  letter-spacing: .16em;
  background: var(--ink);
  color: var(--paper-lift);
  border: 2px solid var(--ink);
  padding: 13px 22px;
  cursor: pointer;
  min-height: 44px;
  transition: background .16s ease, color .16s ease;
}
.btn-recover:hover { background: var(--oxide); border-color: var(--oxide); }

/* ============================================================
   WAYBILL DETAIL (ticket drawer)
   ============================================================ */
.backdrop {
  position: fixed; inset: 0;
  background: rgba(23,19,9,.5);
  z-index: 40;
  opacity: 0;
  transition: opacity .25s ease;
}
.backdrop.show { opacity: 1; }

.detail {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: min(500px, 100vw);
  z-index: 50;
  background: transparent;
  transform: translateX(103%);
  transition: transform .28s cubic-bezier(.25,.8,.3,1);
  display: flex;
}
.detail.open { transform: translateX(0); }

.waybill {
  position: relative;
  flex: 1;
  margin: 0;
  background: var(--paper-lift);
  border-left: 3px solid var(--ink);
  box-shadow: -10px 0 0 rgba(23,19,9,.18);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 20px 22px 42px;
  background-image:
    radial-gradient(circle at 0 74px, var(--paper) 13px, transparent 14px),
    radial-gradient(circle at 100% 74px, var(--paper) 13px, transparent 14px);
}

.close-btn {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 11px;
  letter-spacing: .16em;
  background: var(--ink);
  color: var(--paper-lift);
  border: 2px solid var(--ink);
  padding: 10px 14px;
  cursor: pointer;
  min-height: 40px;
  transition: background .16s ease;
}
.close-btn:hover { background: var(--oxide); border-color: var(--oxide); }

.wb-eyebrow {
  margin-top: 18px;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: .18em;
  color: var(--ink-soft);
  text-align: center;
  border-bottom: 2px dashed var(--line-soft);
  padding-bottom: 10px;
}
.wb-no {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 44px;
  letter-spacing: .05em;
  text-align: center;
  line-height: 1.05;
  padding: 12px 0 2px;
}
.wb-no small {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: .2em;
  color: var(--ink-soft);
  display: block;
}

.detail-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(23px, 5.5vw, 30px);
  line-height: 1.12;
  letter-spacing: .02em;
  text-transform: uppercase;
  padding: 8px 0 14px;
  border-bottom: 2px dashed var(--line-soft);
}

.wb-stamp {
  display: inline-block;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 16px;
  letter-spacing: .12em;
  border: 3px solid currentColor;
  padding: 3px 10px;
  transform: rotate(-3.5deg);
  margin: 16px 0 4px;
  color: var(--st-todo);
}
.wb-stamp.s-todo { color: var(--st-todo); }
.wb-stamp.s-in-progress { color: var(--st-progress); }
.wb-stamp.s-blocked { color: var(--st-blocked); }
.wb-stamp.s-done { color: var(--st-done); }

/* routing block */
.routing {
  margin-top: 18px;
  border: 2px solid var(--ink);
  background: var(--paper-dim);
  padding: 14px 14px 12px;
}
.routing-label {
  display: block;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 10.5px;
  letter-spacing: .2em;
  color: var(--ink-soft);
  margin-bottom: 8px;
}
.routing select {
  width: 100%;
  font-family: var(--font-mono);
  font-size: 15px;
  color: var(--ink);
  background: var(--paper-lift);
  border: 2px solid var(--ink);
  padding: 10px 12px;
  min-height: 44px;
  appearance: none;
  border-radius: 0;
  cursor: pointer;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--ink) 50%),
    linear-gradient(135deg, var(--ink) 50%, transparent 50%);
  background-position: calc(100% - 20px) 57%, calc(100% - 13px) 57%;
  background-size: 6px 6px;
  background-repeat: no-repeat;
}
.routing-note {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: .06em;
  color: var(--ink-soft);
  margin-top: 8px;
  min-height: 15px;
}
.routing-note.ok { color: var(--st-done); font-weight: 700; }

/* meta grid */
.wb-meta {
  margin-top: 20px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  border: 2px solid var(--ink);
}
.wb-meta > div {
  padding: 10px 12px;
  border: 1px solid var(--line-soft);
}
.wb-meta dt {
  font-family: var(--font-mono);
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: .2em;
  color: var(--ink-soft);
}
.wb-meta dd {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 400;
  letter-spacing: .05em;
  text-transform: uppercase;
  margin-top: 3px;
}
.wb-meta .full { grid-column: 1 / -1; }

/* body prose */
.wb-body { margin-top: 22px; max-width: 62ch; }
.wb-body p {
  font-size: 16.5px;
  line-height: 1.62;
  margin-bottom: 14px;
}
.wb-outcome {
  border: 2px solid var(--ink);
  border-left: 8px solid var(--st-done);
  background: var(--paper-dim);
  padding: 12px 14px;
  font-size: 16px;
  line-height: 1.55;
}
.wb-outcome .oc-tag {
  display: block;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 10px;
  letter-spacing: .22em;
  color: var(--st-done);
  margin-bottom: 5px;
}

/* slam stamp */
.slam-stamp {
  position: sticky;
  bottom: 18px;
  margin: 26px auto 0;
  width: max-content;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 24px;
  letter-spacing: .14em;
  text-align: center;
  color: var(--oxide);
  border: 4px double var(--oxide);
  padding: 8px 18px;
  transform: rotate(-7deg);
  background: rgba(242,234,213,.82);
  animation: slam .34s cubic-bezier(.2, 1.4, .4, 1) both;
}
@keyframes slam {
  0% { transform: rotate(-7deg) scale(2.8); opacity: 0; }
  60% { opacity: 1; }
  100% { transform: rotate(-7deg) scale(1); opacity: 1; }
}

/* ============================================================
   FOOTER
   ============================================================ */
.office-foot {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 26px;
  justify-content: space-between;
  padding: 14px clamp(20px, 4vw, 48px) 20px;
  border-top: 3px solid var(--ink);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: .18em;
  color: var(--ink-soft);
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 760px) {
  .masthead { align-items: flex-start; flex-direction: column; gap: 10px; padding-top: 18px; }
  .roundel { width: 48px; height: 48px; }
  .masthead h1 { font-size: 44px; }
  .masthead-side { text-align: left; display: flex; gap: 14px; align-items: center; }
  .occupancy { margin-top: 0; }
  .control-strip { flex-wrap: wrap; }
  .field-search, .field-filter { flex: 1 1 100%; }
  .telex { flex: 1 1 100%; }
  .lane-body { padding: 14px 16px 8px; }
  .cars-row { gap: 24px; }
  .car { width: 216px; }
  .detail { width: 100vw; }
  .waybill { border-left: none; box-shadow: none; }
}

/* ============================================================
   REDUCED MOTION
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
  .roundel { animation: none; }
  .telex-caret { animation: none; }
  .car:hover { transform: none; }
  .detail { transform: none; }
  .detail:not(.open) { display: none; }
}
