/* Ismaili Books: lapis on cool white, one typeface per script. */
:root {
  --bg: #FAFAFC;
  --surface: #FFFFFF;
  --sunk: #F1F2F7;
  --ink: #161A33;
  --muted: #5D6380;
  --line: #E2E4EE;
  --lapis: #2347C5;
  --lapis-deep: #1A3596;
  --lapis-wash: #E9EDFB;
  --saffron: #E2A012;
  --on-lapis: #FFFFFF;

  --latin: "Schibsted Grotesk", system-ui, -apple-system, "Segoe UI", sans-serif;
  --naskh: "Vazirmatn", "Noto Naskh Arabic", "Geeza Pro", serif;
  --nastaliq: "Noto Nastaliq Urdu", "Vazirmatn", serif;
  --gujarati: "Hind Vadodara", "Noto Sans Gujarati", sans-serif;

  --r-sm: 6px;
  --r-md: 12px;
  --wrap: 1320px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0E1127; --surface: #151936; --sunk: #1B2043; --ink: #E9EBF7; --muted: #A2A8C6;
    --line: #2A3058; --lapis: #7D97FF; --lapis-deep: #A6B7FF; --lapis-wash: #1E2652;
    --saffron: #F2B83A; --on-lapis: #0E1127;
  }
}

/* base */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
body { margin: 0; background: var(--bg); color: var(--ink); font: 400 17px/1.6 var(--latin); -webkit-font-smoothing: antialiased; }
a { color: var(--lapis); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
:focus-visible { outline: 3px solid var(--saffron); outline-offset: 2px; border-radius: 4px; }
h1, h2, h3 { font-weight: 800; letter-spacing: -0.02em; line-height: 1.1; margin: 0 0 .5em; }
h1 { font-size: clamp(2rem, 4.2vw, 3rem); }
h2 { font-size: 1.375rem; letter-spacing: -0.01em; }
p { margin: 0 0 1em; }
.wrap { max-width: var(--wrap); margin: 0 auto; padding: 0 24px; }
.narrow { max-width: 760px; }
.muted { color: var(--muted); }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: 12px; top: -48px; background: var(--lapis); color: var(--on-lapis); padding: 8px 14px; border-radius: var(--r-sm); z-index: 20; }
.skip:focus { top: 12px; }

/* scripts: each language in a face drawn for it */
[dir="rtl"] { text-align: right; }
.s-ar, .s-fa { font-family: var(--naskh); }
.s-ur, .s-bsk { font-family: var(--nastaliq); line-height: 2.1; }
.s-gu { font-family: var(--gujarati); }

/* buttons & fields */
button, .btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: 600 1rem/1 var(--latin); color: var(--on-lapis); background: var(--lapis);
  border: 0; border-radius: var(--r-sm); padding: 12px 20px; cursor: pointer; text-decoration: none;
}
button:hover, .btn:hover { background: var(--lapis-deep); text-decoration: none; }
.btn-quiet { background: transparent; color: var(--lapis); box-shadow: inset 0 0 0 1.5px var(--line); }
.btn-quiet:hover { background: var(--lapis-wash); }
.btn-wide { width: 100%; }
input[type="search"], select {
  font: 400 1rem/1.2 var(--latin); color: var(--ink); background: var(--surface);
  border: 1.5px solid var(--line); border-radius: var(--r-sm); padding: 11px 14px; width: 100%;
}
input[type="search"]:focus, select:focus { border-color: var(--lapis); outline: none; box-shadow: 0 0 0 3px var(--lapis-wash); }
input::placeholder { color: var(--muted); opacity: .85; }

/* header */
.site-header { position: sticky; top: 0; z-index: 10; background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(12px); -webkit-backdrop-filter: saturate(1.4) blur(12px); border-bottom: 1px solid var(--line); }
.header-row { display: flex; align-items: center; gap: 32px; min-height: 68px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); font-weight: 800; font-size: 1.125rem; letter-spacing: -0.02em; white-space: nowrap; }
.brand:hover { text-decoration: none; }
.mark { width: 26px; height: 26px; fill: var(--lapis); }
.mark .mark-eye { fill: var(--bg); }
.main-nav { display: flex; gap: 4px; }
.main-nav a { color: var(--muted); font-weight: 500; padding: 8px 12px; border-radius: var(--r-sm); }
.main-nav a:hover { color: var(--ink); background: var(--sunk); text-decoration: none; }
.main-nav a[aria-current="page"] { color: var(--ink); background: var(--sunk); }
.header-search { position: relative; margin-left: auto; width: 260px; }
.header-search svg { position: absolute; left: 12px; top: 50%; width: 18px; height: 18px; transform: translateY(-50%); fill: none; stroke: var(--muted); stroke-width: 2; stroke-linecap: round; pointer-events: none; }
.header-search input { padding: 9px 12px 9px 38px; background: var(--sunk); border-color: transparent; }

/* hero */
.hero { padding: 88px 0 56px; }
.hero h1 { font-size: clamp(2.5rem, 7vw, 5.25rem); letter-spacing: -0.035em; line-height: 1; max-width: 13ch; margin-bottom: 20px; }
.lede { font-size: 1.25rem; color: var(--muted); max-width: 58ch; }
.big-search { position: relative; display: flex; gap: 8px; max-width: 720px; margin-top: 32px;
  background: var(--surface); border: 1.5px solid var(--line); border-radius: var(--r-md); padding: 6px; }
.big-search:focus-within { border-color: var(--lapis); box-shadow: 0 0 0 4px var(--lapis-wash); }
.big-search svg { position: absolute; left: 20px; top: 50%; width: 22px; height: 22px; transform: translateY(-50%); fill: none; stroke: var(--muted); stroke-width: 2; stroke-linecap: round; pointer-events: none; }
.big-search input { border: 0; background: transparent; font-size: 1.125rem; padding: 14px 14px 14px 46px; }
.big-search input:focus { box-shadow: none; }
.big-search button { padding: 0 28px; font-size: 1.05rem; }
.stats { margin-top: 18px; color: var(--muted); }

/* language collections: card with a fanned stack of covers */
.eyebrow, .coll-group-h { font-size: .8rem; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); margin: 0 0 12px; }
.coll-group { margin: 8px 0 56px; }
.coll-group-h { margin-bottom: 20px; }
.coll-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; }
.coll-grid-main { grid-template-columns: repeat(2, minmax(0, 1fr)); max-width: calc((100% - 40px) / 3 * 2 + 20px); }
.coll-card { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 22px; height: 100%; padding: 24px 24px 22px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 18px; color: var(--ink);
  transition: border-color .18s ease, box-shadow .18s ease; }
.coll-card.is-main { background: linear-gradient(160deg, var(--lapis-wash), var(--surface) 70%); }
.coll-card:hover { text-decoration: none; border-color: color-mix(in srgb, var(--lapis) 45%, var(--line)); box-shadow: 0 10px 30px -18px rgba(35, 71, 197, .45); }
.coll-card:hover .coll-title { color: var(--lapis); }

.stack { position: relative; height: 156px; }
.sheet { position: absolute; top: 0; left: 0; width: 98px; aspect-ratio: 2 / 3; object-fit: cover; border-radius: 4px;
  z-index: calc(10 - var(--i)); transform-origin: 30% 100%;
  transform: translateX(calc(var(--i) * 13px)) rotate(calc(var(--i) * 3deg));
  box-shadow: 0 1px 2px rgba(22, 26, 51, .18), 0 8px 18px -8px rgba(22, 26, 51, .35);
  transition: transform .25s ease; }
.sheet:not([style*="--i: 0"]) { filter: brightness(.94); }
.coll-card:hover .sheet { transform: translateX(calc(var(--i) * 17px)) rotate(calc(var(--i) * 4deg)); }
.sheet-ph { display: flex; align-items: flex-end; padding: 12px; background: var(--tint, var(--lapis)); color: #fff; overflow: hidden; }
.sheet-ph > span { width: 100%; font-weight: 700; font-size: .95rem; line-height: 1.3; }
.sheet-ph > .s-ur, .sheet-ph > .s-bsk { font-weight: 400; line-height: 1.9; }
.sheet-ph.is-blank { background: color-mix(in srgb, var(--tint, var(--lapis)) 55%, #fff); }
@media (prefers-reduced-motion: reduce) { .sheet, .coll-card { transition: none; } .coll-card:hover .sheet { transform: translateX(calc(var(--i) * 13px)) rotate(calc(var(--i) * 3deg)); } }

.coll-body { display: flex; flex-direction: column; min-width: 0; }
.coll-title { font-size: 1.3rem; font-weight: 700; letter-spacing: -0.015em; line-height: 1.2; }
.coll-native { font-size: 1.25rem; color: var(--lapis); margin-top: 6px; line-height: 1.5; }
.coll-native.s-ur, .coll-native.s-bsk { line-height: 2; }
.coll-desc { color: var(--muted); margin-top: 8px; line-height: 1.55; }
.coll-count { margin-top: auto; padding-top: 16px; font-weight: 600; color: var(--lapis); font-variant-numeric: tabular-nums; }

/* shelves & book cards */
.page { padding-top: 40px; padding-bottom: 64px; }
.page-head { margin-bottom: 28px; }
.crumbs { color: var(--muted); font-size: .95rem; margin-bottom: 14px; }
.crumbs a { color: var(--muted); }
.result-count { margin: 0; }
.shelf { margin: 72px 0; }
.shelf h2 { margin-bottom: 24px; }
.shelf-head { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; margin-bottom: 24px; }
.shelf-head h2 { margin: 0; }
.shelf-head a { font-weight: 600; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); gap: 40px 24px; }
.card { display: flex; flex-direction: column; gap: 3px; color: var(--ink); }
.card:hover { text-decoration: none; }
.card:hover .card-title { color: var(--lapis); }
.cover { display: block; width: 100%; aspect-ratio: 2 / 3; object-fit: cover; border-radius: var(--r-sm); background: var(--sunk);
  box-shadow: inset 0 0 0 1px rgba(22, 26, 51, .08); margin-bottom: 12px; }
.card:hover .cover { outline: 2px solid var(--lapis); outline-offset: 3px; }
.placeholder { display: flex; align-items: flex-end; padding: 18px; color: #fff; background: var(--tint, #2347C5); overflow: hidden; }
.placeholder .ph-title { font-weight: 700; font-size: 1.15rem; line-height: 1.25; letter-spacing: -0.01em; width: 100%; }
.placeholder .ph-title.s-ur, .placeholder .ph-title.s-bsk { font-weight: 400; line-height: 1.9; }
.placeholder.big { padding: 28px; }
.placeholder.big .ph-title { font-size: 1.9rem; }
.tint-en { --tint: #2347C5; } .tint-ur { --tint: #0E6B62; } .tint-ar { --tint: #7A2E4E; } .tint-fa { --tint: #5B3C99; }
.tint-gu { --tint: #9A5A0E; } .tint-bsk { --tint: #29606F; } .tint-fr { --tint: #33427A; } .tint-sv { --tint: #3F5E2C; }
.card-title { font-weight: 600; line-height: 1.3; }
.card-native { color: var(--muted); font-size: 1rem; text-align: left; }
.card-meta { color: var(--muted); font-size: .9rem; }
.empty { padding: 48px 24px; text-align: center; background: var(--sunk); border-radius: var(--r-md); color: var(--muted); }
.empty p { margin-bottom: 16px; }
.empty p:last-child { margin-bottom: 0; }

/* chips & index lists */
.chips { list-style: none; padding: 0; margin: 0 0 24px; display: flex; flex-wrap: wrap; gap: 8px; }
.chips a { display: inline-flex; gap: 8px; align-items: baseline; padding: 6px 14px; border-radius: 999px; background: var(--lapis-wash); color: var(--lapis-deep); font-weight: 500; }
.chips a:hover { background: var(--lapis); color: var(--on-lapis); text-decoration: none; }
.count { color: var(--muted); font-size: .88em; font-variant-numeric: tabular-nums; }
.chips a:hover .count { color: inherit; }
.index-list { list-style: none; padding: 0; margin: 0; columns: 2 320px; column-gap: 48px; }
.index-list li { break-inside: avoid; border-bottom: 1px solid var(--line); }
.index-list a { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; padding: 14px 0; color: var(--ink); }
.index-list a:hover { color: var(--lapis); text-decoration: none; }
.il-main { display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: baseline; font-weight: 500; }
.il-native { color: var(--muted); font-weight: 400; }

/* filters & pager */
.filters { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 40px; padding: 10px; background: var(--sunk); border-radius: var(--r-md); }
.field { flex: 0 1 190px; }
.field-search { flex: 1 1 280px; }
.filters input, .filters select { border-color: transparent; }
.pager { display: flex; justify-content: center; align-items: center; gap: 20px; margin-top: 56px; }

/* language page title */
.lang-title { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 8px 32px; }
.lang-title h1 { margin: 0; }
.native-big { text-align: left; font-size: clamp(1.9rem, 4vw, 3rem); font-weight: 600; color: var(--lapis); margin: 0 0 .3em; line-height: 1.4; }
.native-big.s-ur, .native-big.s-bsk { font-weight: 400; line-height: 2; }

/* book detail */
.book { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 56px; align-items: start; }
.book-cover { position: sticky; top: 96px; display: flex; flex-direction: column; gap: 16px; }
.book-cover .cover { margin: 0; }
.book-body h1 { font-size: clamp(2rem, 4vw, 3.25rem); }
.subtitle { font-size: 1.25rem; color: var(--muted); }
.facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 20px 32px; margin: 32px 0; padding: 24px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.facts dt { color: var(--muted); font-size: .9rem; }
.facts dd { margin: 2px 0 0; font-weight: 500; }
.prose { max-width: 68ch; }
.prose p:last-child { margin-bottom: 0; }

/* footer */
.site-footer { margin-top: 64px; border-top: 1px solid var(--line); background: var(--surface); }
.footer-row { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 20px 40px; padding-top: 32px; padding-bottom: 32px; }
.footer-row p { margin: 0; color: var(--muted); }
.footer-row strong { color: var(--ink); }
.footer-langs { display: flex; flex-wrap: wrap; gap: 6px 18px; }
.footer-langs a { color: var(--muted); font-size: 1.05rem; }
.footer-langs a:hover { color: var(--lapis); }
.footer-langs .s-ur, .footer-langs .s-bsk { line-height: 1.6; }

/* responsive */
@media (max-width: 1000px) {
  .coll-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .coll-grid-main { max-width: none; }
  .header-search { width: 200px; }
}
@media (max-width: 760px) {
  .wrap { padding: 0 18px; }
  .header-row { flex-wrap: wrap; gap: 4px 12px; padding-top: 10px; padding-bottom: 10px; }
  .main-nav { order: 3; width: 100%; overflow-x: auto; margin: 0 -8px; gap: 0; }
  .main-nav a { padding: 6px 8px; font-size: .95rem; white-space: nowrap; }
  .header-search { width: auto; flex: 1; min-width: 140px; }
  .hero { padding: 48px 0 36px; }
  .lede { font-size: 1.1rem; }
  .big-search button { padding: 0 18px; }
  .coll-grid { grid-template-columns: 1fr; }
  .coll-grid-main { grid-template-columns: 1fr; }
  .coll-card { grid-template-columns: 132px minmax(0, 1fr); gap: 18px; padding: 20px; }
  .stack { height: 150px; }
  .sheet { width: 88px; }
  .book { grid-template-columns: 1fr; gap: 28px; }
  .book-cover { position: static; max-width: 260px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 32px 16px; }
  .shelf { margin: 52px 0; }
}
