/* The breakfast machine */
:root {
  --pannello: #e8c597;          /* the pegboard on the wall */
  --fori: #a97a4c;              /* the holes in the pegboard */
  --legno: #c98a4b;             /* the ramps and the shelves */
  --legno-scuro: #8e5429;       /* the edges of the wood */
  --biglia: #2f7de1;            /* the glass marble */
  --tessera: #221c24;           /* the dominoes */
  --puntini: #f7efe1;           /* the spots on the dominoes */
  --righello: #f4c430;          /* the ruler of the seesaw */
  --gomma: #ef8a9a;             /* the eraser under the ruler */
  --palla: #e5462d;             /* the rubber ball */
  --vetro: #bfe8f2;             /* the glass funnel and tube */
  --tazza: #fbf7ee;             /* the paper cup */
  --ottone: #d7a548;            /* the counterweight */
  --tostapane: #7fc8b6;         /* the toaster */
  --cromo: #dfe3e5;             /* the chrome of the toaster, the pulley and the rack */
  --pane: #f2ddb0;              /* the bread before the toaster */
  --tostato: #c98840;           /* the toast */
  --calore: #ff7a2a;            /* the glow inside the slots */
  --percorso: #241a14;          /* the route drawn over the whole machine at the end */
  --inchiostro: #241a14;        /* the words */
  --carta: #fbf3e4;             /* the cards on the stage */
  --alto-grande: 100vh;
}
/* the still stage is as tall as the screen with the Safari bar pulled back */
@supports (height: 100lvh) {
  :root { --alto-grande: 100lvh; }
}

* { box-sizing: border-box; }
html,
body {
  margin: 0;
  background: var(--pannello);
}
html.lenis,
html.lenis body { height: auto; }
.lenis.lenis-smooth { scroll-behavior: auto !important; }
body {
  color: var(--inchiostro);
  font-family: 'Anybody Variable', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
a { color: inherit; }

/* ---------------------------------------------------------------- the header */
.testata {
  position: fixed;
  inset: 0 0 auto;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px clamp(16px, 4vw, 40px);
  pointer-events: none;
}
.testata > * { pointer-events: auto; }
.marchio,
.testata__link {
  margin: 0;
  padding: 9px 15px;
  border-radius: 999px;
  background: var(--carta);
  box-shadow: 0 2px 0 rgba(36, 26, 20, 0.16);
  font-size: 15px;
  line-height: 1.1;
}
.marchio {
  font-weight: 800;
  font-stretch: 120%;
  letter-spacing: -0.01em;
}
.marchio span {
  font-weight: 500;
  color: var(--palla);
}
.testata__link {
  display: inline-block;
  font-weight: 650;
  font-stretch: 100%;
  text-decoration: none;
  transition: font-stretch 0.45s cubic-bezier(0.34, 1.56, 0.64, 1), transform 0.45s cubic-bezier(0.34, 1.56, 0.64, 1), background-color 0.3s ease;
}
@media (hover: hover) {
  /* the link widens on its own letters and leans like a domino about to go */
  .testata__link:hover {
    font-stretch: 135%;
    background: var(--righello);
    transform: rotate(-3deg);
  }
}

/* ---------------------------------------------------------------- the run */
.corsa {
  position: relative;
  height: calc(var(--alto-grande) * 11);
}
.palco {
  position: sticky;
  top: 0;
  height: var(--alto-grande);
  overflow: hidden;
  background: var(--pannello);
}
.mondo {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: pan-y;
}
.mondo [data-pezzo] { cursor: pointer; }

/* ---------------------------------------------------------------- the opening */
.apertura {
  position: absolute;
  top: clamp(84px, 15vh, 150px);
  left: clamp(16px, 6vw, 88px);
  max-width: min(640px, 92vw);
  pointer-events: none;
}
.apertura__etichetta,
.chiusa__etichetta {
  margin: 0 0 14px;
  font-family: 'JetBrains Mono Variable', ui-monospace, monospace;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.apertura__titolo {
  margin: 0;
  font-size: clamp(50px, 7.6vw, 118px);
  line-height: 0.86;
  font-weight: 850;
  font-stretch: 78%;
  letter-spacing: -0.03em;
}
.apertura__titolo em,
.chiusa__titolo em {
  font-style: normal;
  color: var(--palla);
}
.riga {
  display: block;
  overflow: hidden;
  padding-bottom: 0.07em;
}
.riga > span { display: inline-block; }
.apertura__testo {
  max-width: 31ch;
  margin: 18px 0 0;
  font-size: clamp(16px, 1.45vw, 19px);
  line-height: 1.4;
  font-weight: 480;
  font-stretch: 96%;
}
.cenno {
  position: absolute;
  left: 50%;
  bottom: clamp(22px, 5vh, 46px);
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  transform: translateX(-50%);
  font-family: 'JetBrains Mono Variable', ui-monospace, monospace;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
  pointer-events: none;
}
.cenno svg {
  width: 16px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ---------------------------------------------------------------- the captions */
.didascalie {
  position: absolute;
  left: clamp(16px, 4vw, 44px);
  bottom: clamp(18px, 5vh, 44px);
  width: min(360px, calc(100% - 32px));
  pointer-events: none;
}
.didascalia {
  position: absolute;
  left: 0;
  bottom: 0;
  width: 100%;
  padding: 16px 18px 18px;
  border-radius: 18px;
  background: var(--carta);
  box-shadow: 0 3px 0 rgba(36, 26, 20, 0.14);
  visibility: hidden;
}
.didascalia__nome,
.didascalia__testo {
  margin: 0;
  overflow: hidden;
}
.didascalia__nome > span,
.didascalia__testo > span { display: inline-block; }
.didascalia__nome {
  font-size: clamp(24px, 2.4vw, 32px);
  line-height: 1;
  font-weight: 820;
  font-stretch: 84%;
  letter-spacing: -0.02em;
  padding-bottom: 0.06em;
}
.didascalia__testo {
  margin-top: 6px;
  font-size: 15px;
  line-height: 1.35;
  font-weight: 470;
}

/* ---------------------------------------------------------------- the stopwatch */
.cronometro {
  position: absolute;
  top: clamp(76px, 11vh, 96px);
  right: clamp(16px, 4vw, 40px);
  padding: 12px 16px 10px;
  border-radius: 18px;
  background: var(--inchiostro);
  color: var(--carta);
  box-shadow: 0 3px 0 rgba(36, 26, 20, 0.2);
  visibility: hidden;
}
.cronometro__nome {
  margin: 0 0 4px;
  font-family: 'JetBrains Mono Variable', ui-monospace, monospace;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  opacity: 0.7;
}
.cronometro__tempo {
  margin: 0;
  display: flex;
  align-items: baseline;
  gap: 4px;
  font-family: 'JetBrains Mono Variable', ui-monospace, monospace;
  font-size: clamp(30px, 3vw, 40px);
  font-weight: 700;
  line-height: 1;
}
.contatore { display: inline-flex; }
.cifra {
  display: inline-block;
  height: 1em;
  overflow: hidden;
}
.cifra__colonna {
  display: flex;
  flex-direction: column;
}
.cifra__colonna > span { height: 1em; line-height: 1; }
.contatore__punto { line-height: 1; }
.cronometro__unita {
  font-size: 0.5em;
  opacity: 0.7;
}

/* ---------------------------------------------------------------- the close */
.chiusa {
  position: absolute;
  left: 50%;
  bottom: clamp(20px, 6vh, 64px);
  width: min(560px, calc(100% - 32px));
  padding: 22px 24px 24px;
  border-radius: 22px;
  background: var(--carta);
  box-shadow: 0 4px 0 rgba(36, 26, 20, 0.16);
  text-align: center;
  transform: translateX(-50%);
  visibility: hidden;
}
.chiusa__etichetta { margin-bottom: 8px; }
.chiusa__titolo {
  margin: 0;
  font-size: clamp(44px, 5.6vw, 76px);
  line-height: 0.9;
  font-weight: 850;
  font-stretch: 80%;
  letter-spacing: -0.03em;
}
.chiusa__testo {
  max-width: 36ch;
  margin: 10px auto 18px;
  font-size: 16px;
  line-height: 1.4;
  font-weight: 470;
}

/* the elastic pill: the words widen on their own axis and the fill swells with a bounce */
.pulsante {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 52px;
  padding: 0 28px;
  border-radius: 999px;
  color: var(--carta);
  text-decoration: none;
  isolation: isolate;
}
.pulsante__fondo {
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: inherit;
  background: var(--palla);
  transition: transform 0.6s cubic-bezier(0.34, 1.8, 0.5, 1), background-color 0.3s ease;
}
.pulsante__testo {
  font-size: 17px;
  font-weight: 760;
  font-stretch: 100%;
  letter-spacing: 0.005em;
  transition: font-stretch 0.55s cubic-bezier(0.34, 1.7, 0.5, 1);
}
@media (hover: hover) {
  .pulsante:hover .pulsante__fondo { transform: scale(1.08, 1.16); background: var(--inchiostro); }
  .pulsante:hover .pulsante__testo { font-stretch: 140%; }
}
.pulsante:active .pulsante__fondo { transform: scale(0.95); transition-duration: 0.15s; }
.pulsante:focus-visible { outline: 3px solid var(--inchiostro); outline-offset: 4px; }

/* ---------------------------------------------------------------- the machine's parts */
.m-fori { fill: var(--fori); }
.m-fori-luce { fill: #ffffff; opacity: 0.22; }
.m-pannello { fill: var(--pannello); }
.m-ombra { fill: #3b2410; opacity: 0.16; }
.m-legno { fill: var(--legno); stroke: var(--legno-scuro); stroke-width: 2.5; stroke-linejoin: round; }
.m-legno-bordo { fill: var(--legno-scuro); }
.m-ferro { fill: #5f5a57; }
.m-chiodo { fill: #3e3936; }
.m-filo { fill: none; stroke: #4a3a2e; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.m-placca { fill: var(--carta); stroke: var(--inchiostro); stroke-width: 3; }
.m-leva { fill: var(--palla); stroke: var(--inchiostro); stroke-width: 3; }
.m-scritta { fill: var(--inchiostro); font-family: 'JetBrains Mono Variable', ui-monospace, monospace; font-weight: 700; font-size: 13px; letter-spacing: 0.06em; }
.m-sportello { fill: var(--righello); stroke: var(--inchiostro); stroke-width: 2.5; }
.m-biglia { fill: var(--biglia); }
.m-biglia-riga { fill: none; stroke: #ffffff; stroke-width: 4; stroke-linecap: round; opacity: 0.55; }
.m-luce { fill: #ffffff; opacity: 0.75; }
.m-tessera { fill: var(--tessera); }
.m-tessera-riga { stroke: var(--puntini); stroke-width: 2; opacity: 0.6; }
.m-puntino { fill: var(--puntini); }
.m-righello { fill: var(--righello); stroke: var(--inchiostro); stroke-width: 2.5; }
.m-tacca { stroke: var(--inchiostro); stroke-width: 1.6; }
.m-gomma { fill: var(--gomma); stroke: var(--inchiostro); stroke-width: 2.5; stroke-linejoin: round; }
.m-palla { fill: var(--palla); }
.m-palla-riga { fill: none; stroke: #ffd2a6; stroke-width: 4; opacity: 0.8; }
.m-vetro { fill: var(--vetro); fill-opacity: 0.42; stroke: #ffffff; stroke-width: 2.5; stroke-opacity: 0.9; }
.m-vetro-dietro { fill: var(--vetro); fill-opacity: 0.25; }
.m-vetro-bordo { fill: none; stroke: #6aa9b9; stroke-width: 2.5; }
.m-riflesso { fill: none; stroke: #ffffff; stroke-width: 4; stroke-linecap: round; opacity: 0.75; }
.m-tubo { fill: none; stroke: var(--vetro); stroke-opacity: 0.5; stroke-linecap: butt; }
.m-tubo-bordo { fill: none; stroke: #6aa9b9; stroke-linecap: butt; }
.m-cromo { fill: var(--cromo); stroke: var(--inchiostro); stroke-width: 2.5; }
.m-raggio { stroke: var(--inchiostro); stroke-width: 2.5; stroke-linecap: round; }
.m-ottone { fill: var(--ottone); stroke: var(--inchiostro); stroke-width: 2.5; }
.m-tazza { fill: var(--tazza); stroke: var(--inchiostro); stroke-width: 2.5; stroke-linejoin: round; }
.m-tazza-riga { fill: var(--palla); }
.m-tostapane { fill: var(--tostapane); stroke: var(--inchiostro); stroke-width: 3; }
.m-fessura { fill: #2a2420; }
.m-calore { fill: var(--calore); }
.m-manopola { fill: var(--tessera); }
.m-pane { stroke-width: 3; stroke-linejoin: round; }
.m-mollica { fill: #ffffff; opacity: 0.18; }
/* the toast goes golden as the script raises --k from 0 to 1 */
.m-crosta {
  fill: color-mix(in srgb, var(--tostato) calc(var(--k, 0) * 100%), var(--pane));
  stroke: color-mix(in srgb, var(--legno-scuro) calc(35% + var(--k, 0) * 55%), var(--pane));
}
.m-mollica-fondo { fill: color-mix(in srgb, #fff6dc 45%, color-mix(in srgb, var(--tostato) calc(var(--k, 0) * 85%), var(--pane))); }
.m-fumo { fill: none; stroke: #ffffff; stroke-width: 4; stroke-linecap: round; }
.m-suono { fill: none; stroke: var(--inchiostro); stroke-width: 4; stroke-linecap: round; }
.m-percorso { fill: none; stroke: var(--percorso); stroke-width: 5; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 2 14; }
.m-tazzina { fill: var(--carta); stroke: var(--inchiostro); stroke-width: 3; stroke-linejoin: round; }
.m-briciola { fill: var(--tostato); }

@media (max-width: 700px) {
  .apertura { top: 82px; }
  .apertura__testo { font-size: 15px; max-width: 28ch; }
  .didascalia { padding: 13px 15px 14px; border-radius: 16px; }
  .didascalia__testo { font-size: 14px; }
  .cronometro { top: 70px; padding: 9px 12px 8px; border-radius: 14px; }
  .cronometro__nome { font-size: 10px; }
  .cronometro__tempo { font-size: 24px; }
  .chiusa { padding: 18px 18px 20px; }
  .chiusa__testo { font-size: 15px; }
}
