/* The tip page: a café counter with a POS tablet on a stand. The POS UI scales with the screen via container units. */
:root {
  --wall: #1d1813;
  --wall-2: #2a221a;
  --wood-top: #9a6a43;
  --wood: #6e4a2d;
  --wood-dark: #3f2918;
  --bezel: #121214;
  --accent: #ffd23f;
  --pos-bg: #ffffff;
  --pos-ink: #121212;
  --pos-muted: #6d6d6d;
  --pos-line: #e3e3e3;
  --pos-btn: #f5f5f4;
  --pos-hover: #ececea;
  --good: #1f9d55;
  --bad: #d93a2b;
  --display: "Bricolage Grotesque", ui-sans-serif, system-ui, sans-serif;
  --ui: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, Consolas, monospace;
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; display: flex; flex-direction: column; min-height: 100svh;
  background: radial-gradient(ellipse 60% 70% at 50% 58%, var(--wall-2), var(--wall) 70%);
  color: #f4efe4; font: 400 16px/1.5 var(--display); -webkit-font-smoothing: antialiased;
  overflow-x: hidden; -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; cursor: pointer; }
svg { display: block; }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
:focus-visible { outline: 3px solid #2f7cf6; outline-offset: 2px; }

.backlink {
  position: absolute; top: 18px; left: 20px; z-index: 5; display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px 8px 8px; border-radius: 12px; color: #f4efe4; text-decoration: none; font-weight: 700;
  background: rgba(255, 255, 255, 0.06); border: 1px solid rgba(255, 255, 255, 0.1);
}
.backlink:hover { background: rgba(255, 255, 255, 0.12); }
.backlink svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- counter, device, stand ---------- */
.counter {
  --dw: min(920px, 92vw, calc((100svh - 230px) * 4 / 3));
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end;
  padding-top: 72px; position: relative;
}
.device {
  position: relative; z-index: 2; width: var(--dw); padding: calc(var(--dw) * 0.022);
  border-radius: calc(var(--dw) * 0.048);
  background: linear-gradient(160deg, #2a2a2e, var(--bezel) 30%, #0b0b0c);
  box-shadow: 0 0 0 1px #000, inset 0 1px 0 rgba(255, 255, 255, 0.12), 0 40px 80px -30px rgba(0, 0, 0, 0.8), 0 12px 24px -12px rgba(0, 0, 0, 0.6);
}
.screen {
  position: relative; aspect-ratio: 4 / 3; overflow: hidden; isolation: isolate;
  border-radius: calc(var(--dw) * 0.022); background: var(--pos-bg); color: var(--pos-ink);
  font-family: var(--ui); container-type: size;
}
.stand { position: relative; z-index: 1; display: flex; flex-direction: column; align-items: center; margin-top: -14px; }
.neck { width: calc(var(--dw) * 0.13); height: 70px; background: linear-gradient(90deg, #b9b9bd, #ececef 45%, #c7c7cb 70%, #9d9da2); border-radius: 0 0 6px 6px; }
.base { width: calc(var(--dw) * 0.36); height: 16px; margin-top: -2px; border-radius: 50% / 100% 100% 30% 30%; background: linear-gradient(#f2f2f4, #b5b5ba); box-shadow: 0 10px 18px -6px rgba(0, 0, 0, 0.6); }
.front {
  position: relative; min-height: clamp(64px, 12svh, 130px); padding: 22px 16px 18px; text-align: center;
  background: linear-gradient(var(--wood-top), var(--wood) 14px, var(--wood-dark));
  box-shadow: inset 0 3px 0 rgba(255, 255, 255, 0.12);
}
.front::before { content: ""; position: absolute; inset: 14px 0 auto; height: 1px; background: rgba(0, 0, 0, 0.35); }
.front p { margin: 0; color: rgba(255, 244, 228, 0.72); font-size: 14px; }

.device.is-hit { animation: hit 0.6s cubic-bezier(.36, .07, .19, .97); }
@keyframes hit {
  10% { transform: translate(-14px, 10px) rotate(-2.2deg); }
  22% { transform: translate(12px, -8px) rotate(1.8deg); }
  36% { transform: translate(-9px, 6px) rotate(-1.2deg); }
  52% { transform: translate(6px, -3px) rotate(0.7deg); }
  70% { transform: translate(-3px, 2px) rotate(-0.3deg); }
  100% { transform: none; }
}

/* ---------- POS UI (sized from the screen, u = one unit) ---------- */
.screen > * { --u: min(1cqh, 1.45cqw); }
.statusbar {
  position: absolute; inset: 0 0 auto; height: calc(var(--u) * 6.4); z-index: 3;
  display: flex; align-items: center; justify-content: space-between; padding: 0 calc(var(--u) * 3);
  font-size: calc(var(--u) * 2.3); font-weight: 600; color: var(--pos-ink); border-bottom: 1px solid var(--pos-line);
  font-variant-numeric: tabular-nums;
}
.sb-brand { display: inline-flex; align-items: center; gap: calc(var(--u) * 1); }
.sb-brand svg { width: calc(var(--u) * 3); height: calc(var(--u) * 3); }
.sb-clock { position: absolute; left: 50%; transform: translateX(-50%); }
.sb-icons { display: inline-flex; align-items: center; gap: calc(var(--u) * 1.2); }
.sb-icons svg { width: calc(var(--u) * 2.8); height: calc(var(--u) * 2.8); fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; }
.sb-icons .fill { fill: currentColor; stroke: none; }
.batt { position: relative; width: calc(var(--u) * 4.2); height: calc(var(--u) * 2.1); border: 1.5px solid currentColor; border-radius: 3px; padding: 1.5px; }
.batt::after { content: ""; position: absolute; right: -4px; top: 30%; width: 2px; height: 40%; background: currentColor; border-radius: 0 1px 1px 0; }
.batt i { display: block; height: 100%; width: 72%; background: currentColor; border-radius: 1px; }

.view {
  position: absolute; inset: calc(var(--u) * 6.4) 0 0; z-index: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: calc(var(--u) * 3) calc(var(--u) * 6) calc(var(--u) * 4); text-align: center;
}
.view[hidden] { display: none; }
.view.is-entering { animation: viewIn 0.32s cubic-bezier(.2, .8, .2, 1); }
@keyframes viewIn { from { opacity: 0; transform: translateY(calc(var(--u) * 2)); } }

.order { margin: 0; font-size: calc(var(--u) * 2.5); color: var(--pos-muted); font-weight: 500; }
.total { margin: calc(var(--u) * 0.4) 0 0; font-size: calc(var(--u) * 8.4); font-weight: 700; letter-spacing: -0.03em; line-height: 1.05; font-variant-numeric: tabular-nums; }
.view h1, .view h2 { margin: calc(var(--u) * 1.4) 0 0; font-size: calc(var(--u) * 5); font-weight: 700; letter-spacing: -0.02em; line-height: 1.1; }
.hint { margin: calc(var(--u) * 0.8) 0 0; font-size: calc(var(--u) * 2.5); color: var(--pos-muted); }

.view-tip { gap: 0; }
.view-tip > .tips, .view-tip > .wide { width: min(100%, calc(var(--u) * 118)); }
.tips { display: grid; grid-template-columns: repeat(3, 1fr); gap: calc(var(--u) * 1.8); margin-top: calc(var(--u) * 3.6); }
.tip, .wide, .keypad button, .ghost {
  border: 2px solid var(--pos-line); background: var(--pos-bg); border-radius: calc(var(--u) * 1.8);
  transition: background 0.12s, border-color 0.12s, transform 0.08s;
  touch-action: manipulation; user-select: none; -webkit-user-select: none;
}
.tip:hover, .wide:hover, .keypad button:hover, .ghost:hover { border-color: var(--pos-ink); }
.tip:active, .wide:active, .keypad button:active, .ghost:active, .primary:active { transform: scale(0.975); background: var(--pos-hover); }
.tip { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: calc(var(--u) * 0.6); height: calc(var(--u) * 17); }
.tip b { font-size: calc(var(--u) * 6); font-weight: 700; letter-spacing: -0.02em; line-height: 1; }
.tip span { font-size: calc(var(--u) * 2.3); color: var(--pos-muted); }
.wide { height: calc(var(--u) * 8.6); margin-top: calc(var(--u) * 1.8); font-size: calc(var(--u) * 2.9); font-weight: 600; }
.is-pressed { background: var(--pos-ink) !important; color: #fff !important; border-color: var(--pos-ink) !important; }
.is-pressed span { color: rgba(255, 255, 255, 0.7) !important; }

.primary {
  font-family: var(--ui);
  display: inline-flex; align-items: center; justify-content: center; min-height: calc(var(--u) * 8.6); padding: 0 calc(var(--u) * 5);
  border: 0; border-radius: calc(var(--u) * 1.8); background: var(--pos-ink); color: #fff; text-decoration: none;
  font-size: calc(var(--u) * 2.9); font-weight: 650; transition: transform 0.08s, opacity 0.2s;
  touch-action: manipulation;
}
.primary:disabled { opacity: 0.25; cursor: default; }
.ghost { min-height: calc(var(--u) * 8.6); padding: 0 calc(var(--u) * 4); font-size: calc(var(--u) * 2.9); font-weight: 600; }
.back {
  position: absolute; top: calc(var(--u) * 2.4); left: calc(var(--u) * 2.6); display: inline-flex; align-items: center; gap: calc(var(--u) * 0.4);
  border: 0; background: none; padding: calc(var(--u) * 1) calc(var(--u) * 1.6) calc(var(--u) * 1) calc(var(--u) * 0.6); border-radius: calc(var(--u) * 1.4);
  font-size: calc(var(--u) * 2.6); font-weight: 600; color: var(--pos-ink);
}
.back:hover { background: var(--pos-btn); }
.back svg, .keypad svg { width: calc(var(--u) * 3.4); height: calc(var(--u) * 3.4); fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }

/* custom */
.view-custom { flex-direction: row; gap: calc(var(--u) * 6); }
.custom-left { display: flex; flex-direction: column; align-items: center; min-width: calc(var(--u) * 44); }
.amount { margin: calc(var(--u) * 1) 0 0; font-size: calc(var(--u) * 10); font-weight: 700; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; line-height: 1.05; }
.amount.is-zero { color: #c4c4c4; }
.custom-left .primary { margin-top: calc(var(--u) * 3.4); width: 100%; }
.keypad { display: grid; grid-template-columns: repeat(3, calc(var(--u) * 15)); grid-auto-rows: calc(var(--u) * 12); gap: calc(var(--u) * 1.4); }
.keypad button { font-size: calc(var(--u) * 4.2); font-weight: 600; display: grid; place-items: center; font-variant-numeric: tabular-nums; }
.view-custom .custom-left { justify-content: center; }
@container (aspect-ratio < 1) {
  .view-custom { flex-direction: column; gap: calc(var(--u) * 3); }
  .custom-left { min-width: 0; width: 100%; }
  .keypad { grid-template-columns: repeat(3, 1fr); width: 100%; grid-auto-rows: calc(var(--u) * 10); }
}

/* pay */
.tap { width: calc(var(--u) * 11); height: calc(var(--u) * 11); color: var(--pos-ink); margin-bottom: calc(var(--u) * 1.4); }
.tap svg { width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 4.5; stroke-linecap: round; }
.tap path { animation: wave 1.6s ease-in-out infinite; }
.tap .w2 { animation-delay: 0.18s; } .tap .w3 { animation-delay: 0.36s; }
@keyframes wave { 0%, 100% { opacity: 0.18; } 40% { opacity: 1; } }
.view-pay .primary { margin-top: calc(var(--u) * 3.4); min-width: min(100%, calc(var(--u) * 60)); }
.fine { margin: calc(var(--u) * 2) 0 0; font-size: calc(var(--u) * 2.1); color: var(--pos-muted); max-width: calc(var(--u) * 70); }

/* thanks + receipt */
.view-thanks { flex-direction: row; gap: calc(var(--u) * 7); }
.thanks-copy { display: flex; flex-direction: column; align-items: center; max-width: calc(var(--u) * 60); }
.check { width: calc(var(--u) * 13); height: calc(var(--u) * 13); fill: none; stroke: var(--good); stroke-width: 3.4; stroke-linecap: round; stroke-linejoin: round; }
.check circle { stroke-dasharray: 151; stroke-dashoffset: 151; animation: draw 0.6s 0.1s ease-out forwards; }
.check path { stroke-dasharray: 36; stroke-dashoffset: 36; animation: draw 0.35s 0.6s ease-out forwards; }
@keyframes draw { to { stroke-dashoffset: 0; } }
.thanks-actions, .declined-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: calc(var(--u) * 1.6); margin-top: calc(var(--u) * 3.4); }
.printer { position: relative; width: calc(var(--u) * 40); align-self: stretch; display: flex; flex-direction: column; align-items: center; }
.printer-slot { width: 100%; height: calc(var(--u) * 3); border-radius: calc(var(--u) * 1.5); background: linear-gradient(#2c2c2e, #0f0f10); box-shadow: inset 0 -2px 0 rgba(255, 255, 255, 0.08); position: relative; z-index: 2; }
.paper-wrap { width: 88%; overflow: hidden; margin-top: calc(var(--u) * -1.4); flex: 1; min-height: 0; }
.paper {
  --edge: calc(var(--u) * 1.4);
  padding: calc(var(--u) * 4) calc(var(--u) * 3) calc(var(--u) * 4); background: #fbfaf6; color: #222;
  font: 500 calc(var(--u) * 1.95)/1.55 var(--mono); text-align: left; text-transform: uppercase;
  box-shadow: 0 6px 16px -8px rgba(0, 0, 0, 0.35);
  -webkit-mask: conic-gradient(from -45deg at bottom, #0000, #000 1deg 89deg, #0000 90deg) 50% / var(--edge) 100%;
          mask: conic-gradient(from -45deg at bottom, #0000, #000 1deg 89deg, #0000 90deg) 50% / var(--edge) 100%;
  transform: translateY(-100%);
}
.paper.is-printing { animation: print 2.2s steps(14, end) 0.5s forwards; }
@keyframes print { to { transform: translateY(0); } }
.paper .r-center { text-align: center; }
.paper .r-big { font-weight: 700; font-size: 1.25em; letter-spacing: 0.04em; }
.paper .r-row { display: flex; justify-content: space-between; gap: 1em; }
.paper .r-rule { border-top: 1.5px dashed #999; margin: 0.7em 0; }
.paper .r-bars { height: 3.2em; margin-top: 0.9em; background: repeating-linear-gradient(90deg, #222 0 2px, transparent 2px 4px, #222 4px 5px, transparent 5px 8px, #222 8px 11px, transparent 11px 12px); }
@container (aspect-ratio < 1) {
  .view-thanks { flex-direction: column; gap: calc(var(--u) * 3); justify-content: flex-start; padding-top: calc(var(--u) * 6); }
  .printer { width: min(100%, calc(var(--u) * 56)); flex: 1; }
}

/* declined */
.bandage { width: calc(var(--u) * 14); height: calc(var(--u) * 14); }
.bandage rect { fill: #efc49b; }
.bandage rect.pad { fill: #f8e2c8; }
.bandage circle { fill: #d9a577; }
.view-declined .hint { max-width: calc(var(--u) * 72); }

/* ---------- the camera ---------- */
.view-cam { inset: 0; padding: 0; background: #000; z-index: 4; }
.view-cam video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.cam-ui { position: absolute; inset: 0; color: #fff; font-family: var(--ui); pointer-events: none; }
.cam-top {
  position: absolute; inset: 0 0 auto; height: calc(var(--u) * 9); display: flex; align-items: center; justify-content: space-between;
  padding: 0 calc(var(--u) * 3.4); background: linear-gradient(rgba(0, 0, 0, 0.55), transparent);
}
.cam-flash svg { width: calc(var(--u) * 3.2); height: calc(var(--u) * 3.2); fill: #ffd23f; }
.cam-rec { display: inline-flex; align-items: center; gap: calc(var(--u) * 0.9); padding: calc(var(--u) * 0.6) calc(var(--u) * 1.4); border-radius: calc(var(--u) * 1); background: var(--bad); font-size: calc(var(--u) * 2.3); font-weight: 600; font-variant-numeric: tabular-nums; }
.cam-rec i { width: calc(var(--u) * 1.1); height: calc(var(--u) * 1.1); border-radius: 50%; background: #fff; animation: blink 1s steps(2, start) infinite; }
@keyframes blink { to { visibility: hidden; } }
.cam-zoom { width: calc(var(--u) * 5); height: calc(var(--u) * 5); display: grid; place-items: center; border-radius: 50%; background: rgba(0, 0, 0, 0.45); font-size: calc(var(--u) * 2); font-weight: 700; color: #ffd23f; }
.cam-toast {
  position: absolute; top: calc(var(--u) * 11); left: 50%; transform: translateX(-50%);
  padding: calc(var(--u) * 1) calc(var(--u) * 2.4); border-radius: 999px; background: rgba(0, 0, 0, 0.6); backdrop-filter: blur(8px);
  font-size: calc(var(--u) * 2.3); font-weight: 600; white-space: nowrap; animation: toast 1.5s ease forwards;
}
@keyframes toast { 0% { opacity: 0; transform: translate(-50%, -8px); } 15%, 75% { opacity: 1; transform: translate(-50%, 0); } 100% { opacity: 0; } }
.cam-focus {
  position: absolute; left: 50%; top: var(--face-y, 40%); width: calc(var(--u) * 30); height: calc(var(--u) * 30); transform: translate(-50%, -50%);
  border: 2px solid #ffd23f; border-radius: 4px; opacity: 0; animation: focus 1.1s 0.25s ease forwards;
}
@keyframes focus { 0% { opacity: 0; transform: translate(-50%, -50%) scale(1.5); } 25% { opacity: 1; transform: translate(-50%, -50%) scale(1); } 45% { opacity: 0.4; } 60% { opacity: 1; } 100% { opacity: 0; } }
.cam-bottom { position: absolute; inset: auto 0 0; padding: calc(var(--u) * 2) calc(var(--u) * 4) calc(var(--u) * 3); background: linear-gradient(transparent, rgba(0, 0, 0, 0.6) 40%); }
.cam-modes { display: flex; justify-content: center; gap: calc(var(--u) * 3.4); font-size: calc(var(--u) * 1.9); font-weight: 600; letter-spacing: 0.08em; color: rgba(255, 255, 255, 0.85); }
.cam-modes .on { color: #ffd23f; }
.cam-row { display: flex; align-items: center; justify-content: space-between; margin: calc(var(--u) * 1.8) auto 0; max-width: calc(var(--u) * 70); }
.cam-thumb { width: calc(var(--u) * 6.4); height: calc(var(--u) * 6.4); border-radius: calc(var(--u) * 1.2); background: linear-gradient(135deg, #6a5b4d, #2d2620); border: 2px solid rgba(255, 255, 255, 0.8); }
.cam-shutter { width: calc(var(--u) * 10); height: calc(var(--u) * 10); border-radius: 50%; border: calc(var(--u) * 0.7) solid #fff; display: grid; place-items: center; }
.cam-shutter i { width: 42%; height: 42%; border-radius: calc(var(--u) * 0.8); background: var(--bad); }
.cam-flip { width: calc(var(--u) * 6.4); height: calc(var(--u) * 6.4); border-radius: 50%; display: grid; place-items: center; background: rgba(255, 255, 255, 0.18); }
.cam-flip svg { width: 55%; height: 55%; fill: none; stroke: #fff; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.view-cam.is-dropped .cam-ui { opacity: 0; transition: opacity 0.15s; }
.static {
  position: absolute; inset: 0; opacity: 0; pointer-events: none; mix-blend-mode: screen;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 1.4 -.2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
.view-cam.is-static .static { opacity: 0.85; animation: static 0.2s steps(4) infinite; }
.view-cam.is-static video { filter: grayscale(1) contrast(1.6) brightness(0.5); }
@keyframes static { 25% { background-position: 40px -30px; } 50% { background-position: -60px 20px; } 75% { background-position: 10px 70px; } }

/* glass + flash, above every view */
.crack { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 20; pointer-events: none; opacity: 0.55; transition: opacity 0.3s; }
.screen.is-cam .crack { opacity: 1; }
.flash { position: absolute; inset: 0; z-index: 21; background: #fff; opacity: 0; pointer-events: none; }
.flash.is-on { animation: flash 0.45s ease-out; }
@keyframes flash { 0% { opacity: 0.95; } 100% { opacity: 0; } }
.screen.is-processing .view-tip { filter: blur(2px); opacity: 0.5; transition: filter 0.2s, opacity 0.2s; }
.spinner { position: absolute; inset: 0; z-index: 5; background: rgba(255, 255, 255, 0.72); display: grid; place-content: center; justify-items: center; gap: calc(var(--u) * 2); font-size: calc(var(--u) * 2.8); font-weight: 600; }
.spinner i { width: calc(var(--u) * 7); height: calc(var(--u) * 7); border-radius: 50%; border: calc(var(--u) * 0.8) solid var(--pos-line); border-top-color: var(--pos-ink); animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- phones: the page becomes the device ---------- */
@media (max-width: 720px), (max-height: 520px) and (max-width: 1000px) {
  body { background: #0e0c0a; }
  .backlink { position: static; align-self: flex-start; margin: calc(env(safe-area-inset-top) + 8px) 0 8px 10px; }
  .counter { padding: 0 8px 8px; justify-content: stretch; align-items: stretch; }
  .device { flex: 1; width: 100%; display: flex; padding: 5px; border-radius: 28px; }
  .screen { flex: 1; aspect-ratio: auto; border-radius: 23px; min-height: 480px; }
  .stand { display: none; }
  .front { min-height: 0; padding: 10px 16px calc(env(safe-area-inset-bottom) + 12px); background: none; box-shadow: none; }
  .front::before { display: none; }
  .front p { font-size: 12.5px; color: rgba(244, 239, 228, 0.55); }
  .screen > * { --u: min(1cqh, 1.75cqw); }
  .view { padding-left: calc(var(--u) * 4); padding-right: calc(var(--u) * 4); }
  .tips { gap: calc(var(--u) * 1.4); }
}

@media (prefers-reduced-motion: reduce) {
  .device.is-hit { animation: none; }
  .paper.is-printing { animation-duration: 0.01s; animation-delay: 0s; }
  .view.is-entering { animation: none; }
}

[tabindex="-1"]:focus { outline: none; }
