/* Pizza Fractions: a neighbourhood pizzeria. The page is deep basil green and
   stays quiet so the shop on the canvas can glow; the order sits on a waiter's
   guest check. Baloo 2 (round and easy to read) for words and fractions,
   Pacifico, the sign-painter script, for the title and the chalk menu. */

:root {
  --basil-deep: #16301f;
  --basil: #1f3f2a;
  --basil-light: #2d5a3c;
  --paper: #fcf7e9;
  --rule-strong: #2f6b45;
  --ink: #23180f;
  --ink-soft: #5c4a39;
  --tomato: #c43a22;
  --tomato-dark: #9a2b17;
  --crust: #f2b84b;
  --crust-light: #f8cd77;
  --text: #f5eedf;
  --text-soft: #c5d1c2;

  --display: "Pacifico", "Brush Script MT", cursive;
  --body: "Baloo 2", system-ui, sans-serif;
}

*,
*::before,
*::after { box-sizing: border-box; }

html { color-scheme: dark; }

body {
  margin: 0;
  min-height: 100svh;
  background: var(--basil-deep);
  color: var(--text);
  font: 500 1.0625rem/1.5 var(--body);
}

.pizzeria {
  max-width: 76rem;
  margin: 0 auto;
  padding: clamp(0.5rem, 1.6vw, 1.2rem) clamp(1rem, 3vw, 2rem) 2rem;
}

.top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.3rem 1.25rem;
  margin-bottom: 0.7rem;
}
.back { color: var(--text-soft); font-weight: 600; text-underline-offset: 3px; }
.back:hover { color: var(--text); }
h1 {
  margin: 0;
  flex: 1;
  font: 400 clamp(1.5rem, 3.2vw, 2.2rem)/1.25 var(--display);
  color: var(--crust);
  white-space: nowrap;
}

.levels { display: flex; gap: 0.3rem; padding: 0.3rem; border-radius: 1.4rem; background: var(--basil); }
.levels button {
  min-height: 2.75rem;
  font: 600 0.95rem/1.1 var(--body);
  padding: 0.35rem 0.95rem;
  border: 0;
  border-radius: 1.1rem;
  background: transparent;
  color: var(--text-soft);
  cursor: pointer;
}
.levels button[aria-pressed="true"] { background: var(--crust); color: #3a2304; }
.levels button:hover:not([aria-pressed="true"]) { color: var(--text); }

/* the shop on the left, the guest check and buttons beside it */
.play {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 19.5rem;
  grid-template-areas: "scene ticket" "scene controls";
  grid-template-rows: auto 1fr;
  gap: 0.9rem 1.1rem;
}
.scene { grid-area: scene; border-radius: 1rem; overflow: hidden; box-shadow: 0 1rem 3rem rgba(0, 0, 0, 0.45); }
.ticket { grid-area: ticket; }
.controls { grid-area: controls; }

canvas {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  max-height: calc(100svh - 9.5rem);
  min-height: 20rem;
  touch-action: none;
  background: #e9dcc0;
}
canvas:focus-visible { outline: 4px solid var(--crust); outline-offset: -4px; }

/* a waiter's guest check: green ruling, a torn stub at the top */
.ticket {
  position: relative;
  padding: 0.55rem 1.1rem 0.8rem;
  background: var(--paper);
  color: var(--ink);
  border-radius: 0.3rem 0.3rem 0.6rem 0.6rem;
  box-shadow: 0 0.5rem 1.4rem rgba(0, 0, 0, 0.35);
  transform: rotate(-0.6deg);
}
.ticket::before {
  content: "";
  position: absolute;
  inset: 2.2rem 0 auto;
  border-top: 2px dashed var(--rule-strong);
  opacity: 0.55;
}
.ticket-head {
  margin: 0 0 0.6rem;
  font-size: 1rem;
  font-weight: 700;
  color: var(--rule-strong);
}
.order {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 700;
  line-height: 1.6;
}
.hint {
  margin: 0.5rem 0 0;
  min-height: 4.5em;
  font-size: 1.05rem;
  font-weight: 500;
  line-height: 1.75;
  color: var(--ink-soft);
}

/* stacked fractions: a number over a bar over a number */
.frac { display: inline-block; vertical-align: middle; margin: 0 0.12em; }
.stack {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  font-weight: 800;
  font-size: 0.86em;
  line-height: 1.02;
  font-variant-numeric: tabular-nums;
}
.stack span { padding: 0 0.18em; }
.stack span:first-child { border-bottom: 0.11em solid currentColor; }
.order .frac { color: var(--tomato); font-size: 1.15em; }
.hint .frac { color: var(--ink); }

.controls { display: flex; flex-wrap: wrap; align-content: flex-start; gap: 0.6rem; }
.controls [hidden] { display: none; }
.cuts, .picks, .toppings { display: flex; flex-wrap: wrap; gap: 0.45rem; width: 100%; }
.cuts button,
.picks button,
.toppings button,
.serve {
  min-height: 3.1rem;
  border: 0;
  border-radius: 0.8rem;
  font: 700 1.1rem/1.1 var(--body);
  cursor: pointer;
}
.cuts button {
  flex: 1;
  min-width: 2.9rem;
  font-size: 1.5rem;
  background: var(--paper);
  color: var(--ink);
  box-shadow: inset 0 -0.25rem 0 #dccfb0;
}
.cuts button:hover:not(:disabled) { background: #fff; }
.cuts button:disabled { opacity: 0.5; cursor: default; }
.picks button { flex: 1; background: var(--paper); color: var(--ink); box-shadow: inset 0 -0.25rem 0 #dccfb0; }
.picks button:hover { background: #fff; }

.toppings button {
  flex: 1;
  padding: 0.4rem 0.8rem;
  background: var(--basil);
  color: var(--text);
  box-shadow: inset 0 0 0 2px var(--basil-light);
}
.toppings button::before {
  content: "";
  display: inline-block;
  width: 0.8em;
  height: 0.8em;
  margin-right: 0.45em;
  border-radius: 50%;
  vertical-align: -0.05em;
  background: var(--dot, #fff);
}
.toppings button[aria-pressed="true"] { background: var(--paper); color: var(--ink); box-shadow: inset 0 0 0 3px var(--crust); }
.toppings button:disabled { cursor: default; opacity: 1; }
.toppings .is-pepperoni { --dot: #b8301f; }
.toppings .is-mushroom { --dot: #cdb491; }
.toppings .is-olive { --dot: #26231f; }
.toppings .is-pineapple { --dot: #f2b52a; }
.toppings .is-cheese { --dot: #f4cc63; }

.serve {
  width: 100%;
  padding: 0.6rem 1.2rem;
  background: var(--tomato);
  color: #fff8ec;
  font-size: 1.25rem;
  box-shadow: inset 0 -0.3rem 0 var(--tomato-dark);
}
.serve:hover { background: #d4452b; }
.serve.next { background: var(--crust); color: #3a2304; box-shadow: inset 0 -0.3rem 0 #c98e22; }
.serve.next:hover { background: var(--crust-light); }

.below {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1.5rem;
  margin-top: 0.9rem;
}
.progress {
  display: grid;
  grid-template-columns: repeat(8, 2.6rem);
  gap: 0.25rem;
  margin: 0;
  padding: 0;
  list-style: none;
}
.progress li {
  height: 2.2rem;
  display: grid;
  place-items: center;
  border-radius: 0.5rem;
  background: var(--basil);
  color: var(--crust);
  font-size: 0.65rem;
  letter-spacing: -0.05em;
}
.progress li.now { box-shadow: inset 0 0 0 2px var(--crust); }
.progress li.done { background: var(--basil-light); }

.tally { display: flex; gap: 1.25rem; margin: 0 0 0 auto; }
.tally div { display: flex; align-items: baseline; gap: 0.4rem; }
.tally dt { font-size: 0.95rem; color: var(--text-soft); }
.tally dd { margin: 0; font-weight: 700; font-size: 1.35rem; font-variant-numeric: tabular-nums; }

.again {
  min-height: 2.75rem;
  font: 600 1rem/1 var(--body);
  padding: 0.7rem 1.2rem;
  border: 0;
  border-radius: 999px;
  background: var(--basil-light);
  color: var(--text);
  cursor: pointer;
}
.again:hover { background: #366b48; }

.again:focus-visible,
.levels button:focus-visible,
.back:focus-visible,
.controls button:focus-visible { outline: 3px solid var(--crust); outline-offset: 2px; }

.notes { max-width: 46rem; margin-top: 1.4rem; }
.keys, .about { margin: 0 0 0.8rem; font-size: 0.95rem; color: var(--text-soft); }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* one column: the check above the shop, the buttons under it */
@media (max-width: 900px) {
  .play {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "ticket" "scene" "controls";
    grid-template-rows: auto;
    gap: 0.6rem;
  }
  .ticket { transform: none; }
  canvas { aspect-ratio: 4 / 3; max-height: calc(100svh - 21rem); min-height: 16rem; }
  .controls { flex-wrap: nowrap; }
  .controls > * { flex: 1 1 auto; }
  .serve { width: auto; flex: 1 1 8rem; }
  .toppings { width: auto; flex: 2 1 12rem; }
}

@media (max-width: 760px) {
  .pizzeria { padding-top: 0.4rem; }
  .top { gap: 0.25rem 1rem; margin-bottom: 0.5rem; }
  .levels { width: 100%; }
  .levels button { flex: 1; padding: 0.25rem 0.4rem; font-size: 0.9rem; }
  .ticket { padding: 0.4rem 0.8rem 0.5rem; }
  .ticket::before { top: 1.85rem; }
  .ticket-head { margin-bottom: 0.35rem; font-size: 1rem; line-height: 1.3; }
  .order { font-size: 1.15rem; line-height: 1.45; }
  .hint { font-size: 1rem; line-height: 1.6; min-height: 3.2em; margin-top: 0.25rem; }
  canvas { aspect-ratio: 1 / 1; max-height: calc(100svh - 24rem); min-height: 15rem; }
  .controls { flex-wrap: wrap; }
  .toppings button { padding: 0.3rem 0.35rem; font-size: 0.95rem; white-space: nowrap; }
  .toppings button::before { margin-right: 0.3em; }
  .below { margin-top: 0.7rem; gap: 0.6rem 1rem; }
  .progress { grid-template-columns: repeat(8, 1fr); width: 100%; }
  .progress li { height: 1.9rem; }
  .tally { margin: 0; }
  .again { margin-left: auto; }
  .keys, .about { font-size: 1rem; }
}

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