/* Tom's stand: customers in the street on top, one open order below. Everything is a real button, so nothing here draws on a canvas. */

.stage { display: flex; flex-direction: column; }

/* Street */
.street { position: relative; flex: 1 1 auto; min-height: 0; overflow: hidden; container-type: size; }
/* Cover by hand: Tom stands in the window the picture draws, so her box has to scale with the picture. */
.scene { --picture: max(100cqh, 100cqw * 669 / 720); position: absolute; inset: 0; overflow: hidden; background: #f3e6d4; }
.picture { position: absolute; top: 0; right: 0; height: var(--picture); aspect-ratio: 720 / 669; background: url("../assets/ragazzi/scene.webp") center / 100% 100% no-repeat; }
.frames { position: absolute; top: 0; left: 36%; display: flex; gap: 8px; pointer-events: none; }
.frame { height: min(30cqh, 74px); width: auto; transform-origin: top center; animation: swing 4.4s ease-in-out infinite alternate; }
.frame + .frame { animation-delay: -1.6s; }
/* The family photo opens Tom's dedication. A customer standing in front of it keeps the tap. */
.tom-frame { padding: 0; border: 0; background: none; cursor: pointer; pointer-events: auto; touch-action: manipulation; }
.tom-frame img { display: block; height: 100%; width: auto; }
@keyframes swing { from { transform: rotate(-2.4deg); } to { transform: rotate(2.4deg); } }
/* A short street cuts the sill off, so she rests on the street's bottom edge and stays in view. */
.window { position: absolute; top: calc(var(--picture) * .24); right: 0; bottom: max(0px, 100cqh - var(--picture) * .735); width: calc(var(--picture) * .178); overflow: hidden; }
.tom { position: absolute; bottom: 0; left: 50%; width: 118%; max-width: none; height: auto; transform: translateX(-50%); }
.rider { position: absolute; top: 12%; left: 0; height: min(42cqh, 100px); width: auto; filter: drop-shadow(0 4px 6px rgb(0 0 0 / .2)); }

/* Delivery yellow, the one colour the warm scene does not use. It sits above Tom, where no customer stands. */
.ticket {
  --ticket-width: min(26cqw, 124px); --ticket-ink: #2a1c00;
  position: absolute; z-index: 2; top: 6px; right: 6px; width: var(--ticket-width); display: grid; justify-items: center; gap: 4px; padding: 6px 4px 11px; overflow: hidden;
  background: #ffd400; color: var(--ticket-ink); border: 3px solid #fff; border-radius: 16px; cursor: pointer;
  font: 800 14px/1.1 var(--font-body); box-shadow: 0 0 0 2px var(--ticket-ink), 0 7px 14px rgb(0 0 0 / .4);
  animation: ticket-in .45s cubic-bezier(.2, 1.5, .4, 1) both;
}
@keyframes ticket-in { from { transform: scale(.4) rotate(-8deg); opacity: 0; } to { transform: none; opacity: 1; } }
/* Most of the beat stands still, so a tap never chases a moving button. */
@keyframes ticket-call { 0%, 55%, 100% { transform: none; } 65% { transform: scale(1.12) rotate(-3deg); } 75% { transform: scale(.98) rotate(3deg); } 85% { transform: scale(1.05); } }
/* Waiting behind the open order, so it has to ask for a tap. */
.ticket[data-state="open"][data-active="false"] { animation: ticket-call 1.5s ease-in-out infinite; }
.ticket .items { display: flex; gap: 3px; padding: 2px 6px; border-radius: 9px; background: #fff; }
.ticket img { width: 24px; height: 24px; }
.ticket .bar { position: absolute; inset: auto 0 0; height: 6px; background: rgb(0 0 0 / .18); }
.ticket .bar span { display: block; height: 100%; background: var(--ticket-ink); width: 100%; transform-origin: right; }
.ticket[data-state="bagged"] { opacity: .75; }

/* The first delivery ever: all but the ticket goes dark, and the rest of the stand ignores taps. */
.stage[data-coach="true"] :is(.scene, .queue, .counter) { filter: brightness(.35); }
.stage[data-coach="true"] .ticket { animation: ticket-call 1.1s ease-in-out infinite; }
.coach { position: absolute; z-index: 3; top: 18px; right: calc(min(26cqw, 124px) + 24px); padding: 8px 14px; border-radius: 12px; background: #fff; color: #2a1c00; font: 800 17px/1.1 var(--font-body); white-space: nowrap; pointer-events: none; animation: coach-nudge .5s ease-in-out infinite alternate; }
.coach::after { content: ""; position: absolute; top: calc(50% - 10px); right: -14px; border: 10px solid transparent; border-right-width: 0; border-left: 15px solid #fff; }
@keyframes coach-nudge { from { transform: translateX(-8px); } to { transform: none; } }

/* Queue: customers stand on the street, next to Tom. The open one is the one lit up. */
.queue { position: absolute; inset-block: 0; left: 0; width: 72%; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); grid-template-rows: minmax(0, 1fr); gap: 2px; padding: 0 4px 12px; }
.slot { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 3px; min-width: 0; min-height: 0; cursor: pointer; animation: arrive .25s ease both; }
/* The empty street above a customer passes the tap to the wall behind, so the photo stays reachable. */
.queue { pointer-events: none; }
.slot > * { pointer-events: auto; }
.slot[data-leaving="true"] { animation: leave .5s ease .35s both; }
@keyframes arrive { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes leave { to { opacity: 0; transform: translateY(14px); } }
.who { flex: 0 1 auto; min-height: 0; height: min(54cqh, 124px); max-width: 100%; object-fit: contain; object-position: bottom; filter: drop-shadow(0 3px 4px rgb(0 0 0 / .25)); transition: filter .15s ease; }
.slot[data-active="false"] .who { filter: brightness(.72) drop-shadow(0 3px 4px rgb(0 0 0 / .25)); }
/* The panel points up at the customer it belongs to. */
.slot[data-active="true"]::after { content: ""; position: absolute; bottom: -12px; left: calc(50% - 11px); border: 11px solid transparent; border-top-width: 0; border-bottom-color: var(--panel); }
.nerves { flex: none; width: 88%; height: 7px; border-radius: 4px; background: rgb(0 0 0 / .45); overflow: hidden; }
.nerves span { display: block; height: 100%; width: 0; background: var(--good); }
.nerves[data-level="mid"] span { background: var(--mid); }
.nerves[data-level="high"] span { background: var(--bad); }
.bubble { flex: none; max-width: 100%; display: grid; justify-items: center; padding: 3px 6px; background: var(--panel); color: var(--fg); border: 1px solid var(--line); border-radius: 12px; line-height: 1.15; text-align: center; box-shadow: 0 2px 5px rgb(0 0 0 / .18); }
.slot[data-active="true"] .bubble { border: 2px solid var(--accent); }
.bubble .items { display: flex; gap: 2px; justify-content: center; }
.bubble img { width: 30px; height: 30px; }
.bubble .line { font-size: 12px; font-weight: 700; }
/* מוישה needs room for his buttons under him, and his line above him. */
.slot:has(.actions) .who { height: min(40cqh, 92px); }
.actions { flex: none; width: 100%; display: flex; flex-direction: column; gap: 3px; }
.moishe-button { min-height: 28px; padding: 2px; border: 1px solid var(--line); border-radius: 999px; background: var(--panel); color: var(--fg); font: 800 11.5px/1.1 var(--font-body); cursor: pointer; touch-action: manipulation; }
.moishe-button.feed { background: var(--good-soft); color: var(--good); }

/* Open order: who, what they can't have, one row per choice, then the two answers. */
.counter { --row: clamp(54px, 9.6vh, 62px); position: relative; flex: none; padding: 8px; background: var(--panel); border-top: 2px solid var(--line); container-type: inline-size; }
.order { position: relative; display: grid; gap: 7px; }
.order[data-state="empty"] > :not(.order-empty) { visibility: hidden; }
.order-empty { position: absolute; inset: 0; display: grid; place-items: center; margin: 0; color: var(--muted); font-weight: 700; font-size: 15px; }
.order[data-state="open"] .order-empty { display: none; }
.order-head { display: flex; align-items: center; gap: 8px; min-height: 50px; }
.order-face { flex: none; width: 50px; height: 50px; border-radius: 50%; object-fit: cover; object-position: top; background: var(--panel-2); border: 2px solid var(--accent); }
.order-text { min-width: 0; display: grid; gap: 2px; }
.order-title { font: 800 16.5px/1.15 var(--font-display); text-wrap: balance; }
.order-limit { justify-self: start; padding: 1px 8px; border: 0; border-radius: 999px; background: var(--bad-soft); color: var(--bad); font-family: var(--font-body); font-size: 14px; font-weight: 800; line-height: 1.3; cursor: pointer; }
.order-limit:not(:disabled)::after { --mark: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cmask id='q'%3E%3Crect width='16' height='16' fill='white'/%3E%3Cpath d='M5.7 6.1a2.4 2.4 0 1 1 3.7 2c-.9.6-1.4 1-1.4 2' fill='none' stroke='black' stroke-width='1.9' stroke-linecap='round'/%3E%3Ccircle cx='8' cy='12.5' r='1.15'/%3E%3C/mask%3E%3Ccircle cx='8' cy='8' r='8' mask='url(%23q)'/%3E%3C/svg%3E"); content: ""; display: inline-block; width: 16px; height: 16px; margin-inline-start: 5px; vertical-align: -3px; background: var(--bad); -webkit-mask: var(--mark) center / contain no-repeat; mask: var(--mark) center / contain no-repeat; }
.order-limit:disabled { cursor: default; }
.steps { display: grid; gap: 5px; align-content: center; height: calc(var(--row) * 3 + 10px); grid-auto-rows: var(--row); }
.step { display: flex; align-items: center; gap: 6px; min-width: 0; }
.step-label { flex: none; width: 50px; color: var(--muted); font-size: 12px; font-weight: 800; line-height: 1.1; }
.step-options { flex: 1; min-width: 0; display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 5px; }
.tile-wrap { position: relative; min-width: 0; }
.tile {
  position: relative; width: 100%; display: flex; align-items: center; gap: 5px; height: var(--row); padding: 3px 6px; overflow: hidden; text-align: start;
  border: 2px solid var(--line); border-radius: 12px; background: var(--bg); color: var(--fg); cursor: pointer;
  font: 700 13.5px/1.15 var(--font-body); touch-action: manipulation; -webkit-tap-highlight-color: transparent;
}
.tile:active { transform: scale(.97); }
.tile img { flex: none; width: 32px; height: 32px; object-fit: contain; }
.tile-text { min-width: 0; display: grid; gap: 1px; }
/* Leaves the corner of the first line to the ingredients button. */
.tile-name { font-weight: 800; padding-inline-end: 16px; }
.info { position: absolute; top: 4px; inset-inline-end: 4px; width: 20px; height: 20px; padding: 0; border: 1px solid var(--line); border-radius: 50%; background: var(--panel-2); color: var(--fg); font: italic 800 12px/1 Georgia, serif; cursor: pointer; touch-action: manipulation; }
.info::before { content: ""; position: absolute; inset: -6px; }
.tile-note { color: var(--fg); font-size: 11.5px; font-weight: 600; line-height: 1.15; }
.tile[data-picked="true"] { border-color: var(--accent); background: var(--accent-soft); }
.tile[data-clash="true"] .tile-note { color: var(--bad); font-weight: 800; }
.tile[data-picked="true"]::after { content: "✓"; position: absolute; top: 1px; inset-inline-start: 4px; font-size: 14px; font-weight: 800; color: var(--accent); }
.tile[data-busy="true"] { border-color: var(--accent); }
.tile .progress { position: absolute; inset: auto 0 0; height: 5px; background: var(--accent); transform-origin: right; transform: scaleX(0); }
/* Three in a row leaves no width for a picture beside two lines, so the note drops under it. */
.step-options[data-count="3"] .tile { display: grid; grid-template-columns: auto minmax(0, 1fr); column-gap: 4px; align-content: center; padding: 2px 5px; }
.step-options[data-count="3"] .tile img { width: 22px; height: 22px; }
.step-options[data-count="3"] .tile-text { display: contents; }
.step-options[data-count="3"] .tile-name { font-size: 12px; align-self: center; }
.step-options[data-count="3"] .tile-note { grid-column: 1 / -1; font-size: 10px; line-height: 1.1; }
.step:has([data-count="3"]) .step-label { display: none; }
/* An empty tray drops its picture and its note, so the refill button reads as the only thing to do. */
.refill { display: none; padding: 3px 14px; border-radius: 999px; background: var(--accent); color: var(--accent-ink); font-size: 12.5px; font-weight: 800; line-height: 1.2; white-space: nowrap; }
.step-options .tile[data-empty="true"] { display: grid; grid-template-columns: minmax(0, 1fr); justify-items: center; align-content: center; gap: 3px; padding: 2px 4px; }
.step-options .tile[data-empty="true"] img, .step-options .tile[data-empty="true"] .tile-note { display: none; }
.tile[data-empty="true"] .refill { display: block; }
.tile[data-busy="true"] .refill { background: var(--panel-2); color: var(--fg); }
/* The button already names the row, so a narrow phone gives the label's width to the options. */
@container (max-width: 340px) {
  .step-label { display: none; }
  .step-options[data-count="3"] .tile img { display: none; }
}
.order-actions { display: flex; gap: 6px; }
.serve, .refuse { min-width: 0; min-height: 48px; padding: 4px 8px; border-radius: 999px; border: 2px solid transparent; font-family: var(--font-body); font-weight: 800; line-height: 1.1; cursor: pointer; touch-action: manipulation; }
.serve { flex: 1.5; background: var(--accent); color: var(--accent-ink); font-size: 16px; animation: ready 1s ease-in-out infinite alternate; }
.serve:disabled { background: var(--panel-2); color: var(--muted); cursor: default; animation: none; }
.refuse { flex: 1; background: transparent; border-color: var(--line); color: var(--fg); font-size: 12.5px; }
.refuse[data-hint="true"] { background: var(--bad-soft); border-color: var(--bad); color: var(--bad); }
@keyframes ready { from { box-shadow: 0 0 0 0 var(--accent-soft); } to { box-shadow: 0 0 0 5px var(--accent-soft); } }
.tile:focus-visible, .serve:focus-visible, .refuse:focus-visible, .moishe-button:focus-visible, .ticket:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.beti-run { position: absolute; top: -34px; left: 8px; width: 58px; height: auto; pointer-events: none; animation: dash 2s linear both; }
@keyframes dash { from { transform: translateX(0); } 50% { transform: translateX(calc(100cqw - 90px)); } to { transform: translateX(0); } }

.popup[data-kind="delivery"] { border-color: var(--accent); }
.popup[data-kind="delivery"] img { object-fit: contain; }
.popup[data-kind="delivery"] .timer { background: var(--accent); }
/* Under the scrims, or a pause during a hold would lock the resume button behind it. */
.hold { position: absolute; inset: 0; z-index: 2; background: rgb(0 0 0 / .35); }

/* The why card and the scrims sit over the street and the order, and the rules open over the pause screen. */
.popup, .scrim { z-index: 3; }
#rules, #menu, #memory { z-index: 5; }
/* The walkthrough has its own way out, so pause sits out until the stand opens. */
#pause-button:disabled { opacity: .4; cursor: default; }

/* The pace. The chosen one is filled, so all three stay readable at once. */
.levels { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
.levels .chip-button[aria-pressed="false"] { opacity: 1; color: var(--fg); }
.levels .chip-button[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.card .level-note { min-height: 2.6em; font-size: 13.5px; line-height: 1.3; }
.speedo { flex: none; display: flex; align-items: center; height: 36px; border: 1px solid var(--line); border-radius: 18px; background: var(--panel-2); }
.speedo svg { display: block; width: 30px; height: 22px; fill: none; stroke: currentColor; stroke-width: 3.2; stroke-linecap: round; }
.speedo-step { width: 30px; height: 44px; margin-block: -4px; padding: 0; border: 0; background: none; color: inherit; font-family: var(--font-body); font-size: 19px; font-weight: 800; line-height: 1; cursor: pointer; }
.speedo-step:disabled { opacity: .3; cursor: default; }
.speedo-step:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; border-radius: 12px; }
.speedo .calm { stroke: var(--good); }
.speedo .normal { stroke: var(--mid); }
.speedo .rush { stroke: var(--bad); }
.speedo .needle { transform: rotate(var(--needle, -80deg)); transform-origin: 16px 20px; transition: transform .25s ease; }
.button.quiet { background: transparent; color: var(--accent); box-shadow: inset 0 0 0 2px var(--accent); }

/* A short phone keeps Start and the walkthrough above the fold. */
@media (max-height: 700px) { #start .beti { width: 96px; } #start .card { gap: 8px; } #start .card p { font-size: 13.5px; } }

/* The walkthrough. One hole in the dark over the real control, so the player learns the real screen. */
.spot { position: absolute; z-index: 3; border-radius: 14px; box-shadow: 0 0 0 200vmax rgb(30 14 6 / .62); outline: 3px solid #fff; pointer-events: none; transition: top .25s ease, left .25s ease, width .25s ease, height .25s ease; animation: spot-pulse 1s ease-in-out infinite alternate; }
.spot[data-empty="true"] { outline: 0; animation: none; }
@keyframes spot-pulse { from { outline-offset: 1px; } to { outline-offset: 6px; } }
.guide { position: absolute; z-index: 4; inset-inline: 10px; display: grid; gap: 8px; padding: 12px 14px; border-radius: 16px; background: var(--panel); color: var(--fg); box-shadow: 0 10px 24px rgb(0 0 0 / .35); }
.guide[data-at="top"] { top: 10px; }
.guide[data-at="bottom"] { bottom: 10px; }
.guide[data-at="middle"] { top: 50%; transform: translateY(-50%); }
.guide p { margin: 0; font-size: 16px; font-weight: 700; line-height: 1.32; }
.guide-count { color: var(--muted); font-size: 12px; font-weight: 800; }
.guide-actions { display: flex; align-items: center; justify-content: space-between; gap: 8px; }

/* Rules page */
#info { background: color-mix(in srgb, var(--shade) 55%, transparent); }
.info-card { position: relative; max-width: 320px; padding: 22px 20px; background: var(--panel); border: 1px solid var(--line); border-radius: 18px; }
.info-close { position: absolute; top: 10px; inset-inline-end: 10px; }
.info-art { width: 88px; height: 88px; object-fit: contain; }
.info-card p { color: var(--fg); }
.info-tags { margin: 0; padding: 0; list-style: none; display: grid; gap: 5px; font-size: 14px; line-height: 1.32; text-align: start; }
.info-tags:empty { display: none; }
.memory-card { padding-top: 58px; }
.memory-photo { width: 100%; height: auto; border-radius: 12px; }
.memory-card p { max-width: 28ch; font-size: 17px; line-height: 1.5; text-wrap: balance; }
.rules-card { max-width: 420px; text-align: start; align-items: stretch; }
.rules-card h2 { text-align: center; }
.rules-list { margin: 0; padding-inline-start: 20px; display: grid; gap: 6px; font-size: 14px; line-height: 1.35; }
.rules-points { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.rules-points td { padding: 3px 0; border-bottom: 1px solid var(--line); }
.rules-points td:last-child { text-align: left; font-weight: 800; font-variant-numeric: tabular-nums; direction: ltr; }
.rules-card .button { align-self: center; }
.glossary { margin: 0; display: grid; gap: 6px; font-size: 14px; line-height: 1.32; }
.glossary dd { margin: 0; }
.menu-list { margin: 0; padding: 0; list-style: none; display: grid; gap: 8px; }
.menu-list li { display: grid; grid-template-columns: 40px minmax(0, 1fr); gap: 2px 8px; align-items: center; padding-top: 8px; border-top: 1px solid var(--line); }
.menu-list img { grid-row: span 3; width: 40px; height: 40px; object-fit: contain; }
.menu-name { font-weight: 800; font-size: 14.5px; }
.menu-note { color: var(--bad); font-size: 12.5px; font-weight: 800; }
.menu-note[data-free="true"] { color: var(--good); }
.menu-what { color: var(--muted); font-size: 13px; line-height: 1.3; }
.stats-row { display: flex; gap: 22px; justify-content: center; }

@media (prefers-reduced-motion: reduce) {
  .frame, .slot, .slot[data-leaving="true"], .beti-run, .serve, .coach, .spot, .stage .ticket[data-state][data-active] { animation: none; }
  .speedo .needle { transition: none; }
}
