/* Bayt Al-Hikmah — small, simple, flexible. Tweak the palette in :root. */

:root {
  --bg: #fafafa;
  --fg: #222;
  --muted: #6b6b6b;
  --line: #e7e5e5;
  --card: #ffffff;
  --accent: #2f6b87;
  --g0: #2b5a72; --g1: #3f7d8f; --g2: #9db9ad;
  --codebg: #f0efef;
  --prebg: #111; --prefg: #e8e8e8;
}
html[data-theme="dark"] {
  --bg: #141517; --fg: #eaeaea; --muted: #9a9a9a; --line: #2c2c2c; --card: #1b1c1f;
  --accent: #8db4c7;
  --g0: #1e3743; --g1: #2c4d57; --g2: #6f8f85;
  --codebg: #26272b; --prebg: #0b0c0d; --prefg: #d8d8d8;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 64px; }
body {
  font-family: "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, Helvetica, Arial, sans-serif;
  color: var(--fg); background: var(--bg); line-height: 1.55;
  -webkit-font-smoothing: antialiased; font-size: 17px;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
img, video { max-width: 100%; height: auto; border-radius: 10px; }

/* ── top utility bar ── */
.topbar { position: sticky; top: 0; z-index: 50; background: color-mix(in srgb, var(--bg) 86%, transparent); backdrop-filter: saturate(1.4) blur(12px); border-bottom: 1px solid var(--line); }
.topbar-inner { max-width: 760px; margin: 0 auto; display: flex; align-items: center; gap: 10px; padding: 9px clamp(14px, 4vw, 20px); }
.tb-home, .tb-theme { display: grid; place-items: center; width: 34px; height: 34px; border: 1px solid var(--line); border-radius: 9px; background: transparent; color: var(--fg); cursor: pointer; flex: 0 0 auto; }
.tb-home:hover, .tb-theme:hover { border-color: var(--accent); color: var(--accent); }
.tb-about { display: inline-flex; align-items: center; padding: 0 6px; font-size: 14px; color: var(--muted); white-space: nowrap; }
.tb-about:hover { color: var(--accent); text-decoration: none; }
.tb-theme .ic-moon { display: none; }
html[data-theme="dark"] .tb-theme .ic-sun { display: none; }
html[data-theme="dark"] .tb-theme .ic-moon { display: block; }
.tb-search { position: relative; flex: 1 1 auto; }
.tb-search input { width: 100%; border: 1px solid var(--line); background: var(--card); color: var(--fg); border-radius: 9px; padding: 7px 12px; font-size: 14.5px; }
.tb-search input:focus { outline: none; border-color: var(--accent); }
.sresults { position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: 60; background: var(--card); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 10px 30px rgba(0,0,0,.12); overflow: hidden; }
.sresults a.s-item { display: block; padding: 10px 14px; border-bottom: 1px solid var(--line); color: var(--fg); }
.sresults a.s-item:last-child { border-bottom: 0; }
.sresults a.s-item:hover { background: var(--line); text-decoration: none; }
.sresults a.s-item b { font-weight: 600; }
.sresults a.s-item span { display: block; color: var(--muted); font-size: 13px; }
.sresults .s-empty { padding: 12px 14px; color: var(--muted); font-size: 14px; }

/* ── banner (reusable) — gradient, or image with overlay + bottom fade ── */
.banner {
  --pad: clamp(30px, 6vw, 72px);
  padding: var(--pad) clamp(20px, 6vw, 28px) calc(var(--pad) + 24px);
  color: #fff; position: relative; overflow: hidden;
  background: radial-gradient(120% 120% at 80% -10%, rgba(255,255,255,.16) 0%, transparent 55%),
             linear-gradient(160deg, var(--g0) 0%, var(--g1) 55%, var(--g2) 100%);
  -webkit-mask-image: linear-gradient(to bottom, #000 86%, transparent 100%);
          mask-image: linear-gradient(to bottom, #000 86%, transparent 100%);
}
.banner .banner-wrap { max-width: 700px; margin: 0 auto; }
.banner h1 { font-size: clamp(26px, 5vw, 42px); font-weight: 600; letter-spacing: -.015em; line-height: 1.1; }
.banner p { margin-top: 10px; max-width: 46ch; opacity: .92; font-size: 16px; color: #fff; }
.banner.img { -webkit-mask-image: none; mask-image: none; background-size: cover; background-position: center; background-color: var(--g0); min-height: 300px; display: flex; align-items: center; image-rendering: pixelated; }
.banner.img::before { content: ""; position: absolute; inset: 0; background: linear-gradient(160deg, rgba(0,0,0,.5), rgba(0,0,0,.22)); }
.banner.img::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 70px; background: linear-gradient(to bottom, transparent, var(--bg)); }
.banner.img .banner-wrap { position: relative; text-align: center; margin: 0 auto; }
.banner.img .banner-wrap h1 { font-size: clamp(30px, 6vw, 50px); }
.banner.img .banner-wrap p { margin: 12px auto 0; max-width: 52ch; }

/* ── main column ── */
main { max-width: 700px; margin: 0 auto; padding: 34px clamp(20px, 6vw, 28px) 90px; }
.about .intro { font-size: 18.5px; }
.h-rule { margin: 44px 0 14px; font-size: 12.5px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
main > .topic:first-of-type .h-rule, .about + .topic .h-rule { margin-top: 38px; }

/* quote */
.quote { margin: 26px 0 0; padding: 4px 0 4px 18px; border-left: 3px solid var(--g2); }
.quote blockquote { font-size: 17px; font-style: italic; color: var(--fg); border-left: 0; padding-left: 0; margin: 0; }
.quote figcaption { color: var(--muted); font-size: 14px; margin-top: 8px; }

/* note lists */
ul.plain { list-style: none; }
ul.plain li { padding: 12px 0; border-bottom: 1px solid var(--line); }
ul.plain a { font-weight: 500; color: var(--fg); }
ul.plain a:hover { color: var(--accent); text-decoration: none; }
ul.plain small { display: block; color: var(--muted); font-weight: 400; margin-top: 2px; line-height: 1.5; }

/* ── note article ── */
article .meta { color: var(--muted); font-size: 13.5px; margin-bottom: 6px; }
article h1 { font-size: clamp(26px, 5vw, 38px); margin-bottom: 10px; font-weight: 600; line-height: 1.15; letter-spacing: -.01em; }
article h2 { font-size: 22px; font-weight: 600; margin: 34px 0 12px; }
article h3 { font-size: 18px; font-weight: 600; margin: 24px 0 8px; }
article p { margin: 14px 0; }
article ul, article ol { margin: 12px 0 12px 24px; }
article li { margin: 4px 0; }
article code { background: var(--codebg); padding: 2px 6px; border-radius: 5px; font-size: .9em; font-family: "Cascadia Code", Consolas, monospace; }
article pre { background: var(--prebg); color: var(--prefg); padding: 16px; border-radius: 10px; overflow-x: auto; margin: 16px 0; line-height: 1.5; }
article pre code { background: none; padding: 0; color: inherit; }
article table { border-collapse: collapse; width: 100%; margin: 16px 0; font-size: 15px; }
article th, article td { border: 1px solid var(--line); padding: 8px 10px; text-align: left; vertical-align: top; }
article blockquote { border-left: 3px solid var(--g2); padding-left: 16px; color: var(--muted); font-style: italic; margin: 18px 0; }
article hr { border: 0; border-top: 1px solid var(--line); margin: 30px 0; }

/* wiki links */
a.wnote { color: var(--accent); border-bottom: 1px dotted var(--accent); }
a.wnote:hover { text-decoration: none; border-bottom-style: solid; }
.wpending { color: var(--muted); border-bottom: 1px dashed var(--line); }

/* callouts (Obsidian  > [!NOTE]  etc.) — auto-formatted, colored per type */
.callout { border: 1px solid var(--line); border-left: 3px solid #6f9fc4; border-radius: 10px; padding: 12px 16px; margin: 18px 0; background: color-mix(in srgb, var(--bg) 55%, var(--line)); font-size: 15.5px; }
.callout .ct-hd { display: flex; align-items: center; gap: 7px; margin-bottom: 6px; }
.callout .ct-hd svg { color: var(--muted); flex: 0 0 auto; }
.callout .ct-label { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.callout.tip { border-left-color: #4caf7d; }
.callout.info { border-left-color: #6f9fc4; }
.callout.warning, .callout.important { border-left-color: #e0a03e; }
.callout.danger { border-left-color: #d96b6b; }
.callout.note .ct-hd svg { color: #6f9fc4; }
.callout.info .ct-hd svg { color: #3f9fd0; }
.callout.tip .ct-hd svg { color: #4caf7d; }
.callout.warning .ct-hd svg, .callout.important .ct-hd svg { color: #e0a03e; }
.callout.danger .ct-hd svg { color: #d96b6b; }
.callout .ct-body { margin-top: 4px; }

/* sources / footnotes */
.sources-h { font-size: 15px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin-top: 46px; }
ol.refs { font-size: 14.5px; color: var(--muted); margin: 12px 0 0 20px; }
ol.refs li { margin: 8px 0; }
ol.refs a { color: var(--accent); word-break: break-word; }
sup.ref a { color: var(--accent); font-size: 12px; margin-left: 1px; }

/* back link */
.back { margin-top: 42px; font-size: 15px; }

/* ── footer ── */
footer { border-top: 1px solid var(--line); max-width: 700px; margin: 0 auto; padding: 24px clamp(20px, 6vw, 28px) 40px; display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; }
footer .f-social { display: flex; gap: 8px; }
footer .si { display: grid; place-items: center; width: 26px; height: 26px; border: 1px solid var(--line); border-radius: 8px; color: var(--muted); }
footer .si svg { width: 15px; height: 15px; }
footer .si:hover { color: var(--accent); border-color: var(--accent); }
footer .f-line { display: flex; align-items: center; gap: 7px; font-size: 13px; color: var(--muted); }
footer .f-name { font-weight: 500; color: var(--muted); }
footer .f-name:hover { color: var(--accent); text-decoration: none; }
footer .f-dot { color: var(--muted); }

/* heading anchors (chain icon on hover) */
.h-anchor { opacity: 0; margin-left: 6px; color: var(--muted); vertical-align: middle; display: inline-block; transition: opacity .12s; }
article h2:hover .h-anchor, article h3:hover .h-anchor { opacity: 1; }

/* table of contents */
.toc { margin: 0 0 24px; }
.toc details { border: 1px solid var(--line); border-radius: 10px; background: var(--card); }
.toc summary { cursor: pointer; padding: 9px 14px; font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); user-select: none; list-style: none; }
.toc summary::-webkit-details-marker { display: none; }
.toc summary::after { content: "▾"; margin-left: 8px; font-size: 10px; }
.toc details[open] summary::after { content: "▴"; }
.toc ol { list-style: none; margin: 0; padding: 0 0 10px; }
.toc li a { display: block; padding: 5px 14px 5px 22px; color: var(--fg); font-size: 14.5px; border-top: 1px solid var(--line); }
.toc li[data-h="h3"] a { padding-left: 36px; font-size: 14px; color: var(--muted); }
.toc li a:hover { background: var(--line); color: var(--accent); text-decoration: none; }

/* tags + related */
.tags { margin-top: 34px; display: flex; flex-wrap: wrap; gap: 8px; }
.tagchip { border: 1px solid var(--line); border-radius: 999px; padding: 5px 12px; font-size: 13px; color: var(--muted); }
.tagchip:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }
.related { margin-top: 8px; }
.related .h-rule { margin-top: 40px; }

/* clearer separation: note title vs sub-headings */
article h1 { padding-bottom: 14px; border-bottom: 1px solid var(--line); margin-bottom: 16px; }
article h2, article h3 { scroll-margin-top: 64px; } /* don't hide behind the sticky top bar when jumped to */
.tag-h { font-size: clamp(26px, 5vw, 38px); font-weight: 600; letter-spacing: -.01em; padding-bottom: 14px; border-bottom: 1px solid var(--line); margin-bottom: 6px; }

/* description "lead" snippet shown under a note title when frontmatter has `description` */
article .lead { font-size: 18px; color: var(--muted); margin: 4px 0 22px; line-height: 1.55; }

/* about page */
.about-photo { width: 96px; height: 96px; object-fit: cover; border-radius: 50%; margin: 2px 0 20px; border: 1px solid var(--line); }
.job { margin: 22px 0; }
.job .job-h { font-size: 18px; font-weight: 600; border-bottom: 0; padding-bottom: 0; margin-bottom: 4px; }
.job .co { color: var(--muted); font-weight: 500; }
.job .period { color: var(--muted); font-size: 14px; margin: 0 0 8px; }
.job ul { margin-left: 22px; }

/* notable-work repo cards (About) */
.repos { display: grid; gap: 10px; margin-top: 6px; }
.repo { display: block; padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; color: var(--fg); }
.repo:hover { border-color: var(--accent); text-decoration: none; }
.repo b { font-weight: 600; }
.repo span { display: block; color: var(--muted); font-size: 14px; margin-top: 2px; line-height: 1.5; }
.repo small { color: var(--muted); font-size: 12.5px; margin-top: 6px; display: block; }

/* ── hover preview popover ── */
#popover { position: fixed; z-index: 90; width: 280px; background: var(--card); color: var(--fg); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 14px 40px rgba(0,0,0,.16); padding: 14px 16px; }
#popover .p-title { font-weight: 600; font-size: 15px; }
#popover .p-topic { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .06em; margin: 2px 0 8px; }
#popover .p-text { font-size: 13.5px; line-height: 1.55; color: var(--fg); opacity: .9; display: -webkit-box; -webkit-line-clamp: 5; -webkit-box-orient: vertical; overflow: hidden; }
#popover .p-go { margin-top: 10px; font-size: 13px; color: var(--accent); }

@media (max-width: 480px) {
  #popover { width: 92vw; left: 4vw !important; }
}

/* ── mermaid diagrams ── */
.mermaid {
  text-align: center;
  margin: 1.4rem auto;
  overflow-x: auto;
  padding: 6px 0;
  scrollbar-width: thin;
}
.mermaid svg {
  max-width: 100%;
  height: auto;
  min-width: 420px;
  margin: 0 auto;
  display: block;
}
html[data-theme="dark"] .mermaid {
  background: rgba(255,255,255,.03);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
}

/* ── copy button on code blocks ── */
.copy-btn {
  position: absolute; top: 7px; right: 7px; z-index: 5;
  font-family: inherit; font-size: 11px; padding: 3px 10px; border-radius: 6px;
  border: 1px solid rgba(255,255,255,.22); background: rgba(255,255,255,.92); color: #222;
  cursor: pointer; opacity: 0; transition: opacity .12s;
}
pre:hover .copy-btn, .copy-btn:focus-visible { opacity: 1; }
.copy-btn:hover { background: #fff; }

/* ── lightbox (larger view) ── */
#lightbox {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(0,0,0,.82);
  display: flex; overflow: auto;
  padding: 5vh 3vw; overflow: auto;
}
#lightbox[hidden] { display: none; }
#lightbox .lb-frame { margin: auto; max-width: 100%; }
.lb-img { max-width: 100%; max-height: 90vh; border-radius: 8px; box-shadow: 0 10px 60px rgba(0,0,0,.5); }
.lb-mermaid { max-width: none; }
.lb-mermaid svg { min-width: 0; height: auto; background: #fff; border-radius: 8px; }
.lb-close {
  position: fixed; top: 16px; right: 20px; z-index: 210;
  font-size: 22px; line-height: 1; width: 40px; height: 40px; border-radius: 50%;
  border: none; background: rgba(255,255,255,.15); color: #fff; cursor: pointer;
}
.lb-close:hover { background: rgba(255,255,255,.32); }
.more { margin-top: 30px; }
.more a { color: var(--accent); text-decoration: none; font-weight: 500; }
.more a:hover { text-decoration: underline; }
