/* ---------------------------------------------------------------------------
   La Bussola — Carta Fedeltà (loyalty card)
   Visual language: warm dark wood / beige-champagne / metallic gold, matching
   the site's Warm Noir + Muted Brass identity. Every selector stays namespaced
   under .lb-loyalty so it never collides with the site's own styles, and the
   card's geometry, placement, motion and behaviour are unchanged.
   Palette vars are the site's own (with literal fallbacks).

   The wood is rendered purely in CSS (layered gradients + an inline SVG grain)
   so the card ships with no extra image file and no external URL.
--------------------------------------------------------------------------- */

.lb-loyalty {
  /* Wood plank base — a single local SVG noise layer keeps the grain organic
     instead of an obvious repeating pattern. Feathered so it never tiles
     visibly. */
  --lb-wood-grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9 0.04' numOctaves='4' seed='7'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='220' height='220' filter='url(%23n)' opacity='0.5'/%3E%3C/svg%3E");
  --lb-wood: linear-gradient(180deg, #2a1d13 0%, #241810 40%, #1d130c 100%);
  --lb-wood-veins: repeating-linear-gradient(92deg, rgba(0,0,0,.34) 0 1px, rgba(0,0,0,0) 1px 3px, rgba(120,84,48,.10) 3px 4px, rgba(0,0,0,0) 4px 9px);
  --lb-champagne: #e8cf9a;
  --lb-champagne-light: #f6e2bb;
  --lb-ivory: #f4ead8;
  --lb-gold: #d9a35f;
  --lb-gold-deep: #b8833e;
  --lb-beige: #efe0bf;
  --lb-edge: rgba(217, 163, 95, .55);
  --lb-edge-soft: rgba(217, 163, 95, .30);
}

/* The site owns a floating cart bar fixed at bottom-right (z-[60], measured
   98px tall on desktop and 82px on mobile); the loyalty card/pill shares that
   corner and must sit fully ABOVE it (never over it), so the cart bar stays
   clickable. Offset by the bar's measured height + a small gap, plus the
   mobile safe-area inset. */
.lb-loyalty { position: fixed; right: 1.1rem; bottom: calc(7rem + env(safe-area-inset-bottom, 0px)); z-index: 100; }
@media (max-width: 640px) { .lb-loyalty { left: .75rem; right: .75rem; bottom: calc(5.75rem + env(safe-area-inset-bottom, 0px)); } }

/* --- reopen pill (shown once the card is closed) ------------------------- */
.lb-loyalty__pill {
  display: inline-flex; align-items: center; gap: .45rem;
  padding: .6rem 1rem; border-radius: 9999px; cursor: pointer;
  font-family: 'Inter', system-ui, sans-serif; font-size: 12.5px; font-weight: 500; letter-spacing: .04em;
  color: var(--lb-champagne-light, #f6e2bb);
  background:
    var(--lb-wood-veins),
    var(--lb-wood-grain),
    linear-gradient(160deg, #2b1e14 0%, #1a110b 100%);
  border: 1px solid var(--lb-edge);
  box-shadow: 0 12px 34px rgba(0, 0, 0, .6), 0 0 22px rgba(217, 163, 95, .14), inset 0 1px 0 rgba(246, 226, 187, .10);
  transition: border-color .25s ease, box-shadow .25s ease, transform .2s ease;
}
.lb-loyalty__pill:hover { border-color: rgba(246, 226, 187, .8); transform: translateY(-1px); box-shadow: 0 14px 38px rgba(0, 0, 0, .62), 0 0 30px rgba(217, 163, 95, .26), inset 0 1px 0 rgba(246, 226, 187, .14); }
.lb-loyalty__pill span { color: var(--lb-champagne, #e8cf9a); }

/* --- card ---------------------------------------------------------------- */
.lb-loyalty__card {
  position: relative; width: min(360px, calc(100vw - 2.2rem));
  /* Realistic dark wood: a base plank gradient, subtle vertical grain veins and
     an organic SVG-noise layer. No flat brown, no repeating-kitsch pattern. */
  background:
    var(--lb-wood-veins),
    var(--lb-wood-grain),
    var(--lb-wood);
  background-size: auto, 220px 220px, auto;
  background-blend-mode: normal, soft-light, normal;
  /* Thin metallic gold outline: a crisp 1px border plus a soft outer ring and a
     faint inner highlight — restrained, no thick gaudy frame. */
  border: 1px solid var(--lb-edge); border-radius: 22px;
  box-shadow:
    0 30px 70px rgba(0, 0, 0, .72),
    0 0 0 1px rgba(184, 131, 62, .28),
    0 0 46px rgba(217, 163, 95, .10),
    inset 0 1px 0 rgba(246, 226, 187, .12),
    inset 0 0 60px rgba(0, 0, 0, .45);
  padding: 1.5rem 1.4rem 1.4rem;
  animation: lbLoyaltyUp .42s cubic-bezier(.22, 1, .36, 1) both;
}
@media (max-width: 640px) { .lb-loyalty__card { width: auto; } }

.lb-loyalty.is-collapsed .lb-loyalty__card { display: none; }
.lb-loyalty:not(.is-collapsed) .lb-loyalty__pill { display: none; }

.lb-loyalty__close {
  position: absolute; top: 12px; right: 12px; width: 30px; height: 30px;
  border-radius: 9999px; border: 1px solid rgba(217, 163, 95, .32);
  background: rgba(20, 13, 8, .6);
  color: var(--lb-champagne, #e8cf9a); font-size: 16px; line-height: 1; cursor: pointer;
  transition: border-color .25s ease, color .25s ease, background .25s ease;
}
.lb-loyalty__close:hover { border-color: rgba(246, 226, 187, .85); color: var(--lb-ivory, #f4ead8); background: rgba(43, 30, 20, .85); }

.lb-loyalty__eyebrow {
  font-size: 10px; font-weight: 500; letter-spacing: .34em; text-transform: uppercase;
  color: var(--lb-champagne, #e8cf9a); margin: 0 0 .5rem;
}
.lb-loyalty__title {
  font-family: 'Playfair Display', Georgia, 'Times New Roman', serif; font-weight: 600;
  font-size: 1.28rem; line-height: 1.2; color: var(--lb-ivory, #f4ead8);
  text-shadow: 0 1px 1px rgba(0, 0, 0, .5); margin: 0 0 .5rem;
}
.lb-loyalty__title em {
  font-style: italic; background: linear-gradient(120deg, #f6e2bb, #e8cf9a 46%, #d9a35f);
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; color: transparent;
}
.lb-loyalty__lead { font-size: 12.5px; font-weight: 300; line-height: 1.55; color: #d8c8ad; margin: 0 0 1rem; }

/* --- form ---------------------------------------------------------------- */
.lb-loyalty__form { display: flex; gap: .5rem; }
.lb-loyalty__input {
  flex: 1 1 auto; min-width: 0; padding: .62rem .8rem; border-radius: 12px;
  background: rgba(18, 12, 8, .78); border: 1px solid rgba(217, 163, 95, .40);
  color: var(--lb-ivory, #f4ead8); font-family: 'Inter', system-ui, sans-serif; font-size: 13.5px;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, .55);
  transition: border-color .25s ease, box-shadow .25s ease;
}
.lb-loyalty__input::placeholder { color: rgba(216, 200, 173, .55); }
.lb-loyalty__input:focus { outline: none; border-color: rgba(246, 226, 187, .8); box-shadow: inset 0 1px 3px rgba(0, 0, 0, .55), 0 0 0 3px rgba(217, 163, 95, .18); }

.lb-loyalty__btn {
  flex: 0 0 auto; padding: .62rem 1rem; border-radius: 9999px; cursor: pointer;
  font-family: 'Inter', system-ui, sans-serif; font-size: 12.5px; font-weight: 500; letter-spacing: .03em;
  color: var(--lb-champagne-light, #f6e2bb); background: rgba(20, 13, 8, .5);
  border: 1px solid rgba(217, 163, 95, .6);
  transition: background .25s ease, color .25s ease, border-color .25s ease, transform .2s ease, box-shadow .25s ease;
}
.lb-loyalty__btn:hover { background: rgba(217, 163, 95, .16); border-color: rgba(246, 226, 187, .9); box-shadow: 0 0 18px rgba(217, 163, 95, .18); }
.lb-loyalty__btn--gold {
  color: #2a1b0e; border-color: rgba(246, 226, 187, .5);
  background: linear-gradient(120deg, #f6e2bb, #e8cf9a 55%, #d9a35f);
  box-shadow: 0 8px 22px rgba(217, 163, 95, .34), inset 0 1px 0 rgba(255, 250, 235, .6);
}
.lb-loyalty__btn--gold:hover { transform: translateY(-1px); box-shadow: 0 10px 26px rgba(217, 163, 95, .46), inset 0 1px 0 rgba(255, 250, 235, .7); }

/* --- status / balance ---------------------------------------------------- */
.lb-loyalty__status { margin-top: .95rem; }
.lb-loyalty__status.is-muted { font-size: 12.5px; color: #cdbb9e; }
.lb-loyalty__status.is-err { font-size: 12.5px; color: #e7a58f; }

.lb-loyalty__count { font-family: 'Inter', system-ui, sans-serif; font-size: 13px; color: #d8c8ad; }
.lb-loyalty__count strong { font-family: 'Playfair Display', Georgia, serif; font-size: 1.5rem; color: var(--lb-ivory, #f4ead8); }

.lb-loyalty__dots {
  display: grid; grid-template-columns: repeat(10, minmax(0, 1fr));
  gap: .3rem; align-items: center; width: 100%; margin: .62rem 0 .25rem;
}
.lb-loyalty__dot {
  display: flex; align-items: center; justify-content: center;
  width: 100%; aspect-ratio: 1 / 1; max-width: 26px; margin: 0 auto;
  background: none; border: none;
  transition: filter .28s ease, transform .28s ease;
}
.lb-loyalty__pizza { display: block; width: 100%; height: 100%; overflow: visible; }
.lb-loyalty__pizza-crust {
  fill: rgba(20, 13, 8, .45); stroke: rgba(217, 163, 95, .52);
  stroke-width: 1.35; stroke-linejoin: round;
  transition: fill .28s ease, stroke .28s ease;
}
.lb-loyalty__pizza-body {
  fill: rgba(20, 13, 8, .30); stroke: rgba(217, 163, 95, .52);
  stroke-width: 1.35; stroke-linejoin: round;
  transition: fill .28s ease, stroke .28s ease;
}
.lb-loyalty__pizza-top {
  fill: none; stroke: rgba(217, 163, 95, .42); stroke-width: 1.1;
  transition: fill .28s ease, stroke .28s ease;
}
.lb-loyalty__dot.is-on {
  filter: drop-shadow(0 0 5px rgba(217, 163, 95, .46));
}
.lb-loyalty__dot.is-on .lb-loyalty__pizza-crust {
  fill: var(--lb-gold, #d9a35f); stroke: var(--lb-champagne-light, #f6e2bb); stroke-width: 1.3;
}
.lb-loyalty__dot.is-on .lb-loyalty__pizza-body {
  fill: var(--lb-champagne-light, #f6e2bb); stroke: var(--lb-champagne, #e8cf9a); stroke-width: 1.25;
}
.lb-loyalty__dot.is-on .lb-loyalty__pizza-top {
  fill: #9a6224; stroke: none;
}
@media (max-width: 380px) {
  .lb-loyalty__dots { gap: .2rem; }
}

.lb-loyalty__hint { margin-top: .7rem; font-size: 12.5px; line-height: 1.5; color: #d8c8ad; }
.lb-loyalty__hint strong { color: var(--lb-champagne-light, #f6e2bb); }

.lb-loyalty__reward {
  margin-top: .85rem; padding: .9rem .95rem; border-radius: 16px; text-align: center;
  /* Beige / champagne cream highlighted surface. */
  background:
    var(--lb-wood-grain),
    radial-gradient(circle at 50% 0%, #f7ead0 0%, #efe0bf 55%, #e2cfa5 100%);
  background-size: 220px 220px, auto;
  background-blend-mode: soft-light, normal;
  border: 1px solid rgba(246, 226, 187, .75);
  box-shadow: inset 0 1px 0 rgba(255, 250, 235, .8), 0 8px 20px rgba(0, 0, 0, .35);
  animation: lbLoyaltyUp .4s cubic-bezier(.22, 1, .36, 1) both;
}
.lb-loyalty__reward-title { font-size: 13.5px; font-weight: 600; color: #6d4a1e; }
.lb-loyalty__reward-sub { font-size: 12px; color: #6f5a37; margin: .25rem 0 .7rem; }
.lb-loyalty__reward-sub strong { color: #4a3418; }

/* --- reward picker ------------------------------------------------------- */
.lb-loyalty__picker { animation: lbLoyaltyUp .38s cubic-bezier(.22, 1, .36, 1) both; }
.lb-loyalty__picker-title { font-family: 'Playfair Display', Georgia, serif; font-size: 1.05rem; color: var(--lb-ivory, #f4ead8); margin-bottom: .7rem; }
.lb-loyalty__label { display: block; font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--lb-champagne, #e8cf9a); margin: .55rem 0 .3rem; }
.lb-loyalty__select {
  width: 100%; padding: .58rem .7rem; border-radius: 12px;
  background: rgba(18, 12, 8, .85); border: 1px solid rgba(217, 163, 95, .40);
  color: var(--lb-ivory, #f4ead8); font-family: 'Inter', system-ui, sans-serif; font-size: 13.5px;
}
.lb-loyalty__select:focus { outline: none; border-color: rgba(246, 226, 187, .8); }
.lb-loyalty__picker-actions { display: flex; flex-direction: column; gap: .5rem; margin-top: .9rem; }
.lb-loyalty__fine { font-size: 11px; line-height: 1.5; color: rgba(216, 200, 173, .8); margin: .7rem 0 0; }

.lb-loyalty__done {
  padding: .75rem .85rem; border-radius: 14px; font-size: 12.5px; line-height: 1.55;
  color: #cfe9d4; background: rgba(120, 200, 140, .1); border: 1px solid rgba(120, 200, 140, .35);
}
.lb-loyalty__done strong { color: var(--lb-ivory, #f4ead8); }

@keyframes lbLoyaltyUp { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }

@media (prefers-reduced-motion: reduce) {
  .lb-loyalty__card, .lb-loyalty__reward, .lb-loyalty__picker { animation: none; }
  .lb-loyalty__dot, .lb-loyalty__pizza-crust, .lb-loyalty__pizza-body, .lb-loyalty__pizza-top { transition: none; }
}

/* ---------------------------------------------------------------------------
   PHASE 2 — the reward is chosen from the original menu (no in-card picker)
   --------------------------------------------------------------------------- */

/* reopen pill: a live hint while a reward session is active and fully chosen */
.lb-loyalty__pill.has-reward { border-color: rgba(246, 226, 187, .9); box-shadow: 0 12px 34px rgba(0, 0, 0, .6), 0 0 26px rgba(217, 163, 95, .42), inset 0 1px 0 rgba(246, 226, 187, .14); }

/* --- claimed items list inside the card ---------------------------------- */
.lb-loyalty__claim { margin: .15rem 0 .75rem; display: flex; flex-direction: column; gap: .3rem; }
.lb-loyalty__claim-row {
  display: flex; align-items: baseline; gap: .5rem;
  padding: .4rem .55rem; border-radius: 11px;
  background: rgba(18, 12, 8, .5); border: 1px solid rgba(217, 163, 95, .22);
  font-size: 12px; color: #d8c8ad;
}
.lb-loyalty__claim-row.is-on { border-color: rgba(217, 163, 95, .55); background: rgba(217, 163, 95, .1); }
.lb-loyalty__claim-ico { color: rgba(216, 200, 173, .45); font-size: 9px; line-height: 1.6; }
.lb-loyalty__claim-row.is-on .lb-loyalty__claim-ico { color: var(--lb-champagne, #e8cf9a); }
.lb-loyalty__claim-lbl { text-transform: uppercase; letter-spacing: .14em; font-size: 9.5px; color: var(--lb-champagne, #e8cf9a); }
.lb-loyalty__claim-val { margin-left: auto; color: #d8c8ad; text-align: right; }
.lb-loyalty__claim-row.is-on .lb-loyalty__claim-val { color: var(--lb-ivory, #f4ead8); font-weight: 500; }
.lb-loyalty__claim-note {
  margin-top: .1rem; padding: .5rem .6rem; border-radius: 11px;
  background: rgba(217, 163, 95, .1); border: 1px dashed rgba(217, 163, 95, .45);
  font-size: 11.5px; line-height: 1.5; color: #d8c8ad;
}
.lb-loyalty__claim-note strong { color: var(--lb-ivory, #f4ead8); font-weight: 600; }

/* --- MENU overlay: eligible rows + the claimed row ------------------------ */
/* Cosmetic only: a class on the row; React may drop it on re-render and
   loyalty-native-reward.js simply re-applies it. Prices are never touched. */
#cat-classiche div.group.lb-loy-eligible,
#cat-speciali div.group.lb-loy-eligible,
#cat-bianche div.group.lb-loy-eligible,
#cat-calzoni div.group.lb-loy-eligible,
#cat-bevande div.group.lb-loy-eligible {
  position: relative;
  background: linear-gradient(90deg, rgba(217, 163, 95, .07), transparent 62%);
  box-shadow: inset 3px 0 0 rgba(217, 163, 95, .45);
  border-radius: 8px;
}
#cat-classiche div.group.lb-loy-claimed,
#cat-speciali div.group.lb-loy-claimed,
#cat-bianche div.group.lb-loy-claimed,
#cat-calzoni div.group.lb-loy-claimed,
#cat-bevande div.group.lb-loy-claimed {
  background: linear-gradient(90deg, rgba(217, 163, 95, .16), transparent 68%);
  box-shadow: inset 3px 0 0 var(--color-gold, #d9a35f);
}
#cat-classiche div.group.lb-loy-claimed::after,
#cat-speciali div.group.lb-loy-claimed::after,
#cat-bianche div.group.lb-loy-claimed::after,
#cat-calzoni div.group.lb-loy-claimed::after,
#cat-bevande div.group.lb-loy-claimed::after {
  content: '\2726 PREMIO FEDELT\00C0';
  position: absolute; top: -9px; right: 4px;
  padding: 1px 7px; border-radius: 9999px;
  font-family: 'Inter', system-ui, sans-serif; font-size: 8.5px; font-weight: 600;
  letter-spacing: .16em; text-transform: uppercase; color: #2a1b0e;
  background: linear-gradient(120deg, #f6e2bb, #e8cf9a 55%, #d9a35f);
  box-shadow: 0 3px 10px rgba(0, 0, 0, .45);
  pointer-events: none; white-space: nowrap;
}

/* --- CART overlay: the free line ----------------------------------------- */
aside[aria-label="Il tuo ordine"] li.lb-loy-line { position: relative; }
aside[aria-label="Il tuo ordine"] li.lb-loy-line > div {
  border-color: rgba(217, 163, 95, .5) !important;
  background: linear-gradient(135deg, rgba(217, 163, 95, .1), rgba(217, 163, 95, .03)) !important;
}
aside[aria-label="Il tuo ordine"] li.lb-loy-line .lb-loy-strike {
  text-decoration: line-through; text-decoration-color: rgba(217, 163, 95, .9);
  color: rgba(217, 163, 95, .9);
}
aside[aria-label="Il tuo ordine"] li.lb-loy-line::after {
  content: attr(data-lb-loy-label);
  position: absolute; top: -7px; right: 8px; z-index: 2;
  padding: 1px 8px; border-radius: 9999px;
  font-family: 'Inter', system-ui, sans-serif; font-size: 8.5px; font-weight: 600;
  letter-spacing: .13em; text-transform: uppercase; color: #2a1b0e;
  background: linear-gradient(120deg, #f6e2bb, #e8cf9a 55%, #d9a35f);
  box-shadow: 0 3px 10px rgba(0, 0, 0, .45);
  pointer-events: none; white-space: nowrap;
}

/* --- mobile context suppression (pizza options / relevant text entry) ----- */
/* Mobile-only: temporarily hide Carta Fedeltà while a pizza customization /
   options interface is open or a relevant text-entry field is active.
   Desktop behavior remains completely unchanged. */
@media (max-width: 767px), (hover: none) and (pointer: coarse) and (max-width: 932px) {
  .lb-loyalty.is-context-hidden {
    display: none !important;
    pointer-events: none !important;
  }
}
@media (max-width: 767px), (hover: none) and (pointer: coarse) and (max-width: 932px) {
  body:has(.lb-customizer) .lb-loyalty,
  body:has(.lb-mmp) .lb-loyalty,
  body:has(.lb-rew) .lb-loyalty {
    display: none !important;
    pointer-events: none !important;
  }
}


/* Website loyalty: keep the longer reward explanation usable on short screens. */
.lb-loyalty__card { max-height: calc(100vh - 8rem); overflow-y: auto; }
@supports (height: 100dvh) {
  .lb-loyalty__card { max-height: calc(100dvh - 8rem); }
}
.lb-loyalty__reward-sub { line-height: 1.45; }

/* A claimed cart line may include paid units: show their actual amount rather
   than making the whole quantity look free. */
aside[aria-label="Il tuo ordine"] .lb-loy-due {
  margin-left: .35rem; color: #f6e2bb; font-weight: 600; white-space: nowrap;
}

/* The existing mode controls are retained; only reward-only carts lock delivery. */
.lb-loy-pickup-only::after {
  content: attr(data-lb-loy-note); grid-column: 1 / -1;
  padding: .2rem .75rem .4rem; text-align: center;
  color: #e8cf9a; font-size: 11px; line-height: 1.35;
}
button[data-lb-loy-disabled] { opacity: .45; cursor: not-allowed; }

.lb-loy-checkout-unavailable {
  padding: .75rem; border-radius: 12px; border: 1px solid rgba(220,90,90,.55);
  background: rgba(220,90,90,.1); color: #f2c6b7; font-size: 12px; line-height: 1.45;
}
.lb-loyalty__error-actions { margin-top: .65rem; }
