/* Alfouz — shared stylesheet. Design tokens match the approved
   "Heritage Modern" direction: deep emerald + gold, warm cream. */

:root {
  --emerald: #173F32;
  --emerald-light: #1F5744;
  --emerald-darker: #142E25;
  --gold: #C6963C;
  --cream: #F7F1E4;
  --cream-alt: #FBF7EE;
  --border: #E3D6B8;
  --text-dark: #1C1C1A;
  --text-body: #4B4740;
  --text-muted: #8A867C;
  --footer-text: #A9B4AB;
  --radius: 4px;
  --max-width: 1180px;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  background: var(--cream);
  color: var(--text-dark);
  font-family: "Work Sans", "Segoe UI", Tahoma, sans-serif;
  line-height: 1.5;
}

[dir="rtl"] body {
  font-family: "Noto Naskh Arabic", "Work Sans", Tahoma, sans-serif;
}

h1, h2, h3 {
  font-family: "Newsreader", Georgia, serif;
  font-weight: 500;
  margin: 0;
}

a { color: var(--gold); text-decoration: none; }
a:hover { color: #a97c2e; }

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

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

/* ---------- Header ---------- */

.site-header {
  background: var(--emerald);
  padding: 18px 0;
}

.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 10px;
  color: var(--cream-alt);
}

.brand .kufi {
  font-family: "Reem Kufi", sans-serif;
  font-size: 24px;
  color: var(--gold);
}

.brand .latin {
  font-size: 12px;
  letter-spacing: 2px;
}

.main-nav {
  display: flex;
  align-items: center;
  gap: 26px;
  flex-wrap: wrap;
}

.main-nav a {
  color: #EFE7D6;
  font-size: 14px;
  padding-bottom: 4px;
  border-bottom: 2px solid transparent;
}

.main-nav a:hover,
.main-nav a.active {
  color: var(--gold);
  border-bottom-color: var(--gold);
}

.lang-switcher {
  position: relative;
}

.lang-switcher summary {
  list-style: none;
  cursor: pointer;
  font-size: 12px;
  letter-spacing: 1px;
  color: var(--gold);
  border: 1px solid var(--gold);
  border-radius: 3px;
  padding: 7px 14px;
}

.lang-switcher summary::-webkit-details-marker { display: none; }

.lang-switcher[open] summary { background: var(--emerald-light); }

.lang-menu {
  position: absolute;
  inset-inline-end: 0;
  top: calc(100% + 6px);
  background: var(--cream-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px;
  min-width: 140px;
  z-index: 20;
}

.lang-menu a {
  display: block;
  padding: 8px 10px;
  color: var(--text-dark);
  font-size: 14px;
  border-radius: 3px;
}

.lang-menu a:hover { background: var(--border); }

/* ---------- Buttons ---------- */

.btn {
  display: inline-block;
  font-size: 14px;
  font-weight: 600;
  padding: 13px 26px;
  border-radius: 3px;
  border: 1px solid transparent;
  cursor: pointer;
}

.btn-primary { background: var(--gold); color: var(--text-dark); }
.btn-primary:hover { background: #b8862e; color: var(--text-dark); }

.btn-outline {
  background: transparent;
  border-color: var(--gold);
  color: var(--gold);
}

.btn-dark { background: var(--emerald); color: var(--cream-alt); }

/* ---------- Hero ---------- */

.hero {
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  gap: 48px;
  align-items: center;
  padding: 72px 0;
}

.hero .eyebrow {
  font-family: "Reem Kufi", sans-serif;
  color: var(--gold);
  font-size: 17px;
}
[dir="ltr"] .eyebrow.latin-eyebrow {
  font-family: "Work Sans", sans-serif;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 1.5px;
}

.hero h1 { font-size: 42px; line-height: 1.15; margin: 14px 0; max-width: 22ch; }
.hero p { color: var(--text-body); max-width: 46ch; margin-bottom: 24px; }
.hero-actions { display: flex; gap: 24px; align-items: center; flex-wrap: wrap; }

.hero-art {
  height: 380px;
  border-radius: 6px;
  background: #EFE4C8;
  position: relative;
  overflow: hidden;
}
.hero-art .block { position: absolute; border-radius: 3px; box-shadow: 0 18px 30px rgba(23,63,50,0.2); }

.divider-strip {
  height: 20px;
  background-color: var(--emerald);
  background-image: repeating-linear-gradient(135deg, var(--gold) 0px, var(--gold) 2px, transparent 2px, transparent 13px);
  opacity: 0.55;
}

/* ---------- Sections ---------- */

.section { padding: 72px 0; }
.section.alt { background: var(--cream-alt); }
.section.dark { background: var(--emerald); color: var(--cream-alt); }
.section.dark h2 { color: var(--cream-alt); }
.section.dark p { color: #C9CFC7; }

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 20px;
  margin-bottom: 32px;
  flex-wrap: wrap;
}

.section-head h2 { font-size: 28px; }
.eyebrow-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 1.5px;
  color: var(--gold);
  margin-bottom: 8px;
}

.grid {
  display: grid;
  gap: 26px;
}
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }

@media (max-width: 900px) {
  .hero { grid-template-columns: 1fr; }
  .grid-3, .grid-4, .grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .main-nav { order: 3; width: 100%; justify-content: flex-start; }
}
@media (max-width: 560px) {
  .grid-3, .grid-4, .grid-2 { grid-template-columns: 1fr; }
  .hero h1 { font-size: 32px; }
}

.pillar-card, .program-card {
  padding: 26px;
  background: var(--cream);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.program-photo {
  height: 110px;
  width: 110px;
  flex-shrink: 0;
  border-radius: 4px;
  object-fit: cover;
}
.program-photo-placeholder {
  background: var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  color: #8A7E5F;
  text-align: center;
}
.section.alt .pillar-card { background: var(--cream); }

/* ---------- Book cards ---------- */

.book-card { display: flex; flex-direction: column; gap: 10px; }
.book-cover {
  position: relative;
  height: 230px;
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  text-align: center;
}
.book-cover-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
/* Once a real cover image has loaded, the placeholder title text
   underneath it is redundant (the cover already shows the title
   graphically) — hide it, but keep the lock badge on top. */
.book-cover.has-cover .title { display: none; }
.book-cover .title { font-family: "Reem Kufi", sans-serif; font-size: 16px; position: relative; z-index: 1; }
.book-cover .lock {
  position: absolute;
  top: 10px;
  inset-inline-end: 10px;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: rgba(0,0,0,0.25);
  display: flex; align-items: center; justify-content: center;
}
.tag {
  align-self: flex-start;
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 1px;
  color: var(--emerald);
  background: var(--border);
  padding: 2px 8px;
  border-radius: 2px;
}
[dir="rtl"] .tag { align-self: flex-end; }

/* ---------- Post cards ---------- */

.post-card { display: flex; flex-direction: column; gap: 12px; }
.post-thumb {
  height: 190px;
  border-radius: var(--radius);
  background: var(--border);
  display: flex; align-items: center; justify-content: center;
  color: #8A7E5F;
  font-size: 12px;
}
.post-card .category { font-size: 10px; font-weight: 600; letter-spacing: 1px; color: var(--gold); }
.post-card h3 { font-size: 18px; line-height: 1.3; }
.post-meta { font-size: 12px; color: var(--text-muted); }

.featured-post {
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  gap: 44px;
  align-items: center;
  background: var(--cream-alt);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  margin-bottom: 48px;
}
.featured-post .post-thumb { height: 100%; border-radius: 0; }
.featured-post .content { padding: 40px 44px; display: flex; flex-direction: column; gap: 14px; }
@media (max-width: 900px) { .featured-post { grid-template-columns: 1fr; } .featured-post .post-thumb { height: 220px; } }

.filter-chips { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 36px; }
.chip {
  font-size: 13px;
  padding: 10px 20px;
  border-radius: 20px;
  border: 1px solid var(--border);
  color: var(--text-body);
}
.chip.active { background: var(--emerald); color: var(--cream-alt); border-color: var(--emerald); }

/* ---------- Search / filters ---------- */

.search-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 13px 18px;
  flex-grow: 1;
  min-width: 260px;
}
.search-bar input {
  border: none;
  outline: none;
  font-size: 14px;
  flex-grow: 1;
  background: transparent;
  font-family: inherit;
  color: var(--text-dark);
}
.filter-row { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; margin-bottom: 40px; }
.filter-pill {
  font-size: 13px;
  padding: 11px 20px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  color: var(--text-body);
}
.filter-pill.active { background: var(--emerald); color: var(--cream-alt); border-color: var(--emerald); }

/* ---------- Article body ---------- */

.article-body {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 24px 60px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  font-size: 17px;
  line-height: 1.8;
}
.article-body blockquote {
  margin: 0;
  border-inline-start: 3px solid var(--gold);
  padding-inline-start: 24px;
  font-family: "Newsreader", serif;
  font-style: italic;
  font-size: 22px;
  color: var(--emerald);
}

/* ---------- Reader ---------- */

/* Chevron/arrow icons whose meaning is directional (back, previous,
   next) need to visually point the other way once the page flips to
   right-to-left — the browser already re-positions these elements for
   RTL automatically, but it never re-draws the icon inside them. */
[dir="rtl"] .rtl-flip { transform: scaleX(-1); }

.reader-shell {
  background: var(--emerald-darker);
  height: 100vh;
  display: flex;
  flex-direction: column;
  color: var(--cream-alt);
  overflow: hidden;
}

.reader-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 24px;
  background: var(--emerald);
  border-bottom: 1px solid #22463A;
  flex-wrap: wrap;
}

.reader-search {
  position: relative;
  flex-grow: 1;
  max-width: 280px;
}

.reader-search-results {
  position: absolute;
  top: calc(100% + 8px);
  inset-inline-start: 0;
  width: 100%;
  min-width: 280px;
  max-height: 340px;
  overflow-y: auto;
  background: #14312A;
  border: 1px solid #2E5747;
  border-radius: var(--radius);
  box-shadow: 0 16px 40px rgba(0,0,0,0.45);
  z-index: 20;
}

.reader-search-results .result-item {
  display: flex;
  flex-direction: column;
  gap: 3px;
  width: 100%;
  text-align: start;
  padding: 10px 14px;
  background: none;
  border: none;
  border-bottom: 1px solid #22463A;
  color: var(--cream-alt);
  cursor: pointer;
  font-family: inherit;
}
.reader-search-results .result-item:last-child { border-bottom: none; }
.reader-search-results .result-item:hover,
.reader-search-results .result-item:focus { background: #1C3C31; }
.reader-search-results .result-page {
  font-size: 11px;
  color: var(--gold, #C9A24A);
  font-weight: 600;
}
.reader-search-results .result-snippet {
  font-size: 13px;
  color: #C9CFC7;
  line-height: 1.5;
}
.reader-search-results .result-empty {
  padding: 14px;
  font-size: 13px;
  color: #8FA096;
}

.reader-badge {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.5px;
  color: var(--gold);
  border: 1px solid var(--gold);
  border-radius: 3px;
  padding: 6px 12px;
  white-space: nowrap;
}

.reader-body { flex-grow: 1; display: flex; min-height: 0; }

.reader-thumbs {
  width: 108px;
  flex-shrink: 0;
  background: #0F241D;
  padding: 18px 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
  overflow-y: auto;
  min-height: 0;
}
.reader-thumbs .thumb {
  width: 100%;
  flex-shrink: 0;
  aspect-ratio: 3/4;
  background: #1C3C31;
  border-radius: 2px;
  cursor: pointer;
  border: 2px solid transparent;
}
.reader-thumbs .thumb.active { border-color: var(--gold); }

.reader-page-area {
  flex-grow: 1;
  min-height: 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 24px;
  user-select: none;
  overflow: hidden;
}

.reader-page-frame {
  display: flex;
  align-items: center;
  justify-content: center;
  max-width: min(94vw, 920px);
  max-height: calc(86vh - 50px);
  box-shadow: 0 20px 50px rgba(0,0,0,0.4);
  border-radius: 2px;
  background: var(--cream-alt);
  position: relative;
}
.reader-page-frame canvas {
  display: block;
  max-width: 100%;
  max-height: calc(86vh - 50px);
  width: auto;
  height: auto;
  border-radius: 2px;
}

.reader-controls { display: flex; align-items: center; gap: 20px; font-size: 13px; color: #C9CFC7; }
.reader-controls button {
  background: none;
  border: none;
  color: #C9CFC7;
  cursor: pointer;
  padding: 6px;
}
.reader-controls button:disabled { opacity: 0.35; cursor: default; }

/* ---------- Footer ---------- */

.site-footer { background: var(--emerald-darker); color: var(--footer-text); padding: 56px 0 0; }
.footer-grid { display: grid; grid-template-columns: 1.4fr 1fr 1fr 1fr; gap: 40px; padding-bottom: 40px; }
.footer-grid h4 { color: #EFE7D6; font-size: 13px; margin-bottom: 10px; }
.footer-grid a, .footer-grid span { display: block; font-size: 13px; color: var(--footer-text); margin-bottom: 8px; }
.footer-bottom {
  border-top: 1px solid #22463A;
  padding: 22px 0 26px;
  font-size: 12px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
@media (max-width: 700px) { .footer-grid { grid-template-columns: 1fr 1fr; } }

/* ---------- Admin ---------- */

.admin-shell { max-width: 640px; margin: 60px auto; padding: 0 24px; }
.admin-card { background: var(--cream-alt); border: 1px solid var(--border); border-radius: var(--radius); padding: 36px; }
.form-field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 18px; }
.form-field label { font-size: 13px; font-weight: 600; color: var(--text-body); }
.form-field input, .form-field select, .form-field textarea {
  font-family: inherit;
  font-size: 14px;
  padding: 11px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  color: var(--text-dark);
}
.form-field textarea { resize: vertical; }
.admin-table { width: 100%; border-collapse: collapse; }
.admin-table th, .admin-table td { text-align: start; padding: 10px 8px; border-bottom: 1px solid var(--border); font-size: 14px; }
.flash { background: #E6F0DA; border: 1px solid #B9D89B; padding: 12px 16px; border-radius: var(--radius); margin-bottom: 20px; font-size: 14px; }
.error { background: #F6DEDA; border: 1px solid #E3A79B; padding: 12px 16px; border-radius: var(--radius); margin-bottom: 20px; font-size: 14px; }

/* ---------- Stats ---------- */
.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 1px; background: var(--border); border-radius: 6px; overflow: hidden; margin-bottom: 60px; }
.stat-cell { background: var(--emerald); padding: 30px 24px; display: flex; flex-direction: column; gap: 6px; }
.stat-cell .num { font-family: "Newsreader", serif; font-weight: 600; font-size: 32px; color: var(--gold); }
.stat-cell .label { font-size: 13px; color: #C9CFC7; }
@media (max-width: 700px) { .stats-grid { grid-template-columns: repeat(2, minmax(0,1fr)); } }

.timeline-row { display: flex; gap: 24px; padding: 20px 0; border-bottom: 1px solid var(--border); }
.timeline-row .year { width: 80px; flex-shrink: 0; font-family: "Newsreader", serif; font-weight: 600; color: var(--gold); }
