/* ============================================================
   موسوعة الخيل — نموذج المخطوط التراثي
   مستوحى من الزخرفة الإسلامية وكتب المخطوطات
   ============================================================ */

:root {
  --parchment: #f3e3c0;
  --parchment-deep: #e9d4a5;
  --parchment-edge: #d4b87a;
  --ink: #2a1707;
  --ink-soft: rgba(42, 23, 7, .78);
  --ink-mute: rgba(42, 23, 7, .55);
  --burgundy: #6e1e1e;
  --burgundy-deep: #4a1212;
  --teal: #134848;
  --gold: #b8864a;
  --gold-deep: #8a5a2b;
  --gold-light: #d9b378;

  --font-display: "Amiri", serif;
  --font-kufi: "Reem Kufi", "Amiri", serif;

  --maxw: 760px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body.heritage-body {
  margin: 0;
  font-family: var(--font-display);
  color: var(--ink);
  line-height: 2;
  font-size: 17px;
  background: var(--parchment);
}

/* ===================== Parchment background ===================== */
.parchment-bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(ellipse at 20% 10%, rgba(184, 134, 74, .14), transparent 45%),
    radial-gradient(ellipse at 80% 90%, rgba(110, 30, 30, .10), transparent 45%),
    radial-gradient(ellipse at 50% 50%, transparent 60%, rgba(74, 39, 12, .18) 100%),
    linear-gradient(180deg, #f3e3c0 0%, #e8d5a8 100%);
}
.parchment-bg::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 220 220'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.18  0 0 0 0 0.10  0 0 0 0 0.04  0 0 0 0.18 0'/></filter><rect width='220' height='220' filter='url(%23n)'/></svg>");
  background-size: 220px 220px;
  opacity: .45;
  pointer-events: none;
  mix-blend-mode: multiply;
}

/* ===================== Manuscript container ===================== */
.manuscript {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 48px 28px 32px;
}

.page {
  padding: 36px 12px;
  position: relative;
  scroll-margin-top: 20px;
}
.page + .page {
  border-top: 1px solid rgba(110, 30, 30, .12);
  padding-top: 56px;
}

/* ===================== Section heading ===================== */
.section-h {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(22px, 3vw, 30px);
  color: var(--burgundy);
  text-align: center;
  margin: 0 0 10px;
  letter-spacing: .2px;
}
.rule {
  width: 56px;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--gold) 30%, var(--gold) 70%, transparent);
  margin: 0 auto 28px;
  border-radius: 2px;
  opacity: .85;
}

/* ===================== Diamond divider ===================== */
.diamond-divider {
  display: block;
  width: 240px;
  height: 16px;
  margin: 28px auto;
  position: relative;
  color: var(--gold);
}
.diamond-divider::before {
  content: "";
  position: absolute;
  top: 50%;
  inset-inline: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, currentColor 18%, currentColor 82%, transparent);
  transform: translateY(-50%);
}
.diamond-divider::after {
  content: "";
  position: absolute;
  top: 50%;
  inset-inline-start: 50%;
  width: 11px;
  height: 11px;
  background: currentColor;
  transform: translate(50%, -50%) rotate(45deg);
  box-shadow: 0 0 0 4px var(--parchment), 0 0 0 5px var(--gold);
}
.diamond-divider.small { width: 150px; }

/* ===================== Frontispiece ===================== */
.frame {
  position: relative;
  padding: 56px 36px;
  border: 1px solid var(--gold);
  background:
    linear-gradient(rgba(255, 252, 240, .35), rgba(255, 252, 240, .35)),
    var(--parchment);
  text-align: center;
  margin-block: 24px;
  box-shadow:
    inset 0 0 0 8px var(--parchment),
    inset 0 0 0 9px var(--gold-light),
    0 12px 36px -16px rgba(74, 39, 12, .35);
}
.frame-corner {
  position: absolute;
  width: 36px; height: 36px;
  color: var(--gold);
  background:
    radial-gradient(circle at 6px 6px, currentColor 0 3px, transparent 4px),
    linear-gradient(currentColor, currentColor) top/100% 1px no-repeat,
    linear-gradient(currentColor, currentColor) right/1px 100% no-repeat;
  opacity: .85;
}
.frame-corner.tl { top: -2px; inset-inline-start: -2px; }
.frame-corner.tr { top: -2px; inset-inline-end: -2px; transform: scaleX(-1); }
.frame-corner.bl { bottom: -2px; inset-inline-start: -2px; transform: scaleY(-1); }
.frame-corner.br { bottom: -2px; inset-inline-end: -2px; transform: scale(-1, -1); }

.ornament { color: var(--gold-deep); display: flex; justify-content: center; margin: 0 auto 18px; }
.ornament-bottom { margin: 18px auto 0; }
.ornament-end { margin: 24px auto; color: var(--gold-deep); }

.bism {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 16px;
  color: var(--burgundy);
  margin: 0 0 8px;
  letter-spacing: 1px;
}

.manuscript-title {
  font-family: var(--font-display);
  margin: 0;
  line-height: 1.3;
}
.title-line {
  display: block;
  font-size: clamp(30px, 5vw, 48px);
  font-weight: 700;
  color: var(--burgundy-deep);
  letter-spacing: .5px;
  text-shadow: 0 1px 0 rgba(184, 134, 74, .35);
}
.title-sub {
  display: block;
  font-size: clamp(18px, 2.4vw, 24px);
  font-weight: 400;
  color: var(--ink);
  margin-top: 6px;
  font-style: italic;
}

.frontispiece-blurb {
  max-width: 540px;
  margin: 18px auto 6px;
  font-size: 17px;
  color: var(--ink);
  line-height: 2;
}
.folio {
  text-align: center;
  font-size: 13px;
  color: var(--ink-mute);
  font-style: italic;
  letter-spacing: 2px;
  margin: 24px 0 0;
}

/* ===================== Prose ===================== */
.manuscript-prose {
  font-size: 17px;
  line-height: 2.1;
  margin: 0 0 18px;
  text-align: justify;
  color: var(--ink);
  hyphens: auto;
}
.manuscript-prose.center { text-align: center; }
.manuscript-prose em {
  font-style: normal;
  color: var(--burgundy);
  font-weight: 700;
  border-bottom: 1px dotted var(--gold-deep);
  padding-bottom: 1px;
}

.dropcap {
  font-family: var(--font-display);
  font-size: 2.6em;
  line-height: .9;
  color: var(--burgundy);
  font-weight: 700;
  margin-inline-end: 4px;
  display: inline-block;
  vertical-align: -10px;
  text-shadow: 1px 1px 0 var(--gold-light);
}

.kalam-attr {
  text-align: end;
  font-style: italic;
  color: var(--ink-mute);
  font-size: 15px;
  margin: 8px 0 0;
}

/* ===================== Doors ===================== */
.doors-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  margin-top: 22px;
}
.door {
  position: relative;
  padding: 22px 22px 20px;
  background: rgba(255, 252, 240, .55);
  border: 1px solid var(--gold-light);
  text-align: center;
}
.door::before,
.door::after {
  content: "";
  position: absolute;
  width: 12px; height: 12px;
  border: 1px solid var(--gold);
}
.door::before { top: -1px; inset-inline-start: -1px; border-inline-end: none; border-block-end: none; }
.door::after  { bottom: -1px; inset-inline-end: -1px; border-inline-start: none; border-block-start: none; }
.door-num {
  display: inline-block;
  font-family: var(--font-display);
  font-size: 32px;
  color: var(--gold-deep);
  font-weight: 700;
  margin-bottom: 6px;
  width: 48px; height: 48px;
  line-height: 48px;
  border: 1px solid var(--gold);
  border-radius: 50%;
  background: var(--parchment);
}
.door h3 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 19px;
  margin: 8px 0 6px;
  color: var(--burgundy);
}
.door p {
  margin: 0;
  font-size: 14.5px;
  color: var(--ink-soft);
  line-height: 1.8;
}

/* ===================== Chapter figure ===================== */
.chapter-figure {
  margin: 0 0 22px;
  text-align: center;
}
.figure-art {
  max-width: 420px;
  margin: 0 auto;
  aspect-ratio: 280 / 200;
  border: 1px solid var(--gold);
  padding: 6px;
  background: var(--parchment-deep);
  box-shadow: 0 8px 22px -12px rgba(74, 39, 12, .4);
}
.chapter-figure figcaption {
  margin-top: 8px;
  font-size: 13px;
  color: var(--ink-mute);
  font-style: italic;
}

/* ===================== Annals (timeline) ===================== */
.annals-list {
  list-style: none;
  padding: 0;
  margin: 0;
  position: relative;
}
.annals-list::before {
  content: "";
  position: absolute;
  inset-block: 8px;
  inset-inline-start: 50%;
  width: 2px;
  background: repeating-linear-gradient(180deg, var(--gold) 0 6px, transparent 6px 10px);
  transform: translateX(50%);
}
.annals-list li {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: center;
  gap: 28px;
  padding: 18px 0;
}
.annals-list li::before {
  content: "";
  position: absolute;
  inset-inline-start: 50%;
  top: 50%;
  width: 14px; height: 14px;
  background: var(--burgundy);
  border: 2px solid var(--gold);
  border-radius: 50%;
  transform: translate(50%, -50%);
  z-index: 1;
  box-shadow: 0 0 0 4px var(--parchment);
}
.annals-list li:nth-child(even) { direction: ltr; }
.annals-list li:nth-child(even) > * { direction: rtl; }
.annal-year {
  font-family: var(--font-kufi);
  font-weight: 700;
  font-size: 16px;
  color: var(--burgundy);
  text-align: center;
}
.annal-body {
  background: rgba(255, 252, 240, .55);
  border: 1px solid var(--gold-light);
  padding: 12px 16px;
}
.annal-body h4 {
  font-family: var(--font-display);
  font-size: 18px;
  margin: 0 0 4px;
  color: var(--burgundy-deep);
}
.annal-body p {
  margin: 0;
  font-size: 14.5px;
  color: var(--ink-soft);
  line-height: 1.8;
}

/* ===================== Steeds (cartouches) ===================== */
.steeds-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}
.cartouche {
  padding: 4px;
  background: linear-gradient(135deg, var(--gold-light), var(--gold), var(--gold-deep));
  border-radius: 22px;
  box-shadow: 0 8px 22px -14px rgba(74, 39, 12, .45);
}
.cartouche-frame {
  background: var(--parchment);
  border-radius: 18px;
  padding: 20px 22px;
  text-align: center;
  border: 1px solid rgba(184, 134, 74, .35);
}
.cartouche-kind {
  display: inline-block;
  font-family: var(--font-kufi);
  font-size: 12px;
  letter-spacing: 1px;
  color: var(--teal);
  background: rgba(19, 72, 72, .08);
  padding: 4px 12px;
  border-radius: 999px;
  margin-bottom: 8px;
}
.cartouche-frame h3 {
  font-family: var(--font-display);
  font-size: 22px;
  margin: 4px 0 8px;
  color: var(--burgundy);
  font-weight: 700;
}
.cartouche-frame p {
  margin: 0;
  font-size: 14.5px;
  color: var(--ink-soft);
  line-height: 1.85;
}

/* ===================== Lexicon ===================== */
.lexicon-list {
  margin: 24px 0 0;
  padding: 0;
  display: grid;
  gap: 14px;
}
.lex-entry {
  display: grid;
  grid-template-columns: 130px 1fr;
  gap: 18px;
  padding: 14px 18px;
  background: rgba(255, 252, 240, .55);
  border-inline-start: 3px solid var(--gold);
  align-items: baseline;
}
.lex-entry dt {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 22px;
  color: var(--burgundy);
  text-align: center;
  background: var(--parchment-deep);
  padding: 6px 10px;
  border: 1px dashed var(--gold);
}
.lex-entry dd {
  margin: 0;
  font-size: 15px;
  line-height: 1.95;
  color: var(--ink);
}

/* ===================== Colophon ===================== */
.page-colophon {
  text-align: center;
  padding-block: 60px;
}
.colophon-text {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  color: var(--burgundy);
  margin: 18px 0 6px;
}
.colophon-meta {
  font-size: 14px;
  color: var(--ink-mute);
  font-style: italic;
  margin: 0;
  line-height: 1.9;
}

/* ===================== Theme chooser (shared) ===================== */
.theme-chooser {
  position: fixed;
  bottom: 22px;
  inset-inline-start: 22px;
  z-index: 999;
}
.chooser-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--burgundy);
  color: #fff8e8;
  padding: 11px 18px;
  border-radius: 999px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, .28);
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
  border: 1px solid var(--burgundy-deep);
  cursor: pointer;
  transition: background .18s ease, transform .18s ease, box-shadow .18s ease;
}
.chooser-toggle:hover {
  background: var(--burgundy-deep);
  transform: translateY(-2px);
  box-shadow: 0 10px 22px rgba(0, 0, 0, .35);
}
.chooser-icon { font-size: 16px; line-height: 1; color: var(--gold-light); }
.chooser-label { line-height: 1; }

.chooser-menu {
  list-style: none;
  padding: 8px;
  margin: 0;
  position: absolute;
  bottom: calc(100% + 10px);
  inset-inline-start: 0;
  min-width: 200px;
  background: #fff8e8;
  border: 1px solid var(--gold);
  border-radius: 14px;
  box-shadow: 0 14px 36px rgba(0, 0, 0, .25);
  opacity: 0;
  visibility: hidden;
  transform: translateY(6px);
  transition: opacity .18s ease, transform .18s ease, visibility .18s;
}
.theme-chooser.is-open .chooser-menu {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}
.chooser-menu li { margin: 0; }
.chooser-menu a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 9px;
  color: var(--ink);
  text-decoration: none;
  font-size: 14px;
  font-family: var(--font-display);
  transition: background .14s ease;
}
.chooser-menu a:hover { background: rgba(184, 134, 74, .15); }
.chooser-menu a.is-active {
  background: var(--burgundy);
  color: #fff8e8;
  font-weight: 700;
  pointer-events: none;
}
.chooser-dot {
  display: inline-block;
  width: 12px; height: 12px;
  border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, .25);
  flex-shrink: 0;
}
.chooser-dot[data-tone="modern"]   { background: linear-gradient(135deg, #c9a961, #6b3410); }
.chooser-dot[data-tone="wiki"]     { background: linear-gradient(135deg, #cedff2, #0645ad); }
.chooser-dot[data-tone="heritage"] { background: linear-gradient(135deg, #b8864a, #6e1e1e); }
.chooser-dot[data-tone="gallery"]  { background: linear-gradient(135deg, #e6c878, #15100a); }
.chooser-dot[data-tone="portal"]   { background: linear-gradient(135deg, #11a195, #095a54); }
.chooser-dot[data-tone="magazine"] { background: linear-gradient(135deg, #8b1e1e, #1a1a18); }
.chooser-dot[data-tone="guide"]    { background: linear-gradient(135deg, #6e69e0, #3a35a3); }
.chooser-dot[data-tone="bento"]    { background: linear-gradient(135deg, #c89048, #2b2118); }
.chooser-dot[data-tone="platform"] { background: linear-gradient(135deg, #c2a04a, #16243a); }
.chooser-dot[data-tone="digest"]   { background: linear-gradient(135deg, #ac7a36, #34271a); }

/* الشعار الرسمي في واجهة المخطوط */
.hr-frontis-logo { display: block; height: 120px; width: auto; margin: 0 auto 6px; }

/* ====== صور حقيقية للخيل العربي ====== */
.figure-art { background: url("images/arabian-white-field.jpg") center/cover; }
.figure-art svg { display: none; }
.chooser-menu a.is-active .chooser-dot { border-color: #fff8e8; }

/* ===================== Responsive ===================== */
@media (max-width: 720px) {
  .manuscript { padding: 28px 16px 20px; }
  .frame { padding: 36px 18px; }

  .doors-grid { grid-template-columns: 1fr; gap: 14px; }
  .steeds-grid { grid-template-columns: 1fr; }

  .annals-list::before { inset-inline-start: 14px; transform: none; }
  .annals-list li {
    grid-template-columns: 1fr;
    gap: 8px;
    padding-inline-start: 36px;
  }
  .annals-list li::before {
    inset-inline-start: 14px;
    top: 28px;
    transform: translateX(50%);
  }
  .annals-list li:nth-child(even) { direction: rtl; }
  .annal-year { text-align: start; font-size: 14px; }

  .lex-entry { grid-template-columns: 1fr; gap: 8px; padding: 12px 14px; }
  .lex-entry dt { font-size: 20px; padding: 4px 8px; }
}

@media (max-width: 480px) {
  body.heritage-body { font-size: 16px; }
  .title-line { font-size: 28px; }
  .title-sub { font-size: 17px; }
  .frontispiece-blurb { font-size: 15.5px; }
  .manuscript-prose { font-size: 15.5px; line-height: 1.95; }
  .dropcap { font-size: 2.2em; }

  .chooser-label { display: none; }
  .chooser-toggle { padding: 10px 12px; }
  .theme-chooser { bottom: 14px; inset-inline-start: 14px; }
}
