/* =========================================================
   TechBridge v2 — قالب أبيض متجاوب (RTL)
   ========================================================= */
:root {
  --bg: #FFFFFF;
  --surface: #F5F7FA;
  --ink: #141B2D;
  --text: #2E3648;
  --muted: #6A7286;
  --line: #E5E8EE;
  --brand: #0B63CE;
  --brand-dark: #084C9E;
  --brand-soft: #EAF2FD;
  --amber: #B7791F;
  --amber-soft: #FFF6E5;
  --code-bg: #0F172A;

  --font: "IBM Plex Sans Arabic", "Segoe UI", Tahoma, system-ui, sans-serif;
  --mono: ui-monospace, "Cascadia Code", Consolas, monospace;

  --container: 1200px;
  --side: 320px;
  --radius: 10px;
  --hdr-h: 68px;
}

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.8;
  text-rendering: optimizeLegibility;
}

img { max-width: 100%; height: auto; display: block; }
a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--brand-dark); }
:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; border-radius: 4px; }
h1, h2, h3, h4 { color: var(--ink); line-height: 1.45; font-weight: 700; margin: 0; }
button { font: inherit; }

.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; inset-inline-start: -9999px; top: 0; }
.skip:focus { inset-inline-start: 1rem; top: 1rem; z-index: 100; background: var(--bg); padding: .5rem 1rem; border: 1px solid var(--line); }
.muted { color: var(--muted); }

.container { max-width: var(--container); margin-inline: auto; padding-inline: 1.25rem; }

/* ---------------- Header ---------------- */
.hdr {
  position: sticky; top: 0; z-index: 50;
  background: rgba(255, 255, 255, .96);
  backdrop-filter: saturate(180%) blur(8px);
  border-bottom: 1px solid var(--line);
}
.hdr-row { display: flex; align-items: center; gap: 1.5rem; height: var(--hdr-h); }

.logo { display: inline-flex; align-items: center; gap: .55rem; color: var(--ink); font-weight: 700; font-size: 1.25rem; direction: ltr; flex-shrink: 0; }
.logo:hover { color: var(--ink); }
.logo img { height: 40px; width: auto; }

.nav { flex: 1; min-width: 0; }
.nav-list { list-style: none; display: flex; align-items: center; gap: .25rem; margin: 0; padding: 0; }
.nav-item { position: relative; }
.nav-link {
  display: inline-flex; align-items: center; gap: .25rem;
  padding: .5rem .75rem; border-radius: 8px;
  color: var(--text); font-weight: 500; font-size: .97rem; white-space: nowrap;
  background: none; border: 0; cursor: pointer;
}
.nav-link:hover, .nav-item:focus-within > .nav-link { background: var(--surface); color: var(--ink); }
.nav-link[aria-current] { color: var(--brand); }
.nav-link .ic { transition: transform .15s; }

.sub {
  list-style: none; margin: 0; padding: .4rem;
  position: absolute; top: 100%; inset-inline-start: 0; min-width: 220px;
  background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 12px 32px rgba(20, 27, 45, .12);
  opacity: 0; visibility: hidden; transform: translateY(4px);
  transition: opacity .15s, transform .15s, visibility .15s;
}
.has-sub:hover > .sub, .has-sub:focus-within > .sub { opacity: 1; visibility: visible; transform: none; }
.has-sub:hover > .nav-link .ic, .has-sub:focus-within > .nav-link .ic { transform: rotate(180deg); }
.sub a { display: block; padding: .5rem .75rem; border-radius: 6px; color: var(--text); font-size: .93rem; }
.sub a:hover { background: var(--brand-soft); color: var(--brand); }

.hdr-search { display: flex; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding-inline: 1rem .3rem; flex-shrink: 0; }
.hdr-search:focus-within { border-color: var(--brand); background: var(--bg); }
.hdr-search input { border: 0; background: transparent; outline: none; font: inherit; font-size: .9rem; color: var(--ink); width: 12rem; padding: .45rem 0; }
.hdr-search button { border: 0; background: none; color: var(--muted); padding: .4rem; cursor: pointer; display: grid; }

.icon-btn { display: none; place-items: center; width: 42px; height: 42px; border: 0; border-radius: 8px; background: none; color: var(--ink); cursor: pointer; }
.icon-btn:hover { background: var(--surface); }

@media (max-width: 1080px) {
  .nav, .hdr-search { display: none; }
  .icon-btn { display: grid; }
  .hdr-row { gap: .5rem; justify-content: space-between; }
  .logo { margin-inline: auto; }
}

/* ---------------- Drawer (موبايل) ---------------- */
.drawer { position: fixed; inset: 0; z-index: 90; background: rgba(15, 23, 42, .45); }
.drawer[hidden] { display: none; }
.drawer-panel {
  position: absolute; inset-block: 0; inset-inline-start: 0;
  width: min(86vw, 340px); background: var(--bg); overflow-y: auto;
  padding: 1rem 1.1rem 2rem; box-shadow: 0 0 40px rgba(0, 0, 0, .2);
}
.drawer-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem; }
.drawer-head .icon-btn { display: grid; }
.drawer-title { font-weight: 700; color: var(--ink); direction: ltr; }
.drawer-search { display: flex; border: 1px solid var(--line); border-radius: 8px; margin-bottom: 1rem; }
.drawer-search input { flex: 1; border: 0; background: none; font: inherit; padding: .55rem .8rem; outline: none; min-width: 0; }
.drawer-search button { border: 0; background: none; padding: 0 .75rem; color: var(--muted); }
.drawer-list, .drawer-list ul { list-style: none; margin: 0; padding: 0; }
.drawer-list > li { border-bottom: 1px solid var(--line); }
.drawer-list a { display: flex; align-items: center; justify-content: space-between; padding: .7rem .25rem; color: var(--ink); font-weight: 500; }
.drawer-list ul { padding-inline-start: 1rem; padding-bottom: .4rem; }
.drawer-list ul a { font-weight: 400; color: var(--text); padding-block: .4rem; font-size: .93rem; }
.count { color: var(--muted); font-size: .8rem; font-weight: 400; }

/* ---------------- Layout ---------------- */
.layout { display: grid; grid-template-columns: minmax(0, 1fr) var(--side); gap: 2.5rem; align-items: start; padding-block: 1.5rem 2rem; }
.main { min-width: 0; }
@media (max-width: 980px) { .layout { grid-template-columns: 1fr; gap: 1.5rem; } }

.crumbs ol { list-style: none; display: flex; flex-wrap: wrap; gap: .35rem; margin: 0; padding: 1rem 0 0; font-size: .85rem; color: var(--muted); }
.crumbs li + li::before { content: "/"; margin-inline-end: .35rem; color: #B5BBC8; }
.crumbs a { color: var(--muted); }
.crumbs a:hover { color: var(--brand); }

.page-head { padding: 1.25rem 0 0; }
.page-head h1 { font-size: clamp(1.6rem, 3.5vw, 2.1rem); }
.page-head p { margin: .35rem 0 0; color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: 1rem; }
.chips a { padding: .3rem .9rem; border: 1px solid var(--line); border-radius: 999px; font-size: .88rem; color: var(--text); }
.chips a:hover { border-color: var(--brand); color: var(--brand); }

/* ---------------- Hero ---------------- */
.hero { display: grid; grid-template-columns: 1.35fr 1fr; gap: 1.5rem; padding-top: 1.5rem; }
.hero-side { display: grid; gap: 1rem; align-content: start; }
@media (max-width: 900px) { .hero { grid-template-columns: 1fr; } }

.card-hero { position: relative; border-radius: var(--radius); overflow: hidden; background: var(--ink); min-height: 100%; }
.card-hero-img, .card-hero-img img, .card-hero-img .ph { display: block; width: 100%; height: 100%; aspect-ratio: 16 / 10; object-fit: cover; }
.card-hero-body {
  position: absolute; inset: auto 0 0 0; padding: 1.5rem;
  background: linear-gradient(to top, rgba(10, 15, 30, .92) 0%, rgba(10, 15, 30, .55) 60%, transparent 100%);
}
.card-hero-title { font-size: clamp(1.3rem, 2.6vw, 1.85rem); margin: .55rem 0 .4rem; }
.card-hero-title a { color: #fff; }
.card-hero-title a:hover { text-decoration: underline; text-underline-offset: .2em; }
.card-hero .card-ex { color: rgba(255, 255, 255, .85); margin: 0 0 .4rem; font-size: .95rem; }
.card-hero .card-meta { color: rgba(255, 255, 255, .75); }
.card-hero .chip { background: var(--brand); color: #fff; }
@media (max-width: 560px) {
  .card-hero-body { position: static; background: var(--ink); }
  .card-hero .card-ex { display: none; }
}

/* ---------------- Cards ---------------- */
.chip { display: inline-block; font-size: .78rem; font-weight: 500; color: var(--brand); background: var(--brand-soft); padding: .1rem .6rem; border-radius: 6px; }
.chip:hover { background: var(--brand); color: #fff; }
.card-title { font-size: 1.05rem; margin: .45rem 0 .3rem; }
.card-title a { color: var(--ink); }
.card-title a:hover { color: var(--brand); }
.card-meta { display: flex; flex-wrap: wrap; gap: .25rem .9rem; font-size: .8rem; color: var(--muted); }
.card-ex { color: var(--muted); font-size: .93rem; margin: 0 0 .45rem; }
.card-img { display: block; align-self: start; border-radius: 8px; overflow: hidden; background: var(--surface); }
.card-img img, .ph { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; transition: transform .3s; }
.ph { display: grid; place-items: center; color: var(--ink); background: var(--brand-soft); }
.card-img:hover img { transform: scale(1.03); }

.card .card-img { margin-bottom: .65rem; }

.card-h { display: grid; grid-template-columns: 132px 1fr; gap: .9rem; align-items: start; }
.card-h .card-title { font-size: .98rem; margin-top: .3rem; }

.card-row { display: grid; grid-template-columns: 260px 1fr; gap: 1.25rem; padding-block: 1.25rem; border-bottom: 1px solid var(--line); }
.card-row:first-child { padding-top: 0; }
.card-row .card-title { font-size: 1.2rem; }
@media (max-width: 640px) {
  .card-row { grid-template-columns: 120px 1fr; gap: .9rem; padding-block: 1rem; }
  .card-row .card-title { font-size: 1rem; }
  .card-row .card-ex { display: none; }
}

.grid { display: grid; gap: 1.5rem 1.25rem; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 900px) { .grid-4 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 520px) { .grid-2, .grid-4 { grid-template-columns: 1fr; } }

/* ---------------- Blocks ---------------- */
.block + .block { margin-top: 2.5rem; }
.block-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1.25rem; padding-bottom: .65rem; border-bottom: 2px solid var(--line); position: relative; }
.block-head::after { content: ""; position: absolute; bottom: -2px; inset-inline-start: 0; width: 56px; height: 2px; background: var(--brand); }
.block-head h2 { font-size: 1.25rem; }
.block-head h2 a { color: var(--ink); }
.block-head h2 a:hover { color: var(--brand); }
.more { font-size: .88rem; font-weight: 500; white-space: nowrap; }
.related { padding-bottom: 2rem; }

/* ---------------- Sidebar ---------------- */
.side { display: grid; gap: 1.5rem; position: sticky; top: calc(var(--hdr-h) + 1rem); }
@media (max-width: 980px) { .side { position: static; } }
.widget { border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem 1.2rem; }
.widget-title { font-size: 1.02rem; margin-bottom: .9rem; padding-bottom: .55rem; border-bottom: 1px solid var(--line); }

.pop-list { list-style: none; counter-reset: pop; margin: 0; padding: 0; display: grid; gap: .9rem; }
.pop-list li { counter-increment: pop; }
.pop-list a { display: grid; grid-template-columns: auto 72px 1fr; gap: .7rem; align-items: center; color: var(--ink); font-size: .92rem; font-weight: 500; line-height: 1.6; }
.pop-list a::before { content: counter(pop); width: 1.6rem; height: 1.6rem; display: grid; place-items: center; border-radius: 50%; background: var(--surface); color: var(--brand); font-size: .8rem; font-weight: 700; }
.pop-list a:hover { color: var(--brand); }
.pop-list img { width: 72px; height: 50px; object-fit: cover; border-radius: 6px; }
.pop-list a:not(:has(img)) { grid-template-columns: auto 1fr; }

.cat-list, .cat-list ul { list-style: none; margin: 0; padding: 0; }
.cat-list a { display: flex; align-items: center; justify-content: space-between; padding: .45rem 0; color: var(--text); font-size: .93rem; border-bottom: 1px dashed var(--line); }
.cat-list a:hover { color: var(--brand); }
.cat-list ul { padding-inline-start: 1rem; }
.cat-list ul a { font-size: .87rem; }
.cat-list > li:last-child > a:last-child { border-bottom: 0; }

.tag-cloud { display: flex; flex-wrap: wrap; gap: .4rem; }
.tag-cloud a { font-size: .82rem; color: var(--text); background: var(--surface); padding: .2rem .7rem; border-radius: 6px; }
.tag-cloud a:hover { background: var(--brand); color: #fff; }

/* ---------------- Article ---------------- */
.post-head { margin-bottom: 1.25rem; }
.post-head h1 { font-size: clamp(1.65rem, 4vw, 2.35rem); margin: .7rem 0 .8rem; letter-spacing: -.005em; }
.post-meta { display: flex; flex-wrap: wrap; gap: .3rem 1.1rem; font-size: .87rem; color: var(--muted); }
.post-meta span { display: inline-flex; align-items: center; gap: .3rem; }
.post-cover { margin: 0 0 1.5rem; }
.post-cover img { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; border-radius: var(--radius); }
.post-intro { font-size: 1.12rem; }
.admin-note { background: var(--amber-soft); border-radius: 8px; padding: .6rem 1rem; font-size: .9rem; }

.prose { font-size: 1.07rem; line-height: 2; color: var(--text); }
.prose p { margin: 0 0 1.15em; }
.prose a { text-decoration: underline; text-underline-offset: .2em; }
.prose ul, .prose ol { padding-inline-start: 1.5rem; margin: 0 0 1.15em; }
.prose li { margin-bottom: .4em; }
.prose li::marker { color: var(--brand); }
.prose h3 { font-size: 1.2rem; margin: 1.6em 0 .6em; }
.prose h4 { font-size: 1.05rem; margin: 1.4em 0 .5em; }
.prose strong { color: var(--ink); }
.prose code, .prose kbd { font-family: var(--mono); font-size: .85em; padding: .12em .4em; border-radius: 5px; direction: ltr; unicode-bidi: isolate; }
.prose code { background: var(--amber-soft); color: #7A4A0A; }
.prose kbd { background: var(--bg); border: 1px solid var(--line); border-bottom-width: 3px; color: var(--ink); }
.prose pre { direction: ltr; text-align: left; background: var(--code-bg); color: #E2E8F0; padding: 1rem 1.25rem; border-radius: 8px; overflow-x: auto; font-size: .9rem; line-height: 1.65; margin: 0 0 1.25em; }
.prose pre code { background: none; color: inherit; padding: 0; font-size: inherit; }
.prose blockquote { margin: 1.5em 0; padding: .8em 1.2em; border-inline-start: 4px solid var(--brand); background: var(--brand-soft); border-radius: 0 8px 8px 0; }
[dir=rtl] .prose blockquote { border-radius: 8px 0 0 8px; }
.prose blockquote p:last-child { margin-bottom: 0; }
.prose table { width: 100%; border-collapse: collapse; margin: 0 0 1.25em; font-size: .95rem; display: block; overflow-x: auto; }
.prose th, .prose td { border: 1px solid var(--line); padding: .6rem .85rem; text-align: start; }
.prose th { background: var(--surface); color: var(--ink); font-weight: 700; }
.prose tr:nth-child(even) td { background: #FAFBFC; }

.toc { margin: 1.75rem 0; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.toc summary { cursor: pointer; padding: .9rem 1.2rem; font-weight: 700; color: var(--ink); }
.toc ol { margin: 0; padding: 0 2.6rem 1rem 1.2rem; font-size: .97rem; line-height: 1.9; }
.toc a { color: var(--text); }
.toc a:hover { color: var(--brand); text-decoration: underline; }

.sections { margin-top: 2rem; }
.sec { scroll-margin-top: calc(var(--hdr-h) + 1rem); }
.sec + .sec { margin-top: 2.25rem; }
.sec h2 { font-size: 1.45rem; margin-bottom: .85rem; }
.is-steps .sec h2 { display: flex; align-items: flex-start; gap: .75rem; }
.step-n { flex-shrink: 0; width: 2.1rem; height: 2.1rem; margin-top: .1rem; display: grid; place-items: center; border-radius: 8px; background: var(--brand); color: #fff; font-size: 1rem; }
@media (max-width: 560px) { .sec h2 { font-size: 1.25rem; } .step-n { width: 1.85rem; height: 1.85rem; font-size: .9rem; } }

.summary { margin-top: 2.5rem; padding: 1.4rem 1.6rem; background: var(--brand-soft); border-radius: var(--radius); }
.summary h2 { font-size: 1.2rem; margin-bottom: .6rem; }
.summary > :last-child { margin-bottom: 0; }

.faq { margin-top: 2.5rem; }
.faq h2 { font-size: 1.35rem; margin-bottom: .75rem; }
.faq details { border: 1px solid var(--line); border-radius: 8px; margin-bottom: .6rem; }
.faq summary { list-style: none; cursor: pointer; display: flex; justify-content: space-between; gap: 1rem; padding: .85rem 1.1rem; font-weight: 500; color: var(--ink); }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; color: var(--brand); font-size: 1.3rem; line-height: 1; }
.faq details[open] summary::after { content: "−"; }
.faq details[open] summary { border-bottom: 1px solid var(--line); }
.faq details p { margin: 0; padding: .85rem 1.1rem 1rem; color: var(--text); }

.post-tags { display: flex; flex-wrap: wrap; align-items: center; gap: .45rem; margin-top: 2rem; font-size: .9rem; }
.post-tags span { color: var(--muted); }
.post-tags a { background: var(--surface); color: var(--text); padding: .2rem .75rem; border-radius: 6px; font-size: .85rem; }
.post-tags a:hover { background: var(--brand); color: #fff; }
.source { font-size: .88rem; color: var(--muted); margin-top: 1rem; }

.share { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; margin-top: 1.75rem; padding: 1rem 0; border-block: 1px solid var(--line); font-size: .9rem; }
.share span { color: var(--muted); margin-inline-end: .25rem; }
.share a, .share button { display: inline-flex; align-items: center; gap: .3rem; padding: .35rem .85rem; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); color: var(--text); font-size: .85rem; cursor: pointer; }
.share a:hover, .share button:hover { border-color: var(--brand); color: var(--brand); }

.post-nav { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-top: 1.75rem; }
.pn { display: block; padding: 1rem 1.1rem; border: 1px solid var(--line); border-radius: 8px; color: var(--ink); }
.pn:hover { border-color: var(--brand); }
.pn small { display: block; color: var(--muted); font-size: .8rem; }
.pn span { font-weight: 500; font-size: .95rem; line-height: 1.6; }
.pn-next { text-align: end; }
@media (max-width: 560px) { .post-nav { grid-template-columns: 1fr; } .pn-next { text-align: start; } }

/* ---------------- Ads (بدون CLS) ---------------- */
.ad { margin: 1.75rem auto; text-align: center; min-height: 100px; overflow: hidden; }
.ad-label { display: block; font-size: .7rem; color: #9AA1B0; margin-bottom: .25rem; }
.ad-header { max-width: var(--container); padding-inline: 1.25rem; margin-block: 1rem; min-height: 90px; }
.ad-sidebar { margin: 0; min-height: 250px; }
.ad:has(ins[data-ad-status="unfilled"]) { display: none; }
.list .ad { border-bottom: 1px solid var(--line); padding-bottom: 1.25rem; margin-block: 0 1.25rem; }

/* ---------------- Pager / Search / Empty ---------------- */
.pager { display: flex; flex-wrap: wrap; gap: .4rem; justify-content: center; margin-top: 2rem; }
.pager a, .pager span { min-width: 2.5rem; height: 2.5rem; padding-inline: .8rem; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 8px; color: var(--text); font-size: .9rem; }
.pager a:hover { border-color: var(--brand); color: var(--brand); }
.pager [aria-current] { background: var(--brand); border-color: var(--brand); color: #fff; }

.big-search { display: flex; max-width: 560px; margin-top: 1rem; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.big-search:focus-within { border-color: var(--brand); }
.big-search input { flex: 1; min-width: 0; border: 0; font: inherit; padding: .75rem 1rem; outline: none; }
.big-search button { border: 0; background: var(--brand); color: #fff; padding: 0 1.4rem; cursor: pointer; font-weight: 500; }

.empty { text-align: center; padding: 3.5rem 1rem; color: var(--muted); }
.empty svg { margin: 0 auto .75rem; color: var(--ink); }
.notfound { text-align: center; padding-block: 3.5rem 2rem; }
.notfound .big-search { margin-inline: auto; }
.nf-code { font-size: 4.5rem; font-weight: 700; color: var(--brand); margin: 0; line-height: 1; }
.notfound h1 { margin: .5rem 0; font-size: 1.8rem; }
.notfound p { color: var(--muted); }

/* ---------------- Footer ---------------- */
.ftr { margin-top: 3rem; background: var(--surface); border-top: 1px solid var(--line); font-size: .92rem; }
.ftr-grid { display: grid; grid-template-columns: 1.4fr 1fr 1.3fr 1fr; gap: 2rem; padding-block: 2.75rem 2rem; }
@media (max-width: 900px) { .ftr-grid { grid-template-columns: 1fr 1fr; } }
@media (max-width: 520px) { .ftr-grid { grid-template-columns: 1fr; } }
.ftr h2 { font-size: 1rem; margin-bottom: .8rem; }
.ftr ul { list-style: none; margin: 0; padding: 0; display: grid; gap: .45rem; }
.ftr-col a { color: var(--text); }
.ftr-col a:hover { color: var(--brand); }
.ftr-about p { color: var(--muted); margin: .7rem 0 1rem; }
.social { display: flex !important; flex-wrap: wrap; gap: .5rem !important; }
.social a { display: inline-block; padding: .25rem .75rem; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); color: var(--text); font-size: .82rem; }
.social a:hover { border-color: var(--brand); color: var(--brand); }
.ftr-bottom { border-top: 1px solid var(--line); padding-block: 1rem; font-size: .83rem; color: var(--muted); }

@media print {
  .hdr, .side, .ftr, .ad, .share, .post-nav, .related, .toc { display: none !important; }
  .layout { display: block; }
}
