/*
 * Port del viewer web del SaaS (frontend/src/assets/style.scss:
 * classi base ~160-300 + .web-menu ~529-636), tutto namespaced sotto
 * .menu-publisher-embed per non collidere con il tema WordPress.
 * Le custom properties sono sovrascritte inline dal renderer (tema del menu).
 */

/* Font di default del tema, impacchettato nel plugin (come style.scss del SaaS). */
@font-face {
  font-family: "Gulax";
  src: url("../fonts/Gulax-Regular.woff2") format("woff2");
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

.menu-publisher-embed {
  --pbg: #f5f0e1;
  --ink: #1a1208;
  --rule: #1a1208;
  --accent: #7a6a45;
  --divider: rgba(26, 18, 8, 0.13);
  --font-display: "Gulax", Georgia, "Times New Roman", serif;
  --page-bg-image: none;
  --fs-page-title: 1;
  --fs-section-title: 1;
  --fs-item-title: 1;
  --fs-description: 1;
  box-sizing: border-box;
}

.menu-publisher-embed *,
.menu-publisher-embed *::before,
.menu-publisher-embed *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* ---- Contenitore (da .web-menu; min-height 100vh rimosso: siamo embedded) ---- */
.menu-publisher-embed.menu-publisher-native {
  background-color: var(--pbg);
  background-image: var(--page-bg-image);
  background-size: cover;
  background-position: center;
  font-family: var(--font-display);
  color: var(--ink);
}

.menu-publisher-embed .web-group {
  max-width: 42rem;
  margin: 0 auto;
  padding: 0 1.25rem 4rem;
}

/* Immagine/logo header: in-flow nella griglia del titolo, cosi' l'altezza
   dell'header segue il logo; il testo resta centrato (colonna 2). */
.menu-publisher-embed .mp-menu-image-header {
  max-height: calc(1.2em * var(--menu-image-size, 1));
  max-width: 100%;
  object-fit: contain;
}
.menu-publisher-embed .mp-menu-image-header.left {
  grid-column: 1;
  justify-self: start;
}
.menu-publisher-embed .mp-menu-image-header.right {
  grid-column: 3;
  justify-self: end;
}

/* Banda immagine: footer centrato in fondo (e fallback header senza titoli). */
.menu-publisher-embed .mp-menu-image {
  max-width: 42rem;
  margin: 0 auto;
  padding: 1rem 1.25rem 0;
  display: flex;
  justify-content: center;
}
.menu-publisher-embed .mp-menu-image.left {
  justify-content: flex-start;
}
.menu-publisher-embed .mp-menu-image.right {
  justify-content: flex-end;
}
.menu-publisher-embed .mp-menu-image.footer {
  padding: 1rem 1.25rem 2rem;
}
.menu-publisher-embed .mp-menu-image img {
  max-height: calc(4rem * var(--menu-image-size, 1));
  max-width: 100%;
  object-fit: contain;
}

.menu-publisher-embed .web-group-title {
  position: sticky;
  /* sotto l'admin bar di WP quando presente */
  top: var(--wp-admin--admin-bar--height, 0px);
  z-index: 1;
  background-color: var(--pbg);
  font-family: var(--font-display);
  font-weight: normal;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  text-align: center;
  color: var(--ink);
  font-size: calc(2.2rem * var(--fs-page-title));
  line-height: 1;
  padding: 0.7rem 0 0.45rem;
  border-bottom: 3px solid var(--rule);
  margin-bottom: 1rem;
  white-space: pre-line;
  /* 3 colonne: logo | titolo | logo. L'header cresce col logo (in-flow). */
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
}
.menu-publisher-embed .web-group-title-text {
  grid-column: 2;
}

/* ---- Sezione ---- */
.menu-publisher-embed .menu-section {
  display: flex;
  flex-direction: column;
  gap: 0;
  margin-bottom: 1.5rem;
}

.menu-publisher-embed .section-header {
  margin-bottom: 0.5rem;
}

.menu-publisher-embed .section-title {
  font-family: var(--font-display);
  font-weight: bold;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink);
  line-height: 1.2;
  border-bottom: 2px solid var(--ink);
  padding-bottom: 0;
  display: inline-block;
  font-size: calc(1.3rem * var(--fs-section-title));
}

.menu-publisher-embed .section-subtitle {
  font-family: var(--font-display);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
  margin-top: 0.2rem;
  font-style: italic;
  font-size: calc(0.95rem * var(--fs-section-title));
}

/* ---- Item ---- */
.menu-publisher-embed .web-items {
  display: grid;
  grid-template-columns: 1fr;
}

.menu-publisher-embed .menu-item {
  border-bottom: 1px solid var(--divider);
  padding: 0.7rem 0 0.55rem;
}

.menu-publisher-embed .menu-item.full {
  grid-column: 1 / -1;
}

.menu-publisher-embed .item-title-row {
  display: flex;
  align-items: flex-start;
  gap: 0.15rem;
}

/* Senza descrizione il prezzo sale sulla riga del titolo, allineato a destra
   (l'allineamento a destra viene da .item-price { margin-left: auto }). */
.menu-publisher-embed .item-title-row.title-with-price {
  align-items: baseline;
}

.menu-publisher-embed .item-title {
  font-family: var(--font-display);
  font-weight: bold;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink);
  line-height: 1.25;
  font-size: calc(1.2rem * var(--fs-item-title));
  white-space: pre-line;
}

.menu-publisher-embed .item-allergens {
  font-family: var(--font-display);
  color: var(--accent);
  font-size: calc(0.62rem * var(--fs-item-title, 1));
  letter-spacing: 0.08em;
  line-height: 1;
  padding-top: 0.2em;
  white-space: nowrap;
}

/* Indicatore "prodotto con immagine" accanto al titolo. */
.menu-publisher-embed .item-image-ico {
  flex-shrink: 0;
  width: calc(0.95rem * var(--fs-item-title, 1));
  height: calc(0.95rem * var(--fs-item-title, 1));
  color: var(--accent);
  opacity: 0.75;
  margin-top: 0.15em;
}

/* Item con immagine: cliccabile per aprire il lightbox. */
.menu-publisher-embed .menu-item.has-image {
  cursor: pointer;
  transition: background-color 0.15s ease;
}
.menu-publisher-embed .menu-item.has-image:hover {
  background-color: rgba(0, 0, 0, 0.04);
}
/* Focus da tastiera ben visibile (non affidarsi all'outline del tema WP). */
.menu-publisher-embed .menu-item.has-image:focus-visible {
  outline: 3px solid #2563eb;
  outline-offset: 2px;
  border-radius: 2px;
}

.menu-publisher-embed .item-body {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  margin-top: 0.2rem;
}

.menu-publisher-embed .item-description {
  font-family: var(--font-display);
  color: var(--accent);
  line-height: 1.4;
  flex: 1;
  font-size: calc(1.05rem * var(--fs-description));
  white-space: pre-line;
}

.menu-publisher-embed .item-price {
  flex-shrink: 0;
  display: flex;
  gap: 0.55rem;
  align-items: center;
  margin-left: auto;
}

.menu-publisher-embed .price-entry {
  display: flex;
  align-items: center;
  gap: 0.2rem;
  font-family: var(--font-display);
  color: var(--accent);
  white-space: nowrap;
  letter-spacing: 0.02em;
  font-size: calc(1.05rem * var(--fs-item-title));
}

.menu-publisher-embed .price-icon {
  flex-shrink: 0;
  width: 17px;
  height: 17px;
  margin-left: 14px;
}

/* ---- Footer di gruppo e legenda allergeni ---- */
.menu-publisher-embed .web-group-footer {
  text-align: center;
  margin-top: 1.2rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--accent);
  font-size: 0.75rem;
  white-space: pre-line;
}

.menu-publisher-embed .allergen-legend {
  font-family: var(--font-display);
  color: var(--ink);
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem 1.1rem;
  font-size: 0.85rem;
  padding: 0.8rem 1.5rem;
}

.menu-publisher-embed .allergen-legend sup {
  color: var(--accent);
  font-weight: bold;
}

/* ---- Desktop: due colonne ---- */
@media (min-width: 768px) {
  .menu-publisher-embed .web-group,
  .menu-publisher-embed .mp-menu-image {
    max-width: 80vw;
  }

  .menu-publisher-embed .web-items {
    grid-template-columns: 1fr 1fr;
    column-gap: 3rem;
  }

  .menu-publisher-embed .section-title {
    font-size: calc(1.15rem * var(--fs-section-title));
  }

  .menu-publisher-embed .section-subtitle {
    font-size: calc(0.85rem * var(--fs-section-title));
  }

  .menu-publisher-embed .item-title {
    font-size: calc(1.05rem * var(--fs-item-title));
  }

  .menu-publisher-embed .item-description {
    font-size: calc(0.95rem * var(--fs-description));
  }

  .menu-publisher-embed .price-entry {
    font-size: calc(0.95rem * var(--fs-item-title));
  }

  .menu-publisher-embed .price-icon {
    width: 15px;
    height: 15px;
  }
}

/* ---- Modalità iframe ---- */
.menu-publisher-embed.menu-publisher-iframe-wrap iframe {
  display: block;
  width: 100%;
  border: 0;
  height: clamp(480px, 80vh, 1200px);
}

/* ---- Box di errore ---- */
.menu-publisher-embed.menu-publisher-error {
  padding: 1rem 1.25rem;
  border: 1px solid rgba(0, 0, 0, 0.15);
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.03);
  font-style: italic;
}

/* ---- Lightbox immagine prodotto (montato su <body>, non namespaced) ---- */
.mp-lightbox {
  position: fixed;
  inset: 0;
  z-index: 100000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 1.5rem;
  background-color: rgba(0, 0, 0, 0.85);
}
.mp-lightbox[hidden] {
  display: none;
}
.mp-lightbox-figure {
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.9rem;
  max-width: min(92vw, 900px);
  max-height: 90vh;
}
.mp-lightbox-figure img {
  max-width: 100%;
  max-height: 70vh;
  object-fit: contain;
  border-radius: 6px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}
.mp-lightbox-caption {
  text-align: center;
  color: #fff;
  max-width: 42rem;
}
.mp-lightbox-title {
  font-weight: bold;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-size: 1.1rem;
  white-space: pre-line;
}
.mp-lightbox-desc {
  margin-top: 0.35rem;
  opacity: 0.85;
  line-height: 1.4;
  white-space: pre-line;
}
.mp-lightbox-close {
  position: absolute;
  top: 0.6rem;
  right: 0.9rem;
  background: none;
  border: none;
  color: #fff;
  font-size: 2.4rem;
  line-height: 1;
  cursor: pointer;
  padding: 0.2rem 0.6rem;
}
.mp-lightbox-close:focus-visible {
  outline: 3px solid #fff;
  outline-offset: 2px;
  border-radius: 4px;
}
body.mp-lightbox-open {
  overflow: hidden;
}
