/* Sheikh Abdullah Hamid — memorial site. One stylesheet for RTL + LTR (logical properties). */
:root {
  --paper: #f7f3ea;
  --paper-2: #efe8d8;
  --ink: #1f2a24;
  --ink-soft: #4a554e;
  --green: #2f6b52;
  --gold: #9a7a45;
  --rule: #d9cdb3;
  --measure: 68ch;
  --font-ar: "Amiri", "Noto Naskh Arabic", "Geeza Pro", "Times New Roman", serif;
  --font-en: "EB Garamond", "Iowan Old Style", Georgia, serif;
}
/* Dark palette: follows the OS unless the visitor picks a theme with the toggle (html[data-theme]). */
:root[data-theme="dark"] {
  --paper: #141a17; --paper-2: #1b231f; --ink: #ece6d8; --ink-soft: #b9b2a3;
  --green: #8fc4a8; --gold: #cfae74; --rule: #33403a; color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #141a17; --paper-2: #1b231f; --ink: #ece6d8; --ink-soft: #b9b2a3;
    --green: #8fc4a8; --gold: #cfae74; --rule: #33403a; color-scheme: dark;
  }
}

.bar-end { display: flex; align-items: center; gap: .6rem; }
.theme-toggle { background: none; border: 1px solid var(--rule); border-radius: 999px; width: 2.1rem; height: 2.1rem; display: grid; place-items: center; cursor: pointer; color: var(--gold); padding: 0; }
.theme-toggle:hover { color: var(--green); }
.theme-toggle svg { width: 1.1rem; height: 1.1rem; }
.theme-toggle .sun { display: none; }
:root[data-theme="dark"] .theme-toggle .sun { display: block; }
:root[data-theme="dark"] .theme-toggle .moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .sun { display: block; }
  :root:not([data-theme="light"]) .theme-toggle .moon { display: none; }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 1.125rem/1.65 var(--font-en);
}
:lang(ar) body, body:lang(ar) { font-family: var(--font-ar); font-size: 1.25rem; line-height: 1.95; }
.ar { font-family: var(--font-ar); }

a { color: var(--green); text-underline-offset: .2em; }
a:hover { color: var(--gold); }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; border-radius: 2px; }

.skip { position: absolute; inset-inline-start: 1rem; top: -3rem; background: var(--green); color: var(--paper); padding: .4rem .8rem; z-index: 10; }
.skip:focus { top: 1rem; }

.wrap { max-width: var(--measure); margin-inline: auto; padding-inline: 1.25rem; }
.wide { max-width: 72rem; }

/* Top bar */
.bar { border-block-end: 1px solid var(--rule); }
.bar .wrap { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding-block: .6rem; max-width: 72rem; }
.bar nav ul { display: flex; flex-wrap: wrap; gap: .25rem 1.25rem; list-style: none; margin: 0; padding: 0; }
.bar a { text-decoration: none; color: var(--ink-soft); font-size: .95em; }
.bar a:hover, .bar a[aria-current] { color: var(--green); }
.lang { border: 1px solid var(--rule); border-radius: 999px; padding: .1rem .8rem; white-space: nowrap; }

/* Hero */
.hero { text-align: center; padding-block: clamp(3rem, 10vw, 6rem) clamp(2rem, 6vw, 3.5rem); }
.hero .rahima { color: var(--gold); font-family: var(--font-ar); font-size: 1.3rem; margin: 0; }
.hero h1 { font-family: var(--font-ar); font-weight: 700; font-size: clamp(2.4rem, 8vw, 4.2rem); line-height: 1.35; margin: .2em 0 .1em; color: var(--green); }
.hero .latin { font-family: var(--font-en); font-size: clamp(1.15rem, 3vw, 1.45rem); letter-spacing: .06em; margin: 0; color: var(--ink); }
.hero .dates { color: var(--ink-soft); margin: .8rem 0 0; font-size: 1rem; }
.hero .epithet { max-width: 46ch; margin: 1.5rem auto 0; color: var(--ink-soft); font-style: italic; }
:lang(ar) .hero .epithet { font-style: normal; }

/* Ornament divider (inline SVG via mask, so it takes currentColor) */
.orn { display: block; width: 3.25rem; height: 3.25rem; margin: 2.5rem auto; color: var(--gold); }

section { padding-block: 1rem 2.5rem; scroll-margin-top: 1rem; }
h2 { font-family: var(--font-ar); color: var(--green); font-size: clamp(1.7rem, 4.5vw, 2.2rem); font-weight: 700; margin: 0 0 1rem; text-align: center; }
h2 .sub { display: block; font-family: var(--font-en); font-size: .5em; font-weight: 400; color: var(--gold); letter-spacing: .14em; text-transform: uppercase; }
h3 { font-size: 1.15em; margin: 2rem 0 .5rem; color: var(--ink); }
p { margin: 0 0 1em; }

/* Timeline */
.timeline { list-style: none; padding: 0; margin: 1.5rem 0; border-inline-start: 2px solid var(--rule); }
.timeline li { position: relative; padding-inline-start: 1.5rem; padding-block: .35rem .9rem; }
.timeline li::before { content: ""; position: absolute; inset-inline-start: -7px; top: .85em; width: 12px; height: 12px; border-radius: 50%; background: var(--paper); border: 2px solid var(--gold); }
.timeline b { display: block; color: var(--green); font-weight: 700; font-size: .95em; }

/* Teachers */
.teachers { list-style: none; padding: 0; display: grid; gap: .75rem; }
.teachers li { background: var(--paper-2); border-radius: 6px; padding: .75rem 1rem; }
.teachers li span { display: block; color: var(--ink-soft); font-size: .9em; }

/* Books */
.books { display: grid; grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr)); gap: 2rem; margin-top: 2rem; }
.book { display: flex; flex-direction: column; gap: .9rem; }
.cover {
  aspect-ratio: 2 / 3; border-radius: 3px 6px 6px 3px; padding: 1.6rem 1.2rem; display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center;
  background: var(--green); color: #f3ead6; box-shadow: 0 1px 2px rgb(0 0 0 / .15), 0 10px 24px -12px rgb(0 0 0 / .45);
  border: 1px solid rgb(0 0 0 / .1); position: relative; font-family: var(--font-ar);
}
.cover::before { content: ""; position: absolute; inset: .6rem; border: 1px solid rgb(207 174 116 / .7); border-radius: 2px; pointer-events: none; }
.cover .t { font-size: 1.45rem; line-height: 1.7; font-weight: 700; }
.cover .a { margin-top: 1.25rem; font-size: 1rem; color: #cfae74; }
.book:nth-child(2) .cover { background: #6b2f2a; }
.book:nth-child(3) .cover { background: #24384d; }
.book h3 { margin: 0; font-family: var(--font-ar); font-size: 1.25rem; line-height: 1.6; }
.book .en-title { margin: 0; color: var(--ink-soft); font-size: .95rem; font-family: var(--font-en); font-style: italic; }
.book p { margin: 0; font-size: .95em; }
.tag { display: inline-block; font-size: .8rem; border: 1px solid var(--rule); border-radius: 999px; padding: 0 .6rem; color: var(--ink-soft); font-family: var(--font-en); }
:lang(ar) .tag { font-family: var(--font-ar); }

/* Lessons */
.subjects { display: flex; flex-wrap: wrap; justify-content: center; gap: .5rem; list-style: none; padding: 0; margin: 1.5rem 0; }
.subjects li { background: var(--paper-2); border: 1px solid var(--rule); border-radius: 999px; padding: .15rem 1rem; }
.callout { border: 1px dashed var(--gold); border-radius: 8px; padding: 1rem 1.25rem; background: var(--paper-2); }

/* Legacy */
blockquote { margin: 1.5rem 0; padding: 1rem 1.25rem; border-inline-start: 3px solid var(--gold); background: var(--paper-2); border-radius: 0 6px 6px 0; }
:dir(rtl) blockquote, [dir="rtl"] blockquote { border-radius: 6px 0 0 6px; }
blockquote p:last-child { margin: 0; }
blockquote footer { color: var(--ink-soft); font-size: .9em; margin-top: .5rem; }
.traits { padding-inline-start: 1.2rem; }
.traits li { margin-block: .35rem; }

.dua { text-align: center; font-family: var(--font-ar); font-size: 1.35rem; line-height: 2; color: var(--green); max-width: 40ch; margin: 2rem auto 0; }

/* Footer */
.site-foot { border-block-start: 1px solid var(--rule); margin-top: 2rem; padding-block: 2rem 3rem; color: var(--ink-soft); font-size: .92rem; text-align: center; }
.site-foot p { margin: .3rem 0; }

@media (max-width: 40rem) {
  .bar .wrap { flex-wrap: wrap; justify-content: center; }
  .bar nav ul { justify-content: center; }
}
@media print {
  .bar, .skip, .orn { display: none; }
  body { background: #fff; color: #000; }
}

/* Obituary video (click-to-load facade) */
.video { aspect-ratio: 16 / 9; border-radius: 8px; overflow: hidden; background: var(--green); margin-top: 1.5rem; }
.video iframe, .video-play { width: 100%; height: 100%; border: 0; display: block; }
.video-play { cursor: pointer; position: relative; padding: 0; background: #15382a; }
.video-play img { width: 100%; height: 100%; object-fit: cover; display: block; }
.video-play .play { position: absolute; inset: 50% auto auto 50%; transform: translate(-50%, -50%); width: 4.25rem; height: 4.25rem; border-radius: 50%; background: rgb(29 77 58 / .9); box-shadow: 0 4px 18px rgb(0 0 0 / .35); }
.video-play .play::after { content: ""; position: absolute; inset: 50% auto auto 54%; transform: translate(-50%, -50%); border-block: .7rem solid transparent; border-left: 1.1rem solid #f3ead6; }
.video-play:hover .play { background: #9a7a45; }
.hero-cta { margin: 1.25rem 0 0; }
.hero-cta a { display: inline-block; border: 1px solid var(--gold); color: var(--green); border-radius: 999px; padding: .2rem 1.1rem; text-decoration: none; font-size: 1rem; }
.hero-cta a:hover { background: var(--green); color: var(--paper); }
.video-link { text-align: center; margin-top: .75rem; font-size: .95em; }

/* ── Ornaments (Wikimedia Commons SVGs, see footer credits), tinted with the theme gold via masks ── */
:root { --orn-opacity: .3; --pattern: url("/assets/orn/Islamic_geometric_pattern.svg"); }
:root[data-theme="dark"] { --orn-opacity: .24; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --orn-opacity: .24; } }

/* Divider: crescent flanked by fading gold rules */
.orn { width: min(22rem, 80%); height: 3.25rem; overflow: visible;
  background: linear-gradient(to right, transparent, var(--gold) 30%, transparent 42%, transparent 58%, var(--gold) 70%, transparent) center / 100% 1px no-repeat; }

/* Inna lillahi calligraphy above the obituary */
.inna { display: block; width: min(26rem, 90%); aspect-ratio: 871 / 202; margin: 0 auto 1.5rem; background: var(--gold);
  -webkit-mask: url("/assets/orn/Inna_lillahi_wa_inna_ilayhi_rajiun.svg") center / contain no-repeat;
  mask: url("/assets/orn/Inna_lillahi_wa_inna_ilayhi_rajiun.svg") center / contain no-repeat; }

/* Mosque skyline above the footer (all screens; ~6 KB) */
.skyline { display: flex; justify-content: center; align-items: flex-end; gap: clamp(1rem, 6vw, 5rem); margin-top: 3rem; height: 5rem; opacity: .85; }
.skyline span { display: block; height: 100%; aspect-ratio: 487 / 220; background: var(--gold);
  -webkit-mask: url("/assets/orn/Mosque02.svg") bottom / contain no-repeat; mask: url("/assets/orn/Mosque02.svg") bottom / contain no-repeat; }
.skyline span:nth-child(2) { height: 140%; aspect-ratio: 506 / 236; -webkit-mask-image: url("/assets/orn/Mosque_x2.svg"); mask-image: url("/assets/orn/Mosque_x2.svg"); }
.site-foot { margin-top: 0; }

/* Wide screens only (the pattern file is ~115 KB gzipped, so phones never download it) */
@media (min-width: 64rem) {
  body::before, body::after {
    content: ""; position: fixed; top: 0; bottom: 0; z-index: -1; pointer-events: none;
    width: calc((100vw - 52rem) / 2);
    background: var(--gold); opacity: var(--orn-opacity);
    -webkit-mask: var(--pattern) 0 0 / 420px auto, linear-gradient(var(--fade-dir), #000 15%, transparent 95%);
    -webkit-mask-composite: source-in;
    mask: var(--pattern) 0 0 / 420px auto, linear-gradient(var(--fade-dir), #000 15%, transparent 95%);
    mask-composite: intersect;
  }
  body::before { left: 0; --fade-dir: to right; }
  body::after { right: 0; --fade-dir: to left; }
  /* Minarets standing at the foot of each margin */
  .bar::before, .bar::after {
    content: ""; position: fixed; bottom: 0; z-index: -1; pointer-events: none; opacity: .7;
    width: min(18vw, 16rem); aspect-ratio: 506 / 236; background: var(--gold);
    -webkit-mask: url("/assets/orn/Mosque_x2.svg") bottom / contain no-repeat; mask: url("/assets/orn/Mosque_x2.svg") bottom / contain no-repeat;
  }
  .bar::before { left: 2vw; }
  .bar::after { right: 2vw; -webkit-mask-image: url("/assets/orn/Mosque02.svg"); mask-image: url("/assets/orn/Mosque02.svg"); }
  .cover::after { content: ""; position: absolute; inset: 1rem; pointer-events: none; background: #cfae74; opacity: .3;
    -webkit-mask: var(--pattern) center / 260px auto; mask: var(--pattern) center / 260px auto; }
}
@media print { body::before, body::after, .bar::before, .bar::after, .skyline { display: none; } }
