/* =====================================================================
   شاشة العميل (/screen) — shared by the three themes. Colours, font and
   buttons come from /themes/<theme>/base.css (same token names in each).
   Landscape monitor: text beside the QR. Portrait tablet / phone: stacked.
   ===================================================================== */
html, body { height: 100%; }
.k-page { display: flex; flex-direction: column; min-height: 100dvh; overflow: hidden; user-select: none; -webkit-user-select: none; }
.k-page.k-still, .k-page.k-still * { cursor: none !important; } /* nobody moves the mouse: hide it */

/* ---------- header: the café ---------- */
.k-head { display: flex; align-items: center; justify-content: center; gap: 14px; padding: clamp(14px, 3.5vh, 36px) 24px 0; }
.k-logo { width: clamp(40px, 7vh, 76px); height: clamp(40px, 7vh, 76px); object-fit: contain; border-radius: var(--radius-sm); }
.k-shop { font-size: clamp(20px, 4.4vh, 42px); font-weight: var(--fw-bold); line-height: 1.25; text-align: center; }

/* ---------- states (body[data-state]) ---------- */
.k-main { flex: 1; min-height: 0; display: grid; place-items: center; padding: clamp(10px, 3vh, 36px) clamp(16px, 5vw, 80px); }
.k-state { display: none; }
.k-page[data-state="boot"] .k-boot,
.k-page[data-state="pair"] .k-pair,
.k-page[data-state="idle"] .k-idle,
.k-page[data-state="show"] .k-show,
.k-page[data-state="done"] .k-done { display: flex; animation: k-in .5s var(--ease) both; }
@keyframes k-in { from { opacity: 0; transform: translateY(14px) scale(.985); } to { opacity: 1; transform: none; } }

.k-boot, .k-pair, .k-done { flex-direction: column; align-items: center; text-align: center; gap: clamp(10px, 2.4vh, 22px); max-width: 920px; }
.k-text { display: flex; flex-direction: column; gap: clamp(6px, 1.6vh, 16px); min-width: 0; }
.k-title { font-size: clamp(22px, 5vh, 52px); font-weight: var(--fw-bold); line-height: 1.3; }
.k-sub { font-size: clamp(15px, 2.8vh, 26px); color: var(--muted); line-height: 1.6; }
.k-note { font-size: clamp(13px, 2.2vh, 18px); color: var(--muted); }
.k-error { font-size: clamp(14px, 2.4vh, 20px); color: var(--danger); font-weight: var(--fw-medium); }
.k-kicker { font-size: clamp(18px, 3.6vh, 34px); font-weight: var(--fw-medium); color: var(--muted); }

/* QR: always dark modules on white with a quiet zone, whatever the theme (phone cameras need contrast). */
.k-qr { flex: none; background: #fff; padding: clamp(10px, 2vh, 22px); border-radius: var(--radius-lg); box-shadow: inset 0 0 0 1.5px var(--line), 0 28px 50px -30px rgba(0, 0, 0, .55); }
.k-qr img { display: block; width: var(--qr); height: var(--qr); }

/* idle: counter QR (customer types the order number) */
.k-idle { --qr: min(56vh, 36vw); flex-direction: row; align-items: center; gap: clamp(24px, 6vw, 96px); }

/* show: the order QR sent by the cashier */
.k-show { --qr: min(64vh, 44vw); flex-direction: row; align-items: center; gap: clamp(24px, 5vw, 88px); }
.k-num { font-size: clamp(72px, 24vh, 260px); font-weight: var(--fw-bold); line-height: .95; color: var(--ready); letter-spacing: -.02em; }
.k-num.len-4 { font-size: clamp(60px, 17vh, 190px); }
.k-num.len-6 { font-size: clamp(48px, 12vh, 130px); }
.k-timer { height: 8px; max-width: 420px; margin-top: clamp(6px, 2vh, 18px); border-radius: var(--radius-pill); background: var(--line); overflow: hidden; }
.k-timer i { display: block; height: 100%; border-radius: inherit; background: var(--ready); transform-origin: right center; }
.k-timer.is-running i { animation: k-shrink var(--dur, 60s) linear forwards; }
@keyframes k-shrink { from { transform: scaleX(1); } to { transform: scaleX(0); } }

/* pair: 6-digit code typed in the dashboard */
.k-code { font-size: clamp(56px, 16vh, 168px); font-weight: var(--fw-bold); letter-spacing: .08em; line-height: 1.1; white-space: nowrap;
  padding: clamp(12px, 2.4vh, 26px) clamp(24px, 4vw, 56px); border-radius: var(--radius-lg); background: var(--surface); box-shadow: inset 0 0 0 1.5px var(--line); }

/* done: the customer scanned */
.k-check { display: grid; place-items: center; width: clamp(110px, 26vh, 260px); aspect-ratio: 1; border-radius: 50%; background: var(--ready); color: var(--on-ready);
  animation: k-pop .6s var(--spring, cubic-bezier(.3, 1.5, .5, 1)) both; }
.k-check svg { width: 58%; height: 58%; }
@keyframes k-pop { from { opacity: 0; transform: scale(.4); } to { opacity: 1; transform: none; } }
.k-done b { color: var(--text); }

.k-spinner { width: 44px; height: 44px; border-radius: 50%; border: 4px solid var(--line); border-top-color: var(--ready); animation: k-spin 1s linear infinite; }
@keyframes k-spin { to { transform: rotate(360deg); } }
.k-boot p { font-size: 18px; color: var(--muted); }

/* ---------- footer: brand, connection, fullscreen ---------- */
.k-foot { display: flex; align-items: center; gap: 16px; min-height: 64px; padding: 0 clamp(16px, 3vw, 40px) clamp(10px, 2.4vh, 26px); }
.k-foot .wordmark { font-size: clamp(14px, 2.4vh, 22px); }
.k-live { display: inline-flex; align-items: center; gap: 8px; margin-inline-start: auto; font-size: 14px; color: var(--muted); }
.k-live .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); }
.k-live[data-mode="live"] .dot { background: #3C8A55; }
.k-live[data-mode="down"] { color: var(--danger); }
.k-live[data-mode="down"] .dot { background: var(--danger); }
.k-live[data-mode=""] { visibility: hidden; }
.k-fs { transition: opacity .3s; }
.k-still .k-fs { opacity: 0; pointer-events: none; }

/* ---------- portrait (tablet on a stand, phone) ---------- */
@media (max-aspect-ratio: 1/1) {
  .k-idle, .k-show { flex-direction: column; align-items: center; text-align: center; }
  .k-idle { --qr: min(44vh, 70vw); gap: clamp(16px, 4vh, 40px); }
  .k-show { --qr: min(40vh, 72vw); gap: clamp(12px, 3vh, 32px); }
  .k-show .k-text { align-items: center; }
  /* text follows the narrow side too, so an old phone on a stand still fits without scrolling */
  .k-title { font-size: clamp(20px, min(5vh, 6.4vw), 52px); }
  .k-sub { font-size: clamp(14px, min(2.8vh, 3.8vw), 26px); }
  .k-kicker { font-size: clamp(16px, min(3.6vh, 4.8vw), 34px); }
  .k-num { font-size: clamp(64px, min(13vh, 24vw), 200px); }
  .k-num.len-4 { font-size: clamp(54px, min(10vh, 18vw), 150px); }
  .k-num.len-6 { font-size: clamp(44px, min(8vh, 13vw), 110px); }
  .k-code { font-size: clamp(44px, min(16vh, 15vw), 168px); }
  .k-timer { width: min(420px, 70vw); }
}
