* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html {
  /* Scala tutte le misure in rem in base alla larghezza reale dello schermo (o dell'iframe
     di anteprima, che ha una viewport propria): da un telefono piccolo a un tablet, fino
     alla minuscola anteprima nel pannello admin, tutto resta proporzionato e non si sovrappone. */
  font-size: clamp(13px, 4.1vw, 18px);
}

body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  background: var(--bg, #171310);
  color: var(--text, #f2e9da);
  font-family: var(--font-body, 'Karla', sans-serif);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

#app { position: relative; width: 100vw; height: 100vh; height: 100dvh; overflow: hidden; }
.view { position: absolute; inset: 0; }
.view.is-hidden { display: none; }

.loading { margin: 40vh auto 0; max-width: 80vw; font-size: 1.1rem; text-align: center; color: #cfcfcf; }
.loading a { color: inherit; }

:root { --tabbar-h: 3.9rem; }

/* ---------------- Elementi condivisi ---------------- */

.topbar__row { position: relative; display: flex; align-items: center; justify-content: center; gap: .6rem; min-height: 2rem; }
.topbar__brand { display: flex; align-items: center; gap: .5rem; min-width: 0; max-width: calc(100% - 4.5rem); }
.brand__logo { height: 1.9rem; width: 1.9rem; object-fit: contain; flex-shrink: 0; border-radius: .3rem; }
.brand__name {
  font-family: var(--font-heading, 'Fraunces', serif);
  font-weight: 600;
  letter-spacing: .1rem;
  text-transform: uppercase;
  font-size: 1rem;
  color: var(--text, #fff);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.brand__name--dark { color: var(--primary, #9c3b2e); }

.langs { position: absolute; right: 0; top: 50%; transform: translateY(-50%); display: flex; gap: .3rem; flex-shrink: 0; }
.lang-pill {
  width: 1.9rem; height: 1.9rem; padding: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.05rem; line-height: 1; border-radius: 50%; cursor: pointer;
  background: rgba(0,0,0,.3); border: 1.5px solid rgba(255,255,255,.4); overflow: hidden;
}
.lang-pill.is-active { border-color: var(--secondary, #c9973f); box-shadow: 0 0 0 1.5px var(--secondary, #c9973f); }
.list__header .lang-pill { background: rgba(0,0,0,.05); border-color: rgba(0,0,0,.2); }
.list__header .lang-pill.is-active { border-color: var(--list-accent, #4c7a3f); box-shadow: 0 0 0 1.5px var(--list-accent, #4c7a3f); }

.service-badge {
  display: inline-block;
  font-size: .74rem; font-weight: 600;
  padding: .2rem .65rem; border-radius: 999px;
}

.pills { display: flex; gap: .5rem; overflow-x: auto; scrollbar-width: none; }
.pills::-webkit-scrollbar { display: none; }
.pill {
  flex-shrink: 0;
  font-family: var(--font-body); font-size: .78rem; font-weight: 600; letter-spacing: .02rem;
  border-radius: 999px; padding: .45rem .9rem; cursor: pointer;
}
.badge {
  display: inline-block; font-size: .72rem; font-weight: 700; letter-spacing: .02rem;
  border-radius: .4rem; padding: .25rem .55rem; margin-bottom: .5rem;
}

/* ---------------- Feed ("In evidenza") ---------------- */

.topbar {
  position: absolute; top: 0; left: 0; right: 0; z-index: 5;
  padding: max(env(safe-area-inset-top), .9rem) 1.1rem .75rem;
  background: linear-gradient(180deg, rgba(0,0,0,.6) 0%, rgba(0,0,0,0) 100%);
  display: flex; flex-direction: column; gap: .5rem;
}
#view-feed .topbar { pointer-events: none; }
#view-feed .topbar__row, #view-feed .pills { pointer-events: auto; }

.topbar__service { pointer-events: auto; }
.topbar .service-badge { background: rgba(0,0,0,.4); color: var(--secondary, #c9973f); border: 1px solid rgba(255,255,255,.25); }

#view-feed .pills { position: absolute; left: 0; right: 0; z-index: 5; padding: 0 1.1rem; top: 5.7rem; }
#view-feed .pill { background: rgba(0,0,0,.38); border: 1px solid rgba(255,255,255,.28); color: var(--text, #fff); }
#view-feed .pill.is-active { background: var(--secondary, #c9973f); border-color: var(--secondary, #c9973f); color: var(--bg, #171310); }

.feed {
  height: 100%;
  overflow-y: scroll;
  scroll-snap-type: y mandatory;
  scroll-behavior: smooth;
  scrollbar-width: none;
}
.feed::-webkit-scrollbar { display: none; }

.slide {
  position: relative;
  height: 100%;
  scroll-snap-align: start;
  scroll-snap-stop: always;
  overflow: hidden;
  display: flex;
  align-items: flex-end;
}

.slide__media { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: center; background: #000; }
.slide__media--empty {
  background: radial-gradient(120% 90% at 50% 100%, var(--primary, #9c3b2e) 0%, var(--bg, #171712) 72%);
  display: flex; align-items: center; justify-content: center;
}
.ghost-name {
  font-family: var(--font-heading, 'Fraunces', serif);
  font-size: 15vw; line-height: .88; text-align: center; text-transform: uppercase;
  color: rgba(255,255,255,.09); padding: 0 6vw;
}

.slide__scrim { position: absolute; inset: 0; background: linear-gradient(180deg, transparent 35%, rgba(0,0,0,.82) 92%); }

/* Il contenuto testuale e il pulsante Salva stanno sulla STESSA riga flessibile e allineata
   in basso: così il pulsante segue sempre l'altezza reale del testo (mai più "scollegato"
   quando la descrizione è lunga) e non ci va mai a finire sopra. */
.slide__content {
  position: relative; z-index: 2; width: 100%;
  padding: 0 1rem calc(var(--tabbar-h) + 1.1rem);
  display: flex;
  align-items: flex-end;
  gap: .6rem;
}
.slide__info { flex: 1; min-width: 0; }

.slide__name {
  font-family: var(--font-heading, 'Fraunces', serif);
  font-weight: 600; font-size: clamp(1.4rem, 6vw, 2.1rem);
  margin: 0 0 .45rem; color: #fff; text-shadow: 0 .15rem .6rem rgba(0,0,0,.35);
}

.sizes { display: flex; gap: 1.3rem; margin-bottom: .5rem; flex-wrap: wrap; }
.sizes__opt { display: flex; flex-direction: column; }
.sizes__price { font-size: 1.15rem; font-weight: 700; color: var(--secondary, #c9973f); }
.sizes__label { font-size: .72rem; opacity: .8; }

.attrs { margin: 0 0 .4rem; font-size: .8rem; line-height: 1.5; opacity: .82; }
.attrs p { margin: 0; }

.desc { font-size: .82rem; line-height: 1.45; opacity: .88; margin: .35rem 0 .3rem; max-width: 34rem; }
.desc[data-expanded="false"] { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.desc[data-expanded="true"] { display: block; }

.more-btn {
  background: none; border: none; padding: 0; cursor: pointer;
  font-family: var(--font-body); font-size: .76rem; font-weight: 700;
  color: var(--secondary, #c9973f); text-decoration: underline;
}

.save-btn {
  flex-shrink: 0;
  display: flex; flex-direction: column; align-items: center; gap: .3rem;
  background: none; border: none; color: #fff; cursor: pointer; padding: 0 0 .1rem;
}
.save-btn__icon {
  width: 2.6rem; height: 2.6rem; border-radius: 50%;
  background: rgba(0,0,0,.42); border: 1px solid rgba(255,255,255,.32);
  display: flex; align-items: center; justify-content: center;
}
.save-btn__icon svg { width: 1.15rem; height: 1.15rem; }
.save-btn__label { font-size: .66rem; font-weight: 600; text-shadow: 0 .1rem .3rem rgba(0,0,0,.4); }
.save-btn.is-saved .save-btn__icon { color: var(--secondary, #c9973f); border-color: var(--secondary, #c9973f); }

@media (prefers-reduced-motion: reduce) { .feed { scroll-behavior: auto; } }

/* ---------------- Messaggio di conferma (toast) ---------------- */

.toast {
  position: absolute;
  left: 50%;
  bottom: calc(var(--tabbar-h) + .7rem);
  transform: translateX(-50%) translateY(.4rem);
  z-index: 20;
  max-width: min(90%, 26rem);
  background: #fff;
  color: #23201b;
  font-size: .82rem;
  font-weight: 600;
  padding: .6rem 1rem;
  border-radius: .7rem;
  box-shadow: 0 .6rem 1.6rem -.5rem rgba(0,0,0,.4);
  display: flex; align-items: center; gap: .5rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
}
.toast.is-visible { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast__check { color: var(--list-accent, #4c7a3f); flex-shrink: 0; }

/* ---------------- List ("Menu completo") ---------------- */

#view-list {
  background: color-mix(in srgb, var(--list-accent, #4c7a3f) 12%, #fbf9f3);
  color: #23201b;
}
#view-list:not(.is-hidden) {
  display: flex;
  flex-direction: column;
}

.list__header { padding: max(env(safe-area-inset-top), 1rem) 1.1rem .6rem; flex-shrink: 0; }

.pills--light { padding: 0 1.1rem .6rem; flex-shrink: 0; }
.pills--light .pill { background: transparent; border: 1.5px solid var(--list-accent, #4c7a3f); color: var(--list-accent, #4c7a3f); }
.pills--light .pill.is-active { background: var(--list-accent, #4c7a3f); color: #fff; }

.list__service { padding: 0 1.1rem .6rem; flex-shrink: 0; }
.list__service .service-badge { background: color-mix(in srgb, var(--list-accent, #4c7a3f) 15%, transparent); color: var(--list-accent, #4c7a3f); }

.list__scroll { flex: 1; overflow-y: auto; padding: 0 1.1rem calc(var(--tabbar-h) + 1.5rem); }

.list__cat {
  font-family: var(--font-heading, 'Fraunces', serif);
  color: var(--list-accent, #4c7a3f);
  text-transform: uppercase; letter-spacing: .12rem; font-size: 1rem;
  margin: 1.4rem 0 .6rem;
}
.list__cat:first-of-type { margin-top: .25rem; }

.card { position: relative; background: #fff; border: 1px solid rgba(0,0,0,.08); border-radius: .9rem; padding: .9rem 4.4rem .9rem 1rem; margin-bottom: .6rem; }
.card .badge--list { background: var(--secondary, #c9973f); color: #fff; }
.card h4 { font-family: var(--font-heading, 'Fraunces', serif); font-size: 1.05rem; margin: 0 0 .4rem; color: #23201b; }
.card .sizes__price { color: var(--list-accent, #4c7a3f); }
.card .sizes__label { color: #6b6559; }
.card .attrs { color: #6b6559; opacity: 1; }
.card__desc { font-size: .82rem; line-height: 1.45; color: #55503f; margin: .35rem 0 0; }
.card__desc[data-expanded="false"] { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card__desc[data-expanded="true"] { display: block; }
.card .more-btn { color: var(--list-accent, #4c7a3f); margin-top: .3rem; display: inline-block; }

.card .save-btn {
  position: absolute; top: .7rem; right: .75rem;
  color: var(--list-accent, #4c7a3f);
}
.card .save-btn__icon { background: var(--list-accent, #4c7a3f); border: none; color: #fff; }
.card .save-btn.is-saved .save-btn__icon { background: #fff; border: 1.5px solid var(--list-accent, #4c7a3f); color: var(--list-accent, #4c7a3f); }
.card .save-btn__label { color: var(--list-accent, #4c7a3f); text-shadow: none; }

/* ---------------- Summary ("Riepilogo") ---------------- */

#view-summary {
  background: color-mix(in srgb, var(--list-accent, #4c7a3f) 12%, #fbf9f3);
  color: #23201b;
  height: 100%;
  overflow-y: auto;
  padding-bottom: calc(var(--tabbar-h) + 1.5rem);
}

.summary__banner {
  background: var(--list-accent, #4c7a3f);
  color: #fff;
  text-align: center;
  font-size: .86rem;
  font-weight: 600;
  line-height: 1.4;
  padding: calc(max(env(safe-area-inset-top), .6rem) + .9rem) 1.2rem .9rem;
}

.summary__service { padding: .75rem 1.1rem 0; }
.summary__service .service-badge { background: color-mix(in srgb, var(--list-accent, #4c7a3f) 15%, transparent); color: var(--list-accent, #4c7a3f); }

.summary__list { padding: .9rem 1.1rem 0; }
.summary__empty { font-size: .86rem; color: #6b6559; text-align: center; margin-top: 1.8rem; line-height: 1.5; }

.summary-row {
  display: flex; align-items: center; gap: .7rem;
  background: #fff; border: 1px solid rgba(0,0,0,.08); border-radius: .9rem;
  padding: .7rem .85rem; margin-bottom: .6rem;
}
.summary-row__info { flex: 1; min-width: 0; }
.summary-row__name { font-family: var(--font-heading, 'Fraunces', serif); font-size: .96rem; margin: 0; color: #23201b; }
.summary-row__price { font-size: .8rem; color: var(--list-accent, #4c7a3f); font-weight: 700; margin: .1rem 0 0; }
.summary-row__qty {
  display: flex; align-items: center; gap: .5rem;
  background: #f3f1ea; border-radius: 999px; padding: .25rem .6rem; flex-shrink: 0;
}
.qty-btn { background: none; border: none; font-size: 1.1rem; line-height: 1; width: 1.1rem; color: #23201b; cursor: pointer; }
.summary-row__qty span { min-width: .8rem; text-align: center; font-weight: 600; font-size: .86rem; }
.qty-remove { background: none; border: none; color: #a33; cursor: pointer; flex-shrink: 0; display: flex; }

/* ---------------- Tab bar ---------------- */

.tabbar {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 10;
  height: var(--tabbar-h);
  padding-bottom: env(safe-area-inset-bottom, 0);
  display: flex;
  background: rgba(15,13,11,.92);
  backdrop-filter: blur(6px);
  border-top: 1px solid rgba(255,255,255,.08);
}
.tab {
  flex: 1; position: relative;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .1rem;
  background: none; border: none; cursor: pointer;
  font-family: var(--font-body); font-size: .72rem; font-weight: 600;
  color: rgba(255,255,255,.55);
}
.tab.is-active { color: var(--secondary, #c9973f); }
.tab__icon { font-size: .9rem; }
.tab-badge {
  position: absolute; top: .1rem; right: 24%;
  background: #c0392b; color: #fff; font-size: .6rem; font-weight: 700;
  min-width: .95rem; height: .95rem; border-radius: 999px;
  display: flex; align-items: center; justify-content: center; padding: 0 .2rem;
}

/* ---------------- Adattamento schermo ---------------- */

@media (orientation: landscape) and (max-height: 500px) {
  html { font-size: clamp(11px, 2.4vh, 15px); }
  #view-feed .pills { top: 4.6rem; }
}

@media (min-width: 700px) {
  .slide__content, .list__scroll, .summary__list { max-width: 40rem; margin: 0 auto; }
  .list__header .topbar__row, .list__service, .pills--light, .summary__banner, .summary__service { max-width: 40rem; margin-left: auto; margin-right: auto; }
}
