/*
 * Restaurant R1 — the kitchen: the station display (views-kitchen.js), the sale screen's kitchen notice and banner
 * (sale-kitchen.js) and the kitchen's back-office tab (views-kitchen-office.js). Every colour, size and radius is a
 * token (tokens.css, with its dark values); spacing is logical, so the page reads right to left without a rule of its
 * own. A bump button is at least 60 px (a cook's wet thumb, two metres from the screen); every other control at least
 * 44 px. A ticket's timer is coloured at 80 %, 100 % and 150 % of the station's target, and the card says its state
 * in words — «جديد», «قيد التحضير», «جاهز», and «متأخر» past the target (review fix M7: never colour alone).
 */

/* ---------------------------------------------------------------- the display */

body[data-screen='kitchen'] .stage {
  max-inline-size: none;
  padding-inline: var(--s-3);
}

.kq {
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
}

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

.kq-head h1 {
  margin: 0;
  font-size: var(--t-title);
  line-height: var(--t-title-lh);
}

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

.kallday {
  background: var(--surface-2);
  border-radius: var(--r-card);
  padding-block: var(--s-2);
  padding-inline: var(--s-3);
}

.kallday h2 {
  margin: 0;
  font-size: var(--t-label);
  color: var(--ink-soft);
}

.kallday-list {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-2) var(--s-4);
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: var(--t-k-meta);
}

.kcards {
  display: grid;
  /* review fix H2: a 1080p display holds five wide cards, not eight narrow ones */
  grid-template-columns: repeat(auto-fill, minmax(22rem, 1fr));
  gap: var(--s-3);
  align-items: start;
}

.kempty {
  color: var(--muted);
  font-size: var(--t-body);
}

.kticket {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  background: var(--surface);
  color: var(--ink);
  border: 2px solid var(--line);
  border-radius: var(--r-card);
  padding: var(--s-3);
  box-shadow: var(--shadow-soft);
}

/* Review fix M7: warn (80 %) is an amber edge on a plain card; late (100 %) a red card; over (150 %) a red card with
   a heavier edge. The timer takes the same colour, and the chip «متأخر» says it. */
.kticket--warn {
  border-color: var(--warn);
  border-width: 3px;
}

.kticket--late {
  border-color: var(--stop);
  border-width: 4px;
  background: var(--stop-bg);
}

.kticket--over {
  border-color: var(--stop);
  border-width: 6px;
  background: var(--stop-bg);
}

.ktimer--warn {
  color: var(--warn);
}

.ktimer--late {
  color: var(--stop);
}

.ktimer--over {
  color: var(--stop);
}

.kstates {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-2);
  margin: 0;
}

.kstate {
  border-radius: var(--r-pill);
  padding-block: var(--s-1);
  padding-inline: var(--s-3);
  font-size: var(--t-k-meta);
  font-weight: 700;
  color: var(--ink);
  background: var(--surface-2);
  border: 2px solid var(--line);
}

.kstate--progress {
  background: var(--info-bg);
  border-color: var(--info);
}

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

.kstate--late {
  background: var(--stop-bg);
  border-color: var(--stop);
  color: var(--stop);
}

.kticket-head {
  display: flex;
  align-items: baseline;
  gap: var(--s-2);
}

.kcall {
  font-size: var(--t-k-call);
  line-height: 1;
  font-weight: 800;
}

/* The order type, a coloured chip a cook tells apart at a glance (review fix H2). */
.ktype {
  align-self: center;
  border-radius: var(--r-chip);
  padding-block: var(--s-1);
  padding-inline: var(--s-2);
  font-size: var(--t-k-meta);
  font-weight: 700;
  color: var(--ink);
  border: 2px solid var(--line);
}

.ktype--dine_in {
  background: var(--info-bg);
  border-color: var(--info);
}

.ktype--takeaway {
  background: var(--warn-bg);
  border-color: var(--warn);
}

.ktype--delivery {
  background: var(--hue-4);
  border-color: var(--hue-4);
  color: var(--on-hue);
}

.ktimer {
  margin-inline-start: auto;
  font-size: var(--t-k-timer);
  line-height: 1;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

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

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

.kflag--refunded {
  color: var(--stop);
}

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

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

.kitem-text {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-inline-size: 0;
}

.kitem-name {
  font-size: var(--t-k-item);
  line-height: 1.25;
  font-weight: 600;
}

.kqty {
  font-weight: 800;
}

.kitem--voided .kitem-name {
  color: var(--muted);
}

.kitem--in_progress .kitem-name {
  color: var(--info);
}

.kitem--ready .kitem-name {
  color: var(--good-ink);
}

.kitem-mods,
.kitem-for,
.kitem-void {
  font-size: var(--t-k-meta);
  color: var(--ink-soft);
}

.kitem-void {
  color: var(--stop);
}

.kactions {
  display: flex;
  gap: var(--s-2);
}

.kbump {
  min-block-size: 60px;
  min-inline-size: 60px;
  flex: 1;
  border: 0;
  border-radius: var(--r-control);
  background: var(--accent);
  color: var(--accent-ink);
  font: inherit;
  font-size: var(--t-k-meta);
  font-weight: 700;
  cursor: pointer;
}

/* Review fix M8: each bump its own colour — start blue, ready the accent, hand over green. */
.kbump--start {
  background: var(--info-bg);
  color: var(--info);
  border: 2px solid var(--info);
}

.kbump--ready {
  background: var(--accent);
  color: var(--accent-ink);
}

.kbump--item {
  flex: 0 0 auto;
  background: var(--surface-2);
  color: var(--ink);
  border: 1px solid var(--line-control);
}

.kbump--handover {
  background: var(--good-bg);
  color: var(--good-ink);
  border: 2px solid var(--good);
}

.kbump:focus-visible,
.kbtn:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.kbump[disabled] {
  opacity: 0.6;
  cursor: progress;
}

.kbtn {
  min-block-size: 44px;
  min-inline-size: 44px;
  padding-inline: var(--s-3);
}

.kundo {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s-3);
  background: var(--surface-2);
  border: 2px solid var(--line-control);
  border-radius: var(--r-card);
  padding-block: var(--s-2);
  padding-inline: var(--s-3);
  font-size: var(--t-k-meta);
  font-weight: 700;
}

.kundo-btn {
  min-block-size: 60px;
  font-size: var(--t-k-meta);
  font-weight: 700;
}

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

.krecall-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-2);
}

.krecall summary {
  min-block-size: 44px;
  cursor: pointer;
  font-weight: 600;
}

.kpick {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  inline-size: 100%;
  text-align: start;
  /* browser drive defect 9: a picker card's three lines had no room above or below them */
  gap: var(--s-1);
  padding-block: var(--s-2);
  padding-inline: var(--s-3);
  margin-inline: 0;
}

/* ---------------------------------------------------------------- the sale screen */

.kdone {
  margin-block-start: var(--s-3);
}

.kdone--sent {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s-2);
  color: var(--good-ink);
  font-weight: 700;
}

.kdone--sent p {
  margin: 0;
}

.kbanner {
  background: var(--warn-bg);
  color: var(--ink);
  border: 1px solid var(--warn);
  border-radius: var(--r-chip);
  padding-block: var(--s-1);
  padding-inline: var(--s-2);
  font-size: var(--t-label);
}

.kbanner p {
  margin: 0;
}

/* Review fix H3: a sale the kitchen did not get is a stop, never a quiet line — listed until it is resent. */
.kdone--failed {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s-2);
  background: var(--stop-bg);
  color: var(--ink);
  border: 2px solid var(--stop);
  border-radius: var(--r-chip);
  padding-block: var(--s-2);
  padding-inline: var(--s-3);
  font-weight: 700;
}

.kdone--failed p {
  margin: 0;
  flex: 1;
}

.kbanner--failed {
  background: var(--stop-bg);
  border-color: var(--stop);
}

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

.kreceipt {
  white-space: nowrap;
}

.kbanner-list li {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-2);
}

/* ---------------------------------------------------------------- the receipt */

/* Review fix L14: the call number is what the customer reads off the slip when the kitchen calls it — large, in em
   so the 58 mm roll scales it with its own smaller text. */
.rcall {
  margin-block: 0.2em;
  font-size: 2em;
  line-height: 1.1;
  font-weight: 800;
}

/* ---------------------------------------------------------------- the back-office tab */

.ko-block {
  margin-block-start: var(--s-5);
}

.kstations,
.kdisplays {
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
  padding: 0;
  list-style: none;
}

.kcheck {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  min-block-size: 44px;
}

/* Review fix L13: the box on its label's line (a form's label is a column), and a box, not a stretched field. */
.form .kcheck {
  flex-direction: row;
  align-items: center;
}

.kcheck input {
  min-block-size: 24px;
  min-inline-size: 24px;
  margin: 0;
  padding: 0;
}

/* Review U-M2: the way to «الموافقة والأجهزة», where a display is run on its own device. */
.ko-run {
  margin-block-start: var(--s-3);
}

/* A form folded behind one line, so the tab is a list first and a form only when asked. */
.kfold {
  margin-block-start: var(--s-2);
}

.kfold summary {
  display: flex;
  align-items: center;
  min-block-size: 44px;
  cursor: pointer;
  font-weight: 600;
  color: var(--accent);
}

.kfold[open] summary {
  margin-block-end: var(--s-2);
}

@media (max-width: 420px) {
  .kcards {
    grid-template-columns: 1fr;
  }
}

/* Restaurant R2 (0301): a display with nobody signed in — the owner's list, the pairing's last step, a display gone. */
.devseen {
  font-size: var(--t-meta);
  color: var(--muted);
}

.devleave {
  display: grid;
  gap: var(--s-2);
  margin-block-start: var(--s-3);
}

.devleave .btn,
.devgone .btn {
  min-block-size: 60px;
}

.devgone {
  display: grid;
  gap: var(--s-3);
  justify-items: start;
}
