/* Saufi kiosk (not kiosk.css: content blockers filter that name).
   System fonts only, so nothing is fetched from outside the station. */

:root {
  --ground: #f3f4f6;
  --surface: #ffffff;
  --ink: #16191d;
  --muted: #5f6873;
  --rule: #dfe3e8;
  --go: #1d7f3a;
  --go-hover: #16692f;
  --stop: #c62a2a;
  --stop-hover: #a51f1f;
  --accent: #4b4bc4;
  --neg: #b3261e;
  --bar-h: 6.5rem;
  --radius: 14px;
}

* { box-sizing: border-box; }
[x-cloak] { display: none !important; }

html, body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 18px;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  overscroll-behavior: none;
}

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
  touch-action: manipulation;
}
button:disabled { cursor: not-allowed; opacity: .45; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.kiosk { min-height: 100vh; padding-bottom: calc(var(--bar-h) + 2rem + env(safe-area-inset-bottom)); }

/* ---------- Step 1: drinks ---------- */

.products {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(210px, 44vw), 1fr));
  gap: 1.1rem;
  padding: 1.25rem;
  max-width: 1400px;
  margin: 0 auto;
  align-items: start;
}

.load-error {
  grid-column: 1 / -1;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  display: flex;
  gap: 1rem;
  align-items: center;
  justify-content: space-between;
}

.tile {
  position: relative;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: 0 1px 2px rgba(22, 25, 29, .06), 0 4px 14px rgba(22, 25, 29, .06);
  overflow: hidden;
  transition: box-shadow .15s ease, transform .15s ease;
}
.tile.picked {
  box-shadow: 0 0 0 4px var(--go), 0 6px 18px rgba(29, 127, 58, .22);
}

.tile-photo {
  display: block;
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  padding: 0;
  border: 0;
  background: #fff;
}
.tile-photo:active { transform: scale(.985); }

.tile-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  pointer-events: none;
}

.tile-fallback {
  position: absolute;
  top: 0; right: 0; bottom: 0; left: 0;
  display: grid;
  place-items: center;
  padding: 1rem;
  font-size: 1.35rem;
  font-weight: 600;
  text-align: center;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.tile-price {
  position: absolute;
  top: .6rem;
  left: .6rem;
  background: rgba(255, 255, 255, .92);
  padding: .2rem .55rem;
  border-radius: 999px;
  font-size: .95rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .12);
}

.tile-qty {
  position: absolute;
  top: .5rem;
  right: .5rem;
  min-width: 2.6rem;
  height: 2.6rem;
  padding: 0 .5rem;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: var(--go);
  color: #fff;
  font-size: 1.4rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* Overlaid on the photo, so picking a drink never changes a tile's height. */
.tile-controls {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  display: grid;
  grid-template-columns: 3.4rem 1fr 3.4rem;
  align-items: center;
  background: rgba(255, 255, 255, .94);
  border-top: 1px solid var(--rule);
}

.tile-name {
  text-align: center;
  font-size: .85rem;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 0 .25rem;
}

.step {
  height: 3.4rem;
  border: 0;
  background: transparent;
  font-size: 2rem;
  line-height: 1;
  color: var(--accent);
}
.step:active { background: var(--ground); }
.step.small {
  width: 2.6rem;
  height: 2.6rem;
  font-size: 1.5rem;
  border-radius: 999px;
  background: var(--ground);
}

/* ---------- Step 2: who is buying ---------- */

.checkout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr);
  gap: 1.5rem;
  padding: 1.25rem;
  max-width: 1400px;
  margin: 0 auto;
  align-items: start;
}
@media (max-width: 760px) {
  .checkout { grid-template-columns: 1fr; }
}

.checkout h1 {
  font-size: 1.35rem;
  margin: 0 0 .9rem;
  font-weight: 650;
}

.cart, .who {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: 0 1px 2px rgba(22, 25, 29, .06), 0 4px 14px rgba(22, 25, 29, .06);
}

.cart table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.cart td, .cart th { padding: .55rem .25rem; border-bottom: 1px solid var(--rule); text-align: left; }
.cart tfoot th { border-bottom: 0; padding-top: .9rem; font-size: 1.05rem; }
.cart-qty { white-space: nowrap; }
.cart-qty span { display: inline-block; min-width: 2rem; text-align: center; font-weight: 600; }
.cart-sum { text-align: right !important; white-space: nowrap; }

.search {
  width: 100%;
  font: inherit;
  padding: .8rem 1rem;
  border: 1px solid var(--rule);
  border-radius: 10px;
  background: var(--ground);
  margin-bottom: .9rem;
  -webkit-user-select: text;
  user-select: text;
}

.people {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: calc(100vh - var(--bar-h) - 14rem);
  min-height: 12rem;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
  gap: .5rem;
}

.people li {
  border: 1px solid var(--rule);
  border-radius: 10px;
  background: var(--surface);
}
.people li.open { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent) inset; }
.people li.none { padding: 1rem; color: var(--muted); border-style: dashed; }

.person {
  display: block;
  width: 100%;
  text-align: left;
  padding: .95rem 1rem;
  border: 0;
  background: transparent;
  font-size: 1.1rem;
  color: var(--accent);
}
.open .person { color: var(--ink); font-weight: 600; }

.unlock form {
  display: flex;
  gap: .6rem;
  padding: 0 1rem 1rem;
}
.unlock input {
  flex: 1;
  min-width: 0;
  font: inherit;
  font-size: 1.4rem;
  letter-spacing: .4em;
  text-align: center;
  padding: .6rem;
  border: 1px solid var(--rule);
  border-radius: 10px;
  -webkit-user-select: text;
  user-select: text;
}
.go {
  border: 0;
  border-radius: 10px;
  padding: 0 1.2rem;
  background: var(--go);
  color: #fff;
  font-weight: 600;
}

.account { padding: 0 1rem 1rem; font-variant-numeric: tabular-nums; }
.account p { margin: .15rem 0; display: flex; justify-content: space-between; gap: 1rem; }
.account .after { color: var(--muted); font-size: .95rem; }
.neg { color: var(--neg); }

/* ---------- Action bar ---------- */

.actions {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  padding: .9rem 1.25rem calc(.9rem + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--ground) 70%, rgba(243, 244, 246, 0));
}
.actions-row {
  display: flex;
  gap: 1rem;
  max-width: 1400px;
  margin: 0 auto;
}

.action {
  flex: 1;
  min-height: var(--bar-h);
  border: 0;
  border-radius: var(--radius);
  font-size: 1.7rem;
  font-weight: 650;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .75rem;
  box-shadow: 0 2px 4px rgba(0, 0, 0, .08), 0 10px 24px rgba(0, 0, 0, .10);
}
.action small { font-size: 1.05rem; font-weight: 500; opacity: .9; font-variant-numeric: tabular-nums; }
.action.hint {
  background: var(--surface);
  color: var(--muted);
  font-size: 1.25rem;
  font-weight: 500;
}
.action.green { background: var(--go); color: #fff; flex: 2; }
.action.green:active:not(:disabled) { background: var(--go-hover); }
.action.red { background: var(--stop); color: #fff; }
.action.red:active { background: var(--stop-hover); }

/* ---------- Feedback ---------- */

.success {
  position: fixed;
  top: 0; right: 0; bottom: 0; left: 0;
  background: rgba(22, 25, 29, .55);
  display: grid;
  place-items: center;
  z-index: 20;
  padding: 1.5rem;
}
.success-card {
  background: var(--surface);
  border-radius: 22px;
  padding: 2.5rem 3rem;
  text-align: center;
  min-width: min(28rem, 100%);
  box-shadow: 0 20px 60px rgba(0, 0, 0, .3);
  font-size: 1.3rem;
  font-variant-numeric: tabular-nums;
}
.success-card p { margin: .4rem 0; }
.success-title { font-size: 2.2rem; font-weight: 700; color: var(--go); }
.tick {
  width: 5.5rem;
  height: 5.5rem;
  margin: 0 auto 1rem;
  border-radius: 50%;
  background: var(--go);
  position: relative;
}
.tick::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 46%;
  width: 1.4rem;
  height: 2.6rem;
  border: solid #fff;
  border-width: 0 .45rem .45rem 0;
  transform: translate(-50%, -50%) rotate(45deg);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--bar-h) + 2.4rem);
  transform: translateX(-50%);
  max-width: min(40rem, calc(100vw - 2rem));
  background: var(--ink);
  color: #fff;
  padding: .9rem 1.3rem;
  border-radius: 12px;
  font-size: 1.05rem;
  z-index: 30;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .25);
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* ---------- Safari 12 ----------
   The kiosk iPad (original iPad Air) stops at iOS 12.5. Its Safari has no
   flex `gap` and no `aspect-ratio`; anything without aspect-ratio gets
   margins and the padding trick instead. */
@supports not (aspect-ratio: 1) {
  .products { grid-gap: 1.1rem; }
  .checkout { grid-gap: 1.5rem; }
  .tile-photo { height: 0; padding-top: 100%; overflow: hidden; }
  .tile-photo img { position: absolute; top: 0; left: 0; }
  .people > li + li { margin-top: .5rem; }
  .load-error > * + *,
  .unlock form > * + * { margin-left: .6rem; }
  .account p > * + * { margin-left: 1rem; }
  .actions-row > * + * { margin-left: 1rem; }
  .action > * + *,
  .action small { margin-left: .75rem; }
}
