/* Groupe MN flipbook — UI en français (Québec)
   Couleurs: charbon #1A1A1A, grège #E5E0D8, or #C9A961 */
:root {
  --charbon: #1A1A1A;
  --charbon-2: #242424;
  --charbon-3: #2E2E2E;
  --grege: #E5E0D8;
  --grege-dim: #B9B3A8;
  --or: #C9A961;
  --or-hover: #E0C57A;
  --or-dim: rgba(201, 169, 97, 0.18);
  --or-line: rgba(201, 169, 97, 0.35);
  --danger-ink: #111;
  --shadow: 0 24px 64px rgba(0, 0, 0, 0.55);
  --header-h: 64px;
  --thumbs-h: 110px;
  --pager-h: 40px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

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

html, body {
  width: 100%;
  height: 100%;
  background: radial-gradient(ellipse at 50% 38%, #2a2a2a 0%, var(--charbon) 58%, #0d0d0d 100%);
  color: var(--grege);
  font-family: Montserrat, "Segoe UI", system-ui, sans-serif;
  font-weight: 400;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

body { display: flex; flex-direction: column; padding-top: var(--safe-t); }

/* —— En-tête —— */
.topbar {
  flex: 0 0 auto;
  height: calc(var(--header-h) + var(--safe-t));
  padding: 0 16px;
  padding-top: 0;
  display: flex;
  align-items: center;
  gap: 16px;
  border-bottom: 1px solid var(--or-line);
  background: linear-gradient(180deg, rgba(26,26,26,0.96), rgba(20,20,20,0.88));
  position: relative;
  z-index: 20;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: inherit;
  flex: 0 0 auto;
  min-width: 0;
}
.brand img {
  height: 48px;
  width: auto;
  display: block;
}
.brand .titles {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.brand .kicker {
  font-size: 9px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--or);
  font-weight: 500;
}
.brand h1 {
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.02em;
  color: var(--grege);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 42vw;
}

.toolbar {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.btn {
  appearance: none;
  border: 1px solid transparent;
  background: transparent;
  color: var(--grege);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 40px;
  min-width: 40px;
  padding: 0 10px;
  border-radius: 4px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-decoration: none;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
  user-select: none;
}
.btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.btn:hover, .btn:focus-visible {
  background: var(--or-dim);
  border-color: var(--or-line);
  color: #fff;
  outline: none;
}
.btn:active { transform: translateY(1px); }
.btn[disabled], .btn.is-disabled {
  opacity: 0.35;
  pointer-events: none;
}
.btn-gold {
  background: var(--or);
  color: var(--charbon);
  border-color: var(--or);
  font-weight: 600;
  padding: 0 14px;
}
.btn-gold:hover, .btn-gold:focus-visible {
  background: var(--or-hover);
  border-color: var(--or-hover);
  color: #111;
}
.btn .label { white-space: nowrap; }

.sep {
  width: 1px;
  height: 22px;
  background: var(--or-line);
  margin: 0 4px;
}

/* —— Scène du livre —— */
.stage-wrap {
  flex: 1 1 auto;
  display: flex;
  align-items: stretch;
  min-height: 0;
  position: relative;
}

.nav-arrow {
  flex: 0 0 56px;
  border: 0;
  background: transparent;
  color: var(--grege);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 5;
  transition: color 0.15s ease, background 0.15s ease;
}
.nav-arrow svg { width: 28px; height: 28px; stroke: currentColor; fill: none; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.nav-arrow:hover { color: var(--or); background: linear-gradient(90deg, transparent, var(--or-dim)); }
.nav-arrow.prev:hover { background: linear-gradient(-90deg, transparent, var(--or-dim)); }
.nav-arrow[disabled] { opacity: 0.25; pointer-events: none; }

.stage {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  position: relative;
  overflow: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px 0 8px;
}

.book-frame {
  position: relative;
  /* sized by JS */
  transform-origin: center center;
  transition: transform 0.7s ease;
}

.book-frame #book,
.book-frame .stf__parent {
  margin: 0 auto;
  filter: drop-shadow(0 18px 40px rgba(0,0,0,0.55)) drop-shadow(0 0 0.5px rgba(201,169,97,0.25));
}

/* —— Compteur —— */
.pager {
  flex: 0 0 var(--pager-h);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--grege-dim);
  font-weight: 500;
}
.pager strong { color: var(--grege); font-weight: 600; }

/* —— Vignettes —— */
.thumbs {
  flex: 0 0 auto;
  height: calc(var(--thumbs-h) + var(--safe-b));
  padding: 6px 16px calc(10px + var(--safe-b));
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
  overflow-y: hidden;
  border-top: 1px solid var(--or-line);
  background: rgba(0,0,0,0.28);
  scrollbar-width: thin;
  scrollbar-color: var(--or) transparent;
}
.thumbs::-webkit-scrollbar { height: 6px; }
.thumbs::-webkit-scrollbar-thumb { background: var(--or); border-radius: 3px; }

.thumb {
  flex: 0 0 auto;
  width: 56px;
  height: 76px;
  padding: 0;
  border: 1px solid rgba(255,255,255,0.12);
  background: #111;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  border-radius: 1px;
  transition: border-color 0.15s ease, transform 0.15s ease;
}
.thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.thumb .n {
  position: absolute;
  right: 2px;
  bottom: 2px;
  font-size: 9px;
  font-weight: 600;
  background: rgba(26,26,26,0.75);
  color: var(--grege);
  padding: 1px 4px;
  letter-spacing: 0.04em;
}
.thumb:hover { border-color: var(--or-hover); transform: translateY(-2px); }
.thumb.is-active {
  border-color: var(--or);
  box-shadow: 0 0 0 1px var(--or);
}
.thumb.is-active .n { background: var(--or); color: var(--charbon); }

/* —— Chargement —— */
.loader {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  background: radial-gradient(ellipse at 50% 38%, #2a2a2a 0%, var(--charbon) 58%, #0d0d0d 100%);
  z-index: 30;
  transition: opacity 0.4s ease;
}
.loader.is-done { opacity: 0; pointer-events: none; }
.loader img { height: 92px; width: auto; }
.loader p {
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--grege-dim);
}
.bar {
  width: 180px;
  height: 2px;
  background: rgba(201,169,97,0.2);
  overflow: hidden;
}
.bar > span {
  display: block;
  height: 100%;
  width: 0%;
  background: var(--or);
  transition: width 0.2s ease;
}

/* —— Zoom plein cadre (loupe) —— */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(10,10,10,0.94);
  z-index: 50;
  display: none;
  flex-direction: column;
}
.lightbox.is-open { display: flex; }
.lightbox-bar {
  flex: 0 0 56px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 0 12px;
  border-bottom: 1px solid var(--or-line);
}
.lightbox-stage {
  flex: 1 1 auto;
  overflow: hidden;
  cursor: grab;
  position: relative;
  touch-action: none;
}
.lightbox-stage.is-dragging { cursor: grabbing; }
.lightbox-inner {
  position: absolute;
  left: 50%;
  top: 50%;
  display: flex;
  gap: 0;
  transform-origin: center center;
  will-change: transform;
  box-shadow: var(--shadow);
}
.lightbox-inner img {
  display: block;
  max-height: none;
  background: #fff;
  user-select: none;
  -webkit-user-drag: none;
}

/* —— Plein écran : un peu plus d'espace pour le livre —— */
:fullscreen .topbar { background: #141414; }
:-webkit-full-screen .topbar { background: #141414; }

/* —— Mobile —— */
@media (max-width: 720px) {
  :root { --header-h: 56px; --thumbs-h: 92px; }
  .brand img { height: 40px; }
  .brand .titles { display: none; }
  .btn .label { display: none; }
  .btn-gold { padding: 0 10px; }
  .btn-gold .label { display: inline; }
  .nav-arrow { flex-basis: 36px; }
  .nav-arrow svg { width: 22px; height: 22px; }
  .stage { padding: 8px 0 4px; }
  .thumb { width: 44px; height: 62px; }
}

@media (max-width: 420px) {
  .sep { display: none; }
  .btn-gold .label { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .btn, .thumb, .loader, .bar > span { transition: none; }
}
