/* ============================================================================
   As-Suʿadāʾ Memorial — Base layer
   Reset, document defaults, typography, accessibility, layout primitives.
   ========================================================================== */

/* Fonts are loaded via a <link> in index.html <head> (not an @import here): an
   @import is discovered only after this file downloads+parses, adding a serial
   round-trip that blocks first paint. The <link> is fetched in parallel. */

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  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;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg-page);
  color: var(--text-body);
  font-family: var(--font-body);
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

h1, h2, h3, h4 {
  font-family: var(--font-display);
  color: var(--text-heading);
  font-weight: var(--fw-bold);
  line-height: var(--lh-tight);
  margin: 0;
}

p { margin: 0; }

a {
  color: var(--accent-text);
  text-decoration: none;
  transition: color var(--dur-fast) var(--ease-out);
}
a:hover { color: var(--paper-200); }

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

button, input, textarea, select {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

button { cursor: pointer; }

ul, ol { margin: 0; padding: 0; list-style: none; }

/* Numerals in Latin contexts read better tabular */
.tnum { font-variant-numeric: tabular-nums; }

/* Direction-aware: Arabic numbers stay LTR inline */
[dir="rtl"] .ltr-num { direction: ltr; unicode-bidi: isolate; }

/* --- Accessibility ---------------------------------------------------------- */

:focus-visible {
  outline: 2px solid var(--accent-text);
  outline-offset: 2px;
  border-radius: var(--radius-xs);
}
:focus:not(:focus-visible) { outline: none; }

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

.skip-link {
  position: fixed;
  inset-inline-start: var(--space-4);
  top: -200px;
  z-index: 200;
  background: var(--accent);
  color: var(--text-on-accent);
  padding: var(--space-3) var(--space-5);
  border-radius: var(--radius-md);
  font-weight: var(--fw-semibold);
  box-shadow: var(--shadow-lg);
  transition: top var(--dur-base) var(--ease-out);
}
.skip-link:focus { top: var(--space-4); color: var(--text-on-accent); }

/* --- Scrollbars (quiet) ------------------------------------------------------ */
* { scrollbar-width: thin; scrollbar-color: var(--ink-600) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--ink-600); border-radius: 999px; border: 3px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: var(--ink-500); background-clip: content-box; }

/* Hide scrollbar on horizontal rails while keeping scroll */
.no-scrollbar { -ms-overflow-style: none; scrollbar-width: none; }
.no-scrollbar::-webkit-scrollbar { display: none; }

/* --- Layout primitives ------------------------------------------------------ */

.shell { width: 100%; max-width: var(--shell-max); margin-inline: auto; padding-inline: var(--gutter); }
.readable { max-width: var(--content-max); margin-inline: auto; }

.section { padding-block: var(--space-12); }
.section--tight { padding-block: var(--space-8); }

.stack { display: flex; flex-direction: column; }
.row { display: flex; align-items: center; }
.between { display: flex; align-items: center; justify-content: space-between; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }

.eyebrow {
  font-family: var(--font-body);
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
  color: var(--accent-text);
}
[lang="ar"] .eyebrow, [dir="rtl"] .eyebrow {
  letter-spacing: normal;       /* never track Arabic */
  text-transform: none;
}

.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-4); margin-bottom: var(--space-6); }
.section-head h2 { font-size: var(--fs-h2); }
.section-head .link { font-size: var(--fs-sm); color: var(--accent-text); white-space: nowrap; }

.muted { color: var(--text-muted); }
.lead { font-size: var(--fs-lead); line-height: var(--lh-loose); color: var(--text-body); }

/* Anemone divider — a quiet centered motif between two hairlines */
.rule {
  display: flex; align-items: center; gap: var(--space-4);
  color: var(--ink-600);
}
.rule::before, .rule::after { content: ""; height: 1px; flex: 1; background: var(--border-hairline); }
.rule .rule__mark { color: var(--accent); opacity: 0.85; display: inline-flex; }

/* Reveal-on-scroll (progressive enhancement; safe without JS) */
.reveal { opacity: 0; transform: translateY(14px); transition: opacity var(--dur-slow) var(--ease-out), transform var(--dur-slow) var(--ease-out); }
.reveal.is-in { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) { .reveal { opacity: 1; transform: none; } }

/* App scaffold */
#app { display: flex; flex-direction: column; min-height: 100vh; min-height: 100dvh; }
main { flex: 1; outline: none; }
.page { animation: page-in var(--dur-base) var(--ease-out); }
@keyframes page-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .page { animation: none; } }
