/* HiveStock Kiosk — self-contained styles.
   Palette and type per the Session-2 visual direction. Recorded in
   ARCHITECTURE.md for later refinement. */

/* Barlow, self-hosted (latin subset) so the kiosk never depends on a font CDN
   being reachable on factory wifi. Licensed under the SIL Open Font License. */
@font-face {
  font-family: 'Barlow';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('/fonts/Barlow-500.woff2') format('woff2');
}
@font-face {
  font-family: 'Barlow';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('/fonts/Barlow-600.woff2') format('woff2');
}
@font-face {
  font-family: 'Barlow';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('/fonts/Barlow-700.woff2') format('woff2');
}
@font-face {
  font-family: 'Barlow';
  font-style: normal;
  font-weight: 800;
  font-display: swap;
  src: url('/fonts/Barlow-800.woff2') format('woff2');
}

:root {
  --bg: #121417;
  --surface: #1c1f24;
  --surface-2: #23272e;
  --border: #2a2e35;
  --text: #f2f4f7;
  --text-dim: #9aa3ae;
  --accent: #ffc400; /* hive yellow — accent only */
  --accent-ink: #14161a; /* text on yellow */
  --warn: #ff8a00; /* stock low */
  --danger: #ff4d4f; /* stock out / negative */
  --success: #2ecc71; /* vend success */
  --radius: 12px;
  --radius-sm: 8px;
  --font: 'Barlow', 'Segoe UI', system-ui, -apple-system, sans-serif;
  --tap: 64px; /* default large tap target (min 48) */
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 18px;
  -webkit-user-select: none;
  user-select: none;
  overscroll-behavior: none;
  touch-action: manipulation;
}

#app {
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ---------- Screen scaffolding ---------- */
.screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  animation: fade 160ms ease-out;
}
@keyframes fade {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.screen-pad {
  padding: clamp(20px, 3.5vw, 48px);
}

/* ---------- Buttons ---------- */
button {
  font-family: inherit;
  font-weight: 700;
  color: var(--text);
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  min-height: var(--tap);
  cursor: pointer;
  transition:
    transform 60ms ease,
    background 60ms ease,
    border-color 60ms ease;
}
button:active {
  transform: scale(0.97);
}
.btn-primary {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: var(--accent);
  font-size: 1.4rem;
  font-weight: 800;
  letter-spacing: 0.02em;
}
.btn-primary:active {
  background: #ffce33;
}
.btn-ghost {
  background: transparent;
}
.btn-lg {
  font-size: 1.3rem;
  padding: 0 2rem;
}
button:disabled {
  opacity: 0.4;
  pointer-events: none;
}

/* ---------- Wordmark ---------- */
.wordmark {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 800;
  letter-spacing: 0.14em;
}
.wordmark .hex {
  width: 1.15em;
  height: 1.15em;
  fill: var(--accent);
}
.wordmark .mark {
  color: var(--accent);
}

/* ---------- Idle / attract ---------- */
.idle {
  align-items: center;
  justify-content: center;
  text-align: center;
  position: relative;
  cursor: pointer;
  /* Flat charcoal so the badge PNG (same #121417 ground) blends seamlessly. */
  background: var(--bg);
}
.idle .hexfield {
  position: absolute;
  inset: 0;
  opacity: 0.05;
  pointer-events: none;
}
/* Idle attract badge (full brand lockup). Idle screen only — the PIN/product
   header keeps the compact CSS wordmark. */
.idle-badge {
  width: 60vw;
  max-width: 900px;
  height: auto;
  margin-bottom: 8vh;
  z-index: 1;
}
.idle .touch {
  font-size: clamp(2.6rem, 8vw, 5.5rem);
  font-weight: 800;
  color: var(--accent);
  letter-spacing: 0.03em;
  z-index: 1;
  animation: pulse 2.4s ease-in-out infinite;
}
.idle .site {
  margin-top: 2.5vh;
  font-size: clamp(1.1rem, 2.4vw, 1.7rem);
  color: var(--text-dim);
  font-weight: 600;
  z-index: 1;
}
@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.62;
  }
}

/* ---------- Top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: clamp(14px, 2vw, 22px) clamp(20px, 3.5vw, 40px);
  border-bottom: 2px solid var(--border);
  background: var(--surface);
}
.topbar .wordmark {
  font-size: 1.25rem;
}
.topbar .who {
  color: var(--text-dim);
  font-weight: 600;
  font-size: 1.05rem;
}
.topbar .right {
  display: flex;
  align-items: center;
  gap: 1rem;
}

/* ---------- PIN pad ---------- */
.pin {
  align-items: center;
  justify-content: center;
  gap: clamp(18px, 3vh, 34px);
}
.pin h1 {
  font-size: clamp(1.6rem, 3.6vw, 2.4rem);
  margin: 0;
  font-weight: 700;
}
.pin .dots {
  display: flex;
  gap: 18px;
  height: 40px;
  align-items: center;
}
.pin .dot {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 3px solid var(--text-dim);
}
.pin .dot.on {
  background: var(--accent);
  border-color: var(--accent);
}
.pin .msg {
  min-height: 1.6em;
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--danger);
}
.keypad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: clamp(10px, 1.6vw, 16px);
  width: min(92vw, 440px);
}
.keypad button {
  font-size: clamp(1.8rem, 4.5vw, 2.6rem);
  font-weight: 700;
  aspect-ratio: 3 / 2;
  min-height: 72px;
}
.keypad button:active {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: var(--accent);
}
.keypad .key-action {
  font-size: 1.2rem;
  color: var(--text-dim);
}

/* ---------- Product grid ---------- */
.scroll {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: clamp(16px, 2.4vw, 28px);
}
.chips {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding: 14px clamp(16px, 2.4vw, 28px);
  border-bottom: 2px solid var(--border);
  background: var(--bg);
}
.chip {
  flex: 0 0 auto;
  padding: 0 1.3rem;
  min-height: 52px;
  font-size: 1.05rem;
  border-radius: 999px;
  color: var(--text-dim);
  font-weight: 600;
}
.chip.active {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: var(--accent);
}
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: clamp(12px, 1.6vw, 18px);
}
.tile {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
  gap: 10px;
  padding: 20px;
  min-height: 150px;
  background: var(--surface);
}
.tile:active {
  border-color: var(--accent);
  background: var(--surface-2);
}
.tile .name {
  font-size: clamp(1.35rem, 2vw, 1.6rem);
  font-weight: 700;
  line-height: 1.15;
}
.tile .meta {
  margin-top: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  gap: 10px;
}
.tile .unit {
  color: var(--text-dim);
  font-weight: 600;
  font-size: 1rem;
}
.stock {
  font-weight: 800;
  font-size: 1.05rem;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text);
  border: 2px solid var(--border);
  white-space: nowrap;
}
.stock.low {
  color: var(--warn);
  border-color: var(--warn);
}
.stock.out {
  color: var(--danger);
  border-color: var(--danger);
}
/* Tappable spot-count badge (low/out) */
.stock.tap {
  border-style: dashed;
  cursor: pointer;
}
.stock.tap:active {
  background: var(--surface-2);
}

/* Transient toast (e.g. "ask your supervisor") */
.kiosk-toast {
  position: fixed;
  left: 50%;
  bottom: 8vh;
  transform: translateX(-50%);
  background: var(--surface-2);
  color: var(--text);
  border: 2px solid var(--warn);
  border-radius: var(--radius);
  padding: 16px 24px;
  font-size: 1.2rem;
  font-weight: 700;
  z-index: 30;
  animation: fade 160ms ease-out;
}

/* ---------- Quantity ---------- */
.qty {
  align-items: center;
  justify-content: center;
  gap: clamp(20px, 4vh, 44px);
  text-align: center;
}
.qty .prod {
  font-size: clamp(1.6rem, 3.4vw, 2.4rem);
  font-weight: 700;
  max-width: 90vw;
}
.qty .prod .unit {
  display: block;
  color: var(--text-dim);
  font-size: 1.1rem;
  font-weight: 600;
  margin-top: 6px;
}
.stepper {
  display: flex;
  align-items: center;
  gap: clamp(20px, 5vw, 56px);
}
.stepper button {
  width: clamp(90px, 16vw, 130px);
  height: clamp(90px, 16vw, 130px);
  border-radius: 50%;
  font-size: clamp(3rem, 7vw, 4.5rem);
  font-weight: 700;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}
.stepper .value {
  font-size: clamp(4rem, 12vw, 7rem);
  font-weight: 800;
  min-width: 1.8em;
  font-variant-numeric: tabular-nums;
}
.field {
  width: min(92vw, 460px);
  display: flex;
  flex-direction: column;
  gap: 8px;
  text-align: left;
}
.field label {
  color: var(--text-dim);
  font-weight: 600;
  font-size: 1rem;
}
.field .fake-input {
  min-height: var(--tap);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  display: flex;
  align-items: center;
  padding: 0 1.1rem;
  font-size: 1.4rem;
  font-weight: 600;
}
.field .fake-input.placeholder {
  color: var(--text-dim);
  font-weight: 500;
}
.row {
  display: flex;
  gap: 14px;
  width: min(92vw, 460px);
}
.row > * {
  flex: 1;
}

/* ---------- Confirm ---------- */
.confirm {
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: clamp(24px, 5vh, 50px);
}
.confirm .headline {
  font-size: clamp(2rem, 5vw, 3.4rem);
  font-weight: 800;
  line-height: 1.1;
  max-width: 92vw;
}
.confirm .headline .accent {
  color: var(--accent);
}
.confirm .sub {
  color: var(--text-dim);
  font-size: 1.3rem;
  font-weight: 600;
}

/* ---------- Success ---------- */
.success {
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 24px;
}
.success .check {
  width: 130px;
  height: 130px;
  border-radius: 50%;
  background: rgba(46, 204, 113, 0.14);
  border: 4px solid var(--success);
  display: flex;
  align-items: center;
  justify-content: center;
}
.success .check svg {
  width: 68px;
  height: 68px;
  stroke: var(--success);
}
.success .headline {
  font-size: clamp(1.8rem, 4vw, 2.8rem);
  font-weight: 800;
}
.success .remaining {
  font-size: 1.3rem;
  color: var(--text-dim);
  font-weight: 600;
}
.success .remaining.warn {
  color: var(--warn);
}
.success .remaining.out {
  color: var(--danger);
}

/* ---------- Overlay numeric pad (job number) ---------- */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(8, 9, 11, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  animation: fade 140ms ease-out;
}
.sheet {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: 16px;
  padding: clamp(18px, 3vw, 30px);
  width: min(94vw, 480px);
  display: flex;
  flex-direction: column;
  gap: 18px;
  align-items: center;
}
.sheet h2 {
  margin: 0;
  font-size: 1.5rem;
}
.sheet .display {
  width: 100%;
  min-height: 60px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  display: flex;
  align-items: center;
  padding: 0 1rem;
  font-size: 1.8rem;
  font-weight: 700;
  letter-spacing: 0.05em;
}

/* ---------- Basket model additions (extend, don't restyle) ---------- */
/* Tile basket badge + capability tags */
.tile {
  position: relative;
}
.tile .badge {
  position: absolute;
  top: 10px;
  right: 10px;
  min-width: 36px;
  height: 36px;
  padding: 0 9px;
  border-radius: 18px;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 800;
  font-size: 1.15rem;
  display: flex;
  align-items: center;
  justify-content: center;
}
.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.tag {
  font-size: 0.78rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--text-dim);
  border: 1px solid var(--border);
  letter-spacing: 0.04em;
}
.tile.blocked-tile {
  opacity: 0.55;
}

/* Persistent basket panel on the products screen */
.basket {
  border-top: 2px solid var(--border);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  max-height: 44vh;
}
/* Collapsed: a slim bar. Full editable list is one tap away (or on Review). */
.basket.collapsed {
  flex-direction: row;
  align-items: stretch;
  gap: 12px;
  padding: 10px clamp(16px, 2.4vw, 28px);
}
.basket-bar {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 60px;
  padding: 0 18px;
  text-align: left;
}
.basket-bar .btitle {
  font-size: 1.2rem;
  font-weight: 700;
}
.basket-bar .expand-hint,
.bhead .expand-hint {
  color: var(--text-dim);
  font-weight: 600;
  font-size: 0.95rem;
}
.basket-review {
  flex: 0 0 auto;
  min-width: 220px;
}
.basket .bhead {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: transparent;
  border: none;
  min-height: 56px;
  padding: 12px clamp(16px, 2.4vw, 28px) 6px;
}
.basket .bhead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px clamp(16px, 2.4vw, 28px) 6px;
}
.basket .btitle {
  font-weight: 700;
  font-size: 1.15rem;
}
.basket .lines {
  overflow-y: auto;
  padding: 0 clamp(16px, 2.4vw, 28px);
}
.bline {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-top: 1px solid var(--border);
}
.bline .info {
  flex: 1;
  min-width: 0;
}
.bline .nm {
  font-weight: 700;
  font-size: 1.05rem;
}
.bline .sub {
  color: var(--text-dim);
  font-size: 0.9rem;
}
.bline .mini {
  display: flex;
  align-items: center;
  gap: 10px;
}
.bline .mini button {
  width: 54px;
  height: 54px;
  min-height: 54px;
  font-size: 1.7rem;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.bline .qv {
  min-width: 1.4em;
  text-align: center;
  font-weight: 800;
  font-size: 1.35rem;
  font-variant-numeric: tabular-nums;
}
.bline .rm {
  color: var(--danger);
}
.basket .foot {
  padding: 12px clamp(16px, 2.4vw, 28px);
  display: flex;
  gap: 14px;
}
.basket .foot .btn-primary {
  flex: 2;
}
.basket .foot .btn-ghost {
  flex: 1;
}

/* Option rows for batch / serial pickers (inside the existing .sheet) */
.opts {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 52vh;
  overflow-y: auto;
}
.opt {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px;
  min-height: 66px;
  text-align: left;
}
.opt .lbl {
  font-weight: 700;
  font-size: 1.15rem;
}
.opt .meta {
  color: var(--text-dim);
  font-weight: 600;
  font-size: 0.92rem;
}
.opt.rec {
  border-color: var(--accent);
}
.opt.blocked {
  opacity: 0.5;
  pointer-events: none;
}
.opt .flag {
  font-weight: 800;
  white-space: nowrap;
}
.opt .flag.out {
  color: var(--danger);
}
.opt .flag.rec {
  color: var(--accent);
}

/* Confirm line list */
.clines {
  width: min(94vw, 640px);
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 46vh;
  overflow-y: auto;
  text-align: left;
}
.cline {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  padding: 14px 16px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}
.cline .q {
  font-weight: 800;
  color: var(--accent);
  white-space: nowrap;
}
.cline .due,
.success .due {
  color: var(--warn);
  font-weight: 600;
  font-size: 0.92rem;
}
.err-banner {
  color: var(--danger);
  font-weight: 700;
  font-size: 1.05rem;
  min-height: 1.4em;
  text-align: center;
}

.hidden {
  display: none !important;
}

/* Landscape phones / short screens: tighten spacing. */
@media (max-height: 560px) {
  .pin,
  .qty,
  .confirm,
  .success {
    gap: 14px;
  }
  .keypad button {
    min-height: 56px;
  }
}

/* ===================== staff mode: on-cabinet stocktake ================== */
/* Discreet corner target on the idle screen. */
.staff-dot {
  position: absolute;
  right: 14px;
  bottom: 14px;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: transparent;
  border: 1px solid transparent;
  opacity: 0.18;
  z-index: 3;
}
.staff-dot:active { opacity: 0.4; }

.staff { justify-content: flex-start; gap: 18px; }
.staff-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  gap: 12px;
  color: var(--text-dim);
  font-weight: 600;
}
.staff-top .site { text-align: right; }
.staff-top .reveal { display: flex; align-items: center; gap: 6px; font-size: 0.85rem; }
.staff-top .reveal input { width: 20px; height: 20px; accent-color: var(--accent); }

.sc-choices { display: flex; flex-direction: column; gap: 12px; width: min(92vw, 520px); }
.sc-choice {
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.sc-choice strong { font-size: 1.15rem; }
.sc-choice span { color: var(--text-dim); font-size: 0.9rem; }
.sc-choice.resume { border-color: var(--accent); }
.sc-choice:active { border-color: var(--accent); }

.staff-count { justify-content: flex-start; padding: 18px clamp(12px, 3vw, 28px); }
.sc-sheet { width: 100%; max-width: 760px; overflow-y: auto; flex: 1; display: flex; flex-direction: column; gap: 14px; }
.sc-group { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 16px; }
.sc-ghead { font-weight: 700; margin-bottom: 8px; }
.sc-line {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
  border-top: 1px solid var(--border);
}
.sc-group .sc-line:first-of-type { border-top: none; }
.sc-lbl { font-weight: 600; }
.sc-sys { color: var(--text-dim); font-size: 0.82rem; text-align: right; }
.sc-sheet .blind { opacity: 0; }
.sc-sheet.revealed .blind { opacity: 1; }
.sc-num { display: inline-flex; align-items: center; gap: 6px; }
.sc-num button { width: 48px; height: 48px; font-size: 1.5rem; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--border); color: var(--text); }
.sc-num input { width: 68px; height: 48px; text-align: center; font-size: 1.2rem; font-weight: 700; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--text); }
.sc-toggle { display: inline-flex; gap: 6px; }
.sc-toggle button { min-height: 48px; padding: 0 16px; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--border); color: var(--text); font-weight: 700; }
.sc-toggle button.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.sc-toggle button.miss.on { background: var(--danger); color: #fff; border-color: var(--danger); }

.sc-unexp { width: 100%; max-width: 760px; }
.sc-unexp label { display: block; color: var(--text-dim); font-size: 0.85rem; margin-bottom: 5px; font-weight: 600; }
.sc-unexp input { width: 100%; min-height: 46px; padding: 8px 12px; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--text); }
.sc-actions { display: flex; gap: 12px; width: 100%; max-width: 760px; }
.sc-actions button { flex: 1; }

.sc-summary { color: var(--text-dim); font-weight: 600; }
.sc-review { width: min(92vw, 640px); display: flex; flex-direction: column; gap: 8px; max-height: 52vh; overflow-y: auto; }
.sc-drow { display: flex; justify-content: space-between; gap: 12px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px 16px; }
.sc-drow em { color: var(--warn); font-style: normal; }
.empty, .ok { color: var(--text-dim); }
.staff .ok { color: var(--success); }

/* Offline banner: reflects connectivity + pending-queue count. */
.offline-banner {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 50;
  background: var(--warn);
  color: var(--accent-ink);
  font-weight: 700;
  text-align: center;
  padding: 8px 14px;
  font-size: 0.95rem;
  letter-spacing: 0.02em;
  box-shadow: 0 2px 8px rgba(0,0,0,0.35);
}

/* Offline badge sign-in. */
.offline-note { color: var(--warn); font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase; font-size: 0.8rem; margin-bottom: 6px; }
.badge-input {
  width: min(92vw, 440px); min-height: 64px; text-align: center;
  font-size: 1.4rem; font-weight: 700; letter-spacing: 0.06em;
  background: var(--bg); color: var(--text);
  border: 2px solid var(--border); border-radius: var(--radius);
}
.badge-input:focus { outline: none; border-color: var(--accent); }

/* Batched/serialised tiles that can't be taken offline. */
.tile.online-only { opacity: 0.62; }
.tile .olo {
  position: absolute; top: 8px; right: 8px;
  background: var(--warn); color: var(--accent-ink);
  font-size: 0.62rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.04em;
  padding: 2px 6px; border-radius: 5px;
}
