/*
  The status bar, the cart, and the book in your hand.

  §2's three zones are top / bookstore / cart, and the cart is docked so it is
  in the same place whatever the shift is doing. Its contents change — waiting
  arrivals, an order list, books pulled off the shelf — but the zone does not,
  which is §14C's "variations of the same bookstore job" made structural.
*/

/* ── Top: situation, clock, progress (§2, §14C) ─────────────────────────── */

.hud {
  flex: none;
  display: flex;
  flex-direction: column;
  gap: .3rem;
  padding: .55rem .8rem .5rem;
  background: linear-gradient(180deg, var(--paper-warm), rgba(253, 248, 238, .82));
  border-bottom: 1px solid var(--paper-edge);
  box-shadow: 0 2px 8px rgba(60, 38, 18, .07);
  z-index: 5;
}

.hud-top {
  display: flex;
  align-items: center;
  gap: .5rem;
}

.hud-scenario {
  display: flex;
  align-items: center;
  gap: .38rem;
  font-size: .74rem;
  font-weight: 700;
  letter-spacing: .13em;
  text-transform: uppercase;
  color: var(--oak-dark);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.hud-scenario .icon { color: var(--oak); }

.hud-clock {
  margin-left: auto;
  font-family: var(--serif);
  font-size: 1.22rem;
  font-weight: 700;
  letter-spacing: .01em;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
/* The last thirty seconds. Colour *and* weight, because §19 forbids colour
   carrying meaning on its own. */
.hud-clock.is-low { color: var(--bad); }
.hud-clock.is-low::after { content: ' ⏷'; font-size: .7em; vertical-align: .18em; }

.hud-line {
  display: flex;
  align-items: baseline;
  gap: .45rem;
  font-size: .8rem;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
}
.hud-line b { color: var(--ink); font-weight: 700; }
.hud-line .sep { color: var(--paper-edge); }
.hud-line .hud-goal { margin-left: auto; font-size: .74rem; color: var(--ink-faint); }

/* Progress toward today's target. Reaching it does not end the shift (§10),
   so the bar keeps filling past the mark and changes texture instead. */
.hud-bar {
  position: relative;
  height: 5px;
  border-radius: 3px;
  background: rgba(120, 88, 54, .16);
  overflow: hidden;
}
.hud-bar-fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--oak-light), var(--oak));
  transition: width .28s cubic-bezier(.2, .8, .3, 1);
}
.hud-bar.is-met .hud-bar-fill { background: linear-gradient(90deg, var(--good), #6a9a5c); }

/* ── Bottom: the cart ───────────────────────────────────────────────────── */

.cart {
  flex: none;
  position: relative;
  padding: .5rem .7rem calc(.55rem + env(safe-area-inset-bottom, 0px));
  background: linear-gradient(180deg, #a9754a, #8b5c37 40%, #6f4629);
  box-shadow: 0 -6px 18px rgba(50, 30, 14, .26), inset 0 1px 0 rgba(255, 232, 198, .28);
  z-index: 6;
}

.cart-head {
  display: flex;
  align-items: center;
  gap: .5rem;
  margin-bottom: .38rem;
  font-size: .68rem;
  letter-spacing: .14em;
  text-transform: uppercase;
  font-weight: 700;
  color: rgba(255, 240, 216, .88);
}
.cart-count {
  margin-left: auto;
  letter-spacing: .04em;
  font-variant-numeric: tabular-nums;
  color: rgba(255, 240, 216, .7);
}

.cart-rail {
  display: flex;
  gap: 6px;
  align-items: flex-end;
  min-height: var(--cover-h);
}

/* An empty slot is drawn, not collapsed: §13B's cart has a fixed number of
   spaces and the player needs to see how many are free. */
.cart-slot {
  flex: 1 1 0;
  min-width: 0;
  max-width: calc(var(--cover-w) + 14px);
  height: var(--cover-h);
  border-radius: 5px;
  display: grid;
  place-items: center;
}
.cart-slot.is-empty {
  box-shadow: inset 0 0 0 1px rgba(255, 236, 206, .16);
  background: rgba(60, 34, 14, .16);
}

/* ── A face-out book: on the cart, and in your hand ─────────────────────── */

.cover {
  position: relative;
  width: 100%;
  max-width: var(--cover-w);
  height: var(--cover-h);
  display: flex;
  flex-direction: column;
  border-radius: 3px 5px 5px 3px;
  overflow: hidden;
  color: var(--cover-ink, #fdf6e8);
  background: hsl(var(--hue) var(--sat) var(--lit));
  box-shadow: 0 2px 5px rgba(30, 14, 2, .45), inset 1px 0 0 rgba(255,255,255,.18);
  cursor: grab;
  touch-action: none;
  transition: transform .16s ease, opacity .16s ease;
}
.cover::before {
  /* The bound edge. Cheap, and it stops a cover reading as a coloured card. */
  content: '';
  position: absolute;
  inset: 0 auto 0 0;
  width: 5px;
  background: linear-gradient(90deg, rgba(0,0,0,.34), rgba(255,255,255,.10));
}

.cover-mark {
  flex: none;
  display: flex;
  align-items: center;
  gap: .22rem;
  padding: 3px 4px 3px 8px;
  background: rgba(255, 247, 232, .92);
  color: var(--mark-colour, var(--oak-dark));
}
.cover-mark .icon { width: 13px; height: 13px; }
.cover-genre {
  font-size: 8.5px;
  font-weight: 800;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--mark-colour, var(--oak-dark));
  white-space: nowrap;
  overflow: hidden;
}

.cover-body {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 4px 5px 5px 9px;
}
.cover-title {
  font-family: var(--serif);
  font-size: 9.5px;
  line-height: 1.16;
  font-weight: 700;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-shadow: 0 1px 1px rgba(0,0,0,.3);
}
/* The surname is the thing being alphabetised, so it is the emphatic half. */
.cover-author {
  font-size: 8.5px;
  line-height: 1.15;
  opacity: .92;
  overflow: hidden;
}
/* The surname sits on its own line and is never clipped; the given name sits
   under it, smaller, and is allowed to disappear on a narrow cover. */
.cover-author b { display: block; font-weight: 700; }
.cover-author span { display: block; opacity: .78; font-size: .92em; }

@media (min-width: 720px) {
  .cover-title { font-size: 11.5px; }
  .cover-author, .cover-genre { font-size: 10px; }
  .cover-mark .icon { width: 15px; height: 15px; }
}

/* Big Rush: a book running out of patience (§13B, §14B). Pulse plus a shrinking
   fuse bar, so the warning is not colour alone. */
.cover.is-expiring { animation: fret 700ms ease-in-out infinite; }
.cover-fuse {
  position: absolute;
  inset: auto 0 0 0;
  height: 3px;
  background: var(--warn);
  transform-origin: left center;
}
.cover.is-expiring .cover-fuse { background: var(--bad); }
@keyframes fret {
  0%, 100% { transform: none; }
  50% { transform: translateY(-2px) rotate(-1.4deg); }
}

.cover.is-arriving { animation: arrive 260ms cubic-bezier(.2, .9, .3, 1); }
@keyframes arrive {
  from { transform: translateY(14px) scale(.9); opacity: 0; }
}
.cover.is-lost { animation: lost 260ms ease-in forwards; }
@keyframes lost {
  to { transform: translateY(18px) scale(.86); opacity: 0; }
}
.cover.is-carried { opacity: .2; }

/* ── The book in hand ───────────────────────────────────────────────────── */

/*
  Fixed to the viewport and pointer-events: none, which is what makes
  `elementFromPoint` in drag.js see the shelf underneath rather than the ghost.
*/
.hand {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 60;
  width: var(--cover-w);
  pointer-events: none;
  will-change: transform;
  filter: drop-shadow(0 10px 16px rgba(40, 22, 8, .45));
}
.hand .cover {
  max-width: none;
  transform: rotate(-3deg) scale(1.08);
  cursor: grabbing;
}
.hand.is-rejecting .cover { animation: shake 240ms ease-in-out; }
@keyframes shake {
  0%, 100% { transform: rotate(-3deg) scale(1.08); }
  25% { transform: rotate(-9deg) scale(1.08) translateX(-5px); }
  70% { transform: rotate(3deg) scale(1.08) translateX(4px); }
}

/*
  A Big Order's cart carries two things — the slots and the list — and at full
  size they eat a third of the screen. The slots are only ever transit here (a
  found title rides for a moment and then boxes), so they shrink and the list
  gets the room. Same zone, same components, less of it.
*/
.cart.is-order { --cover-w: 46px; --cover-h: 58px; }
.cart.is-order .cart-rail { min-height: var(--cover-h); }
.cart.is-order .cover-title { -webkit-line-clamp: 2; }
.cart.is-order .cover-author span { display: none; }

/* ── Order list (§13C) ──────────────────────────────────────────────────── */

.order-list {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 2px;
  scrollbar-width: none;
  touch-action: pan-x;
}
.order-list::-webkit-scrollbar { display: none; }

.order-item {
  flex: none;
  display: flex;
  align-items: center;
  gap: .35rem;
  max-width: 190px;
  padding: .3rem .5rem .32rem .38rem;
  border-radius: 5px;
  background: var(--paper-warm);
  box-shadow: var(--shadow-sign);
  transition: opacity .2s ease, filter .2s ease;
}
.order-item .icon { color: var(--mark-colour, var(--oak-dark)); }
.order-item-text { min-width: 0; }
.order-item-title {
  font-family: var(--serif);
  font-size: .74rem;
  font-weight: 700;
  line-height: 1.15;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.order-item-author {
  font-size: .66rem;
  color: var(--ink-faint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.order-item.is-found {
  opacity: .45;
  filter: saturate(.3);
}
.order-item.is-found .order-item-title { text-decoration: line-through; }

/* ── Toast: the one-line feedback channel ───────────────────────────────── */

/*
  §7 and §8 both forbid modals and explanatory text on every placement, so this
  is used sparingly: displaced books, an order title crossed off, the target
  being reached. Never for an ordinary right or wrong placement.
*/
.toast {
  position: absolute;
  left: 50%;
  bottom: calc(var(--cover-h) + 68px);
  transform: translate(-50%, 8px);
  z-index: 40;
  padding: .42rem .85rem;
  border-radius: 999px;
  background: rgba(44, 33, 24, .92);
  color: var(--paper-warm);
  font-size: .78rem;
  font-weight: 600;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s ease, transform .18s ease;
}
.toast.is-showing { opacity: 1; transform: translate(-50%, 0); }
