/*
 * POI di Trame (QR code nel museo): pagina leggera mobile-first, CSS non compilato e indipendente
 * dal resto del tema. Colori dal POI: --trame-bg (sfondo) e --trame-fg (testo), scritti nel <head>.
 * Template: templates/TramePOI.ss — JS: src/js/trame.js (copiato in dist/js/trame.js da npm run build:js)
 */
/* Font Omnitype (licenza in Downloads/Font/Omnitype-EULA-2026.pdf): OT Parallel per i titoli,
   OT Polar per il testo. Esiste solo il peso Regular, quindi niente grassetti/light finti. */
@font-face {
  font-family: "OT Parallel";
  src: url("../dist/fonts/trame/OTParallel-Regular.woff2") format("woff2"), url("../dist/fonts/trame/OTParallel-Regular.woff") format("woff");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "OT Polar";
  src: url("../dist/fonts/trame/OTPolar-Regular.woff2") format("woff2"), url("../dist/fonts/trame/OTPolar-Regular.woff") format("woff");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  --trame-bg: #f5f1ea;
  --trame-fg: #1b1b1b;
  --trame-gutter: 20px;
  --trame-max: 640px;
  --trame-ease: cubic-bezier(.22, .61, .36, 1);
  --trame-heading: "OT Parallel", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --trame-body: "OT Polar", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  /* tinte ricavate dal colore del testo: bordi, fondi dei bottoni */
  --trame-line: color-mix(in srgb, var(--trame-fg) 18%, transparent);
  --trame-soft: color-mix(in srgb, var(--trame-fg) 8%, transparent);
}

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

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

body.trame {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--trame-bg);
  color: var(--trame-fg);
  font-family: var(--trame-body);
  font-size: 1.0625rem;
  line-height: 1.6;
  font-synthesis-weight: none;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

img { max-width: 100%; height: auto; display: block; }
button { font: inherit; color: inherit; }
a { color: inherit; }

.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

:focus-visible { outline: 2px solid currentColor; outline-offset: 3px; }

/* ---------- Header: logo al centro, lingua a destra ---------- */
.trame-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 60px;
  padding: max(8px, env(safe-area-inset-top)) var(--trame-gutter) 8px;
  background: var(--trame-bg);
  transition: box-shadow .3s var(--trame-ease);
}
.trame-header.is-scrolled { box-shadow: 0 1px 0 var(--trame-line); }

.trame--header-scuro .trame-header { --trame-header-fg: #111; }
.trame--header-chiaro .trame-header { --trame-header-fg: #fff; }
.trame-header { color: var(--trame-header-fg); }

.trame-header__logo { height: 36px; width: auto; max-width: 60vw; object-fit: contain; object-position: left center; }
.trame-header__logo--schiarito { filter: brightness(0) invert(1); }
.trame-header__nome {
  font-family: var(--trame-heading);
  font-size: 1.25rem;
  letter-spacing: .14em;
  text-transform: uppercase;
}

.trame-lang {
  margin-left: auto;
  display: flex;
  gap: 2px;
  font-size: .8125rem;
  font-weight: 400;
  letter-spacing: .06em;
}
.trame-lang__item {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 40px;
  min-height: 40px;
  padding: 0 6px;
  border-radius: 999px;
  text-decoration: none;
  opacity: .55;
  transition: opacity .2s, background-color .2s;
}
.trame-lang__item.is-current { opacity: 1; }
a.trame-lang__item:hover, a.trame-lang__item:focus-visible { opacity: 1; background: color-mix(in srgb, var(--trame-header-fg) 10%, transparent); }

/* ---------- Contenuto ---------- */
.trame-main {
  max-width: var(--trame-max);
  margin: 0 auto;
  padding: 8px 0 calc(56px + env(safe-area-inset-bottom));
}
.trame-intro, .trame-testo, .trame-approfondire { padding: 0 var(--trame-gutter); }

.trame-intro { text-align: center; }
.trame-titolo {
  margin: 16px 0 0;
  font-family: var(--trame-heading);
  font-weight: 400;
  font-size: clamp(2rem, 9vw, 2.75rem);
  line-height: 1.08;
  letter-spacing: -.01em;
  text-wrap: balance;
}
.trame-sottotitolo {
  margin: 8px 0 0;
  font-size: clamp(1.625rem, 7.4vw, 2.375rem);
  line-height: 1.15;
  opacity: .78;
  text-wrap: balance;
  text-wrap: pretty;
}

.trame-testo { margin-top: 28px; }
.trame-testo > :first-child { margin-top: 0; }
.trame-testo p { margin: 0 0 1em; text-wrap: pretty; }
.trame-testo h2, .trame-testo h3 { font-family: var(--trame-heading); font-weight: 400; line-height: 1.2; margin: 1.6em 0 .5em; }
.trame-testo h2 { font-size: 1.5rem; }
.trame-testo h3 { font-size: 1.25rem; }
.trame-testo a { text-underline-offset: 3px; }
.trame-testo img { border-radius: 4px; margin: 1.2em 0; }
.trame-testo blockquote { margin: 1.4em 0; padding-left: 16px; border-left: 2px solid currentColor; font-style: italic; }

.trame-didascalia {
  margin-top: 10px;
  font-size: .8125rem;
  line-height: 1.4;
  opacity: .72;
}

/* ---------- Immagine singola ---------- */
.trame-immagine { margin: 24px 0 0; }
.trame-immagine .trame-didascalia { padding: 0 var(--trame-gutter); }
.trame-immagine .trame-zoom img { width: 100%; }

/* bottone attorno all'immagine: apre lo zoom */
.trame-zoom {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background: var(--trame-soft);
  cursor: zoom-in;
  overflow: hidden;
}
.trame-zoom img { transition: transform .5s var(--trame-ease), opacity .4s; }
@media (hover: hover) { .trame-zoom:hover img { transform: scale(1.02); } }

/* ---------- Carosello: slide all'84% così si vede l'inizio della successiva ---------- */
.trame-carousel { margin-top: 24px; }
.trame-carousel__track {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin: 0;
  padding: 0 var(--trame-gutter);
  list-style: none;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scroll-snap-type: x mandatory;
  scroll-padding: 0 var(--trame-gutter);
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.trame-carousel__track::-webkit-scrollbar { display: none; }
/* scorrimento orizzontale col dito sempre permesso, anche partendo da un'immagine */
.trame-carousel__track, .trame-lb__track { touch-action: pan-x pan-y; }
.trame-carousel__track img, .trame-lb__track img { -webkit-user-drag: none; user-select: none; }
@media (hover: hover) and (pointer: fine) { .trame-carousel__track { cursor: grab; } }
.trame-carousel__track.is-dragging, .trame-lb__track.is-dragging { scroll-snap-type: none; cursor: grabbing; }
.trame-carousel__track.is-dragging .trame-zoom { cursor: grabbing; }
.trame-carousel__track:focus-visible { outline-offset: -2px; }
.trame-carousel__slide {
  flex: 0 0 84%;
  scroll-snap-align: start;
  transition: opacity .4s var(--trame-ease);
}
.trame-carousel__slide:last-child { scroll-snap-align: end; }
.trame-carousel__slide figure { margin: 0; }
.trame-carousel__slide:not(.is-active) { opacity: .55; }
.trame-carousel__slide .trame-zoom { border-radius: 2px; }
.trame-carousel__slide .trame-zoom img { width: 100%; max-height: 68vh; max-height: 68dvh; object-fit: contain; }
@media (min-width: 720px) { .trame-carousel__slide { flex-basis: 560px; } }

.trame-carousel__controls {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  padding: 10px var(--trame-gutter) 0;
}
.trame-carousel__count {
  min-width: 52px;
  text-align: center;
  font-size: .8125rem;
  font-variant-numeric: tabular-nums;
  letter-spacing: .04em;
}

.trame-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid var(--trame-line);
  border-radius: 999px;
  background: transparent;
  cursor: pointer;
  transition: background-color .2s, opacity .2s, transform .2s var(--trame-ease);
}
.trame-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.trame-btn:hover { background: var(--trame-soft); }
.trame-btn:active { transform: scale(.94); }
.trame-btn:disabled { opacity: .3; cursor: default; }

/* ---------- Per approfondire ---------- */
.trame-approfondire {
  margin-top: 48px;
  padding-top: 28px;
  /* filetto allineato al testo, non a tutta larghezza */
  background: linear-gradient(var(--trame-line), var(--trame-line)) var(--trame-gutter) 0 / calc(100% - 2 * var(--trame-gutter)) 1px no-repeat;
}
.trame-approfondire__titolo {
  margin: 0 0 20px;
  font-family: var(--trame-heading);
  font-size: clamp(1.625rem, 7vw, 2rem);
  font-weight: 400;
  line-height: 1.15;
  text-align: center;
}
.trame-card-list { display: grid; gap: 12px; margin: 0; padding: 0; list-style: none; }
.trame-card {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 84px;
  position: relative;
  overflow: hidden;
  padding: 10px 14px 10px 20px;
  border-radius: 6px;
  /* card neutra nei colori della pagina; il legame con il POI collegato è la fascia a sinistra nel suo colore */
  background: var(--trame-soft);
  color: inherit;
  text-decoration: none;
  box-shadow: inset 0 0 0 1px var(--trame-line);
  transition: transform .25s var(--trame-ease);
}
.trame-card:active { transform: scale(.98); }
.trame-card__colore {
  position: absolute;
  inset: 0 auto 0 0;
  width: 8px;
  background: var(--card-bg, transparent);
  box-shadow: inset -1px 0 0 var(--trame-line);
  transition: width .3s var(--trame-ease);
}
@media (hover: hover) { .trame-card:hover .trame-card__colore { width: 12px; } }
.trame-card__img { flex: 0 0 64px; width: 64px; height: 64px; object-fit: cover; border-radius: 3px; }
.trame-card__testo { flex: 1; min-width: 0; display: grid; gap: 2px; }
.trame-card__titolo { font-family: var(--trame-heading); font-size: 1.125rem; line-height: 1.2; }
.trame-card__sotto { font-size: .875rem; line-height: 1.35; opacity: .75; }
.trame-card__freccia { flex: 0 0 20px; width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; transition: transform .25s var(--trame-ease); }
@media (hover: hover) { .trame-card:hover .trame-card__freccia { transform: translateX(4px); } }

/* ---------- Zoom a tutto schermo ---------- */
.trame-lb {
  position: fixed;
  inset: 0;
  width: 100%;
  max-width: none;
  height: 100%;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: #0b0b0b;
  color: #fff;
  --trame-line: rgba(255, 255, 255, .28);
  --trame-soft: rgba(255, 255, 255, .1);
  overflow: hidden;
}
.trame-lb::backdrop { background: #0b0b0b; }
.trame-lb[open] { animation: trame-lb-in .35s var(--trame-ease); }
.trame-lb.is-closing { animation: trame-lb-out .25s var(--trame-ease) forwards; }
@keyframes trame-lb-in { from { opacity: 0; transform: scale(.97); } }
@keyframes trame-lb-out { to { opacity: 0; transform: scale(.97); } }

.trame-lb__track {
  display: flex;
  height: 100%;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  overscroll-behavior: contain;
  scrollbar-width: none;
}
.trame-lb__track::-webkit-scrollbar { display: none; }
.trame-lb.is-zoomed .trame-lb__track { overflow: hidden; }
.trame-lb__slide {
  flex: 0 0 100%;
  height: 100%;
  margin: 0;
  display: flex;
  flex-direction: column;
  scroll-snap-align: center;
  scroll-snap-stop: always;
}
.trame-lb__frame {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 64px 0 8px;
  overflow: hidden;
}
.trame-lb__frame img {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  cursor: zoom-in;
  touch-action: manipulation;
  transition: opacity .3s;
}
.trame-lb__frame img:not([src]) { opacity: 0; }
/* ingrandita: immagine a 2,5x dentro un riquadro scorrevole (pan con il dito) */
.trame-lb__slide.is-zoomed .trame-lb__frame { align-items: safe center; justify-content: safe center; padding: 0; overflow: auto; overscroll-behavior: contain; }
.trame-lb__slide.is-zoomed .trame-lb__frame img { flex: none; max-width: none; max-height: none; width: 250%; cursor: zoom-out; }
.trame-lb__slide figcaption {
  padding: 4px var(--trame-gutter) calc(84px + env(safe-area-inset-bottom));
  font-size: .8125rem;
  line-height: 1.4;
  opacity: .8;
  text-align: center;
}
.trame-lb__slide.is-zoomed figcaption { display: none; }
.trame-lb__slide:not(:has(figcaption)) .trame-lb__frame { padding-bottom: calc(84px + env(safe-area-inset-bottom)); }

.trame-lb__close { position: absolute; top: max(12px, env(safe-area-inset-top)); right: 12px; background: rgba(0, 0, 0, .4); }
.trame-lb__controls {
  position: absolute;
  left: 0;
  right: 0;
  bottom: max(16px, env(safe-area-inset-bottom));
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  pointer-events: none;
}
.trame-lb__controls > * { pointer-events: auto; }
.trame-lb__controls .trame-btn { background: rgba(0, 0, 0, .4); }
.trame-lb__hint {
  position: absolute;
  top: max(22px, env(safe-area-inset-top));
  left: var(--trame-gutter);
  margin: 0;
  font-size: .75rem;
  opacity: .6;
}
.trame-lb.is-zoomed .trame-lb__hint, .trame-lb.is-zoomed .trame-lb__controls { opacity: 0; pointer-events: none; }

/* ---------- Animazioni d'ingresso (solo con JS e senza "riduci movimento") ---------- */
.js .trame-entra {
  opacity: 0;
  transform: translateY(14px);
  transition: opacity .7s var(--trame-ease), transform .7s var(--trame-ease);
  transition-delay: calc(var(--i, 0) * 90ms);
}
.js .trame-entra.is-visible { opacity: 1; transform: none; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; transition-delay: 0s !important; scroll-behavior: auto !important; }
  .js .trame-entra { opacity: 1; transform: none; }
}

@media (min-width: 720px) {
  :root { --trame-gutter: 32px; }
  .trame-header__logo { height: 42px; }
}

/* nel testo redazionale il grassetto resta riconoscibile anche con il solo Regular */
.trame-testo strong, .trame-testo b { font-synthesis-weight: auto; }
