/**
 * Flipbook Catálogo — Malhas Wilson v2
 * CSS com efeito real de page-flip 3D + orelha nos cantos
 */

/* ── Utilitário ─────────────────────────────────────────────────────────────── */
.mwfb-noscroll { overflow: hidden; }
.hidden        { opacity: 0 !important; pointer-events: none !important; }

/* ── Botão Trigger ──────────────────────────────────────────────────────────── */
.mwfb-trigger {
  display: flex; align-items: center; gap: 16px;
  width: 100%; background: #fff;
  border: 1px solid #e0d8cc; border-radius: 10px;
  padding: 1.1rem 1.4rem; cursor: pointer; text-align: left;
  transition: border-color .2s, box-shadow .2s, background .2s;
  font-family: inherit;
}
.mwfb-trigger:hover {
  border-color: #b0a090; background: #faf8f5;
  box-shadow: 0 4px 16px rgba(80,60,40,.08);
}
.mwfb-trigger:focus-visible { outline: 2px solid #8a6a40; outline-offset: 3px; }

.mwfb-trigger-thumb {
  width: 56px; height: 70px; background: #e8dfd0;
  border-radius: 3px 5px 5px 3px; flex-shrink: 0; position: relative;
  display: flex; align-items: center; justify-content: center;
  box-shadow: -3px 3px 8px rgba(0,0,0,.12);
}
.mwfb-thumb-spine {
  position: absolute; left: 0; top: 0; bottom: 0; width: 7px;
  background: linear-gradient(to right, #b0956a, #d4b88a);
  border-radius: 3px 0 0 3px;
}
.mwfb-thumb-lines { display: flex; flex-direction: column; gap: 5px; margin-left: 10px; }
.mwfb-thumb-lines span { display: block; height: 5px; border-radius: 2px; background: #b8a888; }
.mwfb-thumb-lines span:nth-child(1) { width: 26px; }
.mwfb-thumb-lines span:nth-child(2) { width: 18px; }
.mwfb-thumb-lines span:nth-child(3) { width: 22px; }
.mwfb-thumb-lines span:nth-child(4) { width: 14px; }

.mwfb-trigger-text { flex: 1; min-width: 0; }
.mwfb-trigger-text strong { display: block; font-size: 15px; font-weight: 600; color: #2a1f14; margin-bottom: 3px; }
.mwfb-trigger-text span   { font-size: 13px; color: #7a6a5a; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }

.mwfb-trigger-badge {
  flex-shrink: 0; background: #f0ebe3; color: #6a5040;
  font-size: 12px; font-weight: 500; padding: 5px 12px;
  border-radius: 20px; white-space: nowrap; border: 1px solid #ddd3c4;
}

/* ── Overlay ────────────────────────────────────────────────────────────────── */
.mwfb-overlay {
  display: none; position: fixed; inset: 0; z-index: 1055;
  background: rgba(12,8,4,.9); align-items: center; justify-content: center;
  padding: 16px; backdrop-filter: blur(5px);
}
.mwfb-overlay.active { display: flex; animation: mwfbFadeIn .2s ease; }
@keyframes mwfbFadeIn { from { opacity:0 } to { opacity:1 } }

/* ── Modal ──────────────────────────────────────────────────────────────────── */
.mwfb-modal {
  background: #1a140c; border-radius: 12px; width: 100%;
  max-width: 940px; max-height: 96vh; display: flex; flex-direction: column;
  overflow: hidden; box-shadow: 0 32px 80px rgba(0,0,0,.75);
  animation: mwfbSlideUp .25s ease;
}
@keyframes mwfbSlideUp { from { opacity:0; transform:translateY(18px) } to { opacity:1; transform:none } }

/* ── Topbar ─────────────────────────────────────────────────────────────────── */
.mwfb-topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 11px 16px; border-bottom: 1px solid rgba(255,255,255,.07); flex-shrink: 0;
}
.mwfb-topbar-title { font-size: 13px; font-weight: 500; color: #d0c4b0; letter-spacing: .3px; }
.mwfb-topbar-actions { display: flex; gap: 8px; align-items: center; }
.mwfb-btn-icon {
  background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.12);
  color: #a09080; font-size: 12px; padding: 5px 12px; border-radius: 6px;
  cursor: pointer; text-decoration: none; transition: background .15s, color .15s;
  font-family: inherit; display: inline-flex; align-items: center; gap: 4px;
}
.mwfb-btn-icon:hover { background: rgba(255,255,255,.14); color: #e8ddd0; }
.mwfb-close { font-size: 15px; }

/* ── Área do livro ──────────────────────────────────────────────────────────── */
.mwfb-book-area {
  flex: 1; display: flex; align-items: center; justify-content: center;
  padding: 24px 16px; min-height: 0; overflow: hidden;
}

/* ── Loading ────────────────────────────────────────────────────────────────── */
.mwfb-loading { display: flex; flex-direction: column; align-items: center; gap: 14px; color: #7a6a5a; font-size: 14px; }
.mwfb-spinner {
  width: 34px; height: 34px; border: 3px solid rgba(255,255,255,.07);
  border-top-color: #b0956a; border-radius: 50%;
  animation: mwfbSpin .7s linear infinite;
}
@keyframes mwfbSpin { to { transform: rotate(360deg) } }
.mwfb-error { color: #c08070; text-align: center; line-height: 1.6; }

/* ── Scene (perspectiva 3D) ─────────────────────────────────────────────────── */
.mwfb-scene {
  display: flex; align-items: center; gap: 0;
  perspective: 2000px;
}

/* ── Setas laterais ─────────────────────────────────────────────────────────── */
.mwfb-arrow {
  background: rgba(255,255,255,.05); border: 1px solid rgba(255,255,255,.1);
  color: rgba(255,255,255,.35); font-size: 36px; line-height: 1;
  width: 42px; height: 64px; border-radius: 7px; cursor: pointer; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s, color .15s; margin: 0 10px;
}
.mwfb-arrow:hover { background: rgba(255,255,255,.12); color: rgba(255,255,255,.85); }
.mwfb-arrow:disabled { opacity: .25; cursor: default; }

/* ── Livro ──────────────────────────────────────────────────────────────────── */
.mwfb-book {
  position: relative;
  display: flex;
  box-shadow: -10px 10px 40px rgba(0,0,0,.55), 10px 10px 40px rgba(0,0,0,.55);
  border-radius: 3px 5px 5px 3px;
}

/* ── Páginas estáticas (fundo) ──────────────────────────────────────────────── */
.mwfb-static-page {
  position: relative; overflow: hidden;
  background: #f4f0ea; line-height: 0;
  flex-shrink: 0;
}
.mwfb-static-left  { border-radius: 3px 0 0 3px; border-right: 1px solid #ccc4b4; }
.mwfb-static-right { border-radius: 0 5px 5px 0; }

.mwfb-static-page canvas { display: block; max-width: 100%; height: auto; }

/* Sombra da lombada */
.mwfb-spine-shadow {
  position: absolute; top: 0; bottom: 0; width: 18px; z-index: 2; pointer-events: none;
}
.mwfb-spine-shadow.left  { right: 0; background: linear-gradient(to left,  rgba(0,0,0,.20), transparent); }
.mwfb-spine-shadow.right { left:  0; background: linear-gradient(to right, rgba(0,0,0,.20), transparent); }

/* ── Zonas de clique nos cantos ─────────────────────────────────────────────── */
.mwfb-corner {
  position: absolute; width: 52px; height: 52px; z-index: 10; cursor: pointer;
  transition: opacity .2s;
}
/* Indicador visual (triângulo no canto) */
.mwfb-corner::after {
  content: '';
  position: absolute;
  border-style: solid;
  transition: border-width .2s ease;
}

/* Canto superior direito */
.mwfb-corner-tr { top: 0; right: 0; }
.mwfb-corner-tr::after {
  top: 0; right: 0;
  border-width: 0 28px 28px 0;
  border-color: transparent rgba(176,149,106,.45) transparent transparent;
}
.mwfb-corner-tr:hover::after { border-width: 0 40px 40px 0; border-color: transparent rgba(176,149,106,.75) transparent transparent; }

/* Canto inferior direito */
.mwfb-corner-br { bottom: 0; right: 0; }
.mwfb-corner-br::after {
  bottom: 0; right: 0;
  border-width: 0 0 28px 28px;
  border-color: transparent transparent rgba(176,149,106,.45) transparent;
}
.mwfb-corner-br:hover::after { border-width: 0 0 40px 40px; border-color: transparent transparent rgba(176,149,106,.75) transparent; }

/* Canto superior esquerdo */
.mwfb-corner-tl { top: 0; left: 0; }
.mwfb-corner-tl::after {
  top: 0; left: 0;
  border-width: 28px 28px 0 0;
  border-color: rgba(176,149,106,.45) transparent transparent transparent;
}
.mwfb-corner-tl:hover::after { border-width: 40px 40px 0 0; border-color: rgba(176,149,106,.75) transparent transparent transparent; }

/* Canto inferior esquerdo */
.mwfb-corner-bl { bottom: 0; left: 0; }
.mwfb-corner-bl::after {
  bottom: 0; left: 0;
  border-width: 0 0 0 28px;
  border-width: 28px 0 0 28px;
  border-color: transparent transparent transparent rgba(176,149,106,.45);
}
.mwfb-corner-bl:hover::after { border-width: 40px 0 0 40px; border-color: transparent transparent transparent rgba(176,149,106,.75); }

/* ── Folha animada ──────────────────────────────────────────────────────────── */
.mwfb-flip-leaf {
  position: absolute;
  top: 0; bottom: 0;
  /* largura = metade do livro = uma página */
  width: 50%;
  transform-style: preserve-3d;
  /* z acima das páginas estáticas */
  z-index: 20;
  /* por padrão fica invisível / sem rotação */
  transform: none;
}

/* Frente e verso compartilham o mesmo espaço, verso girado 180° */
.mwfb-leaf-front,
.mwfb-leaf-back {
  position: absolute; inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  overflow: hidden; line-height: 0;
  background: #f4f0ea;
}
.mwfb-leaf-front { border-radius: 0; z-index: 1; }
.mwfb-leaf-back  {
  transform: rotateY(180deg);
  background: #f4f0ea;
}
.mwfb-leaf-front canvas,
.mwfb-leaf-back  canvas { display: block; width: 100%; height: 100%; object-fit: fill; }

/* Sombra que desce sobre a página durante a virada */
.mwfb-leaf-front::after {
  content: '';
  position: absolute; inset: 0; z-index: 5; pointer-events: none;
  background: linear-gradient(to right, rgba(0,0,0,.18), transparent 40%);
  opacity: 0; transition: opacity .3s;
}

/* ── Animações de virada ────────────────────────────────────────────────────── */

/* Virar para ESQUERDA (avançar) — leaf no lado direito, gira horário */
.mwfb-flip-leaf.flip-right {
  right: 0; left: auto;
  transform-origin: left center;
  animation: leafFlipRight .52s cubic-bezier(.645,.045,.355,1) forwards;
}
@keyframes leafFlipRight {
  0%   { transform: rotateY(0deg);     box-shadow: none; }
  30%  { box-shadow: -12px 0 30px rgba(0,0,0,.35); }
  100% { transform: rotateY(-180deg);  box-shadow: none; }
}

/* Virar para DIREITA (voltar) — leaf no lado esquerdo, gira anti-horário */
.mwfb-flip-leaf.flip-left {
  left: 0; right: auto;
  transform-origin: right center;
  animation: leafFlipLeft .52s cubic-bezier(.645,.045,.355,1) forwards;
}
@keyframes leafFlipLeft {
  0%   { transform: rotateY(0deg);    box-shadow: none; }
  30%  { box-shadow: 12px 0 30px rgba(0,0,0,.35); }
  100% { transform: rotateY(180deg);  box-shadow: none; }
}

/* ── Efeito de orelha (peel) nos cantos ─────────────────────────────────────── */
/* peel suave — apenas levanta um pouquinho o canto */
.mwfb-flip-leaf.peel-rt {
  right: 0; left: auto; transform-origin: left top;
  animation: peelRT .25s ease forwards;
}
@keyframes peelRT { to { transform: rotateY(-12deg) rotateX(5deg); } }

.mwfb-flip-leaf.peel-rb {
  right: 0; left: auto; transform-origin: left bottom;
  animation: peelRB .25s ease forwards;
}
@keyframes peelRB { to { transform: rotateY(-12deg) rotateX(-5deg); } }

.mwfb-flip-leaf.peel-lt {
  left: 0; right: auto; transform-origin: right top;
  animation: peelLT .25s ease forwards;
}
@keyframes peelLT { to { transform: rotateY(12deg) rotateX(5deg); } }

.mwfb-flip-leaf.peel-lb {
  left: 0; right: auto; transform-origin: right bottom;
  animation: peelLB .25s ease forwards;
}
@keyframes peelLB { to { transform: rotateY(12deg) rotateX(-5deg); } }

/* ── Controles inferiores ───────────────────────────────────────────────────── */
.mwfb-controls {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 11px 16px; border-top: 1px solid rgba(255,255,255,.07); flex-shrink: 0;
}
.mwfb-nav-btn {
  background: rgba(255,255,255,.07); border: 1px solid rgba(255,255,255,.13);
  color: #d0c4b0; font-size: 13px; font-weight: 500;
  padding: 8px 18px; border-radius: 7px; cursor: pointer;
  transition: background .15s, color .15s; white-space: nowrap;
  font-family: inherit; min-width: 110px;
}
.mwfb-nav-btn:hover:not(:disabled) { background: rgba(255,255,255,.15); color: #fff; }
.mwfb-nav-btn:disabled { opacity: .3; cursor: default; }

.mwfb-page-info { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; min-width: 0; }
#mwfbPageLabel  { font-size: 12px; color: #7a6a5a; white-space: nowrap; }

.mwfb-progress     { width: 100%; max-width: 200px; height: 3px; background: rgba(255,255,255,.08); border-radius: 3px; overflow: hidden; }
.mwfb-progress-bar { height: 100%; background: linear-gradient(to right, #b0956a, #d4aa70); border-radius: 3px; transition: width .3s ease; }

/* ── Responsivo ─────────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .mwfb-overlay { padding: 8px; }
  .mwfb-modal   { border-radius: 10px; max-height: 98vh; }
  /* Mobile: uma página por vez — esconde página esquerda */
  .mwfb-static-left { display: none !important; }
  .mwfb-flip-leaf   { width: 100% !important; }
  .mwfb-trigger-badge { display: none; }
  .mwfb-arrow { margin: 0 4px; width: 34px; font-size: 28px; }
  .mwfb-nav-btn { padding: 7px 12px; font-size: 12px; min-width: 90px; }
}
@media (max-width: 480px) {
  .mwfb-trigger { gap: 12px; padding: .9rem 1rem; }
  .mwfb-trigger-thumb { width: 44px; height: 56px; }
  .mwfb-book-area { padding: 12px 4px; }
}

/* ── Acessibilidade ─────────────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .mwfb-flip-leaf.flip-right,
  .mwfb-flip-leaf.flip-left,
  .mwfb-flip-leaf[class*="peel-"],
  .mwfb-overlay, .mwfb-modal { animation: none !important; transition: none !important; }
}
