@import url('https://fonts.googleapis.com/css2?family=Vazirmatn:wght@400;500;600;700;800&display=swap');

:root {
  --paper: #f7f4ed;
  --paper-raised: #ffffff;
  --ink: #221f1a;
  --ink-soft: #55503f;
  --muted: #948d78;
  --accent: #2f4a3d;
  --accent-soft: #e4ede7;
  --gold: #a9761f;
  --gold-soft: #f4e9d3;
  --line: #e2dbc9;
  --line-soft: #ece6d6;
  --shadow: 0 10px 30px -18px rgba(34, 31, 26, 0.35);
  color-scheme: light;
}

:root[data-theme="dark"] {
  --paper: #17150f;
  --paper-raised: #1f1c15;
  --ink: #efe9db;
  --ink-soft: #c9c1ab;
  --muted: #8c8368;
  --accent: #7fae95;
  --accent-soft: #24352c;
  --gold: #d9ab5b;
  --gold-soft: #33291a;
  --line: #34301f;
  --line-soft: #2a2619;
  --shadow: 0 10px 30px -16px rgba(0, 0, 0, 0.6);
  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #17150f;
    --paper-raised: #1f1c15;
    --ink: #efe9db;
    --ink-soft: #c9c1ab;
    --muted: #8c8368;
    --accent: #7fae95;
    --accent-soft: #24352c;
    --gold: #d9ab5b;
    --gold-soft: #33291a;
    --line: #34301f;
    --line-soft: #2a2619;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: 'Vazirmatn', 'Tahoma', sans-serif;
  line-height: 1.75;
  direction: rtl;
  transition: background 0.25s ease, color 0.25s ease;
}

a { color: inherit; }

.wrap {
  max-width: 1040px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

.icon { width: 1em; height: 1em; stroke: currentColor; fill: none; stroke-width: 1.8; vertical-align: -0.15em; }

/* ---------- Nav ---------- */

.site-nav {
  position: sticky;
  top: 0;
  z-index: 20;
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}

.site-nav .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 1.1rem;
  padding-bottom: 1.1rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  text-decoration: none;
  color: var(--ink);
  font-weight: 700;
  font-size: 1.05rem;
}
.brand .mark {
  width: 1.7rem;
  height: 1.7rem;
  border-radius: 5px;
  background: var(--accent);
  color: var(--paper-raised);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 800;
}

.nav-links {
  display: flex;
  gap: 1.6rem;
  font-size: 0.92rem;
  color: var(--ink-soft);
}
.nav-links a { text-decoration: none; }
.nav-links a:hover { color: var(--accent); }

.nav-actions { display: flex; align-items: center; gap: 0.7rem; }
.icon-btn {
  width: 2.1rem;
  height: 2.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--paper-raised);
  color: var(--ink-soft);
  cursor: pointer;
}
.icon-btn:hover { color: var(--accent); border-color: var(--accent); }

/* ---------- Hero ---------- */

.hero {
  padding: 3.5rem 0 2.5rem;
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 2.5rem;
  align-items: center;
}

.hero-title {
  font-size: 2.6rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  margin: 0 0 0.5rem;
}
.hero-title .accent-word { color: var(--accent); }

.hero-tagline {
  color: var(--ink-soft);
  font-size: 1.05rem;
  max-width: 34ch;
  margin: 0 0 1.6rem;
}

.search-box-wrap { position: relative; max-width: 26rem; }
.search-box-wrap .icon {
  position: absolute;
  top: 50%;
  right: 0.95rem;
  transform: translateY(-50%);
  color: var(--muted);
}
.search-box {
  width: 100%;
  padding: 0.85rem 2.6rem 0.85rem 1rem;
  font-family: inherit;
  font-size: 0.95rem;
  color: var(--ink);
  background: var(--paper-raised);
  border: 1px solid var(--line);
  border-radius: 999px;
  box-shadow: var(--shadow);
}
.search-box:focus { outline: none; border-color: var(--accent); }
.search-box::placeholder { color: var(--muted); }

/* Decorative stacked-book illustration, pure CSS */
.book-stack {
  position: relative;
  height: 15rem;
}
.book-stack .spine {
  position: absolute;
  right: 6%;
  left: 6%;
  height: 3.1rem;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.1rem;
  font-size: 0.85rem;
  font-weight: 600;
  box-shadow: var(--shadow);
}
.book-stack .spine:nth-child(1) { bottom: 0;    z-index: 4; }
.book-stack .spine:nth-child(2) { bottom: 3.4rem; z-index: 3; right: 3%; left: 9%; }
.book-stack .spine:nth-child(3) { bottom: 6.8rem; z-index: 2; right: 9%; left: 3%; }
.book-stack .spine:nth-child(4) { bottom: 10.2rem; z-index: 1; right: 0%; left: 12%; }

/* ---------- Category pills ---------- */

.pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0 0 2.2rem;
}
.pill {
  padding: 0.45rem 1rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--paper-raised);
  color: var(--ink-soft);
  font-size: 0.85rem;
  cursor: pointer;
  font-family: inherit;
}
.pill:hover { border-color: var(--accent); color: var(--accent); }
.pill.active { background: var(--accent); border-color: var(--accent); color: var(--paper-raised); }

/* ---------- Section heading row ---------- */

.section-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 1.2rem;
}
.section-title { font-size: 1.25rem; font-weight: 700; margin: 0; }

/* ---------- Book grid & cards ---------- */

.book-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 1.4rem;
  margin-bottom: 3rem;
}

.book-card {
  text-decoration: none;
  color: var(--ink);
  background: var(--paper-raised);
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.book-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); }

.cover {
  aspect-ratio: 3 / 4;
  display: flex;
  align-items: flex-end;
  padding: 1rem;
  position: relative;
}
.cover::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(0,0,0,0) 55%, rgba(0,0,0,0.28) 100%);
}
.cover .cover-title {
  position: relative;
  font-weight: 700;
  font-size: 1.05rem;
  line-height: 1.4;
}
.cover .cover-tag {
  position: absolute;
  top: 0.8rem;
  left: 0.8rem;
  font-size: 0.68rem;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  background: rgba(255,255,255,0.22);
  backdrop-filter: blur(3px);
}

.card-body { padding: 1rem 1.1rem 1.2rem; flex: 1; display: flex; flex-direction: column; }
.card-body .c-title { font-weight: 700; font-size: 1rem; margin: 0 0 0.15rem; }
.card-body .c-author { color: var(--muted); font-size: 0.82rem; margin: 0 0 0.7rem; }
.card-body .c-quote {
  color: var(--ink-soft);
  font-size: 0.85rem;
  flex: 1;
  margin: 0 0 0.9rem;
}
.card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.78rem;
  color: var(--muted);
  border-top: 1px solid var(--line-soft);
  padding-top: 0.7rem;
}
.card-meta .arrow { color: var(--accent); font-weight: 700; }

.empty-state {
  color: var(--muted);
  padding: 3rem 0;
  text-align: center;
  font-size: 0.95rem;
  grid-column: 1 / -1;
}

/* ---------- Book detail ---------- */

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  color: var(--accent);
  text-decoration: none;
  font-size: 0.88rem;
  margin: 2rem 0 1.6rem;
}

.detail-grid {
  display: grid;
  grid-template-columns: 15rem 1fr;
  gap: 2.6rem;
  align-items: start;
}

.detail-cover {
  aspect-ratio: 3 / 4;
  border-radius: 10px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: flex-end;
  padding: 1.3rem;
  position: relative;
}
.detail-cover::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(0,0,0,0) 50%, rgba(0,0,0,0.3) 100%);
}
.detail-cover .cover-title { position: relative; font-weight: 700; font-size: 1.3rem; line-height: 1.45; }

.book-title { font-size: 1.9rem; font-weight: 800; margin: 0 0 0.3rem; letter-spacing: -0.01em; }
.book-byline { color: var(--muted); font-size: 0.98rem; margin-bottom: 1rem; }

.meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 1.4rem;
  color: var(--ink-soft);
  font-size: 0.86rem;
  margin-bottom: 1rem;
}
.meta-row .item { display: flex; align-items: center; gap: 0.35rem; }
.meta-row .pill-tag {
  background: var(--accent-soft);
  color: var(--accent);
  padding: 0.2rem 0.65rem;
  border-radius: 999px;
  font-size: 0.78rem;
}

.rating { color: var(--gold); font-size: 0.95rem; margin-bottom: 1.4rem; }
.rating .num { color: var(--muted); font-size: 0.82rem; margin-right: 0.3rem; }

.quote-box {
  background: var(--gold-soft);
  border-right: 3px solid var(--gold);
  border-radius: 6px;
  padding: 1rem 1.2rem;
  color: var(--ink);
  font-size: 0.98rem;
  margin-bottom: 2.2rem;
}

.block { margin-bottom: 2.2rem; }
.block h2 { font-size: 1.15rem; font-weight: 700; margin: 0 0 0.9rem; }
.block .prose p { color: var(--ink-soft); margin: 0 0 1rem; }

ol.key-ideas { list-style: none; margin: 0; padding: 0; counter-reset: idea; }
ol.key-ideas li {
  counter-increment: idea;
  display: flex;
  gap: 0.8rem;
  align-items: flex-start;
  padding: 0.55rem 0;
  color: var(--ink-soft);
}
ol.key-ideas li::before {
  content: counter(idea);
  flex: 0 0 auto;
  width: 1.6rem;
  height: 1.6rem;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 700;
  font-size: 0.8rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

ul.takeaways { list-style: none; margin: 0; padding: 0; }
ul.takeaways li {
  display: flex;
  gap: 0.7rem;
  align-items: flex-start;
  padding: 0.4rem 0;
  color: var(--ink-soft);
}
ul.takeaways li::before {
  content: "✓";
  color: var(--accent);
  font-weight: 700;
}

.detail-footer {
  display: flex;
  justify-content: space-between;
  border-top: 1px solid var(--line);
  padding-top: 1.4rem;
  margin-top: 2.5rem;
  font-size: 0.88rem;
}
.detail-footer a { text-decoration: none; color: var(--ink-soft); }
.detail-footer a:hover { color: var(--accent); }

footer.site-footer {
  margin-top: 3rem;
  padding: 1.6rem 0 3rem;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.8rem;
  text-align: center;
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .book-card { transition: none; }
}

@media (max-width: 820px) {
  .hero { grid-template-columns: 1fr; }
  .book-stack { height: 11rem; margin-top: 1rem; }
  .detail-grid { grid-template-columns: 1fr; }
  .detail-cover { max-width: 12rem; }
  .nav-links { display: none; }
}

@media (max-width: 480px) {
  .hero-title { font-size: 2rem; }
}
