/* ============================================================================
   KOREVRA SERVE — Kitchen display (.portal-kds / .kd-) + Collection board
   (.portal-board / .bd-). Designed dark for a kitchen; every colour is a token
   so the light theme is a real theme, not an accident.
   ==========================================================================*/

/* ---------------------------------------------------------------- KDS shell */
.portal-kds { height: 100vh; height: 100dvh; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; background: var(--bg); color: var(--ink); overflow: hidden; }

/* header */
.kd-head { display: flex; align-items: center; gap: 20px; padding: 12px 22px; border-bottom: 1px solid var(--line); background: var(--bg-2); flex-wrap: wrap; }
.kd-brand { display: flex; align-items: center; gap: 14px; min-width: 0; }
.kd-brand h1 { font-size: 22px; line-height: 1.1; white-space: nowrap; }
.kd-sub { font-size: 12.5px; color: var(--ink-3); margin-top: 2px; white-space: nowrap; }
.kd-counts { display: flex; gap: 8px; }
.kd-count { min-width: 102px; padding: 8px 14px; border-radius: var(--r-2); background: var(--card); border: 1px solid var(--line); display: flex; flex-direction: column; gap: 2px; border-top: 3px solid var(--line-2); }
.kd-count b { font-family: var(--font-display); font-size: 28px; line-height: 1; font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; display: inline-block; }
.kd-count span { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-3); font-weight: 700; }
.kd-count-placed { border-top-color: var(--sky); } .kd-count-placed b { color: var(--sky-ink); }
.kd-count-preparing { border-top-color: var(--saffron); } .kd-count-preparing b { color: var(--saffron-ink); }
.kd-count-ready { border-top-color: var(--basil); } .kd-count-ready b { color: var(--basil-ink); }
.kd-load { flex: 1 1 280px; min-width: 260px; max-width: 560px; }
.kd-load-cap { display: flex; justify-content: space-between; gap: 10px; font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; font-weight: 700; color: var(--ink-3); margin-bottom: 4px; }
.kd-load-next { color: var(--saffron-ink); text-transform: none; letter-spacing: 0; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kd-load .bars { gap: 4px; }
.kd-load .bar { border-radius: 4px 4px 2px 2px; }
.kd-load .bar.is-hi { box-shadow: 0 0 0 2px var(--bg-2), 0 0 0 4px var(--saffron); }
.kd-status { margin-left: auto; display: flex; align-items: center; gap: 14px; }
.kd-clock { font-family: var(--font-display); font-size: 32px; font-weight: 600; line-height: 1; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; display: inline-flex; align-items: baseline; }
.kd-clock span { font-size: 18px; color: var(--ink-4); font-weight: 500; }
.kd-rail-btn[aria-pressed="true"] { background: var(--plum-wash); color: var(--plum-ink); border-color: transparent; }

/* columns */
.kd-main { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; padding: 14px 22px; min-height: 0; }
.portal-kds.rail-open .kd-main { grid-template-columns: repeat(3, minmax(0, 1fr)) 340px; }
.kd-col { display: flex; flex-direction: column; min-height: 0; background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--r-3); overflow: hidden; border-top: 4px solid var(--line-2); }
.kd-col-placed { border-top-color: var(--sky); } .kd-col-preparing { border-top-color: var(--saffron); } .kd-col-ready { border-top-color: var(--basil); }
.kd-ch { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.kd-ch h2 { font-size: 20px; }
.kd-col-placed .kd-ch h2 { color: var(--sky-ink); } .kd-col-preparing .kd-ch h2 { color: var(--saffron-ink); } .kd-col-ready .kd-ch h2 { color: var(--basil-ink); }
.kd-ch-n { font-family: var(--font-display); font-size: 22px; font-weight: 600; color: var(--ink-2); font-variant-numeric: tabular-nums; display: inline-block; }
.kd-col-body { flex: 1; min-height: 0; overflow-y: auto; padding: 12px; position: relative; scrollbar-width: thin; }
.kd-col.is-empty .kd-col-body::after { content: attr(data-empty); position: absolute; inset: 0; display: grid; place-items: center; padding: 30px; text-align: center; color: var(--ink-4); font-size: 14px; line-height: 1.5; pointer-events: none; }
.kd-groups { display: flex; flex-direction: column; gap: 14px; }
.kd-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(236px, 1fr)); gap: 10px; align-content: start; }

/* slot groups (incoming) */
.kd-group { display: flex; flex-direction: column; gap: 8px; }
.kd-gh { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 2px 4px; }
.kd-gh-l { display: flex; align-items: baseline; gap: 8px; }
.kd-gh-slot { font-family: var(--font-display); font-size: 20px; font-weight: 600; letter-spacing: -0.01em; }
.kd-group.is-due .kd-gh-slot { color: var(--saffron-ink); }
.kd-group.is-due .kd-gh-slot::before { content: ''; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--saffron); margin-right: 8px; vertical-align: 2px; box-shadow: 0 0 0 3px var(--saffron-wash); }
.kd-gh-n { font-size: 12.5px; color: var(--ink-3); font-weight: 600; }
.kd-gh .btn { min-height: 36px; }

/* ticket */
.kd-ticket { background: var(--card); border: 1px solid var(--line); border-radius: var(--r-2); padding: 12px 14px 12px; display: flex; flex-direction: column; gap: 8px; box-shadow: var(--shadow-1); position: relative; transition: border-color var(--t-base), box-shadow var(--t-base); }
.kd-ticket.is-warn { border-color: var(--saffron); }
.kd-ticket.is-hot { border-color: var(--paprika); box-shadow: 0 0 0 3px var(--paprika-wash), var(--shadow-1); }
.kd-th { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.kd-code { font-family: var(--font-display); font-size: 36px; font-weight: 700; letter-spacing: 0.08em; line-height: 1; color: var(--ink); }
.kd-age { font-family: var(--font-mono); font-size: 15px; font-weight: 600; padding: 4px 9px; border-radius: var(--r-pill); background: var(--bg-2); color: var(--ink-2); font-variant-numeric: tabular-nums; transition: background var(--t-base), color var(--t-base); }
.kd-age[data-due-slot] { background: transparent; color: var(--ink-3); font-family: var(--font-ui); font-size: 13px; }
.kd-ticket.is-warn .kd-age { background: var(--saffron-wash); color: var(--saffron-ink); }
.kd-ticket.is-hot .kd-age { background: var(--paprika-wash); color: var(--paprika-ink); }
.kd-meta { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 12.5px; color: var(--ink-3); }
.kd-slot { display: inline-flex; align-items: center; gap: 4px; font-weight: 600; color: var(--ink-2); }
.kd-slot .ic { width: 14px; height: 14px; color: var(--ink-3); }
.kd-who { margin-left: auto; font-weight: 600; color: var(--ink-2); }
.kd-items { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 5px; }
.kd-items li { display: flex; align-items: center; gap: 8px; font-size: 15px; font-weight: 600; line-height: 1.3; }
.kd-emoji { font-size: 20px; width: 26px; text-align: center; flex: none; line-height: 1; }
.kd-iname { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kd-qty { font-family: var(--font-mono); font-size: 12.5px; padding: 2px 7px; border-radius: var(--r-pill); background: var(--bg-3); color: var(--ink-2); flex: none; }
.kd-note { display: flex; gap: 8px; align-items: flex-start; font-size: 13px; background: var(--saffron-wash); border-radius: var(--r-1); padding: 8px 10px; color: var(--ink); }
.kd-note .ic { color: var(--saffron-ink); flex: none; margin-top: 2px; }
.kd-actions { display: flex; gap: 8px; margin-top: 2px; }
.kd-act { flex: 1; min-height: 44px; font-size: 15px; border-radius: var(--r-2); }
.kd-act-sm { flex: 0 0 auto; }
.kd-out { animation: kd-out 0.28s var(--ease-out) forwards; pointer-events: none; }
@keyframes kd-out { to { opacity: 0; transform: scale(0.96) translateY(-4px); } }

/* production rail */
.kd-rail { display: none; flex-direction: column; min-height: 0; background: var(--card); border: 1px solid var(--line); border-radius: var(--r-3); overflow: hidden; border-top: 4px solid var(--plum); }
.portal-kds.rail-open .kd-rail { display: flex; animation: slide-in 0.4s var(--ease-out) both; }
.kd-rh { display: flex; align-items: center; justify-content: space-between; padding: 10px 10px 10px 16px; border-bottom: 1px solid var(--line); }
.kd-rh h3 { font-size: 18px; display: inline-flex; align-items: center; gap: 8px; color: var(--plum-ink); }
.kd-rail-body { flex: 1; min-height: 0; overflow-y: auto; padding: 12px 14px 16px; display: flex; flex-direction: column; gap: 12px; scrollbar-width: thin; }
.kd-rail-cap { font-size: 12.5px; color: var(--ink-3); line-height: 1.5; }
.kd-rail-cap b { color: var(--ink); font-family: var(--font-display); font-size: 15px; }
.kd-plan { display: flex; flex-direction: column; gap: 8px; }
.kd-pd { background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--r-2); padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; transition: opacity var(--t-base), border-color var(--t-base); }
.kd-pd.is-off { opacity: 0.62; border-style: dashed; }
.kd-pd.is-off .kd-pd-name::after { content: 'SOLD OUT'; margin-left: 8px; font-size: 10px; letter-spacing: 0.1em; color: var(--paprika-ink); vertical-align: 1px; }
.kd-pd-top { display: flex; align-items: center; gap: 8px; }
.kd-pd-emoji { font-size: 22px; line-height: 1; flex: none; }
.kd-pd-name { flex: 1; min-width: 0; font-weight: 700; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kd-pd-nums { display: flex; align-items: baseline; gap: 12px; font-size: 12px; color: var(--ink-3); flex-wrap: wrap; }
.kd-pd-nums b { color: var(--ink); font-family: var(--font-display); font-size: 17px; font-weight: 600; font-variant-numeric: tabular-nums; display: inline-block; }
.kd-pd-range { margin-left: auto; font-size: 11.5px; color: var(--plum-ink); white-space: nowrap; }
.kd-pd-acts { display: flex; gap: 6px; }
.kd-pd-acts .btn { flex: 1; min-height: 40px; }
.kd-short ul { margin: 6px 0 0; padding-left: 16px; font-size: 13px; line-height: 1.5; }
.kd-short li + li { margin-top: 4px; }
.kd-rail-foot { font-size: 11.5px; color: var(--ink-4); line-height: 1.5; border-top: 1px solid var(--line); padding-top: 10px; }

/* footer ticker */
.kd-foot { border-top: 1px solid var(--line); background: var(--bg-2); padding: 8px 22px; display: flex; align-items: center; gap: 14px; overflow: hidden; min-height: 50px; }
.kd-foot-l { font-size: 11px; text-transform: uppercase; letter-spacing: 0.1em; font-weight: 700; color: var(--ink-4); display: inline-flex; align-items: center; gap: 6px; flex: none; }
.kd-foot-l .ic { color: var(--saffron-ink); }
.kd-ticker { display: flex; gap: 8px; flex: 1; min-width: 0; overflow: hidden; }
.kd-tk { display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: var(--r-pill); background: var(--card); border: 1px solid var(--line); font-size: 12.5px; white-space: nowrap; flex: none; color: var(--ink-2); }
.kd-tk b { font-family: var(--font-display); letter-spacing: 0.06em; font-size: 14px; color: var(--ink); }
.kd-tk .faint { font-size: 11.5px; }
.kd-tk.kd-out { animation-duration: 0.2s; }

/* narrow / portrait fallbacks — the KDS is built for a 32" landscape screen */
@media (max-width: 1100px) {
  .portal-kds { height: auto; overflow: visible; grid-template-rows: auto auto auto; }
  .kd-main, .portal-kds.rail-open .kd-main { grid-template-columns: minmax(0, 1fr); }
  .kd-col-body { overflow: visible; min-height: 120px; }
  .kd-status { margin-left: 0; width: 100%; justify-content: space-between; }
  .kd-foot { position: sticky; bottom: 0; }
}

/* ---------------------------------------------------------------- BOARD */
.portal-board { position: relative; height: 100vh; height: 100dvh; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; overflow: hidden; background: var(--bg); color: var(--ink); isolation: isolate; }
.bd-ambient { position: absolute; inset: -25%; z-index: -1; pointer-events: none; filter: blur(48px); opacity: 0.9;
  background: radial-gradient(38% 46% at 18% 22%, var(--saffron-wash), transparent 70%), radial-gradient(34% 44% at 84% 82%, var(--basil-wash), transparent 70%), radial-gradient(28% 38% at 72% 12%, var(--plum-wash), transparent 70%), radial-gradient(30% 40% at 10% 90%, var(--teal-wash), transparent 70%);
  animation: bd-drift 26s ease-in-out infinite alternate; will-change: transform; }
@keyframes bd-drift { from { transform: translate3d(-3%, -2%, 0) scale(1); } to { transform: translate3d(3%, 3%, 0) scale(1.1); } }

.bd-head { display: flex; justify-content: space-between; align-items: center; padding: 22px 44px 8px; gap: 20px; }
.bd-brand { display: flex; align-items: center; gap: 18px; min-width: 0; }
.bd-site { font-family: var(--font-display); font-size: clamp(18px, 1.6vw, 24px); color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bd-status { display: flex; align-items: center; gap: 22px; }
.bd-live { display: inline-flex; align-items: center; gap: 9px; font-size: 12.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.1em; color: var(--ink-3); }
.bd-clock { font-family: var(--font-display); font-size: clamp(36px, 3.4vw, 52px); font-weight: 600; line-height: 1; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; display: inline-flex; align-items: baseline; }
.bd-clock span { font-size: 0.5em; color: var(--ink-4); font-weight: 500; }

.bd-main { display: grid; grid-template-columns: minmax(0, 1fr) clamp(280px, 24vw, 420px); gap: 36px; padding: 8px 44px 18px; min-height: 0; }
.bd-ready, .bd-prep { min-height: 0; display: flex; flex-direction: column; }
.bd-title { font-family: var(--font-display); font-size: clamp(26px, 2.4vw, 40px); font-weight: 600; text-transform: uppercase; letter-spacing: 0.1em; color: var(--basil-ink); display: flex; align-items: baseline; gap: 14px; margin-bottom: 16px; }
.bd-title-n { font-size: 0.55em; color: var(--ink-3); letter-spacing: 0; font-variant-numeric: tabular-nums; }
.bd-title-sm { font-size: clamp(18px, 1.6vw, 26px); color: var(--saffron-ink); }
.bd-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(236px, 1fr)); gap: 18px; align-content: start; overflow: hidden; min-height: 0; }
.bd-tile { background: var(--card); border: 1px solid var(--line); border-radius: var(--r-4); padding: 28px 18px 22px; text-align: center; box-shadow: var(--shadow-2); position: relative; overflow: hidden; transition: box-shadow var(--t-base); }
.bd-tile::before { content: ''; position: absolute; left: 0; right: 0; top: 0; height: 5px; background: linear-gradient(90deg, var(--basil), var(--saffron)); }
.bd-tile.breathe { box-shadow: 0 0 0 3px var(--basil), var(--shadow-3); }
.bd-tile-more { background: transparent; border-style: dashed; box-shadow: none; }
.bd-tile-more::before { display: none; }
.bd-tile-more .bd-code { color: var(--ink-3); }
.bd-code { font-family: var(--font-display); font-size: clamp(64px, 5.4vw, 100px); font-weight: 700; letter-spacing: 0.1em; line-height: 1; color: var(--ink); font-variant-numeric: tabular-nums; }
.bd-name { margin-top: 10px; font-size: clamp(16px, 1.3vw, 22px); font-weight: 600; color: var(--ink-2); }
.bd-since { margin-top: 4px; font-size: 12px; color: var(--ink-4); text-transform: uppercase; letter-spacing: 0.08em; font-weight: 700; }
.bd-empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; text-align: center; color: var(--ink-3); font-size: clamp(16px, 1.4vw, 22px); padding: 40px 20px; }
.bd-empty-ic .ic { width: 56px; height: 56px; color: var(--basil-ink); opacity: 0.8; }
.bd-empty .faint { font-size: 0.8em; }
.bd-list { overflow: hidden; display: flex; flex-direction: column; gap: 8px; min-height: 0; }
.bd-row { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 14px; padding: 10px 18px; background: var(--card); border: 1px solid var(--line); border-radius: var(--r-2); }
.bd-row-code { font-family: var(--font-display); font-size: clamp(24px, 2vw, 34px); font-weight: 700; letter-spacing: 0.08em; line-height: 1; color: var(--ink); }
.bd-row-slot { font-size: 12.5px; font-weight: 700; color: var(--saffron-ink); background: var(--saffron-wash); padding: 3px 10px; border-radius: var(--r-pill); justify-self: start; }
.bd-row-name { color: var(--ink-3); font-size: 14px; font-weight: 600; white-space: nowrap; }
.bd-row-more { display: block; text-align: center; color: var(--ink-4); font-size: 13px; background: transparent; border-style: dashed; }

.bd-foot { border-top: 1px solid var(--line); background: var(--bg-2); padding: 16px 0; overflow: hidden; }
.bd-marquee-wrap { overflow: hidden; white-space: nowrap; }
.bd-marquee-wrap .marquee { gap: 0; animation-duration: 48s; }
.bd-mq-copy { display: inline-flex; align-items: center; gap: 28px; padding-right: 28px; }
.bd-mi { display: inline-flex; align-items: center; gap: 10px; font-family: var(--font-display); font-size: clamp(18px, 1.5vw, 24px); color: var(--ink); }
.bd-mi i { font-style: normal; font-size: 1.2em; line-height: 1; }
.bd-mi b { color: var(--saffron-ink); font-weight: 600; }
.bd-sep { color: var(--ink-4); font-size: 20px; }
.bd-msg { font-size: clamp(15px, 1.2vw, 19px); font-weight: 700; text-transform: uppercase; letter-spacing: 0.12em; color: var(--basil-ink); }
.bd-msg-2 { color: var(--teal-ink); }

@media (max-width: 900px) {
  .bd-main { grid-template-columns: minmax(0, 1fr); padding: 8px 20px 12px; gap: 20px; }
  .bd-head { padding: 16px 20px 4px; }
  .bd-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
  .bd-code { font-size: clamp(44px, 12vw, 64px); }
  .bd-prep { max-height: 38vh; }
}

@media (prefers-reduced-motion: reduce) {
  .bd-ambient, .kd-out, .portal-kds.rail-open .kd-rail { animation: none !important; }
  .kd-out { opacity: 0; }
}
