/**
 * Foresta dei Florence Ambassador (template-parts/foresta-ambassador.php).
 *
 * Foglio a parte rispetto a df.css, caricato solo dove c'è la sezione.
 * Colori, font e raggi sono quelli del tema: nero #4C4C4C, beige #F4EEE7,
 * bianco #FBF8F4, giallo #FCC46B; GeneralSans per titoli e numeri, GT
 * Pressura Mono per testi ed etichette.
 */

.foresta {
 --f-nero: #4C4C4C;
 --f-beige: #F4EEE7;
 --f-bianco: #FBF8F4;
 --f-giallo: #FCC46B;
 --f-sans: "GeneralSans", sans-serif;
 --f-mono: "GT Pressura Mono", monospace;
 --f-ease: cubic-bezier(.16, 1, .3, 1); /* expo out, come reveal.js */
 --f-ratio: 2.38795; /* viewBox della mappa: 1000 × 418,77 */
}

.foresta-sprite {
 position: absolute;
 width: 0;
 height: 0;
 overflow: hidden;
}

.foresta-icona {
 width: 1em;
 height: 1em;
 flex: none;
 fill: none;
 stroke: currentColor;
 stroke-width: 1.5;
 stroke-linecap: round;
 stroke-linejoin: round;
}


/* --------------------------------------------------------------- Apertura */

.foresta-eyebrow {
 display: flex;
 flex-wrap: wrap;
 gap: 6px;
 margin: 0 0 1.5rem;
}

.foresta-eyebrow span {
 font-family: var(--f-mono);
 font-size: .72rem;
 line-height: 1;
 letter-spacing: .06em;
 text-transform: uppercase;
 color: var(--f-nero);
 border: .5px solid var(--f-nero);
 border-radius: 3px;
 padding: 5px 8px 4px;
}

.foresta-eyebrow .foresta-eyebrow-treedom {
 background-color: var(--f-giallo);
 border-color: var(--f-giallo);
}

.foresta-numeri {
 display: grid;
 grid-template-columns: repeat(4, minmax(0, 1fr));
}

.foresta-numeri > div {
 display: flex;
 flex-direction: column-reverse;
 justify-content: flex-end;
 gap: 12px;
 padding: 20px 16px 0 0;
 border-top: .5px solid var(--f-nero);
}

.foresta-numeri dt {
 font-family: var(--f-mono);
 font-size: .72rem;
 font-weight: normal;
 letter-spacing: .06em;
 text-transform: uppercase;
 color: var(--f-nero);
}

.foresta-numeri dd {
 margin: 0;
 font-family: var(--f-sans);
 font-weight: 200;
 font-size: clamp(3.2rem, 1.4rem + 4vw, 6.5rem);
 line-height: .9;
 letter-spacing: -.02em;
 font-variant-numeric: tabular-nums;
 color: var(--f-nero);
}


/* ---------------------------------------------------------- Pannello mappa */

.foresta-mappa {
 --foresta-h: clamp(340px, 46vw, 520px);
 --f-pin: 32px;
 position: relative;
 isolation: isolate;
 margin-right: 15px;
 margin-left: 15px;
 border-radius: 16px;
 overflow: hidden;
 background-color: var(--f-nero);
 color: var(--f-beige);
}

.foresta-testata {
 display: flex;
 flex-wrap: wrap;
 align-items: center;
 justify-content: space-between;
 gap: 16px 32px;
 padding-top: 28px;
 padding-bottom: 22px;
 position: relative;
 z-index: 7;
}

.foresta-tabs {
 display: flex;
 flex-wrap: wrap;
 gap: 6px;
}

.foresta-tab {
 display: inline-flex;
 align-items: center;
 gap: 8px;
 padding: 9px 12px 8px;
 font-size: .72rem;
 line-height: 1;
 letter-spacing: .06em;
 text-transform: uppercase;
 color: var(--f-beige);
 background-color: transparent;
 border: .5px solid rgba(244, 238, 231, .35);
 border-radius: .375rem;
 cursor: pointer;
 transition: background-color .3s ease, border-color .3s ease, color .3s ease;
}

.foresta-tab-num {
 color: var(--f-giallo);
 transition: color .3s ease;
}

.foresta-tab:hover {
 border-color: var(--f-beige);
}

.foresta-tab[aria-selected="true"] {
 color: var(--f-nero);
 background-color: var(--f-giallo);
 border-color: var(--f-giallo);
}

.foresta-tab[aria-selected="true"] .foresta-tab-num {
 color: rgba(76, 76, 76, .6);
}

.foresta-legenda {
 display: flex;
 flex-wrap: wrap;
 gap: 8px 22px;
 margin: 0;
 padding: 0;
 list-style: none;
}

.foresta-legenda li {
 display: flex;
 align-items: center;
 gap: 9px;
 font-size: .66rem;
 letter-spacing: .06em;
 text-transform: uppercase;
 color: rgba(244, 238, 231, .7);
}

.foresta-legenda li::before {
 content: "";
 width: 12px;
 height: 12px;
 border: 1px solid var(--f-giallo);
 border-radius: 50%;
}

.foresta-legenda .foresta-legenda-anniversario::before {
 border-radius: 3px;
}

.foresta-corpo {
 position: relative;
}


/* -------------------------------------------------------------------- Mappa */

/*
 * Niente transform e niente z-index su cornice, stage e canvas: così pin,
 * sfumature e archi stanno tutti nel contesto di .foresta-mappa e i pin
 * passano sopra le sfumature ai bordi.
 */
.foresta-cornice {
 position: relative;
 height: var(--foresta-h);
}

/* Sfumature ai bordi: la mappa continua oltre il pannello. */
.foresta-cornice::before,
.foresta-cornice::after {
 content: "";
 position: absolute;
 top: 0;
 bottom: 0;
 width: 6%;
 z-index: 3;
 pointer-events: none;
}

.foresta-cornice::before {
 left: 0;
 background: linear-gradient(to right, var(--f-nero), rgba(76, 76, 76, 0));
}

.foresta-cornice::after {
 right: 0;
 background: linear-gradient(to left, var(--f-nero), rgba(76, 76, 76, 0));
}

.foresta-stage {
 position: relative;
 height: 100%;
 overflow-x: auto;
 overflow-y: hidden;
 overscroll-behavior-x: contain;
 scrollbar-width: none;
 -webkit-overflow-scrolling: touch;
}

.foresta-stage::-webkit-scrollbar {
 display: none;
}

.foresta-stage.is-trascinabile {
 cursor: grab;
}

.foresta-stage.is-trascinando {
 cursor: grabbing;
 user-select: none;
}

.foresta-canvas {
 position: relative;
 height: 100%;
 width: calc(var(--foresta-h) * var(--f-ratio));
 margin: 0 auto;
}

.foresta-terra,
.foresta-archi {
 position: absolute;
 inset: 0;
 z-index: 1;
 width: 100%;
 height: 100%;
 overflow: visible;
}

.foresta-archi {
 z-index: 2;
}

.foresta-terre,
.foresta-paese {
 fill: none;
 stroke-width: 2.5;
 stroke-linecap: round;
}

.foresta-terre {
 stroke: var(--f-beige);
 opacity: .2;
}

.foresta-paese {
 stroke: var(--f-giallo);
 opacity: .65;
 transition: opacity .6s ease;
}

.foresta-paese.is-active {
 opacity: 1;
}

.foresta-arco-traccia,
.foresta-arco-scia {
 fill: none;
 stroke: var(--f-giallo);
 stroke-linecap: round;
}

.foresta-arco-traccia {
 stroke-width: 1;
 stroke-dasharray: 1.5 4;
 opacity: .35;
 transition: opacity .5s ease;
}

.foresta-arco.is-active .foresta-arco-traccia {
 opacity: .9;
}

/* La "scia": un tratto che corre da Firenze verso il luogo selezionato. */
.foresta-arco-scia {
 stroke-width: 2.4;
 stroke-dasharray: 9 100;
 stroke-dashoffset: 9;
 opacity: 0;
}

.foresta-arco.is-active .foresta-arco-scia {
 animation: foresta-scia 2.6s cubic-bezier(.5, 0, .2, 1) calc(var(--ritardo, 0) * 1s) infinite;
}

@keyframes foresta-scia {
 0% { stroke-dashoffset: 9; opacity: 0; }
 12% { opacity: 1; }
 80% { opacity: 1; }
 100% { stroke-dashoffset: -100; opacity: 0; }
}


/* --------------------------------------------------------------------- Pin */

.foresta-pin {
 position: absolute;
 left: var(--x);
 top: var(--y);
 z-index: 4;
 display: grid;
 place-items: center;
 width: var(--f-pin);
 height: var(--f-pin);
 margin: calc(var(--f-pin) / -2) 0 0 calc(var(--f-pin) / -2);
 padding: 0;
 font-size: calc(var(--f-pin) / 2);
 color: var(--f-giallo);
 background-color: var(--f-nero);
 border: 1px solid var(--f-giallo);
 border-radius: 50%;
 cursor: pointer;
 transition: transform .6s var(--f-ease), background-color .3s ease, color .3s ease, opacity .6s ease, box-shadow .6s var(--f-ease);
}

.foresta-pin-anniversario {
 border-radius: 10px;
}

.foresta-pin::after {
 content: "";
 position: absolute;
 inset: -1px;
 border: 1px solid var(--f-giallo);
 border-radius: inherit;
 opacity: 0;
 pointer-events: none;
}

.foresta-pin:hover {
 background-color: #5a5650;
}

.foresta-pin.is-active {
 z-index: 5;
 color: var(--f-nero);
 background-color: var(--f-giallo);
 transform: scale(1.15);
 box-shadow: 0 0 0 7px rgba(252, 196, 107, .16);
}

.foresta-pin.is-active::after {
 animation: foresta-onda 2.4s var(--f-ease) infinite;
}

@keyframes foresta-onda {
 0% { transform: scale(1); opacity: .8; }
 100% { transform: scale(2.3); opacity: 0; }
}

.foresta-pin-etichetta {
 position: absolute;
 top: 50%;
 left: calc(100% + 10px);
 transform: translateY(-50%);
 padding: 4px 7px 3px;
 font-size: .64rem;
 line-height: 1;
 letter-spacing: .08em;
 text-transform: uppercase;
 white-space: nowrap;
 color: var(--f-beige);
 background-color: rgba(76, 76, 76, .82);
 border-radius: 3px;
 pointer-events: none;
 transition: opacity .4s ease, color .3s ease;
}

.foresta-pin-sinistra .foresta-pin-etichetta {
 left: auto;
 right: calc(100% + 10px);
}

.foresta-pin-sopra .foresta-pin-etichetta {
 top: auto;
 bottom: calc(100% + 9px);
 left: 50%;
 transform: translateX(-50%);
}

/* Sulla mappa che scorre si legge solo l'etichetta del luogo scelto. */
.foresta-pin:not(.is-active) .foresta-pin-etichetta {
 opacity: 0;
}

.foresta-pin-etichetta b {
 margin-left: 3px;
 font-weight: normal;
 color: var(--f-giallo);
}

.foresta-pin.is-active .foresta-pin-etichetta {
 color: var(--f-nero);
 background-color: var(--f-giallo);
}

.foresta-pin.is-active .foresta-pin-etichetta b {
 color: rgba(76, 76, 76, .65);
}


/* ------------------------------------------------------------------ Scheda */

.foresta-sovrapposto {
 position: relative;
 z-index: 6;
 padding-top: 22px;
}

.foresta-card {
 width: 100%;
 padding: 20px 22px;
 color: var(--f-nero);
 background-color: var(--f-beige);
 border-radius: 16px;
 box-shadow: 0 34px 60px -34px rgba(0, 0, 0, .55);
 pointer-events: auto;
}

.foresta-card p {
 margin: 0;
 color: var(--f-nero);
}

.foresta-card-nav {
 display: flex;
 align-items: center;
 justify-content: space-between;
 margin-bottom: 16px;
}

.foresta-card .foresta-contatore {
 font-size: .7rem;
 letter-spacing: .12em;
 font-variant-numeric: tabular-nums;
}

.foresta-frecce {
 display: flex;
 gap: 6px;
}

.foresta-freccia {
 display: grid;
 place-items: center;
 width: 34px;
 height: 34px;
 padding: 0;
 font-size: 16px;
 color: var(--f-nero);
 background-color: transparent;
 border: .5px solid var(--f-nero);
 border-radius: 50%;
 cursor: pointer;
 transition: background-color .3s ease, color .3s ease;
}

.foresta-freccia:hover {
 color: var(--f-beige);
 background-color: var(--f-nero);
}

.foresta-scheda {
 display: flex;
 flex-direction: column;
}

.foresta-scheda + .foresta-scheda {
 margin-top: 28px;
 padding-top: 28px;
 border-top: .5px solid var(--f-nero);
}

.foresta-card .foresta-scheda-foresta {
 margin-bottom: 10px;
 font-size: .64rem;
 letter-spacing: .08em;
 text-transform: uppercase;
 opacity: .7;
}

.foresta-scheda-nome {
 margin: 0 0 6px;
 font-size: 2.4rem;
 line-height: 1;
}

.foresta-card .foresta-scheda-luogo {
 font-size: .78rem;
}

.foresta-card .foresta-scheda-totale {
 display: flex;
 align-items: baseline;
 gap: 8px;
 margin-top: 16px;
 padding-top: 14px;
 border-top: .5px solid rgba(76, 76, 76, .3);
}

.foresta-scheda-numero {
 font-family: var(--f-sans);
 font-weight: 200;
 font-size: 3.6rem;
 line-height: .85;
 letter-spacing: -.02em;
}

.foresta-scheda-unita {
 font-family: var(--f-mono);
 font-size: .72rem;
 letter-spacing: .08em;
 text-transform: uppercase;
}

.foresta-card .foresta-scheda-nota {
 margin: 12px 0 14px;
 font-size: .76rem;
 line-height: 1.55;
}

.foresta-specie {
 margin: 0 0 16px;
 padding: 0;
 list-style: none;
}

.foresta-specie li {
 position: relative;
 display: grid;
 grid-template-columns: 22px minmax(0, 1fr) auto;
 align-items: center;
 gap: 0 10px;
 padding: 8px 0;
 font-size: .78rem;
 line-height: 1.25;
 border-top: .5px solid rgba(76, 76, 76, .2);
}

/* Quota della specie sul totale del luogo. */
.foresta-specie li::before {
 content: "";
 position: absolute;
 top: -1px;
 left: 0;
 width: var(--quota);
 height: 2px;
 background-color: var(--f-giallo);
 transition: width .9s var(--f-ease) .25s;
}

.foresta-specie .foresta-icona {
 font-size: 22px;
 stroke-width: 1.3;
}

.foresta-specie-dettaglio {
 display: block;
 margin-top: 3px;
 font-size: .68rem;
 opacity: .75;
}

.foresta-specie-significato {
 display: inline-block;
 margin-left: 4px;
 padding: 2px 4px 1px;
 font-size: .56rem;
 line-height: 1;
 letter-spacing: .08em;
 text-transform: uppercase;
 vertical-align: 1px;
 border: .5px solid currentColor;
 border-radius: 3px;
}

.foresta-specie-alberi {
 font-family: var(--f-sans);
 font-weight: 200;
 font-size: 1.4rem;
 font-variant-numeric: tabular-nums;
}

.foresta-scheda-piede {
 display: flex;
 align-items: center;
 justify-content: space-between;
 gap: 12px;
 padding-top: 12px;
 border-top: .5px solid rgba(76, 76, 76, .3);
}

.foresta-card .foresta-coordinate {
 font-size: .66rem;
 letter-spacing: .03em;
 opacity: .75;
}

.foresta-link {
 display: inline-flex;
 align-items: center;
 gap: 4px;
 flex: none;
 padding-bottom: 1px;
 font-size: .7rem;
 letter-spacing: .08em;
 text-transform: uppercase;
 color: var(--f-nero);
 text-decoration: none;
 border-bottom: .5px solid var(--f-nero);
}

.foresta-link .foresta-icona {
 transition: transform .4s var(--f-ease);
}

.foresta-link:hover {
 color: var(--f-nero);
}

.foresta-link:hover .foresta-icona {
 transform: translate(2px, -2px);
}

.foresta-nota p {
 margin: 0;
 padding: 18px 0 26px;
 font-size: .64rem;
 color: rgba(244, 238, 231, .55);
}

.foresta-tab:focus-visible,
.foresta-pin:focus-visible {
 outline: 2px solid var(--f-giallo);
 outline-offset: 3px;
}

.foresta-freccia:focus-visible,
.foresta-link:focus-visible {
 outline: 2px solid var(--f-nero);
 outline-offset: 3px;
}


/* ----------------------------------------------------- Con JS: una scheda */

.foresta-mappa:not(.is-ready) .foresta-card-nav {
 display: none;
}

/*
 * Schede sovrapposte; l'altezza del contenitore la imposta lo script su
 * quella della scheda attiva, così può passare dall'una all'altra.
 */
.foresta-mappa.is-ready .foresta-schede {
 position: relative;
}

.foresta-mappa.is-ready .foresta-schede.is-animata {
 transition: height .6s var(--f-ease);
}

.foresta-mappa.is-ready .foresta-scheda {
 position: absolute;
 top: 0;
 left: 0;
 right: 0;
 margin: 0;
 padding: 0;
 border: 0;
 opacity: 0;
 visibility: hidden;
 transform: translateY(10px);
}

.foresta-mappa.is-ready .foresta-scheda.is-active {
 opacity: 1;
 visibility: visible;
 transform: none;
}

/* Transizioni solo dopo il primo frame: all'avvio le schede non attive
   spariscono subito, senza sovrapporsi a quella visibile. */
.foresta-mappa.is-ready .is-animata .foresta-scheda {
 transition: opacity .3s ease, transform .5s var(--f-ease), visibility 0s linear .3s;
}

.foresta-mappa.is-ready .is-animata .foresta-scheda.is-active {
 transition: opacity .5s ease .1s, transform .8s var(--f-ease) .1s, visibility 0s;
}

.foresta-mappa.is-ready .foresta-scheda:not(.is-active) .foresta-specie li::before {
 width: 0;
 transition: none;
}


/* ------------------------------------------------- Ingresso della mappa */

.foresta-mappa.is-attesa .foresta-pin {
 opacity: 0;
 transform: scale(.3);
}

.foresta-mappa.is-attesa .foresta-paese,
.foresta-mappa.is-attesa .foresta-arco-traccia {
 opacity: 0;
}

.foresta-mappa.is-intro .foresta-pin {
 transition-delay: calc(.55s + var(--i) * .12s);
}

.foresta-mappa.is-intro .foresta-paese {
 transition-duration: 1.2s;
 transition-delay: .2s;
}

.foresta-mappa.is-intro .foresta-arco-traccia {
 transition-duration: .8s;
 transition-delay: calc(.4s + var(--i) * .15s);
}

/* All'ingresso parte una scia per ogni arco, da Firenze verso il mondo. */
.foresta-mappa.is-intro .foresta-arco .foresta-arco-scia {
 animation: foresta-scia 1.6s cubic-bezier(.5, 0, .2, 1) calc(.35s + var(--i) * .18s) 1 both;
}


/* -------------------------------------------------------------- Responsive */

@media (min-width: 768px) and (max-width: 1399.98px) {

 .foresta-scheda {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr);
  grid-template-rows: auto auto 1fr auto;
  align-content: start;
  column-gap: 40px;
 }

 .foresta-scheda > header,
 .foresta-scheda > .foresta-scheda-totale,
 .foresta-scheda > .foresta-scheda-nota {
  grid-column: 1;
 }

 .foresta-scheda > .foresta-specie {
  grid-column: 2;
  grid-row: 1 / 4;
  margin-bottom: 0;
 }

 .foresta-scheda > .foresta-scheda-piede {
  grid-column: 1 / -1;
  margin-top: 16px;
 }
}

@media (max-width: 767.98px) {

 .foresta-mappa {
  --foresta-h: 330px;
  --f-pin: 30px;
 }

 /* Il pannello ha già i suoi 15px per lato: qui il rientro mobile di
    .container-md (df.css) stringerebbe la scheda due volte. */
 .foresta-mappa .container-md {
  max-width: none;
  width: auto;
 }

 .foresta-numeri {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  row-gap: 30px;
 }

 .foresta-testata {
  padding-top: 22px;
  padding-bottom: 18px;
 }

 .foresta-tabs {
  flex-wrap: nowrap;
  overflow-x: auto;
  margin: 0 -16px;
  padding: 0 16px;
  scrollbar-width: none;
 }

 .foresta-tabs::-webkit-scrollbar {
  display: none;
 }

 .foresta-tab {
  flex: none;
 }

 .foresta-card {
  padding: 18px;
 }

 .foresta-scheda-nome {
  font-size: 2.1rem;
 }
}

/*
 * Da 1400px la scheda sta sopra la mappa, sul Pacifico: la mappa è spostata
 * di poco più di un decimo verso est, così le Americhe restano scoperte.
 */
@media (min-width: 1400px) {

 .foresta-mappa {
  --foresta-h: clamp(620px, 44vw, 720px);
  --f-pin: 36px;
 }

 .foresta-cornice {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
 }

 .foresta-cornice::before,
 .foresta-cornice::after {
  width: 7%;
 }

 .foresta-stage {
  overflow: hidden;
 }

 .foresta-canvas {
  position: absolute;
  top: 0;
  left: calc(50% - var(--foresta-h) * var(--f-ratio) * .37);
  margin: 0;
 }

 .foresta-pin:not(.is-active) .foresta-pin-etichetta {
  opacity: .9;
 }

 /* In alto: cambiando scheda le frecce restano sotto il cursore. */
 .foresta-sovrapposto {
  display: flex;
  align-items: flex-start;
  min-height: var(--foresta-h);
  padding-top: 24px;
  padding-bottom: 24px;
  pointer-events: none;
 }

 .foresta-card {
  max-width: 380px;
  padding: 16px 22px 16px;
  pointer-events: auto;
 }

 .foresta-card-nav {
  margin-bottom: 10px;
 }

 /* Numero e nota affiancati: la scheda resta più bassa della mappa. */
 .foresta-mappa.is-ready .foresta-scheda {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  column-gap: 18px;
 }

 .foresta-scheda > header {
  grid-column: 1 / -1;
  padding-bottom: 12px;
  border-bottom: .5px solid rgba(76, 76, 76, .3);
 }

 .foresta-card .foresta-scheda-totale {
  flex-direction: column;
  gap: 6px;
  margin-top: 14px;
  padding-top: 0;
  border-top: 0;
 }

 .foresta-scheda-numero {
  font-size: 3.2rem;
 }

 .foresta-card .foresta-scheda-nota {
  margin: 14px 0 0;
 }

 .foresta-scheda > .foresta-specie {
  grid-column: 1 / -1;
  margin: 16px 0 14px;
 }

 .foresta-specie li {
  padding: 7px 0;
 }

 .foresta-scheda > .foresta-scheda-piede {
  grid-column: 1 / -1;
 }
}

@media (prefers-reduced-motion: reduce) {

 .foresta-pin.is-active::after,
 .foresta-arco.is-active .foresta-arco-scia,
 .foresta-mappa.is-intro .foresta-arco .foresta-arco-scia {
  animation: none;
 }

 .foresta-mappa.is-ready .is-animata .foresta-scheda,
 .foresta-mappa.is-ready .is-animata .foresta-scheda.is-active,
 .foresta-pin,
 .foresta-specie li::before {
  transition: none;
 }
}
