/* RABBANI (ربّاني) Base Styles & Reset */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  direction: rtl;
  text-align: right;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-arabic-body);
  background-color: var(--bg-parchment);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
  position: relative;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Headings with traditional Arabic scholarly typography */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-arabic-heading);
  font-weight: 700;
  color: var(--primary-forest);
  line-height: 1.35;
  margin-bottom: var(--space-3);
}

h1 { font-size: var(--font-size-3xl); }
h2 { font-size: var(--font-size-2xl); }
h3 { font-size: var(--font-size-xl); }
h4 { font-size: var(--font-size-lg); }

p {
  margin-bottom: var(--space-3);
}

a {
  color: var(--primary-forest);
  text-decoration: none;
  transition: color var(--transition-fast);
}

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

/* Accessible focus rings */
button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--border-focus);
  outline-offset: 2px;
}

/* Programmatic focus after a client-side route change lands on the view's
   heading (or the content region). Keep it perceivable but calm. */
#main-content-view:focus-visible {
  outline: 2px dashed var(--border-focus);
  outline-offset: 4px;
}

/* Quiz questions are grouped as native fieldsets so screen readers announce
   the radio-group boundary and its name (the legend). */
fieldset.quiz-question {
  border: 1px solid var(--border-subtle, rgba(0, 0, 0, 0.15));
  border-radius: 8px;
  padding: 1rem 1.25rem;
  margin: 0;
}

fieldset.quiz-question > legend {
  font-weight: 600;
  padding: 0 0.5rem;
}

/* Form elements reset */
button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  border: none;
  background: none;
}

ul, ol {
  list-style: none;
}

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

/* Screen reader utility */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

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