/*
Theme Name: Homad Legacy
Description: Custom theme for the AbdulWahab Homad Digital Legacy Library.
Version: 0.2.0
*/

:root {
	--ink: #17140f;
	--ink-soft: #4a4238;
	--paper: #fdfbf7;
	--panel: #ffffff;
	--accent: #7a1f2b;
	--accent-dark: #591620;
	--gold: #a8813f;
	--border: #e7e0d2;
	--border-strong: #d8cdb6;
	--max-width: 740px;
	--wide-width: 1040px;
	--serif: 'Source Serif 4', Georgia, 'Times New Roman', serif;
	--display: 'Playfair Display', var(--serif);
	--sans: 'Inter', 'Segoe UI', system-ui, sans-serif;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
	margin: 0;
	background: var(--paper);
	color: var(--ink);
	font-family: var(--serif);
	line-height: 1.75;
	font-size: 18px;
	-webkit-font-smoothing: antialiased;
}

body.lang-ar {
	font-family: 'Noto Naskh Arabic', 'Traditional Arabic', 'Tahoma', serif;
	direction: rtl;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; }

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

.site-header {
	background: var(--panel);
	border-bottom: 3px solid var(--ink);
	padding: 0;
	position: relative;
}

.site-header::after {
	content: "";
	display: block;
	height: 4px;
	background: linear-gradient(90deg, var(--accent) 0%, var(--accent) 60px, var(--gold) 60px, var(--gold) 90px, transparent 90px);
}

.site-header .wrap {
	max-width: var(--wide-width);
	margin: 0 auto;
	display: flex;
	align-items: center;
	justify-content: space-between;
	flex-wrap: wrap;
	gap: 14px;
	padding: 22px 24px;
}

.site-title {
	font-family: var(--display);
	font-size: 23px;
	font-weight: 700;
	letter-spacing: 0.01em;
	display: flex;
	align-items: center;
	gap: 12px;
}

.site-title .crest {
	width: 38px;
	height: 38px;
	flex: none;
	border-radius: 50%;
	border: 2px solid var(--ink);
	display: flex;
	align-items: center;
	justify-content: center;
	font-family: var(--display);
	font-weight: 700;
	font-size: 16px;
	color: var(--accent);
}

.site-title a { color: var(--ink); }
.site-title a:hover { text-decoration: none; }

.site-nav {
	font-family: var(--sans);
}

.site-nav a {
	margin-inline-start: 26px;
	color: var(--ink-soft);
	font-size: 14px;
	font-weight: 600;
	letter-spacing: 0.04em;
	text-transform: uppercase;
}

.site-nav a:hover { color: var(--accent); text-decoration: none; }

.site-nav a.lang-toggle {
	margin-inline-start: 22px;
	color: var(--panel);
	background: var(--ink);
	border-radius: 3px;
	padding: 6px 12px;
	letter-spacing: 0.08em;
}

.site-nav a.lang-toggle:hover { background: var(--accent); text-decoration: none; }

/* ---------- Breadcrumb ---------- */

.breadcrumb {
	max-width: var(--max-width);
	margin: 30px auto 0;
	padding: 0 24px;
	font-family: var(--sans);
	font-size: 13px;
	font-weight: 500;
	letter-spacing: 0.03em;
	text-transform: uppercase;
	color: var(--ink-soft);
}

.breadcrumb a { color: var(--ink-soft); }
.breadcrumb .sep { margin: 0 8px; color: var(--border-strong); }

.wide-wrap .breadcrumb,
main.wide-wrap + .breadcrumb { max-width: var(--wide-width); }

/* ---------- Layout ---------- */

.content-wrap {
	max-width: var(--max-width);
	margin: 0 auto;
	padding: 20px 24px 90px;
}

.wide-wrap {
	max-width: var(--wide-width);
	margin: 0 auto;
	padding: 20px 24px 90px;
}

h1.entry-title {
	font-family: var(--display);
	font-size: 40px;
	font-weight: 700;
	margin: 14px 0 32px;
	line-height: 1.25;
	color: var(--ink);
}

.chapter-body { font-size: 19px; }

.chapter-body p {
	margin: 0 0 1.5em;
	text-align: justify;
	hyphens: none;
}

.chapter-body > p:first-of-type::first-letter {
	font-family: var(--display);
	font-size: 3.4em;
	font-weight: 700;
	float: inline-start;
	line-height: 0.8;
	padding-inline-end: 10px;
	padding-top: 6px;
	color: var(--accent);
}

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

.hero {
	border-bottom: 1px solid var(--border);
	padding-bottom: 46px;
	margin-bottom: 10px;
}

.hero .eyebrow {
	font-family: var(--sans);
	font-size: 13px;
	font-weight: 700;
	letter-spacing: 0.12em;
	text-transform: uppercase;
	color: var(--accent);
	margin-bottom: 14px;
}

.hero h1 {
	font-family: var(--display);
	font-size: 46px;
	line-height: 1.2;
	margin: 0 0 20px;
}

.hero .lede {
	font-size: 20px;
	color: var(--ink-soft);
	max-width: 620px;
	line-height: 1.7;
}

.hero .cta {
	display: inline-block;
	margin-top: 26px;
	padding: 13px 26px;
	background: var(--accent);
	color: #fff;
	font-family: var(--sans);
	font-size: 14px;
	font-weight: 700;
	letter-spacing: 0.04em;
	text-transform: uppercase;
	border-radius: 2px;
}

.hero .cta:hover { background: var(--accent-dark); text-decoration: none; }

/* ---------- Book hero / landing ---------- */

.book-hero {
	display: flex;
	gap: 40px;
	align-items: flex-start;
	margin-bottom: 40px;
	flex-wrap: wrap;
	padding-bottom: 40px;
	border-bottom: 1px solid var(--border);
}

.book-hero .book-cover {
	width: 220px;
	flex: none;
	border: 1px solid var(--border-strong);
	box-shadow: 0 12px 30px -12px rgba(23,20,15,0.35);
	background: var(--panel);
}

.book-hero .book-cover-placeholder {
	width: 220px;
	aspect-ratio: 3 / 4.4;
	flex: none;
	background: linear-gradient(160deg, #221a14, #3a2b1f);
	color: #e9dcc4;
	display: flex;
	flex-direction: column;
	justify-content: center;
	align-items: center;
	text-align: center;
	padding: 24px;
	font-family: var(--display);
	border: 1px solid var(--ink);
	box-shadow: 0 12px 30px -12px rgba(23,20,15,0.45);
}

.book-hero .book-cover-placeholder .rule { width: 40px; height: 2px; background: var(--gold); margin: 14px 0; }
.book-hero .book-cover-placeholder .vol { font-family: var(--sans); font-size: 11px; letter-spacing: 0.2em; text-transform: uppercase; color: var(--gold); margin-top: 16px; }

.book-hero .book-desc { flex: 1; min-width: 280px; }
.book-hero .book-description { color: var(--ink-soft); font-size: 18px; }

.lang-switch {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	margin: 4px 0 22px;
	font-family: var(--sans);
	font-size: 13px;
	font-weight: 600;
	letter-spacing: 0.03em;
	padding: 7px 14px;
	border: 1px solid var(--border-strong);
	border-radius: 20px;
	background: var(--panel);
	color: var(--ink-soft);
}

.lang-switch a { color: var(--accent); }

h2.section-heading {
	font-family: var(--display);
	font-size: 15px;
	font-weight: 700;
	letter-spacing: 0.14em;
	text-transform: uppercase;
	color: var(--ink-soft);
	margin: 0 0 6px;
	padding-bottom: 14px;
	border-bottom: 2px solid var(--ink);
}

.toc-list {
	list-style: none;
	margin: 0;
	padding: 0;
}

.toc-list li { border-bottom: 1px solid var(--border); }

.toc-list a {
	display: flex;
	align-items: baseline;
	gap: 14px;
	padding: 16px 4px;
	color: var(--ink);
	font-size: 17px;
	font-family: var(--serif);
}

.toc-list a:hover { color: var(--accent); text-decoration: none; }

.toc-num {
	font-family: var(--sans);
	color: var(--gold);
	font-weight: 700;
	font-size: 13px;
	min-width: 26px;
}

/* ---------- Library grid ---------- */

.book-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
	gap: 34px;
}

.book-card {
	display: block;
	background: var(--panel);
	border: 1px solid var(--border);
	padding: 0 0 20px;
	text-align: center;
	transition: box-shadow 0.15s ease, transform 0.15s ease;
}

.book-card:hover { text-decoration: none; box-shadow: 0 16px 34px -18px rgba(23,20,15,0.35); transform: translateY(-2px); }

.book-card .cover-placeholder {
	aspect-ratio: 3 / 4.2;
	background: linear-gradient(160deg, #221a14, #3a2b1f);
	color: #e9dcc4;
	display: flex;
	flex-direction: column;
	justify-content: center;
	align-items: center;
	padding: 18px;
	font-family: var(--display);
	margin-bottom: 16px;
}

.book-card h3 { font-family: var(--display); font-size: 19px; margin: 0 10px 8px; color: var(--ink); }
.book-card .status { font-family: var(--sans); font-size: 12px; letter-spacing: 0.05em; text-transform: uppercase; color: var(--ink-soft); }

/* ---------- Chapter nav ---------- */

.chapter-nav {
	display: flex;
	justify-content: space-between;
	margin-top: 60px;
	padding-top: 26px;
	border-top: 2px solid var(--ink);
	gap: 24px;
	font-family: var(--sans);
}

.chapter-nav a {
	flex: 1;
	color: var(--ink);
	font-size: 15px;
	font-family: var(--serif);
}

.chapter-nav a:hover { color: var(--accent); text-decoration: none; }
.chapter-nav .next { text-align: end; }

.chapter-nav .label {
	display: block;
	font-family: var(--sans);
	font-size: 11px;
	color: var(--accent);
	text-transform: uppercase;
	letter-spacing: 0.1em;
	margin-bottom: 6px;
	font-weight: 700;
}

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

.site-footer {
	text-align: center;
	padding: 40px 20px;
	color: var(--ink-soft);
	font-family: var(--sans);
	font-size: 13px;
	border-top: 1px solid var(--border);
	background: var(--panel);
}

.site-footer .ornament { color: var(--gold); margin-bottom: 10px; font-size: 18px; letter-spacing: 0.4em; }
.site-footer .footer-links { margin: 8px 0 0; }
.site-footer .footer-links a { color: var(--ink-soft); }
.site-footer .footer-links .sep { margin: 0 8px; color: var(--border-strong); }

/* ---------- Chapter sub-headings, verse and dividers (Book 4) ---------- */

.chapter-body h2.sub-heading,
.chapter-body h3.sub-heading { color: var(--ink); line-height: 1.4; }
.chapter-body h2.sub-heading { font-family: var(--display); font-size: 23px; margin: 44px 0 16px; }
.chapter-body h3.sub-heading { font-family: var(--serif); font-size: 19px; font-weight: 700; margin: 30px 0 12px; }
body.lang-ar .chapter-body h2.sub-heading,
body.lang-ar .chapter-body h3.sub-heading { font-family: inherit; }
.chapter-body .verse p { margin: 0; text-align: center; }
.chapter-body .verse-en { max-width: 620px; margin: 20px auto 24px; padding: 14px 20px; background: var(--panel); border: 1px solid var(--border); border-inline-start: 3px solid var(--gold); }
.chapter-body .verse-en p { margin: 0; text-align: start; font-style: italic; line-height: 1.8; }
.chapter-body > p.lead-line { text-align: center; font-family: var(--sans); font-size: 15px; color: var(--ink-soft); margin: 0 0 0.5em; }
body.lang-ar .chapter-body > p.lead-line { font-family: inherit; font-size: 17px; }
.chapter-body > p.lead-line::first-letter { float: none; font: inherit; color: inherit; padding: 0; line-height: inherit; }
.chapter-body > p.lead-line + p:not(.lead-line) { margin-top: 1.4em; }
.chapter-body hr.text-divider { border: 0; text-align: center; margin: 36px 0; }
.chapter-body hr.text-divider::after { content: "\2726  \2726  \2726"; color: var(--gold); letter-spacing: 0.3em; }

/* ---------- About page ---------- */

.about-page .lede { font-size: 18px; color: var(--ink-soft); margin: -20px 0 28px; }
.about-portrait { max-width: 260px; margin: 0 auto 32px; text-align: center; }
.about-portrait img,
.about-figure img { display: block; width: 100%; height: auto; border: 1px solid var(--border-strong); }
.about-portrait figcaption,
.about-figure figcaption { font-family: var(--sans); font-size: 13px; color: var(--ink-soft); margin-top: 10px; text-align: center; }
.about-figure { margin: 36px 0; }
.about-intro { font-size: 20px; }
.about-quote { margin: 32px 0; padding: 18px 24px; background: var(--panel); border-inline-start: 3px solid var(--accent); }
.about-quote p { margin: 0 0 8px; font-style: italic; }
.about-quote cite { font-family: var(--sans); font-size: 13px; font-style: normal; color: var(--ink-soft); }
.about-toc { margin: 32px 0 8px; padding: 18px 22px; background: var(--panel); border: 1px solid var(--border-strong); }
.about-toc .toc-title { font-family: var(--sans); font-size: 13px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-soft); margin: 0 0 8px; }
.about-toc ol { margin: 0; padding-inline-start: 1.4em; columns: 2; column-gap: 32px; font-size: 16px; }
.about-toc li { break-inside: avoid; margin-bottom: 4px; }
.about-page h2.section-heading { margin-top: 48px; margin-bottom: 18px; scroll-margin-top: 16px; }
.about-list { padding-inline-start: 1.3em; }
.about-list li { margin-bottom: 0.5em; }
.about-sources { font-size: 16px; color: var(--ink-soft); }

.verse {
	max-width: 620px;
	margin: 20px auto 24px;
	padding: 14px 20px;
	background: var(--panel);
	border: 1px solid var(--border);
	border-inline-start: 3px solid var(--gold);
	font-family: 'Noto Naskh Arabic', 'Traditional Arabic', 'Tahoma', serif;
	font-size: 19px;
	line-height: 2;
	direction: rtl;
}
.verse p { display: flex; justify-content: space-between; gap: 2.5em; margin: 0; }
.verse span { flex: 1; text-align: center; }
.verse-translation { font-style: italic; color: var(--ink-soft); margin: -8px 0 24px; }

body.lang-ar .about-page h2.section-heading { font-family: inherit; font-size: 21px; letter-spacing: 0; text-transform: none; }
body.lang-ar .about-quote p { font-style: normal; }
body.lang-ar .about-toc .toc-title { font-family: inherit; font-size: 15px; letter-spacing: 0; text-transform: none; }

@media (max-width: 600px) {
	.about-toc ol { columns: 1; }
	.verse { padding: 12px 14px; }
	.verse p { flex-direction: column; gap: 0; margin-bottom: 8px; }
	.verse span:first-child { text-align: right; }
	.verse span:last-child { text-align: left; }
}

/* ---------- Privacy policy ---------- */

.policy .updated { font-family: var(--sans); font-size: 13px; color: var(--ink-soft); margin: -20px 0 32px; }
.policy h2.section-heading { margin-top: 40px; }
.policy ul { padding-inline-start: 1.3em; }
.policy li { margin-bottom: 0.4em; }
.policy code { font-size: 0.9em; direction: ltr; unicode-bidi: embed; }
.policy bdi { white-space: nowrap; }

/* ---------- Consent banner ---------- */

.consent-banner {
	position: fixed;
	left: 16px;
	right: 16px;
	bottom: 16px;
	z-index: 1000;
	max-width: 640px;
	margin: 0 auto;
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 12px 18px;
	padding: 16px 20px;
	background: var(--panel);
	border: 1px solid var(--border-strong);
	border-top: 3px solid var(--accent);
	box-shadow: 0 16px 34px -18px rgba(23,20,15,0.45);
	font-family: var(--sans);
	font-size: 14px;
	line-height: 1.55;
	color: var(--ink-soft);
}

.consent-banner[hidden] { display: none; }
.consent-banner p { margin: 0; flex: 1 1 300px; }
.consent-actions { display: flex; gap: 10px; }

.consent-actions button {
	font-family: var(--sans);
	font-size: 13px;
	font-weight: 600;
	letter-spacing: 0.04em;
	text-transform: uppercase;
	padding: 10px 16px;
	border-radius: 2px;
	cursor: pointer;
}

.consent-accept { background: var(--accent); color: #fff; border: 1px solid var(--accent); }
.consent-accept:hover { background: var(--accent-dark); }
.consent-decline { background: transparent; color: var(--ink); border: 1px solid var(--border-strong); }
.consent-decline:hover { border-color: var(--ink); }

body.lang-ar .consent-banner,
body.lang-ar .consent-actions button { font-family: 'Noto Naskh Arabic', 'Tahoma', sans-serif; text-transform: none; letter-spacing: 0; }

/* ---------- Photo gallery (document/photo appendices) ---------- */

.photo-gallery-heading {
	font-family: var(--display);
	font-size: 15px;
	font-weight: 700;
	letter-spacing: 0.14em;
	text-transform: uppercase;
	color: var(--ink-soft);
	margin: 60px 0 6px;
	padding-bottom: 14px;
	border-bottom: 2px solid var(--ink);
}

.photo-gallery-note {
	font-family: var(--sans);
	font-size: 14px;
	color: var(--ink-soft);
	margin: 0 0 26px;
}

.photo-gallery {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
	gap: 20px;
	list-style: none;
	margin: 0;
	padding: 0;
}

.photo-gallery li {
	background: var(--panel);
	border: 1px solid var(--border);
}

.photo-gallery img {
	width: 100%;
	height: auto;
	display: block;
}

/* ---------- Responsive ---------- */

@media (max-width: 640px) {
	h1.entry-title { font-size: 30px; }
	.hero h1 { font-size: 32px; }
	.book-hero { gap: 24px; }
	.book-hero .book-cover, .book-hero .book-cover-placeholder { width: 150px; }
}
