/* ==========================================================================
   ORDINE EXPRESS — stili del modulo isolato
   Usa i token del sito (style.css) ma non ne modifica nessuna regola.
   Per rimuovere la funzione basta eliminare questo file (vedi index.html).
   ========================================================================== */

/* senza JavaScript o senza supporto <dialog> i pulsanti non compaiono */
.no-js [data-oe-open],
.oe-unsupported [data-oe-open] { display: none !important; }
html.oe-open { overflow: hidden; }

/* ---------- CTA nella sezione Prodotti ---------- */
.oe-cta {
  display: grid; gap: 20px; align-items: center;
  margin-top: clamp(48px, 6vw, 88px); padding-top: clamp(24px, 3vw, 36px);
  border-top: 1px solid var(--hairline-strong);
}
.oe-cta__label {
  font-size: var(--fs-label); font-weight: 600; letter-spacing: 0.16em; text-transform: uppercase; color: var(--brand-ink);
}
.oe-cta__title {
  margin-top: 8px; max-width: 34ch;
  font-size: clamp(1.25rem, 1.05rem + 0.8vw, 1.625rem); font-weight: 500; line-height: 1.25; letter-spacing: -0.015em; color: var(--navy);
}
.oe-cta .btn { justify-self: start; }
@media (min-width: 768px) {
  .oe-cta { grid-template-columns: minmax(0, 1fr) auto; column-gap: 40px; }
}

/* ---------- Voce nel menu flottante mobile ---------- */
@media (max-width: 767px) {
  .fab__action--oe {
    border: 0; font-family: inherit; cursor: pointer;
    background: var(--ice-50); color: var(--navy);
    box-shadow: inset 0 0 0 1px rgba(11, 36, 104, 0.35), 0 6px 18px rgba(11, 36, 104, 0.12);
  }
  .fab__action--oe svg { width: 20px; height: 20px; flex: none; fill: none; stroke: var(--brand); stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
  .fab.is-open .fab__action--oe { transition-delay: 0.1s; } /* la più lontana entra per ultima */
}

/* ---------- Pannello ---------- */
.oe {
  width: min(660px, calc(100% - 48px)); max-width: none;
  max-height: min(800px, calc(100vh - 48px));
  max-height: min(800px, calc(100dvh - 48px));
  padding: 0; border: 0; background: transparent; color: var(--text); overflow: visible;
}
.oe::backdrop { background: rgba(11, 36, 104, 0.32); }
.oe__panel {
  position: relative; display: flex; flex-direction: column;
  max-height: inherit; overflow: hidden;
  border-radius: 14px;
  background:
    radial-gradient(ellipse 90% 180px at 80% 0%, rgba(221, 239, 252, 0.7), rgba(221, 239, 252, 0) 100%),
    linear-gradient(180deg, #fff 0%, #fff 70%, #f7fbfe 100%);
  box-shadow: 0 30px 80px rgba(11, 36, 104, 0.22);
}
/* velo "brina" che si dissolve all'apertura */
.oe__panel::before {
  content: ""; position: absolute; inset: 0; z-index: 5; pointer-events: none; opacity: 0;
  background: radial-gradient(120% 90% at 50% 0%, rgba(255, 255, 255, 0.95), rgba(221, 239, 252, 0.55) 55%, rgba(255, 255, 255, 0) 100%);
}

.oe__head { position: relative; padding: 28px 72px 0 32px; }
.oe__kicker { font-size: var(--fs-label); font-weight: 600; letter-spacing: 0.16em; text-transform: uppercase; color: var(--brand-ink); }
.oe__title { margin-top: 6px; font-size: clamp(1.625rem, 1.3rem + 1.2vw, 2.125rem); font-weight: 600; line-height: 1.1; letter-spacing: -0.025em; }
.oe__intro { margin-top: 8px; font-size: 0.9375rem; line-height: 1.5; color: var(--muted); }
.oe__close {
  position: absolute; top: 16px; right: 16px;
  display: grid; place-items: center; width: 44px; height: 44px; padding: 0;
  border: 0; border-radius: 50%; background: transparent; color: var(--navy); cursor: pointer;
  transition: background-color 0.2s var(--ease);
}
.oe__close:hover { background: var(--ice-50); }
.oe__close svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; }

/* progressione 01 ─── 02 ─── 03 ─── 04 */
.oe__progress { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); margin: 24px 32px 0; }
.oe__progress li { position: relative; display: grid; justify-items: start; gap: 6px; }
.oe__progress li:not(:last-child)::after {
  content: ""; position: absolute; top: 0.62em; left: 2.6em; right: 10px; height: 1px;
  background: var(--hairline-strong); transition: background-color 0.4s var(--ease);
}
.oe__progress li.is-done::after { background: var(--brand); }
.oe__num { font-size: 0.8125rem; font-weight: 700; line-height: 1.2; letter-spacing: 0.08em; color: var(--muted); font-variant-numeric: tabular-nums; }
.oe__plabel { font-size: 0.6875rem; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }
.oe__progress .is-current .oe__num, .oe__progress .is-current .oe__plabel { color: var(--navy); }
.oe__progress .is-done .oe__num { color: var(--brand-ink); }

.oe__body { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 28px 32px 12px; }
.oe__step { margin: 0; padding: 0; border: 0; min-width: 0; }
.oe__legend {
  display: block; padding: 0; margin: 0 0 18px;
  font-size: clamp(1.25rem, 1.1rem + 0.6vw, 1.5rem); font-weight: 500; line-height: 1.25; letter-spacing: -0.015em; color: var(--navy);
}
.oe__legend small { margin-left: 6px; font-size: 0.875rem; font-weight: 500; letter-spacing: 0; color: var(--muted); }
.oe__legend:focus { outline: none; }
/* il titolo del riepilogo riceve il focus solo per gli screen reader: nessun contorno */

/* scelte: radio e checkbox nascosti visivamente ma focalizzabili */
.oe__choice { position: relative; display: block; cursor: pointer; }
.oe__choice input { position: absolute; top: 0; left: 0; width: 1px; height: 1px; opacity: 0; }
.oe__choice input:focus-visible + span { outline: 2px solid var(--brand); outline-offset: 3px; }

/* 01 · prodotti */
.oe__grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.oe__card {
  position: relative; display: grid; gap: 10px; padding: 8px 8px 14px; border-radius: 12px;
  background: #fff; box-shadow: inset 0 0 0 1px var(--hairline);
  transition: box-shadow 0.2s var(--ease), background-color 0.2s var(--ease);
}
.oe__card img { width: 100%; height: auto; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 8px; }
.oe__card-name { padding: 0 6px; font-size: 0.9375rem; font-weight: 600; line-height: 1.3; color: var(--navy); }
.oe__card::after {
  content: ""; position: absolute; top: 16px; right: 16px; width: 22px; height: 22px; border-radius: 6px;
  background-position: center; background-repeat: no-repeat; background-size: 16px 16px;
  background: #fff; box-shadow: inset 0 0 0 1.5px rgba(11, 36, 104, 0.35), 0 1px 4px rgba(11, 36, 104, 0.12);
  transition: box-shadow 0.2s var(--ease), background-color 0.2s var(--ease);
}
.oe__choice:hover .oe__card { box-shadow: inset 0 0 0 1px var(--hairline-strong); }
.oe__choice input:checked + .oe__card { background: var(--ice-50); box-shadow: inset 0 0 0 2px var(--navy); }
.oe__choice input:checked + .oe__card::after {
  background-color: var(--navy); box-shadow: 0 1px 4px rgba(11, 36, 104, 0.2);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23fff' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5'/%3E%3C/svg%3E");
}

@media (min-width: 600px) {
  .oe__grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .oe__card img { aspect-ratio: 1 / 1; }
  .oe__card-name { font-size: 0.875rem; }
}

/* micro-indicazione sopra l'elenco dei prodotti */
.oe__select-hint { margin: -10px 0 16px; font-size: 0.875rem; line-height: 1.4; color: var(--muted); }

/* 02 · quantità: un blocco verticale per ogni prodotto scelto */
.oe__qty-list { display: grid; gap: 0; }
.oe__qty-item { padding: 18px 0 16px; border-top: 1px solid var(--hairline); }
.oe__qty-label { display: grid; gap: 2px; margin-bottom: 6px; }
.oe__qty-name { font-size: 1.0625rem; font-weight: 600; color: var(--navy); }
.oe__qty-question { font-size: 0.9375rem; color: var(--muted); }
.oe__hint { margin: -8px 0 18px; font-size: 0.9375rem; line-height: 1.5; color: var(--muted); }
.oe__input {
  width: 100%; min-height: 60px; padding: 8px 2px;
  border: 0; border-bottom: 1.5px solid rgba(11, 36, 104, 0.28); border-radius: 0; background: transparent;
  font-family: var(--font); font-size: clamp(1.25rem, 1.1rem + 0.6vw, 1.5rem); font-weight: 500; color: var(--navy);
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}
.oe__input::placeholder { color: #8594b3; opacity: 1; }
.oe__input:focus { outline: none; border-bottom-color: var(--brand); box-shadow: 0 1.5px 0 0 var(--brand); }
/* campo quantità: [numero] unità sulla stessa riga, con la linea sotto come prima.
   flex-wrap: nowrap e min-width: 0 impediscono che campo e unità vadano a capo sui telefoni stretti. */
.oe__qty {
  display: flex; flex-wrap: nowrap; align-items: center; gap: 12px; width: 100%;
  border-bottom: 1.5px solid rgba(11, 36, 104, 0.28);
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}
.oe__qty:focus-within { border-bottom-color: var(--brand); box-shadow: 0 1.5px 0 0 var(--brand); }
.oe__qty .oe__input {
  flex: 1 1 auto; width: auto; min-width: 0; border-bottom: 0; box-shadow: none;
  text-align: left; font-variant-numeric: tabular-nums;
  -webkit-appearance: none; -moz-appearance: textfield; appearance: textfield; /* niente frecce native */
}
.oe__qty .oe__input::-webkit-outer-spin-button,
.oe__qty .oe__input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.oe__qty .oe__input:focus { box-shadow: none; }
.oe__unit { flex: none; font-size: 1.0625rem; font-weight: 600; letter-spacing: 0.01em; color: var(--muted); white-space: nowrap; }
.oe__hint--after { margin: 10px 0 0; }
.oe__total { min-height: 1.5em; margin-top: 6px; font-size: 0.9375rem; font-weight: 600; color: var(--brand-ink); }
.oe__total.is-error { color: #b3261e; }
.oe__qty:has(input[aria-invalid]) { border-bottom-color: #b3261e; box-shadow: 0 1.5px 0 0 #b3261e; } /* valore non valido */

/* 03 · servizi */
.oe__list { display: grid; gap: 10px; }
.oe__row {
  display: grid; grid-template-columns: 28px minmax(0, 1fr) 24px; align-items: center; gap: 14px;
  min-height: 60px; padding: 12px 16px; border-radius: 12px;
  background: #fff; box-shadow: inset 0 0 0 1px var(--hairline);
  transition: box-shadow 0.2s var(--ease), background-color 0.2s var(--ease);
}
.oe__row-icon { width: 26px; height: 26px; fill: none; stroke: var(--brand); stroke-width: 1.3; stroke-linecap: round; stroke-linejoin: round; }
.oe__row-name { font-size: 1rem; font-weight: 600; color: var(--navy); }
.oe__tick {
  display: grid; place-items: center; width: 22px; height: 22px; border-radius: 6px;
  box-shadow: inset 0 0 0 1.5px rgba(11, 36, 104, 0.35); background: #fff;
  transition: background-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}
.oe__tick svg { width: 16px; height: 16px; fill: none; stroke: #fff; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; opacity: 0; }
.oe__choice:hover .oe__row { box-shadow: inset 0 0 0 1px var(--hairline-strong); }
.oe__choice input:checked + .oe__row { background: var(--ice-50); box-shadow: inset 0 0 0 2px var(--navy); }
.oe__choice input:checked + .oe__row .oe__tick { background: var(--navy); box-shadow: none; }
.oe__choice input:checked + .oe__row .oe__tick svg { opacity: 1; }

/* 04 · riepilogo */
.oe__summary > div { display: grid; grid-template-columns: 7rem minmax(0, 1fr); gap: 12px; padding: 12px 0; border-top: 1px solid var(--hairline); }
.oe__summary > div:last-child { border-bottom: 1px solid var(--hairline); }
.oe__summary dt { padding-top: 3px; font-size: var(--fs-label); font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); }
.oe__summary dd { margin: 0; font-weight: 600; color: var(--navy); overflow-wrap: anywhere; }
.oe__summary-list { display: grid; gap: 10px; }
.oe__summary-name { display: block; }
.oe__summary-qty { display: block; font-weight: 500; color: var(--text); }
.oe__preview-label { margin-top: 22px; font-size: var(--fs-label); font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); }
.oe__preview-label { display: block; }
/* messaggio modificabile: cresce con il testo (dove supportato), altrimenti si allunga a mano o scorre */
.oe__message {
  display: block; width: 100%; margin-top: 8px;
  min-height: 9.5em; max-height: 45vh; padding: 14px 16px;
  border: 0; border-radius: 12px; resize: vertical;
  background: #fff; box-shadow: inset 0 0 0 1px var(--hairline-strong);
  font-family: var(--font); font-size: 1rem; line-height: 1.55; color: var(--navy);
  caret-color: var(--brand); overflow-wrap: anywhere;
  field-sizing: content;
  transition: box-shadow 0.2s var(--ease);
}
.oe__message:hover { box-shadow: inset 0 0 0 1px rgba(11, 36, 104, 0.35); }
.oe__message:focus { outline: none; box-shadow: inset 0 0 0 2px var(--brand); }
.oe__message[aria-invalid] { box-shadow: inset 0 0 0 2px #b3261e; }
.oe__message-hint { margin-top: 8px; font-size: 0.875rem; line-height: 1.5; color: var(--muted); }
.oe__send[aria-disabled="true"] { opacity: 0.45; cursor: not-allowed; }

/* navigazione */
.oe__nav {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 32px 24px; border-top: 1px solid var(--hairline); background: rgba(255, 255, 255, 0.96);
}
.oe__nav .oe__next, .oe__nav .oe__send { margin-left: auto; }
.oe__next[disabled] { opacity: 0.4; cursor: not-allowed; }
.oe__next[disabled]:hover { background: var(--navy); }
.oe__back {
  display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 6px;
  border: 0; background: none; cursor: pointer;
  font-family: var(--font); font-size: 0.9375rem; font-weight: 600; color: var(--navy);
}
.oe__back { flex: none; }
.oe__back svg { flex: none; width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; transform: rotate(180deg); }

/* ---------- Mobile: pannello a tutto schermo, controlli grandi ---------- */
@media (max-width: 599px) {
  .oe {
    width: 100%; height: 100%; max-height: 100%; margin: 0;
    height: 100dvh; max-height: 100dvh;
  }
  .oe__panel { height: 100%; max-height: none; border-radius: 0; box-shadow: none; }
  .oe__head { padding: max(20px, env(safe-area-inset-top)) 64px 0 20px; }
  .oe__close { top: max(10px, env(safe-area-inset-top)); right: 10px; }
  .oe__progress { margin: 20px 20px 0; }
  .oe__body { padding: 24px 20px 12px; }
  .oe__grid { gap: 10px; }
  .oe__nav { padding: 12px 20px max(16px, env(safe-area-inset-bottom)); }
  .oe__nav .oe__next, .oe__nav .oe__send { flex: 1 1 auto; min-height: 54px; }
  .oe__summary > div { grid-template-columns: minmax(0, 1fr); gap: 4px; }
}

/* ---------- Microanimazioni (disattivate con "riduci movimento") ---------- */
@media (prefers-reduced-motion: no-preference) {
  .oe[open] { animation: oe-in 0.5s var(--ease) both; }
  .oe[open]::backdrop { animation: oe-fade 0.35s ease both; }
  .oe[open] .oe__panel::before { animation: oe-frost 1s var(--ease) both; }
  .oe__step.is-entering { animation: oe-step 0.38s var(--ease) both; }
}
@keyframes oe-in { from { opacity: 0; filter: blur(8px); transform: translateY(8px) scale(1.015); } to { opacity: 1; filter: none; transform: none; } }
@keyframes oe-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes oe-frost { from { opacity: 0.9; } to { opacity: 0; } }
@keyframes oe-step { from { opacity: 0; transform: translateY(8px); filter: blur(2px); } to { opacity: 1; transform: none; filter: none; } }
