/* The iPad: the order view fills the screen; the barista list slides over it from the right. */
body { overflow: hidden; height: 100dvh; display: grid; grid-template-rows: auto minmax(0, 1fr); }

/* ---------- Header ---------- */
.bar {
	display: flex; align-items: center; gap: 16px; position: relative; z-index: 50; background: var(--surface);
	padding: calc(14px + env(safe-area-inset-top)) calc(24px + env(safe-area-inset-right)) 14px calc(24px + env(safe-area-inset-left));
	border-bottom: 1.5px solid var(--line);
}
.bar-tools { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.bar-tools > .btn { min-height: 48px; font-size: 15px; padding: 0 18px; }

.switcher { position: relative; display: grid; grid-template-columns: 1fr 1fr; padding: 4px; border-radius: 999px; background: var(--chip); }
.switcher button { position: relative; z-index: 1; display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-width: 116px; height: 44px; padding: 0 18px; border-radius: 999px; font-size: 16px; font-weight: 700; color: var(--text-2); transition: color .25s; }
.switcher button[aria-selected="true"] { color: var(--surface); }
.switcher-thumb { position: absolute; top: 4px; bottom: 4px; left: 4px; width: calc(50% - 4px); border-radius: 999px; background: var(--ink); transition: transform .45s var(--spring); }
body.show-barista .switcher-thumb { transform: translateX(100%); }
.badge { display: inline-grid; place-items: center; min-width: 24px; height: 24px; padding: 0 7px; border-radius: 999px; background: var(--accent); color: #fff; font-size: 13px; }
.badge.bump { animation: bump .5s var(--spring); }
@keyframes bump { 30% { transform: scale(1.45); } }

/* ---------- Order view ---------- */
.order-view {
	display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); gap: 24px; min-height: 0;
	padding: 20px calc(24px + env(safe-area-inset-right)) calc(20px + env(safe-area-inset-bottom)) calc(24px + env(safe-area-inset-left));
	transition: transform .55s var(--out), filter .55s var(--out);
	transform-origin: 30% 50%;
}
body.show-barista .order-view { transform: scale(.97) translateX(-12px); filter: saturate(.6); }

.drinks-pane { min-height: 0; overflow-y: auto; }
.drinks { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); grid-auto-rows: minmax(118px, 1fr); gap: 10px; height: 100%; }
.drink {
	display: grid; justify-items: center; align-content: center; gap: 6px; padding: 8px 4px; border-radius: 22px;
	background: var(--surface); box-shadow: inset 0 0 0 1.5px var(--line);
	transition: transform .3s var(--spring), box-shadow .2s;
	animation: fade-up .5s var(--out) both; animation-delay: calc(var(--i) * 30ms);
}
.drink svg { width: 64px; height: 64px; transition: transform .4s var(--spring); overflow: visible; }
.drink span { font-size: 17px; font-weight: 700; letter-spacing: -0.015em; text-align: center; line-height: 1.1; }
.drink:active { transform: scale(.94); }
.drink[aria-pressed="true"] { box-shadow: inset 0 0 0 3px var(--ink); }
.drink[aria-pressed="true"] svg { transform: translateY(-3px) scale(1.08); }

.build-pane { display: flex; flex-direction: column; gap: 14px; min-height: 0; }
.build-card { flex: 1; min-height: 0; overflow-y: auto; border-radius: 28px; box-shadow: inset 0 0 0 1.5px var(--line); padding: 22px 24px; }
.hello { height: 100%; display: grid; place-content: center; justify-items: center; text-align: center; gap: 10px; padding: 20px; }
.hello-mark .cupmark { width: 120px; height: auto; overflow: visible; }
.hello h1 { font-size: clamp(30px, 3.4vw, 44px); letter-spacing: var(--display); line-height: 1; margin-top: 12px; }
.hello p { color: var(--text-3); font-size: 17px; }
.build-head { display: flex; align-items: center; gap: 16px; padding-bottom: 16px; margin-bottom: 16px; border-bottom: 1.5px solid var(--line); animation: fade-up .4s var(--out); }
.build-head svg { width: 72px; height: 72px; flex: none; overflow: visible; }
.build-head h2 { font-size: 32px; letter-spacing: var(--display); line-height: 1; }
.build-head p { color: var(--text-2); font-size: 15px; margin-top: 6px; }
.options { display: grid; gap: 12px; }
.options:empty { display: none; }
.opt { display: grid; grid-template-columns: 78px 1fr; align-items: center; gap: 12px; animation: fade-up .45s var(--out) both; animation-delay: calc(var(--i, 0) * 45ms); }
.opt:has(.hot) { grid-template-columns: 78px auto auto; justify-content: start; }
.opt:has(.hot) .hot { margin-left: 12px; }
.opt-label { font-size: 12px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--text-3); }

.finish { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; }
.tray { display: flex; flex-wrap: wrap; gap: 8px; }
.tray:empty { display: none; }
.tray li { display: inline-flex; align-items: center; gap: 4px; height: 40px; padding: 0 6px 0 14px; border-radius: 999px; background: var(--chip); font-size: 15px; font-weight: 700; animation: pop .35s var(--spring); }
.tray li button { width: 30px; height: 30px; border-radius: 50%; color: var(--text-3); font-size: 20px; line-height: 1; }
.finish-row { display: flex; gap: 10px; }
.name-input {
	flex: 1 1 0; width: 0; min-width: 0; height: 60px; padding: 0 22px; border-radius: 999px;
	font: inherit; font-size: 22px; font-weight: 700; letter-spacing: -0.02em;
	border: 1.5px solid var(--line-strong); background: var(--surface); color: var(--ink); transition: border-color .15s;
}
.name-input::placeholder { color: var(--text-3); font-weight: 500; }
.name-input:focus { outline: none; border-color: var(--ink); }
.finish-row .btn { min-height: 60px; }
.finish-row .btn { padding: 0 20px; }
.finish-row .primary { padding: 0 26px; font-size: 18px; }

/* The name flies to the Barista tab when an order is added. */
.fly { position: fixed; left: 0; top: 0; z-index: 80; pointer-events: none; }
.fly span { display: block; padding: 10px 16px; border-radius: 999px; background: var(--ink); color: #fff; font-weight: 700; font-size: 16px; white-space: nowrap; box-shadow: 0 10px 30px rgba(0, 0, 0, .25); }

/* ---------- Barista panel ---------- */
.scrim { position: fixed; inset: var(--bar-h, 80px) 0 0 0; z-index: 35; background: var(--scrim); opacity: 0; transition: opacity .4s; }
body.show-barista .scrim { opacity: 1; }
.barista {
	position: fixed; z-index: 40; top: var(--bar-h, 80px); right: 0; bottom: 0; width: min(760px, 66vw);
	display: flex; flex-direction: column; background: var(--surface); box-shadow: -24px 0 60px rgba(0, 0, 0, .14);
	transform: translateX(104%); transition: transform .55s var(--out); visibility: hidden;
	padding-right: env(safe-area-inset-right);
}
body.show-barista .barista { transform: none; visibility: visible; }
body.barista-moving .barista { visibility: visible; }
.barista-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 22px 24px 8px; }
.barista-head h2 { font-size: 46px; letter-spacing: var(--display); line-height: .95; }
.barista-count { color: var(--text-3); font-size: 16px; font-weight: 700; margin-top: 6px; min-height: 1.2em; }
.barista-tools { display: flex; gap: 8px; }
.barista-tools .btn { min-height: 48px; font-size: 15px; }
.barista-tools .close { width: 48px; padding: 0; }

.phone-row { padding: 8px 24px 14px; }
.toggle { display: flex; align-items: center; justify-content: space-between; gap: 16px; width: 100%; padding: 12px 14px 12px 18px; border-radius: 20px; box-shadow: inset 0 0 0 1.5px var(--line); text-align: left; }
.toggle-text b { display: block; font-size: 17px; }
.toggle-text span { display: block; font-size: 14px; color: var(--text-3); margin-top: 2px; }
.toggle[aria-checked="true"] .toggle-text span::before { content: ''; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: oklch(0.62 0.17 150); margin-right: 7px; vertical-align: 1px; }
.toggle.offline .toggle-text span::before { background: var(--accent); animation: none; }
.sw { flex: none; width: 56px; height: 34px; border-radius: 999px; background: var(--line-strong); position: relative; transition: background .25s; }
.sw::after { content: ''; position: absolute; top: 3px; left: 3px; width: 28px; height: 28px; border-radius: 50%; background: #fff; box-shadow: 0 2px 6px rgba(0, 0, 0, .2); transition: transform .4s var(--spring); }
.toggle[aria-checked="true"] .sw { background: var(--ink); }
.toggle[aria-checked="true"] .sw::after { transform: translateX(22px); }

.todo { flex: 1; min-height: 0; overflow-y: auto; padding: 4px 18px 18px; display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; align-content: start; -webkit-overflow-scrolling: touch; }
.empty { grid-column: 1 / -1; color: var(--text-3); text-align: center; padding: 56px 20px; font-size: 17px; line-height: 1.5; display: grid; justify-items: center; gap: 4px; }
.empty .cupmark { width: 80px; height: auto; color: var(--line-strong); margin-bottom: 10px; }
.empty b { display: block; color: var(--ink); font-size: 22px; letter-spacing: var(--heading); }

.ticket { position: relative; border-radius: 22px; padding: 8px 8px 10px; box-shadow: inset 0 0 0 1.5px var(--line); background: var(--surface); }
body.show-barista .ticket { animation: fade-up .5s var(--out) both; animation-delay: calc(var(--i) * 50ms + 120ms); }
.ticket.new { animation: arrive .7s var(--spring) both !important; }
@keyframes arrive { from { transform: translateY(-16px) scale(.9); opacity: 0; } }
.ticket.leaving { animation: leave .55s var(--out) forwards !important; }
@keyframes leave { 0% { transform: none; } 30% { transform: scale(1.03); } 100% { opacity: 0; transform: translateX(60px) scale(.95); } }
.ticket-head { display: flex; align-items: center; gap: 10px; padding: 4px 4px 2px; }
.ticket-head .who { flex: 1; min-width: 0; display: flex; align-items: baseline; gap: 8px; }
.ticket-head .who b { font-size: 24px; letter-spacing: var(--heading); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ticket-head .no { color: var(--text-3); font-size: 14px; font-weight: 700; }
.ticket-head .src { display: inline-grid; place-items: center; height: 22px; padding: 0 8px; border-radius: 999px; background: var(--ink); color: #fff; font-size: 11px; font-weight: 700; letter-spacing: .08em; }
.age { font-size: 14px; font-weight: 700; color: var(--text-3); padding: 4px 8px; border-radius: 999px; }
.age.late { color: var(--accent-text); background: var(--accent-soft); }
.ticket .x { width: 40px; height: 40px; border-radius: 50%; color: var(--text-3); font-size: 22px; line-height: 1; }

.check {
	position: relative; flex: none; width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center;
	box-shadow: inset 0 0 0 2px var(--line-strong); color: var(--surface); transition: background .2s, box-shadow .2s, transform .35s var(--spring);
}
.check svg { width: 18px; height: 18px; }
[aria-checked="true"] > .check { background: var(--ink); box-shadow: none; transform: scale(1.08); }
.tick-all { padding: 6px; margin: -6px; border-radius: 50%; }
.line { display: flex; align-items: flex-start; gap: 12px; width: 100%; padding: 10px 8px; border-radius: 16px; text-align: left; transition: background .15s; }
.line:active { background: var(--chip); }
.line .check { width: 30px; height: 30px; margin-top: 1px; }
.line .check svg { width: 15px; height: 15px; }
.line .t { display: block; font-size: 18px; font-weight: 700; letter-spacing: -0.015em; line-height: 1.25; transition: opacity .3s; }
.line .m { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 5px; transition: opacity .3s; }
.line .m:empty { display: none; }
.mod { display: inline-flex; align-items: center; gap: 5px; height: 26px; padding: 0 9px; border-radius: 999px; background: var(--chip); font-size: 14px; font-weight: 700; color: var(--text-2); }
.mod.alt { background: var(--ink); color: var(--surface); }
.mod.alt .milk-dot { box-shadow: none; }
.mod.hot { background: var(--accent-soft); color: var(--accent-text); }
.mod.note { background: none; padding: 0; height: auto; font-style: italic; font-weight: 500; color: var(--ink); font-size: 15px; flex-basis: 100%; }
.line[aria-checked="true"] .t, .line[aria-checked="true"] .m { opacity: .32; }
.line[aria-checked="true"] .t { text-decoration: line-through; }

/* A little burst when a drink is ticked */
.burst { position: absolute; left: 50%; top: 50%; width: 0; height: 0; pointer-events: none; }
.burst i { position: absolute; width: 6px; height: 6px; margin: -3px; border-radius: 50%; background: var(--ink); animation: burst .55s var(--out) forwards; transform: rotate(var(--a)) translateY(0); }
@keyframes burst { to { transform: rotate(var(--a)) translateY(-26px); opacity: 0; } }

.done { border-top: 1.5px solid var(--line); max-height: 40%; display: flex; flex-direction: column; }
.done summary { display: flex; justify-content: space-between; align-items: center; padding: 16px 24px calc(16px + env(safe-area-inset-bottom)); font-size: 16px; font-weight: 700; cursor: pointer; list-style: none; }
.done summary::-webkit-details-marker { display: none; }
.done summary::after { content: ''; width: 9px; height: 9px; border-right: 2px solid; border-bottom: 2px solid; transform: rotate(-135deg); margin-left: 10px; transition: transform .3s var(--spring); }
.done[open] summary::after { transform: rotate(45deg); }
.done summary span:last-of-type { margin-left: auto; color: var(--text-3); }
.done[open] summary { padding-bottom: 10px; }
.done-list { overflow-y: auto; padding: 0 18px calc(14px + env(safe-area-inset-bottom)); }
.done-list li { display: flex; align-items: center; gap: 10px; padding: 9px 6px; border-top: 1px solid var(--line); font-size: 15px; animation: fade-up .35s var(--out); }
.done-list li:first-child { border-top: 0; }
.done-list .what { flex: 1; min-width: 0; color: var(--text-2); }
.done-list .what b { color: var(--ink); }
.done-list .what span { display: block; color: var(--text-3); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.done-list button { font-size: 14px; font-weight: 700; padding: 8px 14px; border-radius: 999px; box-shadow: inset 0 0 0 1.5px var(--line-strong); }

/* ---------- QR poster ---------- */
.poster { width: min(720px, calc(100vw - 40px)); max-height: calc(100dvh - 40px); border-radius: 32px; overflow: auto; }
.poster-body { display: grid; justify-items: center; text-align: center; gap: 18px; padding: 36px 40px 8px; }
.poster-body h2 { font-size: 48px; letter-spacing: var(--display); line-height: 1; }
.poster-qr { width: min(320px, 60vw, 40dvh); aspect-ratio: 1; padding: 12px; border-radius: 24px; box-shadow: inset 0 0 0 1.5px var(--line-strong); }
.poster-qr svg { display: block; width: 100%; height: 100%; }
.poster[open] .poster-qr svg { animation: reveal .9s var(--out) .15s both; }
@keyframes reveal { from { clip-path: inset(0 0 100% 0); } to { clip-path: inset(0); } }
.poster-steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; text-align: left; font-size: 15px; color: var(--text-2); line-height: 1.35; }
.poster-steps b { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--ink); color: var(--surface); font-size: 14px; margin-bottom: 8px; }
.poster-url { color: var(--text-3); font-size: 15px; font-weight: 700; }
.poster-off { color: var(--accent-text); font-weight: 700; font-size: 16px; }
.poster-off button { text-decoration: underline; text-underline-offset: 3px; }
.poster-actions { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 24px 24px; }

/* ---------- PIN ---------- */
.pin { width: min(400px, calc(100vw - 32px)); border-radius: 32px; padding: 30px 28px 24px; display: none; text-align: center; }
.pin[open] { display: grid; justify-items: center; gap: 8px; }
.pin h2 { font-size: 30px; letter-spacing: var(--display); }
.pin > p { color: var(--text-3); font-size: 15px; }
.pin-dots { display: flex; gap: 16px; height: 22px; margin: 16px 0 18px; }
.pin-dots i { width: 16px; height: 16px; border-radius: 50%; box-shadow: inset 0 0 0 2px var(--line-strong); transition: background .15s, transform .3s var(--spring); }
.pin-dots i.on { background: var(--ink); box-shadow: none; transform: scale(1.15); }
.pin-dots.shake { animation: shake .4s; }
@keyframes shake { 20%, 60% { transform: translateX(-10px); } 40%, 80% { transform: translateX(10px); } }
.keypad { display: grid; grid-template-columns: repeat(3, 76px); gap: 12px; margin-bottom: 12px; }
.keypad button { height: 76px; border-radius: 50%; box-shadow: inset 0 0 0 1.5px var(--line-strong); font-size: 28px; font-weight: 500; transition: background .1s, transform .2s var(--spring); }
.keypad button:active { background: var(--chip); transform: scale(.92); }
.keypad button.fn { box-shadow: none; font-size: 15px; font-weight: 700; }

/* ---------- History ---------- */
.sheet { width: min(760px, calc(100vw - 40px)); height: min(760px, calc(100dvh - 40px)); border-radius: 28px; display: none; flex-direction: column; }
.sheet[open] { display: flex; }
.sheet-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 28px 28px 16px; border-bottom: 1.5px solid var(--line); }
.sheet-head h2 { font-size: 40px; letter-spacing: var(--display); line-height: 1; }
.sheet-head p { color: var(--text-3); margin-top: 6px; font-size: 15px; }
.sheet-tools { display: flex; gap: 8px; }
.history { overflow-y: auto; padding: 8px 28px 28px; }
.history .empty .cupmark { color: var(--line-strong); }
.day { border-bottom: 1px solid var(--line); }
.day summary { display: flex; align-items: baseline; gap: 14px; padding: 18px 0; cursor: pointer; list-style: none; }
.day summary::-webkit-details-marker { display: none; }
.day summary b { font-size: 20px; letter-spacing: var(--heading); flex: 1; }
.day summary span { color: var(--text-3); font-weight: 700; font-size: 15px; }
.day ul { padding-bottom: 14px; }
.day li { display: grid; grid-template-columns: 76px 1fr auto; gap: 12px; padding: 8px 0; font-size: 15px; border-top: 1px solid var(--line); }
.day li .tm { color: var(--text-3); font-weight: 700; white-space: nowrap; }
.day li .what b { display: block; font-size: 16px; }
.day li .what span { color: var(--text-2); }
.day li .st { color: var(--text-3); font-size: 13px; font-weight: 700; }
.day-totals { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 0 14px; }
.day-totals span { background: var(--chip); border-radius: 999px; padding: 5px 11px; font-size: 13px; font-weight: 700; color: var(--text-2); }

/* ---------- Update pill ---------- */
.update { position: fixed; left: 50%; top: max(14px, env(safe-area-inset-top)); transform: translateX(-50%); display: flex; align-items: center; gap: 14px; padding: 8px 8px 8px 18px; border-radius: 999px; background: var(--ink); color: var(--surface); font-weight: 700; font-size: 15px; z-index: 90; box-shadow: 0 10px 30px rgba(0, 0, 0, .2); animation: rise .5s var(--spring); }
.update button { background: var(--surface); color: var(--ink); border-radius: 999px; padding: 8px 14px; font-weight: 700; }

/* Toasts sit bottom-left on the iPad: clear of the Add button and of the barista panel's controls. */
.toast { left: calc(24px + env(safe-area-inset-left)); transform: translateY(16px) scale(.96); }
.toast.show { transform: none; }

/* ---------- Narrower screens ---------- */
@media (max-width: 1060px) {
	.order-view { grid-template-columns: 1fr; grid-template-rows: auto minmax(0, 1fr); overflow-y: auto; }
	.drinks { grid-template-columns: repeat(4, minmax(0, 1fr)); grid-auto-rows: 112px; height: auto; }
	.drinks-pane { overflow: visible; }
	.build-card { min-height: 360px; }
	.barista { width: 100vw; }
	.bar-tools > .btn { padding: 0 14px; }
}
@media (max-width: 640px) {
	.bar { flex-wrap: wrap; }
	.wordmark small { display: none; }
	.bar-tools { width: 100%; }
	.switcher { flex: 1; }
	.switcher button { min-width: 0; }
	.bar-tools > .btn { font-size: 0; gap: 0; width: 48px; padding: 0; }
	.drinks { grid-template-columns: repeat(3, minmax(0, 1fr)); grid-auto-rows: 100px; }
	.opt, .opt:has(.hot) { grid-template-columns: 1fr; gap: 6px; }
	.opt:has(.hot) .hot { margin-left: 0; justify-self: start; }
	.finish-row { flex-wrap: wrap; }
	.name-input { flex-basis: 100%; }
	.finish-row .btn { flex: 1; }
	.todo { grid-template-columns: 1fr; }
	.barista-head h2 { font-size: 36px; }
	.poster-steps { grid-template-columns: 1fr; }
}

/* ---------- Print: the QR poster only, A4 ---------- */
@media print {
	@page { size: A4; margin: 18mm; }
	body { display: block; overflow: visible; height: auto; }
	.bar, .order-view, .barista, .scrim, .update, .toast, dialog:not(.poster) { display: none !important; }
	dialog::backdrop { display: none; }
	.poster { position: static; display: block; width: 100%; max-height: none; border-radius: 0; animation: none; }
	.poster-actions, .poster-off { display: none !important; }
	.poster-body { padding-top: 10mm; gap: 10mm; }
	.poster-body h2 { font-size: 40pt; }
	.poster-qr { width: 110mm; }
	.poster-steps { font-size: 13pt; }
}
