/* PEC staff order system — shared tokens, top bar, buttons, overlays and motion.
   Each screen has its own file (register/kitchen/presenter/sales.css) for its layout. */

:root {
  --cream: #FBF5E8;
  --cream-deep: #F3E9D2;
  --ink: #1B0F0C;
  --white: #FFFFFF;
  --red: #D9381E;      /* destructive buttons only (取り消す, 全部消す) */
  --blue: #2459F5;     /* go forward */
  --green: #15803D;    /* completion */
  --orange: #FF8A1F;   /* errors and warnings (ink text on it) */
  --pec: #FFE500;
  --kindai: #38E3FF;
  --teriyaki: #D28CFF;
  --hot: #FF5BB0;
  --side: var(--cream-deep);
  --drink: var(--white);
  --font-display: "Abril Fatface", "Times New Roman", serif;
  --font-label: "Montserrat", system-ui, sans-serif;
  --font-jp: "Zen Kaku Gothic New", "Hiragino Sans", "Yu Gothic", sans-serif;
  --border: 2.5px solid var(--ink);
  --shadow-sm: 3px 3px 0 var(--ink);
  --shadow: 4px 4px 0 var(--ink);
  --shadow-lg: 6px 6px 0 var(--ink);
  --topbar-h: 64px;
  --pad: 24px;
  --ease-out: cubic-bezier(.2, .8, .2, 1);
  --ease-spring: cubic-bezier(.34, 1.56, .64, 1);
}

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--cream); color: var(--ink);
  font-family: var(--font-jp); font-weight: 700; -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent; -webkit-user-select: none; user-select: none;
  touch-action: manipulation; overscroll-behavior: none;
  display: flex; flex-direction: column; overflow: hidden;
}
button { font: inherit; color: inherit; cursor: pointer; }
input { font: inherit; -webkit-user-select: text; user-select: text; }
[hidden] { display: none !important; }
.en { font-family: var(--font-label); font-weight: 900; }
.num { font-family: var(--font-display); font-weight: 400; font-variant-numeric: lining-nums; }

/* ---------- top bar ---------- */
.topbar {
  flex: none; height: calc(var(--topbar-h) + env(safe-area-inset-top)); padding: env(safe-area-inset-top) var(--pad) 0;
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 16px;
  background: var(--ink); color: var(--cream);
}
.topbar__logo { font-family: var(--font-display); font-size: 22px; white-space: nowrap; display: flex; align-items: center; gap: 10px; }
.tabs { justify-self: center; display: flex; gap: 6px; }
.tab {
  display: flex; align-items: center; gap: 8px; padding: 9px 18px; border-radius: 999px;
  border: 1.5px solid var(--cream); background: transparent; color: var(--cream);
  transition: background .2s var(--ease-out), color .2s var(--ease-out), border-color .2s, transform .08s;
}
.tab b { font-weight: 900; font-size: 15px; white-space: nowrap; }
.tab small { font-family: var(--font-label); font-weight: 800; font-size: 10px; letter-spacing: .02em; }
.tab[aria-current="page"] { background: var(--pec); border-color: var(--pec); color: var(--ink); }
.tab:active, .tab.is-pressed { transform: scale(.94); }
.tab--admin svg { flex: none; width: 13px; height: 13px; margin-right: -2px; }
.topbar__clock { justify-self: end; display: flex; align-items: center; gap: 10px; }
#clock { font-family: var(--font-label); font-weight: 900; font-size: 22px; font-variant-numeric: tabular-nums; }

.pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.pill--yellow { background: var(--pec); color: var(--ink); font-family: var(--font-label); font-weight: 900; font-size: 11px; }
.pill--outline { border: 1.5px solid currentColor; }
.pill--snack { background: var(--hot); color: var(--ink); border-color: var(--hot); }

/* who is logged in: avatar, name + role, ログアウト (not red: red is for destructive buttons) */
.who { display: flex; align-items: center; gap: 10px; padding-left: 14px; border-left: 1.5px solid rgb(251 245 232 / .3); }
.who__av {
  flex: none; width: 34px; height: 34px; display: grid; place-items: center; border-radius: 50%;
  background: var(--cream); color: var(--ink); font-size: 16px; font-weight: 900; line-height: 1;
}
.who[data-role="admin"] .who__av { background: var(--pec); }
.who[data-role="master"] .who__av { background: var(--kindai); }
.who__t { display: grid; min-width: 0; line-height: 1.2; }
.who__t b { max-width: 6.5em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; font-weight: 900; }
.who__t small { font-size: 11px; font-weight: 700; opacity: .75; }
.who__out {
  padding: 7px 13px; border: 1.5px solid var(--cream); border-radius: 999px; background: transparent; color: var(--cream);
  font-size: 13px; font-weight: 900; white-space: nowrap; transition: background-color .2s, color .2s, transform .08s;
}
.who__out:active, .who__out.is-pressed { transform: scale(.94); background: var(--cream); color: var(--ink); }

/* iPads and small laptops: five tabs + clock + who chip need the room, so the tabs lose their English labels */
@media (max-width: 1459px) {
  .topbar__logo .pill { display: none; }
  .tab { padding: 9px 14px; }
  .tab small { display: none; }
}
@media (max-width: 1100px) {
  .topbar { gap: 10px; }
  .tab { padding: 9px 11px; }
  #mode { display: none; }
}

/* phones: the presenter carries one; tabs shrink (and scroll if an owner has all five), logo goes */
@media (max-width: 760px) {
  :root { --topbar-h: 56px; --pad: 14px; }
  .topbar { grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
  .topbar__logo { display: none; }
  .tabs { justify-self: start; min-width: 0; max-width: 100%; gap: 4px; overflow-x: auto; scrollbar-width: none; }
  .tabs::-webkit-scrollbar { display: none; }
  .tab { flex: none; padding: 7px 10px; }
  .tab small { display: none; }
  .tab b { font-size: 14px; }
  #mode { display: none; }
  #clock { font-size: 18px; }
  .topbar__clock { gap: 8px; }
  .who { gap: 6px; padding-left: 0; border-left: 0; }
  .who__t { display: none; }
  .who__av { width: 28px; height: 28px; font-size: 14px; }
  .who__out { padding: 5px 9px; font-size: 12px; }
}

/* ---------- connection warning (orange = error) ---------- */
.netwarn {
  flex: none; background: var(--orange); color: var(--ink); border-bottom: var(--border);
  padding: 10px var(--pad); font-weight: 900; font-size: 15px; text-align: center;
  animation: drop-in .3s var(--ease-out);
}

/* ---------- views ---------- */
#views { flex: 1; min-height: 0; position: relative; view-transition-name: views; }
.view { position: absolute; inset: 0; overflow: auto; -webkit-overflow-scrolling: touch; }

/* ---------- buttons: pressing pushes the button into its hard shadow ---------- */
.btn {
  --bg: var(--white); --fg: var(--ink);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 12px 20px; border: var(--border); border-radius: 14px;
  background: var(--bg); color: var(--fg); box-shadow: var(--shadow);
  font-family: var(--font-jp); font-weight: 900; font-size: 17px; line-height: 1.2; text-align: center;
  transition: transform .09s var(--ease-out), box-shadow .09s var(--ease-out), background-color .2s, color .2s, opacity .2s;
}
.btn:active:not(:disabled), .btn.is-pressed:not(:disabled) { transform: translate(3px, 3px); box-shadow: 1px 1px 0 var(--ink); }
.btn:disabled { --bg: var(--cream-deep); box-shadow: none; opacity: .75; cursor: default; }
.btn--lg { min-height: 64px; font-size: 21px; border-radius: 16px; }
.btn--sm { min-height: 36px; padding: 6px 12px; font-size: 13px; border-radius: 12px; border-width: 2px; box-shadow: none; }
.btn--sm:active:not(:disabled), .btn--sm.is-pressed:not(:disabled) { transform: scale(.94); box-shadow: none; }
.btn--blue { --bg: var(--blue); --fg: var(--white); }
.btn--green { --bg: var(--green); --fg: var(--white); }
.btn--ink { --bg: var(--ink); --fg: var(--cream); }
.btn--yellow { --bg: var(--pec); }
.btn--white { --bg: var(--white); }
.btn--danger { --bg: var(--white); --fg: var(--red); border-color: var(--red); box-shadow: none; border-width: 2px; }
.btn--danger:active:not(:disabled), .btn--danger.is-pressed:not(:disabled) { transform: scale(.97); box-shadow: none; background: #FDECE8; }
.btn--outline { --bg: transparent; --fg: var(--ink); box-shadow: none; border-width: 2px; }
.btn--outline:active:not(:disabled), .btn--outline.is-pressed:not(:disabled) { transform: scale(.95); box-shadow: none; }
.btn .icon { width: 1.1em; height: 1.1em; flex: none; }
.btn--dialog-danger { --bg: var(--red); --fg: var(--white); }
[data-busy] { pointer-events: none; opacity: .65; }

/* ---------- toasts ---------- */
.toasts { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); translate: -50% 0; z-index: 50; display: grid; gap: 8px; justify-items: center; pointer-events: none; }
.toast {
  padding: 12px 20px; border: var(--border); border-radius: 14px; box-shadow: var(--shadow);
  font-weight: 900; font-size: 16px; background: var(--white); max-width: min(560px, 90vw);
  animation: toast-in .35s var(--ease-spring);
}
.toast--error { background: var(--orange); }
.toast--success { background: var(--green); color: var(--white); }
.toast.is-leaving { animation: toast-out .25s var(--ease-out) forwards; }

/* ---------- gate (staff code on a tenkey, or one tap to start) ---------- */
.gate { position: fixed; inset: 0; z-index: 60; display: flex; padding: 24px; overflow-y: auto; background: var(--ink); }
.gate.is-leaving { animation: fade-out .35s var(--ease-out) forwards; }
.gate__card {
  width: min(420px, 100%); margin: auto; display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; padding: 32px; text-align: center;
  background: var(--cream); border: var(--border); border-radius: 24px; box-shadow: 8px 8px 0 var(--pec);
  animation: pop-in .45s var(--ease-spring);
}
.gate__logo { font-family: var(--font-display); font-size: 30px; }
.gate__lead { margin: 0; font-size: 15px; }
.gate__title { margin: 0; font-size: 22px; font-weight: 900; }
.gate__sub { margin: -10px 0 0; font-size: 13px; font-weight: 500; opacity: .7; }
.gate__card > * { min-width: 0; }
/* one box per digit, filled yellow as they are typed (8; more only appear for the longer master key) */
.gate__boxes { display: grid; grid-template-columns: repeat(var(--n, 8), minmax(0, 1fr)); gap: 6px; }
.gate__box {
  position: relative; height: 52px; border: var(--border); border-radius: 12px; background: var(--white);
  transition: background-color .15s, box-shadow .15s;
}
.gate__box.is-on { background: var(--pec); }
.gate__box.is-on::after { content: ""; position: absolute; inset: 0; margin: auto; width: 35%; max-width: 14px; aspect-ratio: 1; border-radius: 50%; background: var(--ink); animation: pop-in .2s var(--ease-spring); }
.gate__box.is-next { box-shadow: 0 0 0 3px var(--blue); }
.gate__keys { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.gate__key { min-height: 58px; padding: 0; font-family: var(--font-label); font-weight: 900; font-size: 26px; border-radius: 16px; }
.gate__key--back, .gate__key--go { font-family: var(--font-jp); font-size: 19px; }
.gate__key--go:disabled { --bg: var(--blue); opacity: .4; } /* until 8 digits are in */
.gate__error { margin: 0; padding: 10px; border-radius: 12px; background: var(--orange); font-weight: 900; }
.gate__error.shake, .gate__boxes.shake { animation: shake .4s; }
.gate__note { margin: 0; font-size: 12px; font-weight: 500; opacity: .7; }
@media (max-width: 480px) {
  .gate { padding: 14px; }
  .gate__card { padding: 22px 18px; gap: 14px; }
  .gate__logo { font-size: 26px; }
}

/* ---------- confirm dialog ---------- */
.dialog { border: none; padding: 0; background: transparent; max-width: min(460px, 92vw); }
.dialog::backdrop { background: rgb(27 15 12 / .55); animation: fade-in .2s; }
.dialog[open] .dialog__card { animation: pop-in .3s var(--ease-spring); }
.dialog__card { display: grid; gap: 14px; padding: 28px; background: var(--cream); border: var(--border); border-radius: 22px; box-shadow: var(--shadow-lg); }
.dialog__title { margin: 0; font-size: 22px; font-weight: 900; }
.dialog__body { margin: 0; font-size: 15px; font-weight: 500; line-height: 1.6; }
.dialog__actions { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 6px; }

/* ---------- keyed list motion (app.keyed adds these) ---------- */
.is-entering { animation: pop-in .42s var(--ease-spring) both; }
.is-leaving { animation: leave .32s var(--ease-out) forwards; pointer-events: none; }
.is-bumped { animation: bump .35s var(--ease-spring); }

/* full-screen success flash (app.celebrate) */
.celebrate {
  position: fixed; inset: 0; z-index: 55; display: grid; place-items: center; pointer-events: none;
  background: rgb(21 128 61 / .92); color: var(--white); animation: fade-in .15s;
}
.celebrate.is-leaving { animation: fade-out .3s var(--ease-out) forwards; }
.celebrate__inner { display: grid; justify-items: center; gap: 12px; font-size: 32px; font-weight: 900; animation: pop-in .45s var(--ease-spring); }
.celebrate__check { width: 120px; height: 120px; border-radius: 50%; background: var(--white); display: grid; place-items: center; }
.celebrate__check path { stroke: var(--green); stroke-dasharray: 40; stroke-dashoffset: 40; animation: draw .4s .12s var(--ease-out) forwards; }
.celebrate__sub { font-size: 18px; opacity: .9; }

/* ---------- screen changes (View Transitions; app.js sets html.vt-forward / vt-back) ---------- */
::view-transition-old(root), ::view-transition-new(root) { animation: none; }
::view-transition-old(views), ::view-transition-new(views) { animation-duration: .32s; animation-timing-function: var(--ease-out); }
html.vt-forward::view-transition-old(views) { animation-name: slide-out-left; }
html.vt-forward::view-transition-new(views) { animation-name: slide-in-right; }
html.vt-back::view-transition-old(views) { animation-name: slide-out-right; }
html.vt-back::view-transition-new(views) { animation-name: slide-in-left; }
/* browsers without View Transitions get a simple slide on the incoming screen */
.view.enter-forward { animation: slide-in-right .32s var(--ease-out); }
.view.enter-back { animation: slide-in-left .32s var(--ease-out); }

@keyframes slide-in-right { from { transform: translateX(48px); opacity: 0; } }
@keyframes slide-in-left { from { transform: translateX(-48px); opacity: 0; } }
@keyframes slide-out-left { to { transform: translateX(-48px); opacity: 0; } }
@keyframes slide-out-right { to { transform: translateX(48px); opacity: 0; } }
@keyframes pop-in { from { transform: scale(.85); opacity: 0; } }
@keyframes leave { to { transform: scale(.85); opacity: 0; } }
@keyframes bump { 40% { transform: scale(1.25); } }
@keyframes drop-in { from { transform: translateY(-100%); } }
@keyframes toast-in { from { transform: translateY(24px) scale(.9); opacity: 0; } }
@keyframes toast-out { to { transform: translateY(12px); opacity: 0; } }
@keyframes fade-in { from { opacity: 0; } }
@keyframes fade-out { to { opacity: 0; } }
@keyframes draw { to { stroke-dashoffset: 0; } }
@keyframes shake { 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }
@keyframes pulse-warn { 50% { box-shadow: 0 0 0 6px rgb(255 138 31 / .45); } }
@keyframes flash-new { from { box-shadow: 0 0 0 8px var(--pec); } }

/* two rules: a browser that doesn't know ::view-transition-* would drop the whole list, and with it the first part */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  ::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) { animation-duration: .01ms !important; }
}
