/* Minimal, no framework, no external fonts/resources — the site has to work
   fully offline, so nothing here may reach off-page. */

:root {
  --suhuf-font-scale: 1;
  --bg: #fdfdfb;
  --fg: #1a1a1a;
  --muted: #6b6b6b;
  --border: #e0ddd6;
  --link: #1d5c3a;
  --mark-bg: #ffe58a;
  --mark-fg: #1a1a1a;
  --card-bg: #f4f2ec;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16171a;
    --fg: #eceae6;
    --muted: #9a9a9a;
    --border: #33343a;
    --link: #7fd9a8;
    --mark-bg: #6b5400;
    --mark-fg: #fff3c9;
    --card-bg: #1f2024;
  }
}

* {
  box-sizing: border-box;
}

html {
  color-scheme: light dark;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  line-height: 1.5;
}

a {
  color: var(--link);
}

main {
  max-width: 40rem;
  margin: 0 auto;
  padding: 1rem;
}

.site-header {
  border-bottom: 1px solid var(--border);
  padding: 0.5rem 1rem;
}

.site-header .bar {
  max-width: 40rem;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  padding: 0.25rem 0;
}

.brand {
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}

.search-form {
  display: flex;
  gap: 0.4rem;
  flex: 1;
  min-width: 12rem;
}

.search-form input {
  flex: 1;
  min-width: 0;
}

.controls {
  font-size: 0.85rem;
  color: var(--muted);
}

.controls select,
.controls button,
.controls input {
  font-size: inherit;
}

input,
select,
button {
  font-family: inherit;
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 0.3rem;
  background: var(--bg);
  color: var(--fg);
}

button {
  cursor: pointer;
}

:focus-visible {
  outline: 2px solid var(--link);
  outline-offset: 2px;
}

.breadcrumbs {
  font-size: 0.85rem;
  color: var(--muted);
}

h1 {
  font-size: 1.6rem;
  margin: 0.4rem 0 1rem;
}

.ar-name {
  color: var(--muted);
  font-size: 1.1rem;
  font-weight: 400;
}

.chapter-nav {
  display: flex;
  justify-content: space-between;
  margin: 0.75rem 0;
  font-size: 0.9rem;
}

.verse {
  display: block;
  margin: 1.1rem 0;
  padding-top: 0.2rem;
  scroll-margin-top: 5rem;
}

.verse:target {
  background: color-mix(in srgb, var(--mark-bg) 35%, transparent);
  border-radius: 0.3rem;
}

.vn {
  display: inline-block;
  min-width: 1.6rem;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.8rem;
  vertical-align: super;
  margin-right: 0.3rem;
}

p.tr,
p.orig,
p.opening {
  margin: 0.3rem 0;
  font-size: calc(1.05rem * var(--suhuf-font-scale));
}

p.tr {
  font-family: Georgia, "Times New Roman", serif;
}

p.omitted {
  color: var(--muted);
  font-style: italic;
}

p[lang="ar"] {
  font-family: "Noto Naskh Arabic", "Amiri", "Scheherazade New", "Traditional Arabic", serif;
  font-size: calc(1.5rem * var(--suhuf-font-scale));
  line-height: 2;
}

p[lang="he"] {
  font-family: "Noto Serif Hebrew", "SBL Hebrew", "Ezra SIL", "David", serif;
  font-size: calc(1.3rem * var(--suhuf-font-scale));
  line-height: 1.9;
}

[dir="rtl"] {
  direction: rtl;
  text-align: right;
}

mark {
  background: var(--mark-bg);
  color: var(--mark-fg);
}

.rl {
  color: #b23b3b;
}

@media (prefers-color-scheme: dark) {
  .rl {
    color: #ff8b8b;
  }
}

sup.fn a,
sup.xr {
  font-size: 0.7rem;
  text-decoration: none;
  cursor: help;
}

.footnotes {
  margin-top: 2rem;
  border-top: 1px solid var(--border);
  padding-top: 1rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.footnotes ol {
  padding-left: 1.2rem;
}

.book-list ul,
.book-list ol {
  columns: 2;
  list-style: none;
  padding: 0;
  column-gap: 2rem;
}

.book-list li {
  break-inside: avoid;
  padding: 0.25rem 0;
}

.book-list .num {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  display: inline-block;
  min-width: 2.2rem;
}

.book-list .meta {
  display: block;
  color: var(--muted);
  font-size: 0.8em;
  padding-left: 2.2rem;
}

.book-list .ar-name {
  margin-left: 0.4rem;
  font-size: 1.05em;
}

@media (max-width: 40rem) {
  .book-list ul,
  .book-list ol {
    columns: 1;
  }
}

.chapter-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.chapter-link {
  display: inline-block;
  min-width: 2.2rem;
  text-align: center;
  padding: 0.3rem;
  border: 1px solid var(--border);
  border-radius: 0.3rem;
  text-decoration: none;
}

.offline-panel {
  margin: 1rem 0;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 0.4rem;
  background: var(--card-bg);
}

.hit {
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border);
}

.hit .edition-name {
  color: var(--muted);
  font-size: 0.8rem;
}

.book-jump-card {
  display: block;
  padding: 0.75rem;
  margin-bottom: 1rem;
  background: var(--card-bg);
  border-radius: 0.4rem;
  text-decoration: none;
  font-weight: 600;
}

.hint,
.offline-search-notice {
  color: var(--muted);
  font-size: 0.85rem;
}

.site-footer {
  max-width: 40rem;
  margin: 2rem auto 0;
  padding: 1rem;
  border-top: 1px solid var(--border);
  font-size: 0.8rem;
  color: var(--muted);
}

.tagline {
  font-style: italic;
}

@media (prefers-reduced-motion: reduce) {
  * {
    scroll-behavior: auto !important;
    transition: none !important;
    animation: none !important;
  }
}

@media print {
  .site-header,
  .site-footer,
  .chapter-nav,
  .offline-panel,
  .search-form {
    display: none !important;
  }
  main {
    max-width: none;
  }
}

.tanzil-notice {
  margin: 1rem 0;
  padding: 0.6rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: 0.3rem;
  background: var(--card-bg);
}

.tanzil-notice .small {
  font-size: 0.8rem;
  color: var(--muted);
}
