/* ==========================================================================
   Catechism of the Coptic Orthodox Church — public site
   Light paper, deep ink, a single Coptic-burgundy accent.
   Logical properties throughout so Arabic (RTL) works without overrides.
   ========================================================================== */

:root {
  --paper: #FDFCFB;
  --paper-2: #F8F5F4;
  --ink: #221B1D;
  --ink-2: #463D40;
  --muted: #6E6467;
  --faint: #9A9093;
  --rule: #ECE6E5;
  --rule-2: #E0D8D7;
  --accent: #7A1E2C;
  --accent-deep: #5C1520;
  --accent-tint: #F7EEEF;

  --serif: "Spectral", "Noto Serif", Georgia, "Times New Roman", serif;
  --sans: "Source Sans 3", "Noto Sans", "Noto Sans Coptic", system-ui, -apple-system, "Segoe UI", sans-serif;

  --measure: 40rem;
  --gutter: clamp(1rem, 4vw, 2.5rem);
  --wide: 76rem;
  --radius: 6px;
  --ease: cubic-bezier(.2, .7, .2, 1);
}

html[lang="ar"] {
  --serif: "Noto Naskh Arabic", "Spectral", serif;
  --sans: "IBM Plex Sans Arabic", "Source Sans 3", system-ui, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-padding-top: 5.5rem;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 1.0625rem;
  line-height: 1.7;
  font-feature-settings: "kern", "liga";
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

@media (min-width: 48rem) { body { font-size: 1.125rem; } }

img { max-width: 100%; height: auto; }

a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: .18em; }
a:hover { color: var(--accent-deep); }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 2px; }

::selection { background: var(--accent-tint); color: var(--accent-deep); }

.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.skip-link {
  position: absolute; inset-inline-start: 1rem; top: -3rem; z-index: 50;
  background: var(--ink); color: var(--paper); padding: .5rem .9rem; border-radius: var(--radius);
}
.skip-link:focus { top: 1rem; color: var(--paper); }

.wrap { width: 100%; max-width: var(--wide); margin-inline: auto; padding-inline: var(--gutter); }

/* ---------- Coptic cross accents ---------- */

.cross { width: 1em; height: 1em; display: inline-block; vertical-align: middle; flex: none; }

.divider {
  display: flex; align-items: center; gap: 1rem;
  color: var(--accent); margin-block: 2.5rem;
}
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--rule); }
.divider .cross { width: .8rem; height: .8rem; opacity: .7; }

.end-mark { display: flex; justify-content: center; color: var(--accent); margin-block: 3rem 0; }
.end-mark .cross { width: .9rem; height: .9rem; opacity: .65; }

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

.site-header {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--paper) 92%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  -webkit-backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--rule);
}
.site-header .wrap { display: flex; align-items: center; gap: 1.25rem; min-height: 4rem; }

.brand {
  display: flex; align-items: center; gap: .65rem;
  color: var(--ink); text-decoration: none; min-width: 0;
}
.brand-mark { width: 1.9rem; height: 1.9rem; color: var(--accent); flex: none; }
.brand-name {
  font-family: var(--serif); font-size: 1.02rem; line-height: 1.2; letter-spacing: .005em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.brand-name span { display: none; }
@media (min-width: 40rem) { .brand-name span { display: inline; } }
.brand:hover { color: var(--ink); }

.site-nav { margin-inline-start: auto; display: flex; align-items: center; gap: .25rem; }
.site-nav a, .site-nav button {
  font: inherit; font-size: .95rem; color: var(--ink-2); text-decoration: none;
  background: none; border: 0; cursor: pointer;
  padding: .45rem .7rem; border-radius: var(--radius);
  display: inline-flex; align-items: center; gap: .4rem;
}
.site-nav a:hover, .site-nav button:hover { background: var(--paper-2); color: var(--ink); }
.site-nav a[aria-current="page"] { color: var(--accent); }
.site-nav .icon { width: 1.15rem; height: 1.15rem; }
.nav-label-sm { display: none; }
@media (min-width: 34rem) { .nav-label-sm { display: inline; } }

.lang-switch { font-size: .9rem; border-inline-start: 1px solid var(--rule); padding-inline-start: .5rem; margin-inline-start: .25rem; }

.admin-bar {
  background: var(--ink); color: #EDE6E7; font-size: .85rem;
}
.admin-bar .wrap { display: flex; gap: 1rem; align-items: center; min-height: 2.25rem; }
.admin-bar a { color: #fff; text-decoration: none; }
.admin-bar a:hover { text-decoration: underline; color: #fff; }
.admin-bar .spacer { margin-inline-start: auto; }

.preview-note {
  background: var(--accent-tint); color: var(--accent-deep); font-size: .92rem;
  border-bottom: 1px solid #EBD9DC; padding-block: .55rem;
}

/* ---------- Home ---------- */

.home {
  display: grid; gap: 2.5rem;
  padding-block: clamp(2.5rem, 7vw, 5.5rem) 5rem;
}
@media (min-width: 62rem) {
  .home { grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: clamp(3rem, 6vw, 6rem); }
  .home-intro { position: sticky; top: 7rem; align-self: start; }
}

.home-mark { width: 3rem; height: 3rem; color: var(--accent); margin-block-end: 1.75rem; }

.home-title {
  font-family: var(--serif); font-weight: 300;
  font-size: clamp(2.3rem, 4.6vw, 3.5rem);
  line-height: 1.08; letter-spacing: -.012em;
  margin: 0 0 1.5rem; color: var(--ink);
  text-wrap: balance;
}
.home-lede { color: var(--ink-2); max-width: 30rem; margin: 0 0 2.25rem; }

.front-links { list-style: none; margin: 0 0 2.5rem; padding: 0; border-top: 1px solid var(--rule); max-width: 30rem; }
.front-links li { border-bottom: 1px solid var(--rule); }
.front-links a, .front-links .is-soon {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: .85rem 0; text-decoration: none; color: var(--ink);
  font-family: var(--serif); font-size: 1.2rem;
}
.front-links a:hover { color: var(--accent); }
.front-links a .icon { width: 1.1rem; height: 1.1rem; color: var(--faint); }
.front-links a:hover .icon { color: var(--accent); }
.front-links .is-soon { color: var(--faint); }

@media (max-width: 61.99rem) { .home-credit { display: none; } }
.home-credit { font-size: .9rem; color: var(--muted); max-width: 30rem; line-height: 1.6; }
.home-credit p { margin: 0 0 .35rem; }

.contents-head {
  display: flex; align-items: baseline; justify-content: space-between; gap: 1rem;
  border-bottom: 1px solid var(--ink); padding-bottom: .6rem; margin-bottom: 0;
}
.contents-head h2 { font-family: var(--serif); font-weight: 400; font-size: 1.05rem; margin: 0; color: var(--ink); letter-spacing: .01em; }
.text-button {
  font: inherit; font-size: .9rem; color: var(--muted); background: none; border: 0; padding: .2rem 0; cursor: pointer;
}
.text-button:hover { color: var(--accent); }

/* ---------- Chapter accordion ---------- */

.chapters { list-style: none; margin: 0; padding: 0; }
.chapter { border-bottom: 1px solid var(--rule); }
.chapter-h { margin: 0; font: inherit; }

.chapter-toggle {
  width: 100%; display: grid; grid-template-columns: 2.6rem 1fr auto auto; align-items: baseline; gap: .75rem;
  background: none; border: 0; padding: 1.3rem 0; margin: 0; cursor: pointer;
  font: inherit; color: var(--ink); text-align: start;
}
.chapter-num {
  font-family: var(--serif); font-style: italic; font-size: 1.05rem; color: var(--accent);
  font-variant-numeric: oldstyle-nums;
}
.chapter-title {
  font-family: var(--serif); font-weight: 400; font-size: clamp(1.35rem, 2.4vw, 1.65rem); line-height: 1.25;
}
.chapter-count { font-size: .88rem; color: var(--muted); white-space: nowrap; }
.chapter-chevron { width: 1.1rem; height: 1.1rem; color: var(--faint); align-self: center; transition: transform .35s var(--ease); }
.chapter-toggle:hover .chapter-title { color: var(--accent); }
.chapter-toggle:hover .chapter-chevron { color: var(--accent); }
.chapter.is-open .chapter-chevron { transform: rotate(180deg); }

.chapter-panel { display: grid; grid-template-rows: 1fr; transition: grid-template-rows .4s var(--ease); }
.chapter-panel > div { overflow: hidden; min-height: 0; }
.js .chapter:not(.is-open) .chapter-panel { grid-template-rows: 0fr; }
.js .chapter:not(.is-open) .chapter-panel > div { visibility: hidden; transition: visibility 0s .4s; }

.article-list { list-style: none; margin: 0; padding: 0 0 1.4rem; padding-inline-start: 3.35rem; }
.article-list li { display: flex; align-items: baseline; gap: .8rem; padding: .32rem 0; }
.article-list .cross { width: .62rem; height: .62rem; color: var(--accent); opacity: .5; transform: translateY(-.08em); }
.article-list a { color: var(--ink-2); text-decoration: none; }
.article-list a:hover { color: var(--accent); text-decoration: underline; }
.article-list .is-soon { color: var(--faint); }
.article-list .is-soon .cross { color: var(--faint); opacity: .6; }
.tag {
  font-size: .74rem; letter-spacing: .02em; color: var(--muted);
  border: 1px solid var(--rule-2); border-radius: 999px; padding: .02rem .5rem; white-space: nowrap; line-height: 1.5;
}
.tag-draft { color: var(--accent-deep); border-color: #E6CCD0; background: var(--accent-tint); }
.chapter-open-link { display: inline-block; margin-top: .4rem; font-size: .92rem; }

@media (max-width: 34rem) {
  .chapter-toggle { grid-template-columns: 2rem 1fr auto; }
  .chapter-count { display: none; }
  .article-list { padding-inline-start: 2.75rem; }
}

/* ---------- Page headers (chapter / article / page) ---------- */

.page { padding-block: clamp(2rem, 6vw, 4rem) 5rem; }

.crumb { font-size: .95rem; color: var(--muted); margin: 0 0 1.25rem; display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; }
.crumb a { color: var(--muted); text-decoration: none; }
.crumb a:hover { color: var(--accent); text-decoration: underline; }
.crumb .sep { color: var(--rule-2); }
.crumb em { font-family: var(--serif); font-style: italic; color: var(--accent); }

.page-title {
  font-family: var(--serif); font-weight: 300; color: var(--ink);
  font-size: clamp(2.1rem, 5vw, 3.15rem); line-height: 1.12; letter-spacing: -.01em;
  margin: 0 0 1rem; text-wrap: balance;
}
.page-meta { color: var(--muted); font-size: .92rem; margin: 0; }

/* ---------- Article layout ---------- */

.article-layout { display: grid; gap: 3rem; }
@media (min-width: 64rem) {
  .article-layout { grid-template-columns: 14.5rem minmax(0, 1fr); gap: clamp(3rem, 6vw, 5.5rem); }
}

.rail { display: none; }
@media (min-width: 64rem) {
  .rail { display: block; position: sticky; top: 6.5rem; align-self: start; max-height: calc(100vh - 8rem); overflow-y: auto; padding-bottom: 2rem; }
}
.rail-title { font-family: var(--serif); font-style: italic; color: var(--muted); font-size: .98rem; margin: 0 0 .75rem; }
.rail-title a { color: inherit; text-decoration: none; }
.rail-title a:hover { color: var(--accent); }
.rail ol { list-style: none; margin: 0; padding: 0; border-inline-start: 1px solid var(--rule); }
.rail li a, .rail li span {
  display: block; padding: .38rem 0 .38rem 1rem; padding-inline: 1rem 0; margin-inline-start: -1px;
  border-inline-start: 1px solid transparent;
  font-size: .93rem; line-height: 1.4; color: var(--ink-2); text-decoration: none;
}
.rail li a:hover { color: var(--accent); }
.rail li a[aria-current="page"] { color: var(--accent); border-inline-start-color: var(--accent); }
.rail li span { color: var(--faint); }
.rail .rail-back { display: inline-flex; gap: .35rem; align-items: center; margin-top: 1.5rem; font-size: .9rem; color: var(--muted); text-decoration: none; }
.rail .rail-back:hover { color: var(--accent); }
.rail .rail-back .icon { width: 1rem; height: 1rem; }

.article-main { min-width: 0; max-width: var(--measure); }

.toc-inline { margin: 2rem 0 0; padding: 0; list-style: none; font-size: .95rem; }
.toc-inline li { margin: .2rem 0; }
.toc-inline a { color: var(--muted); text-decoration: none; }
.toc-inline a:hover { color: var(--accent); text-decoration: underline; }

/* ---------- Prose ---------- */

.prose { color: var(--ink); hyphens: manual; overflow-wrap: break-word; }
.prose > * + * { margin-top: 1.15em; }
.prose p { margin: 0; }
.prose > p + p { margin-top: 1.05em; }
.prose h2 {
  font-family: var(--serif); font-weight: 400; font-size: 1.6rem; line-height: 1.25;
  margin: 2.4em 0 .6em; color: var(--ink);
}
.prose h3 { font-family: var(--serif); font-weight: 500; font-size: 1.25rem; margin: 2em 0 .5em; }
.prose h4 { font-size: 1.05rem; font-weight: 600; margin: 1.8em 0 .4em; }
.prose h2 + *, .prose h3 + * { margin-top: 0; }
.prose strong { font-weight: 600; }
.prose ul, .prose ol { padding-inline-start: 1.4em; }
.prose li + li { margin-top: .35em; }
.prose ul { list-style: none; padding-inline-start: 1.6em; }
.prose ul > li { position: relative; }
.prose ul > li::before {
  content: ""; position: absolute; inset-inline-start: -1.35em; top: .62em;
  width: .5em; height: .5em; background: var(--accent); opacity: .55;
  -webkit-mask: url("../img/cross.svg") center / contain no-repeat;
  mask: url("../img/cross.svg") center / contain no-repeat;
}
.prose ol li::marker { color: var(--accent); font-family: var(--serif); }

.prose blockquote {
  margin: 1.8em 0; padding: .1em 0; padding-inline-start: 1.4em;
  border-inline-start: 2px solid color-mix(in srgb, var(--accent) 45%, transparent);
  font-family: var(--serif); font-style: italic; font-size: 1.13em; line-height: 1.65; color: var(--ink-2);
}
.prose blockquote p + p { margin-top: .8em; }
html[lang="ar"] .prose blockquote { font-style: normal; }

.prose hr { border: 0; height: 1px; background: var(--rule); margin: 2.5em 0; }

.prose a { overflow-wrap: anywhere; }

.prose .table-wrap { overflow-x: auto; margin: 1.8em 0; }
.prose table { width: 100%; border-collapse: collapse; font-size: .96em; line-height: 1.6; }
.prose th, .prose td { text-align: start; vertical-align: top; padding: .85em 1em .85em 0; padding-inline: 0 1em; border-bottom: 1px solid var(--rule); }
.prose thead th { border-bottom-color: var(--ink); font-weight: 600; }
.prose table.definition-table { border-top: 1px solid var(--rule); }
.prose table.definition-table th {
  width: 30%; min-width: 8rem; font-family: var(--serif); font-weight: 500; font-size: 1.08em; color: var(--accent-deep);
}
.prose td p + p { margin-top: .6em; }

.prose .callout { background: var(--paper-2); border-radius: var(--radius); padding: 1.1em 1.3em; }

.prose .coptic, .coptic { font-family: "Noto Sans Coptic", var(--sans); }

.prose figure { margin: 2em 0; }
.prose figcaption { font-size: .88em; color: var(--muted); margin-top: .6em; }

.fn-ref { font-size: .68em; line-height: 0; margin-inline-start: .08em; font-variant-numeric: lining-nums; }
.fn-ref a { text-decoration: none; padding: 0 .1em; font-weight: 600; }
.fn-ref a:hover { text-decoration: underline; }

mark { background: var(--accent-tint); color: var(--accent-deep); padding: 0 .1em; border-radius: 2px; }

/* ---------- Prayer ---------- */

.prayer {
  margin: 3.5rem 0 0; padding: 2rem 0 0; text-align: center;
  border-top: 1px solid var(--rule);
}
.prayer .cross { color: var(--accent); width: .95rem; height: .95rem; opacity: .75; }
.prayer h2 { font-family: var(--serif); font-style: italic; font-weight: 400; font-size: 1rem; color: var(--muted); margin: .6rem 0 1rem; }
.prayer-body { font-family: var(--serif); font-size: 1.18rem; line-height: 1.75; color: var(--ink); max-width: 34rem; margin-inline: auto; }
.prayer-body p { margin: 0 0 .8em; }

/* ---------- Notes ---------- */

.notes { margin-top: 3.5rem; padding-top: 1.5rem; border-top: 1px solid var(--rule); font-size: .9rem; color: var(--ink-2); line-height: 1.6; }
.notes h2 { font-family: var(--serif); font-style: italic; font-weight: 400; font-size: 1rem; color: var(--muted); margin: 0 0 .9rem; }
.notes ol { margin: 0; padding-inline-start: 1.6em; }
.notes li { margin-bottom: .45em; padding-inline-start: .2em; }
.notes li::marker { color: var(--accent); font-variant-numeric: lining-nums; }
.notes .back { text-decoration: none; margin-inline-start: .35em; font-size: .9em; }
.notes li:target { background: var(--accent-tint); border-radius: 3px; }

/* ---------- Prev / next ---------- */

.pager { display: grid; gap: 1rem; margin-top: 3.5rem; border-top: 1px solid var(--rule); padding-top: 1.5rem; }
@media (min-width: 40rem) { .pager { grid-template-columns: 1fr 1fr; } }
.pager a { display: block; text-decoration: none; color: var(--ink); padding: .4rem 0; }
.pager a:hover .pager-title { color: var(--accent); }
.pager-dir { display: flex; align-items: center; gap: .3rem; font-size: .88rem; color: var(--muted); }
.pager-dir .icon { width: .95rem; height: .95rem; }
.pager-title { font-family: var(--serif); font-size: 1.2rem; line-height: 1.3; display: block; margin-top: .2rem; }
.pager-chapter { font-size: .85rem; color: var(--faint); }
.pager .next { text-align: end; }
.pager .next .pager-dir { justify-content: flex-end; }
html[dir="rtl"] .pager-dir .icon { transform: scaleX(-1); }

/* ---------- Chapter page ---------- */

.chapter-page { max-width: 48rem; }
.chapter-intro { margin-top: 1.5rem; color: var(--ink-2); }
.chapter-articles { list-style: none; margin: 2.5rem 0 0; padding: 0; border-top: 1px solid var(--ink); }
.chapter-articles li { border-bottom: 1px solid var(--rule); }
.chapter-articles a, .chapter-articles .is-soon {
  display: grid; grid-template-columns: 1.4rem 1fr auto; gap: .9rem; align-items: baseline;
  padding: 1.15rem 0; text-decoration: none; color: var(--ink);
}
.chapter-articles .cross { width: .7rem; height: .7rem; color: var(--accent); opacity: .55; }
.chapter-articles .t { font-family: var(--serif); font-size: 1.35rem; line-height: 1.3; display: block; }
.chapter-articles .s { display: block; color: var(--muted); font-size: .95rem; margin-top: .3rem; line-height: 1.55; }
.chapter-articles a:hover .t { color: var(--accent); }
.chapter-articles .is-soon { color: var(--faint); }
.chapter-articles .is-soon .cross { color: var(--faint); }

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

.search-form { display: flex; gap: .5rem; margin: 1.5rem 0 2.5rem; max-width: 40rem; }
.search-form input {
  flex: 1; min-width: 0; font: inherit; font-size: 1.1rem; color: var(--ink);
  background: #fff; border: 1px solid var(--rule-2); border-radius: var(--radius);
  padding: .7rem .95rem;
}
.search-form input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-tint); }
.btn {
  font: inherit; font-size: 1rem; border-radius: var(--radius); cursor: pointer;
  background: var(--accent); color: #fff; border: 1px solid var(--accent); padding: .65rem 1.2rem;
  text-decoration: none; display: inline-flex; align-items: center; gap: .4rem;
}
.btn:hover { background: var(--accent-deep); border-color: var(--accent-deep); color: #fff; }
.results { list-style: none; padding: 0; margin: 0; max-width: 46rem; }
.results li { padding: 1.2rem 0; border-bottom: 1px solid var(--rule); }
.results a { font-family: var(--serif); font-size: 1.3rem; text-decoration: none; color: var(--ink); }
.results a:hover { color: var(--accent); }
.results .c { font-size: .88rem; color: var(--muted); margin: .1rem 0 .35rem; }
.results p { margin: 0; color: var(--ink-2); font-size: .97rem; }
.muted { color: var(--muted); }

/* ---------- Soon / empty ---------- */

.soon-box { margin-top: 2rem; padding: 1.5rem 0; border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule); color: var(--muted); display: flex; gap: .9rem; align-items: baseline; }
.soon-box .cross { color: var(--accent); opacity: .6; width: .8rem; height: .8rem; }

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

.site-footer { border-top: 1px solid var(--rule); padding-block: 2.5rem 3rem; color: var(--muted); font-size: .9rem; }
.site-footer .wrap { display: grid; gap: 1.25rem; }
@media (min-width: 48rem) { .site-footer .wrap { grid-template-columns: 1fr auto; align-items: end; } }
.site-footer p { margin: 0; line-height: 1.6; }
.footer-brand { display: flex; gap: .75rem; align-items: flex-start; }
.footer-brand .brand-mark { width: 1.6rem; height: 1.6rem; margin-top: .1rem; }
.footer-brand strong { font-family: var(--serif); font-weight: 400; color: var(--ink); font-size: 1rem; }
.footer-links { display: flex; gap: 1.25rem; flex-wrap: wrap; }
.footer-links a { color: var(--muted); text-decoration: none; }
.footer-links a:hover { color: var(--accent); text-decoration: underline; }

/* ---------- 404 ---------- */
.notfound { max-width: 34rem; padding-block: 15vh; }

/* ---------- Mixed-direction text (e.g. an English title on an Arabic page) ---------- */
html[dir="rtl"] :is(.prose p, .prose li) { unicode-bidi: plaintext; }

/* ---------- Motion & print ---------- */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; scroll-behavior: auto !important; }
}

@media print {
  .site-header, .site-footer, .rail, .pager, .admin-bar, .preview-note, .toc-inline { display: none !important; }
  body { font-size: 11pt; background: #fff; }
  .article-layout { display: block; }
  .prose a { color: inherit; text-decoration: none; }
}
