/* Cartilhas Cardoso Advogados: flipbook, hub e leitor */

/* ---------- flipbook (página individual e leitor) ---------- */
.cartilha-stage { background: linear-gradient(180deg, var(--cream-dark, #F2EDE4) 0%, var(--cream, #FBF9F6) 100%); padding: 48px 0 56px; }
.flip-wrap { max-width: 900px; margin: 0 auto; }
.flipbook { margin: 0 auto; position: relative; transition: transform .6s ease; }
.flipbook .page, .leitor-book .page { background: #fff; overflow: hidden; }
.flipbook .page img, .leitor-book .page img { width: 100%; height: 100%; display: block; object-fit: contain; user-select: none; -webkit-user-drag: none; }
.stf__parent { margin: 0 auto; }
.stf__block { filter: drop-shadow(0 18px 30px rgba(60, 20, 20, .18)); }
.flip-fallback { display: block; width: min(420px, 86vw); height: auto; margin: 0 auto; box-shadow: 0 18px 40px rgba(60, 20, 20, .2); border-radius: 2px; }
.flipbook.is-ready .flip-fallback { display: none; }

.flip-controls { display: flex; align-items: center; justify-content: center; gap: 18px; margin-top: 26px; }
.flip-btn { width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--wine); background: #fff; color: var(--wine); font-size: 1.6rem; line-height: 1; cursor: pointer; transition: background .2s, color .2s; }
.flip-btn:hover, .flip-btn:focus-visible { background: var(--wine); color: #fff; }
.flip-btn:disabled { opacity: .35; cursor: default; background: #fff; color: var(--wine); }
.flip-count { min-width: 140px; text-align: center; font-size: .95rem; color: var(--gray-dark); font-variant-numeric: tabular-nums; }
.flip-hint { text-align: center; font-size: .85rem; color: var(--gray-dark); opacity: .75; margin: 10px 0 0; }
.flip-actions { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; margin-top: 26px; }

/* ---------- capa em formato de livro ---------- */
.book-cover { position: relative; display: block; width: 100%; aspect-ratio: 840 / 1190; perspective: 1400px; border: 0; padding: 0; background: none; cursor: pointer; }
.book-cover-inner { position: absolute; inset: 0; transform-origin: left center; transform: rotateY(-14deg); transition: transform .5s cubic-bezier(.2,.7,.2,1), box-shadow .5s; box-shadow: 14px 18px 34px rgba(60, 20, 20, .22), 2px 2px 6px rgba(0,0,0,.08); border-radius: 2px 5px 5px 2px; overflow: hidden; background: #fff; }
.book-cover-inner img { width: 100%; height: 100%; display: block; object-fit: cover; }
.book-cover-inner::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 7%; background: linear-gradient(90deg, rgba(0,0,0,.22), rgba(255,255,255,.12) 55%, rgba(0,0,0,0)); z-index: 1; pointer-events: none; }
.book-cover-inner::after { content: ""; position: absolute; inset: 0; background: linear-gradient(115deg, rgba(255,255,255,.18) 0%, rgba(255,255,255,0) 40%); pointer-events: none; }
.book-cover:hover .book-cover-inner, .book-cover:focus-visible .book-cover-inner { transform: rotateY(-4deg) translateY(-4px); box-shadow: 18px 26px 44px rgba(60, 20, 20, .26), 2px 2px 6px rgba(0,0,0,.08); }
.book-cover:focus-visible { outline: 2px solid var(--wine); outline-offset: 6px; }
.book-cover-tag { position: absolute; left: 50%; bottom: 12px; transform: translateX(-50%) translateY(6px); background: rgba(255,255,255,.95); color: var(--wine); font-size: .8rem; font-weight: 600; padding: 7px 14px; border-radius: 999px; opacity: 0; transition: opacity .3s, transform .3s; z-index: 2; white-space: nowrap; box-shadow: 0 6px 16px rgba(0,0,0,.12); }
.book-cover:hover .book-cover-tag, .book-cover:focus-visible .book-cover-tag { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- hub ---------- */
.cartilhas-shelf { background: linear-gradient(180deg, var(--cream-dark, #F2EDE4) 0%, var(--cream, #FBF9F6) 100%); padding: 56px 0 72px; }
.cartilha-filtros { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin: 0 auto 44px; }
.cartilha-filtro { border: 1px solid var(--gray-light); background: #fff; color: var(--gray-dark); padding: 8px 18px; border-radius: 999px; font: inherit; font-size: .9rem; cursor: pointer; transition: all .2s; }
.cartilha-filtro:hover { border-color: var(--wine); color: var(--wine); }
.cartilha-filtro[aria-pressed="true"] { background: var(--wine); border-color: var(--wine); color: #fff; }
.cartilhas-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 250px)); justify-content: center; gap: 56px 36px; }
.cartilha-card { display: flex; flex-direction: column; }
.cartilha-card[hidden] { display: none; }
.cartilha-card .book-cover { margin-bottom: 26px; }
.cartilha-ramo { font-size: .72rem; letter-spacing: .14em; text-transform: uppercase; color: var(--wine); font-weight: 600; margin-bottom: 6px; }
.cartilha-card h2 { font-family: var(--font-serif); font-size: 1.65rem; line-height: 1.15; color: var(--gray-dark); margin: 0 0 8px; }
.cartilha-card h2 a { color: inherit; text-decoration: none; }
.cartilha-card h2 a:hover { color: var(--wine); }
.cartilha-card p { font-size: .95rem; line-height: 1.55; color: var(--gray-dark); margin: 0 0 10px; }
.cartilha-meta { font-size: .8rem; color: var(--gray-dark); opacity: .7; margin-bottom: 16px; }
.cartilha-acoes { display: flex; gap: 10px; flex-wrap: wrap; margin-top: auto; }

.cartilhas-sobre { display: grid; grid-template-columns: repeat(3, 1fr); gap: 28px; }
.cartilhas-sobre div { border-top: 2px solid var(--wine); padding-top: 16px; }
.cartilhas-sobre h3 { font-family: var(--font-serif); font-size: 1.35rem; color: var(--gray-dark); margin: 0 0 8px; }
.cartilhas-sobre p { font-size: .98rem; line-height: 1.6; color: var(--gray-dark); margin: 0; }

/* ---------- leitor em tela cheia ---------- */
html.leitor-aberto { overflow: hidden; }
.leitor { width: 100vw; height: 100vh; max-width: none; max-height: none; margin: 0; padding: 0; border: 0; background: rgba(26, 12, 12, .94); color: #fff; }
.leitor[open] { display: flex; flex-direction: column; }
.leitor::backdrop { background: rgba(26, 12, 12, .94); }
.leitor-top { display: flex; align-items: center; gap: 16px; padding: 14px 22px; border-bottom: 1px solid rgba(255,255,255,.1); }
.leitor-info { flex: 1; min-width: 0; }
.leitor-area { font-size: .7rem; letter-spacing: .14em; text-transform: uppercase; color: #e7b9b0; }
.leitor-title { font-family: var(--font-serif); font-size: 1.35rem; line-height: 1.2; margin: 2px 0 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.leitor-links { display: flex; gap: 10px; flex-wrap: wrap; }
.leitor-links a { color: #fff; font-size: .85rem; border: 1px solid rgba(255,255,255,.35); padding: 7px 14px; border-radius: 999px; text-decoration: none; transition: background .2s, border-color .2s; white-space: nowrap; }
.leitor-links a:hover { background: rgba(255,255,255,.12); border-color: #fff; }
.leitor-links a.leitor-wa { background: var(--wine); border-color: var(--wine); }
.leitor-close { width: 42px; height: 42px; border-radius: 50%; border: 1px solid rgba(255,255,255,.35); background: transparent; color: #fff; font-size: 1.5rem; line-height: 1; cursor: pointer; flex: none; }
.leitor-close:hover, .leitor-close:focus-visible { background: #fff; color: var(--wine); }
.leitor-main { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; padding: 18px 16px 8px; }
.leitor-book { width: min(94vw, calc((100vh - 190px) / 1.4167 * 2)); transition: transform .6s ease; }
.leitor-bottom { display: flex; align-items: center; justify-content: center; gap: 18px; padding: 10px 0 18px; }
.leitor .flip-btn { background: transparent; color: #fff; border-color: rgba(255,255,255,.5); }
.leitor .flip-btn:hover, .leitor .flip-btn:focus-visible { background: #fff; color: var(--wine); }
.leitor .flip-btn:disabled { background: transparent; color: #fff; opacity: .25; }
.leitor .flip-count { color: rgba(255,255,255,.85); }
.leitor .stf__block { filter: drop-shadow(0 24px 40px rgba(0,0,0,.45)); }

@media (max-width: 860px) {
  .cartilhas-sobre { grid-template-columns: 1fr; }
  .leitor-links a:not(.leitor-wa) { display: none; }
}
@media (max-width: 640px) {
  .cartilha-stage { padding: 28px 0 40px; }
  .flip-hint { display: none; }
  .cartilhas-grid { grid-template-columns: minmax(0, 300px); gap: 48px; }
  .leitor-top { padding: 10px 12px; gap: 10px; }
  .leitor-area { display: none; }
  .leitor-title { font-size: 1.05rem; white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
  .leitor-links a.leitor-wa { padding: 7px 12px; font-size: .8rem; }
  .leitor-links a.leitor-wa .wa-longo { display: none; }
  .leitor-book { width: min(92vw, calc((100vh - 170px) / 1.4167)); }
}
@media (prefers-reduced-motion: reduce) {
  .book-cover-inner, .flipbook, .leitor-book { transition: none; }
}
.leitor-links a.leitor-wa .wa-curto { display: none; }
@media (max-width: 640px) { .leitor-links a.leitor-wa .wa-curto { display: inline; } }
