/* ==========================================================
   Ibn Mālik — Islamic Articles
   Academic serif + Islamic ornamental accents
   ========================================================== */

/* --- Font faces --- */
@font-face {
  font-family: 'Amiri';
  src: url('fonts/Amiri-Regular.ttf') format('truetype');
  font-weight: normal; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Amiri';
  src: url('fonts/Amiri-Bold.ttf') format('truetype');
  font-weight: bold; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Amiri';
  src: url('fonts/Amiri-Italic.ttf') format('truetype');
  font-weight: normal; font-style: italic; font-display: swap;
}
@font-face {
  font-family: 'Amiri';
  src: url('fonts/Amiri-BoldItalic.ttf') format('truetype');
  font-weight: bold; font-style: italic; font-display: swap;
}
@font-face {
  font-family: 'AmiriQuran';
  src: url('fonts/AmiriQuran.ttf') format('truetype');
  font-weight: normal; font-style: normal; font-display: swap;
}

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

html { font-size: 18px; }

body {
  font-family: 'Palatino Linotype', 'TeX Gyre Pagella', Palatino, 'Book Antiqua', Georgia, serif;
  line-height: 1.75;
  color: #2c2c2c;
  background: #faf8f5;
  margin: 0;
  padding: 0;
}

/* --- Layout --- */
.article-body,
.page-body {
  max-width: 680px;
  margin: 0 auto;
  padding: 2rem 1.25rem 3rem;
  position: relative;
}

/* --- Header — clean, minimal --- */
.site-header {
  border-bottom: 1px solid #d8d0c4;
  padding: 0.75rem 1.5rem;
}

.nav-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  max-width: 900px;
  margin: 0 auto;
}

.nav-bar a {
  color: #5a4a32;
  text-decoration: none;
  font-size: 0.85rem;
  letter-spacing: 0.05em;
}

.nav-bar a:hover { color: #b8860b; }

.nav-home {
  font-variant: small-caps;
  font-size: 1rem !important;
  font-weight: bold;
}

/* --- PDF button (inline next to title) --- */
.pdf-side-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  color: #8a7a62;
  text-decoration: none;
  padding: 0.3rem 0.6rem;
  border-radius: 4px;
  border: 1px solid #d8d0c4;
  transition: all 0.2s;
  vertical-align: middle;
}

.pdf-side-btn:hover {
  color: #b8860b;
  border-color: #b8860b;
}

.pdf-side-btn svg {
  width: 16px;
  height: 16px;
}

.pdf-side-btn span {
  font-size: 0.65rem;
  font-variant: small-caps;
  letter-spacing: 0.1em;
}

/* Title row: title + PDF button */
.title-row {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 1rem;
  margin: 1.5rem -2rem 0.5rem;
}

/* --- Headings --- */
h1, h2, h3, h4, h5, h6 {
  font-family: 'Palatino Linotype', 'TeX Gyre Pagella', Palatino, Georgia, serif;
  color: #3a2e1f;
  line-height: 1.3;
}

/* Article title — wider than body text */
h1 {
  font-variant: small-caps;
  font-weight: normal;
  font-size: 1.8rem;
  margin: 1.5rem -2rem 0.5rem;
  text-align: center;
}

h2 {
  font-variant: small-caps;
  font-weight: normal;
  font-size: 1.35rem;
  border-bottom: 1px solid #d8d0c4;
  padding-bottom: 0.3rem;
  margin-top: 2.5rem;
}

h3 {
  font-variant: small-caps;
  font-weight: normal;
  font-size: 1.15rem;
  margin-top: 2rem;
}

/* --- Arabic text --- */
.arabic {
  font-family: 'AmiriQuran', 'Amiri', 'Traditional Arabic', serif;
  direction: rtl;
  unicode-bidi: bidi-override;
  font-size: 1.2em;
  line-height: 2;
}

/* --- Honorific spans --- */
.honorific {
  font-family: 'Amiri', 'Geeza Pro', 'Traditional Arabic', serif;
  font-size: 1.1em;
}

/* --- Basmallah --- */
.basmallah {
  font-family: 'AmiriQuran', 'Amiri', serif;
  font-size: 2rem;
  display: block;
  text-align: center;
  direction: rtl;
  margin: 0.5rem 0;
  line-height: 1.8;
}

/* --- Centered blocks (Quranic quotations) --- */
.centered {
  text-align: center;
  margin: 1.5rem auto;
  padding: 1rem;
  max-width: 90%;
}

.centered .arabic {
  display: block;
  font-size: 1.3em;
  margin-bottom: 0.75rem;
  line-height: 2.2;
}

.centered em {
  display: block;
  font-size: 0.95em;
  color: #4a4a4a;
  margin-top: 0.25rem;
}

/* --- Links --- */
a {
  color: #6b5730;
  text-decoration-color: #c4b08a;
  text-underline-offset: 2px;
}
a:hover { color: #b8860b; }

/* --- Blockquotes --- */
blockquote {
  border-left: 3px solid #d4a843;
  margin: 1.5rem 0;
  padding: 0.5rem 1.25rem;
  color: #4a4a4a;
  background: #faf6ef;
}

/* --- Lists --- */
ul, ol { padding-left: 1.5rem; }
li { margin-bottom: 0.3rem; }

/* ==========================================================
   Sidenote footnotes (Tufte-style margin notes)
   On wide screens: JS moves footnotes to the margin beside their marker.
   On narrow screens: standard bottom endnotes.
   ========================================================== */

.footnote-ref {
  font-size: 0.75em;
  vertical-align: super;
  text-decoration: none;
}

.footnote-back {
  text-decoration: none;
  margin-left: 0.3em;
}

/* Sidenotes created by JS on wide screens */
.sidenote {
  position: absolute;
  right: -300px;
  width: 260px;
  font-size: 0.78rem;
  line-height: 1.5;
  color: #666;
  padding: 0 0 0.75rem;
}

.sidenote-number {
  font-size: 0.7rem;
  font-weight: bold;
  color: #999;
  margin-right: 0.3em;
}

/* Hide the bottom footnotes section when sidenotes are active */
body.has-sidenotes section.footnotes {
  display: none;
}

/* Default bottom endnotes (narrow screens / no JS) */
section.footnotes {
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid #d8d0c4;
  font-size: 0.85rem;
  line-height: 1.6;
  color: #555;
}

section.footnotes hr { display: none; }
section.footnotes ol { padding-left: 1.25rem; }
section.footnotes li { margin-bottom: 0.5rem; }

/* --- Page break (from \newpage) --- */
hr.page-break {
  border: none;
  border-top: 1px solid #d8d0c4;
  margin: 2.5rem auto;
  width: 40%;
}

/* --- Footer --- */
.site-footer {
  border-top: 1px solid #d8d0c4;
  padding: 1rem;
  text-align: center;
  font-size: 0.85rem;
  color: #7a6a52;
  margin-top: 2rem;
}

.site-footer nav { margin-bottom: 0.5rem; }
.site-footer a { color: #5a4a32; text-decoration: none; }
.site-footer a:hover { color: #b8860b; }
.site-footer .sep { margin: 0 0.5rem; color: #c4b08a; }
.author-credit {
  font-variant: small-caps;
  margin: 0;
  letter-spacing: 0.05em;
}

/* ==========================================================
   Landing page
   ========================================================== */
.landing-basmallah {
  font-family: 'AmiriQuran', 'Amiri', serif;
  font-size: 3rem;
  text-align: center;
  direction: rtl;
  margin: 2.5rem 0 1rem;
  line-height: 1.6;
  color: #3a2e1f;
}

.landing-verse {
  text-align: center;
  max-width: 600px;
  margin: 1.5rem auto 2rem;
}

.landing-verse .arabic {
  display: block;
  font-size: 1.4em;
  line-height: 2.2;
  margin-bottom: 0.75rem;
}

.landing-verse .translation {
  font-style: italic;
  color: #5a5a5a;
  font-size: 0.95rem;
  line-height: 1.6;
}

.landing-verse .verse-ref {
  display: block;
  font-style: normal;
  font-size: 0.8rem;
  color: #999;
  margin-top: 0.5rem;
}

/* Ornamental divider */
.ornament-divider {
  text-align: center;
  color: #b8860b;
  font-size: 1.2rem;
  letter-spacing: 0.4em;
  margin: 2rem 0;
  opacity: 0.5;
}

/* --- Article cards (square, side by side) --- */
.article-list {
  list-style: none;
  padding: 0;
  max-width: 700px;
  margin: 1.5rem auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.25rem;
}

.article-card {
  background: #fff;
  border: 1px solid #e4ddd2;
  border-radius: 4px;
  padding: 1.25rem 1.5rem;
  aspect-ratio: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.article-card:hover {
  border-color: #b8860b;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.article-card-title {
  font-family: 'Palatino Linotype', Palatino, Georgia, serif;
  font-variant: small-caps;
  font-size: 1.15rem;
  color: #3a2e1f;
  text-decoration: none;
  display: block;
  margin-bottom: 0.35rem;
}

.article-card-title:hover { color: #b8860b; }

.article-card-preview {
  font-size: 0.85rem;
  color: #777;
  line-height: 1.5;
  margin-bottom: 0.5rem;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.article-card-meta {
  font-size: 0.75rem;
  color: #aaa;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.article-card-meta a {
  color: #8a7a62;
  text-decoration: none;
  font-size: 0.7rem;
  font-variant: small-caps;
  letter-spacing: 0.05em;
  padding: 0.15rem 0.5rem;
  border: 1px solid #d8d0c4;
  border-radius: 3px;
}

.article-card-meta a:hover {
  border-color: #b8860b;
  color: #b8860b;
}

/* ==========================================================
   About / methodology page
   ========================================================== */
.about-header {
  text-align: center;
  margin-bottom: 2rem;
}

.about-header h1 {
  font-variant: small-caps;
  font-weight: normal;
}

/* ==========================================================
   Responsive
   ========================================================== */
@media (max-width: 768px) {
  html { font-size: 16px; }
  .article-body, .page-body { padding: 1rem; }
  .landing-basmallah { font-size: 2.2rem; }
  .centered { max-width: 100%; padding: 0.5rem; }
  .arabic { font-size: 1.1em; }
  h1 { margin-left: 0; margin-right: 0; font-size: 1.5rem; }
  .title-row { margin-left: 0; margin-right: 0; flex-wrap: wrap; }
  .pdf-side-btn { display: none; }
  .sidenote { display: none; }
  body.has-sidenotes section.footnotes { display: block; }
}

/* ==========================================================
   Print styles
   ========================================================== */
@media print {
  .site-header, .site-footer, .pdf-side-btn { display: none; }
  body { background: white; color: black; font-size: 12pt; }
  a { color: black; text-decoration: none; }
  hr.page-break { page-break-after: always; border: none; }
}
