/* MeMori — gli Scaffali nello stile «Ritagli» (28/10/2026, prova in tools/prova-scaffali): titolo grande
 * con il bollino del numero degli scaffali, raggruppamento a pillole con un'icona, «Colpo d'occhio»,
 * ogni scaffale un riquadro di carta con i dorsi dritti (forma F1 «Ritaglio»: colore pieno, angoli
 * di carta tagliata a mano, senza il segnalibro dello stato) su una mensola lunga colorata con
 * l'ombra d'inchiostro, i primi titoli e la barra di quanto è letto. Scaffale aperto: filtro per
 * stato, copertine come in Libreria (libreria.css), «Scaffali vicini». Vale solo dentro
 * #shelves-view (i dorsi .book-spine servono anche altrove). Caratteri e colori: ritagli.css.
 * Animazioni: motion.css (B2, i dorsi che scivolano; D7) e motion.js («Scaffali»). */

#shelves-view {
  position: relative;
  font-family: var(--rt-body);
  color: var(--rt-ink);
}

#shelves-view > :not(.sh-blobs) {
  position: relative;
  z-index: 1;
}

/* Forme colorate dietro, più lente della pagina (motion.js), come nella Libreria. */
.sh-blobs {
  --sh-rise: 200px;
  position: absolute;
  inset: calc(-1 * var(--sh-rise)) 0 0 0;
  z-index: 0;
  overflow: clip;
  pointer-events: none;
}

.sh-blob {
  position: absolute;
  will-change: translate;
}

.sh-blob path,
.sh-blob circle {
  fill: currentColor;
}

.sh-blob-1 {
  right: -150px;
  top: calc(var(--sh-rise) - 150px);
  width: 460px;
  color: var(--rt-blush);
}

.sh-blob-2 {
  right: 320px;
  top: calc(var(--sh-rise) - 40px);
  width: 64px;
  color: var(--rt-coral);
}

.sh-blob-3 {
  left: -130px;
  top: calc(var(--sh-rise) + 700px);
  width: 380px;
  color: var(--rt-sage);
}

#shelves-view a {
  color: inherit;
  text-decoration: none;
}

/* --- Titolo e bollino ---------------------------------------------------------- */
.sh-head {
  display: flex;
  align-items: flex-end;
  gap: 1rem;
  margin-bottom: 1.2rem;
}

#shelves-view h1 {
  margin: 0;
  font: 800 clamp(2.3rem, 5vw, 3.6rem) / 0.9 var(--rt-display);
  letter-spacing: -0.045em;
  text-transform: none;
  overflow-wrap: anywhere;
}

.sh-count {
  flex: none;
  display: grid;
  place-items: center;
  min-width: 56px;
  height: 56px;
  margin-bottom: 0.2rem;
  padding: 0 0.6rem;
  border-radius: 55% 45% 50% 50% / 50% 55% 45% 50%;
  background: var(--rt-coral);
  color: #161616;
  font: 800 1.25rem var(--rt-display);
  box-shadow: 3px 3px 0 var(--rt-ink);
  rotate: -6deg;
}

.sh-count:empty {
  display: none;
}

.sh-kicker {
  margin: 0 0 0.3rem;
  color: var(--muted);
  font: 700 0.75rem var(--rt-body);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

/* --- Raggruppa per: pillole con un'icona; la scelta piena d'inchiostro ----------------------- */
/* min-width: 0 perché un fieldset si allarga quanto il contenuto: sul telefono la fila di pillole
   (che scorre di lato) allargava la pagina. */
.sh-kinds {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  min-width: 0;
  margin: 0 0 0.7rem;
  padding: 0;
  border: 0;
}

.sh-kinds label,
.sh-toggle label {
  position: relative;
  cursor: pointer;
}

.sh-kinds input,
.sh-toggle input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.sh-kinds span {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.5rem 1rem;
  border: 1.5px solid var(--rt-ink);
  border-radius: 999px;
  font-weight: 600;
  transition: box-shadow 0.15s;
}

.sh-kinds i {
  font-style: normal;
  font-size: 0.95rem;
}

.sh-kinds input:checked + span {
  background: var(--rt-ink);
  color: var(--rt-bg);
  box-shadow: 3px 3px 0 var(--rt-accent);
}

.sh-kinds input:focus-visible + span,
.sh-toggle input:focus-visible + span {
  outline: 2px solid var(--rt-accent);
  outline-offset: 2px;
}

.sh-sub {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1rem;
  margin-bottom: 1.6rem;
}

/* «Principali / Tutti i generi»: un interruttore piccolo. */
.sh-toggle {
  display: inline-flex;
  min-width: 0;
  margin: 0;
  padding: 3px;
  border: 1.5px solid var(--rt-ink);
  border-radius: 999px;
}

.sh-toggle span {
  display: block;
  padding: 0.2rem 0.7rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
}

.sh-toggle input:checked + span {
  background: var(--rt-accent);
  color: var(--rt-accent-ink);
}

/* La spiegazione del raggruppamento, in una riga col segno ⓘ. */
.sh-note {
  display: flex;
  gap: 0.4rem;
  max-width: 75ch;
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.sh-note::before {
  content: "i";
  flex: none;
  display: grid;
  place-items: center;
  width: 1.3em;
  height: 1.3em;
  margin-top: 0.1em;
  border: 1.2px solid var(--muted);
  border-radius: 50%;
  font-size: 0.75rem;
}

.sh-note:empty {
  display: none;
}

/* --- Colpo d'occhio --------------------------------------------------------------- */
.sh-glance {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.8rem;
  margin: 0 0 1.8rem;
  padding: 0;
  list-style: none;
}

.sh-glance a {
  display: block;
  height: 100%;
  padding: 0.8rem 1rem;
  border-radius: 22px 18px 24px 20px;
  background: var(--rt-paper);
  transition:
    translate 0.15s,
    box-shadow 0.15s;
}

.sh-glance a:hover {
  translate: 0 -3px;
  box-shadow: 4px 4px 0 var(--rt-ink);
}

.sh-glance span {
  display: block;
  color: var(--muted);
  font-size: 0.75rem;
}

.sh-glance b {
  display: block;
  font: 800 1.15rem/1.15 var(--rt-display);
  overflow-wrap: anywhere;
}

.sh-glance small {
  color: var(--muted);
  font-size: 0.78rem;
}

/* --- Gli scaffali: una mensola lunga per riga ---------------------------------------- */
#shelves-view .shelves {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1.4rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

#shelves-view .shelves > li:nth-child(n) {
  --c: var(--rt-accent);
  padding: 0;
  border: 0;
}

/* Ogni scaffale il suo colore (mensola e bollino), a giro. */
#shelves-view .shelves > li:nth-child(6n + 2) {
  --c: var(--rt-coral);
}

#shelves-view .shelves > li:nth-child(6n + 3) {
  --c: #7d8c6e;
}

#shelves-view .shelves > li:nth-child(6n + 4) {
  --c: #8e5fd0;
}

#shelves-view .shelves > li:nth-child(6n + 5) {
  --c: var(--s-da_leggere);
}

#shelves-view .shelves > li:nth-child(6n) {
  --c: var(--rt-blush);
}

#shelves-view .shelf {
  display: block;
  height: auto;
  overflow: visible;
  padding: 1.1rem 1.3rem 1rem;
  border-radius: 30px 24px 34px 26px;
  background: var(--rt-paper);
  transition:
    translate 0.2s,
    box-shadow 0.2s;
}

@media (hover: hover) {
  #shelves-view .shelf:hover {
    translate: 0 -4px;
    box-shadow: 5px 5px 0 var(--rt-ink);
  }
}

#shelves-view .shelf:focus-visible {
  outline: 3px solid var(--rt-accent);
  outline-offset: 3px;
}

.sh-top {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  margin-bottom: 0.4rem;
}

.sh-title {
  min-width: 0;
  font: 800 1.6rem/1.05 var(--rt-display);
  letter-spacing: -0.02em;
  overflow-wrap: anywhere;
}

.sh-n {
  flex: none;
  display: inline-grid;
  place-items: center;
  min-width: 34px;
  height: 34px;
  padding: 0 0.4rem;
  border-radius: 50% 45% 55% 50%;
  background: var(--c);
  color: #161616;
  font: 800 0.95rem var(--rt-display);
  box-shadow: 2px 2px 0 var(--rt-ink);
}

.sh-go {
  margin-left: auto;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 700;
  white-space: nowrap;
}

/* I dorsi stanno dritti sulla mensola: tutti, e se non ci stanno la fila si scorre di lato. */
#shelves-view .shelf-row {
  height: 156px;
  padding: 0 6px;
  gap: 3px;
  background: none;
}

/* F1 · Ritaglio: colore pieno (della copertina, o dal titolo), angoli di carta tagliata a mano un
   po' diversi da un libro all'altro (a giro, con nth-child), niente segnalibro dello stato. */
#shelves-view .book-spine {
  border-radius: 6px 3px 2px 2px;
  background: var(--spine, hsl(var(--hue, 30) var(--sat, 40%) var(--light, 32%)));
  box-shadow: none;
  transition: translate 0.2s cubic-bezier(0.3, 1.4, 0.5, 1);
}

#shelves-view .book-spine:nth-child(3n + 2) {
  border-radius: 2px 7px 2px 2px;
}

#shelves-view .book-spine:nth-child(4n + 3) {
  border-radius: 8px 4px 2px 2px;
  clip-path: polygon(0 3px, 100% 0, 100% 100%, 0 100%);
}

#shelves-view .book-spine::after {
  content: none;
}

#shelves-view .book-spine-title {
  font-family: var(--rt-display);
}

#shelves-view .book-spine-author {
  font-family: var(--rt-body);
}

/* Col mouse si sfila il dorso sotto il cursore. */
@media (hover: hover) {
  #shelves-view .book-spine:hover {
    translate: 0 -10px;
  }
}

/* La mensola: una striscia ritagliata nel colore dello scaffale, con l'ombra d'inchiostro. */
#shelves-view .shelf-plank {
  display: block;
  height: 12px;
  margin: 0 -4px;
  border-radius: 3px 6px 4px 5px;
  background: var(--c);
  box-shadow: 0 4px 0 var(--rt-ink);
}

#shelves-view .shelf-caption {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.3rem 1rem;
  margin-top: 0.8rem;
  padding: 0;
  color: var(--muted);
  font-size: 0.85rem;
}

#shelves-view .shelf-caption em {
  font-style: normal;
}

/* Quanto dello scaffale è letto: una barra divisa per stato. */
.sh-mix {
  display: flex;
  flex: 0 1 220px;
  min-width: 120px;
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: color-mix(in srgb, var(--muted) 20%, transparent);
}

.sh-mix i {
  display: block;
  height: 100%;
}

/* --- Scaffale aperto ---------------------------------------------------------------- */
#shelves-view .back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  margin: 0 0 1.2rem;
  padding: 0.3rem 0.9rem 0.3rem 0.6rem;
  border: 2px solid var(--rt-ink);
  border-radius: 999px;
  color: var(--rt-ink);
  font-weight: 600;
  font-size: 0.9rem;
}

#shelves-view .back-link .icon {
  width: 1.1em;
  height: 1.1em;
}

/* Filtro per stato: pillole col pallino e il numero; la scelta piena d'inchiostro. */
.sh-status {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0 0 1.6rem;
}

.sh-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.85rem;
  border: 1.5px solid var(--rt-ink);
  border-radius: 999px;
  background: none;
  color: var(--rt-ink);
  font: 600 0.85rem var(--rt-body);
  cursor: pointer;
}

.sh-pill i {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--status-color);
}

.sh-pill small {
  color: var(--muted);
}

.sh-pill[aria-pressed="true"] {
  background: var(--rt-ink);
  color: var(--rt-bg);
}

.sh-pill[aria-pressed="true"] small {
  color: inherit;
  opacity: 0.7;
}

/* Scaffali vicini: pillole col colore del tipo di scaffale e il numero dei libri. */
.sh-near {
  margin-top: 2.2rem;
  padding: 1.2rem 1.3rem;
  border-radius: 30px 24px 34px 26px;
  background: var(--rt-paper);
}

.sh-near h2 {
  margin: 0 0 0.8rem;
  font: 800 1.3rem var(--rt-display);
  text-transform: none;
  letter-spacing: -0.02em;
}

.sh-near ul {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.sh-near li {
  --c: var(--rt-accent);
}

.sh-near .sh-near-autore {
  --c: var(--rt-coral);
}

.sh-near .sh-near-secolo {
  --c: #7d8c6e;
}

.sh-near .sh-near-nazionalita {
  --c: var(--s-da_leggere);
}

.sh-near .sh-near-editore {
  --c: #8e5fd0;
}

.sh-near a {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.45rem 0.9rem;
  border: 1.5px solid var(--rt-ink);
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.9rem;
}

.sh-near a i {
  width: 22px;
  height: 6px;
  border-radius: 3px;
  background: var(--c);
  box-shadow: 1px 1px 0 var(--rt-ink);
}

.sh-near small {
  color: var(--muted);
  font-weight: 400;
}

.sh-near p {
  margin: 0.7rem 0 0;
}

#shelves-view .empty {
  color: var(--muted);
}

/* --- Telefono -------------------------------------------------------------------- */
@media (max-width: 760px) {
  .sh-blob {
    scale: 0.6;
  }

  .sh-blob-2 {
    right: 30px;
    top: calc(var(--sh-rise) - 10px);
  }

  .sh-count {
    min-width: 46px;
    height: 46px;
    font-size: 1.05rem;
  }

  .sh-kinds {
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    padding-bottom: 4px;
  }

  .sh-kinds label {
    flex: none;
  }

  .sh-glance {
    gap: 0.4rem;
  }

  .sh-glance a {
    padding: 0.55rem 0.6rem;
    border-radius: 16px;
  }

  .sh-glance b {
    font-size: 0.9rem;
  }

  #shelves-view .shelves {
    gap: 1rem;
  }

  #shelves-view .shelf {
    padding: 0.9rem 1rem 0.8rem;
  }

  .sh-title {
    font-size: 1.3rem;
  }

  #shelves-view .shelf-row {
    height: 124px;
  }
}
