/* ==========================================================================
   SÁCH LẬT HEBE — giao diện đọc
   Palette web HEBE (nguồn: wiki/1-thuong-hieu/Nhận diện thương hiệu HEBE Academy.md)
   Kem #fbf6ec · card #fff viền #e9ddc7 · vàng chủ đạo #b0894f · vàng đậm #8f6d38
   tiêu đề #2c2620 · body #4a4238 · chữ phụ #8a7d6a · divider #efe7d5. KHÔNG dùng hồng.
   ========================================================================== */
:root {
  --sl-cream: #fbf6ec;
  --sl-cream-2: #f2e7d2;
  --sl-card: #ffffff;
  --sl-line: #e9ddc7;
  --sl-divider: #efe7d5;
  --sl-gold: #b0894f;
  --sl-gold-dark: #8f6d38;
  --sl-head: #2c2620;
  --sl-body: #4a4238;
  --sl-muted: #8a7d6a;
  --sl-shadow: 0 18px 46px rgba(44, 38, 32, .22);
  --sl-radius: 14px;
  --sl-bar-h: 62px;
  --sl-ui: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --sl-serif: Cambria, "Iowan Old Style", "Palatino Linotype", "Times New Roman", serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: var(--sl-ui);
  color: var(--sl-body);
  background:
    radial-gradient(1200px 700px at 50% -10%, #fffdf8 0%, rgba(255,253,248,0) 60%),
    linear-gradient(180deg, var(--sl-cream) 0%, var(--sl-cream-2) 100%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

.sl-app { display: flex; flex-direction: column; min-height: 100%; min-height: 100dvh; }

/* ---------- Đầu trang ---------- */
.sl-top {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px 8px; flex: 0 0 auto;
}
.sl-top img.sl-logo { width: 42px; height: 42px; border-radius: 50%; flex: 0 0 auto; box-shadow: 0 2px 8px rgba(44,38,32,.12); }
.sl-titles { min-width: 0; }
.sl-titles h1 {
  margin: 0; font-family: var(--sl-serif); font-weight: 700;
  font-size: clamp(15px, 2.4vw, 20px); line-height: 1.25; color: var(--sl-head);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.sl-titles p {
  margin: 2px 0 0; font-size: 12px; color: var(--sl-muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ---------- Sân khấu sách ---------- */
.sl-stage {
  flex: 1 1 auto; position: relative;
  display: flex; align-items: center; justify-content: center;
  padding: 4px 12px 8px; min-height: 0;
}
#sl-book { margin: 0 auto; touch-action: pan-y; transition: transform .34s cubic-bezier(.4,.1,.2,1); }
#sl-book.--lone-right { transform: translateX(-25%); }   /* bìa trước đứng một mình → kéo vào giữa */
#sl-book.--lone-left  { transform: translateX(25%); }    /* bìa sau đứng một mình → kéo vào giữa */
#sl-book .sl-page {
  background: var(--sl-card);
  overflow: hidden;
  box-shadow: 0 12px 30px rgba(44, 38, 32, .15), inset 0 0 0 1px rgba(233, 221, 199, .85);
}
/* Bóng gáy sách: trang trái tối dần về mép phải, trang phải tối dần về mép trái.
   (--left/--right là class do StPageFlip tự gắn) */
#sl-book .sl-page.--left {
  box-shadow: 0 12px 30px rgba(44, 38, 32, .15), inset 0 0 0 1px rgba(233, 221, 199, .85),
              inset -16px 0 26px -14px rgba(44, 38, 32, .30);
}
#sl-book .sl-page.--right {
  box-shadow: 0 12px 30px rgba(44, 38, 32, .15), inset 0 0 0 1px rgba(233, 221, 199, .85),
              inset 16px 0 26px -14px rgba(44, 38, 32, .30);
}
#sl-book.--single .sl-page.--left, #sl-book.--single .sl-page.--right {
  box-shadow: 0 12px 30px rgba(44, 38, 32, .15), inset 0 0 0 1px rgba(233, 221, 199, .85);
}
#sl-book .sl-page img { width: 100%; height: 100%; object-fit: contain; display: block; background: #fff; }
#sl-book .sl-page.--loading::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(100deg, #f7f1e5 30%, #fffdf7 50%, #f7f1e5 70%);
  background-size: 300% 100%; animation: sl-sheen 1.3s linear infinite;
}
@keyframes sl-sheen { to { background-position: -200% 0; } }
.stf__parent { margin: 0 auto; }

/* mũi tên hai bên (chỉ desktop) */
.sl-side {
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 46px; height: 46px; border-radius: 50%;
  display: none; align-items: center; justify-content: center;
  background: rgba(255,255,255,.86); border: 1px solid var(--sl-line);
  color: var(--sl-gold-dark); cursor: pointer; z-index: 5;
  box-shadow: 0 6px 18px rgba(44,38,32,.14); transition: .16s;
}
.sl-side:hover { background: var(--sl-gold); color: #fff; border-color: var(--sl-gold); }
.sl-side:disabled { opacity: .3; cursor: default; }
.sl-side.--prev { left: 10px; } .sl-side.--next { right: 10px; }
@media (min-width: 900px) { .sl-side { display: flex; } }

/* ---------- Thanh điều khiển ---------- */
.sl-bar {
  flex: 0 0 auto; display: flex; align-items: center; justify-content: center;
  gap: 8px; flex-wrap: wrap; padding: 8px 12px 10px;
}
.sl-btn {
  display: inline-flex; align-items: center; gap: 7px;
  height: 38px; padding: 0 14px; border-radius: 999px;
  background: var(--sl-card); border: 1px solid var(--sl-line);
  color: var(--sl-gold-dark); font-size: 13px; font-weight: 600; font-family: inherit;
  cursor: pointer; transition: .16s; white-space: nowrap; user-select: none;
}
.sl-btn:hover { background: var(--sl-gold); border-color: var(--sl-gold); color: #fff; }
.sl-btn:active { transform: scale(.97); }
.sl-btn:disabled { opacity: .38; cursor: default; transform: none; background: var(--sl-card); border-color: var(--sl-line); color: var(--sl-muted); }
.sl-btn.--solid { background: var(--sl-gold); border-color: var(--sl-gold); color: #fff; }
.sl-btn.--solid:hover { background: var(--sl-gold-dark); border-color: var(--sl-gold-dark); }
.sl-btn.--icon { padding: 0; width: 38px; justify-content: center; }
.sl-btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.sl-sep { width: 1px; height: 24px; background: var(--sl-divider); margin: 0 2px; }

.sl-count {
  display: inline-flex; align-items: center; gap: 6px;
  height: 38px; padding: 0 12px; border-radius: 999px;
  background: rgba(255,255,255,.7); border: 1px solid var(--sl-line);
  font-size: 13px; color: var(--sl-body); font-variant-numeric: tabular-nums;
}
.sl-count input {
  width: 42px; height: 26px; text-align: center; font: inherit; color: var(--sl-head);
  border: 1px solid var(--sl-line); border-radius: 7px; background: #fff;
}
.sl-count input::-webkit-outer-spin-button, .sl-count input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

/* ---------- Dải trang nhỏ ---------- */
.sl-thumbs {
  flex: 0 0 auto; max-height: 0; overflow: hidden;
  transition: max-height .28s ease; background: rgba(255,255,255,.62);
  border-top: 1px solid var(--sl-divider);
}
.sl-thumbs.--open { max-height: 190px; }
.sl-thumbs-inner { display: flex; gap: 10px; padding: 12px; overflow-x: auto; scrollbar-width: thin; }
.sl-thumb {
  flex: 0 0 auto; width: 92px; cursor: pointer; border: 0; background: none; padding: 0;
  font: inherit; color: var(--sl-muted); text-align: center;
}
.sl-thumb img {
  width: 92px; display: block; border-radius: 6px; background: #fff;
  border: 2px solid transparent; box-shadow: 0 3px 10px rgba(44,38,32,.13); transition: .16s;
}
.sl-thumb span { display: block; font-size: 11px; margin-top: 4px; font-variant-numeric: tabular-nums; }
.sl-thumb:hover img { border-color: var(--sl-gold); }
.sl-thumb.--on img { border-color: var(--sl-gold-dark); }
.sl-thumb.--on span { color: var(--sl-gold-dark); font-weight: 700; }

/* ---------- Chân trang ---------- */
.sl-foot {
  flex: 0 0 auto; text-align: center; font-size: 11.5px; color: var(--sl-muted);
  padding: 6px 16px 16px; line-height: 1.6;
}
.sl-foot a { color: var(--sl-gold-dark); text-decoration: none; }
.sl-foot a:hover { text-decoration: underline; }

/* ---------- Lớp phủ chung ---------- */
.sl-overlay {
  position: fixed; inset: 0; z-index: 60; display: none;
  align-items: center; justify-content: center; padding: 18px;
  background: rgba(44, 38, 32, .62); backdrop-filter: blur(3px);
  animation: sl-fade .18s ease;
}
.sl-overlay.--open { display: flex; }
@keyframes sl-fade { from { opacity: 0 } to { opacity: 1 } }
.sl-modal {
  background: var(--sl-card); border-radius: var(--sl-radius); border: 1px solid var(--sl-line);
  box-shadow: var(--sl-shadow); max-width: 460px; width: 100%; padding: 22px 22px 20px;
  max-height: 92vh; overflow: auto;
}
.sl-modal h2 { margin: 0 0 6px; font-family: var(--sl-serif); font-size: 20px; color: var(--sl-head); }
.sl-modal p.sl-lead { margin: 0 0 16px; font-size: 13.5px; line-height: 1.65; color: var(--sl-body); }
.sl-close {
  position: absolute; top: 14px; right: 16px; width: 40px; height: 40px; border-radius: 50%;
  background: rgba(255,255,255,.9); border: 1px solid var(--sl-line); color: var(--sl-head);
  cursor: pointer; font-size: 20px; line-height: 1; z-index: 2;
}
.sl-close:hover { background: var(--sl-gold); color: #fff; }

/* ---------- Kính lúp (zoom) ---------- */
.sl-zoom { background: rgba(30, 26, 22, .9); padding: 0; }
.sl-zoom .sl-zoom-canvas {
  position: absolute; inset: 0; overflow: hidden; cursor: grab;
  display: flex; align-items: center; justify-content: center;
}
.sl-zoom .sl-zoom-canvas.--drag { cursor: grabbing; }
.sl-zoom img {
  max-width: none; transform-origin: 0 0; user-select: none; -webkit-user-drag: none;
  box-shadow: 0 10px 40px rgba(0,0,0,.5); background: #fff;
}
.sl-zoom-bar {
  position: absolute; bottom: 18px; left: 50%; transform: translateX(-50%);
  display: flex; gap: 8px; align-items: center; z-index: 3;
  background: rgba(255,255,255,.94); border: 1px solid var(--sl-line);
  border-radius: 999px; padding: 6px 8px; box-shadow: var(--sl-shadow);
}
.sl-zoom-bar .sl-lvl { font-size: 12px; color: var(--sl-body); min-width: 46px; text-align: center; font-variant-numeric: tabular-nums; }

/* ---------- Cổng thu lead ---------- */
.sl-gate { background: rgba(44, 38, 32, .72); }
.sl-gate .sl-modal { max-width: 420px; text-align: left; }
.sl-gate .sl-crest { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.sl-gate .sl-crest img { width: 40px; height: 40px; border-radius: 50%; }
.sl-gate .sl-crest b { font-size: 12px; letter-spacing: 1.4px; color: var(--sl-gold-dark); text-transform: uppercase; }
.sl-field { margin-bottom: 12px; }
.sl-field label { display: block; font-size: 12px; font-weight: 600; color: var(--sl-head); margin-bottom: 5px; }
.sl-field input {
  width: 100%; height: 42px; padding: 0 12px; font: inherit; color: var(--sl-head);
  background: #fffdf9; border: 1px solid var(--sl-line); border-radius: 9px;
}
.sl-field input:focus { outline: none; border-color: var(--sl-gold); box-shadow: 0 0 0 3px rgba(176,137,79,.16); }
.sl-field .sl-err { display: none; font-size: 11.5px; color: #a4472f; margin-top: 4px; }
.sl-field.--bad input { border-color: #cf7f68; }
.sl-field.--bad .sl-err { display: block; }
.sl-submit { width: 100%; height: 46px; justify-content: center; font-size: 14.5px; margin-top: 4px; }
.sl-note { font-size: 11.5px; color: var(--sl-muted); margin: 10px 0 0; line-height: 1.6; text-align: center; }
.sl-gate-skip { display: block; width: 100%; margin-top: 10px; background: none; border: 0; font: inherit; font-size: 12px; color: var(--sl-muted); cursor: pointer; text-decoration: underline; }

/* ---------- Chia sẻ / nhúng ---------- */
.sl-share-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.sl-embed-box {
  width: 100%; height: 86px; font: 12px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace;
  color: var(--sl-body); background: #fffdf9; border: 1px solid var(--sl-line);
  border-radius: 9px; padding: 10px; resize: vertical;
}
.sl-toast {
  position: fixed; bottom: 22px; left: 50%; transform: translate(-50%, 14px);
  background: var(--sl-head); color: #fff; font-size: 13px; padding: 10px 16px;
  border-radius: 999px; opacity: 0; pointer-events: none; transition: .22s; z-index: 90;
}
.sl-toast.--on { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Màn nạp ---------- */
.sl-boot { position: fixed; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; background: var(--sl-cream); z-index: 80; }
.sl-boot .sl-ring { width: 34px; height: 34px; border: 3px solid rgba(176,137,79,.25); border-top-color: var(--sl-gold); border-radius: 50%; animation: sl-spin .9s linear infinite; }
@keyframes sl-spin { to { transform: rotate(360deg) } }
.sl-boot p { margin: 0; font-size: 13px; color: var(--sl-muted); }
.sl-boot.--gone { display: none; }

/* ---------- Chế độ nhúng ---------- */
body.sl-embed .sl-top, body.sl-embed .sl-foot { display: none; }
body.sl-embed .sl-stage { padding-top: 10px; }

@media (max-width: 560px) {
  .sl-bar { gap: 6px; padding: 6px 8px 8px; }
  .sl-btn { height: 36px; padding: 0 11px; font-size: 12.5px; }
  .sl-btn.--icon { width: 36px; }
  .sl-top { padding: 10px 12px 4px; }
  .sl-foot { font-size: 11px; padding: 4px 12px 12px; }
}
@media print { .sl-bar, .sl-thumbs, .sl-side, .sl-top { display: none } }

/* ---------- Trang mời để lại thông tin (nằm trong sách) ---------- */
#sl-book .sl-page { position: relative; }
.sl-page-gate {
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(160deg, #fffdf8 0%, #f4ead6 100%);
}
.sl-teaser { text-align: center; padding: 8% 11%; }
.sl-teaser-logo { width: 54px; height: 54px; border-radius: 50%; margin-bottom: 14px; }
.sl-teaser h3 {
  margin: 0 0 10px; font-family: var(--sl-serif); font-size: clamp(17px, 2.6vw, 25px);
  line-height: 1.28; color: var(--sl-head);
}
.sl-teaser p { margin: 0 0 18px; font-size: clamp(12.5px, 1.5vw, 14.5px); line-height: 1.65; color: var(--sl-body); }
.sl-teaser-btn { height: 44px; padding: 0 22px; font-size: 14px; }
