/* base.css — reset, page typography and global accessibility rules.
   Nothing here knows about a specific screen. */

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  font-size: calc(100% * var(--text-scale, 1));   /* Settings → text size */
}

body {
  min-height: 100dvh;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: var(--text-md);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3 {
  font-family: var(--font-display);
  line-height: 1.15;
  letter-spacing: -.01em;
  font-weight: 700;
  text-wrap: balance;
}
h1 { font-size: var(--text-2xl); }
h2 { font-size: var(--text-xl); }
h3 { font-size: var(--text-lg); }
p  { text-wrap: pretty; max-width: 70ch; }   /* short lines read faster */

img, svg { display: block; max-width: 100%; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; }
a { color: var(--brand); text-underline-offset: 3px; }

/* Arabic text always reads right-to-left in its own font. */
[lang="ar"] {
  font-family: var(--font-arabic);
  font-size: calc(1em * var(--arabic-scale));
  line-height: 1.7;
  direction: rtl;
  unicode-bidi: isolate;
}
.ipa { font-family: var(--font-ipa); color: var(--ink-2); letter-spacing: .01em; overflow-wrap: anywhere; }

/* One visible focus style for every interactive element. */
:focus-visible {
  outline: 3px solid var(--brand);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

/* The main region gets focus on every screen change (for screen readers);
   it should not draw a ring around the whole page. */
#view:focus { outline: none; }

/* Scrollbars: thin, rounded and quiet — they darken only when you reach for them.
   Firefox reads scrollbar-*; Chrome, Edge, Brave and Safari read ::-webkit-scrollbar. */
* { scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--line-strong); border-radius: 999px;
  border: 3px solid transparent; background-clip: padding-box;   /* a slim thumb with breathing room */
}
::-webkit-scrollbar-thumb:hover { background-color: var(--ink-3); }
::-webkit-scrollbar-thumb:active { background-color: var(--brand); }
::-webkit-scrollbar-corner { background: transparent; }

::selection { background: var(--mark); color: var(--on-mark); }

.skip-link:not(:focus) { position: absolute; left: -9999px; }
.skip-link:focus { position: fixed; z-index: 60; top: 8px; left: 8px; padding: 8px 12px; background: var(--surface); border-radius: var(--r-sm); }

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

/* Respect the learner's motion setting everywhere. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 1ms !important;
    animation-delay: 0ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 1ms !important;
    transition-delay: 0ms !important;
    scroll-behavior: auto !important;
  }
}
