:root {
  --carta: #f4ebda;
  --inchiostro: #1a1512;
  --rosso: #e63a20;
  --verde: #0e6b47;
  --rosa: #ff9cc2;
  --giallo: #ffc531;
  --blu: #2b44d9;
  --fucsia: #d1307f;

  --display: "Anybody", "Arial Black", Impact, sans-serif;
  --serif: "Fraunces", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --black: "wdth" 100, "wght" 900;

  --pad: clamp(18px, 5vw, 48px);
  --top: calc(max(16px, env(safe-area-inset-top)) + 42px);
  --bottom: calc(var(--pad) + env(safe-area-inset-bottom));
  --drop: 7px;
}

*,
*::before,
*::after { box-sizing: border-box; }
* { margin: 0; }
[hidden] { display: none !important; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  --bg: var(--rosso);
  --fg: var(--carta);
  min-height: 100dvh;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--serif);
  overflow-x: hidden;
  transition: background-color .45s ease;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
body[data-screen="reel"],
body[data-screen="nolink"] { --bg: var(--inchiostro); }
body[data-screen="result"] { --bg: var(--carta); --fg: var(--inchiostro); }
body[data-screen="boot"] > * { visibility: hidden; }

button {
  font: inherit;
  color: inherit;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
}
:focus-visible { outline: 3px solid currentColor; outline-offset: 4px; }

/* ---------- shared type ---------- */

.bar {
  position: absolute;
  inset: 0 0 auto 0;
  z-index: 2;
  display: flex;
  justify-content: space-between;
  padding: max(16px, env(safe-area-inset-top)) var(--pad) 0;
  font: 800 12px/1 var(--display);
  font-variation-settings: "wdth" 112, "wght" 800;
  letter-spacing: .14em;
  text-transform: uppercase;
  pointer-events: none;
}
/* A trial link wears a tag where the date goes. */
.bar .is-trial {
  margin: -.45em -.5em;
  padding: .5em .7em .4em;
  background: var(--fg);
  color: var(--bg);
  transition: background-color .45s ease, color .45s ease;
}

/* Poster block: every line is scaled by JS to fill the column. */
.fit {
  font-family: var(--display);
  font-weight: 900;
  font-variation-settings: var(--black);
  text-transform: uppercase;
  letter-spacing: -.025em;
  line-height: .84;
}
.fit__l {
  display: block;
  width: max-content;
  white-space: nowrap;
  font-size: 64px;
  transform-origin: 0 60%;
}

.say {
  font: italic 400 clamp(21px, 5.6vw, 30px)/1.15 var(--serif);
  letter-spacing: -.01em;
}
.say--s { font-size: clamp(16px, 4.2vw, 19px); }

.btn {
  appearance: none;
  width: 100%;
  max-width: 400px;
  padding: 1.02em 1.2em .9em;
  border: 3px solid var(--inchiostro);
  border-radius: 999px;
  background: var(--giallo);
  color: var(--inchiostro);
  font: 800 clamp(18px, 5vw, 23px)/1 var(--display);
  font-variation-settings: "wdth" 92, "wght" 800;
  text-transform: uppercase;
  letter-spacing: .01em;
  box-shadow: 0 var(--drop) 0 var(--inchiostro);
  cursor: pointer;
  transition: translate .08s, box-shadow .08s;
}
.btn:active {
  translate: 0 var(--drop);
  box-shadow: 0 0 0 var(--inchiostro);
}
.btn--ink {
  background: var(--inchiostro);
  color: var(--giallo);
  box-shadow: 0 var(--drop) 0 var(--rosso);
}
.btn--ink:active { box-shadow: 0 0 0 var(--rosso); }

.screen {
  position: relative;
  min-height: 100dvh;
  padding: var(--top) var(--pad) var(--bottom);
}

/* ---------- 1. ciao ---------- */

.hello {
  height: 100dvh;
  min-height: 500px;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto 1fr;
  overflow: hidden;
}
.hello__bg {
  position: absolute;
  inset: 0;
  display: grid;
  align-content: space-between;
  pointer-events: none;
}
.hello__row {
  width: max-content;
  white-space: nowrap;
  font: 900 clamp(70px, 15.6dvh, 170px)/.86 var(--display);
  font-variation-settings: var(--black);
  text-transform: uppercase;
  color: rgb(26 21 18 / .06);
  animation: slide var(--t, 70s) linear infinite;
}
.hello__row:nth-child(even) { animation-direction: reverse; }
@keyframes slide { to { transform: translateX(-50%); } }

.hello__copy { position: relative; }
.hello__copy .fit__l:first-child { margin-bottom: .16em; } /* room for the comma */
.hello__copy .say { margin-top: .75em; }

.pesca {
  position: relative;
  place-self: end center;
  margin-bottom: 12px;
  width: clamp(150px, 42vw, 220px);
  aspect-ratio: 1;
  border: 0;
  border-radius: 50%;
  background: var(--carta);
  color: var(--inchiostro);
  font: 900 clamp(28px, 8.4vw, 44px)/1 var(--display);
  font-variation-settings: var(--black);
  text-transform: uppercase;
  letter-spacing: -.01em;
  box-shadow: 0 12px 0 var(--inchiostro);
  cursor: pointer;
  animation: wobble 2.6s ease-in-out infinite;
  transition: translate .08s, box-shadow .08s;
}
.pesca::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 3px solid var(--carta);
  animation: ping 2.6s ease-out infinite;
  pointer-events: none;
}
.pesca:active {
  translate: 0 12px;
  box-shadow: 0 0 0 var(--inchiostro);
}
@keyframes wobble {
  0%, 100% { rotate: -8deg; }
  50% { rotate: 6deg; }
}
@keyframes ping {
  0% { scale: 1; opacity: .8; }
  70%, 100% { scale: 1.55; opacity: 0; }
}

/* ---------- 2. estrazione ---------- */

.reel {
  height: 100dvh;
  padding: 0;
  overflow: hidden;
  cursor: pointer;
}
.reel__window {
  position: absolute;
  inset: 0;
  overflow: hidden;
  -webkit-mask-image: linear-gradient(transparent 8%, rgb(0 0 0 / .28) 36%, #000 41%, #000 59%, rgb(0 0 0 / .28) 64%, transparent 92%);
  mask-image: linear-gradient(transparent 8%, rgb(0 0 0 / .28) 36%, #000 41%, #000 59%, rgb(0 0 0 / .28) 64%, transparent 92%);
}
.reel__strip {
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  will-change: transform;
}
.reel__row {
  height: var(--row, 120px);
  display: grid;
  place-content: center;
  justify-items: center;
  font: 900 var(--fs, 48px)/.86 var(--display);
  font-variation-settings: "wdth" 68, "wght" 900;
  text-transform: uppercase;
  letter-spacing: -.015em;
  white-space: nowrap;
}
.reel__row span { display: block; width: max-content; }
.reel__mark {
  position: absolute;
  top: 50%;
  translate: 0 -50%;
  border-block: 11px solid transparent;
}
.reel__mark--l { left: 5px; border-left: 15px solid var(--giallo); }
.reel__mark--r { right: 5px; border-right: 15px solid var(--giallo); }

/* ---------- 3. il nome ---------- */

.result {
  display: flex;
  flex-direction: column;
  gap: clamp(20px, 4.4dvh, 44px);
}
.result__who .say { margin-bottom: .6em; }
.name {
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
}
.name .ch { display: inline-block; white-space: pre; }
.name .ini { font-weight: inherit; transition: color .25s, rotate .2s; }
.name .ini.is-lit { color: var(--c); cursor: pointer; }
@media (hover: hover) {
  .name .ini.is-lit:hover { rotate: -7deg; }
}

.result__what {
  display: grid;
  justify-items: start;
  gap: clamp(10px, 2dvh, 18px);
  margin-block: auto;
  container-type: inline-size; /* the letters size themselves to this column */
}
.letters {
  --ls: clamp(104px, min(40vw, 21dvh), 220px);
  display: flex;
  align-items: flex-start;
  gap: clamp(8px, 2.6vw, 22px);
  margin: 0 0 clamp(12px, 3dvh, 28px) calc(var(--ls) * -.07);
}
/* three in a row: "M o L o D" */
.letters[data-n="3"] {
  --ls: clamp(72px, min(23vw, 21dvh), 190px);
  gap: clamp(6px, 2vw, 14px);
}
/* four wrap two by two, the "o" at the end of the first row leads into the second:
   "J o P o / G o A" */
.letters[data-n="4"] {
  --ls: clamp(72px, min(34vw, 15dvh), 190px);
  display: grid;
  grid-template-columns: repeat(4, auto);
  justify-content: start;
  row-gap: clamp(6px, 1.4dvh, 14px);
}
@supports (width: 1cqi) {
  .letters { --ls: clamp(104px, min(42cqi, 21dvh), 220px); }
  .letters[data-n="3"] { --ls: clamp(72px, min(26cqi, 21dvh), 190px); }
  .letters[data-n="4"] { --ls: clamp(72px, min(40cqi, 15dvh), 190px); }
}
.letter {
  all: unset;
  display: grid;
  justify-items: center;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
}
.letter:focus-visible { outline: 3px solid currentColor; outline-offset: 4px; }
.letter__g {
  display: block;
  width: 1em;
  text-align: center;
  font: 900 var(--ls)/.82 var(--display);
  font-variation-settings: var(--black);
  color: var(--c);
  transform-origin: 50% 70%;
  animation: breathe 3.4s ease-in-out infinite;
  animation-delay: var(--d, 0s);
}
.letters__o {
  margin-top: calc(var(--ls) * .3);
  font: italic 400 clamp(22px, 6vw, 34px)/1 var(--serif);
}
@keyframes breathe {
  0%, 100% { font-variation-settings: "wdth" 78, "wght" 900; rotate: -4deg; }
  50% { font-variation-settings: "wdth" 110, "wght" 900; rotate: 4deg; }
}

.result__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.again {
  all: unset;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  margin-right: -10px;
  border-radius: 50%;
  cursor: pointer;
  transition: rotate .5s cubic-bezier(.2, .8, .2, 1);
}
.again:hover { rotate: -180deg; }
.again:focus-visible { outline: 3px solid currentColor; }

@media (min-width: 900px) {
  .result {
    display: grid;
    grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr);
    grid-template-rows: 1fr auto;
    align-items: center;
    column-gap: 7vw;
    max-width: 1320px;
    margin-inline: auto;
  }
  .result__foot { grid-column: 1 / -1; }
  .hello__copy .fit { max-width: 62vw; }
  .pesca { place-self: end end; margin-right: 3vw; }
}

/* ---------- no link ---------- */

.nolink {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-content: center;
  gap: 22px;
}

/* ---------- the letter show ---------- */

.show {
  --sbg: var(--verde);
  --sletter: var(--giallo);
  --stape: var(--rosa);
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: var(--sbg);
  color: var(--carta);
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
}
.show__stage {
  grid-area: 1 / 1;
  z-index: 2;
  display: grid;
  place-items: center;
}
.show__l,
.show__echo > i {
  grid-area: 1 / 1;
  font: normal 900 min(104vw, 76dvh)/.8 var(--display);
  font-variation-settings: var(--black);
}
.show__l { color: var(--sletter); will-change: transform; }
.show__echo {
  grid-area: 1 / 1;
  display: grid;
  place-items: center;
}
.show__echo > i {
  color: transparent;
  -webkit-text-stroke: clamp(2px, .55vw, 5px) var(--sletter);
  opacity: 0;
}
.show__cap {
  position: absolute;
  top: max(12dvh, 74px);
  left: 0;
  right: 0;
  z-index: 4;
  padding-inline: var(--pad);
  text-align: center;
}
.show__wipe { position: absolute; inset: 0; z-index: 6; }

.tape {
  position: absolute;
  left: -25%;
  width: 150%;
  z-index: 1;
  top: 27%;
  rotate: -11deg;
  overflow: hidden;
  background: var(--stape);
  color: var(--inchiostro);
}
.tape--b {
  z-index: 3;
  top: auto;
  bottom: 25%;
  rotate: 8deg;
}
.tape__t {
  width: max-content;
  padding: .5em 0 .38em;
  white-space: pre;
  font: 900 clamp(15px, 4.2vw, 24px)/1 var(--display);
  font-variation-settings: "wdth" 110, "wght" 900;
  letter-spacing: .04em;
  text-transform: uppercase;
  animation: slide 14s linear infinite;
}
.tape--b .tape__t { animation-direction: reverse; }

/* ---------- idee ---------- */

.sheet {
  position: fixed;
  inset: 0;
  z-index: 30;
  overflow: hidden auto;
  overscroll-behavior: contain;
  background: var(--giallo);
  color: var(--inchiostro);
  transform: translateY(102%);
  transition: transform .5s cubic-bezier(.2, .85, .2, 1);
}
.sheet.is-open { transform: none; }
.sheet__in {
  max-width: 720px;
  min-height: 100%;
  margin-inline: auto;
  padding: max(18px, env(safe-area-inset-top)) var(--pad) var(--bottom);
  display: flex;
  flex-direction: column;
}
.sheet__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 18px;
}
.sheet__t {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px 12px;
  font-weight: 400;
}
.tabs { display: inline-flex; gap: 8px; }
.tab {
  all: unset;
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  padding-top: 3px;
  box-sizing: border-box;
  border: 3px solid var(--inchiostro);
  border-radius: 50%;
  font: 900 26px/1 var(--display);
  font-variation-settings: var(--black);
  cursor: pointer;
  transition: rotate .3s cubic-bezier(.2, .8, .2, 1.4), background-color .15s;
}
.tab[aria-pressed="true"] {
  background: var(--inchiostro);
  color: var(--giallo);
  rotate: -10deg;
}
.tab:focus-visible { outline: 3px solid var(--inchiostro); outline-offset: 3px; }
.x {
  all: unset;
  display: grid;
  place-items: center;
  flex: none;
  width: 48px;
  height: 48px;
  margin-right: -10px;
  cursor: pointer;
}
.x:focus-visible { outline: 3px solid var(--inchiostro); }

.ideas { list-style: none; padding: 0; }
.idea {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0 14px;
  align-items: start;
  padding: 18px 0 20px;
  border-top: 3px solid var(--inchiostro);
}
.idea:last-child { border-bottom: 3px solid var(--inchiostro); }
.idea__n {
  min-width: .62em;
  font: 900 clamp(58px, 16vw, 84px)/.8 var(--display);
  font-variation-settings: "wdth" 70, "wght" 900;
  color: transparent;
  -webkit-text-stroke: 2.5px var(--inchiostro);
}
.idea__t {
  font: 900 clamp(25px, 7.2vw, 40px)/.92 var(--display);
  font-variation-settings: "wdth" 72, "wght" 900;
  text-transform: uppercase;
  text-wrap: balance;
}
.idea__d {
  margin-top: .5em;
  font: italic 400 clamp(17px, 4.6vw, 21px)/1.22 var(--serif);
  text-wrap: pretty;
}

.sheet__end {
  margin-top: auto;
  padding-top: 26px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.sheet__end .btn { flex: 0 1 260px; }
.badge {
  flex: none;
  width: clamp(104px, 29vw, 150px);
  margin: -8px -6px -8px 0;
}
.badge__spin {
  transform-box: view-box;
  transform-origin: 50% 50%;
  animation: turn 16s linear infinite;
}
.badge__t {
  font: 800 15.5px/1 var(--display);
  font-variation-settings: "wdth" 100, "wght" 800;
  letter-spacing: .04em;
  text-transform: uppercase;
  fill: var(--carta);
}
@keyframes turn { to { transform: rotate(360deg); } }

/* ---------- fx ---------- */

.fx {
  position: fixed;
  inset: 0;
  z-index: 50;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

@media (prefers-reduced-motion: reduce) {
  .hello__row,
  .pesca,
  .pesca::after,
  .letter__g,
  .tape__t,
  .badge__spin { animation: none; }
  .sheet { transition: none; }
}
