/* The metro map that draws on scroll. Colours in :root (the Playground palette): the page, the card's paper, the map
   paper, the ink, the water and the park, and the four line colours. The script builds the lines, the stations, the
   chips in the header, the photo cards and the footer, then ties the drawing to the scroll. */
:root {
  --page: #ecebe6;          /* the page around the card */
  --paper: #fbfaf7;         /* the card */
  --map: #f6f4ee;           /* the map paper */
  --ink: #1d1e22;           /* names and the station rims */
  --soft: #8b8a85;          /* the small words */
  --water: #d6e4ec;         /* the river and the sea */
  --park: #dfe8d6;          /* the park */
  --red: #e0452f;           /* the Harbour line */
  --blue: #2a64c8;          /* the Riverside line */
  --amber: #e9a21a;         /* the Market line */
  --green: #2c9467;         /* the Parkway line */
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { background: var(--page); }
html, body { overflow-x: clip; }
body {
  background:
    radial-gradient(80% 55% at 50% 0%, rgba(255, 255, 255, 0.75), transparent 70%),
    radial-gradient(70% 50% at 50% 100%, rgba(0, 0, 0, 0.05), transparent 70%),
    var(--page);
  color: var(--ink);
  font-family: 'Mona Sans Variable', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.corsa { position: relative; height: 500vh; height: 500lvh; }
.palco {
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100lvh;
  max-height: 100vh;
  display: grid;
  place-items: center;
  padding: clamp(8px, 3vh, 36px) clamp(8px, 3vw, 40px);
  overflow: hidden;
}

/* the card: paper with a lit top edge, a header, the map set into it and the footer */
.card {
  position: relative;
  width: min(640px, 100%);
  height: min(624px, 100%);
  display: flex;
  flex-direction: column;
  padding: clamp(5px, 0.9vw, 9px);
  border-radius: clamp(16px, 2.4vw, 26px);
  background: linear-gradient(180deg, #ffffff, var(--paper) 30%, #f4f3ef);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 1),
    inset 0 0 0 1px rgba(255, 255, 255, 0.6),
    0 0 0 1px rgba(30, 28, 24, 0.07),
    0 1px 2px rgba(30, 28, 24, 0.06),
    0 8px 18px -6px rgba(30, 28, 24, 0.1),
    0 28px 56px -20px rgba(30, 28, 24, 0.2),
    0 70px 100px -50px rgba(30, 28, 24, 0.24);
  opacity: 0;
}

.testa {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  height: clamp(32px, min(6.6vw, 8vh), 50px);
  padding: 0 clamp(6px, 1.4vw, 12px) clamp(4px, 0.6vw, 7px);
  font-size: clamp(10.5px, min(2vw, 2.4vh), 13px);
}
.marchio { display: inline-flex; align-items: center; gap: 0.5em; white-space: nowrap; }
.marchio svg { width: 1.6em; height: 1.6em; flex: none; }
.marchio rect { fill: var(--ink); }
.marchio path { fill: none; stroke: #fff; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.marchio circle { fill: var(--amber); }
.marchio-nome { font-weight: 640; letter-spacing: -0.02em; font-variation-settings: 'wdth' 100; }
.marchio-citta { color: var(--soft); font-weight: 450; }

/* the line chips: an outline at rest, filled by their colour as the line draws */
.linee { display: flex; gap: clamp(3px, 0.7vw, 6px); list-style: none; }
.chip {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.42em;
  height: 2.1em;
  padding: 0 0.7em 0 0.55em;
  border-radius: 99px;
  font-size: 0.88em;
  font-weight: 560;
  color: var(--soft);
  background: rgba(255, 255, 255, 0.7);
  box-shadow: inset 0 0 0 1px rgba(30, 28, 24, 0.09), 0 1px 1px rgba(30, 28, 24, 0.04);
  cursor: default;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.35s cubic-bezier(0.3, 1.6, 0.5, 1);
}
.chip i {
  position: relative;
  width: 1.15em;
  height: 0.36em;
  border-radius: 9px;
  overflow: hidden;
  box-shadow: inset 0 0 0 1px var(--c);
}
.chip i b { position: absolute; inset: 0; background: var(--c); transform-origin: 0 50%; transform: scaleX(0); }
.chip span { font-variation-settings: 'wdth' 92; }
@media (max-width: 560px) {
  .chip { padding: 0 0.48em; height: 1.9em; }
  .chip span { display: none; }
  .marchio-citta { display: none; }
}

/* the map paper, set into the card */
.mappa {
  position: relative;
  flex: 1;
  min-height: 0;
  border-radius: clamp(11px, 1.7vw, 18px);
  overflow: hidden;
  isolation: isolate;
  background:
    radial-gradient(90% 70% at 20% 0%, rgba(255, 255, 255, 0.85), transparent 60%),
    var(--map);
  box-shadow: inset 0 0 0 1px rgba(30, 28, 24, 0.07), inset 0 1px 3px rgba(30, 28, 24, 0.07);
}
.rete { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.isolati { color: rgba(30, 28, 24, 0.035); }
.mare, .fiume { fill: none; }
.mare { fill: var(--water); }
.parco { fill: var(--park); }
.fiume { stroke: var(--water); stroke-width: 13; stroke-linejoin: round; }
.fiume-luce { fill: none; stroke: rgba(255, 255, 255, 0.55); stroke-width: 1.1; stroke-linejoin: round; stroke-dasharray: 3 9; }
.nome-acqua, .nome-parco { font-size: 7px; font-style: italic; letter-spacing: 0.04em; font-variation-settings: 'wdth' 88; }
.nome-acqua { fill: #7f98a6; }
.nome-parco { fill: #7f9472; text-anchor: middle; }

.cassa { fill: none; stroke: var(--map); stroke-width: 8.5; stroke-linecap: round; stroke-linejoin: round; }
.traccia { fill: none; stroke: var(--c); stroke-width: 4.6; stroke-linecap: round; stroke-linejoin: round; transition: opacity 0.35s ease; }
.rete.scelta .traccia, .rete.scelta .tick { opacity: 0.2; }
.rete.scelta .traccia.vista, .rete.scelta .tick.vista { opacity: 1; }

/* the stations: ticks in the line colour, interchanges as white rings, the station of the moment with its halo ring */
.tick { stroke: var(--c); stroke-width: 3.2; stroke-linecap: butt; transform-box: fill-box; transform-origin: 50% 50%; transform: scale(0); transition: transform 0.4s cubic-bezier(0.3, 1.8, 0.5, 1), opacity 0.35s ease; }
.cambio { fill: #fff; stroke: var(--ink); stroke-width: 1.9; transform-box: fill-box; transform-origin: 50% 50%; transform: scale(0); transition: transform 0.45s cubic-bezier(0.3, 1.8, 0.5, 1); }
.su.tick, .su.cambio { transform: scale(1); }
.nome {
  font-size: 8.4px;
  font-weight: 480;
  fill: #5c5b57;
  letter-spacing: -0.005em;
  font-variation-settings: 'wdth' 90;
  opacity: 0;
  transition: opacity 0.4s ease, fill 0.3s ease;
}
.nome.su { opacity: 1; }
.nome.turno { fill: var(--ink); font-weight: 680; }
.alone { fill: none; stroke: var(--c); stroke-width: 1.4; }
.alone-dentro { fill: #fff; stroke: var(--ink); stroke-width: 2; }
.testa-linea { fill: #fff; stroke: var(--c); stroke-width: 2.2; opacity: 0; }

/* the photo card that rises from the station */
.cartoline { position: absolute; inset: 0; pointer-events: none; }
.cartolina { position: absolute; left: 0; top: 0; width: 0; height: 0; }
.stelo { position: absolute; left: -0.5px; width: 1px; background: var(--c); transform-origin: 50% 100%; }
.stelo.giu { transform-origin: 50% 0; }
.stelo.lato { transform-origin: 100% 50%; }
.stelo { transform: scale(0); }
.foglio {
  position: absolute;
  width: var(--w);
  padding: 3px;
  border-radius: 11px;
  background: #fff;
  box-shadow:
    0 0 0 1px rgba(30, 28, 24, 0.08),
    0 1px 2px rgba(30, 28, 24, 0.08),
    0 8px 16px -6px rgba(30, 28, 24, 0.22),
    0 22px 40px -18px rgba(30, 28, 24, 0.35);
  pointer-events: auto;
}
.finestra { position: relative; aspect-ratio: 4 / 3; border-radius: 8px; overflow: hidden; background: #d9d6cf; }
.finestra img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.finestra::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.22), transparent 38%), linear-gradient(0deg, rgba(10, 10, 12, 0.42), transparent 48%);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.18);
}
.didascalia {
  position: absolute;
  left: 7px;
  right: 6px;
  bottom: 6px;
  display: flex;
  align-items: center;
  gap: 5px;
  color: #fff;
  font-size: clamp(8.5px, calc(var(--w) * 0.068), 12px);
  font-weight: 620;
  letter-spacing: -0.01em;
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.35);
  white-space: nowrap;
}
.didascalia span { overflow: hidden; text-overflow: ellipsis; }
.didascalia i { flex: none; width: 0.9em; height: 0.32em; border-radius: 9px; background: var(--c); box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.5); }

.invito {
  position: absolute;
  left: 50%;
  bottom: clamp(10px, 2.4vh, 18px);
  translate: -50% 0;
  display: inline-flex;
  align-items: center;
  gap: 0.5em;
  height: 2.3em;
  padding: 0 0.9em;
  border-radius: 99px;
  font-size: clamp(10px, min(1.9vw, 2.3vh), 12px);
  font-weight: 520;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.78);
  box-shadow: 0 0 0 1px rgba(30, 28, 24, 0.08), 0 6px 16px -8px rgba(30, 28, 24, 0.3);
  white-space: nowrap;
}
.invito svg { width: 0.95em; height: 0.95em; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }

.grana {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.35;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0.5 0 0 0 0 0.48 0 0 0 0 0.44 0 0 0 0.16 0'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* the footer: one state per station of the moment, stacked */
.piede {
  position: relative;
  flex: none;
  height: clamp(54px, min(13vw, 13.5vh), 82px);
  overflow: hidden;
}
.stato {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  gap: clamp(8px, 1.6vw, 14px);
  padding: 0 clamp(6px, 1.6vw, 14px);
}
.stato + .stato { opacity: 0; }
.bollo {
  flex: none;
  display: grid;
  place-items: center;
  width: clamp(30px, min(6.4vw, 7vh), 42px);
  aspect-ratio: 1;
  border-radius: 30%;
  background: linear-gradient(160deg, color-mix(in srgb, var(--c) 82%, #fff), var(--c) 55%, color-mix(in srgb, var(--c) 85%, #000));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35), 0 0 0 1px color-mix(in srgb, var(--c) 70%, #000 10%), 0 4px 10px -4px var(--c);
}
.bollo svg { width: 56%; height: 56%; fill: none; stroke: #fff; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.parole { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 0.15em; }
.parole strong {
  font-size: clamp(15px, min(3.4vw, 3.8vh), 23px);
  font-weight: 660;
  letter-spacing: -0.025em;
  line-height: 1.05;
  font-variation-settings: 'wdth' 96;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.parole span { font-size: clamp(10px, min(2vw, 2.3vh), 12.5px); color: var(--soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.minuti { flex: none; text-align: right; display: flex; flex-direction: column; gap: 0.15em; }
.minuti b { font-size: clamp(15px, min(3.4vw, 3.8vh), 23px); font-weight: 640; letter-spacing: -0.03em; line-height: 1.05; font-variant-numeric: lining-nums proportional-nums; }
.minuti b small { font-size: 0.55em; font-weight: 520; color: var(--soft); letter-spacing: 0; margin-left: 0.15em; }
.minuti span { font-size: clamp(10px, min(2vw, 2.3vh), 12.5px); color: var(--soft); white-space: nowrap; }

.nota {
  position: absolute;
  bottom: clamp(2px, 0.8vh, 10px);
  left: 0;
  right: 0;
  text-align: center;
  font-size: 10px;
  color: rgba(30, 28, 24, 0.38);
}

@media (hover: hover) {
  .chip:hover { transform: translateY(-1px); color: var(--ink); }
  .foglio:hover .finestra img { scale: 1.04; }
  .finestra img { transition: scale 0.6s cubic-bezier(0.2, 0.8, 0.2, 1); }
}
@media (max-height: 470px) { .nota { display: none; } }
