/* Fonts are loaded via <link rel="preconnect"/stylesheet"> in each page's
   <head> (not @import here) -- @import blocks parallel downloading and adds
   a serial round trip before the font request even starts. */

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

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

body {
  margin: 0;
  /* .site-header is position:fixed (see components.css) so it stays pinned
     on every device -- iOS Safari in particular drops position:sticky to a
     normal-flow element the moment an ancestor gets a transform/filter
     (several of this site's own section wrappers do), so sticky wasn't
     reliable. Fixed takes the header out of flow entirely, so this
     padding-top reserves its space; --header-height is kept in sync with
     the header's real (possibly wrapped/RTL) height by a ResizeObserver in
     assets/js/features/nav.js, with this value as a same-number fallback
     for the instant before that JS runs. */
  padding-top: var(--header-height, 80px);
  /* Reserves space for two other fixed-position bottom elements: the
     player bar (--player-bar-space, set by player.js only while a lecture
     is loaded) and the mobile bottom-nav bar (--bottom-nav-height, only
     nonzero below the mobile breakpoint -- see the media query below and
     .mobile-bottom-nav in components.css). Both default to 0 so this is a
     no-op on desktop with nothing playing. */
  padding-bottom: calc(var(--bottom-nav-height, 0px) + var(--player-bar-space, 0px));
  background: var(--bg-base);
  color: var(--text-main);
  font-family: 'Inter', 'Amiri', system-ui, sans-serif;
  font-size: 17px;
  line-height: 1.65;
  transition: background-color 300ms ease, color 300ms ease;
  -webkit-font-smoothing: antialiased;
}
@media (max-width: 767px) {
  body {
    --bottom-nav-height: 60px;
  }
}

/* English/LTR headings — Inter, matching body (per user preference over Marcellus).
   `color` is kept at plain bare-tag specificity (Tailwind's preflight never
   touches color, and dark-background sections like the footer rely on being
   able to override it via a lower-specificity contextual selector like
   `.site-footer`) -- only font-size/font-weight below need the `body`-
   qualified bump, since those are the two properties Tailwind's CDN preflight
   (`h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}`) resets. That
   preflight is built and appended asynchronously, after this stylesheet has
   already been parsed, regardless of where its own <script> tag sits in the
   page, so at equal specificity it was winning and silently flattening every
   heading site-wide down to plain inherited body text. */
h1, h2, h3, h4, .font-display {
  font-family: 'Inter', 'Amiri', system-ui, sans-serif;
  color: var(--text-main);
  margin: 0;
  letter-spacing: 0.3px;
}

/* Explicit weights (not the UA bold default) and tighter tracking at large
   sizes -- a flat +0.3px letterspacing across a 24px h3 and a 56px h1 reads
   loose at the top of the scale; oversized display text wants tight/negative
   tracking, so h1/h2 get progressively tighter and h3 stays neutral. */
body h1 { font-size: 56px; font-weight: 700; line-height: 1.1; letter-spacing: -0.5px; }
body h2 { font-size: 34px; font-weight: 700; line-height: 1.2; letter-spacing: -0.2px; }
body h3 { font-size: 24px; font-weight: 600; line-height: 1.3; letter-spacing: 0; }

p {
  margin: 0;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}

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

.caption {
  font-size: 13px;
  line-height: 20px;
  color: var(--text-muted);
}

/* Focus visibility — Section 15 */
:focus-visible {
  outline: 2px solid var(--secondary);
  outline-offset: 2px;
  box-shadow: 0 0 0 4px rgba(199, 149, 44, 0.25);
  border-radius: 4px;
}

/* Mobile heading scale -- same `body`-qualified selectors, same reasoning. */
@media (max-width: 767px) {
  body h1 { font-size: 32px; letter-spacing: -0.3px; }
  body h2 { font-size: 26px; letter-spacing: -0.1px; }
  body h3 { font-size: 20px; }
  body { font-size: 16px; }
}

::selection {
  background: var(--accent-gold);
  color: var(--bg-base);
}

.container {
  max-width: var(--container-max);
  margin-inline: auto;
  padding-inline: 24px;
}

@media (max-width: 767px) {
  .container {
    padding-inline: 16px;
  }
}

.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;
}

section[data-section] {
  padding-block: 64px;
}

@media (max-width: 767px) {
  section[data-section] {
    padding-block: 40px;
  }
}

/* Print — Section 10.6 "print-friendly styling (chains are often printed)".
   Force light, ink-economical colors regardless of dark mode, hide chrome
   that has no meaning on paper (sticky header controls, floating demo
   toggle, audio player, decorative background patterns), and keep gold/
   turquoise accents that carry real meaning (Shajrah connectors). */
@media print {
  :root, :root[data-theme="dark"] {
    --bg-base: #FFFFFF;
    --bg-surface: #FFFFFF;
    --bg-raised: #FFFFFF;
    --text-main: #1A1A1A;
    --text-muted: #4A4A4A;
    --border: #CCCCCC;
  }
  body {
    background: #FFFFFF;
  }
  .site-header,
  .mobile-menu,
  .player-bar,
  .toast,
  .pattern-layer,
  .dome-glow-layer,
  .site-footer,
  [data-action="open-menu"],
  [data-action="toggle-theme"],
  .lang-chip,
  .live-pill {
    display: none !important;
  }
  .shajrah-chain,
  .shajrah-node__connector,
  .shajrah-chain::before,
  .tile-band,
  .page-title::after {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  a[href]::after {
    content: none;
  }
}
