:root {
  --bg: #f6f1e7;
  --bg-soft: #fbf8f1;
  --surface: #ffffff;
  --ink: #1c2321;
  --ink-soft: #55605c;
  --primary: #0f3d3e;
  --primary-2: #14595a;
  --gold: #c69a4b;
  --gold-soft: #e7d3a6;
  --line: #e6ddcb;
  --shadow: 0 10px 30px rgba(15, 61, 62, 0.10);
  --radius: 16px;
  --radius-sm: 10px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(1200px 500px at 100% -10%, rgba(198,154,75,0.10), transparent 60%),
    var(--bg);
  line-height: 1.55;
}

html[dir="rtl"] body {
  font-family: "Cairo", "Amiri", system-ui, sans-serif;
}

a { color: var(--primary-2); }

/* ---------- Header ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--primary);
  color: #fff;
  border-bottom: 3px solid var(--gold);
}
.header-inner {
  max-width: 1080px;
  margin: 0 auto;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  font-size: 26px;
  color: var(--gold);
  line-height: 1;
}
.brand-text { display: flex; flex-direction: column; }
.brand-title { font-weight: 700; font-size: 18px; letter-spacing: .3px; }
.brand-sub { font-size: 12px; color: var(--gold-soft); }

.lang-toggle {
  background: rgba(255,255,255,0.10);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.35);
  border-radius: 999px;
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background .2s ease, transform .15s ease;
}
.lang-toggle:hover { background: rgba(255,255,255,0.20); }
.lang-toggle:active { transform: scale(.97); }

/* ---------- Layout ---------- */
.container { max-width: 1080px; margin: 0 auto; padding: 0 20px 60px; }

.hero { padding: 44px 0 26px; text-align: center; }
.hero-title {
  font-family: "Cormorant Garamond", serif;
  font-weight: 700;
  font-size: clamp(30px, 5vw, 46px);
  line-height: 1.1;
  margin: 0 0 12px;
  color: var(--primary);
}
html[dir="rtl"] .hero-title { font-family: "Amiri", "Cairo", serif; }
.hero-lead {
  max-width: 640px;
  margin: 0 auto;
  color: var(--ink-soft);
  font-size: 16px;
}

/* ---------- Controls ---------- */
.controls { margin-top: 8px; }
.search-box {
  position: relative;
  max-width: 520px;
  margin: 0 auto 18px;
}
.search-icon {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  inset-inline-start: 16px;
  font-size: 20px;
  color: var(--ink-soft);
  pointer-events: none;
}
#search {
  width: 100%;
  padding: 13px 18px 13px 46px;
  font-size: 15px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow);
  outline: none;
  transition: border-color .2s ease;
}
html[dir="rtl"] #search { padding: 13px 46px 13px 18px; }
#search:focus { border-color: var(--gold); }

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-bottom: 26px;
}
.chip {
  border: 1px solid var(--line);
  background: var(--bg-soft);
  color: var(--ink-soft);
  border-radius: 999px;
  padding: 7px 15px;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  transition: all .18s ease;
  font-family: inherit;
}
.chip:hover { border-color: var(--gold); color: var(--ink); }
.chip.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.chip .chip-icon { margin-inline-end: 6px; color: var(--gold); }
.chip.active .chip-icon { color: var(--gold-soft); }

.results-meta {
  color: var(--ink-soft);
  font-size: 13px;
  margin-bottom: 12px;
  min-height: 18px;
}

/* ---------- Grid ---------- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 18px;
}
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  cursor: pointer;
  text-align: start;
  position: relative;
  overflow: hidden;
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
  display: flex;
  flex-direction: column;
  gap: 10px;
  font-family: inherit;
  color: inherit;
}
.card::before {
  content: "";
  position: absolute;
  inset-block-start: 0;
  inset-inline-start: 0;
  width: 100%;
  height: 4px;
  background: linear-gradient(90deg, var(--gold), transparent);
  opacity: 0;
  transition: opacity .2s ease;
}
.card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow);
  border-color: var(--gold-soft);
}
.card:hover::before { opacity: 1; }
.card-tag {
  align-self: flex-start;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--primary-2);
  background: rgba(20,89,90,0.08);
  border-radius: 999px;
  padding: 3px 10px;
}
.card-name {
  font-family: "Cormorant Garamond", serif;
  font-size: 24px;
  font-weight: 700;
  color: var(--primary);
  margin: 0;
  line-height: 1.15;
}
.card-arabic {
  font-family: "Amiri", serif;
  font-size: 19px;
  color: var(--ink);
  direction: rtl;
}
.card-dates { font-size: 12.5px; color: var(--ink-soft); }
.card-bio {
  font-size: 13.5px;
  color: var(--ink-soft);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card-foot {
  margin-top: auto;
  padding-top: 6px;
  font-size: 12.5px;
  color: var(--gold);
  font-weight: 600;
}

.empty { text-align: center; color: var(--ink-soft); padding: 40px 0; }

/* ---------- Modal ---------- */
.modal[hidden] { display: none; }
.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 40px 16px;
  overflow-y: auto;
}
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15,35,33,0.55);
  backdrop-filter: blur(3px);
}
.modal-card {
  position: relative;
  background: var(--surface);
  border-radius: var(--radius);
  max-width: 720px;
  width: 100%;
  box-shadow: 0 24px 60px rgba(0,0,0,0.28);
  border-top: 4px solid var(--gold);
  animation: pop .22s ease;
}
@keyframes pop { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
.modal-close {
  position: absolute;
  inset-block-start: 14px;
  inset-inline-end: 14px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 50%;
  width: 34px;
  height: 34px;
  cursor: pointer;
  font-size: 14px;
  color: var(--ink-soft);
}
.modal-close:hover { color: var(--ink); border-color: var(--gold); }

.fiche-head { padding: 30px 30px 18px; border-bottom: 1px solid var(--line); }
.fiche-tag {
  font-size: 12px; font-weight: 600; color: var(--primary-2);
  background: rgba(20,89,90,0.08); border-radius: 999px; padding: 4px 12px;
}
.fiche-name {
  font-family: "Cormorant Garamond", serif;
  font-size: 34px; font-weight: 700; color: var(--primary);
  margin: 12px 0 2px;
}
.fiche-arabic { font-family: "Amiri", serif; font-size: 24px; direction: rtl; }
.fiche-translit { font-size: 13.5px; color: var(--ink-soft); font-style: italic; margin-top: 4px; }
.fiche-meta {
  display: flex; flex-wrap: wrap; gap: 8px 18px;
  margin-top: 14px; font-size: 13px; color: var(--ink-soft);
}
.fiche-meta b { color: var(--ink); font-weight: 600; }

.fiche-body { padding: 22px 30px 30px; }
.fiche-section { margin-bottom: 24px; }
.fiche-section h3 {
  font-size: 13px; text-transform: uppercase; letter-spacing: .8px;
  color: var(--gold); margin: 0 0 10px;
}
.fiche-section p { margin: 0; font-size: 14.5px; }
.oeuvres { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; }
.oeuvres li {
  font-size: 14px; padding-inline-start: 16px; position: relative;
}
.oeuvres li::before {
  content: "❖"; color: var(--gold); position: absolute; inset-inline-start: 0; font-size: 11px; top: 3px;
}

/* Ressources */
.res-group { margin-bottom: 16px; }
.res-group-title {
  display: flex; align-items: center; gap: 8px;
  font-size: 13.5px; font-weight: 600; color: var(--ink); margin-bottom: 8px;
}
.res-list { display: flex; flex-direction: column; gap: 8px; }
.res-item {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg-soft);
  text-decoration: none;
  color: var(--ink);
  transition: border-color .15s ease, background .15s ease;
}
.res-item:hover { border-color: var(--gold); background: #fff; }
.res-ico { font-size: 18px; }
.res-main { flex: 1; min-width: 0; }
.res-title { font-size: 14px; font-weight: 500; }
.res-sub { font-size: 12px; color: var(--ink-soft); }
.res-badge {
  font-size: 11px; color: var(--primary-2);
  background: rgba(20,89,90,0.08); border-radius: 999px; padding: 2px 9px; white-space: nowrap;
}
.res-arrow { color: var(--gold); font-size: 15px; }
.video-embed {
  position: relative; width: 100%; aspect-ratio: 16 / 9;
  border-radius: var(--radius-sm); overflow: hidden; border: 1px solid var(--line); margin-top: 4px;
}
.video-embed iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.res-empty { font-size: 13px; color: var(--ink-soft); font-style: italic; }

/* ---------- Navigation des vues ---------- */
.viewnav {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin: 0 auto 24px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px;
  width: fit-content;
  max-width: 100%;
  flex-wrap: wrap;
}
.viewtab {
  border: 0;
  background: transparent;
  color: var(--ink-soft);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  padding: 8px 18px;
  border-radius: 999px;
  cursor: pointer;
  transition: all .18s ease;
}
.viewtab:hover { color: var(--ink); }
.viewtab.active { background: var(--primary); color: #fff; }

.view-intro { text-align: center; color: var(--ink-soft); font-size: 14px; margin: 0 auto 22px; max-width: 620px; }

/* ---------- Frise chronologique ---------- */
.frise { position: relative; padding: 34px 0 10px; }
.frise-axis { position: relative; height: 26px; margin-bottom: 10px; border-bottom: 2px solid var(--line); }
.frise-tick { position: absolute; transform: translateX(-50%); font-size: 12px; color: var(--ink-soft); top: 0; }
.frise-tick::after {
  content: ""; position: absolute; left: 50%; top: 20px; width: 1px; height: 8px; background: var(--line);
}
.frise-rows { position: relative; }
.frise-row { position: relative; height: 46px; }
.frise-bar {
  position: absolute; height: 30px; top: 8px;
  background: linear-gradient(90deg, var(--primary), var(--primary-2));
  border-radius: 999px; cursor: pointer;
  display: flex; align-items: center; padding: 0 12px; gap: 8px;
  color: #fff; font-size: 13px; font-weight: 600; white-space: nowrap;
  box-shadow: var(--shadow); transition: transform .15s ease, filter .15s ease;
  border: 1px solid rgba(255,255,255,0.25);
}
.frise-bar:hover { transform: translateY(-2px); filter: brightness(1.08); }
.frise-bar .fb-dot { color: var(--gold-soft); }
.frise-bar .fb-ar { font-family: "Amiri", serif; font-weight: 400; opacity: .85; }
.frise-grid-line { position: absolute; top: 0; bottom: 0; width: 1px; background: var(--line); opacity: .5; }

/* ---------- Carte des centres ---------- */
.carte { background: var(--bg-soft); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px; overflow: hidden; }
.carte svg { width: 100%; height: auto; display: block; }
.centre-node { cursor: pointer; }
.centre-dot { fill: var(--gold); stroke: #fff; stroke-width: 2; transition: r .15s ease, fill .15s ease; }
.centre-node:hover .centre-dot, .centre-node.active .centre-dot { fill: var(--primary); r: 11; }
.centre-node.has-savant .centre-dot { fill: var(--primary-2); }
.centre-node.active .centre-dot { fill: var(--gold); }
.centre-label { font: 600 13px "Inter", sans-serif; fill: var(--ink); }
.centre-label-ar { font: 400 13px "Amiri", serif; fill: var(--ink-soft); }
.centre-route { fill: none; stroke: var(--gold); stroke-width: 2; stroke-dasharray: 4 6; opacity: .55; }

.carte-detail { margin-top: 18px; min-height: 20px; }
.cd-card { background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--gold); border-radius: var(--radius-sm); padding: 16px 18px; }
html[dir="rtl"] .cd-card { border-left: 1px solid var(--line); border-right: 4px solid var(--gold); }
.cd-title { font-family: "Cormorant Garamond", serif; font-size: 22px; font-weight: 700; color: var(--primary); margin: 0 0 2px; }
.cd-region { font-size: 12.5px; color: var(--gold); font-weight: 600; text-transform: uppercase; letter-spacing: .5px; }
.cd-note { font-size: 14px; color: var(--ink-soft); margin: 8px 0 12px; }
.cd-savants { display: flex; flex-wrap: wrap; gap: 8px; }
.cd-savant {
  border: 1px solid var(--line); background: var(--bg-soft); border-radius: 999px;
  padding: 6px 14px; font-size: 13px; font-weight: 600; color: var(--primary-2); cursor: pointer; font-family: inherit;
}
.cd-savant:hover { border-color: var(--gold); background: #fff; }
.cd-empty { font-size: 13px; color: var(--ink-soft); font-style: italic; }

/* ---------- Footer ---------- */
.site-footer {
  border-top: 1px solid var(--line);
  padding: 24px 20px;
  text-align: center;
  color: var(--ink-soft);
  font-size: 13px;
}
.site-footer a { color: var(--primary-2); }

@media (max-width: 560px) {
  .fiche-head, .fiche-body { padding-inline: 20px; }
  .hero { padding-top: 30px; }
}
