/* The floor plan of the flat that draws itself on scroll. Colours in :root (the Playground palette): the warm page,
   the paper of the sheet, the graphite of the lines and the one accent, terracotta, for the rooms, the pencil and the
   button. The sticky stage is 100lvh; the sheet and the card are sized on both width and height, so they fit a phone
   box too. GSAP moves the wrappers (.foto-strato, .voce, .fine), the CSS styles their children. */
:root {
  --page: #f2eee7;            /* the warm page */
  --paper: #fffdf8;           /* the sheet of the plan */
  --ink: #23201b;             /* graphite: walls and text */
  --soft: #8a8278;            /* small words and thin lines */
  --hair: rgba(35, 32, 27, 0.1); /* 1px borders */
  --accent: #c65a32;          /* terracotta: rooms, pencil, button */
  --room: rgba(214, 133, 86, 0.2); /* the warm tone a closed room fills with */
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { background: var(--page); }
html, body { overflow-x: clip; }
body {
  background:
    radial-gradient(90% 60% at 30% 0%, rgba(255, 255, 255, 0.8), transparent 62%),
    radial-gradient(50% 45% at 92% 96%, rgba(198, 90, 50, 0.07), transparent 70%),
    var(--page);
  color: var(--ink);
  font-family: 'Mona Sans Variable', 'Mona Sans', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}
/* a veil of grain over everything */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 5;
  opacity: 0.3;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.45  0 0 0 0 0.4  0 0 0 0 0.35  0 0 0 0.2 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
}

.corsa { position: relative; height: 700vh; }
.palco {
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100lvh;
  max-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: clamp(34px, 8vh, 72px) clamp(12px, 3vw, 40px) clamp(10px, 3vh, 32px);
  overflow: hidden;
}

/* the top line */
.testa {
  position: absolute;
  top: clamp(10px, 2.6vh, 26px);
  left: clamp(14px, 3vw, 40px);
  right: clamp(14px, 3vw, 40px);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  font-size: clamp(10px, min(1.15vw, 2vh), 13px);
  color: var(--soft);
  white-space: nowrap;
}
.marchio {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--ink);
  font-weight: 620;
  font-stretch: 108%;
  letter-spacing: -0.01em;
  font-size: 1.12em;
}
.marchio svg { width: 1.35em; height: 1.35em; fill: none; stroke: var(--ink); stroke-width: 1.3; stroke-linejoin: round; }
.marchio .fiamma { fill: var(--accent); stroke: none; }
.testa-destra { display: inline-flex; align-items: center; gap: 0.7em; font-family: 'Geist Mono Variable', 'Geist Mono', ui-monospace, monospace; font-size: 0.86em; letter-spacing: 0.04em; text-transform: uppercase; }
.testa-destra i { display: inline-block; width: 1px; height: 0.9em; background: var(--hair); }
.testa-destra b { font-weight: 500; color: var(--ink); }

/* the scene: the sheet and the card side by side, or one over the other when the box is tall */
.scena {
  --foglio-w: min(58vw, calc((100vh - 120px) * 1.3), 820px);
  --carta-w: min(28vw, 330px);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(14px, 2.6vw, 40px);
  width: 100%;
}

/* the sheet */
.foglio {
  position: relative;
  flex: none;
  width: var(--foglio-w);
  background:
    linear-gradient(var(--paper), var(--paper)) padding-box;
  border: 1px solid var(--hair);
  border-radius: clamp(10px, 1.4vw, 18px);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.9) inset,
    0 1px 2px rgba(35, 32, 27, 0.05),
    0 6px 14px -6px rgba(35, 32, 27, 0.1),
    0 30px 60px -28px rgba(80, 50, 30, 0.28);
  padding: clamp(6px, 1.4vw, 18px) clamp(6px, 1.4vw, 18px) 0;
  overflow: hidden;
}
/* the faint grid of the drafting paper */
.foglio::before {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(35, 32, 27, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(35, 32, 27, 0.045) 1px, transparent 1px);
  background-size: calc(var(--foglio-w) / 32) calc(var(--foglio-w) / 32);
  background-position: -1px -1px;
  -webkit-mask-image: radial-gradient(120% 100% at 50% 40%, #000 40%, transparent 100%);
  mask-image: radial-gradient(120% 100% at 50% 40%, #000 40%, transparent 100%);
}
/* a soft light catching the top edge of the paper */
.foglio::after {
  content: '';
  position: absolute;
  left: 8%;
  right: 8%;
  top: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 1), transparent);
  pointer-events: none;
}
.foglio-dentro { position: relative; }
.pianta { display: block; width: 100%; height: auto; overflow: visible; }

/* the lines of the plan (the script sets stroke-dasharray and stroke-dashoffset as attributes) */
.pianta path { fill: none; }
.muri path { stroke: var(--ink); stroke-linecap: square; }
.muri .esterno { stroke-width: 9; }
.muri .interno { stroke-width: 5; }
.aperture path { stroke: var(--ink); stroke-width: calc(var(--px, 1) * 1.1); }
.aperture .arco { stroke: var(--soft); stroke-width: calc(var(--px, 1) * 0.9); }
.aperture .vetro { stroke: var(--soft); stroke-width: calc(var(--px, 1) * 0.8); }
.aperture .ringhiera { stroke: var(--ink); stroke-width: calc(var(--px, 1) * 1); }
.arredi path { stroke: #6c645a; stroke-width: calc(var(--px, 1) * 0.9); stroke-linejoin: round; stroke-linecap: round; }
.guide path { stroke: rgba(198, 90, 50, 0.4); stroke-width: calc(var(--px, 1) * 0.7); }
.guide .quota { stroke: var(--soft); stroke-width: calc(var(--px, 1) * 0.8); }
.riempimento { fill: var(--room); }
.riempimento.fuori { fill: url(#tratteggio); }
.tratto { stroke: rgba(198, 90, 50, 0.22); stroke-width: 1.2; }
.riempimento-tono { fill: var(--room); }
.etichette text {
  font-family: 'Geist Mono Variable', 'Geist Mono', ui-monospace, monospace;
  font-size: calc(var(--pxt, 1) * 8.5px);
  letter-spacing: 0.08em;
  fill: var(--ink);
  text-anchor: middle;
}
.etichette .et-mq { font-family: 'Mona Sans Variable', 'Mona Sans', sans-serif; font-size: calc(var(--px, 1) * 11px); letter-spacing: 0; font-weight: 600; fill: var(--accent); }
.etichette .et-quota { font-size: calc(var(--px, 1) * 8.5px); fill: var(--soft); letter-spacing: 0.06em; }
.matita-corpo { fill: #e9b24a; stroke: rgba(35, 32, 27, 0.5); stroke-width: 0.6; }
.matita-riga { stroke: rgba(35, 32, 27, 0.25); stroke-width: 0.6; }
.matita-legno { fill: #f1d9b5; stroke: rgba(35, 32, 27, 0.4); stroke-width: 0.6; }
.matita-punta { fill: var(--ink); }
.matita { opacity: 0; }

/* the title block at the foot of the sheet */
.cartiglio {
  position: relative;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  margin: clamp(4px, 1vh, 10px) calc(-1 * clamp(6px, 1.4vw, 18px)) 0;
  padding: clamp(6px, 1.2vh, 11px) clamp(10px, 1.6vw, 18px);
  border-top: 1px solid var(--hair);
  font-family: 'Geist Mono Variable', 'Geist Mono', ui-monospace, monospace;
  font-size: clamp(8.5px, min(1vw, 1.8vh), 11.5px);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--soft);
  white-space: nowrap;
}
.cartiglio-destra { color: var(--ink); }
.cartiglio-destra span[data-totale] { display: inline-block; min-width: 2ch; text-align: right; color: var(--accent); }
.barra { position: absolute; left: 0; right: 0; bottom: 0; height: 2px; background: rgba(35, 32, 27, 0.05); }
.barra b { display: block; height: 100%; background: var(--accent); transform-origin: 0 50%; transform: scaleX(0); }

/* the card */
.carta {
  position: relative;
  flex: none;
  width: var(--carta-w);
  display: flex;
  flex-direction: column;
  background: rgba(255, 253, 248, 0.86);
  border: 1px solid var(--hair);
  border-radius: clamp(12px, 1.4vw, 20px);
  padding: clamp(6px, 0.8vw, 9px);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.95) inset,
    0 1px 2px rgba(35, 32, 27, 0.05),
    0 10px 22px -10px rgba(35, 32, 27, 0.14),
    0 40px 70px -34px rgba(80, 50, 30, 0.32);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}
.foto {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3.3;
  border-radius: clamp(8px, 1vw, 13px);
  overflow: hidden;
  background: linear-gradient(160deg, #ece6dc, #e2dacd);
  isolation: isolate;
}
.foto::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: inset 0 0 0 1px rgba(35, 32, 27, 0.08), inset 0 -40px 50px -30px rgba(20, 14, 8, 0.25);
  pointer-events: none;
  z-index: 3;
}
.foto-vuota { position: absolute; inset: 0; display: grid; place-items: center; }
.foto-vuota svg { width: 22%; max-width: 54px; fill: none; stroke: rgba(35, 32, 27, 0.22); stroke-width: 1; stroke-linejoin: round; }
.foto-strato { position: absolute; inset: 0; overflow: hidden; z-index: 1; }
.foto-strato img { display: block; width: 100%; height: 100%; object-fit: cover; }
/* the little frosted tag on the photo, with the room's light */
.foto-strato .luce {
  position: absolute;
  left: 8px;
  bottom: 8px;
  max-width: calc(100% - 16px);
  padding: 4px 8px;
  border-radius: 999px;
  font-size: clamp(9px, min(0.85vw, 1.6vh), 11px);
  font-weight: 540;
  color: #fff;
  background: rgba(30, 22, 16, 0.32);
  border: 1px solid rgba(255, 255, 255, 0.28);
  -webkit-backdrop-filter: blur(8px) saturate(1.3);
  backdrop-filter: blur(8px) saturate(1.3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.carta-testo {
  display: flex;
  flex-direction: column;
  gap: clamp(2px, 0.6vh, 6px);
  padding: clamp(8px, 1.6vh, 14px) clamp(4px, 0.6vw, 8px) clamp(4px, 0.8vh, 8px);
  min-width: 0;
}
.piccolo {
  position: relative;
  height: 1.4em;
  overflow: hidden;
  font-family: 'Geist Mono Variable', 'Geist Mono', ui-monospace, monospace;
  font-size: clamp(8.5px, min(0.85vw, 1.6vh), 10.5px);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--soft);
  white-space: nowrap;
}
.piccolo span { position: absolute; left: 0; top: 0; }
.nomi { position: relative; height: 1.2em; font-size: clamp(15px, min(1.9vw, 3.4vh), 25px); overflow: hidden; }
.voce {
  position: absolute;
  inset: 0;
  font-weight: 600;
  font-stretch: 104%;
  letter-spacing: -0.02em;
  line-height: 1.2;
  white-space: nowrap;
}
.riga-mq { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.mq { font-size: clamp(13px, min(1.4vw, 2.6vh), 18px); font-weight: 520; color: var(--accent); white-space: nowrap; }
.mq span { display: inline-block; }
.mq small { font-size: 0.8em; }
.nota { position: relative; flex: 1; min-width: 0; height: 1.3em; font-size: clamp(9.5px, min(0.95vw, 1.7vh), 12px); color: var(--soft); overflow: hidden; text-align: right; }
.nota span { position: absolute; right: 0; top: 0; white-space: nowrap; }

/* the end: the total and the button */
.fine {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: clamp(4px, 1vh, 10px);
  padding-top: clamp(6px, 1.2vh, 12px);
  border-top: 1px solid var(--hair);
}
.fine-totale { font-size: clamp(9.5px, min(0.95vw, 1.7vh), 12px); color: var(--soft); white-space: nowrap; }
.fine-totale b span { display: inline-block; min-width: 1.2em; text-align: right; }
.fine-totale b { display: block; font-size: 1.45em; font-weight: 640; color: var(--ink); letter-spacing: -0.02em; }

/* the elastic pill */
.pillola {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: clamp(7px, 1.2vh, 11px) clamp(11px, 1.2vw, 16px);
  color: #8a8278;
  text-decoration: none;
  font-size: clamp(10.5px, min(1vw, 1.9vh), 13px);
  font-weight: 580;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
  isolation: isolate;
  flex: 1 0 auto;
  justify-content: center;
}
.pillola::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -2;
  border-radius: 999px;
  background: rgba(35, 32, 27, 0.05);
  box-shadow: inset 0 0 0 1px var(--hair);
}
.pillola-fondo {
  opacity: 0;
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: 999px;
  background: linear-gradient(180deg, #d0663d, var(--accent) 60%, #b04d29);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.35) inset, 0 -1px 0 rgba(0, 0, 0, 0.12) inset, 0 6px 14px -6px rgba(198, 90, 50, 0.7);
}
.pillola-testo { font-variation-settings: 'wdth' 100; }
.pillola-freccia { width: 1.05em; height: 1.05em; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }

/* tall boxes (phones): the card goes under the sheet, photo on the left and words on the right */
@media (max-aspect-ratio: 1/1) {
  .palco { padding-top: clamp(30px, 7vh, 64px); }
  .scena {
    --foglio-w: min(94vw, calc(100vh * 0.86), 640px);
    flex-direction: column;
    gap: clamp(8px, 1.8vh, 18px);
  }
  .carta {
    width: var(--foglio-w);
    flex-direction: row;
    align-items: stretch;
    gap: clamp(6px, 2vw, 14px);
  }
  .foto { width: 40%; aspect-ratio: auto; height: clamp(76px, 21vh, 220px); flex: none; }
  .carta-testo { flex: 1; padding: clamp(2px, 0.8vh, 8px) 2px clamp(2px, 0.6vh, 6px); justify-content: center; }
  .nomi { font-size: clamp(14px, min(4.6vw, 3.4vh), 24px); }
  .mq { font-size: clamp(12px, min(3.6vw, 2.6vh), 18px); }
  .nota { display: none; }
  .piccolo, .fine-totale { font-size: clamp(8.5px, min(2.4vw, 1.7vh), 12px); }
  .pillola { font-size: clamp(10px, min(3vw, 2vh), 13px); }
  .foto-strato .luce { display: none; }
  .fine-totale { display: none; }
  .fine { justify-content: stretch; }
  .pillola { flex: 1; justify-content: center; }
  .testa { font-size: clamp(9px, min(2.6vw, 2vh), 13px); }
}
/* very narrow: the right part of the top line keeps only the size */
@media (max-width: 460px) {
  .testa-destra .lungo { display: none; }
  .etichette .et-nome { display: none; }
}

@media (hover: hover) {
  .pillola:hover .pillola-testo { font-variation-settings: 'wdth' 112; }
}
@media (prefers-reduced-motion: reduce) {
  .pillola-testo { transition: none; }
}
