*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  background: #0e1410;
  font-family: 'Montserrat', system-ui, -apple-system, sans-serif;
  color: #fff;
}

.app {
  position: relative;
  width: 100%;
  height: 100dvh;
  overflow: hidden;
}

.language-picker {
  position: absolute;
  top: 18px;
  right: 18px;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 8px;
  background: rgba(14, 20, 16, 0.72);
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.language-picker select {
  min-width: 52px;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
}

.language-picker option {
  color: #111;
}

.app .hs-stage {
  width: 100%;
  height: 100%;
}

.app.is-video-loading .hs-stage__img,
.app.is-video-loading .hs-stage__idle-video,
.app.is-video-loading .hs-stage__video {
  /* filter: blur(14px);
  transition: filter 0.22s ease; */
}

.video-loader {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(255, 255, 255, 0);
  pointer-events: none;
}

.video-loader[hidden] {
  display: none;
}

.video-loader__box {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-width: 190px;
  justify-content: center;
  padding: 16px 22px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.3);
  color: #000;
  font-size: 15px;
  font-weight: 800;
}

.video-loader__spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: video-loader-spin 0.8s linear infinite;
}

@keyframes video-loader-spin {
  to {
    transform: rotate(360deg);
  }
}

/* ==========================================================================
   Header e footer delle sottosezioni (assenti sulla home)
   ========================================================================== */

.ui-header,
.ui-footer {
  position: absolute;
  left: 0;
  right: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  pointer-events: none; /* lascia passare i click verso gli hotspot */
  animation: chrome-in 0.45s ease both;
}

.ui-header[hidden],
.ui-footer[hidden] {
  display: none;
}

/* --- header --------------------------------------------------------------- */

.ui-header {
  display: flex;
  justify-content: center;
  top: 0;
  min-height: clamp(64px, 11vh, 104px);
  padding: max(14px, env(safe-area-inset-top)) 18px 26px;
  gap: 12px;
  background: linear-gradient(180deg, rgba(10, 16, 8, 0.62) 0%, rgba(10, 16, 8, 0) 100%);
}

.ui-header__back {
  pointer-events: auto;
  flex: 0 0 auto;
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: #fff;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.2s ease;
}

.ui-header__back:hover {
  background: rgba(255, 255, 255, 0.16);
  transform: translateX(-2px);
}

.ui-header__back[hidden] {
  display: none;
}

.ui-header__back svg {
  width: 26px;
  height: 26px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.ui-header__title {
  margin: 0;
  text-align: center;
  /* compensa la larghezza del pulsante indietro per restare centrato */
  padding-right: 46px;
  font-size: clamp(20px, 2.4vw, 30px);
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: #fff;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.45);
}

/* --- footer --------------------------------------------------------------- */

.ui-footer {
  bottom: 0;
  justify-content: center;
  gap: clamp(18px, 7vw, 90px);
  padding: 34px 18px max(20px, env(safe-area-inset-bottom));
  background: linear-gradient(0deg, rgba(10, 16, 8, 0.55) 0%, rgba(10, 16, 8, 0) 100%);
}

.ui-footer__btn {
  pointer-events: auto;
  appearance: none;
  cursor: pointer;
  font-family: inherit;
  font-weight: 600;
  font-size: clamp(14px, 1.35vw, 20px);
  letter-spacing: 0.02em;
  line-height: 1;
  text-transform: uppercase;
  white-space: nowrap;
  padding: 13px 30px 14px;
  border-radius: 999px;
  border: 3px solid #6cb03c;
  background: #fff;
  color: #5aa02f;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.25);
  transition: transform 0.18s ease, background 0.18s ease, color 0.18s ease;
}

.ui-footer__btn:hover,
.ui-footer__btn:focus-visible {
  transform: translateY(-2px);
  background: #6cb03c;
  color: #fff;
  outline: none;
}

.ui-footer__btn[hidden] {
  display: none;
}

/* durante una transizione header e footer non sono cliccabili */
.app.is-transitioning .ui-header,
.app.is-transitioning .ui-footer {
  opacity: 0;
  transition: opacity 0.2s ease;
}

@keyframes chrome-in {
  from {
    opacity: 0;
    transform: translateY(var(--chrome-shift, -12px));
  }
}

.ui-footer {
  --chrome-shift: 12px;
}

/* ==========================================================================
   Intro di apertura
   ========================================================================== */

.app.is-intro .ui-header,
.app.is-intro .ui-footer {
  opacity: 0;
  pointer-events: none;
}

.intro-skip {
  position: absolute;
  right: max(18px, env(safe-area-inset-right));
  bottom: max(18px, env(safe-area-inset-bottom));
  z-index: 30;
  padding: 11px 24px;
  border-radius: 999px;
  border: 2px solid rgba(255, 255, 255, 0.8);
  background: rgba(10, 16, 8, 0.42);
  backdrop-filter: blur(6px);
  color: #fff;
  font-family: inherit;
  font-weight: 800;
  font-size: 14px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
  animation: skip-in 0.6s 0.8s ease both;
  transition: background 0.2s ease, transform 0.2s ease;
}

.intro-skip:hover {
  background: rgba(10, 16, 8, 0.7);
  transform: translateY(-2px);
}

.intro-skip[hidden] {
  display: none;
}

.intro-start {
  position: absolute;
  inset: 0;
  z-index: 40;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  background: rgba(8, 14, 6, 0.62);
  backdrop-filter: blur(3px);
  color: #fff;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  cursor: pointer;
}

.intro-start[hidden] {
  display: none;
}

.intro-start__btn {
  width: 88px;
  height: 88px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 4px solid #fff;
  background: linear-gradient(180deg, #7cbb45, #4d8a26);
  cursor: pointer;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.4);
}

.intro-start__btn svg {
  width: 40px;
  height: 40px;
  margin-left: 5px;
  fill: #fff;
}

@keyframes skip-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
}

/* --- diagnostica (?diag) -------------------------------------------------- */

.diag {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 90;
  max-height: 45dvh;
  overflow: auto;
  margin: 0;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  background: rgba(0, 0, 0, 0.82);
  color: #9fe870;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 10px;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-all;
}

.diag.is-small {
  max-height: 3.2em;
}

/* --- stato vuoto ---------------------------------------------------------- */

.app__empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: #10180f;
}

.app__empty[hidden] {
  display: none;
}

.app__empty-card {
  max-width: 460px;
  text-align: center;
}

.app__empty-card h1 {
  margin: 0 0 12px;
  font-size: 28px;
  font-weight: 900;
}

.app__empty-card p {
  margin: 0 0 24px;
  color: #b9c9b2;
  line-height: 1.55;
}

.app__empty-btn {
  display: inline-block;
  padding: 13px 26px;
  border-radius: 999px;
  border: 3px solid #fff;
  background: linear-gradient(180deg, #7cbb45, #4d8a26);
  color: #fff;
  font-weight: 800;
  text-decoration: none;
  text-transform: uppercase;
}

/* --- pannello contenuto --------------------------------------------------- */

.panel {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 24px;
}

.panel[hidden] {
  display: none;
}

.panel__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(8, 16, 8, 0.72);
  backdrop-filter: blur(4px);
  animation: panel-fade 0.25s ease;
}

.panel__box {
  position: relative;
  width: min(560px, 100%);
  max-height: 82dvh;
  overflow: auto;
  padding: 38px 38px 34px;
  border-radius: 22px;
  border: 3px solid rgba(255, 255, 255, 0.9);
  background: linear-gradient(170deg, #f7fbf3, #e8f2e0);
  color: #1d2a17;
  box-shadow: 0 28px 60px rgba(0, 0, 0, 0.45);
  animation: panel-pop 0.28s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}

.panel__close {
  position: absolute;
  top: 12px;
  right: 14px;
  width: 38px;
  height: 38px;
  border: none;
  border-radius: 50%;
  background: rgba(29, 42, 23, 0.08);
  color: #1d2a17;
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
}

.panel__close:hover {
  background: rgba(29, 42, 23, 0.16);
}

.panel__title {
  margin: 0 0 14px;
  font-size: 30px;
  font-weight: 700;
  color: #3f7a1f;
  text-transform: uppercase;
}

.panel__body p {
  margin: 0 0 12px;
  line-height: 1.6;
  font-size: 17px;
}

/* immagini inserite nel testo con ![didascalia](percorso) */
.panel__figure {
  margin: 16px 0;
}

.panel__figure img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 12px;
  background: rgba(29, 42, 23, 0.06);
}

.panel__figure figcaption {
  margin-top: 6px;
  font-size: 13.5px;
  line-height: 1.45;
  color: rgba(29, 42, 23, 0.7);
}

/* file non trovato: segnaposto al posto dell'icona rotta */
.panel__figure[data-missing] img {
  min-height: 90px;
  border: 2px dashed rgba(29, 42, 23, 0.3);
}

.panel__figure[data-missing]::after {
  content: 'Immagine non trovata: ' attr(data-missing);
  display: block;
  margin-top: 6px;
  font-size: 12.5px;
  color: #a3421c;
}

.panel__link {
  display: inline-block;
  margin-top: 10px;
  padding: 11px 22px;
  border-radius: 999px;
  background: linear-gradient(180deg, #7cbb45, #4d8a26);
  color: #fff;
  font-weight: 600;
  text-decoration: none;
}

.panel__link[hidden] {
  display: none;
}

/* --------------------------------------------------------------------------
   Mobile: il pannello diventa un foglio agganciato in basso, alto 2/3 dello
   schermo. Titolo e chiusura restano fermi, scorre solo il corpo.
   `data-device` lo imposta app.js seguendo il breakpoint della config.
   -------------------------------------------------------------------------- */
:root[data-device='mobile'] .panel {
  padding: 0;
  place-items: end stretch;
}

:root[data-device='mobile'] .panel__box {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: calc(100dvh * 2 / 3);
  max-height: none;
  overflow: hidden;
  padding: 22px 20px calc(16px + env(safe-area-inset-bottom));
  border-width: 3px 0 0;
  border-radius: 22px 22px 0 0;
  animation: panel-up 0.3s cubic-bezier(0.2, 0.9, 0.3, 1.05);
}

:root[data-device='mobile'] .panel__title {
  flex: none;
  margin: 0 0 12px;
  padding: 0 44px 10px 0;
  border-bottom: 1px solid rgba(29, 42, 23, 0.14);
  font-size: 24px;
}

:root[data-device='mobile'] .panel__body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

/* il link resta agganciato in fondo, sempre raggiungibile */
:root[data-device='mobile'] .panel__link {
  flex: none;
  align-self: flex-start;
  margin-top: 14px;
}

:root[data-device='mobile'] .panel__close {
  top: 14px;
  right: 14px;
}

@keyframes panel-up {
  from {
    transform: translateY(100%);
  }
}

@keyframes panel-fade {
  from {
    opacity: 0;
  }
}

@keyframes panel-pop {
  from {
    opacity: 0;
    transform: translateY(18px) scale(0.96);
  }
}
