/* Reset, typography and global behaviour. Mobile-first; directional spacing uses logical properties
   (margin-inline-start, padding-inline-end …) so right-to-left pages need no separate rules. */

*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-padding-top: calc(var(--header-h) + var(--space-4));
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-text);
  font-size: var(--fs-base);
  line-height: var(--lh-text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

img, svg, video, iframe { display: block; max-width: 100%; }
img { height: auto; }

h1, h2, h3, h4 {
  margin: 0 0 var(--space-3);
  font-family: var(--font-text);
  font-weight: 700;
  line-height: var(--lh-heading);
  letter-spacing: -.01em;
  text-wrap: balance;
}
:lang(ar) :is(h1, h2, h3, h4), :lang(ur) :is(h1, h2, h3, h4) { letter-spacing: 0; }
:lang(ur):not(:lang(ur-Latn)) :is(h1, h2, h3, h4) { font-weight: 600; }
h1 { font-size: var(--fs-2xl); }
h2 { font-size: var(--fs-xl); }
h3 { font-size: var(--fs-lg); }
p { margin: 0 0 var(--space-4); }
small { font-size: var(--fs-sm); }

a { color: var(--link); text-underline-offset: .2em; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:disabled { cursor: not-allowed; }

ul[role="list"], ol[role="list"] { list-style: none; margin: 0; padding: 0; }

hr { border: 0; border-top: 1px solid var(--border); margin: var(--space-6) 0; }

::selection { background: var(--accent-soft); color: var(--text); }

/* One visible focus style for everything you can reach with the keyboard. */
:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}
:focus:not(:focus-visible) { outline: none; }

.skip-link {
  position: absolute;
  inset-inline-start: var(--space-3);
  top: -5rem;
  z-index: 1000;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius);
  background: var(--primary);
  color: var(--on-primary);
  font-family: var(--font-ui);
  font-weight: 600;
  text-decoration: none;
}
.skip-link:focus { top: var(--space-3); }

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

[hidden] { display: none !important; }

/* Icons from the SVG sprite: sized by font size, coloured by text colour. */
.icon {
  width: 1.15em;
  height: 1.15em;
  flex-shrink: 0;
  fill: currentColor;
  vertical-align: -0.2em;
}
/* Arrows and chevrons point the other way in right-to-left languages (logos and symbols don't). */
[dir="rtl"] .icon.flip-rtl { transform: scaleX(-1); }

/* Arabic text (Quran, duas, ziyarat) — always right-to-left in the Quranic typeface,
   whatever the interface language. */
.arabic {
  font-family: var(--font-quran);
  direction: rtl;
  font-feature-settings: "kern", "liga", "calt";
  line-height: 2;
}
.latin { font-family: var(--font-latin); }
.nums { font-variant-numeric: tabular-nums; }

/* Respect reduced-motion preferences everywhere. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
}

@media print {
  .site-header, .bottom-nav, .site-footer, .reader-toolbar, .audio-player, .no-print { display: none !important; }
  body { background: #fff; color: #000; }
}
