/* ==========================================================================
   المكتبة القرآنية الأندلسية — main stylesheet
   Same identity as v1 (Andalusian gold, Cairo, Córdoba arches, star lattice,
   mandala, gold footer) — rebuilt without Bootstrap/jQuery, RTL-first.
   ========================================================================== */

/* ---------- Fonts ---------- */
@font-face { font-family: "Cairo"; font-weight: 400; font-display: swap; src: url(../fonts/Cairo-Regular.woff2) format("woff2"); }
@font-face { font-family: "Cairo"; font-weight: 600; font-display: swap; src: url(../fonts/Cairo-SemiBold.woff2) format("woff2"); }
@font-face { font-family: "Cairo"; font-weight: 700; font-display: swap; src: url(../fonts/Cairo-Bold.woff2) format("woff2"); }

/* ---------- Tokens ---------- */
:root {
    --gold: #D08F37;          /* brand gold (buttons, footer bar) */
    --gold-deep: #AB7200;     /* headings */
    --gold-ink: #8A5B00;      /* gold text on light bg — 5.8:1 on paper */
    --gold-ink-hover: #6B4600;
    --gold-strong: #9C6414;   /* gold surfaces that carry white text — 4.95:1 */
    --on-gold: #fff;
    --focus: #8A5B00;         /* focus ring on light surfaces — 5.8:1 */
    --line-strong: #8F8474;   /* input borders — 3.6:1 */
    --gold-bright: #F2C25B;   /* gold on dark */
    --gold-soft: #F7E7CC;
    --gold-tint: #FCF4E6;

    --ink: #1F1B16;
    --ink-2: #3E372E;
    --muted: #6F665B;
    --line: #EBE1D2;
    --paper: #FFFDF9;
    --night: #171717;
    --night-2: #221D16;

    --font: "Cairo", system-ui, "Segoe UI", Tahoma, sans-serif;

    --radius: 18px;
    --radius-sm: 10px;
    --shadow-sm: 0 1px 2px rgb(60 40 10 / .06), 0 2px 8px rgb(60 40 10 / .05);
    --shadow: 0 2px 6px rgb(60 40 10 / .06), 0 12px 32px -8px rgb(90 60 10 / .18);
    --shadow-lg: 0 4px 10px rgb(60 40 10 / .08), 0 24px 48px -12px rgb(90 60 10 / .28);

    --container: 1180px;
    --narrow: 760px;
    --gutter: clamp(1rem, 4vw, 2rem);
    --header-h: 76px;
    --ease: cubic-bezier(.2, .7, .2, 1);
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: calc(var(--header-h) + 16px); }
body {
    margin: 0;
    font-family: var(--font);
    font-size: 1rem;
    line-height: 1.8;
    color: var(--ink-2);
    background: var(--paper);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}
img, svg, video { max-width: 100%; height: auto; }
img { display: block; }
a { color: var(--gold-ink); text-decoration: none; transition: color .2s; }
a:hover { color: var(--gold-ink-hover); }
h1, h2, h3, h4, h5, h6 { color: var(--ink); line-height: 1.4; margin: 0 0 .6em; font-weight: 700; }
p { margin: 0 0 1em; }
button { font: inherit; }
::selection { background: var(--gold-strong); color: var(--on-gold); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; border-radius: 4px; }
/* Dark surfaces get a bright ring */
.hero, .page-hero, .site-footer, body:not(.menu-open) .site-header.is-overlay:not(.is-scrolled), .filters__item.is-active { --focus: var(--gold-bright); }
::placeholder { color: var(--muted); opacity: 1; }

.icon { width: 1.25em; height: 1.25em; flex: none; vertical-align: middle; }
[dir="rtl"] .icon--flip { transform: scaleX(-1); }

.screen-reader-text {
    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: fixed; inset-inline-start: 1rem; top: -100px; z-index: 1000;
    background: var(--night); color: #fff; padding: .6rem 1rem; border-radius: var(--radius-sm);
}
.skip-link:focus { top: 1rem; color: #fff; }

.container { width: 100%; max-width: var(--container); margin-inline: auto; padding-inline: var(--gutter); }
.container--narrow { max-width: calc(var(--narrow) + var(--gutter) * 2); }

/* ---------- Buttons & chips ---------- */
.btn {
    display: inline-flex; align-items: center; gap: .5rem;
    min-height: 48px; padding: .6rem 1.5rem;
    border: 2px solid var(--gold-strong); border-radius: 999px;
    background: var(--gold-strong); color: var(--on-gold);
    font-weight: 700; font-size: .95rem; line-height: 1;
    cursor: pointer;
    transition: background .25s var(--ease), color .25s var(--ease), transform .25s var(--ease), box-shadow .25s var(--ease);
    box-shadow: 0 6px 18px -6px rgb(208 143 55 / .7);
}
.btn:hover { background: var(--night); border-color: var(--night); color: #fff; transform: translateY(-2px); }
.btn .icon { transition: transform .25s var(--ease); }
.btn:hover .icon { transform: translateX(-4px); }
.btn--ghost { background: rgb(15 10 4 / .45); border-color: rgb(255 255 255 / .7); color: #fff; box-shadow: none; backdrop-filter: blur(6px); text-shadow: 0 1px 2px rgb(0 0 0 / .5); }
.btn--ghost:hover { background: #fff; border-color: #fff; color: var(--ink); }
.btn--sm { min-height: 40px; padding: .4rem 1.1rem; font-size: .875rem; }

.chip {
    display: inline-flex; align-items: center;
    padding: .2rem .8rem; border-radius: 999px;
    background: var(--gold-tint); color: var(--gold-ink);
    border: 1px solid var(--gold-soft);
    font-size: .8rem; font-weight: 600; line-height: 1.8;
}
.chip:hover { background: var(--gold-strong); border-color: var(--gold-strong); color: var(--on-gold); }
.chip--light { background: rgb(242 194 91 / .14); border-color: rgb(242 194 91 / .4); color: var(--gold-bright); }
.chip--light:hover { background: var(--gold-bright); color: var(--night); }

.meta { display: inline-flex; align-items: center; gap: .35rem; font-size: .85rem; color: var(--muted); }
.meta .icon { width: 1.05em; height: 1.05em; color: var(--gold); }

/* ---------- Header ---------- */
.site-header {
    position: sticky; top: 0; z-index: 50;
    background: rgb(255 253 249 / .88);
    backdrop-filter: saturate(1.6) blur(14px);
    -webkit-backdrop-filter: saturate(1.6) blur(14px);
    border-bottom: 1px solid var(--line);
    transition: background .35s var(--ease), border-color .35s var(--ease), box-shadow .35s var(--ease);
}
.admin-bar .site-header { top: 32px; }
@media (max-width: 782px) { .admin-bar .site-header { top: 46px; } }
@media (max-width: 600px) { .admin-bar .site-header { top: 0; } .admin-bar .site-header.is-overlay:not(.is-scrolled) { top: 46px; } }

.site-header__inner { display: flex; align-items: center; gap: 1.5rem; min-height: var(--header-h); }
.site-header.is-scrolled { box-shadow: 0 8px 24px -12px rgb(60 40 10 / .25); }

/* Transparent over the hero on the front page */
.site-header.is-overlay { position: fixed; inset-inline: 0; background: transparent; border-color: transparent; backdrop-filter: none; -webkit-backdrop-filter: none; }
body:not(.menu-open) .site-header.is-overlay:not(.is-scrolled) .brand__name,
body:not(.menu-open) .site-header.is-overlay:not(.is-scrolled) .nav__list > li > a,
body:not(.menu-open) .site-header.is-overlay:not(.is-scrolled) .icon-btn { color: #fff; text-shadow: 0 1px 3px rgb(0 0 0 / .8); }
body:not(.menu-open) .site-header.is-overlay:not(.is-scrolled) .icon-btn .icon { filter: drop-shadow(0 1px 2px rgb(0 0 0 / .7)); }
body:not(.menu-open) .site-header.is-overlay:not(.is-scrolled) .brand__logo { filter: drop-shadow(0 1px 3px rgb(0 0 0 / .6)); }
.site-header.is-overlay.is-scrolled { background: rgb(255 253 249 / .9); border-color: var(--line); backdrop-filter: saturate(1.6) blur(14px); -webkit-backdrop-filter: saturate(1.6) blur(14px); }

.brand { display: inline-flex; align-items: center; gap: .75rem; color: var(--ink); }
.brand:hover { color: var(--ink); }
.brand__logo { width: 56px; height: 56px; object-fit: contain; transition: width .3s var(--ease), height .3s var(--ease); }
.site-header.is-scrolled .brand__logo { width: 46px; height: 46px; }
.brand__name { font-weight: 700; font-size: 1.05rem; line-height: 1.3; white-space: nowrap; transition: color .3s; }

.nav { margin-inline-start: auto; display: flex; align-items: center; gap: 1rem; }
.nav__list { list-style: none; margin: 0; padding: 0; display: flex; align-items: center; gap: .25rem; }
.nav__list a {
    position: relative; display: block; padding: .5rem .9rem;
    color: var(--ink-2); font-weight: 600; font-size: .95rem;
    transition: color .2s;
}
.nav__list > li > a { border-radius: 8px; transition: color .2s, background-color .2s; }
.nav__list > li > a:hover { background: rgb(208 143 55 / .1); }
.nav__list .current-menu-item > a, .nav__list .current-menu-ancestor > a { font-weight: 700; }
.nav__list > li > a:hover, .nav__list .current-menu-item > a, .nav__list .current-menu-ancestor > a { color: var(--gold-ink); }
body:not(.menu-open) .site-header.is-overlay:not(.is-scrolled) .nav__list > li > a:hover,
body:not(.menu-open) .site-header.is-overlay:not(.is-scrolled) .nav__list .current-menu-item > a { color: var(--gold-bright); }
body:not(.menu-open) .site-header.is-overlay:not(.is-scrolled) .nav__list > li > a:hover { background: rgb(255 255 255 / .12); }

/* sub-menus */
.nav__list .menu-item-has-children { position: relative; }
.nav__list .sub-menu {
    position: absolute; inset-inline-start: 0; top: 100%; min-width: 220px;
    list-style: none; margin: 0; padding: .5rem;
    background: #fff; border-radius: var(--radius-sm); box-shadow: var(--shadow);
    border-top: 2px solid var(--gold);
    opacity: 0; visibility: hidden; transform: translateY(8px);
    transition: all .25s var(--ease);
}
.nav__list .menu-item-has-children:hover > .sub-menu,
.nav__list .menu-item-has-children:focus-within > .sub-menu { opacity: 1; visibility: visible; transform: none; }
.nav__list .sub-menu a { border-radius: 8px; color: var(--ink-2) !important; }
.nav__list .sub-menu a:hover { background: var(--gold-tint); }

.nav__search { display: none; }

.site-header__actions { display: flex; align-items: center; gap: .25rem; }
.icon-btn {
    display: inline-grid; place-items: center; width: 44px; height: 44px;
    border: 0; border-radius: 50%; background: transparent; color: var(--ink-2); cursor: pointer;
    transition: background .2s, color .2s;
}
.icon-btn:hover { background: rgb(208 143 55 / .12); color: var(--gold-ink); }
.menu-toggle { display: none; }
.menu-toggle .icon--close { display: none; }
.menu-toggle[aria-expanded="true"] .icon--open { display: none; }
.menu-toggle[aria-expanded="true"] .icon--close { display: block; }

.header-search { border-top: 1px solid var(--line); background: var(--paper); }
.header-search__form { display: flex; align-items: center; gap: .75rem; padding-block: .9rem; }
.header-search__form > .icon { color: var(--gold); }
.header-search__form input {
    flex: 1; min-width: 0; border: 0; border-bottom: 1px solid var(--line-strong); background: transparent; font: inherit; font-size: 1.05rem; color: var(--ink);
    padding: .4rem 0;
}

/* ---------- Hero (front page) ---------- */
.hero {
    position: relative; isolation: isolate; overflow: hidden;
    min-height: clamp(560px, 92vh, 820px);
    display: flex; align-items: center;
    color: #fff;
    padding-block: calc(var(--header-h) + 3rem) clamp(9rem, 15vw, 12rem);
}
.hero__bg {
    position: absolute; inset: 0; z-index: -3;
    background: url(../images/hero.webp) center 35% / cover no-repeat;
    transform: scale(1.06);
    animation: hero-zoom 18s var(--ease) forwards;
}
.hero::before { /* warm, legible overlay */
    content: ""; position: absolute; inset: 0; z-index: -2;
    background:
        linear-gradient(270deg, rgb(20 14 6 / .88) 0%, rgb(20 14 6 / .72) 50%, rgb(20 14 6 / .35) 100%),
        linear-gradient(180deg, rgb(20 14 6 / .55) 0%, transparent 28%);
}
.hero__lattice { /* the gold Andalusian star lattice from v1 */
    position: absolute; z-index: -1;
    inset-block: 0 25%; inset-inline-start: -8%; width: 34%;
    background: url(../images/lattice.webp) center / 360px repeat;
    mix-blend-mode: soft-light; opacity: .55;
    -webkit-mask-image: linear-gradient(to left, transparent, #000 40%);
            mask-image: linear-gradient(to left, transparent, #000 40%);
}
.hero__content { position: relative; max-width: var(--container); }
.hero__eyebrow {
    margin-bottom: 1rem;
    color: var(--gold-bright); font-size: .95rem; font-weight: 600;
    text-shadow: 0 1px 2px rgb(0 0 0 / .8), 0 0 12px rgb(0 0 0 / .5);
}
.hero__title {
    color: #fff; font-size: clamp(2.1rem, 5.5vw, 4rem); line-height: 1.25; margin-bottom: 1.25rem;
    max-width: 16ch; text-wrap: balance;
    text-shadow: 0 2px 4px rgb(0 0 0 / .6), 0 4px 28px rgb(0 0 0 / .45);
}
.hero__text { font-size: clamp(1rem, 1.6vw, 1.2rem); line-height: 2; max-width: 58ch; color: #fff; margin-bottom: 2.25rem; text-shadow: 0 1px 3px rgb(0 0 0 / .75), 0 0 18px rgb(0 0 0 / .45); }
.hero__actions { display: flex; flex-wrap: wrap; gap: .75rem; }
.hero__wave { position: absolute; inset-inline: 0; bottom: -1px; width: 100%; height: clamp(90px, 14vw, 200px); z-index: 0; }

.hero__content > * { animation: rise .9s var(--ease) both; }
.hero__content > :nth-child(2) { animation-delay: .1s; }
.hero__content > :nth-child(3) { animation-delay: .2s; }
.hero__content > :nth-child(4) { animation-delay: .3s; }

@keyframes rise { from { opacity: 0; transform: translateY(24px); } to { opacity: 1; transform: none; } }
@keyframes hero-zoom { to { transform: scale(1); } }

/* ---------- Sections ---------- */
.section { padding-block: clamp(3.5rem, 8vw, 6.5rem); position: relative; }
.section--tint { background: linear-gradient(180deg, var(--gold-tint), var(--paper)); }

.posts-section { overflow: hidden; isolation: isolate; }
.posts-section::before, .posts-section::after { /* the faint mandalas from v1 */
    content: ""; position: absolute; z-index: -1; top: 8%;
    width: min(46vw, 620px); aspect-ratio: 1;
    background: url(../images/mandala.webp) center / contain no-repeat;
    opacity: .13; pointer-events: none;
}
.posts-section::before { inset-inline-end: calc(min(46vw, 620px) * -.55); }
.posts-section::after { inset-inline-start: calc(min(46vw, 620px) * -.55); top: auto; bottom: 4%; }

.section-head { text-align: center; margin-bottom: clamp(2rem, 4vw, 3rem); color: var(--gold); }
.section-head__title { color: var(--gold-deep); font-size: clamp(1.6rem, 3vw, 2.1rem); margin-bottom: .6rem; }
.ornament { display: block; margin-inline: auto; width: 166px; height: auto; }

/* ---------- Filters ---------- */
.filters { display: flex; flex-wrap: wrap; justify-content: center; gap: .5rem; margin-bottom: clamp(2rem, 4vw, 3rem); }
.filters__item {
    display: inline-flex; align-items: center; gap: .5rem;
    padding: .5rem 1.15rem; border-radius: 999px;
    background: #fff; border: 1px solid var(--line); color: var(--ink-2);
    font: inherit; font-weight: 600; font-size: .9rem; line-height: 1.8; cursor: pointer;
    box-shadow: var(--shadow-sm);
    transition: all .2s var(--ease);
}
.filters__item:hover { border-color: var(--gold); color: var(--gold-ink); }
.filters__item.is-active { background: var(--night); border-color: var(--night); color: #fff; }
.filters__count {
    display: inline-grid; place-items: center; min-width: 1.6rem; height: 1.6rem; padding-inline: .35rem;
    border-radius: 999px; background: var(--gold-tint); color: var(--gold-ink); font-size: .75rem;
}
.filters__item.is-active .filters__count { background: var(--gold-strong); color: var(--on-gold); }

.card.is-filtered-out { display: none; }
.card.is-filtering-in { animation: rise .45s var(--ease) both; }

/* ---------- Cards ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); gap: clamp(1.25rem, 2.5vw, 2rem); }

.card {
    position: relative; display: flex; flex-direction: column;
    background: #fff; border-radius: var(--radius); overflow: hidden;
    border: 1px solid var(--line);
    box-shadow: var(--shadow-sm);
    transition: transform .35s var(--ease), box-shadow .35s var(--ease), border-color .35s;
}
.card:hover { transform: translateY(-6px); box-shadow: var(--shadow-lg); border-color: var(--gold-soft); }
.card:has(.card__title a:focus-visible) { outline: 3px solid var(--focus); outline-offset: 3px; }
.card__title a:focus-visible { outline: none; }
.card__media { display: block; aspect-ratio: 16 / 10; overflow: hidden; background: var(--gold-tint); }
.card__img { width: 100%; height: 100%; object-fit: cover; transition: transform .7s var(--ease); }
.card:hover .card__img { transform: scale(1.06); }
.card__img--placeholder { display: grid; place-items: center; color: var(--gold); }
.card__img--placeholder .icon { width: 48px; height: 48px; }

.card__body { display: flex; flex-direction: column; align-items: flex-start; gap: .65rem; padding: 1.25rem 1.4rem 1.4rem; flex: 1; }
.card__top { display: flex; align-items: center; justify-content: space-between; gap: .75rem; width: 100%; flex-wrap: wrap; }
.card__date { font-size: .8rem; margin-inline-start: auto; }
.card__title { font-size: 1.15rem; line-height: 1.6; margin: 0; }
.card__title a { color: var(--ink); transition: color .2s; }
.card:hover .card__title a { color: var(--gold-ink); }
.card__title a::after { content: ""; position: absolute; inset: 0; z-index: 1; } /* whole card clickable */
.card .chip { position: relative; z-index: 2; }
.card__excerpt {
    margin: 0; color: var(--muted); font-size: .925rem; line-height: 1.9;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.card__footer {
    margin-top: auto; padding-top: .9rem; width: 100%;
    display: flex; align-items: center; justify-content: space-between; gap: 1rem;
    border-top: 1px dashed var(--line);
}
.card__more { display: inline-flex; align-items: center; gap: .35rem; font-weight: 700; font-size: .9rem; color: var(--gold-ink); }
.card__more .icon { transition: transform .3s var(--ease); }
.card:hover .card__more .icon { transform: translateX(-4px); }

/* ---------- Pagination ---------- */
.pagination { margin-top: 3rem; }
.pagination .nav-links { display: flex; justify-content: center; flex-wrap: wrap; gap: .4rem; }
.pagination .page-numbers {
    display: inline-grid; place-items: center; min-width: 44px; height: 44px; padding-inline: .75rem;
    border-radius: 999px; border: 1px solid var(--line); background: #fff; color: var(--ink-2); font-weight: 600;
}
.pagination .page-numbers:hover { border-color: var(--gold); color: var(--gold-ink); }
.pagination .page-numbers.current { background: var(--gold-strong); border-color: var(--gold-strong); color: var(--on-gold); }

/* ---------- Inner page hero ---------- */
.page-hero {
    position: relative; isolation: isolate; overflow: hidden;
    background: radial-gradient(120% 140% at 100% 0%, #2E2416 0%, var(--night) 60%);
    color: rgb(255 255 255 / .85);
    padding-block: clamp(2.5rem, 6vw, 4.5rem) clamp(3.5rem, 8vw, 6rem);
}
.page-hero__lattice {
    position: absolute; inset-block: 0; inset-inline-end: 0; width: 45%; z-index: -1;
    background: url(../images/lattice.webp) center / 300px repeat; opacity: .12;
    -webkit-mask-image: linear-gradient(to right, transparent, #000 70%);
            mask-image: linear-gradient(to right, transparent, #000 70%);
}
.page-hero::after { content: ""; position: absolute; inset-inline: 0; bottom: 0; height: 3px; background: linear-gradient(90deg, transparent, var(--gold), transparent); }
.page-hero__inner { display: flex; flex-direction: column; align-items: flex-start; gap: .9rem; max-width: calc(var(--narrow) + 200px + var(--gutter) * 2); }
.page-hero__title { color: #fff; font-size: clamp(1.7rem, 4vw, 2.75rem); line-height: 1.45; margin: 0; text-wrap: balance; }
.page-hero__meta { display: flex; flex-wrap: wrap; gap: 1.25rem; }
.page-hero__meta .meta { color: rgb(255 255 255 / .75); }
.page-hero__meta .meta .icon { color: var(--gold-bright); }

.breadcrumb ol { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; align-items: center; font-size: .875rem; }
.breadcrumb li { display: inline-flex; align-items: center; color: rgb(255 255 255 / .6); }
.breadcrumb li + li::before { content: "/"; margin-inline: .6rem; color: rgb(242 194 91 / .6); }
.breadcrumb a { color: rgb(255 255 255 / .75); }
.breadcrumb a:hover { color: var(--gold-bright); }
.breadcrumb [aria-current] { color: var(--gold-bright); max-width: 40ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Article ---------- */
.article { padding-bottom: clamp(3rem, 6vw, 5rem); }
.article__cover { max-width: calc(900px + var(--gutter) * 2); margin: calc(clamp(2rem, 5vw, 3.5rem) * -1) auto 0; position: relative; z-index: 2; }
.article__cover img { width: 100%; max-height: 520px; object-fit: cover; border-radius: var(--radius); box-shadow: var(--shadow-lg); border: 6px solid #fff; }
.article__body { max-width: calc(var(--narrow) + var(--gutter) * 2); margin-inline: auto; padding-inline: var(--gutter); padding-top: clamp(2rem, 5vw, 3.5rem); }
.article:not(:has(.article__cover)) .article__body { padding-top: clamp(2.5rem, 6vw, 4rem); }
.article__footer { margin-top: 3rem; display: grid; gap: 2rem; }

.tags { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: .5rem; }

.post-nav { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; padding-top: 2rem; border-top: 1px solid var(--line); }
.post-nav__item {
    display: flex; flex-direction: column; gap: .3rem; padding: 1.1rem 1.25rem;
    border: 1px solid var(--line); border-radius: var(--radius-sm); background: #fff;
    transition: border-color .2s, box-shadow .2s, transform .2s;
}
.post-nav__item:hover { border-color: var(--gold); box-shadow: var(--shadow); transform: translateY(-2px); }
.post-nav__item--next { grid-column: 2; text-align: left; align-items: flex-end; }
.post-nav__label { display: inline-flex; align-items: center; gap: .35rem; font-size: .8rem; font-weight: 600; color: var(--gold-ink); }
.post-nav__title { color: var(--ink); font-weight: 700; line-height: 1.6; }

/* ---------- Prose (post content) ---------- */
.prose { font-size: clamp(1.05rem, 1.2vw, 1.15rem); line-height: 2.1; color: var(--ink-2); }
.prose > * + * { margin-top: 1.1em; }
.prose > * { margin-block: 0; }
.prose > * + * { margin-top: 1.1em; }
.prose h2, .prose h3, .prose h4 { color: var(--gold-deep); margin-top: 2em; line-height: 1.5; }
.prose h2 { font-size: 1.6em; padding-bottom: .4em; border-bottom: 1px solid var(--line); }
.prose h3 { font-size: 1.3em; }
.prose h4 { font-size: 1.1em; }
.prose strong { color: inherit; font-weight: 700; }

/* Map the WordPress default palette the posts were written with onto the brand:
   body text used "vivid cyan blue", headings used "vivid green cyan". */
.prose {
    --wp--preset--color--vivid-cyan-blue: var(--ink-2);
    --wp--preset--color--vivid-green-cyan: var(--gold-ink);
    --wp--preset--color--luminous-vivid-orange: var(--gold-ink);
    --wp--preset--color--luminous-vivid-amber: var(--gold-ink);
    --wp--preset--color--vivid-red: #A63A2B;
}
.prose p[style*="font-size"] { line-height: 1.6; margin-top: 1.6em; font-weight: 700; }
.prose a:not(.wp-block-button__link):not(.wp-block-file__button) { color: var(--gold-ink); text-decoration: underline; text-decoration-color: var(--gold-soft); text-decoration-thickness: 2px; text-underline-offset: 5px; }
.prose a:not(.wp-block-button__link):not(.wp-block-file__button) { border-radius: 3px; transition: background-color .2s, color .2s; }
.prose a:not(.wp-block-button__link):not(.wp-block-file__button):hover { color: var(--gold-ink-hover); background: var(--gold-tint); text-decoration-color: transparent; }
.prose ul, .prose ol { padding-inline-start: 1.4em; }
.prose li + li { margin-top: .35em; }
.prose ul li::marker { color: var(--gold); }
.prose ol li::marker { color: var(--gold-ink); font-weight: 700; }
.prose blockquote, .prose .wp-block-quote {
    margin-inline: 0; padding: 1.25rem 1.5rem; border: 0; border-inline-start: 4px solid var(--gold);
    background: var(--gold-tint); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; color: var(--ink);
}
.prose figure { margin-inline: 0; }
.prose img { border-radius: var(--radius-sm); }
.prose .wp-block-image { text-align: center; }
.prose .wp-block-image img { display: inline-block; box-shadow: var(--shadow); }
.prose .wp-block-image.is-resized img, .prose .wp-block-image .is-resized img { height: auto; }
.prose figcaption, .prose .wp-element-caption { font-size: .85rem; color: var(--muted); text-align: center; margin-top: .6rem; }
.prose hr { border: 0; height: 8px; margin-block: 2.5em; background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 166 8'%3E%3Cg fill='none' stroke='%23D08F37'%3E%3Cpath d='M6 4h66M94 4h66'/%3E%3C/g%3E%3Cg fill='%23D08F37'%3E%3Cpath d='m0 4 5-3v6z'/%3E%3Cpath d='m166 4-5-3v6z'/%3E%3Ccircle cx='83' cy='4' r='3.5'/%3E%3C/g%3E%3C/svg%3E") center / 166px 8px no-repeat; }
.prose table { width: 100%; border-collapse: collapse; font-size: .95em; }
.prose th, .prose td { border: 1px solid var(--line); padding: .6em .8em; text-align: start; }
.prose th { background: var(--gold-tint); color: var(--ink); }

/* Audio recordings (Shatibiyyah readings) */
.prose .wp-block-audio {
    display: flex; flex-direction: column; gap: .6rem;
    padding: 1rem 1.1rem; border-radius: var(--radius);
    background: linear-gradient(135deg, var(--gold-tint), #fff);
    border: 1px solid var(--gold-soft); box-shadow: var(--shadow-sm);
}
.prose .wp-block-audio audio { width: 100%; min-width: 0; height: 44px; }
.prose .wp-block-audio figcaption { text-align: start; margin: 0; color: var(--ink-2); font-weight: 600; }

/* File downloads */
.prose .wp-block-file {
    display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem;
    padding: 1rem 1.25rem; border: 1px dashed var(--gold); border-radius: var(--radius-sm); background: #fff;
}
.prose .wp-block-file .wp-block-file__button, .prose .wp-block-button__link {
    background: var(--gold-strong); color: var(--on-gold); border-radius: 999px; padding: .5rem 1.25rem; font-weight: 700; font-size: .9rem; text-decoration: none;
}
.prose .wp-block-file .wp-block-file__button:hover, .prose .wp-block-button__link:hover { background: var(--night); color: #fff; }

.prose .alignwide { width: min(1000px, 100vw - var(--gutter) * 2); max-width: none; margin-inline: calc(50% - min(500px, 50vw - var(--gutter))); }
.prose .alignfull { width: 100vw; max-width: 100vw; margin-inline: calc(50% - 50vw); }

.page-links { display: flex; gap: .5rem; margin-top: 2rem; }

/* ---------- Search form / empty ---------- */
.search-form { display: flex; gap: .5rem; max-width: 520px; margin-inline: auto; }
.search-form input {
    flex: 1; min-width: 0; min-height: 48px; padding: .5rem 1.25rem;
    border: 1px solid var(--line-strong); border-radius: 999px; background: #fff; font: inherit; color: var(--ink);
}
.search-form input:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 4px rgb(208 143 55 / .15); }
.empty { text-align: center; display: grid; gap: 1.5rem; justify-items: center; color: var(--muted); font-size: 1.05rem; }
.archive-intro { max-width: var(--narrow); margin: 0 auto 2.5rem; text-align: center; }

/* ---------- Footer ---------- */
.site-footer { color: rgb(255 255 255 / .72); }
.site-footer__main {
    position: relative; isolation: isolate; overflow: hidden;
    background: var(--night); padding-block: clamp(3rem, 6vw, 4.5rem);
}
.site-footer__main::before {
    content: ""; position: absolute; inset: 0; z-index: -1;
    background: url(../images/lattice.webp) center / 280px repeat; opacity: .05;
}
.site-footer__grid { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 2.5rem; }
.site-footer__about p { max-width: 52ch; font-size: .925rem; line-height: 2; margin-top: 1rem; }
.brand--footer .brand__name { color: #fff; max-width: none; }
.brand--footer .brand__logo { width: 64px; height: 64px; }
.site-footer__title { color: var(--gold-bright); font-size: 1rem; margin-bottom: 1rem; }
.site-footer ul { list-style: none; margin: 0; padding: 0; display: grid; gap: .5rem; }
.site-footer a { color: rgb(255 255 255 / .78); }
.site-footer a:hover { color: var(--gold-bright); }
.social { display: flex !important; gap: .5rem !important; }
.social a {
    display: inline-grid; place-items: center; width: 42px; height: 42px; border-radius: 50%;
    border: 1px solid rgb(255 255 255 / .15); transition: all .2s;
}
.social a:hover { background: var(--gold-strong); border-color: var(--gold-strong); color: var(--on-gold); }

.site-footer__bar { background: var(--gold-strong); color: var(--on-gold); }
.site-footer__bar-inner { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .5rem 2rem; padding-block: 1.1rem; }
.site-footer__bar p { margin: 0; font-weight: 600; font-size: .9rem; }

.to-top {
    position: fixed; inset-inline-end: 1.25rem; bottom: 1.25rem; z-index: 40;
    display: grid; place-items: center; width: 48px; height: 48px;
    border: 0; border-radius: 50%; background: var(--gold-strong); color: var(--on-gold); cursor: pointer;
    box-shadow: 0 8px 24px -6px rgb(208 143 55 / .8);
    opacity: 0; visibility: hidden; transform: translateY(16px);
    transition: all .3s var(--ease);
}
.to-top.is-visible { opacity: 1; visibility: visible; transform: none; }
.to-top:hover { background: var(--night); color: #fff; }

/* ---------- Reading progress ---------- */
.progress { position: fixed; inset-inline: 0; top: 0; height: 3px; z-index: 100; pointer-events: none; }
.admin-bar .progress { top: 32px; }
.progress__bar { display: block; height: 100%; width: 100%; background: linear-gradient(90deg, var(--gold-deep), var(--gold-bright)); transform-origin: right; transform: scaleX(0); }

/* ---------- Reveal on scroll (progressive: only when JS adds .js) ---------- */
.js .reveal { opacity: 0; transform: translateY(24px); transition: opacity .7s var(--ease), transform .7s var(--ease); }
.js .reveal.is-in { opacity: 1; transform: none; }
.js .card.reveal.is-in:hover { transform: translateY(-6px); }

/* ---------- Responsive ---------- */
@media (max-width: 960px) {
    .menu-toggle { display: inline-grid; }
    .site-header__actions { margin-inline-start: auto; }
    .search-toggle { display: none; }
    .nav {
        position: fixed; inset: 0; inset-block-start: var(--nav-top, var(--header-h)); z-index: 49;
        flex-direction: column; align-items: stretch; gap: 1.5rem;
        padding: 1.5rem var(--gutter) 2rem;
        background: var(--paper);
        overflow-y: auto;
        opacity: 0; visibility: hidden; transform: translateY(-12px);
        transition: opacity .3s var(--ease), transform .3s var(--ease), visibility .3s;
    }
    .nav.is-open { opacity: 1; visibility: visible; transform: none; }
    .nav__list { flex-direction: column; align-items: stretch; gap: 0; }
    .nav__list a {
        display: flex; align-items: center; justify-content: space-between;
        padding: 1rem .25rem; font-size: 1.1rem; font-weight: 600;
        border-bottom: 1px solid var(--line); color: var(--ink-2) !important; text-shadow: none;
    }
    .nav__list a::before { /* small chevron pointing forward (left in RTL) */
        content: ""; order: 2; width: 8px; height: 8px;
        border-left: 2px solid var(--gold); border-bottom: 2px solid var(--gold);
        transform: rotate(45deg); opacity: .7;
    }
    .nav__list a:hover, .nav__list .current-menu-item > a { color: var(--gold-ink) !important; }
    .nav__list .current-menu-item > a { font-weight: 700; }
    .nav__list > li > a:hover { background: none; }
    .nav__list .sub-menu { position: static; opacity: 1; visibility: visible; transform: none; box-shadow: none; border: 0; padding: 0 1rem 0 0; background: none; }
    .nav__search { display: flex; gap: .5rem; order: -1; }
    .nav__search input { flex: 1; min-width: 0; min-height: 48px; padding: .5rem 1.25rem; border: 1px solid var(--line-strong); border-radius: 999px; font: inherit; background: #fff; }
    .nav__search button { display: grid; place-items: center; width: 48px; border: 0; border-radius: 50%; background: var(--gold-strong); color: var(--on-gold); }
    .menu-open { overflow: hidden; }
    /* backdrop-filter makes the header the containing block of the fixed nav — drop it while open */
    .menu-open .site-header { backdrop-filter: none; -webkit-backdrop-filter: none; background: var(--paper); }
    .menu-open .site-header.is-overlay { background: var(--paper); }
    .menu-open .site-header .brand__name, .menu-open .site-header .icon-btn { color: var(--ink) !important; text-shadow: none; }
    .menu-open .site-header .brand__logo, .menu-open .site-header .icon { filter: none; }
    .menu-open .menu-toggle { background: var(--gold-tint); }
    .site-footer__grid { grid-template-columns: 1fr 1fr; }
    .site-footer__about { grid-column: 1 / -1; }
}

@media (max-width: 640px) {
    :root { --header-h: 64px; }
    .brand__logo { width: 46px; height: 46px; }
    .brand__name { font-size: .95rem; }
    .hero { min-height: 0; padding-block: calc(var(--header-h) + 3.5rem) 7rem; }
    .hero__lattice { width: 70%; opacity: .5; }
    /* text spans the full width on phones — keep the scrim strong everywhere */
    .hero::before { background: linear-gradient(180deg, rgb(20 14 6 / .7), rgb(20 14 6 / .78)); }
    .hero__actions .btn { flex: 1 1 100%; justify-content: center; }
    .post-nav { grid-template-columns: 1fr; }
    .post-nav__item--next { grid-column: auto; }
    .site-footer__grid { grid-template-columns: 1fr; }
    .site-footer__bar-inner { flex-direction: column; text-align: center; padding-bottom: 1.5rem; }
    .article__cover img { border-width: 4px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
    .js .reveal { opacity: 1; transform: none; }
}

@media print {
    .site-header, .site-footer, .to-top, .progress, .related, .post-nav, .page-hero__lattice { display: none !important; }
    .page-hero { background: none; color: #000; padding: 0; }
    .page-hero__title { color: #000; }
}

/* ---------- Forced colours (Windows High Contrast) ---------- */
@media (forced-colors: active) {
    .btn, .filters__item, .chip, .card, .icon-btn, .to-top, .search-form input { border: 1px solid CanvasText; }
    .filters__item.is-active { outline: 2px solid Highlight; }
    .hero::before, .hero__lattice, .page-hero__lattice, .posts-section::before, .posts-section::after { display: none; }
}
