/* ArabDev documentation sites: the look they share with the app.

   This exact file is in wiki/assets, privacy/assets and patch-notes/assets, because each site is
   published on its own. Change one, copy it to the other two.

   The values come from the app's theme (frontend/src/theme): the same colours, the same 60px top
   bar, the 244px navigation column and 320px side column, bordered cards with a 12px radius, and
   the typography used for posts. */

@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 {
  --primary: #d0152b;
  --primary-hover: #a50e21;
  --accent-text: #c8102e;
  --accent-subtle: rgba(208, 21, 43, 0.07);
  --accent-hover: rgba(208, 21, 43, 0.12);
  --background: #f7f7f5;
  --paper: #ffffff;
  --sunken: #f1f0ed;
  --divider: #e6e4e0;
  --border-strong: #d4d1cc;
  --text: #141414;
  --text-secondary: #5c5a57;
  --text-muted: #7a7874;
  --hover: rgba(0, 0, 0, 0.04);
  --info: #2c5282;
  --info-bg: rgba(44, 82, 130, 0.07);
  --success: #1e7b4a;
  --success-bg: rgba(30, 123, 74, 0.08);
  --warning: #9a6700;
  --warning-bg: rgba(154, 103, 0, 0.09);
  --code-bg: #111113;
  --code-text: #ededea;
  --shadow: 0 4px 12px rgba(20, 20, 20, 0.08), 0 1px 3px rgba(20, 20, 20, 0.06);
  --appbar: 60px;
  --nav: 244px;
  --aside: 320px;
  --max: 1280px;
  --font-body: 'Tajawal', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-heading: 'Alexandria', 'Tajawal', system-ui, sans-serif;
  --font-display: 'Anton', Impact, 'Arial Narrow', sans-serif;
  --font-mono: 'JetBrains Mono', 'Cascadia Code', Consolas, 'SFMono-Regular', monospace;
  color-scheme: light;
}

:root[data-theme='dark'] {
  --primary: #db2436;
  --primary-hover: #b81c2c;
  --accent-text: #ff6b76;
  --accent-subtle: rgba(255, 107, 118, 0.1);
  --accent-hover: rgba(255, 107, 118, 0.16);
  --background: #0f0f10;
  --paper: #161618;
  --sunken: #1c1c1f;
  --divider: #2a2a2d;
  --border-strong: #3a3a3e;
  --text: #f2f2f0;
  --text-secondary: #a3a3a0;
  --text-muted: #85857f;
  --hover: rgba(255, 255, 255, 0.07);
  --info: #7fb3f5;
  --info-bg: rgba(127, 179, 245, 0.1);
  --success: #4cc38a;
  --success-bg: rgba(76, 195, 138, 0.1);
  --warning: #f2c94c;
  --warning-bg: rgba(242, 201, 76, 0.1);
  --shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-padding-top: calc(var(--appbar) + 16px); -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--background);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
a { color: var(--accent-text); font-weight: 500; text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
::selection { background: var(--accent-hover); }
[hidden] { display: none !important; }
.icon { width: 24px; height: 24px; fill: currentColor; flex-shrink: 0; }

.skip {
  position: absolute;
  top: -48px;
  inset-inline-start: 8px;
  z-index: 1500;
  padding: 8px 16px;
  border-radius: 8px;
  background: var(--paper);
  color: var(--accent-text);
}
.skip:focus { top: 8px; }

/* ---------- top bar (the app's Navbar) ---------- */
.appbar {
  position: sticky;
  top: 0;
  z-index: 1100;
  background: var(--paper);
  border-bottom: 1px solid var(--divider);
}
.appbar-inner {
  display: flex;
  align-items: center;
  gap: 16px;
  max-width: var(--max);
  height: var(--appbar);
  margin: 0 auto;
  padding: 0 24px;
}
.appbar-start { display: flex; align-items: center; gap: 12px; width: var(--nav); flex-shrink: 0; min-width: 0; }
.logo {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 28px;
  line-height: 1;
  letter-spacing: 0.01em;
  color: var(--text);
  white-space: nowrap;
}
.logo:hover { text-decoration: none; }
.logo-arab { color: var(--primary); }
.site-name {
  padding-inline-start: 12px;
  border-inline-start: 1px solid var(--divider);
  color: var(--text-secondary);
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 0.9375rem;
  line-height: 24px;
  white-space: nowrap;
}
.site-name:hover { color: var(--text); text-decoration: none; }
.appbar-actions { display: flex; align-items: center; gap: 8px; margin-inline-start: auto; }

.search { position: relative; flex: 1; min-width: 0; max-width: 520px; }
.search-field {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 42px;
  padding: 0 12px;
  border: 1px solid var(--border-strong);
  border-radius: 16px;
  background: var(--sunken);
  transition: border-color 120ms, background-color 120ms;
}
.search-field:focus-within { border-color: var(--primary); background: var(--paper); }
.search-field .icon { width: 20px; height: 20px; color: var(--text-secondary); }
.search-field input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  background: none;
  color: var(--text);
  font: inherit;
  font-size: 0.9375rem;
}
.search-field input::placeholder { color: var(--text-muted); opacity: 1; }
.popup {
  position: absolute;
  top: calc(100% + 6px);
  inset-inline: 0;
  z-index: 1300;
  max-height: 440px;
  overflow-y: auto;
  padding: 4px 0;
  background: var(--paper);
  border: 1px solid var(--divider);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

/* ---------- buttons (MUI Button and IconButton) ---------- */
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 38px;
  padding: 6px 16px;
  border: 0;
  border-radius: 8px;
  background: none;
  color: var(--text);
  font: inherit;
  font-weight: 700;
  font-size: 0.9375rem;
  line-height: 1.6;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 150ms, border-color 150ms;
}
.button:hover { text-decoration: none; background: var(--hover); }
.button .icon { width: 20px; height: 20px; }
.button-contained { background: var(--primary); color: #fff; }
.button-contained:hover { background: var(--primary-hover); }
.button-outlined { padding: 5px 15px; border: 1px solid var(--border-strong); }
.icon-button {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background-color 150ms;
}
.icon-button:hover { background: var(--hover); color: var(--text); }
.menu-button { display: none; margin-inline-start: -8px; }
.theme-icon-dark { display: none; }
:root[data-theme='dark'] .theme-icon-dark { display: block; }
:root[data-theme='dark'] .theme-icon-light { display: none; }

/* ---------- three columns, like the dashboard ---------- */
.page {
  display: grid;
  grid-template-columns: var(--nav) minmax(0, 1fr) var(--aside);
  grid-template-areas: 'nav main aside';
  column-gap: 24px;
  max-width: var(--max);
  margin: 0 auto;
  padding: 0 24px;
}
.nav {
  grid-area: nav;
  position: sticky;
  top: var(--appbar);
  align-self: start;
  max-height: calc(100vh - var(--appbar));
  overflow-y: auto;
  padding: 16px 0 32px;
  scrollbar-width: thin;
}
.main { grid-area: main; min-width: 0; padding: 16px 0 48px; }
.main:focus { outline: none; }
.aside {
  grid-area: aside;
  position: sticky;
  top: var(--appbar);
  align-self: start;
  display: grid;
  gap: 16px;
  max-height: calc(100vh - var(--appbar));
  overflow-y: auto;
  padding: 16px 0;
  scrollbar-width: thin;
}

/* navigation lists (the app's sidebar, sized for longer lists) */
.nav-heading {
  margin: 20px 0 4px;
  padding: 0 12px;
  color: var(--text-muted);
  font-size: 0.8125rem;
  font-weight: 700;
  line-height: 1.5;
}
.nav-heading:first-child { margin-top: 0; }
.nav-list { display: grid; gap: 2px; margin: 0; padding: 0; list-style: none; }
.nav-link {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 6px 12px;
  border-radius: 8px;
  color: var(--text-secondary);
  font-weight: 500;
  font-size: 0.9375rem;
  line-height: 1.45;
}
.nav-link:hover { background: var(--hover); color: var(--text); text-decoration: none; }
.nav-link[aria-current], .nav-link.active { color: var(--text); font-weight: 800; }
.nav-link[aria-current]::before, .nav-link.active::before {
  content: '';
  position: absolute;
  inset-inline-start: 0;
  top: 8px;
  bottom: 8px;
  width: 3px;
  border-radius: 3px;
  background: var(--primary);
}
.nav-link .count { margin-inline-start: auto; color: var(--text-muted); font-size: 0.8125rem; font-weight: 500; }
.nav-list .nav-list { margin: 0 0 6px; padding-inline-start: 12px; }
.nav-list .nav-list .nav-link { min-height: 34px; font-size: 0.875rem; }
.nav-external::after { content: '↗'; margin-inline-start: auto; color: var(--text-muted); font-size: 0.8125rem; }
[dir='rtl'] .nav-external::after { content: '↖'; }

/* ---------- cards (the app's Surface) ---------- */
.surface {
  background: var(--paper);
  border: 1px solid var(--divider);
  border-radius: 12px;
  overflow: clip;
}
.surface + .surface { margin-top: 16px; }
.aside .surface + .surface { margin-top: 0; }
.surface-heading {
  margin: 0;
  padding: 16px 16px 8px;
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 1.0625rem;
  line-height: 1.5;
}
.surface-body { padding: 0 16px 16px; font-size: 0.9375rem; line-height: 1.65; }
.surface-body p { margin: 0 0 8px; }
.surface-body p:last-child { margin-bottom: 0; }
.page-header { padding: 20px 24px; border-bottom: 1px solid var(--divider); }
.page-title {
  margin: 0;
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 1.75rem;
  line-height: 1.35;
}
.page-lead { margin: 6px 0 0; color: var(--text-secondary); font-size: 1rem; }
.caption { color: var(--text-secondary); font-size: 0.8125rem; line-height: 1.5; }

/* key and value rows, for facts in a side card */
.facts { margin: 0; padding: 0 16px 12px; font-size: 0.9375rem; line-height: 1.55; }
.facts div { display: flex; justify-content: space-between; gap: 16px; padding: 8px 0; border-top: 1px solid var(--divider); }
.facts div:first-child { border-top: 0; }
.facts dt { color: var(--text-secondary); }
.facts dd { margin: 0; font-weight: 700; text-align: end; }

/* a list of links in a side card */
.link-list { margin: 0; padding: 0 8px 8px; list-style: none; }
.link-list a {
  display: block;
  padding: 6px 8px;
  border-radius: 8px;
  color: var(--text-secondary);
  font-size: 0.9375rem;
  line-height: 1.5;
}
.link-list a:hover { background: var(--hover); color: var(--text); text-decoration: none; }
.link-list a.active { color: var(--accent-text); font-weight: 700; }
.link-list .sub a { padding-inline-start: 22px; font-size: 0.875rem; }

/* ---------- long text (the app's post typography) ---------- */
.prose { padding: 24px 32px 32px; overflow-wrap: anywhere; }
.prose > :first-child, .prose > :first-child > :first-child { margin-top: 0; }
.prose h2 {
  margin: 36px 0 10px;
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 1.375rem;
  line-height: 1.45;
}
.prose h3 {
  margin: 28px 0 8px;
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 1.125rem;
  line-height: 1.5;
}
.prose h4 { margin: 20px 0 6px; font-family: var(--font-heading); font-weight: 600; font-size: 1rem; }
.prose p { margin: 0 0 14px; }
.prose ul, .prose ol { margin: 0 0 16px; padding-inline-start: 24px; }
.prose li { margin: 4px 0; }
.prose li > ul, .prose li > ol { margin: 4px 0; }
.prose li::marker { color: var(--text-muted); }
.prose blockquote {
  margin: 0 0 16px;
  padding: 2px 0;
  padding-inline-start: 16px;
  border-inline-start: 3px solid var(--primary);
  color: var(--text-secondary);
}
.prose hr { border: 0; border-top: 1px solid var(--divider); margin: 28px 0; }
.prose dl { margin: 0 0 16px; }
.prose dt { font-weight: 700; margin-top: 12px; }
.prose dd { margin: 2px 0 0; padding-inline-start: 16px; color: var(--text-secondary); }
.anchor {
  margin-inline-start: 8px;
  color: var(--text-muted);
  font-weight: 400;
  font-size: 0.8em;
  opacity: 0;
}
h2:hover > .anchor, h3:hover > .anchor, .anchor:focus { opacity: 1; text-decoration: none; }

code {
  padding: 1px 4px;
  border: 1px solid var(--divider);
  border-radius: 6px;
  background: var(--sunken);
  font-family: var(--font-mono);
  font-size: 0.875em;
  direction: ltr;
  unicode-bidi: isolate;
}
pre {
  margin: 12px 0 16px;
  padding: 16px;
  overflow-x: auto;
  border: 1px solid var(--border-strong);
  border-radius: 16px;
  background: var(--code-bg);
  color: var(--code-text);
  font-family: var(--font-mono);
  font-size: 0.875rem;
  line-height: 1.65;
  direction: ltr;
  text-align: left;
}
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: 6px;
  background: var(--paper);
  font-family: var(--font-mono);
  font-size: 0.8125em;
  line-height: 1.6;
  text-align: center;
  direction: ltr;
  unicode-bidi: isolate;
}
mark { background: var(--accent-hover); color: inherit; border-radius: 3px; padding: 0 1px; }

.table-wrap { margin: 12px 0 18px; overflow-x: auto; border: 1px solid var(--divider); border-radius: 8px; }
.table-wrap table { width: 100%; border-collapse: collapse; font-size: 0.9375rem; line-height: 1.6; }
.table-wrap th, .table-wrap td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--divider);
  text-align: start;
  vertical-align: top;
}
.table-wrap thead th { background: var(--sunken); font-size: 0.875rem; font-weight: 700; }
.table-wrap tbody th { font-weight: 700; }
.table-wrap tbody tr:last-child > * { border-bottom: 0; }
.table-wrap caption { padding: 10px 14px 0; caption-side: top; text-align: start; color: var(--text-secondary); font-weight: 700; }

/* notes inside text (MUI Alert, standard variant) */
.callout { margin: 0 0 16px; padding: 12px 16px; border-radius: 8px; background: var(--info-bg); font-size: 0.9375rem; }
.callout p:last-child, .callout ul:last-child { margin-bottom: 0; }
.callout-title { display: block; margin-bottom: 2px; font-weight: 700; }
.callout.note, .callout.info { background: var(--info-bg); }
.callout.note .callout-title, .callout.info .callout-title { color: var(--info); }
.callout.tip, .callout.good { background: var(--success-bg); }
.callout.tip .callout-title, .callout.good .callout-title { color: var(--success); }
.callout.warning { background: var(--warning-bg); }
.callout.warning .callout-title { color: var(--warning); }
.callout.important, .callout.strong { background: var(--accent-subtle); }
.callout.important .callout-title, .callout.strong .callout-title { color: var(--accent-text); }

/* small labels (MUI Chip, small) */
.chip {
  display: inline-flex;
  align-items: center;
  height: 24px;
  padding: 0 8px;
  border-radius: 6px;
  background: var(--sunken);
  color: var(--text-secondary);
  font-size: 0.8125rem;
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
}
.chip.primary { background: var(--accent-subtle); color: var(--accent-text); font-weight: 700; }

/* ---------- footer (the homepage's) ---------- */
.footer { border-top: 1px solid var(--divider); background: var(--paper); }
.footer-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 24px;
  max-width: var(--max);
  margin: 0 auto;
  padding: 20px 24px;
}
.footer .logo { font-size: 22px; }
.footer p { margin: 4px 0 0; color: var(--text-secondary); font-size: 0.8125rem; }
.footer nav { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: 0.8125rem; }
.footer nav a { color: var(--text-secondary); font-weight: 500; }
.footer nav a:hover { color: var(--text); }

/* ---------- smaller screens ---------- */
@media (max-width: 1199px) {
  .page { grid-template-columns: var(--nav) minmax(0, 1fr); grid-template-areas: 'nav main' 'nav aside'; }
  .aside { position: static; max-height: none; overflow: visible; padding: 0 0 48px; }
  .appbar-start { width: auto; }
}
@media (max-width: 899px) {
  .page { grid-template-columns: minmax(0, 1fr); grid-template-areas: 'main' 'aside'; padding: 0 16px; }
  .menu-button { display: inline-grid; }
  .nav {
    position: fixed;
    top: var(--appbar);
    bottom: 0;
    inset-inline-start: 0;
    z-index: 1200;
    width: min(300px, 86vw);
    max-height: none;
    padding: 16px 12px 32px;
    background: var(--paper);
    border-inline-end: 1px solid var(--divider);
    box-shadow: var(--shadow);
    transform: translateX(-105%);
    transition: transform 200ms ease;
    visibility: hidden;
  }
  [dir='rtl'] .nav { transform: translateX(105%); }
  body.nav-open .nav { transform: none; visibility: visible; }
  body.nav-open::after {
    content: '';
    position: fixed;
    inset: var(--appbar) 0 0;
    z-index: 1150;
    background: rgba(0, 0, 0, 0.32);
  }
  .appbar-inner { padding: 0 16px; gap: 8px; }
  .prose { padding: 20px 20px 28px; }
  .page-header { padding: 16px 20px; }
}
@media (max-width: 599px) {
  .page { padding: 0; }
  .main { padding-top: 0; }
  .surface { border-radius: 0; border-inline: 0; }
  .aside { padding: 0 0 32px; gap: 0; }
  .aside .surface { border-top: 0; }
  .site-name, .open-app { display: none; }
  .lang-label { display: none; }
  .search-field { height: 38px; padding: 0 10px; border-radius: 12px; }
  .appbar-actions { gap: 0; }
  .appbar-actions .button { padding-inline: 8px; }
  .page-title { font-size: 1.5rem; }
  .prose { padding: 16px 16px 24px; }
  .page-header { padding: 16px; }
  .footer-inner { padding: 20px 16px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; scroll-behavior: auto !important; }
}
@media print {
  .appbar, .nav, .aside, .footer, .skip, .anchor { display: none !important; }
  .page { display: block; padding: 0; }
  .surface { border: 0; }
  a { color: inherit; }
  pre { white-space: pre-wrap; }
}
