/* The checkout case study that goes from problem to result on scroll. Colours in :root (the Playground palette). */
:root {
  --fondo: #f2f0eb;
  --carta: #ffffff;
  --inchiostro: #15161a;
  --secondario: #6f7179;
  --spento: #b4b5ba;
  --linea: rgba(21, 22, 26, 0.08);
  --blu: #3a5cff;
  --rosso: #e5484d;
  --telefono: #17181c;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { background: var(--fondo); }
body {
  background: var(--fondo);
  color: var(--inchiostro);
  font-family: 'Mona Sans Variable', 'Mona Sans', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }

.corsa { position: relative; height: 360vh; }
.palco {
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100lvh;
  max-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  isolation: isolate;
}
/* a fine grain over the ground */
.palco::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  opacity: 0.045;
  pointer-events: none;
  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%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* the soft light behind the phone: warm red on the problem, blue on the result */
.alone { position: absolute; inset: 0; z-index: -2; pointer-events: none; }
.alone span {
  position: absolute;
  left: 50%;
  top: 58%;
  width: min(820px, 130vw, 140vh);
  aspect-ratio: 1.5;
  translate: -50% -50%;
  border-radius: 50%;
  filter: blur(40px);
}
.alone__rosso { background: radial-gradient(closest-side, rgba(229, 72, 77, 0.16), transparent); opacity: 0; }
.alone__blu { background: radial-gradient(closest-side, rgba(58, 92, 255, 0.2), transparent); opacity: 0; }

/* the composition is drawn at 400 by 500 and scaled to the stage (--k is set by the script on resize) */
.posto { position: relative; width: calc(400px * var(--k, 1)); height: calc(500px * var(--k, 1)); flex: none; }
.scala {
  position: absolute;
  left: 0;
  top: 0;
  width: 400px;
  height: 500px;
  transform: scale(var(--k, 1));
  transform-origin: 0 0;
}

.occhiello {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 6px;
  font-size: 10.5px;
  font-weight: 560;
  letter-spacing: 0.01em;
  color: var(--secondario);
}
.occhiello svg { width: 13px; height: 13px; fill: none; stroke: var(--inchiostro); stroke-width: 1.5; stroke-linecap: round; }
.occhiello__sep { color: var(--spento); }

.titolo {
  position: absolute;
  left: 0;
  right: 0;
  top: 22px;
  text-align: center;
  font-size: 26px;
  line-height: 1.12;
  font-weight: 640;
  font-stretch: 104%;
  letter-spacing: -0.02em;
}
.titolo__due {
  display: inline-block;
  overflow: hidden;
  padding: 0 4px 3px;
  font-size: 17px;
  font-weight: 480;
  font-stretch: 96%;
  letter-spacing: -0.005em;
  color: var(--secondario);
}
.titolo__in { display: inline-block; }

/* the segmented control of the chapters */
.capitoli {
  position: absolute;
  left: 50%;
  top: 92px;
  width: 258px;
  margin-left: -129px;
  height: 30px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  padding: 3px;
  border-radius: 999px;
  background: rgba(21, 22, 26, 0.05);
  box-shadow: inset 0 0 0 1px var(--linea), inset 0 1px 2px rgba(21, 22, 26, 0.06);
}
.capitoli__pillola {
  position: absolute;
  left: 3px;
  top: 3px;
  width: 84px;
  height: 24px;
  border-radius: 999px;
  background: var(--carta);
  box-shadow: 0 0 0 1px rgba(21, 22, 26, 0.06), 0 1px 2px rgba(21, 22, 26, 0.08), 0 4px 10px -4px rgba(21, 22, 26, 0.18);
}
.capitolo {
  position: relative;
  z-index: 1;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 520;
  color: var(--secondario);
  transition: color 0.25s;
}
.capitolo__in { display: inline-block; transition: transform 0.2s cubic-bezier(0.3, 1.6, 0.5, 1); }
.capitolo.attivo { color: var(--inchiostro); font-weight: 620; }
.capitolo:active .capitolo__in { transform: scale(0.94); }
.capitolo:focus-visible { outline: 2px solid var(--blu); outline-offset: 1px; }
@media (hover: hover) {
  .capitolo:hover { color: var(--inchiostro); }
}

.fila { position: absolute; left: 0; top: 140px; width: 400px; height: 360px; }

/* the phone */
.telefono {
  position: absolute;
  left: 6px;
  top: 0;
  width: 172px;
  height: 356px;
  padding: 5px;
  border-radius: 34px;
  background: linear-gradient(150deg, #2b2d33, var(--telefono) 40%, #0d0e10);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.1),
    inset 0 1px 0 rgba(255, 255, 255, 0.18),
    0 1px 2px rgba(21, 22, 26, 0.2),
    0 12px 24px -10px rgba(21, 22, 26, 0.35),
    0 40px 60px -30px rgba(21, 22, 26, 0.45);
}
.schermo {
  position: relative;
  width: 162px;
  height: 346px;
  border-radius: 29px;
  overflow: hidden;
  background: #fbfbfa;
  isolation: isolate;
}
.isola { position: absolute; left: 50%; top: 6px; width: 48px; height: 14px; margin-left: -24px; border-radius: 9px; background: #0b0b0d; z-index: 6; }
.barra-stato {
  position: absolute;
  left: 18px;
  right: 14px;
  top: 7px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 8px;
  font-weight: 640;
}
.barra-stato svg { width: 22px; height: 8px; fill: none; stroke: var(--inchiostro); stroke-width: 1; }
.barra-stato .segnale { stroke-width: 1.4; stroke-linecap: round; }
.barra-stato .pila { fill: var(--inchiostro); stroke: none; }

.testa-app { position: absolute; left: 10px; right: 10px; top: 30px; display: flex; justify-content: space-between; align-items: baseline; }
.testa-app__nome { font-size: 13px; font-weight: 680; letter-spacing: -0.01em; }
.testa-app__passo { position: relative; font-size: 7.5px; font-weight: 560; color: var(--secondario); }
.passo-dopo { position: absolute; right: 0; top: 0; display: inline-flex; align-items: center; gap: 2px; opacity: 0; color: var(--blu); white-space: nowrap; }
.passo-dopo svg { width: 8px; height: 8px; fill: none; stroke: currentColor; stroke-width: 1.2; }

.avanza { position: absolute; left: 10px; top: 49px; width: 142px; height: 3px; }
.avanza__pezzo { position: absolute; top: 0; height: 3px; border-radius: 2px; background: rgba(21, 22, 26, 0.1); }

.griglia { position: absolute; left: 10px; right: 10px; top: 24px; bottom: 0; display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px; opacity: 0; z-index: 1; }
.griglia span { background: rgba(229, 72, 77, 0.07); box-shadow: inset 1px 0 0 rgba(229, 72, 77, 0.22), inset -1px 0 0 rgba(229, 72, 77, 0.22); }

.prima, .dopo, .fili { position: absolute; inset: 0; z-index: 2; }
.p, .d, .filo { position: absolute; }

/* the old screen: crowded and grey */
.p { display: flex; align-items: center; font-size: 7px; color: #8d8f96; }
.p--banner { gap: 4px; padding: 0 7px; border-radius: 5px; background: #fff3c9; color: #7a5b00; font-weight: 600; }
.p--banner svg { width: 8px; height: 8px; fill: #e7b100; }
.p--campo { padding: 0 7px; border-radius: 4px; background: #fff; box-shadow: inset 0 0 0 1px #dcdde1; }
.p--spunta { gap: 5px; font-size: 6.8px; color: #5d5f66; }
.casella { display: grid; place-items: center; width: 10px; height: 10px; border-radius: 3px; background: #9a9ca3; }
.casella svg { width: 8px; height: 8px; fill: none; stroke: #fff; stroke-width: 1.4; }
.p--continua { justify-content: center; border-radius: 6px; background: #d9dade; color: #6e7077; font-size: 8px; font-weight: 600; }
.p--nota { justify-content: center; font-size: 6.4px; color: #a6a8ae; }

/* the wireframe blocks */
.filo {
  border-radius: 5px;
  background: rgba(58, 92, 255, 0.06);
  box-shadow: inset 0 0 0 1px rgba(58, 92, 255, 0.34);
  opacity: 0;
}
.filo::before {
  content: '';
  position: absolute;
  left: 6px;
  top: 50%;
  width: 34%;
  height: 3px;
  margin-top: -1.5px;
  border-radius: 2px;
  background: rgba(58, 92, 255, 0.28);
}
/* the selection frame of the block that moves, with its four handles */
.selezione { position: absolute; z-index: 3; opacity: 0; box-shadow: 0 0 0 1px var(--blu); border-radius: 2px; pointer-events: none; }
.selezione i { position: absolute; width: 5px; height: 5px; background: #fff; box-shadow: 0 0 0 1px var(--blu); }
.selezione i:nth-child(1) { left: -3px; top: -3px; }
.selezione i:nth-child(2) { right: -3px; top: -3px; }
.selezione i:nth-child(3) { left: -3px; bottom: -3px; }
.selezione i:nth-child(4) { right: -3px; bottom: -3px; }

/* the new screen: calm, one column, everything in view */
.d { display: flex; align-items: center; font-size: 7.5px; opacity: 0; }
.d--prodotto { gap: 8px; padding: 0 9px 0 5px; border-radius: 10px; background: #fff; box-shadow: 0 0 0 1px rgba(21, 22, 26, 0.06), 0 4px 10px -6px rgba(21, 22, 26, 0.2); }
.sacco {
  position: relative;
  width: 34px;
  height: 36px;
  flex: none;
  border-radius: 7px 7px 9px 9px;
  background: linear-gradient(160deg, #c99a6b, #8a5a37 60%, #6d4429);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35), inset 0 -6px 8px -4px rgba(0, 0, 0, 0.25), 0 3px 6px -3px rgba(60, 30, 10, 0.5);
}
.sacco::before { content: ''; position: absolute; left: 4px; right: 4px; top: 4px; height: 2px; border-radius: 1px; background: rgba(0, 0, 0, 0.22); box-shadow: 0 1px 0 rgba(255, 255, 255, 0.25); }
.sacco__etichetta { position: absolute; left: 7px; right: 7px; top: 12px; bottom: 8px; border-radius: 3px; background: #f6efe4; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.06); }
.sacco__etichetta::after { content: ''; position: absolute; left: 4px; right: 4px; top: 5px; height: 2px; border-radius: 1px; background: var(--blu); box-shadow: 0 4px 0 -0.5px rgba(21, 22, 26, 0.25); }
.prodotto__testi { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; white-space: nowrap; }
.prodotto__nome { font-size: 9px; font-weight: 660; letter-spacing: -0.01em; }
.prodotto__nota { font-size: 6.8px; color: var(--secondario); }
.prodotto__prezzo { font-size: 8.5px; font-weight: 620; }
.d--express { justify-content: center; gap: 4px; border-radius: 8px; background: var(--inchiostro); color: #fff; font-size: 8.5px; font-weight: 620; box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.16), 0 4px 10px -5px rgba(21, 22, 26, 0.5); }
.d--express svg { width: 9px; height: 9px; fill: #fff; }
.d--o { justify-content: center; font-size: 6.5px; color: var(--spento); }
.d--o::before, .d--o::after { content: ''; flex: 1; height: 1px; background: var(--linea); }
.d--o span { padding: 0 6px; }
.d--campo { position: absolute; padding: 9px 8px 0; border-radius: 7px; background: #fff; box-shadow: inset 0 0 0 1px #e4e5e8; font-size: 7.8px; font-weight: 520; }
.campo__nome { position: absolute; left: 8px; top: 4px; font-size: 5.6px; font-weight: 560; color: var(--secondario); letter-spacing: 0.02em; }
.campo__segno { position: absolute; right: 7px; top: 50%; width: 9px; height: 9px; margin-top: -4.5px; fill: none; stroke: var(--blu); stroke-width: 1.1; }
.d--totale { justify-content: space-between; padding: 0 2px; font-size: 7.5px; color: var(--secondario); }
.d--totale strong { font-size: 10px; font-weight: 700; color: var(--inchiostro); letter-spacing: -0.01em; }
.d--ordina { justify-content: center; color: #fff; font-size: 9px; font-weight: 640; }
.ordina__fondo {
  position: absolute;
  inset: 0;
  border-radius: 9px;
  background: linear-gradient(180deg, #5274ff, var(--blu));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.3), inset 0 -1px 0 rgba(0, 0, 0, 0.12), 0 6px 14px -6px rgba(58, 92, 255, 0.7);
}
.ordina__finestra { position: relative; height: 12px; overflow: hidden; }
.ordina__in { display: flex; flex-direction: column; }
.ordina__riga { display: flex; align-items: center; justify-content: center; gap: 3px; height: 12px; line-height: 12px; }
.ordina__riga svg { width: 10px; height: 10px; fill: none; stroke: #fff; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; opacity: 0; }
.d--nota { justify-content: center; font-size: 6.2px; color: var(--secondario); }

/* the red rings and their tags */
.anelli { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 4; pointer-events: none; overflow: visible; }
.anelli rect { fill: none; stroke: var(--rosso); stroke-width: 1.2; stroke-dasharray: 1; stroke-dashoffset: 1; }
.cartellino {
  position: absolute;
  z-index: 5;
  padding: 2px 5px;
  border-radius: 999px;
  background: var(--rosso);
  color: #fff;
  font-size: 6.4px;
  font-weight: 640;
  white-space: nowrap;
  box-shadow: 0 2px 6px -2px rgba(229, 72, 77, 0.6);
  opacity: 0;
}

/* a light that sweeps the glass once the order is placed */
.riflesso {
  position: absolute;
  inset: -20% -60%;
  z-index: 7;
  pointer-events: none;
  background: linear-gradient(105deg, transparent 42%, rgba(255, 255, 255, 0.55) 50%, transparent 58%);
  transform: translateX(-70%);
  opacity: 0;
}

/* the results card */
.risultati {
  position: absolute;
  left: 194px;
  top: 38px;
  width: 206px;
  padding: 14px 14px 12px;
  border-radius: 18px;
  background: var(--carta);
  box-shadow:
    0 0 0 1px rgba(21, 22, 26, 0.06),
    0 1px 1px rgba(21, 22, 26, 0.04),
    0 8px 16px -8px rgba(21, 22, 26, 0.12),
    0 28px 50px -24px rgba(21, 22, 26, 0.22);
  overflow: hidden;
}
.risultati__luce {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(160px circle at var(--mx, 70%) var(--my, -10%), rgba(58, 92, 255, 0.08), transparent 70%);
}
.risultati::after { content: ''; position: absolute; left: 14px; right: 14px; top: 0; height: 1px; background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 1), transparent); }
.risultati__testa { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.risultati__nome { font-size: 11px; font-weight: 640; }
.etichetta { padding: 2px 7px; border-radius: 999px; background: rgba(21, 22, 26, 0.05); box-shadow: inset 0 0 0 1px var(--linea); font-size: 7.5px; font-weight: 560; color: var(--secondario); }
.etichetta__finestra { display: block; height: 10px; line-height: 10px; overflow: hidden; }
.etichetta__in { display: block; white-space: nowrap; }

.grande__nome { font-size: 8.5px; font-weight: 520; color: var(--secondario); }
.grande { display: flex; align-items: center; gap: 7px; margin: 1px 0 6px; }
.grande__valore { font-size: 32px; font-weight: 700; font-stretch: 108%; letter-spacing: -0.035em; line-height: 1.05; color: var(--rosso); }
.salto {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 2px 6px 2px 4px;
  border-radius: 999px;
  background: rgba(58, 92, 255, 0.1);
  color: var(--blu);
  font-size: 8.5px;
  font-weight: 660;
  opacity: 0;
}
.salto svg { width: 8px; height: 8px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; }

.grafico { display: block; width: 178px; height: 56px; overflow: visible; }
.grafico__riga { fill: none; stroke: var(--linea); stroke-width: 1; }
.grafico__area { fill: url(#sotto); opacity: 0; }
.grafico__a, .grafico__b { fill: none; stroke-width: 1.6; stroke-linecap: round; stroke-dasharray: 1; stroke-dashoffset: 1; opacity: 0; }
.grafico__a { stroke: var(--spento); }
.grafico__b { stroke: var(--blu); opacity: 0; }
.legenda { display: flex; gap: 10px; margin: 5px 0 10px; font-size: 7px; color: var(--secondario); }
.legenda span { display: inline-flex; align-items: center; gap: 4px; }
.legenda span::before { content: ''; width: 10px; height: 1.6px; border-radius: 1px; background: var(--spento); }
.legenda__b { opacity: 0.35; }
.legenda__b::before { background: var(--blu) !important; }

.riga { display: grid; grid-template-columns: 1fr auto; row-gap: 5px; padding: 8px 0 0; border-top: 1px solid var(--linea); margin-top: 8px; }

.riga__nome { font-size: 8.5px; color: var(--secondario); }
.riga__valore { font-size: 12px; font-weight: 660; letter-spacing: -0.01em; color: var(--rosso); }
.binario { grid-column: 1 / -1; position: relative; height: 4px; border-radius: 2px; background: rgba(21, 22, 26, 0.06); }
.binario__pieno { position: absolute; left: 0; top: 0; bottom: 0; width: 100%; border-radius: 2px; background: var(--rosso); transform-origin: 0 50%; transform: scaleX(0); }
.binario__prima { position: absolute; top: -2px; bottom: -2px; width: 1.5px; border-radius: 1px; background: var(--spento); opacity: 0; }

@media (hover: hover) {
  .d--ordina { cursor: pointer; }
  .ordina__fondo { transition: filter 0.25s, box-shadow 0.25s; }
  .d--ordina:hover .ordina__fondo { filter: brightness(1.07); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.3), inset 0 -1px 0 rgba(0, 0, 0, 0.12), 0 9px 18px -7px rgba(58, 92, 255, 0.8); }
}

.piede-pagina { padding: 28px 16px 36px; text-align: center; font-size: 12px; color: var(--secondario); }

/* the card colours follow the chapter: red figures on the problem, ink while testing, blue on the result */
.grande__valore, .riga__valore { transition: color 0.45s; }
.binario__pieno { transition: background-color 0.45s; }
.risultati[data-fase="1"] .grande__valore, .risultati[data-fase="1"] .riga__valore { color: var(--inchiostro); }
.risultati[data-fase="1"] .binario__pieno { background: #8d8f96; }
.risultati[data-fase="2"] .grande__valore { color: var(--inchiostro); }
.risultati[data-fase="2"] .riga__valore { color: var(--blu); }
.risultati[data-fase="2"] .binario__pieno { background: var(--blu); }
