/* Shared typography and layout for the Arabic physics book HTML edition.
   Navigation and chrome only — book text is unchanged from the Markdown source. */

@font-face {
  font-family: "Noto Naskh Arabic";
  src: url("fonts/NotoNaskhArabic-VariableFont_wght.ttf") format("truetype");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Cairo";
  src: url("fonts/Cairo-VariableFont_slnt,wght.ttf") format("truetype");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Noto Sans Arabic";
  src: url("fonts/NotoSansArabic-VariableFont_wdth,wght.ttf") format("truetype");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  --ink: #1c1712;
  --muted: #5c564c;
  --paper: #fffdf8;
  --page-bg: #efe8dc;
  --rule: #e0d6c6;
  --accent: #1f4b66;
  --accent-soft: #e7f0f5;
  --link: #1a5a7a;
  --link-visited: #4a3f73;
  --quote-bg: #f7f1e7;
  --quote-edge: #b0894f;
  --table-head: #eef4f7;
  --shadow: 0 1px 2px rgba(40, 30, 10, 0.04), 0 12px 36px rgba(40, 30, 10, 0.08);
}

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

html {
  font-size: 18px;
}

body {
  margin: 0;
  background: var(--page-bg);
  color: var(--ink);
  font-family: "Noto Naskh Arabic", "Amiri", "Scheherazade New", "Traditional Arabic", "Geeza Pro", "Liberation Serif", "Times New Roman", serif;
  font-weight: 500;
  line-height: 2;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

.page {
  max-width: 54rem;
  margin: 0 auto;
  min-height: 100vh;
  background: var(--paper);
  box-shadow: var(--shadow);
  padding: 0 1.75rem 3.5rem;
}

@media (min-width: 800px) {
  .page {
    padding: 0 2.75rem 4rem;
  }
}

.brand {
  font-family: "Cairo", "Noto Sans Arabic", "Noto Naskh Arabic", sans-serif;
  font-weight: 650;
  font-size: 0.92rem;
  padding: 1rem 0 0.35rem;
  color: var(--accent);
}

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

.brand a:hover {
  text-decoration: underline;
}

.book-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  padding: 0.65rem 0 0.85rem;
  border-bottom: 1px solid var(--rule);
  font-family: "Cairo", "Noto Sans Arabic", "Noto Naskh Arabic", sans-serif;
  font-size: 0.92rem;
  line-height: 1.5;
  background: var(--paper);
  position: sticky;
  top: 0;
  z-index: 20;
}

footer .book-nav {
  position: static;
  border-bottom: 0;
  border-top: 1px solid var(--rule);
  margin-top: 3rem;
  padding-top: 1rem;
}

.book-nav a {
  color: var(--link);
  text-decoration: none;
  max-width: 38%;
}

.book-nav a:hover {
  text-decoration: underline;
}

.book-nav .nav-index {
  font-weight: 700;
  color: var(--accent);
  max-width: none;
}

.book-nav .nav-placeholder {
  max-width: 38%;
  color: var(--muted);
}

.content {
  padding-top: 1.25rem;
}

.content > h1:first-child,
.content > h2:first-child {
  margin-top: 0.25rem;
}

h1, h2, h3, h4, h5, h6 {
  font-family: "Cairo", "Noto Sans Arabic", "Noto Naskh Arabic", sans-serif;
  color: var(--accent);
  line-height: 1.45;
  font-weight: 700;
  margin: 1.8rem 0 0.7rem;
}

h1 { font-size: 1.75rem; }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.15rem; }

p {
  margin: 0.7rem 0;
  text-align: justify;
  text-align-last: start;
  text-justify: inter-word;
}

strong {
  font-weight: 700;
}

em {
  font-style: italic;
}

a {
  color: var(--link);
}

a:visited {
  color: var(--link-visited);
}

code {
  font-family: "IBM Plex Mono", "Cascadia Code", "Liberation Mono", monospace;
  font-size: 0.88em;
  background: var(--accent-soft);
  padding: 0.1em 0.35em;
  border-radius: 0.25em;
  direction: ltr;
  unicode-bidi: isolate;
  text-align: left;
}

blockquote {
  margin: 1rem 0;
  padding: 0.35rem 1rem 0.35rem 0.85rem;
  background: var(--quote-bg);
  border-inline-start: 4px solid var(--quote-edge);
  color: #2a241c;
}

blockquote p {
  margin: 0.35rem 0;
  text-align: start;
}

blockquote.correction-note {
  margin: 0.9rem 0 1.2rem;
  padding: 0.6rem 1.05rem 0.65rem;
  background: #fff6dc;
  border-inline-start: 4px solid #c9891a;
  border-radius: 0.3rem;
  color: #3a2c10;
  box-shadow: 0 0 0 1px rgba(201, 137, 26, 0.18);
}
blockquote.correction-note p {
  margin: 0.15rem 0;
  line-height: 1.7;
}
blockquote.correction-note strong {
  color: #7a4e00;
}

.figure,
p:has(> img:only-child) {
  margin: 1.4rem 0;
  text-align: center;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 0.4rem auto;
  background: #fff;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
  margin: 1.25rem 0 1.5rem;
  -webkit-overflow-scrolling: touch;
}

table {
  border-collapse: collapse;
  width: 100%;
  min-width: 28rem;
  font-size: 0.92rem;
  line-height: 1.6;
  background: #fff;
}

th, td {
  border: 1px solid #cfc4b2;
  padding: 0.4rem 0.65rem;
  text-align: start;
  vertical-align: top;
}

th {
  background: var(--table-head);
  font-family: "Cairo", "Noto Sans Arabic", "Noto Naskh Arabic", sans-serif;
  font-weight: 700;
  color: var(--accent);
}

tr:nth-child(even) td {
  background: #fbf8f3;
}

ul, ol {
  margin: 0.7rem 0;
  padding-inline-start: 1.5rem;
}

li {
  margin: 0.25rem 0;
}

/* Math fonts: Arabic variables in Naskh; Latin/Greek/operators in KaTeX / DejaVu. */
@font-face {
  font-family: "KaTeX_Main";
  src: url("katex/fonts/KaTeX_Main-Regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0000-024F, U+0370-03FF, U+1D400-1D7FF, U+2000-2BFF, U+2190-21FF;
}
@font-face {
  font-family: "KaTeX_Main";
  src: url("katex/fonts/KaTeX_Main-Bold.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0000-024F, U+0370-03FF, U+2000-2BFF;
}
@font-face {
  font-family: "KaTeX_Math";
  src: url("katex/fonts/KaTeX_Math-Italic.woff2") format("woff2");
  font-weight: 400;
  font-style: italic;
  font-display: swap;
}
@font-face {
  font-family: "DejaVu Serif";
  src: url("fonts/DejaVuSerif.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "BookMath";
  src: url("fonts/NotoNaskhArabic-VariableFont_wght.ttf") format("truetype");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0600-06FF, U+0750-077F, U+08A0-08FF, U+FB50-FDFF, U+FE70-FEFF;
}
@font-face {
  font-family: "BookMath";
  src: url("fonts/DejaVuSerif.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0000-05FF, U+0370-03FF, U+1D400-1D7FF, U+2000-2BFF, U+2070-209F;
}
@font-face {
  font-family: "BookMath";
  src: url("katex/fonts/KaTeX_Main-Regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0000-024F, U+0370-03FF, U+2000-2BFF, U+2190-21FF;
}

/* Display equations: formula centered, book-style number at the visual LEFT edge. */
.eq-block {
  position: relative;
  display: block;
  margin: 1.15rem 0;
  padding: 0.15rem 5rem;
  text-align: center;
  overflow-x: auto;
  overflow-y: hidden;
}
.eq-block .eq-num {
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  direction: ltr;
  unicode-bidi: isolate;
  font-family: "Noto Naskh Arabic", "Cairo", serif;
  font-size: 1.05rem;
  font-weight: 600;
  white-space: nowrap;
  padding-inline: 0.15rem;
}
.eq-block .eq-math {
  direction: rtl;
  display: inline-block;
  max-width: 100%;
}

.math-inline {
  display: inline-block;
  direction: rtl;
  unicode-bidi: isolate;
  vertical-align: middle;
  padding: 0 0.12em;
}


/* Non-Arabic runs (Latin/Greek, digits, scientific notation) isolated LTR
   inside the overall RTL equation, so 4πε, ε₀, 6.6×10⁻³⁴ read naturally. */
math mrow[dir="ltr"] {
  direction: ltr;
  unicode-bidi: isolate;
}
/* Native MathML, forced RTL to match the printed Arabic book.
   font-family !important beats Chrome's MathML UA "math" font, which
   otherwise leaves Greek letters (ω, π, μ) as missing glyphs. */
math {
  font-family: "DejaVu Serif", "KaTeX_Main", "KaTeX_Math", "BookMath", "Noto Naskh Arabic", serif !important;
  font-style: normal;
  font-weight: 500;
}
math mtext, math mtext * {
  font-family: "Noto Naskh Arabic", "DejaVu Serif", serif !important;
  font-style: normal;
  font-weight: 500;
}
math mtext.sym, math mi, math mn, math mo {
  font-family: "DejaVu Serif", "KaTeX_Main", "KaTeX_Math-Italic", "KaTeX_Math", serif !important;
  font-style: normal;
  font-weight: 400;
}
math[display="block"] {
  font-size: 1.2em;
  margin: 0.15rem auto;
}
.math-inline math {
  font-size: 1.05em;
}
math mtext {
  font-weight: 500;
}
math mi, math mn, math mo {
  font-style: normal;
}
math menclose[notation="box"],
math menclose[notation="box"] {
  border: 1.6px solid #1c1712;
  padding: 0.28em 0.55em;
}
.math-error {
  color: #9b1c1c;
  direction: ltr;
  unicode-bidi: isolate;
  font-family: "IBM Plex Mono", "Cascadia Code", monospace;
  font-size: 0.85em;
  white-space: pre-wrap;
}

@media print {
  body { background: #fff; }
  .page { box-shadow: none; max-width: none; padding: 0; }
  .book-nav, .brand { position: static; }
  .book-nav { display: none; }
  footer .book-nav { display: flex; }
}
