/* ==========================================================================
   Base — reset, typography, shared primitives, focus & skip link
   ========================================================================== */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  /* sticky header must never hide a focused target (WCAG 2.4.11) */
  scroll-padding-block-start: 96px;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  color: var(--ink);
  background-color: var(--paper);
  /* Subtle girih (8-point star) texture — ornamental, never behind long text */
  background-image: url("../img/pattern.svg");
  background-size: 260px 260px;
  background-repeat: repeat;
  background-attachment: fixed;
  min-height: 100vh;
}

h1, h2, h3, h4 {
  font-family: var(--font-display);
  line-height: 1.45;
  color: var(--green-900);
  margin-block: 0 0.5em;
  font-weight: 600;
  text-wrap: balance;
}

h1 { font-size: var(--fs-h1); }
h2 { font-size: var(--fs-h2); }
h3 { font-size: 1.12rem; }

p { margin-block: 0 1em; text-wrap: pretty; }

a {
  color: var(--green-700);
  text-decoration: none;
  transition: color var(--dur) var(--ease);
}

a:hover { color: var(--gold-700); }

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

[hidden] { display: none !important; }

button { font-family: inherit; }

:focus-visible {
  outline: 3px solid var(--gold-500);
  outline-offset: 3px;
  border-radius: 4px;
}

::selection {
  background: var(--gold-300);
  color: var(--green-900);
}

/* Skip link — parked off-screen until keyboard focus (WCAG 2.4.1) */
.skip-link {
  position: fixed;
  inset-block-start: -100%;
  inset-inline-start: var(--s-4);
  z-index: 100;
  background: var(--green-800);
  color: var(--white);
  font-weight: 700;
  font-size: var(--fs-small);
  padding: 0.7rem 1.2rem;
  border: 1px solid var(--gold-500);
  border-block-start: 0;
  border-radius: 0 0 var(--r-sm) var(--r-sm);
  box-shadow: var(--shadow-lift);
  transition: inset-block-start var(--dur) var(--ease);
}

.skip-link:hover,
.skip-link:focus { color: var(--white); }

/* the skip target is a landmark, not a control — no ring needed there */
main:focus { outline: none; }

/* Sacred-text styling: Qur'an and hadith use the Naskh face + open quotes */
.quran-text,
.hadith-text {
  font-family: var(--font-quran);
  line-height: var(--lh-quran);
}

.hadith-text::before { content: "«"; color: var(--gold-800); }
.hadith-text::after { content: "»"; color: var(--gold-800); }

.quran-text { font-size: 1.2em; }

.source {
  display: block;
  font-size: var(--fs-small);
  color: var(--muted);
  font-style: normal;
}

.source::before { content: "— "; color: var(--gold-600); }

/* Section kicker — gold rule before/after, tracking only where Latin */
.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  font-size: var(--fs-small);
  letter-spacing: var(--ls-kicker);
  color: var(--gold-800);
  text-transform: uppercase;
  font-weight: 700;
}

/* each rule fades out away from the text it flanks — mirrored per direction */
.eyebrow::before,
.eyebrow::after {
  content: "";
  width: 26px;
  height: 1px;
}

.eyebrow::before { background: linear-gradient(90deg, transparent, var(--gold-500)); }
.eyebrow::after { background: linear-gradient(90deg, var(--gold-500), transparent); }

html[dir="rtl"] .eyebrow::before { background: linear-gradient(270deg, transparent, var(--gold-500)); }
html[dir="rtl"] .eyebrow::after { background: linear-gradient(270deg, var(--gold-500), transparent); }

.lead {
  font-size: var(--fs-lead);
  color: var(--muted);
}

.muted { color: var(--muted); }
.center { text-align: center; }
.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}

/* ---------- Shared keyframes (ornament & feedback only — never sacred text) */
@keyframes orn-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes count-bump {
  0% { transform: scale(1); }
  35% { transform: scale(1.055); }
  100% { transform: scale(1); }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
