/* ============================================================
   Kind of Blue — Il Quaderno (sfogliatore)
   Sezione autonoma, agganciata ai token del design system.
   Tema carta/scuro automatico via variabili (--blue, --white, ...).
   ============================================================ */

.quaderno-section {
  position: relative;
  overflow: hidden;
}

/* Filo di stacco dall'archivio soprastante */
.quaderno-section::before {
  content: "";
  position: absolute;
  top: 0; left: 50%;
  transform: translateX(-50%);
  width: min(1200px, calc(100% - 48px));
  height: 1px;
  background: var(--faint);
}

/* --- Intro editoriale --- */
.quaderno-intro {
  max-width: 640px;
  margin: 0 0 clamp(32px, 4vw, 56px);
}
.quaderno-h2 {
  font-family: "Oswald", var(--sans);
  font-weight: 700;
  text-transform: uppercase;
  line-height: .98;
  letter-spacing: -.01em;
  font-size: clamp(30px, 4.4vw, 54px);
  margin: 14px 0 18px;
  color: var(--white);
}
.quaderno-lead {
  font-size: clamp(16px, 1.35vw, 19px);
  line-height: 1.6;
  color: var(--muted);
  max-width: 56ch;
}
.quaderno-lead em {
  font-family: var(--serif);
  font-style: italic;
  color: var(--white);
}

/* --- Viewer --- */
.quaderno-viewer {
  --qv-page-ratio: 210 / 265;      /* rapporto pagina rifilata */
  position: relative;
  width: 100%;
}

.qv-frame {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(8px, 2vw, 26px);
}

/* Frecce laterali */
.qv-nav {
  flex: 0 0 auto;
  width: clamp(38px, 3.4vw, 52px);
  height: clamp(38px, 3.4vw, 52px);
  border-radius: 50%;
  border: 1px solid var(--border-soft);
  background: transparent;
  color: var(--white);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background .3s var(--ease), border-color .3s var(--ease), opacity .3s var(--ease), transform .3s var(--ease);
  -webkit-tap-highlight-color: transparent;
}
.qv-nav svg { width: 42%; height: 42%; }
.qv-nav:hover:not(:disabled) { background: var(--cyan); border-color: var(--cyan); color: #fff; transform: scale(1.06); }
.qv-nav:disabled { opacity: .25; cursor: default; }

/* --- Libro --- */
.qv-book {
  position: relative;
  perspective: 2400px;
  width: min(100%, 1040px);
  aspect-ratio: calc(210 / 265 * 2);   /* due pagine affiancate */
  display: flex;
  transition: aspect-ratio .4s var(--ease);
  user-select: none;
}
.qv-book.is-single { aspect-ratio: 210 / 265; width: min(100%, 520px); }

/* Le due metà statiche (base) */
.qv-slot {
  position: relative;
  flex: 1 1 50%;
  min-width: 0;
  background: var(--blue-2);
  overflow: hidden;
}
.qv-book.is-single .qv-slot.qv-slot-right { display: none; }
.qv-slot img {
  display: block;
  width: 100%; height: 100%;
  object-fit: contain;
  background: #fff;
}
.qv-slot.is-blank { background: var(--blue-3); }
.qv-slot.is-blank img { opacity: 0; }

/* Ombra della piega centrale (spine) */
.qv-book::after {
  content: "";
  position: absolute;
  top: 0; bottom: 0; left: 50%;
  width: 12%;
  transform: translateX(-50%);
  pointer-events: none;
  background: linear-gradient(90deg,
    rgba(0,0,0,0) 0%,
    rgba(0,0,0,.12) 46%,
    rgba(0,0,0,.16) 50%,
    rgba(0,0,0,.12) 54%,
    rgba(0,0,0,0) 100%);
  opacity: .55;
  z-index: 5;
  transition: opacity .3s var(--ease);
}
.qv-book.is-single::after { opacity: 0; }

/* Ombra portante sotto al libro */
.qv-book::before {
  content: "";
  position: absolute;
  left: 4%; right: 4%; bottom: -3%;
  height: 8%;
  background: radial-gradient(ellipse at center, rgba(0,0,0,.22), rgba(0,0,0,0) 72%);
  filter: blur(3px);
  z-index: 0;
}

/* --- Foglio che si volta --- */
.qv-leaf {
  position: absolute;
  top: 0; bottom: 0;
  width: 50%;
  transform-style: preserve-3d;
  z-index: 20;
  will-change: transform;
}
.qv-leaf.qv-leaf-right { left: 50%; transform-origin: left center; }
.qv-leaf.qv-leaf-left  { left: 0;   transform-origin: right center; }
.qv-leaf.is-animating { transition: transform .62s var(--ease-soft); }

.qv-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  overflow: hidden;
  background: #fff;
}
.qv-face img { display: block; width: 100%; height: 100%; object-fit: contain; background: #fff; }
.qv-face.qv-back { transform: rotateY(180deg); }

/* Velo dinamico sulla pagina in movimento (dà volume alla piega) */
.qv-face::after {
  content: "";
  position: absolute; inset: 0;
  pointer-events: none;
  opacity: 0;
  transition: opacity .62s var(--ease-soft);
}
.qv-leaf.is-animating .qv-face-front::after { opacity: .0; }

/* --- Barra di controllo --- */
.qv-bar {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-top: clamp(20px, 2.4vw, 30px);
  flex-wrap: wrap;
}
.qv-counter {
  font-family: "Barlow Condensed", var(--sans);
  font-size: 15px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--muted-2);
  min-width: 92px;
}
.qv-counter strong { color: var(--white); font-weight: 500; }

/* Traccia di avanzamento (echo del "02/06" dell'hero) */
.qv-track {
  flex: 1 1 auto;
  height: 2px;
  min-width: 120px;
  background: var(--faint);
  position: relative;
  border-radius: 2px;
  cursor: pointer;
}
.qv-track-fill {
  position: absolute;
  left: 0; top: 0; height: 100%;
  background: var(--cyan);
  border-radius: 2px;
  transition: width .45s var(--ease);
}

.qv-actions { display: flex; align-items: center; gap: 10px; }
.qv-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: "Barlow Condensed", var(--sans);
  font-size: 14px;
  letter-spacing: .12em;
  text-transform: uppercase;
  padding: 10px 16px;
  border-radius: 999px;
  border: 1px solid var(--border-soft);
  background: transparent;
  color: var(--white);
  cursor: pointer;
  text-decoration: none;
  transition: background .3s var(--ease), border-color .3s var(--ease), color .3s var(--ease);
  -webkit-tap-highlight-color: transparent;
}
.qv-btn svg { width: 15px; height: 15px; }
.qv-btn:hover { border-color: var(--cyan); color: var(--cyan); }
.qv-btn--pdf { background: var(--cyan); border-color: var(--cyan); color: #fff; }
.qv-btn--pdf:hover { background: transparent; color: var(--cyan); }
.qv-btn-size { opacity: .7; letter-spacing: .06em; }

/* Suggerimento sfoglio */
.qv-hint {
  text-align: center;
  margin-top: 14px;
  font-family: "Barlow Condensed", var(--sans);
  font-size: 13px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted-2);
  transition: opacity .4s var(--ease);
}

/* --- Fullscreen --- */
.quaderno-viewer:fullscreen,
.quaderno-viewer:-webkit-full-screen {
  background: var(--blue);
  padding: clamp(20px, 4vw, 60px);
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.quaderno-viewer:fullscreen .qv-book { width: min(100%, 1200px); margin-inline: auto; }

/* --- Mobile --- */
@media (max-width: 767px) {
  .qv-nav { display: none; }           /* su mobile si scorre a swipe/tap */
  .qv-book { width: min(100%, 460px); margin-inline: auto; }
  .qv-hint { display: block; }
}
@media (min-width: 768px) {
  .qv-hint.is-desktop-hide { display: none; }
}

/* Rispetto reduce-motion: nessuna piega, cambio istantaneo */
@media (prefers-reduced-motion: reduce) {
  .qv-leaf.is-animating { transition: none; }
  .qv-track-fill { transition: none; }
}

/* ============================================================
   Richiamo dalla home — teaser del Quaderno
   ============================================================ */
.quaderno-teaser-inner {
  display: grid;
  grid-template-columns: 1.1fr .9fr;
  align-items: center;
  gap: clamp(32px, 6vw, 80px);
}
.quaderno-teaser-h2 {
  font-family: "Oswald", var(--sans);
  font-weight: 700;
  text-transform: uppercase;
  line-height: .98;
  letter-spacing: -.01em;
  font-size: clamp(34px, 5vw, 64px);
  margin: 14px 0 20px;
  color: var(--white);
}
.quaderno-teaser-lead {
  font-size: clamp(16px, 1.35vw, 19px);
  line-height: 1.6;
  color: var(--muted);
  max-width: 46ch;
  margin-bottom: 30px;
}
.quaderno-teaser-cta {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  font-family: "Barlow Condensed", var(--sans);
  font-size: 16px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--white);
  text-decoration: none;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border-soft);
  transition: color .3s var(--ease), border-color .3s var(--ease), gap .3s var(--ease);
}
.quaderno-teaser-cta svg { width: 22px; height: 12px; }
.quaderno-teaser-cta:hover { color: var(--cyan); border-color: var(--cyan); gap: 18px; }

/* Pila di pagine "a ventaglio" */
.quaderno-teaser-stack {
  position: relative;
  display: block;
  aspect-ratio: 210 / 265;
  width: min(100%, 380px);
  margin-inline: auto;
  perspective: 1400px;
}
.qt-page {
  position: absolute;
  inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  background: #fff;
  border-radius: 2px;
  box-shadow: 0 18px 50px rgba(0,0,0,.28);
  transition: transform .5s var(--ease), box-shadow .5s var(--ease);
  transform-origin: bottom left;
  backface-visibility: hidden;
}
.qt-page-3 { transform: rotate(-13deg) translate(-12%, 1%); }
.qt-page-2 { transform: rotate(-6.5deg) translate(-6%, .5%); }
.qt-page-1 { transform: rotate(0deg); }
.quaderno-teaser-stack:hover .qt-page-3 { transform: rotate(-19deg) translate(-20%, 2%); }
.quaderno-teaser-stack:hover .qt-page-2 { transform: rotate(-10.5deg) translate(-10%, 1%); }
.quaderno-teaser-stack:hover .qt-page-1 { transform: rotate(3deg) translateY(-3%); box-shadow: 0 30px 66px rgba(0,0,0,.36); }

@media (max-width: 767px) {
  .quaderno-teaser-inner { grid-template-columns: 1fr; gap: 40px; }
  .quaderno-teaser-stack { width: min(72%, 300px); order: -1; }
}
@media (prefers-reduced-motion: reduce) {
  .qt-page, .quaderno-teaser-cta { transition: none; }
}

/* ============================================================
   Home — il teaser risale leggermente sul fondo dell'hero:
   sale SOLO la pila di pagine (a destra), il testo resta sotto,
   libero dalla scritta/linea inferiore dell'hero.
   ============================================================ */
.quaderno-teaser{ position:relative; z-index:6; margin-top:clamp(-70px,-4vw,-40px); }
.quaderno-teaser .container{ position:relative; z-index:2; }
.quaderno-teaser-stack{ margin-top:clamp(-230px,-17vw,-140px); }
@media (max-width:767px){
  .quaderno-teaser{ margin-top:0; }
  .quaderno-teaser-stack{ margin-top:0; }
}
