/*
 * Restaurant R3 — the order-ready board (views-board.js), the kitchen's paper (chit-html.js: a chit per ticket, a
 * 40x30 mm cup label per unit), «نفد» and «باقي» (soldout-html.js: the sale screen's tile badge and the display's
 * sheet), the note on a cart line, the pay sheet's label and name, and the print station's line. Every colour, size and
 * radius is a token (tokens.css, with its dark values); spacing is logical; every control is at least 44 px. The paper
 * is ink on paper whatever the theme (the slip tokens), as the receipt is.
 */

/* ---------------------------------------------------------------- the board */

/* Review F-M4: the board fits the screen — the page is the viewport (the till's bar, then the board), the columns
   take what is left and never scroll; what a column cannot hold is its «+N» (views-board.js measures it). */
body[data-screen='board'] {
  block-size: 100dvh;
  min-block-size: 0;
  overflow: hidden;
}

body[data-screen='board'] .stage {
  display: flex;
  flex-direction: column;
  max-inline-size: none;
  padding-inline: var(--s-4);
}

.board {
  display: flex;
  flex-direction: column;
  gap: var(--s-4);
  flex: 1;
  min-block-size: 0;
  overflow: hidden;
}

.board__head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s-3);
}

.board__head h1 {
  margin: 0;
  font-size: var(--t-b-title);
  line-height: 1.2;
}

.board__live {
  flex: 1;
  margin: 0;
  color: var(--stop);
  font-size: var(--t-label);
}

.bsound {
  min-block-size: 44px;
}

.board__cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--s-5);
  flex: 1;
  min-block-size: 0;
}

.bcol {
  display: flex;
  flex-direction: column;
  min-block-size: 0;
  min-inline-size: 0;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  padding-block: var(--s-4);
  padding-inline: var(--s-4);
}

.bcol--ready {
  background: var(--good-bg);
  border-color: var(--good);
}

.bcol__title {
  margin-block: 0 var(--s-4);
  font-size: var(--t-b-title);
  color: var(--ink);
}

.bcol--ready .bcol__title {
  color: var(--good-ink);
}

.bnums {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(clamp(7rem, 12vw, 12rem), 1fr));
  align-content: start;
  gap: var(--s-4);
  flex: 1;
  min-block-size: 0;
  overflow: hidden;
}

.bcell {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s-1);
  min-inline-size: 0;
  padding-block: var(--s-3);
  padding-inline: var(--s-2);
  border-radius: var(--r-card);
  background: var(--surface-2);
}

.bcell--ready {
  background: var(--surface);
  border: 3px solid var(--good);
}

/* Review F-M4: a number newly ready flashes three times (a still ring where motion is reduced: motion.css). */
.bcell--fresh {
  animation: bflash var(--m-flash) ease-in-out 3;
  outline: 4px solid var(--good);
  outline-offset: 2px;
}

@keyframes bflash {
  50% {
    background: var(--good-bg);
    transform: scale(1.06);
  }
}

.bcell--more {
  border: 2px dashed var(--line);
}

.bnum {
  font-size: clamp(2.5rem, 6vw, var(--t-b-num));
  font-weight: 800;
  line-height: 1;
  color: var(--ink);
}

.bnum--more {
  color: var(--ink-soft);
}

/* Review F-M4: a long name is cut, centred, on one line — never a cell that grows and pushes the grid. */
.bname {
  max-inline-size: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: center;
  font-size: clamp(1rem, 2.2vw, var(--t-b-name));
  color: var(--ink-soft);
}

@media (prefers-reduced-motion: reduce) {
  .bcell--fresh {
    animation: none;
  }
}

.bempty {
  color: var(--muted);
  font-size: var(--t-k-meta);
}

@media (max-width: 48rem) {
  .board__cols {
    grid-template-columns: 1fr;
  }
}

/* ---------------------------------------------------------------- «نفد» and «باقي» */

/* Review F-L4: a sold-out tile is greyed by the theme's own tokens in every layout (a classic tile's hue too) — not
   faded, so its «نفد» badge stays solid and readable, light and dark. */
.item.item--soldout,
.sale--classic .item.item--soldout {
  background: var(--surface-2);
  color: var(--muted);
  border: 2px dashed var(--line-strong);
  cursor: not-allowed;
}

.item__soldout,
.item__left {
  display: inline-block;
  margin-block-start: var(--s-1);
  padding-inline: var(--s-2);
  border-radius: var(--r-chip);
  font-size: var(--t-caption);
  font-weight: 700;
}

.item__soldout {
  background: var(--stop);
  color: var(--surface);
  font-size: var(--t-label);
}

.item__left {
  background: var(--warn-bg);
  color: var(--ink);
}

.so-panel {
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
  background: var(--surface);
  border-radius: var(--r-card);
  padding-block: var(--s-4);
  padding-inline: var(--s-4);
}

/* Review F-M2: the till's sheet over the sale screen, wide enough for the item's three buttons; the display's sheet
   says what came meanwhile. */
.so-sheet {
  inline-size: min(100%, 44rem);
}

.so-new {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s-2);
  margin: 0;
  padding-block: var(--s-2);
  padding-inline: var(--s-3);
  border-radius: var(--r-chip);
  background: var(--warn-bg);
  border: 1px solid var(--warn);
  font-weight: 700;
}

.so-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
}

.so-head h2 {
  margin: 0;
  font-size: var(--t-title);
}

.so-live {
  margin: 0;
  min-block-size: 1.5rem;
  color: var(--good-ink);
}

.so-filter input {
  min-block-size: 44px;
  inline-size: 100%;
  font-size: var(--t-body);
}

.so-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
}

.so-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s-3);
  padding-block: var(--s-2);
  border-block-end: 1px solid var(--line);
}

.so-row--out .so-state {
  color: var(--stop);
  font-weight: 700;
}

.so-row--left .so-state {
  color: var(--ink);
  font-weight: 700;
}

.so-name {
  flex: 1;
  font-size: var(--t-k-meta);
}

.so-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-2);
}

.so-btn {
  min-block-size: 44px;
  min-inline-size: 44px;
}

.so-btn--out {
  background: var(--stop-bg);
  color: var(--stop);
}

.so-btn--back {
  background: var(--good-bg);
  color: var(--good-ink);
}

/* ---------------------------------------------------------------- the note, the label, the name */

.line__note,
.kitem-note,
.ktag {
  display: block;
  color: var(--ink-soft);
  font-size: var(--t-caption);
}

.kitem-note {
  font-size: var(--t-k-meta);
  font-weight: 700;
  color: var(--ink);
}

.ktag {
  margin: 0;
  font-size: var(--t-k-meta);
  font-weight: 700;
  color: var(--ink);
}

.knote-btn {
  min-block-size: 44px;
}

.kpay {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--s-3);
}

.kpay__field {
  display: flex;
  flex-direction: column;
  gap: var(--s-1);
}

.kpay__field input {
  min-block-size: 44px;
  font-size: var(--t-body);
}

.kprint {
  margin: 0;
  color: var(--info);
  font-size: var(--t-label);
}

@media (max-width: 30rem) {
  .kpay {
    grid-template-columns: 1fr;
  }
}

/* ---------------------------------------------------------------- the kitchen's paper */

.chit,
.clabel {
  color: var(--slip-ink);
  background: var(--slip-paper);
}

.chit {
  font-size: 11pt;
  line-height: 1.35;
  padding-block: 2mm;
}

.slip-preview .chit,
.slip-preview .clabel {
  margin-block-start: var(--s-4);
  border-block-start: 2px dashed var(--slip-ink);
}

.chit__head {
  text-align: center;
  border-block-end: 1px dashed var(--slip-ink);
  padding-block-end: 1mm;
}

.chit__call {
  font-size: 22pt;
  font-weight: 800;
}

.chit__meta,
.chit__small {
  font-size: 9pt;
}

.chit__tag {
  font-size: 12pt;
  font-weight: 700;
}

.chit__items {
  list-style: none;
  margin: 0;
  padding: 0;
}

.chit__item {
  padding-block: 1mm;
  border-block-end: 1px dotted var(--slip-ink);
  font-size: 12pt;
}

.chit__mods {
  font-size: 10pt;
}

.chit__note {
  font-size: 11pt;
  font-weight: 700;
}

.chit--58 {
  font-size: 9pt;
}

.clabel {
  inline-size: var(--p-label-w);
  block-size: var(--p-label-h);
  box-sizing: border-box;
  padding-block: 1mm;
  padding-inline: 1.5mm;
  overflow: hidden;
  font-size: 8pt;
  line-height: 1.2;
}

/* Review F-M5: what matters first, each part held to its lines (the markup cuts it to its room with «…» too): the
   number and the cup's count, then the name and the table; the item on one line; options and note on two each. */
.clabel__top {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas:
    'call unit'
    'name tag';
  column-gap: 1mm;
  font-weight: 700;
}

.clabel__call {
  grid-area: call;
  font-size: 12pt;
  line-height: 1.1;
}

.clabel__unit {
  grid-area: unit;
}

.clabel__name {
  grid-area: name;
}

.clabel__tag {
  grid-area: tag;
}

.clabel__name,
.clabel__tag,
.clabel__item {
  min-inline-size: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.clabel__item {
  font-size: 10pt;
  font-weight: 700;
  white-space: nowrap;
}

/* Two lines each, held by height (8 pt at 1.2): a -webkit-box line clamp makes Chromium drop the label's named page
   (found in the lab drive) — the markup cuts the text to its room with «…» anyway. */
.clabel__mods,
.clabel__note {
  max-block-size: 2.4em;
  overflow: hidden;
}

.clabel__note {
  font-weight: 700;
}

@media print {
  /* The cup label: a named 40x30 mm page each label opts into (D-20: a setting of the station's label printer). */
  @page label {
    size: 40mm 30mm;
    margin: 0;
  }
  /* A label station's print is labels only: the page itself is the label's from the first one, so no blank page (a
     blank label) comes before it (found in the lab drive: the first page was the roll's, empty). */
  body:has(> .receipt--label) {
    page: label;
    min-block-size: 0;
  }
  .receipt--label {
    page: label;
    inline-size: var(--p-label-w);
  }
  .clabel {
    page: label;
    break-after: page;
  }
  /* A chit after the receipt, or after another chit, starts its own page. */
  .chit--page {
    break-before: page;
  }
  .receipt--label .clabel:last-child {
    break-after: auto;
  }
}

/* Till UX slice 3: the board's English line under its Arabic one */
.b-en {
  display: block;
  font-size: 0.6em;
  font-weight: 600;
  opacity: 0.85;
}
