/* ================================
   Amal — Global Styles
   Hope has a home.
================================ */

:root {
  /* — Backgrounds — */
  --bg:             #F5F0E8;   /* parchment */
  --bg-card:        #EDE7DB;   /* warm linen */
  --bg-elevated:    #E4DDD0;   /* deep linen */

  /* — Gold accent — */
  --accent:         #A0601A;   /* deep amber */
  --accent-mid:     #7A4510;   /* dark ochre */
  --accent-light:   rgba(160,96,26,0.08);
  --accent-text:    #7A4510;

  /* — Amber (maps to gold-mid) — */
  --amber:          #7A4510;
  --amber-light:    #F7EEE0;

  /* — Borders — */
  --border:         rgba(28,22,16,0.09);
  --border-strong:  rgba(28,22,16,0.15);
  --border-gold:    rgba(160,96,26,0.28);

  /* — Text — */
  --text:           #1C1610;
  --text-muted:     rgba(28,22,16,0.55);
  --text-subtle:    rgba(28,22,16,0.32);

  /* — Shadows — */
  --shadow:         0 2px 16px rgba(28,22,16,0.10);
  --shadow-gold:    0 0 40px rgba(160,96,26,0.10);

  /* — Typography — */
  --font:           'Crimson Pro', Georgia, serif;
  --font-ui:        'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-arabic:    'Lateef', serif;
  --font-mono:      'DM Mono', monospace;

  /* — Layout — */
  --radius:         10px;
  --radius-lg:      16px;
  --max-w:          860px;
  --nav-h:          60px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:             #080610;
    --bg-card:        #0e0c1a;
    --bg-elevated:    #14112a;

    --accent:         #F5C97A;
    --accent-mid:     #C8884A;
    --accent-light:   rgba(245,201,122,0.10);
    --accent-text:    #F5C97A;

    --amber:          #C8884A;
    --amber-light:    rgba(245,201,122,0.08);

    --border:         rgba(255,255,255,0.07);
    --border-strong:  rgba(255,255,255,0.12);
    --border-gold:    rgba(245,201,122,0.22);

    --text:           #e8e0d8;
    --text-muted:     rgba(232,224,216,0.55);
    --text-subtle:    rgba(232,224,216,0.30);

    --shadow:         0 4px 24px rgba(0,0,0,0.40);
    --shadow-gold:    0 0 40px rgba(245,201,122,0.08);
  }
}

:root[data-theme="dark"] {
  --bg:             #080610;
  --bg-card:        #0e0c1a;
  --bg-elevated:    #14112a;

  --accent:         #F5C97A;
  --accent-mid:     #C8884A;
  --accent-light:   rgba(245,201,122,0.10);
  --accent-text:    #F5C97A;

  --amber:          #C8884A;
  --amber-light:    rgba(245,201,122,0.08);

  --border:         rgba(255,255,255,0.07);
  --border-strong:  rgba(255,255,255,0.12);
  --border-gold:    rgba(245,201,122,0.22);

  --text:           #e8e0d8;
  --text-muted:     rgba(232,224,216,0.55);
  --text-subtle:    rgba(232,224,216,0.30);

  --shadow:         0 4px 24px rgba(0,0,0,0.40);
  --shadow-gold:    0 0 40px rgba(245,201,122,0.08);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: var(--font-ui);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  padding-top: calc(var(--nav-h) + 1rem);
  padding-bottom: 3rem;
  background-image:
    repeating-linear-gradient( 60deg, transparent, transparent 40px, rgba(28,22,16,0.022) 40px, rgba(28,22,16,0.022) 41px),
    repeating-linear-gradient(-60deg, transparent, transparent 40px, rgba(28,22,16,0.022) 40px, rgba(28,22,16,0.022) 41px);
}

@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]) body {
    background-image:
      repeating-linear-gradient( 60deg, transparent, transparent 40px, rgba(255,255,255,0.008) 40px, rgba(255,255,255,0.008) 41px),
      repeating-linear-gradient(-60deg, transparent, transparent 40px, rgba(255,255,255,0.008) 40px, rgba(255,255,255,0.008) 41px);
  }
}

html[data-theme="dark"] body {
  background-image:
    repeating-linear-gradient( 60deg, transparent, transparent 40px, rgba(255,255,255,0.008) 40px, rgba(255,255,255,0.008) 41px),
    repeating-linear-gradient(-60deg, transparent, transparent 40px, rgba(255,255,255,0.008) 40px, rgba(255,255,255,0.008) 41px);
}

/* ---- Typography ---- */

h1 { font-family: var(--font); font-size: 2rem; font-weight: normal; line-height: 1.2; }
h2 { font-family: var(--font); font-size: 1.4rem; font-weight: normal; line-height: 1.3; }
h3 { font-size: 1rem; font-weight: 500; }
p { color: var(--text-muted); line-height: 1.7; }

.arabic {
  font-family: var(--font-arabic);
  font-size: 1.6rem;
  line-height: 2;
  direction: rtl;
  text-align: right;
  color: var(--text);
}

.transliteration {
  font-style: italic;
  color: var(--text-muted);
  font-size: 0.95rem;
  line-height: 1.8;
}

/* ---- Layout ---- */

.page {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 1.5rem 1rem;
}

.page-header {
  padding: 2.5rem 0 2rem;
  margin-bottom: 1.75rem;
}

.page-header::before {
  content: '';
  display: block;
  width: 2.5rem;
  height: 2px;
  background: var(--accent);
  margin-bottom: 1.1rem;
  opacity: 0.65;
}

.page-header h1 {
  font-size: 2rem;
}

.page-header p {
  margin-top: 0.5rem;
  font-size: 1rem;
}

/* ---- Navigation (top header) ---- */

nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--nav-h);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: flex-start;
  align-items: center;
  z-index: 100;
  padding: 0 1.5rem;
  padding-top: env(safe-area-inset-top);
  gap: 0.25rem;
}

.nav-brand {
  font-family: var(--font);
  font-size: 1.4rem;
  color: var(--text);
  text-decoration: none;
  margin-right: auto;
  letter-spacing: 0.01em;
  flex-shrink: 0;
}
.nav-brand-arabic {
  font-family: 'Lateef', serif;
  font-size: 1.2rem;
  color: var(--text-muted);
  letter-spacing: 0;
  margin-left: 0.3rem;
}

nav a {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.3rem;
  text-decoration: none;
  color: var(--text-subtle);
  font-size: 0.83rem;
  font-family: var(--font-ui);
  padding: 0.45rem 0.7rem;
  border-radius: var(--radius);
  transition: color 0.15s, background 0.15s;
  white-space: nowrap;
}

nav a svg { width: 15px; height: 15px; stroke: currentColor; fill: none; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }

nav a.active { color: var(--accent); background: var(--accent-light); }
nav a:hover { color: var(--text); }

/* ---- Nav auth button ---- */

.nav-auth {
  display: none; /* shown by JS once auth initializes */
  align-items: center;
  gap: 0.3rem;
  padding: 0.35rem 0.75rem;
  border-radius: 100px;
  border: 1px solid var(--border-strong);
  background: transparent;
  color: var(--text-muted);
  font-size: 0.83rem;
  font-family: var(--font-ui);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  white-space: nowrap;
  flex-shrink: 0;
  margin-left: 0.25rem;
}

.nav-auth:hover { background: var(--accent-light); color: var(--accent-text); border-color: var(--accent); }
.nav-auth svg { width: 15px; height: 15px; stroke: currentColor; fill: none; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }

.nav-auth-avatar-img { width: 22px; height: 22px; border-radius: 50%; flex-shrink: 0; display: block; }

.nav-auth-initial {
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--accent-light);
  color: var(--accent-text);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  font-weight: 600;
  flex-shrink: 0;
}

@media (max-width: 520px) {
  nav { padding: 0 0.75rem; gap: 0; }
  nav a { padding: 0.4rem 0.45rem; font-size: 0; }
  nav a svg { width: 20px; height: 20px; }
  nav a.active { background: transparent; }
  .nav-auth { padding: 0.4rem; font-size: 0; border: none; margin-left: 0; }
  .nav-auth svg { width: 20px; height: 20px; }
  .nav-auth-avatar-img { width: 26px; height: 26px; }
  .nav-auth-initial { width: 26px; height: 26px; font-size: 0.8rem; }
}

/* ---- Cards ---- */

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  margin-bottom: 0.75rem;
  box-shadow: var(--shadow);
  transition: border-color 0.15s;
}

.card:hover { border-color: var(--border-strong); }

.card-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

/* ---- Dua card ---- */

.dua-card { cursor: pointer; }
.dua-card .dua-arabic { font-family: var(--font-arabic); font-size: 1.3rem; line-height: 2; direction: rtl; text-align: right; margin-bottom: 0.5rem; }
.dua-card .dua-translation { font-size: 0.9rem; color: var(--text-muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.dua-card .dua-meta { display: flex; gap: 0.5rem; margin-top: 0.75rem; flex-wrap: wrap; }

/* ---- Tags / Badges ---- */

.tag {
  display: inline-block;
  font-size: 0.72rem;
  font-family: var(--font-ui);
  padding: 3px 10px;
  border-radius: 100px;
  background: var(--accent-light);
  color: var(--accent-text);
  font-weight: 500;
}

.tag.amber { background: var(--amber-light); color: var(--amber); }
.tag.muted { background: var(--border); color: var(--text-muted); }

/* ---- Buttons ---- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.6rem 1.25rem;
  border-radius: var(--radius);
  border: 1px solid var(--border-strong);
  background: var(--bg-card);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  text-decoration: none;
}

.btn:hover { background: var(--border); }

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #FAF5EC;
  box-shadow: 0 2px 8px rgba(160,96,26,0.22);
}

@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]) .btn-primary { color: #080610; box-shadow: 0 2px 8px rgba(245,201,122,0.18); }
}
html[data-theme="dark"] .btn-primary { color: #080610; box-shadow: 0 2px 8px rgba(245,201,122,0.18); }

.btn-primary:hover { opacity: 0.9; }

.btn-ghost {
  border-color: transparent;
  background: transparent;
  color: var(--text-muted);
}

.btn-ghost:hover { background: var(--border); color: var(--text); }

/* ---- Input / Textarea ---- */

input[type="text"], input[type="search"], textarea, select {
  width: 100%;
  padding: 0.65rem 0.9rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--bg-card);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.15s;
}

input:focus, textarea:focus, select:focus { border-color: var(--accent); }
textarea { resize: vertical; min-height: 100px; line-height: 1.6; }

.field { margin-bottom: 1rem; }
.field label { display: block; font-size: 0.85rem; font-weight: 500; margin-bottom: 0.35rem; color: var(--text-muted); }

/* ---- Search bar ---- */

.search-wrap { position: relative; margin-bottom: 1.25rem; }
.search-wrap svg { position: absolute; left: 0.75rem; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; stroke: var(--text-subtle); fill: none; stroke-width: 1.5; stroke-linecap: round; }
.search-wrap input { padding-left: 2.4rem; }

/* ---- Category chips ---- */

.chips { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.chip {
  padding: 0.4rem 1rem;
  border-radius: 100px;
  border: 1px solid var(--border-strong);
  background: var(--bg-card);
  font-size: 0.82rem;
  cursor: pointer;
  color: var(--text-muted);
  font-family: var(--font-ui);
  transition: all 0.15s;
}
.chip.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.chip:hover:not(.active) { border-color: var(--accent); color: var(--accent); }

/* ---- Ameen button ---- */

.ameen-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.9rem;
  border-radius: 100px;
  border: 1px solid var(--border-strong);
  background: transparent;
  font-size: 0.82rem;
  font-family: var(--font-ui);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s;
}
.ameen-btn:hover, .ameen-btn.tapped { background: var(--accent-light); border-color: var(--accent); color: var(--accent-text); }

/* ---- Empty state ---- */

.empty {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-subtle);
}
.empty h3 { font-size: 1rem; margin-bottom: 0.5rem; color: var(--text-muted); }
.empty p { font-size: 0.9rem; }

/* ---- Hero (homepage) ---- */

.hero {
  padding: 3rem 0 2rem;
  text-align: center;
}
.hero h1 { margin-bottom: 0.5rem; }
.hero p { font-size: 1rem; margin-bottom: 1.5rem; }
.hero .bismillah { font-family: var(--font-arabic); font-size: 2rem; color: var(--accent); margin-bottom: 1.5rem; display: block; }

/* ---- Divider ---- */

.divider { border: none; border-top: 1px solid var(--border); margin: 1.5rem 0; }

/* ---- Utility ---- */

.text-muted { color: var(--text-muted); }
.text-subtle { color: var(--text-subtle); }
.text-accent { color: var(--accent); }
.text-sm { font-size: 0.85rem; }
.text-center { text-align: center; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.flex { display: flex; }
.items-center { align-items: center; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
.justify-between { justify-content: space-between; }
.w-full { width: 100%; }

/* ---- Answered badge ---- */
.answered-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.75rem;
  color: var(--accent-text);
  background: var(--accent-light);
  padding: 3px 10px;
  border-radius: 100px;
}

/* ---- Toast notification ---- */
#toast {
  position: fixed;
  top: calc(var(--nav-h) + 0.75rem);
  bottom: auto;
  left: 50%;
  transform: translateX(-50%) translateY(-0.5rem);
  background: var(--text);
  color: var(--bg);
  padding: 0.6rem 1.25rem;
  border-radius: 100px;
  font-size: 0.85rem;
  font-family: var(--font-ui);
  opacity: 0;
  transition: opacity 0.2s, transform 0.2s;
  pointer-events: none;
  z-index: 200;
  white-space: nowrap;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0.5rem); }

/* ---- Footer ---- */

footer {
  max-width: var(--max-w);
  margin: 3rem auto 0;
  padding: 1.5rem 1rem 2rem;
  border-top: 1px solid var(--border);
  text-align: center;
}

footer p { font-size: 0.85rem; color: var(--text-subtle); }
footer a { color: var(--accent); text-decoration: none; }
footer a:hover { text-decoration: underline; }

/* ---- Theme Picker ---- */

.theme-picker {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
}

.theme-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  padding: 0.85rem 0.5rem;
  border-radius: var(--radius);
  border: 1px solid var(--border-strong);
  background: var(--bg-elevated);
  color: var(--text-muted);
  font-family: var(--font-ui);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.15s;
}

.theme-btn .theme-icon { font-size: 1.25rem; }

.theme-btn.active {
  border-color: var(--accent);
  background: var(--accent-light);
  color: var(--accent-text);
  font-weight: 500;
}

.theme-btn:hover:not(.active) {
  background: var(--bg-card);
  color: var(--text);
}

/* ---- Responsive ---- */
@media (max-width: 480px) {
  h1 { font-size: 1.6rem; }
  .arabic { font-size: 1.35rem; }
  .page { padding: 1rem 0.85rem; }
}
