/* From the city card to the guide: the site sits in one framed window on warm paper. The grid and the guide are two
   layers of the same window; while the photo travels a third element (.volo) carries it, so the card and the cover
   can stay where the layout puts them. */
:root {
  --page: #efebe4;          /* the paper around the window */
  --site: #fbfaf7;          /* the window of the site */
  --ink: #191815;           /* the words */
  --muted: #77736b;         /* the small words */
  --line: rgba(25, 24, 21, 0.1); /* the hairlines */
  --accent: #c2512b;        /* the route, the stops and the times */
  --map: #f3efe8;           /* the paper of the little map */
  --water: #dfe6e6;         /* the water on the map */
  --radius: 14px;           /* the corners of the cards */
}

* {
  box-sizing: border-box;
}

html {
  touch-action: manipulation;
}

html,
body {
  margin: 0;
  overflow-x: clip;
}

body {
  min-height: 100svh;
  background:
    radial-gradient(120% 80% at 50% 0%, #f7f4ef 0%, rgba(247, 244, 239, 0) 60%),
    var(--page);
  color: var(--ink);
  font-family: 'Mona Sans Variable', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

button {
  font: inherit;
  color: inherit;
}

a {
  color: inherit;
  text-decoration: none;
}

.palco {
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: clamp(10px, 2.4vmin, 28px);
  overflow: hidden;
}

/* ---------- the window of the site ---------- */
.sito {
  position: relative;
  width: min(880px, 94vw);
  height: min(580px, 90vh);
  border-radius: 18px;
  background: var(--site);
  overflow: hidden;
  isolation: isolate;
  box-shadow:
    0 0 0 1px rgba(25, 24, 21, 0.08),
    0 1px 0 rgba(255, 255, 255, 0.9) inset,
    0 1px 2px rgba(25, 24, 21, 0.05),
    0 6px 14px -4px rgba(25, 24, 21, 0.08),
    0 26px 50px -18px rgba(25, 24, 21, 0.2),
    0 60px 90px -40px rgba(60, 40, 20, 0.18);
}

/* ---------- the grid ---------- */
.griglia {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  padding: clamp(12px, min(2.6vw, 3.4vh), 26px);
  gap: clamp(8px, min(2vw, 2.4vh), 20px);
}

.barra {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: clamp(11px, min(1.5vw, 2vh), 13px);
}

.marchio {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 0;
  font-weight: 650;
  font-stretch: 112%;
  letter-spacing: -0.01em;
}

.marchio span {
  color: var(--muted);
  font-weight: 450;
  font-stretch: 100%;
}

.marchio__segno {
  width: 1.5em;
  height: 1.5em;
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.8;
  stroke-linecap: round;
}

.barra__voci {
  display: flex;
  gap: clamp(10px, 2vw, 22px);
  color: var(--muted);
}

.barra__voci [aria-current] {
  color: var(--ink);
}

.intesta {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.intesta__titolo {
  margin: 0;
  font-size: clamp(20px, min(4.4vw, 6vh), 40px);
  font-weight: 640;
  font-stretch: 116%;
  letter-spacing: -0.03em;
  line-height: 1;
}

.intesta__riga {
  margin: 0;
  max-width: 30ch;
  font-size: clamp(11px, min(1.5vw, 2vh), 13px);
  line-height: 1.4;
  color: var(--muted);
}

.carte {
  flex: 1;
  min-height: 0;
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: clamp(8px, 1.4vw, 14px);
}

.carta-posto {
  min-height: 0;
  display: flex;
}

.carta {
  position: relative;
  flex: 1;
  display: block;
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: var(--radius);
  background: #ddd;
  cursor: pointer;
  overflow: hidden;
  text-align: left;
  -webkit-tap-highlight-color: transparent;
  box-shadow:
    0 0 0 1px rgba(25, 24, 21, 0.1),
    0 1px 2px rgba(25, 24, 21, 0.08),
    0 8px 18px -8px rgba(25, 24, 21, 0.28),
    0 22px 40px -24px rgba(25, 24, 21, 0.35);
  transition: box-shadow 0.4s ease;
}

.carta:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.carta__foto,
.copertina__foto,
.volo {
  position: absolute;
  inset: 0;
  overflow: hidden;
}

.carta__foto img,
.copertina__foto img,
.volo img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.carta__foto img {
  transition: transform 0.9s cubic-bezier(0.2, 0.7, 0.2, 1);
}

/* the grain, painted once by the script, over every photo */
.carta__foto::after,
.copertina__foto::after,
.volo::after {
  content: '';
  position: absolute;
  inset: 0;
  background-image: var(--grana, none);
  background-size: 160px 160px;
  mix-blend-mode: overlay;
  opacity: var(--grana-forza, 0.3);
  pointer-events: none;
}

.carta__velo {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(10, 9, 8, 0) 42%, rgba(10, 9, 8, 0.62) 100%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0) 30%);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.14), inset 0 1px 0 rgba(255, 255, 255, 0.3);
  border-radius: inherit;
  pointer-events: none;
}

.carta__testo {
  position: absolute;
  left: clamp(9px, 1.4vw, 14px);
  right: clamp(9px, 1.4vw, 14px);
  bottom: clamp(9px, 1.4vw, 14px);
  display: flex;
  flex-direction: column;
  gap: 3px;
  color: #fff;
}

.carta__nome {
  display: block;
  align-self: flex-start;
  font-size: clamp(14px, min(2vw, 2.8vh), 20px);
  font-weight: 640;
  font-stretch: 108%;
  letter-spacing: -0.02em;
  line-height: 1;
  white-space: nowrap;
  transform-origin: 0 100%;
  text-shadow: 0 1px 10px rgba(0, 0, 0, 0.25);
}

.carta__meta {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: clamp(10px, min(1.3vw, 1.7vh), 12px);
  color: rgba(255, 255, 255, 0.78);
  white-space: nowrap;
}

.carta__meta i,
.corpo__meta i {
  width: 1px;
  height: 0.9em;
  background: currentColor;
  opacity: 0.45;
}

.carta__apri {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.4);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  opacity: 0;
  transform: scale(0.7) rotate(-20deg);
  transition: opacity 0.3s ease, transform 0.5s cubic-bezier(0.3, 1.6, 0.4, 1);
}

.carta__apri svg {
  width: 13px;
  height: 13px;
  fill: none;
  stroke: #fff;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.carta.is-vicina .carta__foto img {
  transform: scale(1.05);
}

.carta.is-vicina .carta__apri {
  opacity: 1;
  transform: none;
}

.carta.is-vicina {
  box-shadow:
    0 0 0 1px rgba(25, 24, 21, 0.12),
    0 2px 4px rgba(25, 24, 21, 0.1),
    0 14px 26px -10px rgba(25, 24, 21, 0.34),
    0 34px 56px -28px rgba(25, 24, 21, 0.42);
}

@media (hover: hover) {
  .carta:hover .carta__foto img {
    transform: scale(1.05);
  }
  .carta:hover .carta__apri {
    opacity: 1;
    transform: none;
  }
  .indietro:hover {
    background: rgba(255, 255, 255, 0.3);
  }
  .indietro:hover svg {
    transform: translateX(-2px);
  }
  .salva:hover {
    background: rgba(255, 255, 255, 0.3);
  }
}

/* ---------- the guide ---------- */
.guida {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  visibility: hidden;
}

.guida.is-aperta {
  visibility: visible;
}

.copertina {
  position: relative;
  flex: 0 0 48%;
  overflow: hidden;
  color: #fff;
}

.copertina__velo {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(10, 9, 8, 0.32) 0%, rgba(10, 9, 8, 0) 34%),
    linear-gradient(180deg, rgba(10, 9, 8, 0) 46%, rgba(10, 9, 8, 0.6) 100%);
  pointer-events: none;
}

.indietro,
.salva {
  position: absolute;
  top: clamp(10px, 2vmin, 18px);
  display: flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.42);
  background: rgba(255, 255, 255, 0.18);
  -webkit-backdrop-filter: blur(10px) saturate(1.3);
  backdrop-filter: blur(10px) saturate(1.3);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.35) inset, 0 6px 16px -6px rgba(0, 0, 0, 0.35);
  color: #fff;
  cursor: pointer;
  transition: background 0.3s ease;
  -webkit-tap-highlight-color: transparent;
}

.indietro {
  left: clamp(10px, 2vmin, 18px);
  padding: 0 13px 0 10px;
  font-size: 13px;
  font-weight: 560;
}

.salva {
  right: clamp(10px, 2vmin, 18px);
  width: 32px;
  justify-content: center;
  padding: 0;
}

.indietro svg,
.salva svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: #fff;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform 0.4s cubic-bezier(0.3, 1.6, 0.4, 1);
}

.salva.is-salvata svg {
  fill: #fff;
}

.copertina__testo {
  position: absolute;
  left: clamp(14px, 3vw, 30px);
  right: clamp(14px, 3vw, 30px);
  bottom: clamp(12px, min(2.6vw, 3.4vh), 26px);
}

.copertina__paese {
  margin: 0 0 6px;
  font-size: clamp(11px, min(1.4vw, 1.9vh), 13px);
  font-weight: 520;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.82);
}

.copertina__nome {
  display: inline-block;
  margin: 0;
  font-size: clamp(30px, min(8.4vw, 10vh), 84px);
  font-weight: 680;
  font-stretch: 118%;
  letter-spacing: -0.035em;
  line-height: 0.92;
  white-space: nowrap;
  transform-origin: 0 100%;
  text-shadow: 0 2px 24px rgba(0, 0, 0, 0.25);
}

.corpo {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 1.15fr 1fr;
  gap: clamp(14px, 3vw, 36px);
  padding: clamp(12px, min(2.6vw, 3.4vh), 28px) clamp(14px, 3vw, 30px);
}

.corpo__titolo {
  margin: 0;
  font-size: clamp(16px, min(2.6vw, 3.6vh), 26px);
  font-weight: 640;
  font-stretch: 110%;
  letter-spacing: -0.02em;
  line-height: 1.1;
}

.corpo__meta {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 8px 0 0;
  font-size: clamp(10px, min(1.4vw, 1.8vh), 12.5px);
  color: var(--muted);
}

.corpo__meta svg {
  width: 13px;
  height: 13px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.4;
  stroke-linecap: round;
}

.corpo__intro {
  margin: clamp(8px, 1.6vh, 14px) 0 0;
  max-width: 34ch;
  font-size: clamp(12px, min(1.7vw, 2.3vh), 15px);
  line-height: 1.5;
  color: #45423c;
}

.temi {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: clamp(10px, 2vh, 16px) 0 0;
  padding: 0;
  list-style: none;
}

.temi li {
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #fff;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.9) inset, 0 1px 2px rgba(25, 24, 21, 0.05);
  font-size: clamp(10.5px, min(1.4vw, 1.8vh), 12px);
  color: #45423c;
}

.leggi {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: clamp(10px, 2.2vh, 18px);
  padding: 10px 16px 10px 18px;
  border-radius: 999px;
  color: #fff;
  font-size: clamp(12px, min(1.5vw, 2vh), 13.5px);
  font-weight: 560;
  isolation: isolate;
}

.leggi__fondo {
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: inherit;
  background: linear-gradient(180deg, #2a2824, #141310);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.6), 0 1px 0 rgba(255, 255, 255, 0.18) inset, 0 8px 18px -8px rgba(25, 24, 21, 0.6);
  transition: transform 0.5s cubic-bezier(0.3, 1.6, 0.4, 1);
}

.leggi__testo {
  font-stretch: 100%;
  transition: font-stretch 0.4s ease;
}

.leggi svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform 0.4s cubic-bezier(0.3, 1.6, 0.4, 1);
}

@media (hover: hover) {
  .leggi:hover .leggi__fondo {
    transform: scaleX(1.04) scaleY(1.08);
  }
  .leggi:hover .leggi__testo {
    font-stretch: 112%;
  }
  .leggi:hover svg {
    transform: translateX(3px);
  }
}

.corpo__giro {
  display: flex;
  flex-direction: column;
  gap: clamp(6px, 1.4vh, 12px);
  min-height: 0;
}

.mappa {
  position: relative;
  margin: 0;
  flex: 1 1 auto;
  min-height: 0;
  max-height: 130px;
  border-radius: 12px;
  background: var(--map);
  overflow: hidden;
  box-shadow: inset 0 0 0 1px var(--line), 0 1px 0 rgba(255, 255, 255, 0.8), 0 8px 18px -12px rgba(25, 24, 21, 0.25);
}

.mappa svg {
  display: block;
  width: 100%;
  height: 100%;
}

.mappa__acqua {
  fill: var(--water);
  stroke: rgba(70, 100, 110, 0.18);
  stroke-width: 0.6;
}

.mappa__strade path {
  fill: none;
  stroke: rgba(25, 24, 21, 0.16);
  stroke-width: 1;
  stroke-linecap: round;
}

.mappa__strade .fine {
  stroke: rgba(25, 24, 21, 0.08);
  stroke-width: 0.7;
}

.mappa__giro,
.mappa__giro-ombra {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.mappa__giro {
  stroke: var(--accent);
  stroke-width: 1.8;
}

.mappa__giro-ombra {
  stroke: rgba(194, 81, 43, 0.16);
  stroke-width: 5;
}

.mappa__tappa circle {
  fill: var(--site);
  stroke: var(--accent);
  stroke-width: 1.4;
}

.mappa__tappa .cuore {
  fill: var(--accent);
  stroke: none;
}

.tappe {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
}

.tappa {
  display: grid;
  grid-template-columns: 3.4em 1fr;
  align-items: baseline;
  gap: 8px;
  padding: clamp(4px, 0.9vh, 8px) 0;
  border-top: 1px solid var(--line);
  font-size: clamp(11px, min(1.5vw, 2vh), 13.5px);
  line-height: 1.25;
}

.tappa:last-child {
  border-bottom: 1px solid var(--line);
}

.tappa time {
  color: var(--accent);
  font-weight: 560;
  font-stretch: 92%;
  font-variant-numeric: proportional-nums;
}

.tappa span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------- the flying photo ---------- */
.volo {
  inset: auto;
  top: 0;
  left: 0;
  width: 10px;
  height: 10px;
  visibility: hidden;
  z-index: 5;
  will-change: transform, width, height;
}

.volo::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 1;
  background: linear-gradient(180deg, rgba(10, 9, 8, 0) 46%, rgba(10, 9, 8, 0.55) 100%);
  opacity: var(--velo, 1);
  pointer-events: none;
}

.guida .copertina__testo {
  z-index: 6;
}

.copertina__testo {
  pointer-events: none;
}

/* the title has to fly over the flying photo */
.guida.is-in-volo {
  z-index: 6;
}

.guida.is-in-volo .copertina__foto,
.guida.is-in-volo .copertina__velo {
  opacity: 0;
}

/* ---------- the drawn pointer of the autopilot ---------- */
.puntatore {
  position: fixed;
  top: 0;
  left: 0;
  width: 22px;
  height: 22px;
  z-index: 20;
  fill: #fff;
  stroke: #191815;
  stroke-width: 1.3;
  stroke-linejoin: round;
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.28));
  pointer-events: none;
  opacity: 0;
}

/* ---------- smaller windows ---------- */
@media (max-width: 680px) {
  .carte {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
  }
  .intesta__riga {
    display: none;
  }
  .barra__voci a:not([aria-current]) {
    display: none;
  }
  .corpo {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
    gap: 10px;
  }
  .corpo__intro,
  .temi,
  .leggi {
    display: none;
  }
  .corpo__giro {
    flex-direction: row;
  }
  .mappa {
    flex: 0 0 40%;
    max-height: none;
  }
  .tappe {
    flex: 1;
    min-width: 0;
  }
  .copertina {
    flex-basis: 44%;
  }
}

@media (max-height: 520px) and (min-width: 681px) {
  .leggi {
    display: none;
  }
  .corpo__intro {
    display: none;
  }
}

@media (max-width: 400px) {
  .carta__apri {
    display: none;
  }
  .indietro,
  .salva {
    height: 28px;
  }
  .salva {
    width: 28px;
  }
  .indietro {
    font-size: 12px;
  }
}
