/* === Custom Properties === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #f5f5f4;
  --surface: #ffffff;
  --surface2: #f0f0ef;
  --border: rgba(0,0,0,0.09);
  --text: #111111;
  --muted: #6b7280;
  --faint: #9ca3af;
  --accent: #7c5c2e;
  --accent-bg: #fdf8f0;

  --radius: 14px;
  --radius-sm: 8px;
  --max-width: 900px;

  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08), 0 2px 4px rgba(0,0,0,0.04);
}

[data-theme="dark"] {
  --bg: #0f0f0e;
  --surface: #1a1a19;
  --surface2: #242423;
  --border: rgba(255,255,255,0.08);
  --text: #f2f2f0;
  --muted: #9ca3af;
  --faint: #6b7280;
  --accent: #c9a05a;
  --accent-bg: #1c1710;
}

html { scroll-behavior: smooth; }

/* === Body === */
body {
  font-family: 'Inter', -apple-system, sans-serif;
  font-size: 1rem;
  line-height: 1.65;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  transition: background 0.2s, color 0.2s;
}

/* === Scroll progress bar === */
#progress-bar {
  position: fixed;
  top: 0;
  left: 0;
  height: 2px;
  width: 0%;
  background: var(--accent);
  z-index: 200;
  transition: width 0.1s linear;
}

/* === Header / Nav === */
header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(245, 245, 244, 0.9);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 0 2rem;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: background 0.2s;
}

[data-theme="dark"] header {
  background: rgba(15, 15, 14, 0.9);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 2rem;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.site-banner {
  height: 44px;
  width: auto;
  display: block;
}

nav {
  display: flex;
  gap: 1.75rem;
  list-style: none;
  align-items: center;
}

nav a {
  text-decoration: none;
  color: var(--muted);
  font-family: 'Inter', -apple-system, sans-serif;
  font-size: 0.875rem;
  font-weight: 400;
  transition: color 0.2s;
}

nav a:hover { color: var(--text); }

nav a.active {
  color: var(--accent);
  font-weight: 500;
}

/* === Theme Toggle === */
.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: 100px;
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--muted);
  transition: color 0.2s, background 0.2s;
  flex-shrink: 0;
}

.theme-toggle:hover {
  color: var(--text);
  background: var(--surface2);
}

.theme-toggle svg { width: 15px; height: 15px; }

/* === Layout === */
main, footer {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 2rem;
}

main {
  padding-top: 3.5rem;
  padding-bottom: 5rem;
}

footer {
  border-top: 1px solid var(--border);
  padding-top: 1.5rem;
  padding-bottom: 2rem;
  font-size: 0.8rem;
  color: var(--faint);
}

.footer-inner {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.footer-name { color: var(--muted); font-weight: 500; }
.footer-sep { color: var(--faint); }

footer a {
  color: var(--faint);
  text-decoration: underline;
  text-underline-offset: 3px;
}

footer a:hover { color: var(--muted); }

/* === Typography === */
h1, h2, h3 {
  font-weight: 600;
  line-height: 1.2;
  color: var(--text);
  letter-spacing: -0.01em;
}

h1 {
  font-size: clamp(1.7rem, 3.5vw, 2.1rem);
  margin-bottom: 1rem;
  letter-spacing: -0.03em;
}

h2 {
  font-size: 1.35rem;
  font-weight: 500;
  margin-bottom: 0.6rem;
}

h3 {
  font-size: 1.1rem;
  font-weight: 500;
}

p { margin-bottom: 1.25rem; }
p:last-child { margin-bottom: 0; }

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2rem 0;
}

/* === Section label (eyebrow text) === */
.section-label {
  font-family: 'Inter', -apple-system, sans-serif;
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--faint);
  margin-bottom: 0.75rem;
}

/* === Lists === */
ul {
  list-style: none;
  padding-left: 0;
}

ul li {
  padding-left: 1.25rem;
  text-indent: -1.25rem;
}

ul li::before {
  content: "– ";
  color: var(--faint);
}

ol {
  padding-left: 1.5rem;
}

li { margin-bottom: 0.4rem; }

/* === Entry listing (fatawa, works, etc.) === */
.entry-list {
  margin-top: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.entry-list li {
  padding-left: 0;
  text-indent: 0;
  margin-bottom: 0;
}

.entry-list li::before { content: none; }

.entry-list li a {
  display: block;
  padding: 1rem 1.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 1.075rem;
  font-family: 'EB Garamond', Georgia, serif;
  line-height: 1.5;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}

.entry-list li a:hover {
  border-color: var(--accent);
  background: var(--surface);
  box-shadow: var(--shadow-md);
  text-decoration: none;
  color: var(--text);
}

/* === Search === */
.search-container {
  margin-top: 2rem;
}

#search-input {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: 'Inter', -apple-system, sans-serif;
  font-size: 0.95rem;
  padding: 0.65rem 1rem;
  outline: none;
  transition: border-color 0.2s, background 0.2s;
  -webkit-appearance: none;
  appearance: none;
}

#search-input:focus {
  border-color: var(--accent);
}

#search-input::placeholder {
  color: var(--faint);
}

.search-results {
  margin-top: 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

a.search-result {
  display: block;
  padding: 0.75rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 1rem;
  transition: border-color 0.15s;
}

a.search-result:hover {
  border-color: var(--accent);
  text-decoration: none;
}

p.search-result {
  color: var(--faint);
  font-family: 'Inter', -apple-system, sans-serif;
  font-size: 0.875rem;
  margin: 0;
  padding: 0.5rem 0;
}

.result-type {
  font-family: 'Inter', -apple-system, sans-serif;
  font-size: 0.68rem;
  font-weight: 500;
  color: var(--faint);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-right: 0.6rem;
  background: var(--surface2);
  padding: 2px 7px;
  border-radius: 100px;
}

/* === Arabic text === */
.arabic {
  font-family: "Scheherazade New", serif;
  direction: rtl;
  unicode-bidi: isolate;
  font-size: 1.3em;
  line-height: 2.1;
  color: var(--text);
}

.questioner {
  color: var(--accent);
}

/* === Page subtitle === */
.page-sub {
  color: var(--muted);
  font-size: 0.9rem;
  margin-top: -0.5rem;
  margin-bottom: 1.75rem;
}

/* === Entry metadata (source, type) === */
.entry-meta {
  display: block;
  font-size: 0.75rem;
  color: var(--faint);
  font-family: 'Inter', -apple-system, sans-serif;
  margin-top: 0.2rem;
  font-weight: 400;
}

/* === Prose back-navigation link === */
.prose-back {
  display: inline-block;
  margin-bottom: 1.75rem;
  font-family: 'Inter', -apple-system, sans-serif;
  font-size: 0.85rem;
  color: var(--faint);
  text-decoration: none;
  transition: color 0.15s;
}

.prose-back:hover {
  color: var(--muted);
  text-decoration: none;
}

/* === Prose (fatawa / works reading view) === */
.prose {
  font-family: 'EB Garamond', Georgia, serif;
  font-size: 1.2rem;
  line-height: 1.8;
  max-width: 680px;
}

.prose h1, .prose h2, .prose h3 {
  font-family: 'Inter', -apple-system, sans-serif;
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--muted);
  margin-top: 2.5rem;
  margin-bottom: 0.75rem;
}

.prose h1 {
  font-size: 1.35rem;
  color: var(--text);
  margin-top: 0;
}

/* Source attribution headings (e.g. ## Source: … in fatawa) */
.prose h2 {
  font-size: 0.85rem;
  font-family: 'Inter', -apple-system, sans-serif;
  font-weight: 400;
  color: var(--faint);
  border-top: 1px solid var(--border);
  padding-top: 1.25rem;
  margin-top: 2.5rem;
  letter-spacing: 0;
}

/* === Hero === */
.hero {
  padding: 3.5rem 0 4rem;
  margin-bottom: 3rem;
}

.hero h1 {
  font-size: clamp(2rem, 5vw, 2.75rem);
  font-weight: 700;
  letter-spacing: -0.04em;
  margin-bottom: 0.6rem;
}

.hero-sub {
  color: var(--muted);
  font-size: 0.975rem;
  margin-bottom: 2rem;
  max-width: 480px;
}

/* === Browse Grid === */
.browse-section {
  margin-bottom: 3.5rem;
}

.browse-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  max-width: 560px;
  gap: 10px;
  margin-top: 1rem;
}

.browse-card {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 1.25rem 1.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.9rem;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.15s, box-shadow 0.15s;
  min-height: 72px;
}

.browse-card:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-md);
  text-decoration: none;
  color: var(--text);
}

.browse-card--cover {
  padding: 0;
  overflow: hidden;
  width: 220px;
  min-height: unset;
  border: none;
  box-shadow: var(--shadow-md);
  flex-shrink: 0;
}

.browse-card--cover img {
  display: block;
  width: 100%;
  height: auto;
  transition: opacity 0.2s;
}

.browse-card--cover:hover {
  border-color: transparent;
  box-shadow: 0 8px 24px rgba(0,0,0,0.18);
}

.browse-card--cover:hover img {
  opacity: 0.9;
}

.browse-card-label {
  font-size: 0.7rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--faint);
  margin-bottom: 0.25rem;
}

/* === Recent section (homepage) === */
.recent-section {
  margin-bottom: 3.5rem;
}

.view-all {
  display: inline-block;
  margin-top: 1rem;
  font-family: 'Inter', -apple-system, sans-serif;
  font-size: 0.85rem;
  color: var(--faint);
  text-decoration: none;
  transition: color 0.15s;
}

.view-all:hover {
  color: var(--accent);
  text-decoration: none;
}

/* === Mobile menu button === */
.menu-toggle {
  display: none;
  background: none;
  border: 1px solid var(--border);
  border-radius: 100px;
  width: 34px;
  height: 34px;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--muted);
  transition: color 0.2s, background 0.2s;
  flex-shrink: 0;
}
.menu-toggle:hover { color: var(--text); background: var(--surface2); }
.menu-toggle svg { width: 15px; height: 15px; }

/* === Mobile dropdown menu === */
.mobile-menu {
  display: none;
  flex-direction: column;
  position: fixed;
  top: 60px;
  left: 0;
  right: 0;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-md);
  z-index: 99;
  padding: 0.5rem 0;
}
.mobile-menu.open { display: flex; }
.mobile-menu a {
  padding: 0.85rem 1.5rem;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 400;
  border-bottom: 1px solid var(--border);
  transition: color 0.15s, background 0.15s;
}
.mobile-menu a:last-child { border-bottom: none; }
.mobile-menu a:hover,
.mobile-menu a.active { color: var(--text); background: var(--surface2); }

/* === Mobile === */
@media (max-width: 700px) {
  header { padding: 0 1rem; }

  #main-nav { display: none; }
  .menu-toggle { display: flex; }

  .site-banner { height: 34px; }

  main, footer {
    padding-left: 1rem;
    padding-right: 1rem;
  }

  main { padding-top: 2.5rem; }

  h1 { font-size: 1.5rem; }
  h2 { font-size: 1.2rem; }

  .hero { padding: 2rem 0 2rem; }
  .hero h1 { font-size: 1.75rem; }

  .browse-grid { grid-template-columns: repeat(2, 1fr); }
  .browse-card--cover { width: 100%; }
}
