/* ── Variables ──────────────────────────────────────────────────────────────── */
:root {
  --bg: #f8f8f5;
  --surface: #ffffff;
  --surface-alt: #f0ede5;
  --text: #1a1a1a;
  --text-muted: #6b6860;
  --accent: #1a6b3a;
  --accent-hover: #155730;
  --accent-light: #e8f4ed;
  --border: #e0ddd5;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.05);
  --radius: 10px;
  --font-body: 'Lora', Georgia, serif;
  --font-ui: 'DM Sans', system-ui, sans-serif;
  --fs-base: 1rem;
  --fs-question: 1.1rem;
  --fs-answer: 1rem;
}

[data-theme="dark"] {
  --bg: #161614;
  --surface: #1f1f1d;
  --surface-alt: #2a2a27;
  --text: #f0ede5;
  --text-muted: #9a9790;
  --accent: #2d9e57;
  --accent-hover: #38b868;
  --accent-light: #1a2e20;
  --border: #333330;
  --shadow: 0 1px 3px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.25);
}

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

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  font-size: var(--fs-base);
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  min-height: 100vh;
  transition: background 0.2s, color 0.2s;
}

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

img { max-width: 100%; display: block; }

/* ── Layout ──────────────────────────────────────────────────────────────────── */
.container {
  max-width: 860px;
  margin: 0 auto;
  padding: 0 1.25rem;
}

/* ── Header ──────────────────────────────────────────────────────────────────── */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem 1.25rem;
  max-width: 860px;
  margin: 0 auto;
}

.site-title {
  font-family: var(--font-body);
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--accent);
  white-space: nowrap;
}

.site-title span {
  display: block;
  font-size: 0.72rem;
  font-family: var(--font-ui);
  font-weight: 400;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--font-ui);
}

.btn-icon {
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.35rem 0.6rem;
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--text-muted);
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  font-family: var(--font-ui);
  white-space: nowrap;
}

.btn-icon:hover {
  background: var(--surface-alt);
  color: var(--text);
  border-color: var(--text-muted);
}

.header-link {
  font-family: var(--font-ui);
  font-size: 0.85rem;
  color: var(--text-muted);
  padding: 0.35rem 0.5rem;
  border-radius: 6px;
  transition: background 0.15s, color 0.15s;
}

.header-link:hover {
  background: var(--surface-alt);
  color: var(--accent);
  text-decoration: none;
}

/* ── Hero / Search ───────────────────────────────────────────────────────────── */
.hero {
  padding: 2.5rem 0 0.75rem;
  text-align: center;
}

.hero-title {
  font-size: 1.6rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.35rem;
}

.hero-subtitle {
  font-size: 0.95rem;
  color: var(--text-muted);
  font-family: var(--font-ui);
  margin-bottom: 0.75rem;
}

.search-wrap {
  position: relative;
  max-width: 580px;
  margin: 0 auto;
}

.search-icon {
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 1rem;
  pointer-events: none;
}

#searchInput {
  width: 100%;
  padding: 0.85rem 1rem 0.85rem 2.8rem;
  font-size: 1rem;
  font-family: var(--font-ui);
  border: 1.5px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

#searchInput:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(26, 107, 58, 0.12);
}

#searchInput::placeholder { color: var(--text-muted); }

.search-meta {
  font-family: var(--font-ui);
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
  min-height: 1.2em;
}

/* ── Category Tabs ───────────────────────────────────────────────────────────── */
.category-tabs {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  padding: 0.5rem 0;
  justify-content: center;
}

.tab-btn {
  font-family: var(--font-ui);
  font-size: 0.82rem;
  font-weight: 500;
  padding: 0.35rem 0.85rem;
  border-radius: 20px;
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  white-space: nowrap;
}

.tab-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.tab-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* ── Q&A Cards ───────────────────────────────────────────────────────────────── */
#qaList {
  padding: 1rem 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.qa-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  box-shadow: var(--shadow);
  transition: box-shadow 0.15s;
}

.qa-card:hover {
  box-shadow: var(--shadow-md);
}

.card-top {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.card-question {
  font-size: var(--fs-question);
  font-weight: 600;
  color: var(--text);
  flex: 1;
  line-height: 1.45;
}

.card-summary {
  font-size: 0.9rem;
  color: var(--text-muted);
  font-family: var(--font-ui);
  margin-bottom: 0.75rem;
}

.card-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
}

.badge {
  font-family: var(--font-ui);
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.2rem 0.6rem;
  border-radius: 20px;
  background: var(--accent-light);
  color: var(--accent);
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.tag {
  font-family: var(--font-ui);
  font-size: 0.72rem;
  color: var(--text-muted);
  background: var(--surface-alt);
  border-radius: 4px;
  padding: 0.15rem 0.45rem;
}

.card-answer {
  display: none;
  font-size: var(--fs-answer);
  color: var(--text);
  border-top: 1px solid var(--border);
  padding-top: 0.85rem;
  margin-top: 0.85rem;
  line-height: 1.75;
}

.card-answer.open {
  display: block;
}

.card-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 0.85rem;
}

.btn-expand {
  font-family: var(--font-ui);
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--accent);
  background: none;
  border: 1.5px solid var(--accent);
  border-radius: 6px;
  padding: 0.3rem 0.75rem;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.btn-expand:hover {
  background: var(--accent);
  color: #fff;
}

.btn-share {
  font-family: var(--font-ui);
  font-size: 0.78rem;
  color: var(--text-muted);
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.3rem 0.65rem;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.btn-share:hover {
  background: var(--surface-alt);
  color: var(--text);
  border-color: var(--text-muted);
}

.source-link {
  font-family: var(--font-ui);
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-left: auto;
}

.source-link:hover { color: var(--accent); }

/* ── No results ──────────────────────────────────────────────────────────────── */
.no-results {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
  font-family: var(--font-ui);
  display: none;
}

.no-results.visible { display: block; }

/* ── Random button ───────────────────────────────────────────────────────────── */
#randomBtn {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 50px;
  padding: 0.7rem 1.2rem;
  font-family: var(--font-ui);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(26, 107, 58, 0.35);
  transition: background 0.15s, transform 0.1s, box-shadow 0.15s;
  z-index: 50;
}

#randomBtn:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(26, 107, 58, 0.4);
}

#randomBtn:active { transform: translateY(0); }

/* ── Toast ───────────────────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 5rem;
  left: 50%;
  transform: translateX(-50%) translateY(10px);
  background: #1a1a1a;
  color: #fff;
  font-family: var(--font-ui);
  font-size: 0.85rem;
  padding: 0.6rem 1.2rem;
  border-radius: 6px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 200;
  white-space: nowrap;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ── Footer ──────────────────────────────────────────────────────────────────── */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 1.5rem 1.25rem;
  text-align: center;
  font-family: var(--font-ui);
  font-size: 0.8rem;
  color: var(--text-muted);
  max-width: 860px;
  margin: 0 auto;
}

.site-footer p + p { margin-top: 0.35rem; }

.site-footer a { color: var(--text-muted); }
.site-footer a:hover { color: var(--accent); }

/* ── About page ──────────────────────────────────────────────────────────────── */
.about-section {
  padding: 2.5rem 0;
}

.sheikh-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  box-shadow: var(--shadow);
  display: flex;
  gap: 2rem;
  align-items: flex-start;
}

.sheikh-photo {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--surface-alt);
  flex-shrink: 0;
  border: 3px solid var(--accent-light);
}

.sheikh-photo-placeholder {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: var(--accent-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.5rem;
  flex-shrink: 0;
}

.sheikh-name {
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.sheikh-credentials {
  font-size: 0.85rem;
  font-family: var(--font-ui);
  color: var(--text-muted);
  margin-bottom: 1rem;
}

.sheikh-bio {
  font-size: 0.95rem;
  line-height: 1.75;
  margin-bottom: 1rem;
}

.social-links {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.social-link {
  font-family: var(--font-ui);
  font-size: 0.82rem;
  font-weight: 500;
  padding: 0.4rem 0.9rem;
  border-radius: 6px;
  border: 1.5px solid var(--border);
  color: var(--text-muted);
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.social-link:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-light);
  text-decoration: none;
}

/* ── Category page ───────────────────────────────────────────────────────────── */
.category-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
  padding: 1.5rem 0 4rem;
}

.category-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  cursor: pointer;
  transition: box-shadow 0.15s, border-color 0.15s, transform 0.1s;
  text-align: center;
  box-shadow: var(--shadow);
}

.category-card:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--accent);
  transform: translateY(-1px);
}

.category-card-icon {
  font-size: 1.75rem;
  margin-bottom: 0.5rem;
}

.category-card-name {
  font-weight: 600;
  font-size: 0.95rem;
  margin-bottom: 0.25rem;
}

.category-card-count {
  font-family: var(--font-ui);
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* ── QA page ─────────────────────────────────────────────────────────────────── */
.qa-full {
  padding: 2rem 0 4rem;
}

.qa-full-question {
  font-size: 1.5rem;
  font-weight: 600;
  line-height: 1.4;
  margin-bottom: 0.5rem;
}

.qa-full-answer {
  font-size: var(--fs-answer);
  line-height: 1.8;
  margin: 1.5rem 0;
}

.related-section {
  margin-top: 3rem;
  border-top: 1px solid var(--border);
  padding-top: 1.5rem;
}

.related-title {
  font-family: var(--font-ui);
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-family: var(--font-ui);
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 1.5rem;
}

.back-link:hover { color: var(--accent); text-decoration: none; }

/* ── Load more ───────────────────────────────────────────────────────────────── */
.load-more-btn {
  display: block;
  margin: 0.5rem auto 3rem;
  padding: 0.65rem 2rem;
  background: var(--surface-alt);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: var(--font-ui);
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.load-more-btn:hover {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* ── Mobile menu toggle ──────────────────────────────────────────────────────── */
.menu-toggle {
  display: none;
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.35rem 0.6rem;
  cursor: pointer;
  font-size: 1rem;
  color: var(--text-muted);
  transition: background 0.15s, color 0.15s;
}

.menu-toggle:hover {
  background: var(--surface-alt);
  color: var(--text);
}

/* ── Responsive ──────────────────────────────────────────────────────────────── */
@media (max-width: 600px) {
  .menu-toggle { display: block; }

  .header-controls {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    flex-direction: column;
    align-items: flex-start;
    padding: 0.75rem 1rem;
    gap: 0.5rem;
    box-shadow: var(--shadow-md);
  }

  .header-controls.open { display: flex; }

  .header-controls .header-link,
  .header-controls .btn-icon {
    width: 100%;
    text-align: left;
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
  }

  .header-controls .header-link:hover,
  .header-controls .btn-icon:hover {
    background: var(--surface-alt);
  }

  .site-header { position: relative; }

  .header-inner { padding: 0.75rem 1rem; flex-wrap: wrap; }
  .hero { padding: 1.5rem 0 0.1rem; }
  .hero-title { font-size: 1.3rem; }
  .search-meta { margin-top: 0.15rem; }
  .category-tabs { padding: 0.2rem 0; gap: 0.3rem; }
  #qaList { padding: 0.5rem 0; }
  .qa-card { padding: 0.75rem 0.85rem; margin-top: 0.25rem; }
  .sheikh-card { flex-direction: column; gap: 1rem; align-items: center; text-align: center; }
  .social-links { justify-content: center; }
  .qa-full-question { font-size: 1.2rem; }
  #randomBtn { bottom: 1rem; right: 1rem; padding: 0.6rem 1rem; }
  .category-grid { grid-template-columns: repeat(2, 1fr); }
}
