/* Create your pizza: layout and controls. */

.builder-intro { padding-top: var(--s-2); padding-bottom: var(--s-6); }

.builder {
  display: grid;
  gap: var(--s-6) var(--s-8);
  padding-bottom: var(--s-8);
}
@media (min-width: 1024px) {
  .builder { grid-template-columns: minmax(0, 6fr) minmax(0, 5fr); align-items: start; }
  .builder-aside { position: sticky; top: var(--s-5); }
}

/* ---------- stage ---------- */

.stage { position: relative; margin-inline: auto; width: min(100%, max(300px, calc(100vh - 400px)), 560px); }
.stage-pizza { aspect-ratio: 1; }
.stage-note { position: absolute; right: -2%; top: 2%; margin: 0; pointer-events: none; }
.stage-note .t-hand { font-size: 28px; }
.stage-note .t-hand.swap { animation: note-in .5s var(--spring); }
@keyframes note-in { from { opacity: 0; transform: rotate(-3deg) translateY(6px); } }
.stage-caption { text-align: center; margin: var(--s-3) 0 0; font-size: 14px; color: var(--pietra); font-variant-numeric: tabular-nums; }

/* ---------- half & half ---------- */
/* Each half of the preview is a button. The chosen half gets a filled tag and a dotted outline,
   the other half is veiled: shape and contrast, not colour alone. */
.half-picker { position: absolute; inset: 0; display: flex; }
.half-picker[hidden] { display: none; }
.half-btn { position: relative; flex: 1; padding: 0; border: 0; background: transparent; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.half-btn--left { border-radius: 999px 0 0 999px; }
.half-btn--right { border-radius: 0 999px 999px 0; }
.half-btn:hover { background: rgba(23, 23, 23, .035); }
.half-btn:focus-visible { outline: 2px solid var(--inchiostro); outline-offset: -4px; }
.half-tag {
  position: absolute; bottom: 5%;
  display: grid; place-items: center; width: 32px; height: 32px;
  border: 1px solid rgba(23, 23, 23, .3); border-radius: 50%;
  background: var(--farina); color: var(--pietra); box-shadow: var(--shadow-raised);
  transition: transform .35s var(--spring);
}
.half-btn--left .half-tag { left: 5%; }
.half-btn--right .half-tag { right: 5%; }
.half-tag svg { width: 15px; height: 15px; }
.half-btn:active .half-tag { transform: scale(.9); }
.half-btn[aria-pressed='true'] .half-tag { background: var(--cuore); border-color: var(--cuore); color: #FFFFFF; transform: scale(1.08); }
.half-overlay > * { animation: fade-in .25s ease; }
.half-veil { fill: var(--farina); opacity: .58; }
.half-outline { fill: none; stroke: var(--cuore); stroke-width: 1.6; stroke-dasharray: 1 6; stroke-linecap: round; }
.half-targets { display: flex; justify-content: center; margin-top: var(--s-3); }
.half-targets[hidden] { display: none; }
.seg--targets span { min-height: 40px; }
.target-status { display: flex; align-items: center; gap: var(--s-2); margin: 0 0 var(--s-4); font-size: 14px; color: var(--inchiostro); }
.target-status svg { width: 14px; height: 14px; flex: none; }

/* ---------- summary ---------- */

.summary { margin-top: var(--s-5); padding: var(--s-5); background: var(--raised); border: 1px solid var(--rule); border-radius: 3px; box-shadow: var(--shadow-book); }
.summary-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); margin-bottom: var(--s-2); }
.summary-lines { list-style: none; margin: 0; padding: 0; max-height: 260px; overflow-y: auto; }
.summary-lines.is-scrollable { -webkit-mask-image: linear-gradient(to bottom, #000 calc(100% - 28px), transparent); mask-image: linear-gradient(to bottom, #000 calc(100% - 28px), transparent); padding-bottom: 20px; }
.summary-lines li { display: flex; align-items: center; gap: var(--s-3); padding: 6px 0; font-size: 14px; line-height: 1.35; border-bottom: 1px dotted var(--rule); }
.summary-lines li:last-child { border-bottom: 0; }
.summary-lines .what { flex: 1; min-width: 0; }
.summary-lines .what small { display: block; color: var(--pietra); font-size: 12px; }
.summary-lines .pending { color: var(--pietra); font-style: italic; }
.summary-lines .t-price { font-size: 14px; }
.summary-lines .remove { width: 26px; height: 26px; flex: none; }
.summary-lines .remove svg { width: 10px; height: 10px; }
.summary-total { display: flex; align-items: baseline; justify-content: space-between; margin-top: var(--s-3); padding-top: var(--s-3); border-top: 1px solid var(--inchiostro); }
.summary-total .t-price { font-size: 22px; }
.price-tick { display: inline-block; }
.price-tick.tick { animation: tick .45s var(--spring); }
@keyframes tick { 40% { transform: scale(1.12); } }

@media (max-width: 1023px) {
  .summary-slot { display: none; }
}

/* ---------- stepper ---------- */

.stepper { display: flex; align-items: center; list-style: none; margin: 0 0 var(--s-6); padding: 0; }
.stepper li { display: flex; align-items: center; flex: 1; min-width: 0; }
.stepper li:last-child { flex: none; }
.stepper li:has([aria-current='step']) { flex: 1 0 auto; }
.stepper li:not(:last-child)::after { content: ''; flex: 1; min-width: 12px; height: 1px; margin: 0 var(--s-2); background: var(--rule); }
.stepper li.done:not(:last-child)::after { background: var(--inchiostro); }
.step-btn {
  display: inline-flex; align-items: center; gap: var(--s-2);
  min-height: 44px; padding: 0; border: 0; background: none; cursor: pointer;
  color: var(--inchiostro); font: 500 11px/1 var(--font-sans); letter-spacing: .16em; text-transform: uppercase;
  transition: transform .3s var(--spring), opacity .2s ease;
}
.step-btn:active { transform: scale(.95); }
.step-btn[disabled] { cursor: not-allowed; color: var(--pietra); opacity: .55; }
.step-num {
  display: inline-grid; place-items: center; flex: none;
  width: 30px; height: 30px; border-radius: 50%;
  border: 1px dashed rgba(23, 23, 23, .35);
  font: italic 400 15px/1 var(--font-display); letter-spacing: 0;
}
.done .step-num { border: 1px solid var(--inchiostro); }
.step-btn[aria-current='step'] .step-num { background: var(--cuore); color: #FFFFFF; border: 1px solid var(--cuore); }
.step-btn:not([disabled]):hover .step-num { border-style: solid; border-color: var(--inchiostro); }
/* only the current step is named; the others stay readable to screen readers */
.step-btn:not([aria-current='step']) .step-name { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- panel ---------- */

.panel { position: relative; }
.panel-loading { color: var(--pietra); padding: var(--s-6) 0; }
.panel-step-count { font-size: 13px; color: var(--pietra); margin: 0 0 var(--s-1); }
.panel-title:focus { outline: none; }
.panel-title:focus-visible { outline: 2px solid var(--inchiostro); outline-offset: 4px; }
.panel-hint { margin: var(--s-2) 0 var(--s-5); }
.panel-group + .panel-group { margin-top: var(--s-6); }
.panel-group legend, .panel-group-title { margin-bottom: var(--s-3); font: italic 400 21px/1.2 var(--font-display); }
.panel-group { border: 0; padding: 0; margin: 0; min-width: 0; }
.counter { font-size: 13px; color: var(--pietra); font-variant-numeric: tabular-nums; }
.panel-nav { display: flex; justify-content: space-between; gap: var(--s-3); margin-top: var(--s-7); padding-top: var(--s-5); border-top: 1px solid var(--rule); }
.panel-nav .spacer { flex: 1; }

/* ---------- option cards ---------- */

.choices { display: grid; gap: var(--s-3); }
.choice-wrap { border: 1px solid var(--rule); border-radius: 3px; background: var(--farina); transition: transform .3s var(--spring); }
.choice-wrap:hover { border-color: rgba(23, 23, 23, .45); }
.choice-wrap:has(input.pick:checked) { border-color: var(--cuore); background: var(--raised); box-shadow: var(--shadow-raised), inset 0 0 0 1px var(--cuore); }
.choice-wrap:has(input.pick:focus-visible) { outline: 2px solid var(--inchiostro); outline-offset: 2px; }
.choice-wrap:has(input.pick:disabled) { opacity: .45; }
.choice-wrap:has(input.pick:disabled):hover { border-color: var(--rule); }
.choice {
  display: grid; grid-template-columns: 56px minmax(0, 1fr) 22px; align-items: center; gap: var(--s-4);
  padding: var(--s-3) var(--s-4) var(--s-3) var(--s-3);
  cursor: pointer;
}
.choice:active { transform: scale(.995); }
.choice-wrap:has(input.pick:disabled) .choice { cursor: not-allowed; }
.choice .swatch { display: block; width: 56px; height: 56px; }
.choice-name { display: block; font-weight: 500; font-size: 16px; line-height: 1.3; }
.choice-desc { display: block; margin-top: 2px; }
.choice-price { display: block; margin-top: 6px; font-size: 14px; }
.choice-mark {
  position: relative; width: 22px; height: 22px; border-radius: 50%;
  border: 1px solid rgba(23, 23, 23, .35); background: var(--farina);
}
.choice-mark.square { border-radius: 4px; }
.choice-mark::after {
  content: ''; position: absolute; inset: 0; border-radius: inherit;
  background: var(--cuore) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 22 22'%3E%3Cpath d='M6.5 11.5l3 3 6-7' fill='none' stroke='%23FFFFFF' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 100% no-repeat;
  opacity: 0; transform: scale(.4);
  transition: opacity .15s ease, transform .35s var(--spring);
}
input.pick:checked ~ .choice-mark::after { opacity: 1; transform: none; }
input.pick:checked ~ .choice-mark { border-color: var(--cuore); }

@media (min-width: 640px) and (max-width: 1023px) {
  .choices--two { grid-template-columns: 1fr 1fr; }
}

/* extra controls under a chosen topping */
.choice-extra {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s-3);
  margin: 0 var(--s-4) 0; padding: var(--s-3) 0 var(--s-4);
  border-top: 1px dotted var(--rule);
}
.choice-extra.fresh { animation: extra-in .35s var(--ease-out); }
@keyframes extra-in { from { opacity: 0; transform: translateY(-4px); } }
.seg { display: inline-flex; border: 1px solid var(--rule); border-radius: 999px; padding: 3px; margin: 0; min-width: 0; }
.seg label { position: relative; }
.seg span {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 34px; padding: 0 12px; border-radius: 999px; cursor: pointer;
  font-size: 13px; color: var(--pietra); white-space: nowrap;
  transition: transform .3s var(--spring);
}
.seg span:active { transform: scale(.96); }
.seg span:hover { color: var(--inchiostro); }
.seg input:checked + span { background: var(--cuore); color: #FFFFFF; }
.seg input:focus-visible + span { outline: 2px solid var(--inchiostro); outline-offset: 2px; }
.seg svg { width: 14px; height: 14px; flex: none; }

.toggle { display: inline-flex; align-items: center; gap: var(--s-2); cursor: pointer; font-size: 13px; color: var(--pietra); min-height: 34px; }
.toggle .track { position: relative; width: 34px; height: 20px; border-radius: 999px; border: 1px solid rgba(23, 23, 23, .4); flex: none; }
.toggle .track::after {
  content: ''; position: absolute; top: 3px; left: 3px; width: 12px; height: 12px; border-radius: 50%;
  background: var(--pietra); transition: transform .35s var(--spring);
}
.toggle input:checked + .track { background: var(--cuore); border-color: var(--cuore); }
.toggle input:checked + .track::after { transform: translateX(14px); background: var(--farina); }
.toggle input:focus-visible + .track { outline: 2px solid var(--inchiostro); outline-offset: 2px; }
.toggle:hover { color: var(--inchiostro); }

/* ---------- review ---------- */

.review-list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--rule); }
.review-list li { display: grid; grid-template-columns: 96px minmax(0, 1fr) auto; gap: var(--s-4); align-items: baseline; padding: var(--s-4) 0; border-bottom: 1px solid var(--rule); }
.review-list .t-label { color: var(--pietra); font-size: 11px; }
.review-list .value { font-size: 15px; line-height: 1.45; }
.review-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s-4); margin-top: var(--s-6); }
.review-total { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s-4); margin-top: var(--s-6); padding-top: var(--s-4); border-top: 1px solid var(--inchiostro); }
.review-total .t-price { font-size: 26px; }
.success:focus { outline: none; }
.success:focus-visible { outline: 2px solid var(--inchiostro); outline-offset: 3px; }
.success { padding: var(--s-6); background: var(--raised); border: 1px solid var(--rule); border-radius: 3px; box-shadow: var(--shadow-book); text-align: center; }
.success .actions { display: flex; flex-wrap: wrap; justify-content: center; gap: var(--s-3); margin-top: var(--s-5); }

/* Compact stepper whenever the builder column is narrow (phones, tablets, 1024–1279px desktops):
   a short group of small circles with fixed connectors, the current one filled and named.
   Wide screens keep the stretched stepper above. */
@media (max-width: 1279px) {
  .stepper { max-width: 100%; }
  .stepper li { flex: none; }
  /* the current step may shrink (label ellipsis) so a long name never widens the page */
  .stepper li:has([aria-current='step']) { flex: 0 1 auto; min-width: 0; }
  .stepper li:not(:last-child)::after { flex: none; width: 8px; min-width: 0; margin: 0 4px; }
  .step-btn { gap: 6px; min-width: 0; }
  .step-num { width: 26px; height: 26px; font-size: 14px; }
  .step-btn[aria-current='step'] .step-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; letter-spacing: .12em; margin-right: 2px; }
}

/* ---------- mobile: sticky preview, bottom bar ---------- */

.bottom-bar { display: none; }

@media (max-width: 1023px) {
  /* The bar's measured height (--bar-h, set in app.js) is reserved once, inside the dark footer,
     so the bar never covers footer content and the page still ends on the footer colour. */
  .builder-page .site-footer { padding-bottom: var(--bar-h, 68px); }
  /* keyboard focus and in-page jumps stop clear of the sticky preview and the bar */
  html:has(.builder-page) { scroll-padding-top: var(--aside-h, 240px); scroll-padding-bottom: calc(var(--bar-h, 68px) + 8px); }

  .builder { gap: var(--s-3); padding-bottom: var(--s-7); }
  .builder-intro { padding-bottom: var(--s-3); }
  /* the sample-price note becomes one quiet line instead of a box */
  .builder-intro .notice { display: block; margin-top: var(--s-2); padding: 0; border: 0; background: none; font-size: 12.5px; font-style: italic; }
  .builder-aside {
    position: sticky; top: 0; z-index: 10;
    margin-inline: calc(var(--gutter) * -1); padding: var(--s-2) var(--gutter) 6px;
    background: var(--farina);
    border-bottom: 1px solid var(--rule);
    box-shadow: 0 14px 20px -18px rgba(23, 23, 23, .45);
  }
  .stage { width: min(50vw, 27vh, 232px); }
  .stage-note { right: -56%; top: 34%; }
  .stage-note .t-hand { font-size: 22px; }
  .stage-caption { margin-top: 2px; font-size: 13px; }
  .stepper { margin-bottom: var(--s-2); }
  /* the stepper already shows where you are; keep "Passo 3 di 6" for screen readers only */
  .panel-step-count { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .panel-hint { margin-bottom: var(--s-4); }
  .panel-nav { display: none; }
  .panel { scroll-margin-top: var(--aside-h, 240px); }
  .builder-page .toast-region { bottom: calc(var(--bar-h, 68px) + 12px); }

  .bottom-bar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    display: flex; align-items: center; gap: var(--s-3);
    padding: 10px max(var(--gutter), env(safe-area-inset-right)) calc(10px + env(safe-area-inset-bottom)) max(var(--gutter), env(safe-area-inset-left));
    background: var(--sabbia); border-top: 1px solid var(--rule);
    box-shadow: 0 -10px 24px -16px rgba(23, 23, 23, .5);
  }
  .bottom-bar .btn { flex: none; min-height: 46px; padding: 0 22px; }
  .bottom-bar .icon-btn { width: 44px; height: 44px; flex: none; }
  .bar-total {
    flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
    padding: 4px 0; border: 0; background: none; cursor: pointer; text-align: left; color: var(--inchiostro);
    transition: transform .3s var(--spring);
  }
  .bar-total:active { transform: scale(.97); }
  .bar-total .t-price { font-size: 18px; }
  .bar-total .more { font-size: 12px; color: var(--pietra); text-decoration: underline; text-underline-offset: 3px; }
}

@media (max-width: 599px) {
  .stage-note { display: none; }
}

@media (max-width: 380px) {
  .choice { grid-template-columns: 44px minmax(0, 1fr) 22px; gap: var(--s-3); }
  .choice .swatch { width: 44px; height: 44px; }
  .review-list li { grid-template-columns: 1fr auto; }
  .review-list li .t-label { grid-column: 1 / -1; }
}

.sheet .summary { margin: 0; border: 0; box-shadow: none; background: transparent; padding: 0; }
.sheet .summary-lines { max-height: none; }
