/* kb.css — knowledge base stylesheet.
 *
 * Sources:
 *   - design tokens and base/header rules lifted from amlak-web/style.css
 *   - prose rules extracted from docs/user-manual.org #+HTML_HEAD
 *   - layout rules added for the knowledge base itself
 *
 * Hand-maintained. tools/split.py extracts the manual's inline CSS for review
 * but must never write this file.
 *
 * Self-contained on purpose: the KB must render correctly when uploaded to
 * /kb/ without depending on ../style.css.
 */

/* ------------------------------------------------------------------ tokens */
:root{
  --bg:#f8faf8;
  --surface:#ffffff;
  --surface-2:#f1f5f1;
  --text:#0f1e14;
  --muted:#5a6b5e;
  --border:#dde6df;
  --border-strong:#c8d8cc;
  --primary:#0e7c4a;
  --primary-600:#0a5e38;
  --primary-50:#ecfdf5;
  --accent:#f59e0b;
  --radius:16px;
  --radius-sm:10px;
  --shadow:0 8px 32px rgba(15,30,20,.08);
  --shadow-lg:0 16px 48px rgba(15,30,20,.12);
  --max:1120px;
  --side:260px;
}

/* -------------------------------------------------------------------- base */
*{box-sizing:border-box}
html{scroll-behavior:smooth;scroll-padding-top:84px}
body{
  margin:0;
  font-family:"Vazirmatn", Tahoma, "DejaVu Sans", sans-serif;
  background:var(--bg);
  color:var(--text);
  line-height:1.85;
  -webkit-font-smoothing:antialiased;
}
a{color:var(--primary-600)}
img{max-width:100%}
.container{max-width:var(--max);margin:0 auto;padding:0 20px}
.center{text-align:center}
.skip-link{
  position:absolute;right:16px;top:-100px;
  background:var(--text);color:#fff;padding:8px 14px;border-radius:8px;z-index:999;
}
.skip-link:focus{top:10px}

/* ------------------------------------------------------------------ header */
.site-header{
  position:sticky;top:0;z-index:50;
  background:rgba(255,255,255,.9);
  backdrop-filter:blur(10px);
  border-bottom:1px solid var(--border);
}
.header-inner{
  display:flex;align-items:center;justify-content:space-between;
  gap:16px;min-height:64px;
}
.brand{display:flex;align-items:center;gap:10px;text-decoration:none}
.brand-mark{
  width:38px;height:38px;border-radius:10px;
  display:grid;place-items:center;
  background:var(--primary);color:#fff;font-weight:900;font-size:20px;
}
.brand-text{font-weight:900;font-size:20px;letter-spacing:-.02em}
.main-nav{display:flex;gap:22px;align-items:center}
.main-nav a{
  text-decoration:none;color:var(--muted);font-weight:500;font-size:14.5px;
  padding:6px 2px;border-bottom:2px solid transparent;
}
.main-nav a:hover{color:var(--text);border-bottom-color:var(--border-strong)}

/* ----------------------------------------------------------------- layout */
.kb-layout{
  display:grid;
  grid-template-columns:var(--side) minmax(0,1fr);
  gap:36px;
  align-items:start;
  padding-top:28px;
  padding-bottom:64px;
}
.kb-side{
  position:sticky;top:84px;
  max-height:calc(100vh - 108px);
  overflow-y:auto;
  padding-left:14px;
  scrollbar-width:thin;
}
.nav-group{margin-bottom:22px}
.nav-group h3{
  margin:0 0 8px;
  font-size:12.5px;font-weight:800;letter-spacing:.04em;
  color:var(--muted);
}
.nav-group ul{list-style:none;margin:0;padding:0}
.nav-group a{
  display:block;
  padding:7px 12px;
  border-radius:var(--radius-sm);
  text-decoration:none;
  color:var(--text);
  font-size:14.5px;
  border-right:3px solid transparent;
}
.nav-group a:hover{background:var(--surface-2)}
.nav-group a.current{
  background:var(--primary-50);
  border-right-color:var(--primary);
  color:var(--primary-600);
  font-weight:700;
}
.kb-main{min-width:0}

/* ------------------------------------------------------------------- prose */
.prose{font-size:16.5px}
.prose h1{font-size:31px;line-height:1.3;margin:0 0 20px;font-weight:900;letter-spacing:-.02em}
.prose h2{font-size:23px;margin:38px 0 12px;font-weight:800;line-height:1.4}
.prose h3{font-size:18.5px;margin:28px 0 10px;font-weight:800;line-height:1.5}
.prose h4{font-size:16.5px;margin:22px 0 8px;font-weight:700}
.prose p{margin:0 0 14px}
.prose ul,.prose ol{margin:0 0 16px;padding-right:1.6em}
.prose li{margin:5px 0}
.prose li>p{margin:0 0 6px}
.prose strong{font-weight:800}

table{
  border-collapse:collapse;width:100%;margin:1em 0;font-size:15px;
  display:block;overflow-x:auto;
}
th,td{border:1px solid var(--border);padding:9px 12px;text-align:right;vertical-align:top}
th{background:var(--surface-2);font-weight:800;white-space:nowrap}
tbody tr:nth-child(even){background:rgba(241,245,241,.45)}

blockquote{
  border-right:3px solid var(--primary);
  border-left:none;margin:1.2em 0;padding:.7em 1em;
  background:var(--primary-50);border-radius:var(--radius-sm);
}
blockquote p:last-child{margin-bottom:0}

code{
  background:var(--surface-2);padding:1px 5px;border-radius:4px;
  direction:ltr;display:inline-block;font-size:.92em;
}
pre{
  direction:ltr;text-align:left;
  background:var(--surface-2);padding:14px;border-radius:var(--radius-sm);
  overflow-x:auto;
}
pre code{background:none;padding:0}

/* ----------------------------------------------------- figures / screenshots */
figure.shot{
  margin:22px 0;
  border:1px solid var(--border);
  border-radius:var(--radius);
  background:var(--surface);
  padding:12px;
  box-shadow:var(--shadow);
}
figure.shot img{
  display:block;width:100%;height:auto;
  border-radius:var(--radius-sm);
  border:1px solid var(--border);
  background:var(--surface-2);
}
figure.shot figcaption{
  margin-top:10px;
  color:var(--muted);
  font-size:13.5px;
  text-align:center;
}

/* ------------------------------------------------------------------- video */
/* Reuses figure.shot for the card (border, radius, shadow, caption); only the
 * player itself needs rules. The black background keeps letterboxing from
 * flashing the page surface before the first frame is decoded. */
figure.video video{
  display:block;width:100%;height:auto;
  aspect-ratio:16/9;
  background:#000;
  border-radius:var(--radius-sm);
  border:1px solid var(--border);
}

/* ------------------------------------------------------------------ pager */
.pager-wrap{
  display:flex;justify-content:space-between;align-items:center;gap:14px;
  margin-top:52px;padding-top:22px;border-top:1px solid var(--border);
}
.pager{
  text-decoration:none;font-weight:700;font-size:14.5px;
  color:var(--primary-600);
  padding:10px 18px;border-radius:999px;
  background:var(--surface);border:1px solid var(--border);
}
.pager:hover{background:var(--surface-2);border-color:var(--border-strong)}

/* ------------------------------------------------------------------ footer */
.site-footer{border-top:1px solid var(--border);background:var(--surface);margin-top:40px}
.site-footer .copy{margin:0;padding:22px 0;color:var(--muted);font-size:13.5px}

/* ------------------------------------------------------------------- index */
.kb-index{padding-top:40px;padding-bottom:64px}
.kb-index h1{font-size:36px;margin:0 0 10px;font-weight:900;letter-spacing:-.02em}
.kb-index .lead{color:var(--muted);font-size:17px;max-width:60ch;margin:0 0 26px}
.idx-group{margin-bottom:34px}
.idx-group h2{font-size:15px;font-weight:800;color:var(--muted);margin:0 0 12px}
.idx-cards{
  list-style:none;margin:0;padding:0;
  display:grid;gap:12px;
  grid-template-columns:repeat(auto-fill,minmax(230px,1fr));
}
.idx-cards a{
  display:block;text-decoration:none;
  background:var(--surface);
  border:1px solid var(--border);
  border-radius:var(--radius-sm);
  padding:15px 17px;
  color:var(--text);
  transition:.15s;
}
.idx-cards a:hover{border-color:var(--primary);box-shadow:var(--shadow);transform:translateY(-1px)}
.idx-cards strong{font-size:15.5px;font-weight:700}

/* ------------------------------------------------------------------ search */
.search-wrap{position:relative;margin:0 0 34px;max-width:520px}
.search-wrap input{
  width:100%;
  padding:13px 18px;
  font-family:inherit;font-size:15.5px;
  color:var(--text);
  background:var(--surface);
  border:1px solid var(--border-strong);
  border-radius:999px;
}
.search-wrap input:focus{
  outline:none;border-color:var(--primary);
  box-shadow:0 0 0 3px var(--primary-50);
}
.search-results{
  list-style:none;margin:10px 0 0;padding:0;
  background:var(--surface);
  border:1px solid var(--border);
  border-radius:var(--radius-sm);
  box-shadow:var(--shadow-lg);
  overflow:hidden;
}
.search-results:empty{display:none}
.search-results li{border-bottom:1px solid var(--border)}
.search-results li:last-child{border-bottom:none}
.search-results a{
  display:block;padding:11px 18px;text-decoration:none;color:var(--text);
}
.search-results a:hover{background:var(--surface-2)}
.search-results .r-title{display:block;font-weight:700;font-size:15px}
.search-results .r-snip{display:block;color:var(--muted);font-size:13px;margin-top:2px}
.search-results mark{background:#fde68a;border-radius:3px;padding:0 1px}

/* ------------------------------------------------------------- responsive */
@media (max-width:900px){
  .kb-layout{grid-template-columns:1fr;gap:22px}
  .kb-side{
    position:static;max-height:none;
    padding:16px;border:1px solid var(--border);
    border-radius:var(--radius);background:var(--surface);
  }
  .nav-group{margin-bottom:14px}
  .prose h1{font-size:26px}
  .prose h2{font-size:21px}
}
