/* ArabDev Wiki — standalone stylesheet (shares the app's fonts and colors). */

@font-face { font-family: 'Tajawal'; font-weight: 400; font-display: swap; src: url('fonts/tajawal/tajawal-400.woff2') format('woff2'); }
@font-face { font-family: 'Tajawal'; font-weight: 500; font-display: swap; src: url('fonts/tajawal/tajawal-500.woff2') format('woff2'); }
@font-face { font-family: 'Tajawal'; font-weight: 700; font-display: swap; src: url('fonts/tajawal/tajawal-700.woff2') format('woff2'); }
@font-face { font-family: 'Tajawal'; font-weight: 800; font-display: swap; src: url('fonts/tajawal/tajawal-800.woff2') format('woff2'); }
@font-face { font-family: 'Alexandria'; font-weight: 500; font-display: swap; src: url('fonts/alexandria/alexandria-500.woff2') format('woff2'); }
@font-face { font-family: 'Alexandria'; font-weight: 600; font-display: swap; src: url('fonts/alexandria/alexandria-600.woff2') format('woff2'); }
@font-face { font-family: 'Alexandria'; font-weight: 700; font-display: swap; src: url('fonts/alexandria/alexandria-700.woff2') format('woff2'); }
@font-face { font-family: 'Anton'; font-weight: 400; font-display: swap; src: url('fonts/anton/anton-400.woff2') format('woff2'); }

:root {
  --red: #d0152b;
  --red-text: #c8102e;
  --red-subtle: rgba(208, 21, 43, 0.07);
  --bg: #f7f7f5;
  --paper: #ffffff;
  --sunken: #f1f0ed;
  --border: #e6e4e0;
  --border-strong: #d4d1cc;
  --ink: #141414;
  --muted: #5c5a57;
  --faint: #7a7874;
  --code-bg: #111113;
  --code-ink: #ededea;
  --note: #2c5282;
  --note-bg: rgba(44, 82, 130, 0.07);
  --tip: #1e7b4a;
  --tip-bg: rgba(30, 123, 74, 0.08);
  --warn: #9a6700;
  --warn-bg: rgba(154, 103, 0, 0.09);
  --header-h: 60px;
  --sidebar-w: 264px;
  --font-body: 'Tajawal', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-heading: 'Alexandria', 'Tajawal', system-ui, sans-serif;
  --font-display: 'Anton', Impact, 'Arial Narrow', sans-serif;
  --font-mono: 'Cascadia Code', Consolas, 'SFMono-Regular', monospace;
  color-scheme: light;
}

:root[data-theme='dark'] {
  --red: #db2436;
  --red-text: #ff6b76;
  --red-subtle: rgba(255, 107, 118, 0.1);
  --bg: #0f0f10;
  --paper: #161618;
  --sunken: #1c1c1f;
  --border: #2a2a2d;
  --border-strong: #3a3a3e;
  --ink: #f2f2f0;
  --muted: #a3a3a0;
  --faint: #85857f;
  --note: #7fb3f5;
  --note-bg: rgba(127, 179, 245, 0.1);
  --tip: #4cc38a;
  --tip-bg: rgba(76, 195, 138, 0.1);
  --warn: #f2c94c;
  --warn-bg: rgba(242, 201, 76, 0.1);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { scroll-padding-top: calc(var(--header-h) + 16px); }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.8;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--red-text); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
:focus-visible { outline: 2px solid var(--red); outline-offset: 2px; border-radius: 4px; }
::selection { background: var(--red-subtle); }

/* ---------- header ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  height: var(--header-h);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 20px;
  background: var(--paper);
  border-bottom: 1px solid var(--border);
}
.brand { display: inline-flex; align-items: baseline; gap: 8px; color: var(--ink); white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand-word { font-family: var(--font-display); font-size: 26px; line-height: 1; letter-spacing: 0.01em; }
.brand-word .arab { color: var(--red); }
.brand-label {
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 13px;
  padding: 2px 8px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  color: var(--muted);
}
.search { position: relative; flex: 1; max-width: 480px; margin-inline-start: auto; }
.search input {
  width: 100%;
  height: 40px;
  padding: 0 14px;
  padding-inline-start: 38px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: var(--sunken);
  color: var(--ink);
  font: inherit;
  font-size: 15px;
}
.search input:focus { outline: none; border-color: var(--red); background: var(--paper); }
.search-icon { position: absolute; top: 11px; inset-inline-start: 12px; width: 18px; height: 18px; color: var(--faint); pointer-events: none; }
.search-results {
  position: absolute;
  top: 46px;
  inset-inline: 0;
  max-height: 420px;
  overflow-y: auto;
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 12px 32px rgba(20, 20, 20, 0.14);
  padding: 6px;
}
.search-results[hidden] { display: none; }
.search-result { display: block; padding: 8px 10px; border-radius: 8px; color: var(--ink); }
.search-result:hover, .search-result[aria-selected='true'] { background: var(--red-subtle); text-decoration: none; }
.search-result strong { display: block; font-weight: 700; }
.search-result span { display: block; font-size: 13px; color: var(--muted); line-height: 1.5; }
.search-empty { padding: 10px; color: var(--muted); font-size: 14px; }
.header-actions { display: flex; align-items: center; gap: 8px; }
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 38px;
  padding: 0 14px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--paper);
  color: var(--ink);
  font: inherit;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover { background: var(--sunken); text-decoration: none; }
.btn-primary { background: var(--red); border-color: var(--red); color: #fff; }
.btn-primary:hover { background: var(--red); filter: brightness(0.92); }
.icon-btn { width: 38px; padding: 0; justify-content: center; }
.menu-btn { display: none; }

/* ---------- layout ---------- */
.layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  max-width: 1320px;
  margin: 0 auto;
}
.sidebar {
  position: sticky;
  top: var(--header-h);
  align-self: start;
  height: calc(100vh - var(--header-h));
  overflow-y: auto;
  padding: 20px 14px 40px;
  border-inline-end: 1px solid var(--border);
  scrollbar-width: thin;
}
.nav-group { margin-bottom: 18px; }
.nav-group h2 {
  margin: 0 0 6px;
  padding: 0 10px;
  font-family: var(--font-heading);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--faint);
}
.nav-group ul { list-style: none; margin: 0; padding: 0; }
.nav-group a {
  position: relative;
  display: block;
  padding: 5px 10px;
  border-radius: 8px;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.55;
}
.nav-group a:hover { background: var(--sunken); color: var(--ink); text-decoration: none; }
.nav-group a[aria-current='page'] { background: var(--red-subtle); color: var(--red-text); font-weight: 700; }
.nav-group a[aria-current='page']::before {
  content: '';
  position: absolute;
  inset-inline-start: 0;
  top: 7px;
  bottom: 7px;
  width: 3px;
  border-radius: 3px;
  background: var(--red);
}
.nav-external a::after { content: ' ↗'; font-size: 12px; color: var(--faint); }

.content { min-width: 0; padding: 28px 40px 80px; }

/* ---------- article ---------- */
.wiki-article { max-width: 880px; }
.wiki-article + .wiki-article { margin-top: 64px; padding-top: 32px; border-top: 3px double var(--border); }
html.js .wiki-article + .wiki-article { margin-top: 0; padding-top: 0; border-top: 0; }
.breadcrumbs { font-size: 13px; color: var(--faint); margin-bottom: 6px; }
.breadcrumbs a { color: var(--muted); }
.article-title {
  margin: 0;
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 34px;
  line-height: 1.3;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border-strong);
}
.article-tagline { margin: 8px 0 22px; color: var(--muted); font-size: 14px; }
.wiki-article h2 {
  margin: 36px 0 12px;
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 23px;
  line-height: 1.4;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}
.wiki-article h3 { margin: 26px 0 8px; font-family: var(--font-heading); font-weight: 600; font-size: 18px; line-height: 1.5; }
.wiki-article h4 { margin: 20px 0 6px; font-weight: 800; font-size: 16px; }
.heading-anchor { margin-inline-start: 8px; font-size: 14px; color: var(--faint); opacity: 0; }
h2:hover .heading-anchor, h3:hover .heading-anchor { opacity: 1; }
.wiki-article p { margin: 0 0 14px; }
.wiki-article ul, .wiki-article ol { margin: 0 0 16px; padding-inline-start: 26px; }
.wiki-article li { margin: 4px 0; }
.wiki-article li > ul, .wiki-article li > ol { margin: 4px 0; }
code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  padding: 1px 6px;
  border-radius: 5px;
  background: var(--sunken);
  border: 1px solid var(--border);
  direction: ltr;
  unicode-bidi: isolate;
}
pre {
  direction: ltr;
  text-align: left;
  margin: 0 0 16px;
  padding: 14px 16px;
  overflow-x: auto;
  border-radius: 10px;
  background: var(--code-bg);
  color: var(--code-ink);
  font-family: var(--font-mono);
  font-size: 14px;
  line-height: 1.65;
}
pre code { padding: 0; border: 0; background: none; color: inherit; font-size: inherit; }
kbd {
  display: inline-block;
  min-width: 22px;
  padding: 0 6px;
  border: 1px solid var(--border-strong);
  border-bottom-width: 2px;
  border-radius: 5px;
  background: var(--paper);
  font-family: var(--font-mono);
  font-size: 0.82em;
  line-height: 1.6;
  text-align: center;
  direction: ltr;
  unicode-bidi: isolate;
}

/* table of contents (generated) */
.toc {
  display: inline-block;
  min-width: 260px;
  max-width: 100%;
  margin: 4px 0 22px;
  padding: 12px 18px 12px;
  background: var(--sunken);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.toc-title { display: flex; align-items: center; justify-content: space-between; gap: 16px; font-family: var(--font-heading); font-weight: 600; font-size: 15px; }
.toc-toggle { border: 0; background: none; color: var(--red-text); font: inherit; font-size: 13px; cursor: pointer; }
.toc ol { margin: 8px 0 0; padding-inline-start: 20px; font-size: 14.5px; }
.toc ol ol { margin: 0; }
.toc li { margin: 2px 0; }
.toc.collapsed ol { display: none; }

/* infobox */
.infobox {
  float: inline-end;
  width: 300px;
  margin: 4px 0 18px;
  margin-inline-start: 24px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: var(--paper);
  font-size: 14px;
  line-height: 1.6;
  overflow: hidden;
}
.infobox-title { padding: 12px 14px; text-align: center; background: var(--sunken); border-bottom: 1px solid var(--border); }
.infobox-title .brand-word { font-size: 30px; }
.infobox-caption { display: block; margin-top: 4px; font-size: 13px; color: var(--muted); }
.infobox table { width: 100%; border-collapse: collapse; }
.infobox th, .infobox td { padding: 7px 12px; text-align: start; vertical-align: top; border-top: 1px solid var(--border); }
.infobox th { width: 40%; color: var(--muted); font-weight: 700; }
.clearfix::after { content: ''; display: block; clear: both; }

/* notes */
.hatnote { margin: -4px 0 12px; padding-inline-start: 18px; font-style: italic; color: var(--muted); font-size: 14.5px; }
.callout { margin: 0 0 16px; padding: 12px 16px; border-radius: 10px; border-inline-start: 4px solid; font-size: 15px; }
.callout p:last-child { margin-bottom: 0; }
.callout-title { display: block; font-weight: 800; margin-bottom: 2px; }
.callout.note { border-color: var(--note); background: var(--note-bg); }
.callout.tip { border-color: var(--tip); background: var(--tip-bg); }
.callout.warning { border-color: var(--warn); background: var(--warn-bg); }
.callout.important { border-color: var(--red); background: var(--red-subtle); }

/* tables */
.table-wrap { overflow-x: auto; margin: 0 0 18px; }
table.wikitable { width: 100%; border-collapse: collapse; font-size: 14.5px; line-height: 1.6; background: var(--paper); }
.wikitable th, .wikitable td { padding: 8px 12px; border: 1px solid var(--border); text-align: start; vertical-align: top; }
.wikitable thead th { background: var(--sunken); font-weight: 800; }
.wikitable caption { caption-side: top; text-align: start; padding: 0 0 6px; font-weight: 700; color: var(--muted); }

/* main page */
.portal-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; margin: 0 0 22px; }
.portal-card {
  display: block;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--paper);
  color: var(--ink);
}
.portal-card:hover { border-color: var(--border-strong); text-decoration: none; background: var(--sunken); }
.portal-card strong { display: block; font-family: var(--font-heading); font-weight: 600; font-size: 16px; margin-bottom: 2px; }
.portal-card span { display: block; color: var(--muted); font-size: 14px; line-height: 1.55; }
.box { margin: 0 0 18px; padding: 14px 18px; border: 1px solid var(--border); border-radius: 12px; background: var(--paper); }
.box > h2:first-child, .box > h3:first-child { margin-top: 0; border: 0; padding: 0; }

/* article footer */
.categories {
  clear: both;
  margin: 36px 0 12px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--paper);
  font-size: 14px;
}
.categories a { margin-inline-end: 10px; }
.categories a:not(:last-child)::after { content: ' ·'; color: var(--faint); margin-inline-start: 10px; }
.article-footer { font-size: 13px; color: var(--faint); }
.prev-next { display: flex; justify-content: space-between; gap: 12px; margin-top: 18px; }
.prev-next a { flex: 1; padding: 10px 14px; border: 1px solid var(--border); border-radius: 10px; background: var(--paper); color: var(--ink); font-size: 14px; }
.prev-next a:hover { background: var(--sunken); text-decoration: none; }
.prev-next small { display: block; color: var(--faint); }
.prev-next .next { text-align: end; }
.prev-next [hidden] { visibility: hidden; display: block; }

.site-footer { border-top: 1px solid var(--border); padding: 20px; text-align: center; font-size: 13px; color: var(--faint); }
.site-footer a { color: var(--muted); margin: 0 8px; }

/* ---------- responsive ---------- */
@media (max-width: 980px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .menu-btn { display: inline-flex; }
  .sidebar {
    position: fixed;
    top: var(--header-h);
    inset-inline-start: 0;
    z-index: 30;
    width: min(300px, 86vw);
    background: var(--paper);
    box-shadow: 0 12px 32px rgba(20, 20, 20, 0.2);
    transform: translateX(-105%);
    transition: transform 0.2s ease;
  }
  [dir='rtl'] .sidebar { transform: translateX(105%); }
  body.nav-open .sidebar { transform: none; }
  .content { padding: 20px 18px 64px; }
  .infobox { float: none; width: 100%; margin-inline-start: 0; }
}
@media (max-width: 640px) {
  .site-header { gap: 10px; padding: 0 12px; }
  .brand-label, .open-app-label { display: none; }
  .article-title { font-size: 27px; }
  .search { max-width: none; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; scroll-behavior: auto !important; }
}
@media print {
  .site-header, .sidebar, .prev-next, .toc-toggle, .site-footer { display: none !important; }
  .layout { display: block; }
  .content { padding: 0; }
  .wiki-article[hidden] { display: block !important; }
  a { color: inherit; }
}

/* skip link */
.skip {
  position: absolute;
  top: -60px;
  inset-inline-start: 8px;
  z-index: 50;
  padding: 8px 14px;
  border-radius: 8px;
  background: var(--paper);
  color: var(--ink);
  font-weight: 700;
}
.skip:focus { top: 8px; }
