:root {
  --carta: #efeeed;          /* the warm paper the saga opens on */
  --oro: #b8a88a;            /* the gold of the thread on the edge and of the line on the left */
  --oro-filo: #ecd7a2;       /* the same gold in the light, for the thread on the edge of the noise */
  --campo-1: #b4532f;        /* Kindling: ember */
  --campo-2: #d8b98f;        /* Ashgrove: warm sand */
  --campo-3: #76382a;        /* The Thaw: rust */
  --campo-4: #e8dcc6;        /* Saltwind: bone */
  --campo-5: #22201d;        /* Last Ember: warm black */
  --tinta-1: #f4ece0;        /* the ink on each field */
  --tinta-2: #22201d;
  --tinta-3: #efe4d6;
  --tinta-4: #22201d;
  --tinta-5: #efeeed;
  --tinta: var(--tinta-1);   /* the ink of the corners and of the diamonds, set by the script */
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; background: var(--carta); overflow: hidden; }
body {
  font-family: 'Mulish Variable', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

.palco {
  position: relative;
  height: 100vh;
  height: 100lvh;
  overflow: hidden;
  touch-action: none;
  color: var(--tinta);
  transition: color 0.6s cubic-bezier(.42, 0, .58, 1);
}

.tela {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

/* a very fine paper grain over every field */
.grana {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.5;
  mix-blend-mode: soft-light;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='180' height='180'><filter id='g'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.5  0 0 0 0 0.5  0 0 0 0 0.5  0 0 0 0.5 0'/></filter><rect width='100%' height='100%' filter='url(%23g)'/></svg>");
}

.nascosto {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.marchio,
.editore {
  position: absolute;
  top: clamp(14px, 3.6vh, 30px);
  z-index: 3;
  font-size: clamp(10px, min(1.1vw, 2.4vh), 12px);
  font-weight: 650;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}
.marchio { left: clamp(16px, 3vw, 40px); }
.editore { right: clamp(16px, 3vw, 40px); font-weight: 450; opacity: 0.72; }

/* the five diamonds on the left, joined by a thin line */
.porte {
  position: absolute;
  z-index: 4;
  left: clamp(10px, 2.6vw, 36px);
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  gap: clamp(8px, 3.4vh, 26px);
}
.porte__linea {
  position: absolute;
  left: 13px;
  top: 14px;
  bottom: 14px;
  width: 1px;
  background: currentColor;
  opacity: 0.32;
}
.porte__oro {
  position: absolute;
  left: 13px;
  top: 3px;
  width: 1px;
  height: 22px;
  background: var(--oro);
  box-shadow: 0 0 0 0.5px var(--oro);
}
.porta {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  height: 28px;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.porta:focus-visible { outline: 1px solid var(--oro); outline-offset: 2px; }
.porta__scala {
  position: relative;
  width: 27px;
  height: 27px;
  display: grid;
  place-items: center;
}
.rombo,
.rombo__pieno {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
}
.rombo::before {
  content: '';
  width: 9px;
  height: 9px;
  border: 1px solid currentColor;
  transform: rotate(45deg);
  background: var(--sotto, transparent);
}
.rombo__pieno::before {
  content: '';
  width: 5px;
  height: 5px;
  background: currentColor;
  transform: rotate(45deg);
}
.porta__nome {
  display: flex;
  overflow: clip;
  padding-bottom: 0.15em;
  margin-bottom: -0.15em;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  white-space: nowrap;
  pointer-events: none;
}
.porta__nome span { display: inline-block; white-space: pre; }
@media (max-width: 760px) {
  .porta__nome { display: none; }
}

/* the column of the five books: it jumps by one screen while the words are out */
.finestra {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}
.colonna { height: 500%; }
.libro {
  height: 20%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(8px, 2.2vh, 20px);
  padding: 0 max(52px, 10vw);
  padding-bottom: 6vh;
  text-align: center;
}
.libro:nth-child(1) { color: var(--tinta-1); }
.libro:nth-child(2) { color: var(--tinta-2); }
.libro:nth-child(3) { color: var(--tinta-3); }
.libro:nth-child(4) { color: var(--tinta-4); }
.libro:nth-child(5) { color: var(--tinta-5); }

.libro__badge {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: clamp(9px, min(1vw, 2.2vh), 11px);
  font-weight: 650;
  letter-spacing: 0.24em;
  text-transform: uppercase;
}
.filo {
  width: clamp(14px, 2.4vw, 28px);
  height: 1px;
  background: currentColor;
  opacity: 0.55;
}
.badge { display: block; padding-left: 0.24em; }
.badge span { display: block; }

.libro__titolo {
  display: flex;
  flex-wrap: nowrap;
  justify-content: center;
  font-family: 'Fraunces Variable', Georgia, serif;
  font-size: clamp(2.2rem, min(12vw, 16.5vh), 9.5rem);
  font-weight: 340;
  font-variation-settings: 'SOFT' 50;
  font-optical-sizing: auto;
  line-height: 1;
  letter-spacing: -0.02em;
  white-space: nowrap;
}
.lettere {
  display: block;
  overflow: clip;
  padding: 0.04em 0 0.15em;
  margin-bottom: -0.15em;
}
.lettere span { display: inline-block; white-space: pre; }

.libro__riga {
  max-width: min(34ch, 72vw);
  font-size: clamp(0.8rem, min(1.6vw, 2.9vh), 1.1rem);
  font-weight: 420;
  line-height: 1.45;
  opacity: 0.86;
}
.parola {
  display: inline-block;
  overflow: clip;
  padding-bottom: 0.15em;
  margin-bottom: -0.15em;
  vertical-align: top;
}
.parola span { display: inline-block; }

.invito {
  position: absolute;
  z-index: 3;
  left: 50%;
  bottom: clamp(12px, 4vh, 34px);
  transform: translateX(-50%);
  display: flex;
  font-size: clamp(9px, min(1vw, 2.2vh), 11px);
  font-weight: 600;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  white-space: nowrap;
  opacity: 0.7;
  pointer-events: none;
}
.invito span { display: inline-block; white-space: pre; }

@media (hover: hover) {
  .porta:hover .rombo::before { background: color-mix(in srgb, currentColor 18%, transparent); }
}
