@import url('https://fonts.googleapis.com/css2?family=Figtree:wght@400;500;600;700&family=Fraunces:opsz,wght@9..144,500;9..144,600&display=swap');

:root {
  --bg: #F4EFE6;         /* oat — warm off-white, never pure white */
  --card: #FBF7F0;       /* cream surface, barely lifts off bg */
  --line: #E7DFD2;       /* hairline dividers only */
  --ink: #3B2F2A;        /* espresso text */
  --muted: #7A6E64;      /* labels, secondary text */
  --accent: #C97B5A;     /* terracotta — active states, marks */
  --accent-deep: #A85A3A;/* deeper terracotta — button fills (AA) */
  --sage: #8F9E7E;       /* ready state, money-raised */
  --on-accent: #FBF7F0;  /* cream label on terracotta */

  --shadow: 0 8px 24px rgba(59, 47, 42, 0.06);
  --r-card: 16px;
  --r-input: 12px;
  --r-pill: 999px;
  --tap: 44px;
}

* { box-sizing: border-box; }

/* The hidden attribute must always win, even over display:flex class rules. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Figtree", "Nunito Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 17px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

.wrap {
  max-width: 640px;
  margin: 0 auto;
  padding: 24px 18px 104px;
}
/* Staff console gets more width on tablets to spread the rows out. */
@media (min-width: 700px) {
  .wrap-staff { max-width: 880px; }
}

h1 {
  font-family: "Fraunces", Georgia, serif;
  font-optical-sizing: auto;
  font-size: 1.7rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0 0 0.3em;
}

/* Brand lockup used in place of the text title */
.brand { margin: 0 0 8px; }
.logo { display: block; width: 105px; max-width: 34%; height: auto; margin: 0 auto; }
.logo-sm { width: 66px; }
h2 { font-size: 1.05rem; font-weight: 600; margin: 1.3em 0 0.6em; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.center { text-align: center; }

.card {
  background: var(--card);
  border-radius: var(--r-card);
  padding: 20px;
  margin: 16px 0;
  box-shadow: var(--shadow);
}
/* Collapse the top margin of the first element so cards don't gain a big gap
   above their opening heading/label (very visible in the admin panel). */
.card > :first-child { margin-top: 0; }

/* --- Buttons --- */
button, .btn {
  font: inherit;
  font-weight: 600;
  min-height: var(--tap);
  min-width: var(--tap);
  padding: 12px 20px;
  border-radius: var(--r-pill);
  border: 1px solid transparent;
  background: var(--accent-deep);
  color: var(--on-accent);
  cursor: pointer;
  touch-action: manipulation;
  transition: transform 0.12s ease, background-color 0.2s ease, box-shadow 0.2s ease;
}
button:hover, .btn:hover { box-shadow: var(--shadow); }
button:active, .btn:active { transform: translateY(1px) scale(0.995); }
button:disabled { opacity: 0.4; cursor: not-allowed; box-shadow: none; }
button.secondary { background: transparent; color: var(--accent-deep); border-color: var(--line); }
button.danger { background: transparent; color: var(--accent-deep); border-color: var(--line); }
button.ghost { background: transparent; border-color: var(--line); color: var(--ink); }

/* --- Drink tiles + steppers --- */
.tile {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 18px;
  border-radius: var(--r-card);
  margin: 12px 0;
  background: var(--card);
  box-shadow: var(--shadow);
  transition: box-shadow 0.25s ease, transform 0.25s ease;
}
.tile.active { box-shadow: 0 0 0 2px var(--accent), var(--shadow); }
.tile.active .count { color: var(--accent-deep); }
.tile-info { min-width: 0; }
.tile .name { font-weight: 600; font-size: 0.95rem; white-space: nowrap; }
.tile .sub { color: var(--muted); font-size: 0.9rem; margin-top: 2px; }
.tile .avail { min-height: 1.05em; margin-top: 4px; color: var(--muted); }
.tile.soldout .name, .tile.soldout .sub { opacity: 0.45; }
.tile.soldout .avail { color: var(--accent-deep); font-weight: 600; }

.stepper { display: flex; align-items: center; gap: 8px; flex: none; }
.stepper button {
  width: var(--tap);
  height: var(--tap);
  padding: 0;
  border-radius: var(--r-pill);
  font-size: 1.4rem;
  line-height: 1;
}
.stepper .count {
  min-width: 2ch;
  text-align: center;
  font-variant-numeric: tabular-nums;
  font-size: 1.25rem;
  font-weight: 600;
}

/* --- Forms --- */
label { display: block; font-weight: 600; margin: 14px 0 5px; }
input[type="text"], input[type="number"], input[type="password"], input[type="search"] {
  width: 100%;
  min-height: var(--tap);
  padding: 12px 14px;
  font: inherit;
  border: 1px solid var(--line);
  border-radius: var(--r-input);
  background: #fff;
  color: var(--ink);
}
input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(201, 123, 90, 0.18);
}
input[type="search"] { margin: 4px 0 14px; }

/* Donation input with a leading $ sign inside the field */
.amount-input { position: relative; }
.amount-input .amount-prefix {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--ink);
  font-weight: 600;
  pointer-events: none;
}
.amount-input input[type="number"] { padding-left: 28px; }

/* --- Resume-order banner --- */
.resume {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.resume .btn { flex: none; text-decoration: none; }

/* Order fields locked while an existing order is still open */
.blocked { opacity: 0.5; pointer-events: none; }

/* --- Selected drinks + inline errors --- */
.sel-row { padding: 9px 0; font-weight: 600; }
.sel-row + .sel-row { border-top: 1px solid var(--line); }
.suggested-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}
.suggested-row strong { color: var(--accent-deep); font-weight: 600; }
.field-error { color: var(--accent-deep); font-weight: 600; font-size: 0.9rem; margin: 8px 0 2px; }

/* Donation quick-fill buttons */
.donate-note { margin-bottom: 8px; }
.quickfill { display: flex; gap: 10px; margin: 12px 0 8px; }
.quickfill button { border-color: #8A6A4F; }  /* coffee-brown outline, reads brown not black */
#qf-roll { flex: 2; }   /* decide for me: 2/3 */
#qf-base { flex: 1; }   /* base: 1/3 */

/* "Decide for me" roll popup */
.roll-modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(59, 47, 42, 0.5);
}
.roll-card {
  position: relative;
  width: 100%;
  max-width: 300px;
  background: var(--card);
  border-radius: var(--r-card);
  padding: 30px 26px;
  text-align: center;
  box-shadow: var(--shadow);
  overflow: visible;
  animation: popIn 0.25s ease-out;
}
.roll-title { color: var(--muted); margin: 0 0 12px; }
.roll-amount {
  font-family: "Fraunces", Georgia, serif;
  font-size: 3.4rem;
  font-weight: 600;
  line-height: 1;
  color: var(--accent-deep);
  font-variant-numeric: tabular-nums;
}
@keyframes popIn {
  from { transform: scale(0.85); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}

/* Sticky bottom action bar */
.bar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  background: rgba(244, 239, 230, 0.92);
  border-top: 1px solid var(--line);
  padding: 14px 18px;
  backdrop-filter: blur(10px);
}
.bar .wrap { padding: 0; }
.bar button { width: 100%; }
.bar-actions { display: flex; gap: 10px; }
.bar-actions button { flex: 1; }

/* --- Review step --- */
.review-total {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  font-size: 1.05rem;
}
.review-total strong {
  font-family: "Fraunces", Georgia, serif;
  color: var(--accent-deep);
  font-size: 1.5rem;
}
.btn.block { display: block; width: 100%; text-align: center; text-decoration: none; }
#reorder { margin-top: 16px; }

/* --- Status page: paper receipt --- */
.receipt {
  position: relative;
  max-width: 420px;
  margin: 6px auto 0;
  background: var(--card);
  padding: 20px 24px 28px;   /* top: -25% above logo */
  box-shadow: var(--shadow);
}
/* Space below the logo (the divider right after it) — ~10% tighter */
.receipt .brand + .rule { margin-top: 16px; }
/* Torn zigzag edges drawn as crisp SVG triangles (fill = --card #FBF7F0).
   Overlaps the body by 1px so there is no seam between teeth and card. */
.receipt::before,
.receipt::after {
  content: "";
  position: absolute;
  left: 0; right: 0;
  height: 8px;
  background-repeat: repeat-x;
  background-size: 12px 8px;
}
.receipt::before {
  top: -7px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpolygon points='0,8 12,8 6,0' fill='%23FBF7F0'/%3E%3C/svg%3E");
}
.receipt::after {
  bottom: -7px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpolygon points='0,0 12,0 6,8' fill='%23FBF7F0'/%3E%3C/svg%3E");
}
.receipt h1 { margin: 0; }
.receipt .label { color: var(--muted); font-size: 0.9rem; margin: 0 0 6px; }
.receipt .item-row { border-bottom-style: dotted; }
.receipt .banner { box-shadow: none; }
.receipt-foot { margin: 0; }

.rule {
  border: none;
  border-top: 1.5px dashed var(--line);
  margin: 18px 0;
}

.pay-steps {
  text-align: left;
  margin: 14px 0 8px;
  padding-left: 1.4em;
}
.pay-steps li { margin: 9px 0; padding-left: 2px; }
.pay-steps li::marker { color: var(--accent-deep); font-weight: 700; }

.queue-num {
  font-family: "Fraunces", Georgia, serif;
  font-optical-sizing: auto;
  font-size: 4.4rem;
  font-weight: 600;
  line-height: 1;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}

/* --- Ready celebration --- */
.celebrate { position: relative; margin: 16px 0 8px; overflow: visible; }
.cup {
  position: relative;
  display: inline-block;
  font-size: 4.5rem;
  line-height: 1;
  animation: cupBob 2.6s ease-in-out infinite;
}
.celebrate.go .cup { animation: cupPop 0.5s ease-out, cupBob 2.6s ease-in-out 0.5s infinite; }
.steam {
  position: absolute;
  top: -6px;
  width: 5px; height: 16px;
  border-radius: 999px;
  background: rgba(122, 110, 100, 0.28);
  opacity: 0;
  animation: steamRise 2.4s ease-in-out infinite;
}
.steam.s1 { left: 34%; animation-delay: 0s; }
.steam.s2 { left: 50%; animation-delay: 0.5s; }
.steam.s3 { left: 64%; animation-delay: 1s; }

.confetti { position: absolute; inset: 0; pointer-events: none; }
.confetti span {
  position: absolute;
  top: 6px;
  width: 8px; height: 8px;
  border-radius: 2px;
  opacity: 0;
}
.celebrate.go .confetti span,
.roll-card.go .confetti span { animation: confettiFall 2.4s ease-out forwards; }
.confetti span:nth-child(1) { left: 12%; background: var(--accent); animation-delay: 0s; }
.confetti span:nth-child(2) { left: 24%; background: var(--sage); animation-delay: 0.12s; }
.confetti span:nth-child(3) { left: 36%; background: var(--accent-deep); animation-delay: 0.05s; }
.confetti span:nth-child(4) { left: 46%; background: var(--sage); animation-delay: 0.2s; }
.confetti span:nth-child(5) { left: 56%; background: var(--accent); animation-delay: 0.08s; }
.confetti span:nth-child(6) { left: 66%; background: var(--accent-deep); animation-delay: 0.16s; }
.confetti span:nth-child(7) { left: 78%; background: var(--sage); animation-delay: 0.02s; }
.confetti span:nth-child(8) { left: 88%; background: var(--accent); animation-delay: 0.24s; }
.confetti span:nth-child(9) { left: 18%; background: var(--accent-deep); animation-delay: 0.3s; }

@keyframes cupBob { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
@keyframes cupPop {
  0% { transform: scale(0.5); opacity: 0; }
  60% { transform: scale(1.15); opacity: 1; }
  100% { transform: scale(1); }
}
@keyframes steamRise {
  0% { opacity: 0; transform: translateY(0) scaleX(1); }
  30% { opacity: 1; }
  100% { opacity: 0; transform: translateY(-22px) scaleX(1.6); }
}
@keyframes confettiFall {
  0% { opacity: 0; transform: translateY(-8px) rotate(0deg); }
  15% { opacity: 1; }
  100% { opacity: 0; transform: translateY(120px) rotate(360deg); }
}
@media (prefers-reduced-motion: reduce) {
  .cup, .steam, .confetti span, .banner.just-ready { animation: none; }
}

.banner {
  border-radius: var(--r-card);
  padding: 18px;
  text-align: center;
  font-size: 1.25rem;
  font-weight: 600;
  margin: 16px 0 4px;
  background: var(--card);
  box-shadow: var(--shadow);
  transition: background-color 0.3s ease, color 0.3s ease;
}
.banner.awaiting { background: #F6EADD; color: var(--accent-deep); }
.banner.queue    { background: #F0E8DA; color: var(--ink); }
.banner.making   { background: #F3DDD0; color: var(--accent-deep); }
.banner.ready    { background: #E4EBDC; color: #4F5D40; }
.banner.just-ready { animation: softIn 0.35s ease-out; }
.banner-sub { text-align: center; color: var(--muted); margin: 8px 0 14px; }

@keyframes softIn {
  from { opacity: 0.35; transform: translateY(4px); }
  to   { opacity: 1; transform: none; }
}

.qr { display: block; width: 220px; max-width: 70%; height: auto; margin: 10px auto; border-radius: var(--r-input); }

.item-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}
.item-row:last-child { border-bottom: none; }
.pill {
  font-size: 0.78rem;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: var(--r-pill);
  white-space: nowrap;
}
.pill.queued    { background: #EFE7DB; color: var(--muted); }
.pill.started   { background: #F3DDD0; color: var(--accent-deep); }
.pill.completed { background: #E4EBDC; color: #4F5D40; }
.pill.cancelled { background: #ECE6DC; color: var(--muted); }

/* ======================================================================
 * Staff console — same skin, tighter and snappier
 * ==================================================================== */
.rolebar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  padding: 10px;
  background: var(--card);
  border-radius: var(--r-card);
  margin: 16px 0;
  box-shadow: var(--shadow);
}
.rolebar .seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg button { background: transparent; color: var(--ink); border-color: var(--line); padding: 10px 16px; }
.seg button.active { background: var(--accent-deep); color: var(--on-accent); border-color: transparent; }

/* Even spacing between the switcher, search, and orders list */
#cash-search { margin: 0 0 16px; }

/* Denser cards in the console than in the customer flow */
.order-card, .station-item { padding: 12px 16px; margin: 8px 0; }
.order-card .qn, .station-item .qn {
  flex: none;
  font-family: "Fraunces", Georgia, serif;
  font-size: 1.3rem;
  font-weight: 600;
  color: var(--accent-deep);
}
.amount-row { display: flex; align-items: center; gap: 8px; margin-top: 10px; }
.amount-row input { max-width: 140px; }

/* Cashier order rows — compact, one line on tablet width */
.order-card {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 12px;
}
.order-card .ord-main {
  flex: 1 1 200px;
  min-width: 0;
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.order-card .ord-name { flex: none; }
.order-card .ord-items {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.order-card .ord-pay { flex: none; margin-left: auto; display: flex; align-items: center; gap: 8px; }
.order-card .ord-amt { flex: none; margin-left: auto; font-weight: 600; font-variant-numeric: tabular-nums; }
.order-card [data-act="pay"] { padding: 10px 16px; }
.amount-field { display: inline-flex; align-items: center; gap: 3px; font-weight: 600; }
.amount-field input { width: 88px; min-height: 40px; padding: 8px 10px; text-align: right; }
.icon-x {
  flex: none;
  width: 40px; min-width: 40px; height: 40px;
  padding: 0;
  border-radius: 50%;
  font-size: 1rem; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center;
}

/* Station (lane) rows — drink + who, laid out wide on tablet */
.station-list { display: grid; gap: 10px; }
.station-item { display: flex; align-items: center; gap: 8px 12px; flex-wrap: wrap; margin: 0; }
.station-item .st-main { flex: 1 1 160px; min-width: 0; display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.station-item .drink { font-weight: 600; }
.station-item .st-who { font-size: 0.9rem; }
.station-item .pill { margin-left: auto; }
.station-item > button { flex: none; }
@media (min-width: 700px) {
  .station-list { grid-template-columns: 1fr 1fr; }
  /* Keep every card a single stable line; long names ellipsis, never wrap. */
  .station-item { flex-wrap: nowrap; }
  .station-item .st-main { flex: 1 1 auto; flex-wrap: nowrap; overflow: hidden; }
  .station-item .drink { white-space: nowrap; }
  .station-item .st-who { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .station-item .pill, .station-item > button { flex: none; }
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%);
  background: var(--accent-deep);
  color: var(--on-accent);
  padding: 12px 18px;
  border-radius: var(--r-pill);
  opacity: 0;
  transition: opacity 0.2s;
  pointer-events: none;
  z-index: 50;
  max-width: 90%;
  text-align: center;
  box-shadow: var(--shadow);
}
.toast.show { opacity: 1; }

/* --- Admin --- */
.admin-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin: 0;
  padding: 11px 0;
  border-bottom: 1px solid var(--line);
  font-weight: 600;
}
.admin-row:last-child { border-bottom: none; }
.admin-row input[type="checkbox"] { width: 24px; height: 24px; accent-color: var(--accent-deep); }
/* Each tea = one group: name + cap read together, divider only between teas. */
.admin-tea { padding: 14px 0; }
.admin-tea:first-of-type { padding-top: 2px; }
.admin-tea:last-of-type { padding-bottom: 0; }
.admin-tea + .admin-tea { border-top: 1px solid var(--line); }
.admin-tea .admin-row { border-bottom: none; padding-bottom: 2px; }
#admin-save, #shop-toggle { width: 100%; }
#admin-save { margin: 6px 0 10px; }

.empty { text-align: center; color: var(--muted); padding: 28px 0; }
.err { color: var(--accent-deep); font-weight: 600; }

/* ======================================================================
 * Leaderboard — desktop display screen
 * ==================================================================== */
.lb-wrap { max-width: 860px; margin: 0 auto; padding: 40px 28px 64px; }
.lb-head { text-align: center; }
.lb-head .logo { width: 150px; max-width: 44%; margin-bottom: 6px; }
.lb-title {
  font-family: "Fraunces", Georgia, serif;
  font-size: 2.1rem;
  font-weight: 600;
  text-align: center;
  margin: 6px 0 24px;
}

.lb-total {
  background: var(--sage);
  color: #2B3420;
  border-radius: var(--r-card);
  padding: 30px 24px;
  text-align: center;
  box-shadow: var(--shadow);
  margin-bottom: 26px;
}
.lb-total-num {
  font-family: "Fraunces", Georgia, serif;
  font-size: 4.4rem;
  font-weight: 600;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.lb-total-label { margin-top: 10px; font-size: 1.15rem; }

.lb-list { list-style: none; margin: 0; padding: 0; }
.lb-row {
  display: flex;
  align-items: center;
  gap: 18px;
  background: var(--card);
  border-radius: var(--r-card);
  padding: 16px 22px;
  margin: 10px 0;
  box-shadow: var(--shadow);
}
.lb-rank {
  font-family: "Fraunces", Georgia, serif;
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--muted);
  min-width: 2.4ch;
  text-align: center;
}
.lb-name {
  flex: 1;
  font-size: 1.3rem;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.lb-amount {
  font-family: "Fraunces", Georgia, serif;
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--accent-deep);
  font-variant-numeric: tabular-nums;
}
/* Top three get a little more presence */
.lb-row.top1, .lb-row.top2, .lb-row.top3 { padding: 20px 22px; }
.lb-row.top1 { box-shadow: 0 0 0 2px var(--accent), var(--shadow); }
.lb-row.top1 .lb-name, .lb-row.top1 .lb-amount { font-size: 1.55rem; }
.lb-row.top1 .lb-rank, .lb-row.top2 .lb-rank, .lb-row.top3 .lb-rank { font-size: 1.9rem; }

@media (max-width: 520px) {
  .lb-total-num { font-size: 3.2rem; }
  .lb-name { font-size: 1.1rem; }
  .lb-amount { font-size: 1.25rem; }
}
