/* site.css — stylesheet for the website generated from the book.
   Source lives in _tools/site/site.css; build_site.py copies it to site/assets/.
   Palette is the book's: red #E01F33 · gold #B0801B · dark #14110D · cream #FFFDF8. */

:root {
  --red: #E01F33; --red-dk: #A81325; --gold: #B0801B; --gold-2: #C98A0A;
  --amber: #FFB020; --teal: #0E7C86; --dark: #14110D; --ink: #231F19;
  --cream: #FFFDF8; --paper: #F7F1E6; --sand: #EFE7D8;
  --muted: #6B6256; --line: rgba(20, 17, 13, .12); --line-2: rgba(20, 17, 13, .07);
  --radius: 14px;
  --head: Alexandria, Cairo, system-ui, sans-serif;
  --body: Cairo, system-ui, "Segoe UI", Tahoma, sans-serif;
  --measure: 46rem;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: 1rem; }
body {
  margin: 0; background: var(--cream); color: var(--ink);
  font: 400 1.0625rem/1.95 var(--body);
  text-rendering: optimizeLegibility;
}
img { max-width: 100%; height: auto; display: block; }
a { color: var(--red); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--red-dk); }
:focus-visible { outline: 3px solid var(--amber); outline-offset: 2px; }

.skip { position: absolute; inset-inline-start: 1rem; top: -3rem; z-index: 10;
  background: var(--amber); color: var(--dark); padding: .4rem .9rem; border-radius: 8px; }
.skip:focus { top: 1rem; }

/* ---------------------------------------------------------------- header */
.site-header { background: var(--dark); color: var(--sand); position: relative; z-index: 5; }
.site-header .bar {
  max-width: 78rem; margin: 0 auto; padding: .7rem 1rem;
  display: flex; align-items: center; gap: 1rem; justify-content: space-between;
}
.brand { display: flex; align-items: center; gap: .7rem; color: var(--cream); text-decoration: none;
  font: 700 1rem/1.3 var(--head); }
.brand img { height: 42px; width: auto; }
.brand:hover { color: var(--cream); }
.flag { display: flex; flex-direction: column; }
.flag i { height: 3px; }
.flag i:nth-child(1) { background: var(--red); }
.flag i:nth-child(2) { background: var(--cream); }
.flag i:nth-child(3) { background: #000; }

.site-header ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: .25rem; }
.nav-wide ul { flex-wrap: nowrap; white-space: nowrap; gap: .1rem; }
.brand .yrs { white-space: nowrap; }
.site-header nav a, .site-header nav .pending {
  display: block; padding: .3rem .7rem; border-radius: 999px; text-decoration: none;
  font: 500 .88rem/1.5 var(--body); color: var(--sand);
}
.site-header nav a:hover { background: rgba(255, 253, 248, .08); color: var(--cream); }
.site-header nav a[aria-current="page"] { background: var(--red); color: #fff; }
.pending { opacity: .42; cursor: default; }

.nav-menu { display: none; }
@media (max-width: 1280px) {
  .nav-wide { display: none; }
  .nav-menu { display: block; position: static; }
  .nav-menu summary {
    list-style: none; cursor: pointer; padding: .35rem .9rem; border-radius: 999px;
    border: 1px solid rgba(255, 253, 248, .25); font: 500 .9rem/1.5 var(--body); color: var(--cream);
  }
  .nav-menu summary::-webkit-details-marker { display: none; }
  .nav-menu summary::after { content: " ▾"; }
  .nav-menu[open] summary::after { content: " ▴"; }
  .nav-menu nav {
    position: absolute; inset-inline: 0; top: 100%; background: var(--dark);
    padding: .5rem 1rem 1rem; border-top: 1px solid rgba(255, 253, 248, .1);
  }
  .nav-menu ul { flex-direction: column; }
  .nav-menu nav a, .nav-menu nav .pending { border-radius: 8px; padding: .55rem .8rem; font-size: 1rem; }
}
@media (max-width: 560px) {
  .brand span { font-size: .85rem; max-width: 11rem; }
  .brand img { height: 36px; }
}

/* ------------------------------------------------------------------ hero */
.hero {
  position: relative; min-height: clamp(20rem, 58vh, 34rem); overflow: hidden;
  display: flex; align-items: flex-end; background: var(--dark); color: var(--sand);
}
.hero .hero-img { position: absolute; inset: 0; margin: 0; }
.hero .hero-img img { width: 100%; height: 100%; object-fit: cover; }
.hero::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(to top, rgba(20, 17, 13, .96) 12%, rgba(20, 17, 13, .35) 60%, rgba(20, 17, 13, .6));
}
.hero::before {                      /* the book's flag stripe, on the right edge like the openers */
  content: ""; position: absolute; top: 0; bottom: 0; inset-inline-start: 0; width: 10px; z-index: 2;
  background: linear-gradient(var(--red) 0 33.3%, var(--cream) 33.3% 66.6%, #000 66.6%);
}
.hero-text { position: relative; z-index: 1; width: 100%; max-width: 78rem; margin: 0 auto;
  padding: 2rem clamp(1.25rem, 5vw, 4rem) clamp(2rem, 5vw, 3.5rem); }
.hero .num { display: block; direction: ltr; text-align: right; font: 800 clamp(4rem, 12vw, 7.5rem)/.85 var(--head);
  color: rgba(255, 253, 248, .2); }
.hero .eyebrow { display: inline-block; margin: .6rem 0 0; padding: .1rem .8rem; border-radius: 999px;
  background: var(--red); color: #fff; font: 700 .9rem/1.8 var(--body); }
.hero h1 { margin: .5rem 0 0; font: 800 clamp(1.9rem, 4.6vw, 3.1rem)/1.25 var(--head); color: var(--cream);
  text-wrap: balance; }
.hero .lead { margin: .7rem 0 0; max-width: 40rem; font: 500 clamp(1.05rem, 2.2vw, 1.3rem)/1.6 var(--body);
  color: var(--amber); }

/* --------------------------------------------------------------- layout */
.content {
  max-width: 78rem; margin: 0 auto; padding: clamp(1.5rem, 4vw, 3rem) 1rem 2rem;
  display: grid; grid-template-columns: minmax(0, 17rem) minmax(0, var(--measure));
  gap: clamp(2rem, 5vw, 4.5rem); justify-content: center; align-items: start;
}
.content > article { grid-column: 2; min-width: 0; }
.content > .chapters { grid-column: 1; position: sticky; top: 1.25rem; }
@media (max-width: 900px) {
  .content { grid-template-columns: minmax(0, 1fr); }
  .content > article, .content > .chapters { grid-column: 1; position: static; }
}

/* "المحتويات" box. site.js marks the reader's position: li.ch.open = current chapter
   (its sub-headings unfold), a[aria-current] = the exact heading being read. */
.chapters { background: var(--paper); border-radius: var(--radius); padding: 1.1rem .9rem 1.1rem 1rem; }
.content > .chapters { max-height: calc(100vh - 2.5rem); overflow-y: auto; overscroll-behavior: contain;
  scrollbar-width: thin; }
.chapters h2 { margin: 0 0 .5rem; padding-inline-start: .35rem; font: 700 .95rem/1.5 var(--head); color: var(--muted); }
.chapters ol { margin: 0; padding: 0; list-style: none; }
.chapters li.ch { border-top: 1px solid var(--line-2); }
.chapters li.ch:first-child { border-top: 0; }
.chapters a { position: relative; display: grid; grid-template-columns: 1.6rem 1fr; align-items: baseline;
  padding: .42rem .35rem; border-radius: 8px; color: var(--ink); text-decoration: none;
  font: 500 .95rem/1.6 var(--body); transition: background-color .15s, color .15s; }
.chapters a:hover { color: var(--red); background: rgba(224, 31, 51, .05); }
.chapters .n { font: 800 .95rem/1 var(--head); color: var(--red); }
.chapters .n.dot::before { content: ""; display: inline-block; width: 6px; height: 6px; transform: rotate(45deg);
  background: var(--red); vertical-align: middle; }
.chapters .subs { margin: 0 0 .35rem; padding-inline-start: 1.6rem; }
.chapters .subs a { grid-template-columns: 1fr; padding: .28rem .6rem; font-size: .86rem; line-height: 1.55; color: var(--muted); }
.js .chapters li.ch:not(.open) > .subs { display: none; }

/* where the reader is */
.chapters li.ch.open > a { background: #fff; font-weight: 700; color: var(--dark);
  box-shadow: 0 1px 0 var(--line-2); }
.chapters li.ch.open > a::before, .chapters .subs a[aria-current]::before {
  content: ""; position: absolute; inset-block: .35rem; inset-inline-start: -.55rem; width: 4px;
  border-radius: 2px; background: var(--red); }
.chapters li.ch.open > a .n { color: #fff; background: var(--red); border-radius: 6px; padding: .28rem .35rem;
  justify-self: start; }
.chapters li.ch.open > a .n.dot { background: none; padding: 0; }
.chapters .subs a[aria-current] { color: var(--red); font-weight: 700; background: rgba(224, 31, 51, .06); }
.chapters .subs a[aria-current]::before { inset-inline-start: -.2rem; }
@media (max-width: 900px) {                /* the box sits above the text on small screens */
  .chapters li.ch.open > a::before { display: none; }
}

/* pages without a contents box: one centred column */
.no-toc .content { grid-template-columns: minmax(0, var(--measure)); }
.no-toc .content > article { grid-column: 1; }

/* ----------------------------------------------------------- typography */
article > :first-child { margin-top: 0; }
article p { margin: 0 0 1.05em; text-wrap: pretty; }
article h2.chapter {
  margin: 3.5rem 0 1.4rem; padding-top: 2.2rem; border-top: 1px solid var(--line);
  font: 800 clamp(1.5rem, 3.4vw, 2rem)/1.35 var(--head); color: var(--dark); text-wrap: balance;
}
article > h2.chapter:first-child { border-top: 0; padding-top: 0; }
article h2.chapter::after { content: ""; display: block; width: 74px; height: 5px; margin-top: .9rem;
  border-radius: 3px; background: var(--red); }
article h3 { display: flex; align-items: center; gap: .9rem; margin: 2.4rem 0 1rem;
  font: 700 clamp(1.2rem, 2.6vw, 1.45rem)/1.45 var(--head); color: var(--dark); }
article h3::after { content: ""; flex: 1; min-width: 2rem; height: 3px; border-radius: 2px;
  background: linear-gradient(to left, var(--red), rgba(224, 31, 51, .08)); }
article h4 { margin: 1.8rem 0 .6rem; font: 700 1.12rem/1.6 var(--body); color: var(--red); }
article h5 { margin: 1.4rem 0 .5rem; font: 700 1rem/1.6 var(--body); color: var(--dark); }
article p.fallback { border-inline-start: 3px dashed var(--amber); padding-inline-start: .8rem; }

/* bullets — diamond marker, colour = category (as in the book) */
ul.bullets, ul.bullets ul { list-style: none; margin: 0 0 1.2rem; padding: 0; }
ul.bullets ul { margin: .35rem 0 0; padding-inline-start: 1.4rem; }
ul.bullets li { position: relative; padding-inline-start: 1.35rem; margin: 0 0 .45rem; line-height: 1.85; }
ul.bullets li::before {
  content: ""; position: absolute; inset-inline-start: .15rem; top: .72em; width: 7px; height: 7px;
  transform: rotate(45deg); background: var(--red);
}
li.dot-teal::before { background: var(--teal) !important; }
li.dot-amber::before { background: var(--amber) !important; }
li.dot-gold::before { background: var(--gold-2) !important; }
li.dot-dark::before { background: var(--dark) !important; }

/* definition terms */
dl.terms { margin: 0 0 1.5rem; display: grid; gap: .55rem; }
dl.terms .term { display: grid; grid-template-columns: minmax(8rem, 26%) 1fr; border: 1px solid var(--line);
  border-radius: 13px; overflow: hidden; background: #fff; }
dl.terms dt { margin: 0; padding: .8rem 1rem; background: var(--teal); color: #fff; font-weight: 700; line-height: 1.6;
  display: flex; align-items: center; }
dl.terms dd { margin: 0; padding: .8rem 1rem; line-height: 1.85; }
@media (max-width: 560px) { dl.terms .term { grid-template-columns: 1fr; } }

/* tables */
.table-wrap { margin: 0 0 1.6rem; overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius);
  background: #fff; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: .93rem; line-height: 1.75; }
th, td { padding: .65rem .8rem; text-align: start; vertical-align: top; }
thead th { color: #fff; font-weight: 700; background: var(--dark); }
table.hdr-red thead th { background: var(--red); }
table.hdr-teal thead th { background: var(--teal); }
tbody td, tbody th { border-top: 1px solid var(--line-2); }
tbody tr:nth-child(even) td { background: var(--paper); }
table.t-kv tbody th[scope="row"] { width: 28%; background: var(--dark); color: #fff; font-weight: 700;
  border-top-color: rgba(255, 255, 255, .12); }
table.t-grid tbody td:first-child { font-weight: 700; }
@media (max-width: 640px) { table { min-width: 34rem; } table.t-kv { min-width: 0; } }

/* pictures */
figure { margin: 0 0 1.4rem; }
figure img { border-radius: var(--radius); width: 100%; }
figure.photo img { aspect-ratio: 16 / 9; object-fit: cover; }
figure.diagram { background: #fff; border: 1px solid var(--line-2); border-radius: var(--radius); padding: .5rem; }
figure.diagram img { border-radius: 8px; }
.gallery { display: grid; gap: .7rem; margin: 0 0 1.4rem; }
.gallery.n2 { grid-template-columns: 1.6fr 1fr; }
.gallery.n3 { grid-template-columns: repeat(3, 1fr); }
.gallery.n4 { grid-template-columns: repeat(2, 1fr); }
.gallery figure { margin: 0; }
.gallery img { height: 100%; aspect-ratio: 4 / 3; object-fit: cover; }
.gallery.n2 figure:first-child img { aspect-ratio: 16 / 10; }
.gallery.n2 figure:last-child img { aspect-ratio: auto; height: 100%; }
@media (max-width: 560px) { .gallery.n3 { grid-template-columns: 1fr 1fr; } .gallery.n3 figure:first-child { grid-column: 1 / -1; } }
.media-row { display: grid; grid-template-columns: 12rem 1fr; gap: 1.2rem; align-items: start; margin: 0 0 1.2rem; }
.media-row figure { margin: 0; }
.media-row img { aspect-ratio: 3 / 4; object-fit: cover; }
@media (max-width: 560px) { .media-row { grid-template-columns: 1fr; } .media-row img { aspect-ratio: 16 / 9; } }

/* ---------------------------------------------------------- pager/footer */
.pager { max-width: 78rem; margin: 0 auto; padding: 1rem 1rem 3rem; display: flex; gap: 1rem; justify-content: space-between; }
.pager a { flex: 1 1 0; max-width: 24rem; padding: 1rem 1.2rem; border-radius: var(--radius); background: var(--paper);
  color: var(--ink); text-decoration: none; font: 700 1rem/1.5 var(--head); }
.pager a small { display: block; font: 500 .82rem/1.6 var(--body); color: var(--muted); }
.pager a.next { margin-inline-start: auto; text-align: end; }
.pager a:hover { background: var(--sand); }

.site-footer { background: var(--dark); color: rgba(239, 231, 216, .75); text-align: center; padding: 1.6rem 1rem;
  font-size: .9rem; }
.site-footer p { margin: 0; }

/* ------------------------------------------------------------------- home */
.home { max-width: 60rem; margin: 0 auto; padding: clamp(2rem, 6vw, 4rem) 1rem; }
.home h1 { margin: 0; font: 800 clamp(1.8rem, 4.5vw, 2.8rem)/1.3 var(--head); color: var(--dark); }
.home .lead { color: var(--muted); margin: .4rem 0 2rem; }
.cards { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr)); gap: .8rem; }
.cards a, .cards .pending { display: block; height: 100%; padding: 1.1rem 1.2rem; border-radius: var(--radius);
  background: var(--paper); color: var(--ink); text-decoration: none; border-inline-start: 5px solid var(--red); }
.cards a:hover { background: var(--sand); }
.cards small { display: block; color: var(--red); font-weight: 700; }
.cards strong { font: 700 1.05rem/1.5 var(--head); }

/* ---------------------------------------------------------- back to top */
.to-top { display: none; }
.js .to-top {
  display: grid; place-items: center; position: fixed; z-index: 20;
  inset-inline-end: clamp(.9rem, 2.5vw, 1.6rem); bottom: clamp(.9rem, 2.5vw, 1.6rem);
  width: 3rem; height: 3rem; border: 0; border-radius: 50%; cursor: pointer;
  background: var(--red); color: #fff; box-shadow: 0 6px 18px rgba(20, 17, 13, .25);
  opacity: 0; transform: translateY(12px); pointer-events: none;
  transition: opacity .2s, transform .2s, background-color .15s;
}
.js .to-top.show { opacity: 1; transform: none; pointer-events: auto; }
.to-top:hover { background: var(--red-dk); }
@media (max-width: 560px) { .js .to-top { width: 2.6rem; height: 2.6rem; } }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .js .to-top, .chapters a { transition: none; }
}

/* ---------------------------------------------------------- svg figures */
figure.svg { display: flex; justify-content: center; padding: 1rem; }
figure.svg svg { width: 100%; max-width: 30rem; height: auto; }

/* ------------------------------------------------------------ home page */
.home-hero { position: relative; overflow: hidden; background: var(--dark); color: var(--sand);
  min-height: clamp(30rem, 82vh, 46rem); display: flex; align-items: flex-end; }
.home-hero .hero-img { position: absolute; inset: 0; margin: 0; }
.home-hero .hero-img img { width: 100%; height: 100%; object-fit: cover; border-radius: 0; }
.home-hero::after { content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(to top, rgba(20, 17, 13, .97) 15%, rgba(20, 17, 13, .35) 58%, rgba(20, 17, 13, .55)); }
.home-hero::before { content: ""; position: absolute; top: 0; bottom: 0; inset-inline-end: 0; width: 10px; z-index: 2;
  background: linear-gradient(var(--red) 0 33.3%, var(--cream) 33.3% 66.6%, #000 66.6%); }
.home-tiles { position: absolute; z-index: 1; top: clamp(1rem, 4vw, 2.5rem); inset-inline-end: clamp(1.5rem, 5vw, 4rem);
  display: grid; gap: .7rem; width: clamp(9rem, 20vw, 15rem); }
.home-tiles figure { margin: 0; }
.home-tiles img { aspect-ratio: 4 / 3; object-fit: cover; border-radius: 12px; border: 3px solid rgba(255, 253, 248, .85); }
.home-hero-text { position: relative; z-index: 1; width: 100%; max-width: 78rem; margin: 0 auto;
  padding: 2rem clamp(1.25rem, 5vw, 4rem) clamp(2rem, 6vw, 4rem); }
.home-hero .status { display: inline-block; margin: 0 0 .8rem; padding: .1rem .8rem; border-radius: 999px;
  background: rgba(224, 31, 51, .9); color: #fff; font: 500 .85rem/1.8 var(--body); }
.home-hero h1 { margin: 0; font: 800 clamp(2.4rem, 7vw, 4.6rem)/1.15 var(--head); color: var(--cream); }
.home-hero .years { margin: .4rem 0 0; direction: ltr; text-align: right; font: 800 clamp(1.8rem, 5vw, 3rem)/1.1 var(--head);
  color: var(--amber); unicode-bidi: plaintext; }
.cover-lines { margin-top: 1.2rem; padding-top: 1rem; border-top: 1px solid rgba(255, 253, 248, .2); }
.cover-lines p { margin: 0; font: 500 clamp(1rem, 2vw, 1.2rem)/1.8 var(--body); color: var(--sand); }
@media (max-width: 640px) { .home-tiles { display: none; } }

.vision { background: var(--dark); color: var(--cream); padding: clamp(2.5rem, 7vw, 4.5rem) 1rem;
  text-align: center; border-top: 4px solid var(--red); }
.vision .label { display: inline-block; margin: 0 0 1rem; padding: .1rem 1rem; border-radius: 999px;
  background: var(--amber); color: var(--dark); font: 700 1rem/1.8 var(--head); }
.vision blockquote { margin: 0 auto; max-width: 52rem; }
.vision blockquote p { margin: 0; font: 700 clamp(1.25rem, 3vw, 1.75rem)/1.75 var(--head); text-wrap: balance; }

.home-sections, .movement { max-width: 72rem; margin: 0 auto; padding: clamp(2.5rem, 6vw, 4rem) 1rem 1rem; }
.home-sections h2, .movement h2 { margin: 0 0 1.2rem; font: 800 clamp(1.4rem, 3vw, 1.9rem)/1.4 var(--head); color: var(--dark); }
.movement { padding-bottom: 3.5rem; }
.movement ul { list-style: none; margin: 0 0 1.4rem; padding: 0; display: flex; flex-wrap: wrap; gap: 1rem 2rem;
  justify-content: center; align-items: center; }
.movement li { display: flex; flex-direction: column; align-items: center; gap: .4rem; text-align: center;
  font: 500 .85rem/1.4 var(--body); color: var(--muted); max-width: 9rem; }
.movement ul.assoc img { height: 84px; width: auto; }
.movement ul.intl img { height: 60px; width: auto; }
.gallery.mosaic img { aspect-ratio: 4 / 3; }
@media (min-width: 761px) { .gallery.mosaic { grid-template-columns: repeat(4, 1fr); } }

/* ----------------------------------------------------------- forewords */
.hero.hero-short { min-height: clamp(14rem, 36vh, 22rem); }
.foreword { margin: 0 0 3.5rem; padding-bottom: 3rem; border-bottom: 1px solid var(--line); }
.foreword .fw-banner { display: none; }
.fw-head { display: flex; align-items: center; gap: 1.2rem; margin: 0 0 1.4rem; }
.fw-head .portrait { width: 7.5rem; height: 7.5rem; object-fit: cover; object-position: top; border-radius: 50%;
  background: var(--sand); border: 4px solid #fff; box-shadow: 0 0 0 2px var(--amber); flex: none; }
.fw-head h2 { margin: 0; font: 800 clamp(1.3rem, 3vw, 1.7rem)/1.4 var(--head); color: var(--dark); }
.fw-head .role { margin: .2rem 0 0; color: var(--red); font-weight: 700; }
.fw-body p { margin: 0 0 1.05em; }
.foreword .gallery { margin-top: 1.4rem; }
.notice { background: var(--dark); color: var(--sand); border-radius: var(--radius); padding: clamp(1.4rem, 4vw, 2.2rem); }
.notice h2 { margin: 0 0 .8rem; font: 800 1.4rem/1.4 var(--head); color: var(--amber); }
.notice p { margin: 0 0 1em; }
.notice .gallery { margin: 1.4rem 0 0; }
@media (max-width: 560px) { .fw-head { flex-direction: column; align-items: flex-start; } }

/* -------------------------------------------------------------- footer */
.site-footer .foot { max-width: 72rem; margin: 0 auto; display: flex; flex-wrap: wrap; gap: 1.2rem 2rem;
  align-items: center; justify-content: center; text-align: start; padding-bottom: 1rem;
  border-bottom: 1px solid rgba(255, 253, 248, .1); }
.foot-logos { display: flex; gap: .7rem; }
.foot-logos img { height: 58px; width: auto; background: rgba(255, 253, 248, .94); border-radius: 12px; padding: .35rem; }
.foot-text p { margin: 0; line-height: 1.9; }
.foot-text .org { color: var(--cream); font: 700 1.05rem/1.6 var(--head); }
.foot-text a { color: var(--amber); text-decoration: none; }
.foot-text a:hover { text-decoration: underline; }
.site-footer .foot-line { margin: 1rem 0 0; font-size: .85rem; color: rgba(239, 231, 216, .6); }
