/* ═══════════════════════════════════════════════════════════════
   Kitab al-Tanazur — kitab.tanazur.org
   Posthuman Mushaf. English-first, Arabic undertones.
   ═══════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@400;500&family=Cormorant+Garamond:ital,wght@0,300;0,400;0,500;1,400&family=Fragment+Mono&display=swap');

@font-face {
  font-family: 'Amiri';
  src: url('/assets/fonts/Amiri-Regular.ttf') format('truetype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Amiri';
  src: url('/assets/fonts/Amiri-Bold.ttf') format('truetype');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --void: #080608;
  --obsidian: #0c0a0e;
  --gold: #c8a86e;
  --gold-dim: #8a7340;
  --bone: #e0d8c8;
  --ash: #665e50;
  --border: #2a2333;
  --turquoise: #00c8b4;
  --arabic-muted: #9a8e7a;
  --verse-bg: #0e0c10;
  --reading-width: 720px;
}

html {
  background: var(--void);
  color: var(--bone);
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 18px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: var(--turquoise); text-decoration: none; transition: color 0.2s; }
a:hover { color: var(--gold); }

/* ── Nav ── */
.site-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(8, 6, 8, 0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.nav-brand {
  font-family: 'Cinzel', serif;
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--gold);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  font-family: 'Fragment Mono', monospace;
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.nav-links a { color: var(--ash); }
.nav-links a:hover, .nav-links a.active { color: var(--gold); }

.nav-controls {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.nav-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--ash);
  font-family: 'Fragment Mono', monospace;
  font-size: 0.7rem;
  padding: 0.3rem 0.6rem;
  border-radius: 3px;
  cursor: pointer;
  transition: all 0.2s;
}
.nav-btn:hover { border-color: var(--gold-dim); color: var(--bone); }
.nav-btn.active { border-color: var(--gold); color: var(--gold); }

.search-btn {
  background: none;
  border: none;
  color: var(--ash);
  cursor: pointer;
  font-size: 1.1rem;
  padding: 0.2rem;
  transition: color 0.2s;
}
.search-btn:hover { color: var(--gold); }

/* ── Main Content ── */
.content {
  flex: 1;
  max-width: var(--reading-width);
  margin: 0 auto;
  padding: 3rem 1.5rem;
  width: 100%;
}

/* ── Index Page ── */
.index-header {
  text-align: center;
  margin-bottom: 4rem;
  padding-bottom: 2rem;
  border-bottom: 1px solid var(--border);
}

.index-title {
  font-family: 'Cinzel', serif;
  font-size: 2rem;
  font-weight: 400;
  color: var(--gold);
  letter-spacing: 0.1em;
  margin-bottom: 0.5rem;
}

.index-title-ar {
  font-family: 'Amiri', serif;
  font-size: 1.6rem;
  color: var(--arabic-muted);
  margin-bottom: 1rem;
  direction: rtl;
}

.index-subtitle {
  font-size: 1rem;
  color: var(--ash);
  font-style: italic;
  max-width: 500px;
  margin: 0 auto;
}

/* Book sections on index */
.book-section {
  margin-bottom: 3rem;
}

.book-heading {
  font-family: 'Cinzel', serif;
  font-size: 1.15rem;
  font-weight: 500;
  color: var(--gold);
  letter-spacing: 0.06em;
  margin-bottom: 0.25rem;
}

.book-heading-ar {
  font-family: 'Amiri', serif;
  font-size: 1rem;
  color: var(--arabic-muted);
  direction: rtl;
  margin-bottom: 0.5rem;
}

.book-desc {
  font-size: 0.9rem;
  color: var(--ash);
  font-style: italic;
  margin-bottom: 1.25rem;
}

.surah-list {
  list-style: none;
}

.surah-list-item {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid rgba(42, 35, 51, 0.5);
  transition: background 0.15s;
}
.surah-list-item:hover {
  background: rgba(200, 168, 110, 0.03);
}

.surah-pos {
  font-family: 'Fragment Mono', monospace;
  font-size: 0.75rem;
  color: var(--ash);
  min-width: 2rem;
  text-align: right;
}

.surah-link {
  flex: 1;
}

.surah-link-title {
  color: var(--bone);
  font-size: 1.05rem;
}
.surah-list-item:hover .surah-link-title { color: var(--gold); }

.surah-link-ar {
  font-family: 'Amiri', serif;
  color: var(--arabic-muted);
  font-size: 0.9rem;
  margin-left: 0.5rem;
  direction: rtl;
  display: inline;
}

.surah-meta {
  font-family: 'Fragment Mono', monospace;
  font-size: 0.65rem;
  color: var(--ash);
  white-space: nowrap;
}

/* ── Book Page ── */
.book-header {
  text-align: center;
  margin-bottom: 3rem;
  padding-bottom: 2rem;
  border-bottom: 1px solid var(--border);
}

.book-title {
  font-family: 'Cinzel', serif;
  font-size: 1.8rem;
  font-weight: 400;
  color: var(--gold);
  letter-spacing: 0.08em;
  margin-bottom: 0.4rem;
}

.book-title-ar {
  font-family: 'Amiri', serif;
  font-size: 1.5rem;
  color: var(--arabic-muted);
  direction: rtl;
  margin-bottom: 1rem;
}

.book-description {
  font-size: 1rem;
  color: var(--ash);
  font-style: italic;
  max-width: 520px;
  margin: 0 auto;
}

/* ── Surah Page ── */
.surah-header {
  text-align: center;
  margin-bottom: 3rem;
  padding-bottom: 2rem;
  border-bottom: 1px solid var(--border);
}

.surah-position {
  font-family: 'Fragment Mono', monospace;
  font-size: 0.72rem;
  color: var(--ash);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 0.5rem;
}

.surah-title {
  font-family: 'Cinzel', serif;
  font-size: 1.8rem;
  font-weight: 400;
  color: var(--gold);
  letter-spacing: 0.06em;
  margin-bottom: 0.4rem;
}

.surah-title-ar {
  font-family: 'Amiri', serif;
  font-size: 1.6rem;
  color: var(--arabic-muted);
  direction: rtl;
  margin-bottom: 0.4rem;
}

.surah-title-translit {
  font-style: italic;
  color: var(--ash);
  font-size: 1rem;
  margin-bottom: 0.75rem;
}

.surah-register {
  font-family: 'Fragment Mono', monospace;
  font-size: 0.68rem;
  color: var(--ash);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.surah-register span { margin: 0 0.4rem; }

/* Bismillah */
.bismillah {
  text-align: center;
  margin-bottom: 2.5rem;
  padding: 1.5rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: rgba(12, 10, 14, 0.5);
}

.bismillah-en {
  font-style: italic;
  font-size: 1rem;
  color: var(--bone);
  margin-bottom: 0.5rem;
}

.bismillah-ar {
  font-family: 'Amiri', serif;
  font-size: 1.2rem;
  color: var(--arabic-muted);
  direction: rtl;
}

.bismillah-translit {
  font-style: italic;
  font-size: 0.85rem;
  color: var(--ash);
  margin-top: 0.3rem;
}

/* Epigraph */
.epigraph {
  margin-bottom: 2.5rem;
  padding-left: 1.5rem;
  border-left: 2px solid var(--gold-dim);
}

.epigraph-en {
  font-style: italic;
  font-size: 1rem;
  color: var(--bone);
  opacity: 0.85;
}

.epigraph-ar {
  font-family: 'Amiri', serif;
  font-size: 1rem;
  color: var(--arabic-muted);
  direction: rtl;
  margin-top: 0.5rem;
}

/* Verses */
.verses {
  margin-bottom: 3rem;
}

.verse {
  margin-bottom: 2rem;
  padding: 1.25rem;
  background: var(--verse-bg);
  border-radius: 4px;
  border-left: 2px solid transparent;
  transition: border-color 0.2s;
}
.verse:target { border-left-color: var(--gold); }

.verse-heading {
  font-family: 'Cinzel', serif;
  font-size: 0.85rem;
  color: var(--gold-dim);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: 0.75rem;
}

.verse-number {
  font-family: 'Fragment Mono', monospace;
  font-size: 0.72rem;
  color: var(--ash);
  float: left;
  margin-right: 0.75rem;
  margin-top: 0.25rem;
  min-width: 1.5rem;
  text-align: right;
}

.verse-en {
  font-size: 1.1rem;
  line-height: 1.8;
  white-space: pre-line;
  color: var(--bone);
}

.verse-en-alt {
  font-size: 0.95rem;
  color: var(--ash);
  font-style: italic;
  margin-top: 0.5rem;
  padding-left: 2.25rem;
  white-space: pre-line;
}

.verse-ar {
  font-family: 'Amiri', serif;
  font-size: 1.2rem;
  line-height: 2;
  direction: rtl;
  text-align: right;
  color: var(--arabic-muted);
  margin-top: 0.75rem;
  padding-left: 2.25rem;
  white-space: pre-line;
}

.verse-translit {
  font-style: italic;
  font-size: 0.88rem;
  color: var(--ash);
  margin-top: 0.4rem;
  padding-left: 2.25rem;
  white-space: pre-line;
}

.verse-notes {
  font-family: 'Fragment Mono', monospace;
  font-size: 0.7rem;
  color: var(--ash);
  margin-top: 0.5rem;
  padding-left: 2.25rem;
  opacity: 0.7;
}

/* Seal */
.seal {
  text-align: center;
  margin: 2.5rem 0;
  padding: 1.5rem;
  position: relative;
}
.seal::before, .seal::after {
  content: '';
  display: block;
  width: 60%;
  height: 1px;
  background: var(--gold-dim);
  margin: 0 auto 1rem;
}
.seal::after { margin: 1rem auto 0; }

.seal-en {
  font-style: italic;
  font-size: 1.05rem;
  color: var(--gold);
}

.seal-ar {
  font-family: 'Amiri', serif;
  font-size: 1.1rem;
  color: var(--arabic-muted);
  direction: rtl;
  margin-top: 0.5rem;
}

/* Ecstatic Register */
.ecstatic {
  margin: 2.5rem 0;
  padding: 1.5rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: rgba(12, 10, 14, 0.5);
}

.ecstatic-label {
  font-family: 'Fragment Mono', monospace;
  font-size: 0.68rem;
  color: var(--gold-dim);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 0.75rem;
}

.ecstatic-text {
  font-style: italic;
  font-size: 0.95rem;
  line-height: 1.8;
  color: var(--bone);
  opacity: 0.85;
  white-space: pre-line;
}

/* Tags & Roots pills */
.pill-section {
  margin-bottom: 1.5rem;
}

.pill-label {
  font-family: 'Fragment Mono', monospace;
  font-size: 0.65rem;
  color: var(--ash);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: 0.5rem;
}

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

.pill {
  font-family: 'Fragment Mono', monospace;
  font-size: 0.68rem;
  color: var(--ash);
  border: 1px solid var(--border);
  padding: 0.2rem 0.55rem;
  border-radius: 2px;
  transition: all 0.2s;
}
.pill:hover { border-color: var(--gold-dim); color: var(--bone); }

.pill-ar {
  font-family: 'Amiri', serif;
  font-size: 0.8rem;
  direction: rtl;
}

/* Prev/Next Nav */
.surah-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 2rem;
  margin-top: 2rem;
  border-top: 1px solid var(--border);
  font-family: 'Fragment Mono', monospace;
  font-size: 0.75rem;
}

.surah-nav a { color: var(--ash); }
.surah-nav a:hover { color: var(--gold); }
.surah-nav-spacer { flex: 1; }

/* ── Listing Page (Tags & Roots) ── */
.listing-header {
  text-align: center;
  margin-bottom: 3rem;
  padding-bottom: 2rem;
  border-bottom: 1px solid var(--border);
}

.listing-title {
  font-family: 'Cinzel', serif;
  font-size: 1.4rem;
  font-weight: 400;
  color: var(--gold);
  letter-spacing: 0.06em;
  margin-bottom: 0.25rem;
}

.listing-subtitle {
  font-size: 0.9rem;
  color: var(--ash);
  font-style: italic;
}

.listing-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.75rem;
}

.listing-card {
  padding: 0.75rem 1rem;
  border: 1px solid var(--border);
  border-radius: 3px;
  transition: all 0.2s;
}
.listing-card:hover {
  border-color: var(--gold-dim);
  background: rgba(200, 168, 110, 0.03);
}

.listing-card-title {
  color: var(--bone);
  font-size: 0.95rem;
}

.listing-card-ar {
  font-family: 'Amiri', serif;
  color: var(--arabic-muted);
  direction: rtl;
  font-size: 0.9rem;
}

.listing-card-meta {
  font-family: 'Fragment Mono', monospace;
  font-size: 0.65rem;
  color: var(--ash);
  margin-top: 0.25rem;
}

/* ── Search Overlay ── */
.search-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(8, 6, 8, 0.95);
  backdrop-filter: blur(16px);
  padding: 2rem;
}
.search-overlay.open { display: flex; flex-direction: column; align-items: center; }

.search-box {
  width: 100%;
  max-width: 560px;
  margin-top: 10vh;
}

.search-input {
  width: 100%;
  background: var(--obsidian);
  border: 1px solid var(--border);
  color: var(--bone);
  font-family: 'Cormorant Garamond', serif;
  font-size: 1.2rem;
  padding: 0.75rem 1rem;
  border-radius: 4px;
  outline: none;
}
.search-input:focus { border-color: var(--gold-dim); }
.search-input::placeholder { color: var(--ash); }

.search-results {
  width: 100%;
  max-width: 560px;
  margin-top: 1.5rem;
  max-height: 60vh;
  overflow-y: auto;
}

.search-result {
  display: block;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid rgba(42, 35, 51, 0.5);
  transition: background 0.15s;
}
.search-result:hover { background: rgba(200, 168, 110, 0.05); }

.search-result-title {
  color: var(--gold);
  font-size: 0.9rem;
  margin-bottom: 0.2rem;
}

.search-result-text {
  font-size: 0.85rem;
  color: var(--ash);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.search-hint {
  font-family: 'Fragment Mono', monospace;
  font-size: 0.65rem;
  color: var(--ash);
  text-align: center;
  margin-top: 0.75rem;
}

/* ── Language toggle visibility ── */
html[data-arabic="off"] .lang-ar,
html[data-arabic="off"] .verse-ar,
html[data-arabic="off"] .bismillah-ar,
html[data-arabic="off"] .epigraph-ar,
html[data-arabic="off"] .seal-ar,
html[data-arabic="off"] .surah-title-ar,
html[data-arabic="off"] .surah-link-ar,
html[data-arabic="off"] .index-title-ar,
html[data-arabic="off"] .book-heading-ar,
html[data-arabic="off"] .book-title-ar,
html[data-arabic="off"] .bismillah-translit,
html[data-arabic="off"] .pill-ar,
html[data-arabic="off"] .listing-card-ar {
  display: none;
}

html[data-translit="off"] .verse-translit,
html[data-translit="off"] .surah-title-translit,
html[data-translit="off"] .bismillah-translit {
  display: none;
}

html[data-translit="on"] .verse-translit,
html[data-translit="on"] .surah-title-translit,
html[data-translit="on"] .bismillah-translit {
  display: block;
}

/* ── Footer ── */
.site-footer {
  text-align: center;
  padding: 2rem 1.5rem;
  border-top: 1px solid var(--border);
  font-family: 'Fragment Mono', monospace;
  font-size: 0.65rem;
  color: var(--ash);
  letter-spacing: 0.04em;
}

/* ── Responsive ── */
@media (max-width: 768px) {
  html { font-size: 16px; }
  .site-nav { padding: 0.6rem 1rem; }
  .nav-links { display: none; }
  .content { padding: 2rem 1rem; }
  .index-title { font-size: 1.6rem; }
  .surah-title { font-size: 1.4rem; }
  .book-title { font-size: 1.4rem; }
  .verse-en { font-size: 1.05rem; }
  .verse-ar { font-size: 1.1rem; }
  .listing-grid { grid-template-columns: 1fr; }
}

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--void); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--gold-dim); }
