/* Popes of Alexandria (/synaxarium/saints/popes-of-alexandria-chron).
   Everything is scoped under .popes. It relies on the site's font faces from public/css/main.css ("Crimson Pro", "Figtree",
   "Marcellus", "Arabic Text" = Scheherazade New, "Arabic Heading" = Noto Kufi Arabic, "CSU Avva Shenouda") and on the
   tasbeha.org palette the home page uses. Phone first; the ledger layout starts at 768px. */
.popes {
  --white: #ffffff; --cream: #fffaea; --sand: #ece3cf; --ink: #1f1a17; --ink-soft: #6e6258; --muted: #7d7168;
  --gold-light: #f9edc0; --gold-pale: #fbf0c4; --brown: #562300; --umber: #673417; --sienna: #7a3f1b; --ochre: #8a5a2b;
  --bronze: #c89c65; --gold: #c28a00; --lapis: #3a669f; --cc-header: #f2db87; --cc-brand: #5e3a15;
  --font-display: "Marcellus", "Marcellus Fallback", "Trajan Pro", Georgia, serif;
  --font-serif: "Crimson Pro", "Crimson Pro Fallback", Georgia, "Times New Roman", serif;
  --font-sans: "Figtree", "Figtree Fallback", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-ui: "Arabic Text", "Figtree", "Figtree Fallback", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif, "CSU Avva Shenouda", "Noto Sans Coptic", "Segoe UI Historic";
  --font-coptic: "CSU Avva Shenouda", "Noto Sans Coptic", "Segoe UI Historic", sans-serif;
  --font-ar: "Arabic Text", "Crimson Pro", "Crimson Pro Fallback", Georgia, "Noto Naskh Arabic", "Geeza Pro", "Traditional Arabic", serif;
  --font-ar-heading: "Arabic Heading", "Arabic Text", "Noto Naskh Arabic", "Geeza Pro", serif;
  --av-w: 64px; --av-h: 84px; --gap: 14px; --bar-h: 62px;
  color: var(--ink); font-family: var(--font-serif); font-size: 1.125rem; line-height: 1.5;
  -webkit-font-smoothing: antialiased; overflow-wrap: anywhere;
}

/* ---------- resets for what Bootstrap and main.css would otherwise impose ---------- */
.popes, .popes * { box-sizing: border-box; }
.popes h1, .popes h2, .popes h3 { font-family: var(--font-display); font-weight: 400; color: var(--cc-brand); margin: 0; padding: 0; line-height: 1.15; }
.popes p { margin: 0; }
.popes ol, .popes ul { list-style: none; margin: 0; padding: 0; }
.popes img { display: block; max-width: 100%; }
.popes a { color: var(--sienna); text-underline-offset: 2px; }
.popes a:hover { color: var(--brown); }
.popes :focus-visible { outline: 2px solid var(--lapis); outline-offset: 2px; }
.popes button, .popes input { font-family: var(--font-ui); font-size: 1rem; }
.popes-sr { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.popes [hidden] { display: none !important; }
.popes [data-needs-js] { display: none; }
.popes.has-js [data-needs-js] { display: inline-flex; }

/* ---------- hero ---------- */
.popes-hero { padding: 6px 0 4px; }
.popes-kicker { font: 600 12.5px/1.3 var(--font-sans); letter-spacing: .08em; text-transform: uppercase; color: var(--ochre); margin-bottom: 12px; }
.popes-kicker a { color: inherit; text-decoration: none; }
.popes-kicker a:hover { text-decoration: underline; }
.popes-title { font-size: 2.125rem; letter-spacing: .01em; }
.popes-title-ar { font-family: var(--font-ar-heading); font-weight: 500; font-size: 1.3rem; line-height: 1.8; color: var(--ochre); text-align: left; margin-top: 4px; }
.popes-lead { font-size: 1.1875rem; line-height: 1.5; max-width: 62ch; margin-top: 14px; }
.popes-now-card { display: flex; align-items: center; gap: 14px; margin-top: 20px; padding: 10px 16px 10px 10px; max-width: 480px;
  background: var(--cream); border: 1px solid var(--sand); border-left: 4px solid var(--gold); border-radius: 2px; color: var(--ink); text-decoration: none; }
.popes-now-card:hover { background: var(--gold-pale); color: var(--ink); }
.popes-now-av { flex: none; width: 56px; height: 74px; border-radius: 28px 28px 3px 3px; overflow: hidden; border: 1px solid var(--bronze); background: var(--sand); }
.popes-now-av img { width: 100%; height: 100%; object-fit: cover; object-position: 50% 15%; }
.popes-now-text { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.popes-now-k { font: 600 12px/1.3 var(--font-sans); letter-spacing: .08em; text-transform: uppercase; color: var(--ochre); }
.popes-now-name { font-family: var(--font-display); font-size: 1.3rem; line-height: 1.25; color: var(--cc-brand); display: flex; flex-wrap: wrap; align-items: baseline; column-gap: 10px; }
.popes-now-ar { font-family: var(--font-ar); font-size: 1.2rem; line-height: 1.3; color: var(--umber); }
.popes-now-years { font: 500 14px/1.3 var(--font-sans); color: var(--ink-soft); }

/* ---------- search and order ---------- */
.popes-tools { margin-top: 24px; }
.popes-search { position: relative; display: flex; align-items: center; }
.popes-search-ico { position: absolute; left: 12px; display: flex; color: var(--muted); pointer-events: none; }
.popes-search input { width: 100%; height: 48px; padding: 0 46px 0 42px; border: 1px solid var(--bronze); border-radius: 2px; background: var(--white); color: var(--ink);
  font: 400 16px/1.3 var(--font-ui); box-shadow: inset 0 1px 2px rgba(35, 27, 24, .08); -webkit-appearance: none; appearance: none; }
.popes-search input::placeholder { color: var(--muted); opacity: 1; }
.popes-search input:focus { outline: 2px solid var(--lapis); outline-offset: 1px; border-color: var(--lapis); }
.popes-search input::-webkit-search-cancel-button, .popes-search input::-webkit-search-decoration { -webkit-appearance: none; appearance: none; }
.popes-clear { position: absolute; right: 2px; top: 2px; width: 44px; height: 44px; border: 0; border-radius: 2px; background: transparent; color: var(--ink-soft); font-size: 26px; line-height: 1; cursor: pointer; }
.popes-clear:hover { background: var(--cream); color: var(--brown); }
.popes-tools-row { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px 12px; margin-top: 10px; }
.popes-count { font: 500 14px/1.4 var(--font-sans); color: var(--ink-soft); }
.popes-order { border: 1px solid var(--bronze); border-radius: 2px; overflow: hidden; }
.popes-order button { min-height: 44px; padding: 0 14px; border: 0; background: var(--white); color: var(--umber); font: 600 14px/1 var(--font-sans); cursor: pointer; }
.popes-order button + button { border-left: 1px solid var(--bronze); }
.popes-order button[aria-pressed="true"] { background: var(--umber); color: var(--white); }
.popes-order button:focus-visible { outline-offset: -3px; }

/* ---------- sticky era chips ---------- */
.popes-jump { position: sticky; top: 0; z-index: 5; margin-top: 16px; padding: 8px 0; background: rgba(255, 250, 234, .96); border-top: 1px solid var(--sand); border-bottom: 1px solid var(--sand); }
@supports (backdrop-filter: blur(1px)) { .popes-jump { background: rgba(255, 250, 234, .86); backdrop-filter: saturate(1.1) blur(8px); -webkit-backdrop-filter: saturate(1.1) blur(8px); } }
.popes-jump ul { display: flex; gap: 6px; overflow-x: auto; scroll-snap-type: x proximity; scrollbar-width: none; -webkit-overflow-scrolling: touch; padding: 2px 2px; -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 28px), transparent); mask-image: linear-gradient(90deg, #000 calc(100% - 28px), transparent); }
.popes-jump ul::-webkit-scrollbar { display: none; }
.popes-jump li { flex: none; scroll-snap-align: start; }
.popes-jump li:last-child { padding-right: 28px; }
.popes-jump a { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 0 14px; border: 1px solid var(--bronze); border-radius: 999px; background: var(--white); color: var(--umber);
  font: 500 14px/1 var(--font-sans); text-decoration: none; white-space: nowrap; transition: background-color .15s, color .15s; }
.popes-jump a:hover { background: var(--gold-pale); color: var(--brown); }
.popes-jump a[aria-current="true"] { background: var(--umber); border-color: var(--umber); color: var(--white); }
.popes-jump-search a { width: 44px; padding: 0; }
.popes-jump-today a { border-color: var(--gold); background: var(--gold-light); color: var(--brown); font-weight: 600; }
.popes-jump-today a:hover { background: var(--gold); color: var(--white); }

/* ---------- eras ---------- */
.popes-list { margin-top: 4px; }
.popes-era { scroll-margin-top: calc(var(--bar-h) + 6px); }
.popes-era:focus { outline: none; }
.popes-era-head { padding: 28px 0 10px; }
.popes-era-head::before { content: ""; display: block; width: 56px; border-top: 2px solid var(--gold); margin-bottom: 14px; }
.popes-era-span { font: 600 12.5px/1.3 var(--font-sans); letter-spacing: .08em; text-transform: uppercase; color: var(--ochre); }
.popes-era h2 { font-size: 1.5rem; margin-top: 4px; }
.popes-era-blurb { font-size: 1.0625rem; line-height: 1.45; color: var(--ink-soft); margin-top: 6px; max-width: 60ch; }

/* ---------- one pope ---------- */
.popes-ol { position: relative; }
.popes-ol::before { content: ""; position: absolute; top: 0; bottom: 0; left: calc(var(--av-w) / 2 - 1px); width: 2px; background: var(--sand); } /* the thread of succession */
.pope { position: relative; display: grid; grid-template-columns: var(--av-w) minmax(0, 1fr) auto; grid-template-areas: "av n years" "av en en" "av names names" "av note note";
  column-gap: var(--gap); row-gap: 2px; align-items: baseline; padding: 14px 0 16px; border-top: 1px solid var(--sand); scroll-margin-top: calc(var(--bar-h) + 6px); }
.pope:first-child { border-top: 0; }
.pope:focus { outline: none; }
.pope-av { grid-area: av; align-self: start; position: relative; width: var(--av-w); height: var(--av-h); border-radius: calc(var(--av-w) / 2) calc(var(--av-w) / 2) 3px 3px; background: var(--cream); border: 1px solid var(--bronze); box-shadow: 0 0 0 3px var(--white); }
.pope-av img { width: 100%; height: 100%; object-fit: cover; object-position: 50% 15%; border-radius: inherit; background: var(--sand); }
.pope-mono { display: flex; align-items: center; justify-content: center; width: 100%; height: 100%; padding-top: 6px; border-radius: inherit; font-family: var(--font-coptic); font-size: 2rem; line-height: 1; color: var(--umber); background: linear-gradient(180deg, var(--gold-light), var(--cream) 70%); }
.is-saint .pope-av { border-color: var(--gold); box-shadow: 0 0 0 3px var(--white), 0 0 0 4px var(--gold-light); }
.pope-cross { position: absolute; right: -7px; bottom: -7px; width: 22px; height: 22px; border-radius: 50%; display: flex; align-items: center; justify-content: center; background: var(--gold); color: var(--white); box-shadow: 0 0 0 2px var(--white); }
.pope-n { grid-area: n; font: 600 13px/1.3 var(--font-sans); letter-spacing: .06em; color: var(--ochre); font-variant-numeric: tabular-nums; }
.pope-years { grid-area: years; justify-self: end; display: flex; align-items: center; gap: 8px; font: 500 14px/1.3 var(--font-sans); color: var(--ink-soft); font-variant-numeric: tabular-nums; white-space: nowrap; }
.pope-now { font: 700 11px/1 var(--font-sans); letter-spacing: .08em; text-transform: uppercase; color: var(--brown); background: var(--gold-light); border: 1px solid var(--gold); border-radius: 999px; padding: 4px 8px 3px; }
.pope-en { grid-area: en; font-size: 1.25rem; line-height: 1.25; color: var(--cc-brand); }
.pope-en a { color: inherit; text-decoration: underline; text-decoration-color: var(--bronze); text-decoration-thickness: 1px; text-underline-offset: 3px; }
.pope-en a:hover { color: var(--brown); text-decoration-color: var(--brown); }
.pope-tr { font-family: var(--font-ui, 'Figtree', sans-serif); font-size: .8125rem; color: var(--ink-soft); letter-spacing: .01em; white-space: nowrap; margin-inline: .15em .35em; padding: .05em .5em; border: 1px solid var(--line, #e4d9b8); border-radius: 999px; vertical-align: .12em; }
.pope-epithet { font-family: var(--font-serif); font-style: italic; font-size: 1.0625rem; color: var(--ink-soft); }
.pope-names { grid-area: names; display: flex; flex-wrap: wrap; align-items: baseline; column-gap: 16px; }
.pope-ar { font-family: var(--font-ar); font-size: 1.3rem; line-height: 2.1; color: var(--ink); }
.pope-cop { font-family: var(--font-coptic); font-size: 1.45rem; line-height: 1.6; color: var(--umber); }
.pope-note { grid-area: note; font-size: 1rem; line-height: 1.4; color: var(--ink-soft); margin-top: 2px; }
.is-current { background: var(--cream); margin: 0 -10px; padding-left: 10px; padding-right: 10px; border-radius: 2px; }
.is-current .pope-av { box-shadow: 0 0 0 3px var(--cream); }
.popes-empty { padding: 28px 0; font-size: 1.125rem; color: var(--ink-soft); }
.popes-empty q { color: var(--ink); }

/* ---------- foot ---------- */
.popes-foot { margin-top: 36px; padding-top: 16px; border-top: 1px solid var(--sand); font: 400 14px/1.5 var(--font-sans); color: var(--ink-soft); }
.popes-foot p + p { margin-top: 6px; }

/* ---------- the ledger: tablets and desktops ---------- */
@media (min-width: 768px) {
  .popes { --av-w: 72px; --av-h: 96px; --gap: 18px; --bar-h: 62px; }
  .popes-hero { padding-top: 10px; }
  .popes-title { font-size: 2.75rem; }
  .popes-title-ar { font-size: 1.5rem; }
  .popes-tools { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; column-gap: 16px; }
  .popes-tools-row { margin-top: 0; }
  .popes-search { max-width: 520px; }
  .popes-era-head { padding-top: 36px; }
  .popes-era h2 { font-size: 1.75rem; }
  /* the ledger: English, Coptic, then the Arabic column right-aligned (its natural edge) next to the years */
  .pope { grid-template-columns: var(--av-w) 2.5rem minmax(0, 1.2fr) minmax(0, .9fr) minmax(0, 1fr) max-content; grid-template-areas: "av n en cop ar years" "av n note cop ar years"; column-gap: 16px; padding: 16px 0 18px; }
  .pope-names { display: contents; }
  .pope-ar { grid-area: ar; text-align: right; line-height: 1.7; }
  .pope-cop { grid-area: cop; }
  .popes-jump a { font-size: 13.5px; padding: 0 12px; }
  .pope-years { align-self: baseline; }
  .pope-n { padding-top: 3px; }
  .pope-note { margin-top: 4px; }
  .is-current { margin: 0 -14px; padding-left: 14px; padding-right: 14px; }
}
@media (min-width: 768px) and (max-width: 991.98px) {
  /* tablets: five columns, the Coptic under the English so the Arabic keeps a wide column */
  .pope { grid-template-columns: var(--av-w) 2.25rem minmax(0, 1.1fr) minmax(0, 1fr) max-content; grid-template-areas: "av n en ar years" "av n cop ar years" "av n note ar years"; }
  .pope-cop { margin-top: 2px; }
}
@media (min-width: 992px) {
  .popes-jump ul { flex-wrap: wrap; overflow: visible; -webkit-mask-image: none; mask-image: none; }
  .popes-jump li:last-child { padding-right: 0; }
  .popes-jump-search { display: none; } /* the search box is one screen up; "/" also focuses it */
}

/* ---------- motion, print ---------- */
@media (prefers-reduced-motion: reduce) {
  .popes-jump a { transition: none; }
}
@media print {
  .popes-tools, .popes-jump, .popes-now-years span { display: none !important; }
  .popes-jump { position: static; }
}
