/* ============================================================
   Concepts of the Qur'an — stylesheet
   Light mode is the default; dark mode follows system preference
   unless overridden via the theme toggle (data attribute on <html>).
   ============================================================ */

:root {
  /* Surfaces */
  --bg: #fdfbf6;
  --bg-elev: #ffffff;
  --bg-soft: #f5f0e3;
  --bg-sunken: #efe9d9;

  /* Text */
  --fg: #1a201d;
  --fg-soft: #5a625e;
  --fg-mute: #8a8f8a;

  /* Borders & accents */
  --border: rgba(28, 36, 33, 0.10);
  --border-strong: rgba(28, 36, 33, 0.22);
  --accent: #0f6e56;
  --accent-strong: #04342c;
  --accent-soft: #e1f5ee;
  --accent-soft-fg: #04342c;
  --gold: #854f0b;
  --gold-soft: #faeeda;

  /* Type & layout */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, system-ui, 'Segoe UI', Roboto, sans-serif;
  --font-serif: 'Amiri', 'Scheherazade New', 'Noto Naskh Arabic', Georgia, serif;
  --font-mono: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  --radius: 8px;
  --radius-lg: 12px;
  --maxw: 760px;
}

/* Dark mode — applied either by system preference (when no manual override)
   or by an explicit data-theme="dark" on <html>. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1411;
    --bg-elev: #161b18;
    --bg-soft: #1c221e;
    --bg-sunken: #232a26;
    --fg: #ebe6d8;
    --fg-soft: #a8aca0;
    --fg-mute: #6a6e63;
    --border: rgba(235, 230, 216, 0.10);
    --border-strong: rgba(235, 230, 216, 0.20);
    --accent: #5dcaa5;
    --accent-strong: #9fe1cb;
    --accent-soft: #0a3d30;
    --accent-soft-fg: #9fe1cb;
    --gold: #f0b95a;
    --gold-soft: #3a2a0a;
  }
}

:root[data-theme="dark"] {
  --bg: #0f1411;
  --bg-elev: #161b18;
  --bg-soft: #1c221e;
  --bg-sunken: #232a26;
  --fg: #ebe6d8;
  --fg-soft: #a8aca0;
  --fg-mute: #6a6e63;
  --border: rgba(235, 230, 216, 0.10);
  --border-strong: rgba(235, 230, 216, 0.20);
  --accent: #5dcaa5;
  --accent-strong: #9fe1cb;
  --accent-soft: #0a3d30;
  --accent-soft-fg: #9fe1cb;
  --gold: #f0b95a;
  --gold-soft: #3a2a0a;
}

/* ---------------- Reset ---------------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button { font: inherit; color: inherit; }
input { font: inherit; }
h1, h2, h3, p { margin: 0; }

.qc-skip {
  position: absolute; left: -9999px; top: auto;
  width: 1px; height: 1px; overflow: hidden;
}
.qc-skip:focus {
  position: fixed; left: 12px; top: 12px;
  width: auto; height: auto; padding: 8px 12px;
  background: var(--bg-elev); border: 1px solid var(--border-strong);
  border-radius: var(--radius); z-index: 100;
}

/* ---------------- Frame & header ---------------- */
.qc-frame {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 32px 20px 80px;
}

.qc-header {
  position: relative;
  text-align: center;
  padding: 8px 0 28px;
  margin-bottom: 8px;
}
.qc-decoration { color: var(--fg-soft); margin-bottom: 14px; }
.qc-decoration svg { display: block; margin: 0 auto; }
.qc-mobile-motif { display: none; color: var(--fg-soft); }

.qc-header h1 {
  font-size: 28px;
  font-weight: 500;
  letter-spacing: -0.01em;
  margin: 0 0 6px;
}
.qc-subtitle {
  font-size: 14px;
  color: var(--fg-soft);
}

.qc-about-trigger {
  display: inline-block;
  background: none;
  border: 0;
  padding: 4px 0;
  margin-top: 6px;
  font-family: inherit;
  font-size: 12px;
  color: var(--fg-mute);
  cursor: pointer;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  text-decoration-color: var(--border-strong);
  transition: color 0.15s, text-decoration-color 0.15s;
}
.qc-about-trigger:hover {
  color: var(--fg-soft);
  text-decoration-color: var(--fg-soft);
}
.qc-about-trigger[aria-expanded="true"] {
  color: var(--accent);
  text-decoration-color: var(--accent);
}

.qc-about-panel {
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  width: calc(100% - 8px);
  max-width: 380px;
  background: var(--bg-elev);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-top: 4px;
  font-size: 13px;
  line-height: 1.65;
  color: var(--fg-soft);
  text-align: left;
  z-index: 50;
}
.qc-about-panel[hidden] { display: none; }
.qc-about-panel p { margin: 0 0 8px; }
.qc-about-panel p:last-child { margin: 0; }
.qc-about-panel strong { color: var(--fg); font-weight: 500; }
.qc-about-arabic {
  font-family: var(--font-serif);
  direction: rtl;
  unicode-bidi: isolate;
  color: var(--fg);
}

.qc-theme-toggle {
  position: absolute;
  top: 0;
  right: 0;
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 2px;
  background: var(--bg-elev);
}
.qc-theme-toggle button {
  width: 28px; height: 28px;
  border: 0;
  background: transparent;
  color: var(--fg-mute);
  border-radius: 999px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
}
.qc-theme-toggle button:hover { color: var(--fg); }
.qc-theme-toggle button[aria-pressed="true"] {
  background: var(--bg-soft);
  color: var(--accent);
}

/* ---------------- Search & filters ---------------- */
.qc-search-wrap {
  margin-bottom: 14px;
  position: relative;
}
.qc-search {
  width: 100%;
  height: 42px;
  padding: 0 14px 0 40px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--fg);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.qc-search::placeholder { color: var(--fg-mute); }
.qc-search:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.qc-search-icon {
  position: absolute;
  left: 14px; top: 50%; transform: translateY(-50%);
  color: var(--fg-mute);
  pointer-events: none;
}

.qc-filters {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 22px;
}
.qc-fbtn {
  font-size: 13px;
  padding: 7px 13px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--fg-soft);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.qc-fbtn:hover { color: var(--fg); border-color: var(--border-strong); }
.qc-fbtn[aria-pressed="true"] {
  background: var(--accent-soft);
  color: var(--accent-soft-fg);
  border-color: transparent;
}

/* ---------------- Grid & cards ---------------- */
.qc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 12px;
}

.qc-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.1s, background 0.15s;
  text-align: left;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.qc-card:hover { border-color: var(--border-strong); }
.qc-card:active { transform: scale(0.99); }
.qc-card:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.qc-card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}
.qc-card-tr {
  font-size: 15px;
  font-weight: 500;
  color: var(--fg);
  margin-bottom: 2px;
}
.qc-card-en {
  font-size: 12px;
  color: var(--fg-soft);
}
.qc-arabic {
  font-family: var(--font-serif);
  direction: rtl;
  color: var(--fg);
}
.qc-card-ar {
  font-size: 24px;
  line-height: 1.2;
  flex-shrink: 0;
}
.qc-card-summary {
  font-size: 13px;
  color: var(--fg-soft);
  line-height: 1.55;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.qc-card-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-top: 2px;
}

.qc-pill {
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--bg-soft);
  color: var(--fg-soft);
}
.qc-meta { font-size: 11px; color: var(--fg-mute); }

.qc-empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 40px 20px;
  color: var(--fg-soft);
  font-size: 14px;
}

/* ---------------- Detail view ---------------- */
.qc-back {
  background: none;
  border: 0;
  color: var(--fg-soft);
  cursor: pointer;
  font-size: 13px;
  padding: 6px 8px 6px 0;
  margin-bottom: 12px;
  transition: color 0.15s;
}
.qc-back:hover { color: var(--fg); }

.qc-detail-head {
  text-align: center;
  padding: 8px 0 22px;
}
.qc-detail-arch {
  color: var(--fg-mute);
  margin: 0 auto 12px;
  display: block;
}
.qc-detail-ar {
  font-family: var(--font-serif);
  direction: rtl;
  font-size: 38px;
  font-weight: 500;
  color: var(--fg);
  margin-bottom: 8px;
  line-height: 1.3;
}
.qc-detail-tr {
  font-size: 20px;
  font-weight: 500;
  color: var(--fg);
}
.qc-detail-en {
  font-size: 14px;
  color: var(--fg-soft);
  margin-top: 2px;
}
.qc-detail-cat { margin-top: 12px; }

.qc-detail-summary {
  font-family: var(--font-serif);
  font-size: 16px;
  line-height: 1.75;
  color: var(--fg);
  margin: 0 0 8px;
}

.qc-verse {
  padding: 18px 0;
  border-top: 1px solid var(--border);
}
.qc-verse-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.qc-vref {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-soft-fg);
  font-weight: 500;
}
.qc-vsurah {
  font-size: 12px;
  color: var(--fg-mute);
}
.qc-verse-ar {
  font-family: var(--font-serif);
  direction: rtl;
  font-size: 22px;
  line-height: 2;
  margin-bottom: 12px;
  color: var(--fg);
}
.qc-verse-en {
  font-family: var(--font-serif);
  font-size: 15px;
  line-height: 1.7;
  margin-bottom: 12px;
  color: var(--fg);
}
.qc-verse-context {
  font-size: 13px;
  line-height: 1.65;
  color: var(--fg-soft);
  background: var(--bg-soft);
  padding: 12px 14px;
  border-radius: var(--radius);
}

.qc-actions {
  margin-top: 28px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* ---------------- Footer ---------------- */
.qc-footer {
  margin-top: 48px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
  text-align: center;
  font-size: 13px;
  color: var(--fg-soft);
  line-height: 1.65;
}
.qc-footer p { margin: 0 0 6px; }
.qc-footer-meta { font-size: 12px; color: var(--fg-mute); }
.qc-footer-repo { margin-top: 10px; font-size: 11px; color: var(--fg-mute); letter-spacing: 0.02em; }
.qc-footer-repo a { color: inherit; text-decoration: none; border-bottom: 1px dotted var(--border); padding-bottom: 1px; }
.qc-footer-repo a:hover { color: var(--fg-soft); border-bottom-color: var(--fg-mute); }
.qc-footer em { color: var(--fg); font-style: italic; }

/* ---------------- Loading ---------------- */
.qc-loading {
  text-align: center;
  padding: 60px 20px;
  color: var(--fg-mute);
  font-size: 14px;
}
.qc-error {
  text-align: center;
  padding: 40px 20px;
  color: var(--fg-soft);
  font-size: 14px;
  background: var(--bg-soft);
  border-radius: var(--radius);
}

/* ---------------- Mobile tweaks ----------------
   Compact single-row header: 8-point-star motif + title on the left,
   About trigger on the right. The wide decoration, subtitle, and theme
   toggle are hidden — system default carries the theme. */
@media (max-width: 520px) {
  .qc-frame { padding: 14px 16px 64px; }
  .qc-header {
    display: flex;
    align-items: center;
    gap: 8px;
    text-align: left;
    padding: 0 0 14px;
    margin-bottom: 4px;
  }
  .qc-decoration { display: none; }
  .qc-subtitle { display: none; }
  .qc-theme-toggle { display: none; }
  .qc-mobile-motif { display: inline-block; flex-shrink: 0; }
  .qc-header h1 {
    font-size: 15px;
    font-weight: 500;
    letter-spacing: 0;
    margin: 0;
    flex: 1;
  }
  .qc-about-trigger {
    font-size: 11px;
    margin: 0;
    padding: 2px 0;
    flex-shrink: 0;
  }
  .qc-detail-ar { font-size: 30px; }
  .qc-card-ar { font-size: 20px; }
  .qc-grid { grid-template-columns: 1fr; }
}

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