/* Layered product builder (v2) — assets/js/product-builder.js.
 * An edge-to-edge stage in a faint tone with no picture behind the food, only
 * a soft shadow under it; the options run below in a sheet (white, or dark with
 * the theme's dark mode), and a tray of round ingredient chips replaces the
 * plain option list. */
.code-order-options-drawer-body { --co-drawer-pad: 24px; scroll-timeline: --co-drawer block; }
@media (max-width: 600px) { .code-order-options-drawer-body { --co-drawer-pad: 16px; } }

.co-builder {
  --co-shadow: rgba(20, 14, 8, .22);
  --co-shadow-deep: rgba(20, 14, 8, .26);
  --co-ground: rgba(20, 14, 8, .2);
  position: relative;
  margin: calc(-1 * var(--co-drawer-pad, 24px)) calc(-1 * var(--co-drawer-pad, 24px)) 6px;
  aspect-ratio: 1 / 1;
  /* At most a third of the screen on opening; the food sits in a centred square (product-builder.js). */
  max-height: min(33.3vh, 520px); max-height: min(33.3svh, 520px);
  width: calc(100% + 2 * var(--co-drawer-pad, 24px));
  overflow: hidden; overflow: clip;
  /* Sticky with only its compact part left in view (--co-room, set by product-builder.js):
   * it never changes size, so scrolling never lays out the drawer. */
  position: sticky; top: calc(-1 * var(--co-drawer-pad, 24px) - var(--co-room, 0px)); z-index: 5;
  /* A faint tone of its own, so the white (or dark) sheet of options below reads as a sheet. */
  background: linear-gradient(#f8f6f3, #f2efea);
}
html[data-theme="dark"] .co-builder {
  --co-shadow: rgba(0, 0, 0, .45);
  --co-shadow-deep: rgba(0, 0, 0, .6);
  --co-ground: rgba(0, 0, 0, .55);
  background: linear-gradient(rgba(0, 0, 0, .28), rgba(0, 0, 0, .2)), var(--bg-card, #141416);
}
.co-builder.is-compact { cursor: pointer; }
.co-builder__frame { position: absolute; left: 0; right: 0; top: 0; height: 100%; transform-origin: 50% 0; z-index: 1; will-change: transform; }
/* The options run in a sheet: its rounded top edge and handle sit at the
 * bottom of the stage, so the list scrolls into a sheet, as in an app. */
.co-builder::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 21px; z-index: 3;
  background: #fff; border-radius: 20px 20px 0 0;
  box-shadow: 0 -8px 20px -12px rgba(20, 14, 8, .28);
  pointer-events: none;
}
.co-builder::before {
  content: ""; position: absolute; left: 50%; bottom: 9px; z-index: 4;
  width: 36px; height: 4px; margin-left: -18px; border-radius: 2px;
  background: rgba(20, 14, 8, .16);
  pointer-events: none;
}
html[data-theme="dark"] .co-builder::after { background: var(--bg-card, #141416); box-shadow: 0 -8px 20px -12px rgba(0, 0, 0, .8); }
html[data-theme="dark"] .co-builder::before { background: rgba(255, 255, 255, .2); }
/* Scroll-driven where the browser has it: the food shrinks in place with the
 * scroll, on the compositor, frame for frame, with no script in between. */
.co-builder.is-timeline .co-builder__frame {
  animation: co-dock-fit linear both;
  animation-timeline: --co-drawer;
  animation-range: 0 var(--co-room);
}
@keyframes co-dock-fit { to { transform: translateY(var(--co-room)) scale(var(--co-k)); } }
/* Once the stage is compact the drawer's title becomes the product's name (product-builder.js). */
.code-order-options-drawer-header { position: relative; }
.code-order-options-drawer-title { transition: opacity .2s ease, transform .25s cubic-bezier(.22, 1, .36, 1); }
.co-drawer-name {
  position: absolute; left: 24px; right: 72px; top: 50%;
  font-size: 17px; font-weight: 700; letter-spacing: -.01em; line-height: 1.3;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  opacity: 0; transform: translateY(calc(-50% + 8px));
  transition: opacity .2s ease, transform .25s cubic-bezier(.22, 1, .36, 1);
  pointer-events: none;
}
@media (max-width: 600px) { .co-drawer-name { left: 16px; right: 64px; } }
.co-docked .code-order-options-drawer-title { opacity: 0; transform: translateY(-8px); }
.co-docked .co-drawer-name { opacity: 1; transform: translateY(-50%); }
.co-builder__stage { position: absolute; inset: 0; z-index: 2; }
/* The ground shadow under a stack; a dish seen from above casts its own (base layer). */
.co-builder__shadow {
  position: absolute; left: 50%; bottom: 5%; z-index: 1;
  width: 74%; height: 10%;
  transform: translateX(-50%);
  border-radius: 50%;
  background: radial-gradient(closest-side, var(--co-ground), transparent);
  pointer-events: none;
}
.co-builder[data-mode="top"] .co-builder__shadow { display: none; }
.co-builder .co-builder__layer {
  position: absolute; left: 50%; display: block;
  width: 78%; margin: 0;
  transform: translateX(-50%);
  /* 2.5D parallax: product-builder.js sets the tilt (--co-tx/--co-ty) and each layer's depth */
  translate: calc(var(--co-tx, 0) * var(--co-depth, 0) * 2.4%) calc(var(--co-ty, 0) * var(--co-depth, 0) * 1.4%);
  /* product-builder.js opens the stack for a new layer (is-lift) and eases it shut (is-settle). */
  transition: bottom var(--co-bt, .3s) var(--co-be, cubic-bezier(.22, 1, .36, 1)) var(--co-bd, 0s), opacity .2s ease, translate .35s cubic-bezier(.22, 1, .36, 1);
  will-change: transform, bottom;
  user-select: none; -webkit-user-drag: none;
  /* Each layer rests on the one below: a soft contact shadow. */
  filter: drop-shadow(0 5px 6px var(--co-shadow));
}
.co-builder__turn { position: relative; display: block; transform-origin: 50% 50%; }
.co-builder .co-builder__pic { display: block; width: 100%; height: auto; max-width: none; margin: 0; border-radius: 0; }
.co-builder .co-builder__light {
  position: absolute; inset: 0; width: 100%; height: 100%; max-width: none; margin: 0; border-radius: 0;
  mix-blend-mode: soft-light; opacity: 0; pointer-events: none;
  transition: opacity .35s ease-out;
}
.co-builder[data-mode="top"] .co-builder__layer {
  filter: drop-shadow(0 2px 3px var(--co-shadow));
  top: 50%; bottom: auto !important; width: 86%;
  transform: translate(-50%, -50%);
}
.co-builder[data-mode="top"] .co-builder__layer[data-key="base"] { filter: drop-shadow(0 14px 22px var(--co-shadow-deep)); }
.co-builder .co-builder__layer.is-lift { --co-bt: .2s; --co-be: cubic-bezier(.22, 1, .36, 1); }
.co-builder .co-builder__layer.is-settle { --co-bt: .45s; --co-be: cubic-bezier(.22, 1, .36, 1); }
/* A new layer eases down into the gap the stack opened for it and settles. */
.co-builder .co-builder__layer.is-new { animation: co-builder-in .5s cubic-bezier(.22, 1, .36, 1) .1s both; }
/* A topping is scattered from above onto the pizza. */
.co-builder[data-mode="top"] .co-builder__layer.is-new { animation: co-builder-scatter .48s cubic-bezier(.22, 1, .36, 1) both; }
.co-builder .co-builder__layer.is-gone { animation: co-builder-out .26s cubic-bezier(.4, 0, 1, 1) both; }
.co-builder[data-mode="top"] .co-builder__layer.is-gone { animation: co-builder-scatter-out .22s cubic-bezier(.4, 0, 1, 1) both; }
@keyframes co-builder-in {
  0% { transform: translate(-50%, -55%) scale(.94); opacity: 0; }
  55% { opacity: 1; }
  80% { transform: translate(-50%, 2%) scale(1.01, .97); }
  100% { transform: translate(-50%, 0) scale(1); opacity: 1; }
}
@keyframes co-builder-out {
  to { transform: translate(-50%, -18%) scale(.9); opacity: 0; }
}
/* Seen from above, a topping that falls is a little larger and casts a wide,
 * soft shadow; it is solid at once (no see-through wash over the pizza) and
 * lands as it shrinks to size and its shadow tightens. */
@keyframes co-builder-scatter {
  0% { transform: translate(-50%, -50%) scale(1.08) rotate(-4deg); opacity: 0; filter: drop-shadow(0 16px 14px var(--co-shadow)); }
  22% { opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(1) rotate(0); opacity: 1; filter: drop-shadow(0 2px 3px var(--co-shadow)); }
}
@keyframes co-builder-scatter-out {
  to { transform: translate(-50%, -50%) scale(1.06) rotate(3deg); opacity: 0; filter: drop-shadow(0 14px 12px transparent); }
}

/* The product line under the stage stays the drawer's own. */
.co-builder + .code-order-options-product { margin-top: 0; }

/* ── Ingredient tray ───────────────────────────────────── */
.co-has-tray > :not(.code-order-addon-label):not(.co-tray) { display: none !important; }
.co-tray {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(78px, 1fr));
  gap: 14px 8px;
  margin: 10px 0 4px;
}
.co-chip { position: relative; display: flex; flex-direction: column; align-items: center; }
.co-chip__add {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  width: 100%; padding: 0; margin: 0;
  background: none; border: 0; cursor: pointer; color: inherit; font: inherit; text-align: center;
  -webkit-tap-highlight-color: transparent;
}
.co-chip__pic {
  position: relative; display: grid; place-items: center;
  width: 64px; height: 64px; border-radius: 50%;
  background: radial-gradient(circle at 50% 35%, #fbf9f6, #ece6dd);
  box-shadow: inset 0 0 0 1px rgba(70, 45, 20, .08), 0 3px 8px rgba(70, 45, 20, .12);
  transition: transform .18s cubic-bezier(.22, 1, .36, 1), box-shadow .18s ease;
}
html[data-theme="dark"] .co-chip__pic {
  background: radial-gradient(circle at 50% 35%, #2c2f40, #171923);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .06), 0 4px 10px rgba(15, 17, 24, .18);
}
.co-chip__pic img { width: 82%; height: 82%; object-fit: contain; margin: 0; border-radius: 0; filter: drop-shadow(0 2px 2px rgba(0, 0, 0, .35)); }
.co-chip__add:active .co-chip__pic { transform: scale(.92); }
.co-chip__add:focus-visible .co-chip__pic { outline: 2px solid var(--code-order-primary, #6f00ff); outline-offset: 3px; }
.co-chip.is-on .co-chip__pic { box-shadow: 0 0 0 2px var(--code-order-primary, #6f00ff), 0 6px 14px rgba(var(--code-order-primary-rgb, 111, 0, 255), .3); }
.co-chip__count {
  position: absolute; top: -3px; right: -3px;
  min-width: 22px; height: 22px; padding: 0 5px; border-radius: 11px;
  display: none; place-items: center;
  background: var(--code-order-primary, #6f00ff); color: #fff;
  font-size: 11px; font-weight: 700; line-height: 22px;
}
.co-chip.is-on .co-chip__count { display: grid; }
.co-chip__name {
  font-size: 12px; font-weight: 600; line-height: 1.2; max-width: 88px;
  overflow-wrap: break-word; hyphens: auto;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.co-chip__price { font-size: 11px; opacity: .65; }
.co-chip__minus {
  position: absolute; top: 40px; left: calc(50% - 38px);
  width: 24px; height: 24px; padding: 0; border-radius: 50%;
  display: none; place-items: center;
  background: #fff; color: #111; border: 0;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .25);
  font-size: 16px; line-height: 1; cursor: pointer;
}
.co-chip.is-on .co-chip__minus { display: grid; }
.co-chip.is-full .co-chip__pic { animation: co-chip-full .32s ease; }
@keyframes co-chip-full {
  25% { transform: translateX(-3px); }
  75% { transform: translateX(3px); }
}

@media (prefers-reduced-motion: reduce) {
  .co-builder .co-builder__layer { transition: none; }
  .co-builder .co-builder__layer.is-new, .co-builder .co-builder__layer.is-gone, .co-chip.is-full .co-chip__pic { animation: none; }
}
