/* ============================================================================
   ancientfit-frontend/css/faq.css
   AncientFit — Frequently Asked Questions (page/faq.html)
   Same visual system as the Terms of Use & Privacy Policy page, self-contained
   so the FAQ never depends on terms-privacy.css.
   Palette: obsidian #0A0A0A / #040608 · gold #D39D55 · text #F3F7FF
   ============================================================================ */

:root {
  --af-bg-1: #0A0A0A;
  --af-bg-2: #040608;
  --af-bg-3: #0A0A14;
  --af-card: #131A24;
  --af-gold: #D39D55;
  --af-gold-soft: rgba(211, 157, 85, 0.14);
  --af-white: #F3F7FF;
  --af-muted: #93A4BD;
  --af-amber: #FFB74D;
  --af-red: #FF6B6B;
  --af-line: rgba(255, 255, 255, 0.08);
  --af-line-soft: rgba(255, 255, 255, 0.05);
  --af-maxw: 1180px;
  --af-radius: 18px;
  --af-font: 'Inter', 'Segoe UI', Roboto, system-ui, -apple-system, Arial, sans-serif;
  --af-font-ar: 'Noto Naskh Arabic', 'Amiri', 'Traditional Arabic', serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--af-font);
  line-height: 1.75;
  color: var(--af-white);
  background:
    radial-gradient(1200px 600px at 50% -10%, rgba(211,157,85,0.08), transparent 60%),
    linear-gradient(180deg, var(--af-bg-1), var(--af-bg-2) 55%, var(--af-bg-3));
  background-attachment: fixed;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ── Hero ─────────────────────────────────────────────────────────────────── */
.af-hero { max-width: var(--af-maxw); margin: 0 auto; padding: 56px 24px 24px; text-align: center; }
.af-hero .af-mark { font-size: 0.78rem; letter-spacing: 4px; text-transform: uppercase; color: var(--af-gold); font-weight: 700; }
.af-hero h1 { font-size: clamp(1.8rem, 4vw, 2.8rem); margin: 10px 0 6px; color: var(--af-white); font-weight: 800; letter-spacing: 0.5px; }
.af-hero .af-tagline { color: var(--af-muted); font-size: 0.95rem; margin: 0 0 4px; }
.af-hero .af-updated { color: var(--af-muted); font-size: 0.82rem; margin-top: 10px; }
.af-hero .af-updated strong { color: var(--af-gold); }

/* ── Language toggle ──────────────────────────────────────────────────────── */
.af-langbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; flex-wrap: wrap; gap: 8px; justify-content: center;
  padding: 12px 16px; margin-bottom: 8px;
  background: rgba(4, 6, 8, 0.82);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--af-line);
}
.af-lang {
  border: 1px solid var(--af-line); background: rgba(255,255,255,0.03); color: var(--af-white);
  font: inherit; font-size: 0.85rem; font-weight: 600; padding: 7px 16px; border-radius: 40px;
  cursor: pointer; transition: all 0.15s ease;
}
.af-lang:hover:not(:disabled) { background: var(--af-gold-soft); border-color: rgba(211,157,85,0.5); }
.af-lang.is-active,
.af-lang.is-active:hover:not(:disabled) { background: var(--af-gold); color: #15100A; border-color: var(--af-gold); }
.af-lang.is-loading { opacity: 0.6; cursor: progress; }
.af-lang:disabled { opacity: 0.4; cursor: not-allowed; }
.af-lang .af-soon { display: inline-block; font-size: 0.6rem; letter-spacing: 0.5px; text-transform: uppercase; color: var(--af-amber); margin-inline-start: 6px; }

/* ── Layout: sticky TOC + content ─────────────────────────────────────────── */
.af-wrap {
  max-width: var(--af-maxw); margin: 0 auto; padding: 8px 24px 80px;
  display: grid; grid-template-columns: 270px 1fr; gap: 40px; align-items: start;
}
.af-toc {
  position: sticky; top: 74px; max-height: calc(100vh - 100px); overflow-y: auto;
  padding: 18px; background: rgba(19, 26, 36, 0.5);
  border: 1px solid var(--af-line); border-radius: var(--af-radius); scrollbar-width: thin;
}
.af-toc h4 { margin: 0 0 10px; font-size: 0.72rem; letter-spacing: 2px; text-transform: uppercase; color: var(--af-gold); }
.af-toc a {
  display: block; color: var(--af-muted); text-decoration: none; font-size: 0.82rem;
  padding: 5px 10px; border-radius: 8px; border-left: 2px solid transparent; transition: all 0.12s ease;
}
.af-toc a:hover { color: var(--af-white); background: rgba(255,255,255,0.04); }
.af-toc a.is-current { color: var(--af-gold); border-left-color: var(--af-gold); background: var(--af-gold-soft); }
.af-toc a.is-hidden { display: none; }

.af-main { min-width: 0; }

/* ── FAQ tools: search + expand / collapse ────────────────────────────────── */
.af-faq-tools { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 4px 0 18px; }
.af-search {
  flex: 1 1 260px; min-width: 0;
  font: inherit; font-size: 0.92rem; color: var(--af-white);
  background: rgba(19, 26, 36, 0.7); border: 1px solid var(--af-line); border-radius: 40px;
  padding: 10px 18px; outline: none; transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.af-search::placeholder { color: var(--af-muted); }
.af-search:focus { border-color: rgba(211,157,85,0.6); box-shadow: 0 0 0 3px var(--af-gold-soft); }
.af-tool-btn {
  font: inherit; font-size: 0.8rem; font-weight: 600; color: var(--af-gold);
  background: transparent; border: 1px solid rgba(211,157,85,0.45); border-radius: 40px;
  padding: 8px 16px; cursor: pointer; transition: all 0.15s ease;
}
.af-tool-btn:hover { background: var(--af-gold-soft); }
.af-noresult { display: none; color: var(--af-muted); font-size: 0.92rem; padding: 6px 4px; }
.af-noresult.is-visible { display: block; }

/* ── Article ──────────────────────────────────────────────────────────────── */
.af-article { min-width: 0; }
.af-article > p:first-child { font-size: 1.02rem; color: #D7DEEA; }
.af-article h2 {
  font-size: 1.35rem; color: var(--af-white); font-weight: 700;
  margin: 34px 0 12px; padding-left: 14px; border-left: 4px solid var(--af-gold);
  scroll-margin-top: 84px;
}
.af-article h2.is-hidden { display: none; }
.af-article p { color: #D7DEEA; margin: 0 0 12px; }
.af-article a { color: var(--af-gold); text-decoration: none; border-bottom: 1px solid rgba(211,157,85,0.4); }
.af-article a:hover { border-bottom-color: var(--af-gold); }
.af-article ul { padding-inline-start: 22px; margin: 0 0 14px; }
.af-article li { color: #CBD4E2; margin-bottom: 6px; }
.af-article strong { color: var(--af-white); }
.af-article em { color: var(--af-gold); font-style: normal; }

/* Callout box */
.af-box {
  background: rgba(19, 26, 36, 0.6); border: 1px solid var(--af-line);
  border-left: 5px solid var(--af-gold); border-radius: 12px; padding: 16px 20px; margin: 18px 0;
}
.af-box.is-warn { border-left-color: var(--af-amber); }
.af-box p:last-child { margin-bottom: 0; }

/* ── Question / answer accordion ──────────────────────────────────────────── */
.af-q {
  background: rgba(19, 26, 36, 0.55); border: 1px solid var(--af-line); border-radius: 14px;
  margin: 10px 0; transition: border-color 0.15s ease, background 0.15s ease;
  scroll-margin-top: 84px;
}
.af-q:hover { border-color: rgba(211,157,85,0.3); }
.af-q[open] { border-color: rgba(211,157,85,0.45); background: rgba(19, 26, 36, 0.82); }
.af-q.is-hidden { display: none; }
.af-q > summary {
  list-style: none; cursor: pointer; position: relative;
  padding: 14px 18px; padding-inline-end: 52px;
  font-weight: 600; font-size: 1rem; color: var(--af-white); line-height: 1.5;
  border-radius: 14px;
}
.af-q > summary::-webkit-details-marker { display: none; }
.af-q > summary::after {
  content: '+'; position: absolute; inset-inline-end: 18px; top: 50%; transform: translateY(-50%);
  width: 24px; height: 24px; line-height: 22px; text-align: center;
  border: 1px solid rgba(211,157,85,0.5); border-radius: 50%;
  color: var(--af-gold); font-size: 1rem; font-weight: 700;
}
.af-q[open] > summary::after { content: '−'; background: var(--af-gold); color: #15100A; border-color: var(--af-gold); }
.af-q > summary:focus-visible { outline: 2px solid var(--af-gold); outline-offset: 2px; }
.af-q[open] > summary { color: var(--af-gold); }
.af-a { padding: 0 18px 6px; border-top: 1px solid var(--af-line-soft); padding-top: 12px; }
.af-a ul:last-child, .af-a p:last-child { margin-bottom: 10px; }

/* Related links under an answer */
.af-article .af-related {
  font-size: 0.84rem; color: var(--af-muted); line-height: 1.9;
  margin-top: 4px; padding-top: 10px; border-top: 1px dashed var(--af-line);
}
.af-article .af-related span { color: var(--af-gold); font-weight: 600; margin-inline-end: 4px; }

/* ── Footer ───────────────────────────────────────────────────────────────── */
.af-foot {
  max-width: var(--af-maxw); margin: 0 auto; padding: 28px 24px 48px; text-align: center;
  color: var(--af-muted); font-size: 0.85rem; border-top: 1px solid var(--af-line);
}
.af-foot p { margin: 4px 0; }
.af-foot a { color: var(--af-gold); text-decoration: none; }

/* ── Back to top ──────────────────────────────────────────────────────────── */
#afTopBtn {
  position: fixed; bottom: 22px; inset-inline-end: 22px; width: 46px; height: 46px;
  border-radius: 50%; border: 1px solid rgba(211,157,85,0.5); background: rgba(19,26,36,0.9);
  color: var(--af-gold); font-size: 1.1rem; cursor: pointer;
  opacity: 0; pointer-events: none; transition: opacity 0.2s ease; z-index: 60;
}
#afTopBtn.is-visible { opacity: 1; pointer-events: auto; }

/* ── RTL (Arabic) ─────────────────────────────────────────────────────────── */
[dir="rtl"] body, [dir="rtl"] .af-article, [dir="rtl"] .af-search { font-family: var(--af-font-ar); }
[dir="rtl"] .af-hero, [dir="rtl"] .af-foot { font-family: var(--af-font); }   /* hero + footer stay English */
[dir="rtl"] .af-article h2 { border-left: none; border-right: 4px solid var(--af-gold); padding-left: 0; padding-right: 14px; }
[dir="rtl"] .af-box { border-left: 1px solid var(--af-line); border-right: 5px solid var(--af-gold); }
[dir="rtl"] .af-toc a { border-left: none; border-right: 2px solid transparent; }
[dir="rtl"] .af-toc a.is-current { border-right-color: var(--af-gold); }

/* ── Responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .af-wrap { grid-template-columns: 1fr; gap: 16px; }
  .af-toc { position: static; max-height: none; order: -1; padding: 12px 14px; }
  /* Topics become one swipeable row of chips so the questions stay near the top */
  .af-toc h4 { margin-bottom: 8px; }
  #afTocList { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
  #afTocList::-webkit-scrollbar { display: none; }
  .af-toc a, [dir="rtl"] .af-toc a {
    flex: 0 0 auto; white-space: nowrap; border: 1px solid var(--af-line); border-radius: 40px; padding: 6px 14px;
  }
  .af-toc a.is-current, [dir="rtl"] .af-toc a.is-current { border-color: rgba(211,157,85,0.5); }
}
@media (max-width: 560px) {
  .af-hero { padding: 36px 18px 16px; }
  .af-wrap { padding: 8px 16px 64px; }
  .af-article h2 { font-size: 1.2rem; }
  .af-q > summary { font-size: 0.95rem; padding: 12px 14px; padding-inline-end: 48px; }
  .af-a { padding-left: 14px; padding-right: 14px; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { transition: none !important; }
}

/* ── Print: every answer visible ──────────────────────────────────────────── */
@media print {
  body { background: #fff; color: #111; }
  .af-langbar, .af-toc, .af-faq-tools, #afTopBtn { display: none; }
  .af-wrap { grid-template-columns: 1fr; }
  .af-q { border-color: #ccc; background: #fff; }
  .af-q > summary { color: #111; }
  .af-q > summary::after { display: none; }
  .af-article h2 { color: #111; border-color: #999; }
  .af-article p, .af-article li { color: #222; }
}