/* Postmark — see design/postmark.html for the system this implements.

   Three colour rules hold the whole thing together:
   - --teal is a printing ink, not a text colour (3.2:1 on newsprint). It draws
     the route, the pins and the picture tints, and never carries a word.
   - --teal-ink carries text and buttons (5.6:1 on newsprint, 5.9:1 on white).
   - --marigold and --blush mean "working on it" and "nothing here yet". Their
     washes are the only backgrounds they get; text on them is --ink. */

:root {
  --ground: #fbf7f0;
  --card: #ffffff;
  --ink: #26262b;
  --heading: #123c4a;

  --teal: #0e9aa0;
  --teal-ink: #0b6f73;
  --teal-wash: #e7f4f4;

  --marigold: #f2b233;
  --marigold-wash: #fbecca;

  --blush: #e98a7c;
  --blush-wash: #fbe6e2;
  --danger: #a34433;

  --rule: #e7e0d3;
  --muted: #6e675e;

  --radius: 4px;
  --display: Literata, Georgia, "Times New Roman", serif;
  --body: Figtree, system-ui, -apple-system, "Segoe UI", sans-serif;
  --data: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font: 15px/1.6 var(--body);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--teal-ink); }

main {
  max-width: 860px;
  margin: 0 auto;
  padding: 40px 24px 72px;
}

/* Header — a hairline, not a band. The colour starts further down the page. */
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 24px;
  border-bottom: 1px solid var(--rule);
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font: 400 19px/1 var(--display);
  color: var(--teal-ink);
  text-decoration: none;
}
/* The 2x2 cut of the mark, which is the one drawn to hold at this size. */
.brand img { display: block; width: 28px; height: 28px; }
.site-header nav { display: flex; align-items: center; gap: 20px; }
.site-header nav a { text-decoration: none; color: var(--muted); font-size: 14px; }
.site-header nav a:hover { color: var(--ink); }
.site-header button.link { font-weight: 400; font-size: 14px; color: var(--muted); padding: 0; }
.site-header button.link:hover { color: var(--ink); }
.inline { display: inline; }

/* Typography */
h1 {
  margin: 0 0 8px;
  font: 400 32px/1.2 var(--display);
  color: var(--heading);
  letter-spacing: -.005em;
}
h2 {
  margin: 40px 0 16px;
  font: 400 11px/1 var(--data);
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--muted);
}
.subtitle { color: var(--muted); margin: 0 0 28px; font-size: 14px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.eyebrow {
  margin: 0 0 8px;
  font: 400 11px/1 var(--data);
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--muted);
}
.eyebrow a { text-decoration: none; }

/* Buttons — solid teal ink for the one action that matters on a screen,
   outline for the rest, text-only for retreat. */
button, .button {
  font: 600 13.5px/1.4 var(--body);
  border: 1px solid var(--rule);
  background: var(--card);
  color: var(--teal-ink);
  padding: 9px 18px;
  border-radius: var(--radius);
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
}
button:hover, .button:hover { border-color: var(--teal-ink); }
.button.primary, button.primary {
  background: var(--teal-ink);
  border-color: var(--teal-ink);
  color: #fff;
}
.button.primary:hover, button.primary:hover { background: #095457; border-color: #095457; }
button.link {
  border: none;
  background: none;
  color: var(--teal-ink);
  font-weight: 400;
  padding: 9px 2px;
}
button.danger, .button.danger { color: var(--danger); }
button.danger:hover { border-color: var(--danger); }
.actions { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }

:focus-visible {
  outline: 2px solid var(--teal);
  outline-offset: 2px;
  border-radius: 2px;
}

/* Cards & forms — filled surfaces are rare, so they mean something. */
.card {
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: 5px;
  padding: 22px 24px;
  margin-bottom: 20px;
}
.card h2 { margin-top: 0; }
.card-title {
  margin: 0 0 6px;
  font: 500 18px/1.3 var(--display);
  color: var(--heading);
}
form p { margin: 0 0 16px; }
label { display: block; font-weight: 600; font-size: 12.5px; margin-bottom: 5px; }
input[type=text], input[type=date], input[type=email],
input[type=password], select, textarea {
  font: inherit;
  font-size: 14px;
  width: 100%;
  max-width: 420px;
  padding: 9px 12px;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--card);
  color: var(--ink);
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--teal);
  box-shadow: 0 0 0 3px var(--teal-wash);
}
ul.errorlist { color: var(--danger); font-size: 13px; padding-left: 18px; margin: 4px 0; }
.helptext { display: block; color: var(--muted); font-size: 12.5px; margin-top: 5px; }
form ul { list-style: none; padding: 0; }
form ul label { font-weight: 400; }

/* Messages */
.messages { list-style: none; padding: 0; margin: 0 0 24px; }
.message {
  padding: 12px 16px;
  border-radius: var(--radius);
  background: var(--teal-wash);
  font-size: 14px;
  margin-bottom: 8px;
}
.message.success { background: var(--teal-wash); color: var(--teal-ink); }
.message.error { background: var(--blush-wash); color: var(--danger); }

/* Lists — hairlines instead of boxes. */
.stack { list-style: none; padding: 0; margin: 0; border-top: 1px solid var(--rule); }
.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 15px 2px;
  border-bottom: 1px solid var(--rule);
}
.row-main { min-width: 0; }
.row-title { font: 400 17px/1.3 var(--display); color: var(--heading); }
.row-title a { text-decoration: none; }
.row-title a:hover { text-decoration: underline; }

/* The route — every stop is a pin on one line, in the order they'll travel. */
.route {
  list-style: none;
  margin: 0;
  padding: 0 0 0 30px;
  position: relative;
}
.stop {
  --pin: var(--teal);
  position: relative;
  display: flex;
  align-items: baseline;
  gap: 14px;
  padding: 16px 2px 18px;
  border-bottom: 1px solid var(--rule);
}
.stop:last-child { border-bottom: 0; }
/* Each stop draws its own length of the line, so the route changes colour
   exactly where the trip stops being finished. */
.stop::after {
  content: "";
  position: absolute;
  left: -25px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--pin);
}
.stop:first-child::after { top: 24px; }
.stop:last-child::after { bottom: calc(100% - 24px); }
.stop::before {
  content: "";
  position: absolute;
  left: -30px;
  top: 18px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--ground);
  box-shadow: inset 0 0 0 3px var(--pin);
  z-index: 1;
}
.stop.is-done { --pin: var(--teal); }
.stop.is-done::before {
  background: var(--teal);
  box-shadow: inset 0 0 0 2px var(--ground), 0 0 0 2px var(--teal);
}
.stop.is-work { --pin: var(--marigold); }
.stop.is-idle { --pin: var(--blush); }
.stop.is-bad { --pin: var(--danger); }

.stop-main { flex: 1; min-width: 0; }
.stop-name { font: 400 18px/1.3 var(--display); color: var(--heading); }
.stop-name a { text-decoration: none; color: inherit; }
.stop-name a:hover { text-decoration: underline; }
.stop-sub { margin: 4px 0 0; font-size: 12.5px; color: var(--muted); }
.stop-end {
  flex: none;
  display: flex;
  align-items: baseline;
  justify-content: flex-end;
  gap: 14px;
}
.stop-date {
  font: 400 12px/1 var(--data);
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  min-width: 44px;
  text-align: right;
}
/* Fixed width so the states line up down the route however long their words. */
.stop-state { display: flex; justify-content: flex-end; min-width: 96px; }
.stop-name .drag-handle { font-size: 13px; vertical-align: 2px; }
.stop-count { font: 400 12.5px/1 var(--data); color: var(--teal-ink); font-variant-numeric: tabular-nums; }
.stop-tools { display: flex; align-items: baseline; gap: 12px; font-size: 12.5px; }
.stop-tools a, .stop-tools button.link { color: var(--muted); font-size: 12.5px; font-weight: 400; padding: 0; text-decoration: none; }
.stop-tools a:hover { color: var(--teal-ink); text-decoration: underline; }
.stop-tools button.link:hover { color: var(--danger); }

/* Badges — washes only, so --ink sits on them at 6:1 or better. */
.badge {
  display: inline-block;
  font-size: 11.5px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 3px;
  background: var(--marigold-wash);
  color: var(--ink);
}
.badge.ok { background: var(--teal-wash); color: var(--teal-ink); }
.badge.bad { background: var(--blush-wash); color: var(--danger); }
.badge.neutral { background: var(--blush-wash); color: var(--ink); }
.badge.quiet { background: none; box-shadow: inset 0 0 0 1px var(--rule); color: var(--muted); }

/* Progress indicators */
.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  flex: none;
  border: 2px solid var(--teal-wash);
  border-top-color: var(--teal);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 2.4s; } }

.loading-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  margin-bottom: 20px;
  border-radius: var(--radius);
  background: var(--marigold-wash);
  color: var(--ink);
  font-size: 14px;
}
.loading-banner .spinner { border-color: rgba(242, 178, 51, .45); border-top-color: #b07d12; }
.loading-banner[hidden] { display: none; }
/* The banner outlives the spinner when the page stops watching a slow job. */
.spinner[hidden] { display: none; }

/* Drag & drop reordering */
.draggable { cursor: grab; }
.draggable.dragging { opacity: 0.45; }
.drag-handle { color: var(--muted); cursor: grab; user-select: none; padding-right: 6px; }

/* Bingo grid */
.grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin: 20px 0 28px;
}
.cell {
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: 5px;
  padding: 9px 9px 11px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  min-height: 210px;
}
.cell.empty { background: none; border-style: dashed; }
.cell-image {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--teal-wash);
  border-radius: 3px;
  overflow: hidden;
}
.cell.empty .cell-image { background: var(--blush-wash); }
/* A cell waiting on its replacement is working, not empty: it keeps the card
   and the solid rule a filled cell has, and wears marigold rather than the
   empty cell's blush (see the colour rules at the top). */
.cell.pending {
  background: var(--card);
  border-style: solid;
  border-color: var(--marigold);
}
.cell.pending .cell-image {
  background: var(--marigold-wash);
  animation: pulse 1.6s ease-in-out infinite;
}
.cell.pending .spinner { border-color: rgba(242, 178, 51, .45); border-top-color: #b07d12; }
@keyframes pulse { 50% { opacity: 0.55; } }
@media (prefers-reduced-motion: reduce) { .cell.pending .cell-image { animation: none; } }
.cell-image img { width: 100%; height: 100%; object-fit: contain; }
.cell-image .placeholder { font-size: 11.5px; color: var(--muted); text-align: center; padding: 8px; }
.cell-foot { display: flex; align-items: baseline; gap: 7px; margin-top: auto; }
/* The number is the same on screen and on paper, so "I got number seven"
   works from the back seat. */
.cell-number { font: 400 10px/1.4 var(--data); color: var(--muted); flex: none; }
.cell-label { font-size: 12.5px; font-weight: 500; line-height: 1.35; min-width: 0; flex: 1; }
/* Sixteen bordered buttons would out-shout sixteen pictures, so the per-cell
   action is text only until you hover it. */
.cell-actions { display: flex; gap: 6px; }
.cell-actions button {
  padding: 2px 0;
  font-size: 11.5px;
  font-weight: 400;
  border: none;
  background: none;
  color: var(--muted);
}
.cell-actions button:hover { color: var(--teal-ink); text-decoration: underline; }
.cell input[type=text] { font-size: 12.5px; padding: 5px 8px; }

/* Click-to-edit labels. Without JS both the label and its form are shown; the
   `js` class collapses the form away until the label is clicked. */
.label-text {
  display: block;
  padding: 3px 5px;
  margin: -3px -5px;
  border-radius: 3px;
  cursor: text;
}
.label-text:hover, .label-text:focus-visible { background: var(--teal-wash); }
.empty-label { color: var(--muted); font-weight: 400; font-style: italic; }
.js .label-edit { display: none; }
.js .cell-label.editing .label-text { display: none; }
.js .cell-label.editing .label-edit { display: block; }

@media (max-width: 720px) {
  main { padding: 28px 18px 56px; }
  h1 { font-size: 26px; }
  .grid { grid-template-columns: repeat(2, 1fr); }
  .row { flex-direction: column; align-items: flex-start; }
  .stop { flex-wrap: wrap; }
  .stop-main { flex: 1 1 100%; }
  .stop-end { width: auto; margin-top: 8px; }
}
