/* PROTOTYPE JETABLE — liseuse de plaquettes A5 (façon Calaméo) */
@font-face {
  font-family: "Hanken Grotesk";
  src: url("assets/HankenGrotesk.ttf") format("truetype");
  font-weight: 100 900;
  font-display: block;
}
@font-face {
  font-family: "Inter";
  src: url("assets/InterVariable.woff2") format("woff2");
  font-weight: 100 900;
  font-display: block;
}

:root {
  --pw: 559px; /* A5 : 148 mm à 96 dpi */
  --ph: 794px; /* A5 : 210 mm à 96 dpi */
  --stage: #0b0c0d;
  --bar: #08090a;
  --ink: #f7f8f8;
  --muted: #8a8f98;
  --line: rgba(255, 255, 255, 0.08);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--stage);
  color: var(--ink);
  font-family: "Inter", system-ui, sans-serif;
  font-feature-settings: "cv01", "ss03";
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

/* ---------- Barre de la liseuse ---------- */
.fb-top {
  position: fixed; inset: 0 0 auto 0; height: 56px; z-index: 30;
  display: flex; align-items: center; gap: 16px; padding: 0 20px;
  background: var(--bar); border-bottom: 1px solid var(--line);
}
.fb-top .fb-brand { height: 22px; display: flex; align-items: center; }
.fb-top .fb-brand img { height: 100%; width: auto; display: block; }
.fb-top .fb-title { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fb-top .fb-spacer { flex: 1; }
.fb-back-link { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px 0 8px; border-radius: 999px; color: var(--ink); text-decoration: none; font: 510 13px/1 "Inter"; white-space: nowrap; border: 1px solid var(--line); }
.fb-back-link:hover { background: rgba(255,255,255,.06); }
.fb-back-link svg { width: 16px; height: 16px; }
a.fb-brand { color: inherit; }
.fb-count { white-space: nowrap; font: 510 13px/1 "Inter"; color: var(--muted); font-variant-numeric: tabular-nums; }
.fb-count b { color: var(--ink); font-weight: 510; }
.fb-btn {
  appearance: none; border: 0; background: transparent; color: var(--ink);
  width: 34px; height: 34px; border-radius: 8px; display: grid; place-items: center; cursor: pointer;
}
.fb-btn:hover { background: rgba(255,255,255,.06); }
.fb-btn:focus-visible, .fb-dl:focus-visible, .fb-nav:focus-visible { outline: 2px solid #75a9ff; outline-offset: 2px; }
.fb-btn svg { width: 18px; height: 18px; }
.fb-dl {
  display: inline-flex; align-items: center; gap: 8px; height: 32px; padding: 0 14px;
  border-radius: 999px; background: #e5e5e6; color: #08090a; text-decoration: none;
  font: 510 13px/1 "Inter"; white-space: nowrap;
}
.fb-dl:hover { background: #fff; }
.fb-dl svg { width: 14px; height: 14px; }

/* ---------- Scène et livre ---------- */
.fb-stage {
  position: fixed; inset: 96px 0 64px 0; display: grid; place-items: center;
  perspective: 2600px; user-select: none; -webkit-user-select: none;
}
.fb-scaler { position: absolute; left: 50%; top: 50%; transform-origin: center center; }
.fb-book {
  position: relative; height: var(--ph);
  transition: transform .7s cubic-bezier(.2,.7,.2,1);
  transform-style: preserve-3d;
}
.fb-book.is-spread { width: calc(var(--pw) * 2); }
.fb-book.is-single { width: var(--pw); }
.fb-book::before { /* ombre portée au sol */
  content: ""; position: absolute; left: 4%; right: 4%; bottom: -26px; height: 40px;
  background: radial-gradient(50% 50% at 50% 50%, rgba(0,0,0,.55), transparent 70%);
  filter: blur(6px); z-index: -1;
}
.fb-leaf {
  position: absolute; top: 0; width: var(--pw); height: var(--ph);
  transform-origin: left center; transform-style: preserve-3d;
  will-change: transform;
}
.fb-book.is-spread .fb-leaf { left: var(--pw); }
.fb-book.is-single .fb-leaf { left: 0; }
.fb-face {
  position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden;
  overflow: hidden; background: #fff;
}
.fb-face.fb-back { transform: rotateY(180deg); }
.fb-face.is-empty { background: transparent; }
/* ombrage dynamique pendant la tourne (piloté par --shade) */
.fb-face::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  opacity: var(--shade, 0);
}
.fb-front::after { background: linear-gradient(90deg, rgba(0,0,0,.0) 0%, rgba(0,0,0,.35) 70%, rgba(0,0,0,.55) 100%); }
.fb-back::after  { background: linear-gradient(270deg, rgba(0,0,0,.0) 0%, rgba(255,255,255,.10) 40%, rgba(0,0,0,.45) 100%); }
/* reliure : ombre de pli au centre de la double page */
.fb-book.is-spread .fb-front > .pg::before,
.fb-book.is-spread .fb-back > .pg::before {
  content: ""; position: absolute; top: 0; bottom: 0; width: 34px; z-index: 50; pointer-events: none;
}
.fb-book.is-spread .fb-front > .pg::before { left: 0; background: linear-gradient(90deg, rgba(0,0,0,.22), transparent); }
.fb-book.is-spread .fb-back > .pg::before { right: 0; background: linear-gradient(270deg, rgba(0,0,0,.22), transparent); }
.fb-book.is-spread .fb-leaf:first-child .fb-front > .pg::before,
.fb-book.is-spread .fb-leaf:last-child .fb-back > .pg::before { display: none; }

/* coins cliquables + indice de coin */
.fb-corner { position: absolute; bottom: 0; width: 70px; height: 70px; z-index: 60; cursor: grab; }
.fb-corner.r { right: 0; } .fb-corner.l { left: 0; }
.fb-corner::after {
  content: ""; position: absolute; bottom: 0; width: 0; height: 0; transition: width .25s, height .25s;
  background: linear-gradient(135deg, transparent 50%, rgba(0,0,0,.12) 50%, rgba(255,255,255,.9) 100%);
}
.fb-corner.r::after { right: 0; }
.fb-corner.l::after { left: 0; transform: scaleX(-1); }
.fb-corner:hover::after { width: 38px; height: 38px; }

.fb-nav {
  position: fixed; top: 50%; z-index: 25; width: 48px; height: 48px; border-radius: 999px; border: 0;
  background: rgba(255,255,255,.08); color: var(--ink); display: grid; place-items: center; cursor: pointer;
  transform: translateY(-50%); backdrop-filter: blur(8px);
}
.fb-nav:hover { background: rgba(255,255,255,.16); }
.fb-nav[disabled] { opacity: .25; cursor: default; }
.fb-nav.prev { left: 20px; } .fb-nav.next { right: 20px; }
.fb-nav svg { width: 20px; height: 20px; }

/* ---------- Vignettes ---------- */
.fb-thumbs {
  position: fixed; inset: 56px 0 0 0; z-index: 40; background: rgba(8,9,10,.94); backdrop-filter: blur(10px);
  display: flex; flex-wrap: wrap; gap: 28px; align-content: center; justify-content: center; padding: 32px;
}
.fb-thumbs[hidden] { display: none; }
.fb-thumb { appearance: none; border: 0; background: none; color: var(--muted); cursor: pointer; font: 510 12px "Inter"; }
.fb-thumb .t-frame { width: 140px; height: calc(140px * 794 / 559); overflow: hidden; border-radius: 3px; box-shadow: 0 10px 30px rgba(0,0,0,.5); margin-bottom: 8px; position: relative; }
.fb-thumb .t-frame > .pg { transform: scale(calc(140 / 559)); transform-origin: 0 0; position: absolute; top: 0; left: 0; }
.fb-thumb:hover .t-frame { outline: 2px solid #e5e5e6; }

/* ---------- Planche à plat / impression ---------- */
body.mode-flat, body.mode-print { overflow: auto; }
.flat-wrap { padding: 88px 24px 120px; display: flex; flex-wrap: wrap; gap: 24px; justify-content: center; }
.flat-wrap .flat-item { font: 510 12px "Inter"; color: var(--muted); }
.flat-wrap .flat-item .pg { box-shadow: 0 20px 50px rgba(0,0,0,.5); margin-top: 8px; }
body.mode-print { background: #888; }
body.mode-print .print-wrap { display: flex; flex-direction: column; gap: 0; align-items: center; }
@page { size: 148mm 210mm; margin: 0; }
@media print {
  body { background: none !important; }
  .proto-bar, .fb-top { display: none !important; }
  .print-wrap .pg:not(:last-child) { break-after: page; }
  .print-wrap .pg { width: 148mm; height: 210mm; contain: strict; }
  html, body { height: auto; }
}

/* ---------- Page A5 : socle commun ---------- */
.pg {
  width: var(--pw); height: var(--ph); position: relative; overflow: hidden;
  font-family: "Inter", system-ui, sans-serif; font-feature-settings: "cv01", "ss03";
  -webkit-print-color-adjust: exact; print-color-adjust: exact;
}

/* ---------- Barre du prototype ---------- */
.proto-bar {
  position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); z-index: 100;
  display: flex; align-items: center; gap: 6px; padding: 6px; border-radius: 999px;
  background: rgba(20,21,23,.92); border: 1px solid rgba(255,255,255,.12); backdrop-filter: blur(12px);
  box-shadow: 0 16px 40px rgba(0,0,0,.5); font: 510 12px/1 "Inter"; max-width: calc(100vw - 24px); overflow-x: auto;
}
.proto-bar .grp { display: flex; gap: 2px; padding: 0 4px; }
.proto-bar .grp + .grp { border-left: 1px solid rgba(255,255,255,.1); }
.proto-bar button {
  appearance: none; border: 0; background: transparent; color: #8a8f98; padding: 8px 11px; border-radius: 999px; cursor: pointer;
  font: inherit; white-space: nowrap;
}
.proto-bar button[aria-pressed="true"] { background: #e5e5e6; color: #08090a; }
.proto-bar .tag { color: #f97316; padding: 0 8px; white-space: nowrap; }
.proto-note {
  position: fixed; left: 50%; top: 64px; transform: translateX(-50%); z-index: 99; max-width: min(640px, calc(100vw - 24px));
  font: 400 12px/1.5 "Inter"; color: #d0d6e0; text-align: center; background: rgba(20,21,23,.85); padding: 8px 14px; border-radius: 10px;
}

@media (max-width: 760px) {
  .fb-top .fb-title { display: none; }
  .fb-nav { display: none; }
  .fb-dl span { display: none; }
  .fb-back-link span { display: none; }
  .fb-back-link { padding: 0 8px; }
  .proto-note { display: none; }
}
@media (max-width: 520px) {
  .fb-top { gap: 4px; padding: 0 10px; }
  .fb-top .fb-brand { height: 18px; margin-right: 4px; }
  .fb-dl { padding: 0 10px; height: 32px; }
}
@media (prefers-reduced-motion: reduce) {
  .fb-book { transition: none; }
}

/* ---------- Entrées animées des pages (web uniquement, une seule passe) ---------- */
.pg [data-r] { opacity: 0; transform: translateY(6px); transition: opacity 1s ease, transform 1.1s cubic-bezier(.2,.7,.2,1); transition-delay: var(--d, 0s); }
.pg.is-in [data-r] { opacity: 1; transform: none; }
.pg [data-draw] { stroke-dasharray: var(--len, 1200); stroke-dashoffset: var(--len, 1200); transition: stroke-dashoffset 1.8s cubic-bezier(.4,0,.2,1); transition-delay: var(--d, 0s); }
.pg.is-in [data-draw] { stroke-dashoffset: 0; }
.pg [data-grow] { transform: scaleX(0); transform-origin: left center; transition: transform 1.2s cubic-bezier(.2,.7,.2,1); transition-delay: var(--d, 0s); }
.pg.is-in [data-grow] { transform: none; }
.pg.is-static *, .pg.is-static *::before, .pg.is-static *::after { transition: none !important; animation: none !important; }
@media (prefers-reduced-motion: reduce) {
  .pg [data-r], .pg [data-draw], .pg [data-grow] { transition: none !important; opacity: 1; transform: none; filter: none; stroke-dashoffset: 0; }
}
.k-logo, .qf-logo { display: block; height: auto; }
body.mode-print .grain { display: none; }
