/* ===== Flash Book — stile pubblico ===== */
:root {
  --bg: #120f0d;
  --bg-2: #1d1814;
  --paper: #f2e7cf;
  --paper-edge: #e3d3ae;
  --ink: #1b1512;
  --ink-soft: #5b4a3d;
  --red: #b3261e;
  --red-dark: #7e1812;
  --gold: #d4a64a;
  --gold-soft: #b88a35;
  --leather: #3a1410;
  --leather-2: #24100c;
  --ok: #2f6b3a;
  --display: "Pirata One", "Cormorant Garamond", serif;
  --serif: "Cormorant Garamond", Georgia, serif;
  --mono: "Special Elite", "Courier New", monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background:
    radial-gradient(ellipse at 50% 40%, #2a221c 0%, var(--bg) 62%, #080605 100%);
  color: var(--paper);
  font-family: var(--serif);
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
button { font: inherit; color: inherit; }

/* Layout */
.stage {
  height: 100vh;
  height: 100svh;
  display: flex;
  flex-direction: column;
  padding: max(14px, env(safe-area-inset-top)) 12px max(10px, env(safe-area-inset-bottom));
}
.book-area {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.book {
  width: 100%;
  height: 100%;
  max-width: 1240px;
}
/* il wrapper della libreria usa un padding a proporzione fissa: lo adattiamo all'area disponibile */
.book .stf__wrapper { padding-bottom: 0 !important; height: 100%; }
.book { transition: transform .55s cubic-bezier(.3,.7,.2,1); }
.book.is-ready { animation: bookIn .7s ease backwards; }
@keyframes bookIn { from { opacity: 0; transform: translateY(14px) scale(.98); } to { opacity: 1; transform: none; } }

/* Pagine base */
.page { background: var(--paper); overflow: hidden; }
.page-cover { background: var(--leather); }

/* Carta */
.paper {
  position: relative;
  height: 100%;
  padding: 7% 8% 9%;
  color: var(--ink);
  background-color: var(--paper);
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .35 0 0 0 0 .25 0 0 0 0 .12 0 0 0 .09 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E"),
    radial-gradient(ellipse at 50% 45%, transparent 55%, rgba(120, 85, 40, .22) 100%);
  display: flex;
  flex-direction: column;
}
/* ombra della rilegatura */
.stf__item.--left .paper { box-shadow: inset -26px 0 34px -22px rgba(60, 35, 10, .45); }
.stf__item.--right .paper { box-shadow: inset 26px 0 34px -22px rgba(60, 35, 10, .45); }

.folio {
  position: absolute;
  bottom: 3.2%;
  left: 0; right: 0;
  text-align: center;
  font-family: var(--mono);
  font-size: clamp(10px, 1.4vmin, 13px);
  color: var(--ink-soft);
  letter-spacing: .1em;
}

/* Copertina */
.cover {
  height: 100%;
  padding: 6%;
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='turbulence' baseFrequency='.6' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 .35 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E"),
    radial-gradient(ellipse at 40% 35%, #5a2018 0%, var(--leather) 50%, var(--leather-2) 100%);
  color: var(--gold);
}
.stf__item.--right .cover { box-shadow: inset 14px 0 18px -10px rgba(0,0,0,.6); }
.stf__item.--left .cover { box-shadow: inset -14px 0 18px -10px rgba(0,0,0,.6); }
.cover-frame {
  position: relative;
  height: 100%;
  border: 2px solid var(--gold-soft);
  outline: 1px solid rgba(212, 166, 74, .45);
  outline-offset: -9px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 10% 8%;
  gap: 4%;
}
.corner {
  position: absolute;
  width: 11%;
  aspect-ratio: 1;
  border: 2px solid var(--gold);
  border-radius: 50%;
  background: radial-gradient(circle, var(--gold) 0 18%, transparent 20%);
}
.corner.tl { top: -2%; left: -2%; transform: translate(-30%, -30%); }
.corner.tr { top: -2%; right: -2%; transform: translate(30%, -30%); }
.corner.bl { bottom: -2%; left: -2%; transform: translate(-30%, 30%); }
.corner.br { bottom: -2%; right: -2%; transform: translate(30%, 30%); }
.cover-studio {
  margin: 0;
  font-family: var(--mono);
  text-transform: uppercase;
  letter-spacing: .28em;
  font-size: clamp(10px, 1.7vmin, 15px);
  color: #e9c98a;
}
.emblem { width: 38%; color: var(--gold); filter: drop-shadow(0 2px 0 rgba(0,0,0,.5)); }
.cover-title {
  margin: 0;
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(34px, 8.5vmin, 86px);
  line-height: .95;
  color: var(--gold);
  text-shadow: 0 2px 0 #1a0805, 0 0 18px rgba(212,166,74,.25);
}
.cover-artist {
  margin: 0;
  font-style: italic;
  font-size: clamp(14px, 2.6vmin, 24px);
  color: #e9c98a;
}
.cover-artist.small { font-size: clamp(12px, 2vmin, 18px); }
.cover-hint {
  margin: 6% 0 0;
  font-family: var(--mono);
  font-size: clamp(9px, 1.4vmin, 12px);
  letter-spacing: .12em;
  color: rgba(233, 201, 138, .6);
  animation: pulse 2.4s ease-in-out infinite;
}
@keyframes pulse { 50% { opacity: .35; } }

/* Intro / contatti */
.intro { justify-content: center; text-align: center; }
.kicker {
  margin: 0 0 4px;
  font-family: var(--mono);
  font-size: clamp(10px, 1.5vmin, 13px);
  letter-spacing: .2em;
  color: var(--red);
  text-transform: uppercase;
}
.intro h2 {
  margin: 0;
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(28px, 6vmin, 58px);
  line-height: 1;
  color: var(--ink);
}
.tagline { margin: 6px 0 0; font-style: italic; font-size: clamp(14px, 2.3vmin, 21px); color: var(--ink-soft); }
.rule {
  display: flex; align-items: center; gap: 12px;
  margin: 5% auto;
  width: 70%;
  color: var(--red);
  font-size: clamp(12px, 2vmin, 18px);
}
.rule::before, .rule::after { content: ""; flex: 1; height: 1px; background: currentColor; opacity: .5; }
.rule.big { margin: auto; font-size: clamp(20px, 4vmin, 36px); width: 50%; }
.blank { justify-content: center; }
.intro-text { font-size: clamp(14px, 2.25vmin, 20px); line-height: 1.45; }
.howto {
  list-style: none;
  counter-reset: s;
  padding: 0;
  margin: 6% auto 0;
  text-align: left;
  display: grid;
  gap: 8px;
  font-size: clamp(13px, 2vmin, 18px);
}
.howto li { counter-increment: s; display: flex; align-items: baseline; gap: 10px; }
.howto li::before {
  content: counter(s);
  flex: none;
  width: 1.7em; height: 1.7em;
  display: grid; place-items: center;
  border: 1.5px solid var(--red);
  border-radius: 50%;
  color: var(--red);
  font-family: var(--mono);
  font-size: .8em;
}
.count {
  margin: 7% 0 0;
  font-family: var(--mono);
  font-size: clamp(10px, 1.5vmin, 13px);
  letter-spacing: .12em;
  color: var(--ink-soft);
  text-transform: uppercase;
}
.contact-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.contact-list a {
  display: inline-block;
  color: var(--ink);
  text-decoration: none;
  font-size: clamp(15px, 2.5vmin, 22px);
  font-weight: 700;
  border-bottom: 1.5px solid var(--red);
  padding-bottom: 1px;
}
.address { margin: 6% 0 0; font-style: italic; font-size: clamp(13px, 2vmin, 18px); }
.fine { margin: 8% 0 0; font-size: clamp(12px, 1.8vmin, 16px); color: var(--ink-soft); }
.empty p { font-size: clamp(14px, 2.2vmin, 19px); }

/* Pagina con flash posizionati liberamente (stili in flash-item.css) */
.free-page { padding: 0; }
.free-page .fi:focus-visible { outline: 2px dashed #b3261e; outline-offset: 4px; }
.meta {
  margin: 2px 0 0;
  font-family: var(--mono);
  font-size: clamp(10px, 1.6vmin, 14px);
  color: var(--ink-soft);
  letter-spacing: .05em;
}
.badge {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: .08em;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 2px;
  border: 1.5px solid currentColor;
  white-space: nowrap;
}
.badge-available { color: #2f6b3a; }
.badge-reserved { color: var(--red); }
.badge-done { color: var(--ink-soft); }

/* Controlli */
.controls {
  flex: none;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  padding-top: 12px;
}
.ctl {
  width: 46px; height: 46px;
  display: grid; place-items: center;
  border-radius: 50%;
  border: 1px solid rgba(212, 166, 74, .45);
  background: rgba(255,255,255,.03);
  color: var(--gold);
  cursor: pointer;
  transition: background .2s, transform .15s, opacity .2s;
}
.ctl:hover { background: rgba(212, 166, 74, .14); }
.ctl:active { transform: scale(.94); }
.ctl:disabled { opacity: .3; cursor: default; }
.ctl svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.ctl.ctl-text { width: auto; padding: 0 18px; border-radius: 23px; font-family: var(--mono); font-size: 13px; letter-spacing: .1em; text-transform: uppercase; }
.pager {
  min-width: 110px;
  text-align: center;
  font-family: var(--mono);
  font-size: 13px;
  letter-spacing: .1em;
  color: #cbb48a;
}

/* Overlay */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(8, 6, 5, .88);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
  animation: fade .25s ease;
}
.overlay[hidden] { display: none; }
@keyframes fade { from { opacity: 0; } }
.close {
  position: absolute;
  top: 10px; right: 10px;
  width: 42px; height: 42px;
  border: 0;
  border-radius: 50%;
  background: rgba(0,0,0,.35);
  color: var(--paper);
  font-size: 30px;
  font-family: Arial, sans-serif;
  line-height: 1;
  cursor: pointer;
  z-index: 3;
}

/* Lightbox */
.lb {
  position: relative;
  width: min(920px, 100%);
  max-height: 100%;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  background: var(--paper);
  color: var(--ink);
  border-radius: 4px;
  overflow: hidden;
  box-shadow: 0 30px 80px rgba(0,0,0,.6);
}
.lb .close { color: var(--ink); background: rgba(242,231,207,.85); }
.lb-fig {
  margin: 0;
  padding: 28px 56px 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
  height: min(70vh, 720px);
  height: min(70svh, 720px);
}
.lb-fig img { max-width: 100%; max-height: 100%; object-fit: contain; mix-blend-mode: multiply; }
.lb-nav {
  position: absolute;
  top: 40%;
  width: 44px; height: 44px;
  border: 0; border-radius: 50%;
  background: rgba(27, 21, 18, .08);
  color: var(--ink);
  display: grid; place-items: center;
  cursor: pointer;
  z-index: 2;
}
.lb-nav:hover { background: rgba(27, 21, 18, .16); }
.lb-nav.prev { left: 8px; }
.lb-nav.next { right: 8px; }
.lb-nav svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.lb-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 24px 20px;
  border-top: 1px dashed rgba(91, 74, 61, .45);
}
.lb-info h3 { margin: 0; font-family: var(--display); font-weight: 400; font-size: 30px; line-height: 1; }
.lb-info .meta { font-size: 14px; }
.note { margin: 6px 0 0; font-size: 16px; font-style: italic; color: var(--ink-soft); }
.note:empty { display: none; }
.btn-book {
  flex: none;
  display: inline-block;
  padding: 13px 22px;
  background: var(--red);
  color: #fff;
  text-decoration: none;
  font-family: var(--mono);
  font-size: 14px;
  letter-spacing: .08em;
  text-transform: uppercase;
  border-radius: 3px;
  box-shadow: 0 3px 0 var(--red-dark);
  transition: transform .15s, box-shadow .15s;
}
.btn-book:hover { transform: translateY(-1px); box-shadow: 0 4px 0 var(--red-dark); }
.btn-book[hidden], #lbTaken[hidden] { display: none; }

/* Indice */
.index-panel {
  position: relative;
  width: min(1000px, 100%);
  max-height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--bg-2);
  border: 1px solid rgba(212,166,74,.25);
  border-radius: 6px;
  overflow: hidden;
}
.index-head { padding: 16px 64px 12px 22px; border-bottom: 1px solid rgba(212,166,74,.18); }
.index-head h2 { margin: 0; font-family: var(--display); font-weight: 400; font-size: 30px; color: var(--gold); }
.index-grid {
  overflow-y: auto;
  padding: 18px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 14px;
}
.thumb {
  padding: 0;
  border: 0;
  background: var(--paper);
  border-radius: 3px;
  overflow: hidden;
  cursor: pointer;
  text-align: left;
  transition: transform .15s, box-shadow .15s;
}
.thumb:hover { transform: translateY(-3px); box-shadow: 0 8px 22px rgba(0,0,0,.45); }
.thumb img { display: block; width: 100%; aspect-ratio: 1; object-fit: contain; padding: 10px; mix-blend-mode: multiply; }
.thumb span {
  display: block;
  padding: 6px 9px 8px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  border-top: 1px dashed rgba(91,74,61,.4);
}
.thumb.is-taken img { opacity: .45; filter: grayscale(.7); }

/* Mobile */
@media (max-width: 640px) {
  .stage { padding-left: 8px; padding-right: 8px; }
  .ctl { width: 44px; height: 44px; }
  .pager { min-width: 84px; font-size: 12px; }
  .ctl.ctl-text { padding: 0 14px; font-size: 12px; }
  .lb-fig { padding: 46px 40px 8px; height: 58svh; }
  .lb-nav { top: 30%; width: 36px; height: 36px; }
  .lb-nav.prev { left: 2px; }
  .lb-nav.next { right: 2px; }
  .lb-info { flex-direction: column; align-items: stretch; text-align: center; padding: 14px 16px 18px; }
  .lb-info h3 { font-size: 26px; }
  .btn-book { text-align: center; }
  .index-grid { grid-template-columns: repeat(2, 1fr); padding: 12px; gap: 10px; }
}
@media (max-height: 480px) and (orientation: landscape) {
  .controls { padding-top: 6px; }
  .ctl { width: 38px; height: 38px; }
  .lb { grid-template-columns: minmax(0, 1fr) 260px; grid-template-rows: 1fr; }
  .lb-fig { height: calc(100svh - 32px); padding: 20px 50px; }
  .lb-info { flex-direction: column; align-items: stretch; border-top: 0; border-left: 1px dashed rgba(91,74,61,.45); justify-content: center; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
