/* Winkeltje: home tile, the menu picture, the shop (a shelf with the thing and its price tag, the
   shopkeeper with a speech bubble), the counter with the till and what lies on it, the purse or
   till, and Betalen. The menu reuses Klok kijken's round grid
   (klok.css); shared look lives in css/style.css. Every coin, note and button is 48 px or more. */

/* ---------- home tile and menu ---------- */
#tile-winkel .tile-art { display: flex; align-items: center; justify-content: center; }
.wk-tile-svg { width: 100%; height: 100%; max-width: 104px; display: block; overflow: visible; }
.wk-menu-art { display: flex; justify-content: center; margin: 0 0 8px; }
.wk-menu-art svg { width: 180px; height: auto; display: block; }
.wk-ov { display: inline-flex; width: 170px; height: 117px; }
.wk-ov svg { width: 100%; height: 100%; }
.wk-face, .wk-unit { font-family: var(--bz-font); }

/* ---------- the play screen ---------- */
#screen-winkel { --wk-coin: 56px; --wk-item: 56px; }
.wk-hud { gap: 10px; }
#wk-stage {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 620px);
  grid-template-rows: auto auto minmax(0, 1fr) auto auto auto;
  --wk-gap: 8px;
  grid-template-areas: "shop" "counter" "." "cap" "wallet" "side";
  justify-content: center;
  gap: var(--wk-gap);
  padding: 2px 12px 10px;
}
/* the two halves only group the parts for the sideways layout; the grid places the parts */
.wk-col { display: contents; }
.wk-shop { grid-area: shop; }
.wk-counter { grid-area: counter; }
.wk-wallet-cap { grid-area: cap; }
.wk-wallet { grid-area: wallet; }
.wk-side { grid-area: side; }

/* the shop: an awning over a wall with a shelf (the things and their price tags) and the shopkeeper,
   who stands right behind the counter (the shop sits on the counter's top) and talks in a bubble */
.wk-shop {
  position: relative;
  flex: none;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 2px;
  margin-bottom: calc(-1 * var(--wk-gap));
  padding: 15px 10px 0;
  border-radius: 20px 20px 0 0;
  background: #fff;
  text-align: center;
}
.wk-shop::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 10px;
  border-radius: 20px 20px 0 0;
  background: repeating-linear-gradient(90deg, #ff8a3d 0 22px, #fff4ea 22px 44px);
  border-bottom: 2px solid #e0a37a;
}
/* the shelf: a wooden plank under the things */
.wk-shelf {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 0 6px 3px;
  border-bottom: 6px solid #c98b52;
  border-radius: 0 0 3px 3px;
  box-shadow: 0 3px 0 #ecd9bf;
}
/* the shopkeeper and what it says */
.wk-desk { display: flex; align-items: flex-end; justify-content: flex-end; gap: 10px; padding-top: 4px; }
.wk-bubble {
  position: relative;
  flex: 0 1 auto;
  min-width: 0;
  align-self: center;
  margin: 0 0 6px auto;
  padding: 6px 10px;
  border: 3px solid #d9b98f;
  border-radius: 16px;
  background: #fffdf8;
  text-align: left;
}
.wk-bubble::before,
.wk-bubble::after {
  content: "";
  position: absolute;
  top: 50%;
  width: 0;
  height: 0;
  border: 9px solid transparent;
}
.wk-bubble::before { right: -21px; margin-top: -9px; border-left: 12px solid #d9b98f; }
.wk-bubble::after { right: -16px; margin-top: -7px; border-width: 7px; border-left: 10px solid #fffdf8; }
.wk-say { margin: 0; min-height: 2.5em; display: flex; align-items: center; font-size: 1rem; font-weight: 800; color: var(--bz-ink); line-height: 1.25; text-wrap: pretty; }
.wk-keeper { flex: none; display: block; width: 72px; height: 79px; }
.wk-keeper svg { width: 100%; height: 100%; display: block; overflow: visible; }
.wk-keeper.happy svg { transform-origin: 50% 100%; animation: wk-bob 1.5s ease-in-out infinite alternate; }
.wk-goods { display: flex; justify-content: center; align-items: center; flex-wrap: wrap; gap: 6px 14px; }
.wk-good { display: flex; align-items: center; gap: 6px; }
.wk-good.sold .wk-bag { animation: wk-bag 0.9s ease-out; }
.wk-item-art { width: var(--wk-item); height: var(--wk-item); display: block; flex: none; }
.wk-tag {
  position: relative;
  padding: 2px 10px 2px 16px;
  border: 3px solid var(--bz-brand);
  border-radius: 10px 14px 14px 10px;
  background: #fff;
  color: var(--bz-brand-dark);
  font: 900 1.5rem/1.15 var(--bz-font);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.wk-tag::before { content: ""; position: absolute; left: 5px; top: 50%; width: 6px; height: 6px; margin-top: -3px; border-radius: 50%; background: var(--bz-brand); }
/* two things side by side on the shelf */
.wk-goods.n2 { flex-wrap: nowrap; gap: 6px 12px; }
.wk-goods.n2 .wk-good { gap: 4px; }
.wk-goods.n2 .wk-item-art { width: calc(var(--wk-item) * 0.8); height: calc(var(--wk-item) * 0.8); }
.wk-goods.n2 .wk-tag { font-size: 1.2rem; }
.wk-sum-side { display: none; }
.wk-sum { margin: 0; font: 900 1.45rem/1.15 var(--bz-font); color: var(--bz-brand-dark); font-variant-numeric: tabular-nums; white-space: nowrap; }
.wk-sum[hidden], .wk-upline[hidden], .wk-pips[hidden], .wk-wallet-cap[hidden] { display: none; }
.wk-paid { display: flex; flex-direction: column; align-items: center; gap: 0; }
.wk-paid .wk-note { width: 72px; height: 40px; display: block; }
.wk-paid .wk-coin { width: 44px; height: 44px; display: block; }
.wk-paid-word { font-size: 0.85rem; font-weight: 800; color: var(--bz-ink-soft); }

/* a thing to pick in a budget question */
[data-ask="basket"] .wk-goods { gap: 6px; }
button.wk-good {
  flex-direction: column;
  gap: 2px;
  min-width: 64px;
  min-height: 64px;
  padding: 4px 4px 6px;
  border: 3px solid transparent;
  border-radius: 16px;
  background: #faf5ee;
  cursor: pointer;
  touch-action: manipulation;
  font: inherit;
  color: inherit;
}
button.wk-good .wk-item-art { width: 48px; height: 48px; }
button.wk-good .wk-tag { font-size: 1rem; padding: 1px 6px 1px 12px; border-width: 2px; }
button.wk-good .wk-tag::before { left: 3px; }
button.wk-good.picked { background: var(--bz-group-tint); border-color: var(--bz-group-acc); }
button.wk-good.over { border-color: var(--bz-accent-dark); background: #fde7dc; }
button.wk-good.right { border-color: #3fb35f; background: #dcf7d4; }
button.wk-good:focus-visible { outline: 4px solid var(--bz-focus); outline-offset: 2px; }

/* the counter: a wooden top with what lies on it */
.wk-counter {
  position: relative;
  min-height: calc(var(--wk-coin) * 2 + 54px);
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 6px 10px 10px;
  border-radius: 18px;
  background: #f1d6b0;
  box-shadow: inset 0 6px 0 #dcb383, 0 4px 0 #b9864f;
  transition: box-shadow 0.15s;
  z-index: 1;
}
[data-ask="basket"] .wk-counter { min-height: calc(var(--wk-coin) + 54px); }
.wk-counter.drop { box-shadow: inset 0 6px 0 #dcb383, 0 4px 0 #b9864f, 0 0 0 4px var(--bz-group-acc); }
.wk-counter.right { background: #dcf3cf; box-shadow: inset 0 6px 0 #b4dea0, 0 4px 0 #6fae5d; }
.wk-counter-head { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; min-height: 26px; padding-top: 4px; }
.wk-till-art { flex: none; display: block; width: 38px; height: 32px; }
.wk-till-art svg { width: 100%; height: 100%; display: block; }
.wk-total { font-size: 1.05rem; font-weight: 900; color: #5a3410; font-variant-numeric: tabular-nums; white-space: nowrap; }
.wk-pips { display: flex; gap: 5px; margin-left: auto; }
.wk-pip { width: 16px; height: 16px; border-radius: 50%; border: 3px solid #b98e22; background: #fff; }
.wk-pip.on { background: #ecc85e; }
.wk-pip.over { border-color: var(--bz-accent-dark); border-style: dashed; background: #fde7dc; }
.wk-upline { margin: 0; font-size: 0.95rem; font-weight: 800; color: #5a3410; font-variant-numeric: tabular-nums; line-height: 1.25; text-align: center; }
.wk-laid { flex: 1; display: flex; flex-wrap: wrap; justify-content: center; align-content: flex-start; gap: 6px; min-height: var(--wk-coin); }

/* a coin or note: on the counter, in a pile, in the purse, or dragged */
.wk-piece, .wk-stack {
  position: relative;
  width: var(--wk-coin);
  height: var(--wk-coin);
  flex: none;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  font: inherit;
}
.wk-piece.note, .wk-stack.note, .wk-ghost.note { width: calc(var(--wk-coin) * 1.6); }
.wk-piece svg, .wk-stack svg { width: 100%; height: 100%; display: block; pointer-events: none; }
.wk-layer { position: absolute; inset: 4px 6px 6px 4px; }
.wk-layer.l1 { transform: translate(3px, 3px); }
.wk-layer.l2 { transform: translate(6px, 5px); }
.wk-pile .wk-layer.l0 { z-index: 2; }
.wk-pile .wk-layer.l1 { z-index: 1; }
.wk-piece:not(.wk-pile) .wk-layer { inset: 0; }
.wk-count {
  position: absolute;
  right: -2px;
  bottom: -2px;
  z-index: 3;
  min-width: 22px;
  padding: 1px 5px;
  border-radius: var(--bz-radius-pill);
  background: var(--bz-ink);
  color: #fff;
  font-size: 0.8rem;
  font-weight: 900;
  line-height: 1.3;
  text-align: center;
  pointer-events: none;
}
.wk-piece.over { border-radius: 50%; box-shadow: 0 0 0 3px var(--bz-accent-dark); animation: wk-lift 0.5s ease-out; background: rgba(253, 231, 220, 0.7); }
.wk-piece.note.over { border-radius: 8px; }
.wk-piece.right { border-radius: 50%; box-shadow: 0 0 0 3px #3fb35f; }
.wk-piece.note.right { border-radius: 8px; }
.wk-ghost {
  position: relative;
  width: var(--wk-coin);
  height: var(--wk-coin);
  flex: none;
  border-radius: 50%;
  outline: 3px dashed #9a6a3a;
  outline-offset: -2px;
  opacity: 0.5;
}
.wk-ghost.note { border-radius: 8px; }
/* 6-7 and 8-10: a small ghost per coin, first on the counter (always in sight) */
.wk-ghost.wk-pile { order: -1; width: calc(var(--wk-coin) * 0.8); height: calc(var(--wk-coin) * 0.8); align-self: center; }
.wk-ghost.wk-pile.note { width: calc(var(--wk-coin) * 1.25); }
.wk-ghost svg { width: 100%; height: 100%; display: block; }
.wk-piece:focus-visible, .wk-stack:focus-visible { outline: 4px solid var(--bz-focus); outline-offset: 2px; border-radius: 12px; }
.wk-basket-item { border-radius: 14px; background: #fff; }
.wk-basket-item svg { padding: 4px; }
.wk-basket-item.over { border-radius: 14px; }
.wk-basket-item.right { border-radius: 14px; }

/* the purse (or the till): a stack per coin and note, with how many are left */
.wk-wallet-cap { margin: 0; font-size: 0.9rem; font-weight: 800; color: var(--bz-ink-soft); text-align: center; }
.wk-wallet {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  padding: 6px;
  border-radius: 18px;
  background: var(--bz-group-tint);
}
.wk-stack { border-radius: 14px; background: #fff; box-shadow: 0 3px 0 #e2d3bb; }
.wk-stack svg { padding: 3px; }
.wk-stack:active { transform: translateY(2px); box-shadow: 0 1px 0 #e2d3bb; }
.wk-stack:disabled { opacity: 0.35; cursor: default; transform: none; }
.wk-stack.still { background: none; box-shadow: none; cursor: default; }
.wk-drag {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 60;
  width: calc(var(--wk-coin) * 1.1);
  height: calc(var(--wk-coin) * 1.1);
  pointer-events: none;
  filter: drop-shadow(0 6px 6px rgba(40, 36, 92, 0.3));
}
.wk-drag.note { width: calc(var(--wk-coin) * 1.75); }
.wk-drag svg { width: 100%; height: 100%; display: block; }

/* Betalen and the dots */
.wk-side { display: flex; align-items: center; gap: 10px; }
.btn.big.wk-pay { flex: 0 0 auto; width: min(46%, 220px); min-width: 0; min-height: 56px; padding: 0 12px; font-size: 1.35rem; }
.btn.big.wk-pay:disabled { opacity: 0.45; }
.wk-progress { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
#wk-stage.happy .wk-bubble { border-color: #8fd16e; }
#wk-stage.happy .wk-bubble::before { border-left-color: #8fd16e; }

@keyframes wk-lift { 0% { transform: translateY(0); } 40% { transform: translateY(-8px); } 100% { transform: translateY(0); } }
/* a slow, small bob of joy; no flashing */
@keyframes wk-bob { from { transform: translateY(0) rotate(0); } to { transform: translateY(-5px) rotate(-2deg); } }
@keyframes wk-bag { from { transform: translateY(-8px) scale(0.9); opacity: 0.4; } to { transform: none; opacity: 1; } }

/* tall phones and tablets: bigger coins */
@media (min-height: 780px) and (min-width: 380px) {
  #screen-winkel { --wk-coin: 64px; --wk-item: 68px; }
  .wk-tag { font-size: 1.8rem; }
  .wk-counter { min-height: calc(var(--wk-coin) * 3 + 70px); }
  [data-ask="basket"] .wk-counter { min-height: calc(var(--wk-coin) * 2 + 54px); }
}

/* narrow phones */
@media (max-width: 359px) {
  #screen-winkel { --wk-coin: 50px; --wk-item: 48px; }
  .wk-tag { font-size: 1.3rem; }
  .wk-sum { font-size: 1.25rem; }
  button.wk-good { flex-direction: row; width: calc(50% - 3px); min-width: 0; justify-content: center; gap: 4px; }
  .wk-goods.n2 { gap: 6px 8px; }
  .wk-goods.n2 .wk-tag { font-size: 1.05rem; padding: 2px 7px 2px 13px; }
  .wk-goods.n2 .wk-tag::before { left: 4px; }
}

/* very short phones (320x568): a smaller shopkeeper and till */
@media (max-height: 600px) and (orientation: portrait) {
  .wk-shop { padding-top: 13px; }
  .wk-keeper { width: 52px; height: 57px; }
  .wk-till-art { width: 30px; height: 25px; }
  .wk-sum { font-size: 1.1rem; }
  .wk-shelf { padding-bottom: 2px; border-bottom-width: 5px; }
}

/* short phones: smaller shop and counter, so the purse keeps its room */
@media (max-height: 700px) {
  #screen-winkel { --wk-coin: 50px; --wk-item: 46px; }
  .wk-shop { padding: 14px 10px 0; }
  .wk-desk { gap: 8px; padding-top: 2px; }
  .wk-keeper { width: 58px; height: 64px; }
  .wk-say { font-size: 0.9rem; }
  .wk-bubble { padding: 4px 8px; margin-bottom: 4px; }
  .wk-tag { font-size: 1.25rem; }
  .wk-sum { font-size: 1.2rem; }
  #wk-stage { --wk-gap: 6px; padding-bottom: 6px; }
  .wk-col { gap: 6px; }
  .btn.big.wk-pay { min-height: 50px; font-size: 1.2rem; }
  .wk-counter { padding: 4px 8px 8px; min-height: calc(var(--wk-coin) + 64px); }
  .wk-counter-head { min-height: 22px; }
  .wk-wallet-cap { display: none; }
  .wk-paid .wk-note { width: 58px; height: 32px; }
  .wk-paid-word { font-size: 0.78rem; }
  .wk-upline { font-size: 0.88rem; }
}

/* sideways phones: the bar on the left (like Kangoeroe); the shop over the whole width (the shelf
   left, the shopkeeper right, over the counter), the purse and Betalen left, the counter right */
@media (orientation: landscape) and (max-height: 520px) {
  #screen-winkel { flex-direction: row; --wk-coin: 50px; --wk-item: 44px; }
  .wk-hud { flex-direction: column; justify-content: space-between; padding: 10px 6px 10px 12px; max-width: 120px; }
  .wk-hud .hud-mid { flex: 0; }
  .wk-hud .hud-level { white-space: normal; font-size: 0.92rem; }
  .wk-hud .btn.icon { width: 54px; height: 54px; }
  #wk-stage {
    grid-template-columns: minmax(236px, 1.15fr) minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr) auto;
    grid-template-areas: "shop shop" "wallet counter" "side counter";
    gap: 6px 10px;
    --wk-gap: 6px;
    padding: 6px 12px 6px 4px;
  }
  .wk-side { justify-content: space-between; gap: 6px; }
  .wk-progress { display: contents; }
  #wk-dots { flex: none; gap: 4px; }
  #wk-dots .klok-dot { width: 9px; height: 9px; }
  .wk-paid { display: none; }
  .wk-goods { flex-wrap: nowrap; }
  [data-ask="basket"] .wk-goods { flex-wrap: wrap; }
  .wk-wallet-cap { display: none; }
  .wk-laid { min-height: 0; overflow-y: auto; }
  .wk-upline { font-size: 0.85rem; }
  .wk-shop { flex-direction: row; align-items: flex-end; gap: 12px; padding: 12px 8px 0; }
  .wk-shelf { flex: 0 1 auto; min-width: 0; align-self: flex-end; margin-bottom: 4px; }
  .wk-desk { flex: 1 1 0; min-width: 0; padding-top: 0; gap: 8px; }
  .wk-keeper { width: 52px; height: 57px; }
  .wk-bubble { padding: 3px 8px; margin-bottom: 4px; }
  .wk-say { min-height: 0; font-size: 0.85rem; line-height: 1.2; }
  .wk-tag { font-size: 1.15rem; }
  .wk-sum { font-size: 1.05rem; }
  .wk-counter, [data-ask="basket"] .wk-counter { min-height: 0; padding: 4px 8px 8px; }
  .wk-wallet { align-content: center; }
  .wk-piece.note, .wk-stack.note, .wk-ghost.note { width: calc(var(--wk-coin) * 1.45); }
  .btn.big.wk-pay { width: auto; flex: 1 1 auto; min-height: 50px; padding: 0 8px; font-size: 1.05rem; }
  [data-ask="basket"] .wk-shelf { width: 236px; }
  /* two things: small on the shelf, their sum on the counter */
  .wk-goods.n2 .wk-item-art { width: 34px; height: 34px; }
  .wk-goods.n2 .wk-tag { font-size: 0.95rem; padding: 1px 6px 1px 12px; border-width: 2px; }
  .wk-goods.n2 .wk-tag::before { left: 3px; }
  [data-kind="two"] .wk-shelf .wk-sum { display: none; }
  [data-kind="two"] .wk-sum-side { display: block; font-size: 1.05rem; text-align: center; }
  button.wk-good { flex-direction: row; width: calc(50% - 3px); min-width: 0; min-height: 50px; padding: 1px 2px; justify-content: center; gap: 2px; }
  button.wk-good .wk-item-art { width: 40px; height: 40px; }
  button.wk-good .wk-tag { font-size: 0.85rem; }
}

/* narrow sideways phones (568x320): the counter is too narrow for the till beside its total */
@media (orientation: landscape) and (max-height: 520px) and (max-width: 700px) {
  .wk-till-art { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .wk-piece.over, .wk-good.sold .wk-bag, .wk-keeper.happy svg { animation: none; }
}
