/* ==========================================================================
   BALACCA TEOCHEW PORRIDGE — shared design tokens and components
   Palette is taken from the shop logo: warm bamboo cream + brush-stroke pink.
   ========================================================================== */

:root {
  /* Brand */
  --pink:        #d92b62;
  --pink-deep:   #a91847;
  --pink-soft:   #fce8ef;
  --pink-line:   #f3bfd1;

  --cream:       #f7edd9;
  --cream-deep:  #ecd8ae;
  --cream-soft:  #fdf8ee;

  /* Neutrals */
  --paper:       #fffdf8;
  --ink:         #2b2118;
  --ink-soft:    #6b5a48;
  --ink-faint:   #9d8b76;
  --line:        #e8dcc6;
  --line-strong: #d8c8ab;

  /* Status */
  --green:       #1a7f4b;
  --green-soft:  #e3f5ea;
  --amber:       #b26a00;
  --amber-soft:  #fdf0da;
  --blue:        #1a5f9e;
  --blue-soft:   #e6f0fa;
  --red:         #b3261e;
  --red-soft:    #fdeae8;

  /* Shape & depth */
  --r-sm: 8px;
  --r-md: 14px;
  --r-lg: 20px;
  --r-xl: 28px;
  --shadow-sm: 0 1px 2px rgba(43, 33, 24, .08), 0 1px 3px rgba(43, 33, 24, .06);
  --shadow-md: 0 2px 6px rgba(43, 33, 24, .08), 0 8px 20px rgba(43, 33, 24, .09);
  --shadow-lg: 0 8px 24px rgba(43, 33, 24, .12), 0 24px 60px rgba(43, 33, 24, .16);

  --font: "Segoe UI", "Noto Sans", "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  --font-zh: "Noto Serif SC", "PingFang SC", "Microsoft YaHei", "SimSun", serif;
  --font-num: "SF Mono", "Cascadia Mono", "Consolas", ui-monospace, monospace;

  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

/* The browser's own [hidden] rule loses to any author rule that sets
   display, so `element.hidden = true` silently stops working on anything
   styled as flex or grid. Restate it here, where it wins. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--cream-soft);
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

/* Stop iOS Safari zooming in when a field is focused. */
input, select, textarea, button { font-family: inherit; font-size: 16px; }

h1, h2, h3, h4 { margin: 0; font-weight: 700; letter-spacing: -.01em; }

.zh { font-family: var(--font-zh); }

/* Numbers that sit in columns must not jiggle as they change. */
.num { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }

/* --------------------------------------------------------------- buttons -- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 10px 18px;
  border: 1px solid transparent;
  border-radius: var(--r-md);
  background: var(--paper);
  color: var(--ink);
  font-size: 15px;
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
  transition: transform .08s ease, box-shadow .15s ease, background .15s ease;
  user-select: none;
}
.btn:hover:not(:disabled) { box-shadow: var(--shadow-sm); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn:focus-visible { outline: 3px solid var(--pink); outline-offset: 2px; }

.btn-primary { background: var(--pink); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--pink-deep); }

.btn-ghost { background: transparent; border-color: var(--line-strong); color: var(--ink-soft); }
.btn-ghost:hover:not(:disabled) { background: var(--paper); color: var(--ink); }

.btn-outline { background: var(--paper); border-color: var(--line-strong); }

.btn-success { background: var(--green); color: #fff; }
.btn-danger  { background: var(--red); color: #fff; }
.btn-danger-ghost { background: var(--red-soft); color: var(--red); border-color: #f0c9c5; }

.btn-lg { min-height: 56px; padding: 14px 26px; font-size: 17px; border-radius: var(--r-lg); }
.btn-sm { min-height: 34px; padding: 6px 12px; font-size: 13px; border-radius: var(--r-sm); }
.btn-block { width: 100%; }

/* ---------------------------------------------------------------- pieces -- */

.card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .02em;
  white-space: nowrap;
}
.pill-new      { background: var(--pink-soft); color: var(--pink-deep); }
.pill-preparing{ background: var(--amber-soft); color: var(--amber); }
.pill-served   { background: var(--blue-soft); color: var(--blue); }
.pill-paid     { background: var(--green-soft); color: var(--green); }
.pill-cancelled{ background: #efeae2; color: var(--ink-faint); }
.pill-hot      { background: var(--pink); color: #fff; }

.field { display: block; margin-bottom: 14px; }
.field > .label {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-soft);
  letter-spacing: .02em;
}
.input {
  width: 100%;
  min-height: 46px;
  padding: 11px 14px;
  border: 1.5px solid var(--line-strong);
  border-radius: var(--r-md);
  background: var(--paper);
  color: var(--ink);
}
.input:focus { outline: none; border-color: var(--pink); box-shadow: 0 0 0 3px var(--pink-soft); }
.input.is-error { border-color: var(--red); }

/* Dish photo, and the graceful stand-in when a photo file is missing. */
.photo-wrap { position: relative; overflow: hidden; background: var(--cream); }
.photo-wrap img { width: 100%; height: 100%; object-fit: cover; display: block; }

.photo-fallback {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 8px;
  background:
    repeating-linear-gradient(100deg,
      var(--cream) 0 22px, var(--cream-deep) 22px 44px);
  text-align: center;
}
.photo-fallback span {
  font-family: var(--font-zh);
  font-size: clamp(18px, 8vw, 34px);
  font-weight: 700;
  color: var(--pink);
  text-shadow: 0 1px 0 #fff, 0 2px 6px rgba(255,255,255,.9);
  line-height: 1.15;
}

.spinner {
  width: 20px; height: 20px;
  border: 2.5px solid var(--pink-line);
  border-top-color: var(--pink);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.empty {
  padding: 48px 24px;
  text-align: center;
  color: var(--ink-faint);
}
.empty .big { font-size: 40px; margin-bottom: 10px; }

/* ---------------------------------------------------------------- toasts -- */

#toasts {
  position: fixed;
  left: 50%;
  bottom: calc(24px + var(--safe-b));
  transform: translateX(-50%);
  z-index: 9000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  pointer-events: none;
  width: min(440px, calc(100vw - 32px));
}
.toast {
  padding: 12px 18px;
  border-radius: var(--r-md);
  background: var(--ink);
  color: #fff;
  font-size: 14.5px;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  animation: toast-in .22s ease;
  text-align: center;
}
.toast.ok  { background: var(--green); }
.toast.err { background: var(--red); }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } }

/* ---------------------------------------------------------------- modals -- */

.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 8000;
  background: rgba(43, 33, 24, .5);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: fade-in .18s ease;
}
@media (min-width: 720px) { .sheet-backdrop { align-items: center; } }
@keyframes fade-in { from { opacity: 0; } }

.sheet {
  width: 100%;
  max-width: 560px;
  max-height: 92vh;
  overflow-y: auto;
  background: var(--paper);
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  box-shadow: var(--shadow-lg);
  animation: sheet-up .24s cubic-bezier(.2, .8, .3, 1);
  padding-bottom: var(--safe-b);
}
@media (min-width: 720px) {
  .sheet { border-radius: var(--r-xl); max-height: 88vh; }
}
@keyframes sheet-up { from { transform: translateY(24px); opacity: .6; } }

.sheet-head {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 20px 14px;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}
.sheet-head h2 { font-size: 19px; }
.sheet-body { padding: 20px; }
.sheet-foot {
  position: sticky;
  bottom: 0;
  display: flex;
  gap: 10px;
  padding: 14px 20px;
  background: var(--paper);
  border-top: 1px solid var(--line);
}
.sheet-foot .btn { flex: 1; }

.x-btn {
  width: 36px; height: 36px;
  display: grid; place-items: center;
  border: none;
  border-radius: 50%;
  background: #f0e9dc;
  color: var(--ink-soft);
  font-size: 20px;
  cursor: pointer;
  flex: none;
}
.x-btn:hover { background: var(--line); color: var(--ink); }

/* ------------------------------------------------------------ utilities -- */

.row { display: flex; align-items: center; gap: 10px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--ink-soft); }
.faint { color: var(--ink-faint); }
.tiny { font-size: 12px; }
.small { font-size: 13px; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.center { text-align: center; }
.right { text-align: right; }
.hidden { display: none !important; }
.strike { text-decoration: line-through; }

.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
  }
}
