
:root {
  --bg: #f5f0e8;
  --gold: #b08d57;
  --gold-light: #d4af37;
  --brown: #5c4033;
  --green: #0f5132;
  --green-light: #198754;
  --text: #1a1209;
  --text-muted: #6b5c4e;
  --card-bg: #fffdf7;
  --border: rgba(176,141,87,0.2);
  --shadow: 0 4px 28px rgba(92,64,51,0.10);
  --shadow-hover: 0 16px 48px rgba(92,64,51,0.22);
}
[data-theme="dark"] {
  --bg: #0f1115;
  --gold: #d4af37;
  --gold-light: #f0c94d;
  --brown: #c8a96b;
  --green: #1f7a53;
  --green-light: #2aab72;
  --text: #f1f1f1;
  --text-muted: #a89880;
  --card-bg: #1a1d24;
  --border: rgba(212,175,55,0.15);
  --shadow: 0 4px 24px rgba(0,0,0,0.4);
  --shadow-hover: 0 16px 48px rgba(0,0,0,0.6);
}
* { margin:0; padding:0; box-sizing:border-box; }
html { scroll-behavior:smooth; }
body {
  font-family:'Cairo',sans-serif;
  background:var(--bg); color:var(--text);
  transition:background .4s,color .4s;
  overflow-x:hidden;
}
::-webkit-scrollbar { width:5px; }
::-webkit-scrollbar-track { background:var(--bg); }
::-webkit-scrollbar-thumb { background:var(--gold); border-radius:3px; }

/* ===== PROGRESS ===== */
.top-progress { position:fixed; top:0; right:0; left:0; height:3px; z-index:999; }
.top-progress-fill { height:100%; background:linear-gradient(90deg,var(--gold),var(--green-light)); width:0%; transition:width .1s; }

/* ===== TOPBAR ===== */
.topbar {
  background:#3e1d0ec2; padding:9px 28px;
  display:flex; align-items:center; justify-content:space-between;
  font-size:13px; color:rgba(255,255,255,.85);
  position:sticky; top:0; z-index:100;
}
.topbar-breadcrumb { display:flex; align-items:center; gap:8px; }
.topbar-breadcrumb a { color:rgba(255,255,255,.7); text-decoration:none; transition:color .2s; }
.topbar-breadcrumb a:hover { color:var(--gold-light); }
.sep { opacity:.4; }
.topbar-right { display:flex; align-items:center; gap:10px; }
.tb-btn {
  background:rgba(255,255,255,.12); border:none; color:#fff;
  padding:5px 14px; border-radius:20px;
  font-family:'Cairo',sans-serif; font-size:12px; font-weight:600;
  cursor:pointer; transition:background .2s; display:flex; align-items:center; gap:5px;
}
.tb-btn:hover { background:rgba(255,255,255,.22); }

/* ===== HERO ===== */
.books-hero {
  position:relative;
  background:linear-gradient(160deg,#1a0f05 0%,#3a1f0a 40%,#0f1a12 100%);
  padding:56px 48px 52px;
  overflow:hidden;
}
.hero-ornament {
  position:absolute; inset:0; opacity:.04;
  background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='80' height='80' viewBox='0 0 80 80'%3E%3Crect x='14' y='8' width='20' height='64' rx='2' fill='none' stroke='white' stroke-width='1'/%3E%3Crect x='40' y='12' width='20' height='58' rx='2' fill='none' stroke='white' stroke-width='1'/%3E%3Crect x='28' y='18' width='6' height='46' rx='1' fill='white' opacity='.3'/%3E%3C/svg%3E");
  background-size:80px;
}
.hero-glow-l { position:absolute; top:-100px; right:-100px; width:500px; height:500px; border-radius:50%; background:radial-gradient(ellipse,rgba(176,141,87,.1) 0%,transparent 65%); pointer-events:none; }
.hero-glow-r { position:absolute; bottom:-80px; left:80px; width:400px; height:300px; border-radius:50%; background:radial-gradient(ellipse,rgba(15,81,50,.2) 0%,transparent 65%); pointer-events:none; }
.hero-inner { position:relative; z-index:1; max-width:900px; }
.hero-badge {
  display:inline-flex; align-items:center; gap:8px;
  background:rgba(176,141,87,.15); border:1px solid rgba(176,141,87,.35);
  color:var(--gold-light); padding:5px 16px; border-radius:20px;
  font-size:12px; font-weight:700; margin-bottom:22px; letter-spacing:.5px;
}
.hero-badge .dot { width:7px; height:7px; background:var(--gold-light); border-radius:50%; animation:pulse 2s infinite; }
@keyframes pulse { 0%,100%{opacity:1;transform:scale(1)} 50%{opacity:.5;transform:scale(1.4)} }
.hero-title {
  font-family:'Aref Ruqaa',serif;
  font-size:clamp(26px,4vw,46px);
  color:#fff; line-height:1.5; margin-bottom:14px;
}
.hero-sub { font-size:15px; color:rgba(255,255,255,.55); line-height:1.8; max-width:600px; margin-bottom:28px; }
.hero-counters { display:flex; gap:24px; flex-wrap:wrap; }
.h-counter {
  background:rgba(255,255,255,.07); border:1px solid rgba(255,255,255,.1);
  border-radius:14px; padding:12px 22px;
  display:flex; align-items:center; gap:14px;
}
.h-counter-num { font-family:'Reem Kufi',sans-serif; font-size:24px; color:var(--gold-light); line-height:1; }
.h-counter-lbl { font-size:11px; color:rgba(255,255,255,.45); margin-top:3px; }

/* ===== FILTERS BAR ===== */
.filters-bar {
  background:var(--card-bg); border-bottom:1px solid var(--border);
  padding:16px 36px;
  display:flex; align-items:center; gap:12px; flex-wrap:wrap;
  position:sticky; top:40px; z-index:90;
  box-shadow:0 4px 20px rgba(0,0,0,.06);
}
.filter-label { font-size:12px; font-weight:700; color:var(--text-muted); white-space:nowrap; }
.filter-pills { display:flex; gap:8px; flex-wrap:wrap; flex:1; }
.fpill {
  padding:6px 16px; border-radius:24px;
  border:1px solid var(--border); background:transparent;
  font-family:'Cairo',sans-serif; font-size:13px; font-weight:600;
  color:var(--text-muted); cursor:pointer; transition:all .22s;
  white-space:nowrap;
}
.fpill:hover { border-color:var(--gold); color:var(--gold); }
.fpill.active { background:var(--gold); color:#fff; border-color:var(--gold); }
.filters-right { display:flex; gap:8px; align-items:center; margin-right:auto; }
.sort-select {
  padding:7px 14px; border:1px solid var(--border); border-radius:10px;
  background:var(--bg); color:var(--text);
  font-family:'Cairo',sans-serif; font-size:13px; outline:none; cursor:pointer;
}
.view-btn {
  width:36px; height:36px; border-radius:10px;
  border:1px solid var(--border); background:transparent;
  display:flex; align-items:center; justify-content:center;
  font-size:16px; cursor:pointer; transition:all .2s; color:var(--text-muted);
}
.view-btn.active { background:var(--gold); color:#fff; border-color:var(--gold); }
.search-bar-wrap { position:relative; }
.search-books {
  padding:7px 38px 7px 14px; border:1px solid var(--border);
  border-radius:10px; background:var(--bg); color:var(--text);
  font-family:'Cairo',sans-serif; font-size:13px; outline:none;
  transition:border-color .2s; width:180px;
}
.search-books:focus { border-color:var(--gold); }
.search-icon { position:absolute; right:10px; top:50%; transform:translateY(-50%); font-size:14px; color:var(--text-muted); pointer-events:none; }

/* ===== MAIN LAYOUT ===== */
.page-wrap { max-width:1280px; margin:0 auto; padding:40px 32px; }

/* ===== SECTION HEADER ===== */
.section-hdr {
  display:flex; align-items:center; justify-content:space-between;
  margin-bottom:28px;
}
.section-hdr h2 {
  font-family:'Reem Kufi',sans-serif; font-size:20px; font-weight:700; color:var(--text);
  display:flex; align-items:center; gap:8px;
}
.count-badge {
  font-size:12px; font-weight:700; padding:3px 10px;
  border-radius:20px; background:rgba(176,141,87,.12); color:var(--gold);
}

/* ===== BOOKS GRID ===== */
.books-grid {
  display:grid;
  grid-template-columns:repeat(auto-fill, minmax(220px, 1fr));
  gap:36px 28px;
}
.books-grid.list-view {
  grid-template-columns:1fr;
  gap:16px;
}

/* ===== BOOK CARD ===== */
.book-card {
  display:flex; flex-direction:column; align-items:center;
  cursor:pointer;
  transition:transform .3s cubic-bezier(.25,.46,.45,.94);
}
.book-card:hover { transform:translateY(-8px); }

/* ===== 3D BOOK ===== */
.book-3d {
  perspective:900px;
  width:160px; height:220px;
  margin-bottom:18px;
  flex-shrink:0;
}
.book-inner {
  width:160px; height:220px;
  position:relative;
  transform-style:preserve-3d;
  transform:rotateY(-28deg) rotateX(4deg);
  transition:transform .45s cubic-bezier(.25,.46,.45,.94);
  filter:drop-shadow(0 22px 28px rgba(0,0,0,.35));
}
.book-card:hover .book-inner {
  transform:rotateY(-14deg) rotateX(2deg);
  filter:drop-shadow(0 32px 40px rgba(0,0,0,.45));
}

/* Front cover */
.book-front {
  position:absolute; inset:0;
  border-radius:0 6px 6px 0;
  display:flex; flex-direction:column;
  overflow:hidden;
  backface-visibility:hidden;
}
.book-cover-art {
  flex:1; display:flex; align-items:center; justify-content:center;
  position:relative; overflow:hidden;
}
.book-cover-pattern {
  position:absolute; inset:0; opacity:.08;
  background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='40' height='40' viewBox='0 0 40 40'%3E%3Cpolygon points='20,2 38,11 38,29 20,38 2,29 2,11' fill='none' stroke='white' stroke-width='1'/%3E%3C/svg%3E");
  background-size:40px;
}
.book-icon { font-size:54px; position:relative; z-index:1; filter:drop-shadow(0 4px 12px rgba(0,0,0,.4)); }
.book-cover-bottom {
  padding:14px 12px 12px;
  background:rgba(0,0,0,.3);
  backdrop-filter:blur(2px);
}
.book-cover-title {
  font-family:'Reem Kufi',sans-serif; font-weight:700;
  font-size:12.5px; color:#fff; line-height:1.45;
  text-align:center;
  display:-webkit-box; -webkit-line-clamp:2; -webkit-box-orient:vertical; overflow:hidden;
}
.book-cover-author {
  font-size:10px; color:rgba(255,255,255,.65);
  text-align:center; margin-top:5px;
}

/* Book spine */
.book-spine {
  position:absolute; top:0; right:100%; bottom:0;
  width:28px;
  border-radius:3px 0 0 3px;
  display:flex; align-items:center; justify-content:center;
  overflow:hidden;
  transform:rotateY(90deg) translateZ(-14px) translateX(-14px);
  transform-origin:right center;
}
.spine-title {
  writing-mode:vertical-rl; text-orientation:mixed;
  font-family:'Reem Kufi',sans-serif; font-size:10px; font-weight:700;
  color:rgba(255,255,255,.85); padding:8px 4px;
  display:-webkit-box; -webkit-line-clamp:1; overflow:hidden;
  letter-spacing:.5px; white-space:nowrap;
  max-height:180px;
  direction:ltr;
}

/* Book pages (right edge) */
.book-pages {
  position:absolute; top:2px; left:100%; bottom:2px;
  width:10px;
  border-radius:0 2px 2px 0;
  background:repeating-linear-gradient(
    to bottom,
    #f5f0e0 0px, #f5f0e0 1px,
    #e8e0cc 1px, #e8e0cc 2px
  );
  transform:rotateY(-90deg) translateZ(0px) translateX(5px);
  transform-origin:left center;
  box-shadow:inset -2px 0 4px rgba(0,0,0,.1);
}
[data-theme="dark"] .book-pages {
  background:repeating-linear-gradient(
    to bottom,
    #2a2520 0px, #2a2520 1px,
    #1e1a16 1px, #1e1a16 2px
  );
}

/* Shine overlay */
.book-shine {
  position:absolute; inset:0; border-radius:0 6px 6px 0;
  background:linear-gradient(135deg,rgba(255,255,255,.18) 0%,transparent 50%,rgba(0,0,0,.1) 100%);
  pointer-events:none;
  transition:opacity .3s;
}
.book-card:hover .book-shine { opacity:.5; }

/* ===== CARD INFO ===== */
.book-info { text-align:center; width:100%;padding-top: 70px; }
.book-title {
  font-family:'Reem Kufi',sans-serif; font-size:14.5px; font-weight:700;
  color:var(--text); line-height:1.5; margin-bottom:6px;
  display:-webkit-box; -webkit-line-clamp:2; -webkit-box-orient:vertical; overflow:hidden;
}
.book-meta-row { display:flex; align-items:center; justify-content:center; gap:10px; flex-wrap:wrap; margin-bottom:10px; }
.book-cat {
  font-size:11px; font-weight:700; padding:3px 10px;
  border-radius:20px;
}
.book-pages-count { font-size:11px; color:var(--text-muted); display:flex; align-items:center; gap:3px; }
.book-stars { font-size:12px; color:var(--gold-light); letter-spacing:1px; }
.book-actions { display:flex; gap:8px; justify-content:center; }
.book-btn {
  padding:7px 14px; border-radius:10px; border:none;
  font-family:'Cairo',sans-serif; font-size:12px; font-weight:700;
  cursor:pointer; transition:all .22s;
  display:inline-flex; align-items:center; gap:5px;
  text-decoration:none;
}
.btn-read { background:var(--green); color:#fff; }
.btn-read:hover { opacity:.85; transform:translateY(-1px); }
.btn-dl { background:var(--card-bg); color:var(--text); border:1px solid var(--border); }
.btn-dl:hover { border-color:var(--gold); color:var(--gold); }

/* ===== LIST VIEW CARD ===== */
.books-grid.list-view .book-card {
  flex-direction:row; align-items:flex-start;
  background:var(--card-bg); border:1px solid var(--border);
  border-radius:18px; padding:20px 24px;
  box-shadow:var(--shadow); gap:28px;
  transform:none !important;
}
.books-grid.list-view .book-card:hover {
  box-shadow:var(--shadow-hover); border-color:var(--gold);
}
.books-grid.list-view .book-3d { margin-bottom:0; width:100px; height:138px; flex-shrink:0; }
.books-grid.list-view .book-inner { width:100px; height:138px; }
.books-grid.list-view .book-info { text-align:right; flex:1; }
.books-grid.list-view .book-meta-row { justify-content:flex-start; }
.books-grid.list-view .book-actions { justify-content:flex-start; }
.list-desc {
  font-family:'Amiri',serif; font-size:14px; line-height:1.85;
  color:var(--text-muted); margin-bottom:12px;
  display:-webkit-box; -webkit-line-clamp:2; -webkit-box-orient:vertical; overflow:hidden;
}

/* ===== FEATURED BANNER ===== */
.featured-banner {
  background:var(--card-bg); border:1px solid var(--border);
  border-radius:22px; padding:32px;
  display:flex; align-items:center; gap:36px;
  box-shadow:var(--shadow-hover);
  margin-bottom:48px;
  overflow:hidden; position:relative;
}
.featured-banner::before {
  content:''; position:absolute; inset:0;
  background:linear-gradient(120deg,rgba(176,141,87,.04) 0%,transparent 60%);
  pointer-events:none;
}
.featured-book-wrap { flex-shrink:0; }
.featured-badge {
  display:inline-flex; align-items:center; gap:6px;
  background:rgba(176,141,87,.12); border:1px solid rgba(176,141,87,.3);
  color:var(--gold); padding:4px 14px; border-radius:20px;
  font-size:11px; font-weight:700; margin-bottom:14px;
}
.featured-title {
  font-family:'Aref Ruqaa',serif; font-size:clamp(20px,2.5vw,30px);
  color:var(--text); line-height:1.5; margin-bottom:10px;
}
.featured-desc {
  font-family:'Amiri',serif; font-size:16px; line-height:1.9;
  color:var(--text-muted); margin-bottom:20px;
}
.featured-actions { display:flex; gap:10px; flex-wrap:wrap; }
.feat-btn-primary {
  padding:10px 24px; background:var(--gold); color:#fff;
  border:none; border-radius:12px; font-family:'Cairo',sans-serif;
  font-size:14px; font-weight:700; cursor:pointer; transition:all .22s;
  display:flex; align-items:center; gap:6px;
}
.feat-btn-primary:hover { background:var(--gold-light); transform:translateY(-2px); }
.feat-btn-sec {
  padding:10px 20px; background:transparent; color:var(--text);
  border:1px solid var(--border); border-radius:12px; font-family:'Cairo',sans-serif;
  font-size:14px; font-weight:700; cursor:pointer; transition:all .22s;
  display:flex; align-items:center; gap:6px;
}
.feat-btn-sec:hover { border-color:var(--gold); color:var(--gold); }
@media (max-width:700px) {
  .featured-banner { flex-direction:column; gap:20px; padding:22px; }
  .featured-book-wrap { align-self:center; }
}

/* ===== MODAL ===== */
.modal-overlay {
  position:fixed; inset:0; background:rgba(0,0,0,.7);
  z-index:500; display:flex; align-items:center; justify-content:center;
  padding:20px; opacity:0; pointer-events:none; transition:opacity .3s;
  backdrop-filter:blur(4px);
}
.modal-overlay.open { opacity:1; pointer-events:all; }
.modal-box {
  background:var(--card-bg); border-radius:24px;
  max-width:640px; width:100%; padding:36px;
  box-shadow:0 32px 80px rgba(0,0,0,.4);
  border:1px solid var(--border);
  position:relative;
  transform:scale(.95) translateY(20px);
  transition:transform .3s;
  max-height:90vh; overflow-y:auto;
}
.modal-overlay.open .modal-box { transform:scale(1) translateY(0); }
.modal-close {
  position:absolute; top:16px; left:16px;
  width:34px; height:34px; border-radius:50%;
  background:var(--border); border:none; cursor:pointer;
  font-size:16px; display:flex; align-items:center; justify-content:center;
  color:var(--text-muted); transition:all .2s;
}
.modal-close:hover { background:var(--gold); color:#fff; }
.modal-inner { display:flex; gap:28px; align-items:flex-start; }
.modal-book-wrap { flex-shrink:0; }
.modal-info { flex:1; }
.modal-cat { font-size:11px; font-weight:700; padding:3px 10px; border-radius:20px; margin-bottom:12px; display:inline-block; }
.modal-title { font-family:'Aref Ruqaa',serif; font-size:22px; color:var(--text); line-height:1.5; margin-bottom:10px; }
.modal-desc { font-family:'Amiri',serif; font-size:16px; line-height:1.9; color:var(--text-muted); margin-bottom:16px; }
.modal-stats { display:flex; gap:14px; flex-wrap:wrap; margin-bottom:18px; }
.modal-stat { font-size:12px; color:var(--text-muted); display:flex; align-items:center; gap:4px; }
.modal-actions { display:flex; gap:10px; flex-wrap:wrap; }
.m-btn { padding:9px 18px; border-radius:12px; font-family:'Cairo',sans-serif; font-size:13px; font-weight:700; cursor:pointer; transition:all .22s; display:inline-flex; align-items:center; gap:5px; border:none; text-decoration:none; }
.m-btn-primary { background:var(--green); color:#fff; }
.m-btn-primary:hover { opacity:.85; }
.m-btn-gold { background:var(--gold); color:#fff; }
.m-btn-gold:hover { background:var(--gold-light); }
.m-btn-outline { background:transparent; color:var(--text); border:1px solid var(--border); }
.m-btn-outline:hover { border-color:var(--gold); color:var(--gold); }
@media (max-width:560px) {
  .modal-inner { flex-direction:column; align-items:center; }
}

/* ===== TOAST ===== */
.toast {
  position:fixed; bottom:32px; left:50%; transform:translateX(-50%) translateY(16px);
  background:#1a1d24; color:#fff; padding:12px 22px; border-radius:12px;
  font-size:14px; font-weight:600; font-family:'Cairo',sans-serif;
  display:flex; align-items:center; gap:10px;
  box-shadow:0 8px 32px rgba(0,0,0,.35); opacity:0; transition:all .3s; z-index:1000;
  border:1px solid rgba(176,141,87,.2); pointer-events:none;
}
.toast.show { opacity:1; transform:translateX(-50%) translateY(0); }

/* ===== RESPONSIVE ===== */
@media (max-width:900px) { .books-grid { grid-template-columns:repeat(auto-fill,minmax(170px,1fr)); gap:28px 20px; } }
@media (max-width:600px) {
  .topbar { padding:8px 14px; }
  .books-hero { padding:36px 20px 32px; }
  .page-wrap { padding:24px 16px; }
  .filters-bar { padding:12px 16px; }
  .h-counter { padding:10px 14px; }
  .books-grid { grid-template-columns:repeat(auto-fill,minmax(150px,1fr)); gap:24px 14px; }
  .book-3d { width:130px; height:180px; }
  .book-inner { width:130px; height:180px; }
  .books-grid.list-view .book-3d { width:80px; height:110px; }
  .books-grid.list-view .book-inner { width:80px; height:110px; }
}

