/* Layout — Mobile-first base.
   Le regole desktop-specific (3-zone fixed, grid 16-col) sono in snippets/settings.liquid
   sotto @media (min-width: bp_desktop), perché richiedono interpolazione del breakpoint
   configurabile via Theme Settings. */

main.off-grid {
  position: relative;
  row-gap: var(--off-gap-2);
  padding-block: 0;
}

/* Chapter pages mobile: spazio in fondo per il chapter navigator fixed bottom. */
body.is-chapter main.off-grid {
  padding-bottom: var(--off-zone-middle-height, 60px);
}

/* No `contain: layout`: creerebbe un containing block per i figli position: fixed (desktop). */
.off-chapter {
  display: contents;
}

/* Mobile-first base: le 3 zone fluiscono in normal flow (subgrid del main).
   Su desktop diventano fixed center (override in settings.liquid).
   Eccezione: su chapter pages mobile, .off-zone--middle è fixed bottom (sotto). */
.off-zone--top,
.off-zone--middle,
.off-zone--bottom {
  grid-row: auto;
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: subgrid;
  column-gap: var(--off-gap-1);
  row-gap: var(--off-gap-1);
  grid-auto-flow: dense;
}

/* Chapter pages mobile: chapter navigator fixed bottom (sempre raggiungibile durante scroll).
   Spec Figma (footer node): fascia alta 220px con sfondo sfumato dall'alto (trasparente → light
   al 65%) e nav ancorata in basso → il contenuto che scorre dietro svanisce gradualmente su tutta
   la fascia, non con un taglio netto subito sopra il testo. */
body.is-chapter .off-zone--middle {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: var(--off-z-overlay);
  height: 220px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  /* rgb(from … / 0) = light a 0 alpha → fade senza velo grigio (no `transparent` keyword). */
  background: linear-gradient(to bottom, rgb(from var(--off-color-light) r g b / 0), var(--off-color-light) 65%);
  padding-bottom: 33px; /* spazio sotto la nav (Figma) */
  padding-inline: var(--off-section-padding-inline);
  pointer-events: none; /* lo scrim alto non blocca scroll/touch del contenuto dietro */
}
/* La nav resta interattiva (link capitoli + scroll orizzontale). */
body.is-chapter .off-zone--middle > * {
  pointer-events: auto;
}

.off-section {
  grid-column: 1 / -1;
}

.off-page-bg {
  position: fixed;
  inset: 0;
  z-index: var(--off-z-background);
  pointer-events: none;
}

.off-page-bg--image,
.off-page-bg--video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.off-page-bg__overlay {
  position: fixed;
  inset: 0;
  z-index: var(--off-z-background-overlay);
  background-color: var(--off-color-dark);
  pointer-events: none;
}

html[data-page-has-bg] body {
  background-color: transparent;
}

/* Dark theme = bg invertito (filter agisce sui pixel renderizzati: image, video, overlay).
   In light il video resta nei colori nativi. */
html[data-page-has-bg][data-theme='dark'] .off-page-bg {
  filter: invert(1);
}

/* Difference blend solo sui testi: sui container creerebbe uno stacking context che intercetta il filter invert del bg. */
html[data-page-has-bg] p,
html[data-page-has-bg] h1,
html[data-page-has-bg] h2,
html[data-page-has-bg] h3,
html[data-page-has-bg] .off-text-small,
html[data-page-has-bg] .off-text-medium,
html[data-page-has-bg] .chapter-step-paragraph,
html[data-page-has-bg] .main-index__label,
html[data-page-has-bg] .main-index__numeral {
  mix-blend-mode: difference;
}

/* Footer hidden su chapter pages — visibilità governata da body.is-chapter. */
body.is-chapter .off-footer {
  display: none;
}

/* Logo light/dark: rese entrambe le varianti, si mostra quella adatta allo SFONDO corrente.
   Sfondo scuro = dark theme su pagina normale, oppure pagina con bg in light (invertita, vedi settings.liquid). */
img.off-logo--dark {
  display: none;
}
html[data-theme='dark']:not([data-page-has-bg]) img.off-logo--light,
html[data-page-has-bg]:not([data-theme='dark']) img.off-logo--light {
  display: none;
}
html[data-theme='dark']:not([data-page-has-bg]) img.off-logo--dark,
html[data-page-has-bg]:not([data-theme='dark']) img.off-logo--dark {
  display: block;
}
