/**
 * Arshia documentation — landing + article
 * ---------------------------------------------------------------------------
 * Patterns adapted from liara.ir/docs ("مستنداتی که خواب‌آور نیست"): strong
 * search-first landing, live-filtered card grid, sticky TOC, reading progress,
 * copy-able code blocks — re-skinned with Arshia brand tokens
 * (#352070 brand blue, #EEBB66 gold).
 *
 * Constitution I.1: Vazirmatn on every control (inputs, buttons, selects,
 * code) — enforced by the global reset in main.css plus the explicit
 * font-family declarations below.
 */

/* ─────────────────────────────────────────────────────────────
   Shared tokens for the docs surface
   ───────────────────────────────────────────────────────────── */

.docs-canvas {
    --docs-blue: #352070;
    --docs-blue-dark: #2a1a5a;
    --docs-gold: #EEBB66;
    --docs-bg: #faf9fd;
    --docs-ink: #1f2937;
    --docs-muted: #6b7280;
    --docs-line: #eceaf3;
    font-family: 'Vazirmatn', Tahoma, sans-serif;
    color: var(--docs-ink);
    background: var(--docs-bg);
    direction: rtl;
    line-height: 1.9;
}

.docs-canvas code,
.docs-canvas pre,
.docs-canvas kbd {
    font-family: 'Vazirmatn', Tahoma, sans-serif;
    direction: ltr;
    unicode-bidi: embed;
}

/* ─────────────────────────────────────────────────────────────
   1. Docs landing — hero + search
   ───────────────────────────────────────────────────────────── */

.docs-hero {
    background: linear-gradient(160deg, #2a1a5a 0%, #352070 60%, #241548 100%);
    color: #fff;
    padding: 64px 0 72px;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.docs-hero::after {
    content: "";
    position: absolute;
    width: 420px; height: 420px;
    bottom: -220px; left: 50%;
    transform: translateX(-50%);
    background: radial-gradient(circle, rgba(238,187,102,.16), transparent 68%);
    pointer-events: none;
}

.docs-hero-inner { position: relative; z-index: 1; max-width: 720px; margin: 0 auto; padding: 0 24px; }

.docs-hero-eyebrow {
    display: inline-block;
    padding: 5px 16px;
    border-radius: 999px;
    background: rgba(238,187,102,.16);
    border: 1px solid rgba(238,187,102,.45);
    color: var(--docs-gold);
    font-size: 12.5px;
    font-weight: 700;
    margin-bottom: 16px;
}

.docs-hero h1 {
    font-size: clamp(1.6rem, 4vw, 2.4rem);
    font-weight: 800;
    margin: 0 0 14px;
    line-height: 1.5;
    color: #fff;
}

.docs-hero p {
    font-size: 15.5px;
    color: rgba(255,255,255,.78);
    margin: 0 auto 30px;
    max-width: 560px;
    line-height: 2;
}

/* Search — the first thing a docs visitor reaches for */
.docs-search {
    position: relative;
    max-width: 560px;
    margin: 0 auto;
}

.docs-search input {
    width: 100%;
    box-sizing: border-box;
    padding: 15px 52px 15px 18px;
    border: 1px solid rgba(255,255,255,.22);
    border-radius: 14px;
    background: rgba(255,255,255,.08);
    color: #fff;
    font-family: 'Vazirmatn', Tahoma, sans-serif;
    font-size: 15px;
    transition: background .2s, border-color .2s;
}

/* placeholder روی گرادیان docs-hero (#2a1a5a/#352070/#241548) نشت؛
   سفید ۵۰٪ روی تیره‌ترین حالت واقعی ۴٫۱۴:۱ بود (زیر ۴٫۵).
   سفید ۷۲٪ = ۶٫۲۰:۱. */
.docs-search input::placeholder { color: rgba(255,255,255,.72); opacity: 1; }

.docs-search input:focus {
    outline: none;
    background: rgba(255,255,255,.14);
    border-color: var(--docs-gold);
}

.docs-search .docs-search-ico {
    position: absolute;
    right: 18px;
    top: 50%;
    transform: translateY(-50%);
    color: rgba(255,255,255,.55);
    font-size: 17px;
    pointer-events: none;
}

.docs-search kbd {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 11px;
    color: rgba(255,255,255,.6);
    background: rgba(255,255,255,.1);
    border: 1px solid rgba(255,255,255,.18);
    border-radius: 6px;
    padding: 2px 8px;
}

.docs-search-meta {
    margin-top: 12px;
    font-size: 12.5px;
    color: rgba(255,255,255,.55);
    min-height: 20px;
}

/* ─────────────────────────────────────────────────────────────
   2. Landing body
   ───────────────────────────────────────────────────────────── */

.docs-body { padding: 56px 0 72px; }

.docs-section { margin-bottom: 56px; }
.docs-section:last-child { margin-bottom: 0; }

.docs-section-head { margin-bottom: 24px; }

.docs-section-head h2 {
    font-size: clamp(1.25rem, 2.6vw, 1.6rem);
    font-weight: 800;
    color: #1a1a2e;
    margin: 0 0 8px;
}

.docs-section-head p {
    font-size: 14.5px;
    color: var(--docs-muted);
    margin: 0;
    line-height: 2;
}

/* Module / category grid */
.docs-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 16px;
}

.docs-card {
    display: block;
    background: #fff;
    border: 1px solid var(--docs-line);
    border-radius: 14px;
    padding: 22px 20px;
    text-decoration: none;
    transition: transform .2s, box-shadow .2s, border-color .2s;
}

.docs-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 14px 36px rgba(53,32,112,.12);
    border-color: rgba(53,32,112,.35);
}

.docs-card:focus-visible {
    outline: 3px solid var(--docs-gold);
    outline-offset: 2px;
}

.docs-card-ico {
    width: 42px; height: 42px;
    border-radius: 11px;
    background: rgba(53,32,112,.08);
    color: var(--docs-blue);
    display: flex; align-items: center; justify-content: center;
    font-size: 19px;
    margin-bottom: 14px;
}

.docs-card h3 {
    font-size: 15px;
    font-weight: 800;
    color: #1a1a2e;
    margin: 0 0 6px;
}

.docs-card p {
    font-size: 13px;
    color: var(--docs-muted);
    margin: 0 0 12px;
    line-height: 1.9;
}

.docs-card .docs-card-count {
    font-size: 11.5px;
    font-weight: 700;
    color: var(--docs-blue);
    background: rgba(238,187,102,.16);
    border-radius: 999px;
    padding: 2px 10px;
}

.docs-card.is-hidden { display: none; }

/* Quick-start path */
.docs-path {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 16px;
    counter-reset: step;
}

.docs-step {
    background: #fff;
    border: 1px solid var(--docs-line);
    border-radius: 14px;
    padding: 22px 20px 20px;
    position: relative;
}

.docs-step::before {
    counter-increment: step;
    content: counter(step);
    position: absolute;
    top: -14px; right: 20px;
    width: 30px; height: 30px;
    border-radius: 50%;
    background: var(--docs-blue);
    color: #fff;
    font-size: 13px;
    font-weight: 800;
    display: flex; align-items: center; justify-content: center;
}

.docs-step h3 { font-size: 14.5px; font-weight: 800; color: #1a1a2e; margin: 6px 0 8px; }
.docs-step p { font-size: 13px; color: var(--docs-muted); margin: 0 0 12px; line-height: 1.9; }

.docs-step a {
    font-size: 13px;
    font-weight: 700;
    color: var(--docs-blue);
    text-decoration: none;
}

.docs-step a:hover { text-decoration: underline; }

/* API teaser */
.docs-api {
    background: #fff;
    border: 1px solid var(--docs-line);
    border-radius: 16px;
    padding: 28px 26px;
}

.docs-api h3 { font-size: 16px; font-weight: 800; color: #1a1a2e; margin: 0 0 8px; }
.docs-api > p { font-size: 14px; color: var(--docs-muted); margin: 0 0 18px; line-height: 2; }

/* ─────────────────────────────────────────────────────────────
   3. Code block with copy
   ───────────────────────────────────────────────────────────── */

.docs-code {
    position: relative;
    background: #241548;
    border-radius: 12px;
    border: 1px solid rgba(238,187,102,.18);
    margin: 0;
    overflow: hidden;
}

.docs-code-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 9px 14px;
    background: rgba(0,0,0,.25);
    border-bottom: 1px solid rgba(255,255,255,.07);
}

.docs-code-lang {
    font-size: 11.5px;
    font-weight: 700;
    color: var(--docs-gold);
    letter-spacing: .4px;
}

.docs-code-copy {
    appearance: none;
    border: 1px solid rgba(255,255,255,.16);
    background: rgba(255,255,255,.06);
    color: rgba(255,255,255,.8);
    font-family: 'Vazirmatn', Tahoma, sans-serif;
    font-size: 11.5px;
    font-weight: 700;
    padding: 4px 12px;
    border-radius: 7px;
    cursor: pointer;
    transition: background .2s, color .2s;
}

.docs-code-copy:hover { background: rgba(238,187,102,.2); color: #fff; }
.docs-code-copy.is-done { background: rgba(93,202,139,.22); color: #7fe0a8; border-color: rgba(93,202,139,.4); }

.docs-code-copy:focus-visible {
    outline: 2px solid var(--docs-gold);
    outline-offset: 2px;
}

.docs-code pre {
    margin: 0;
    padding: 16px 18px;
    overflow-x: auto;
    font-size: 13px;
    line-height: 2;
    color: rgba(255,255,255,.92);
}

.docs-code code { background: none; padding: 0; font-size: inherit; }

/* inline code */
.docs-canvas :not(pre) > code {
    background: rgba(53,32,112,.07);
    border: 1px solid rgba(53,32,112,.1);
    border-radius: 6px;
    padding: 1px 7px;
    font-size: .9em;
    color: var(--docs-blue-dark);
}

/* ─────────────────────────────────────────────────────────────
   4. Article layout — sticky TOC + content
   ───────────────────────────────────────────────────────────── */

.docs-article { padding: 40px 0 80px; }

.docs-crumb {
    font-size: 12.5px;
    color: var(--docs-muted);
    margin-bottom: 20px;
    line-height: 2;
}

.docs-crumb a { color: var(--docs-blue); text-decoration: none; font-weight: 700; }
.docs-crumb a:hover { text-decoration: underline; }
.docs-crumb span[aria-current] { color: #1a1a2e; font-weight: 700; }

.docs-article-grid {
    display: grid;
    grid-template-columns: 232px minmax(0, 1fr);
    gap: 40px;
    align-items: start;
}

/* Sticky table of contents — auto-built from h2/h3 by script-docs.js */
.docs-toc {
    position: sticky;
    top: 96px;
    max-height: calc(100vh - 140px);
    overflow-y: auto;
    padding-left: 4px;
    border-inline-start: 1px solid var(--docs-line);
    padding-inline-start: 20px;
}

.docs-toc-title {
    font-size: 11.5px;
    font-weight: 800;
    color: var(--docs-muted);
    letter-spacing: .4px;
    margin: 0 0 12px;
}

.docs-toc ol { list-style: none; margin: 0; padding: 0; }

.docs-toc li { margin: 0 0 2px; }

.docs-toc a {
    display: block;
    font-size: 13px;
    color: var(--docs-muted);
    text-decoration: none;
    padding: 5px 10px;
    border-radius: 7px;
    line-height: 1.8;
    transition: color .15s, background .15s;
}

.docs-toc a:hover { color: var(--docs-blue); background: rgba(53,32,112,.05); }

.docs-toc a.is-active {
    color: var(--docs-blue);
    background: rgba(238,187,102,.18);
    font-weight: 700;
}

.docs-toc li[data-level="3"] a { padding-inline-start: 24px; font-size: 12.5px; }

.docs-toc:focus-visible {
    outline: 3px solid var(--docs-gold);
    outline-offset: 2px;
}

/* Reading progress bar */
.docs-progress {
    position: fixed;
    top: 0;
    inset-inline-start: 0;
    height: 3px;
    width: 0;
    background: linear-gradient(90deg, var(--docs-blue), var(--docs-gold));
    z-index: 99998;
    transition: width .1s linear;
}

/* Article content typography */
.docs-content { min-width: 0; }

.docs-content > h1 {
    font-size: clamp(1.5rem, 3.2vw, 2rem);
    font-weight: 800;
    color: #1a1a2e;
    margin: 0 0 12px;
    line-height: 1.5;
}

.docs-content > h2 {
    font-size: 1.3rem;
    font-weight: 800;
    color: #1a1a2e;
    margin: 40px 0 14px;
    padding-top: 8px;
    scroll-margin-top: 96px;
}

.docs-content > h3 {
    font-size: 1.05rem;
    font-weight: 700;
    color: #2a1a5a;
    margin: 28px 0 10px;
    scroll-margin-top: 96px;
}

.docs-content > p,
.docs-content > ul,
.docs-content > ol {
    font-size: 15px;
    color: #374151;
    line-height: 2.1;
    margin: 0 0 18px;
}

.docs-content > ul,
.docs-content > ol { padding-inline-start: 22px; }

.docs-content li { margin-bottom: 8px; }
.docs-content li::marker { color: var(--docs-blue); }

.docs-content img {
    max-width: 100%;
    height: auto;
    border-radius: 12px;
    border: 1px solid var(--docs-line);
    margin: 20px 0;
}

.docs-content a { color: var(--docs-blue); font-weight: 700; }
.docs-content a:hover { text-decoration: underline; }

.docs-content blockquote {
    margin: 20px 0;
    padding: 14px 18px;
    border-inline-start: 4px solid var(--docs-gold);
    background: rgba(238,187,102,.09);
    border-radius: 0 12px 12px 0;
    font-size: 14.5px;
    color: #4b5563;
}

/* Callouts */
.docs-callout {
    margin: 22px 0;
    padding: 16px 18px;
    border-radius: 12px;
    border: 1px solid var(--docs-line);
    background: #fff;
    font-size: 14px;
    line-height: 2;
}

.docs-callout-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 800;
    font-size: 13.5px;
    margin-bottom: 6px;
}

.docs-callout.is-tip    { border-color: rgba(30,126,79,.35);  background: rgba(30,126,79,.06); }
.docs-callout.is-tip    .docs-callout-title { color: var(--ok-ink); }
.docs-callout.is-note   { border-color: rgba(53,32,112,.28);  background: rgba(53,32,112,.05); }
.docs-callout.is-note   .docs-callout-title { color: var(--docs-blue); }
.docs-callout.is-warn   { border-color: rgba(217,119,6,.35);  background: rgba(217,119,6,.06); }
.docs-callout.is-warn   .docs-callout-title { color: var(--warn-ink); }
.docs-callout p { margin: 0; color: #4b5563; }

/* Article footer: feedback + prev/next */
.docs-helpful {
    margin-top: 40px;
    padding: 22px;
    border: 1px solid var(--docs-line);
    border-radius: 14px;
    background: #fff;
    text-align: center;
}

.docs-helpful p { font-size: 14px; font-weight: 700; color: #1a1a2e; margin: 0 0 14px; }

.docs-helpful-acts { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

.docs-helpful-btn {
    appearance: none;
    border: 1px solid rgba(53,32,112,.25);
    background: #fff;
    color: var(--docs-blue);
    font-family: 'Vazirmatn', Tahoma, sans-serif;
    font-size: 13px;
    font-weight: 700;
    padding: 9px 20px;
    border-radius: 10px;
    cursor: pointer;
    transition: background .2s, transform .2s;
}

.docs-helpful-btn:hover { background: rgba(53,32,112,.06); transform: translateY(-1px); }
.docs-helpful-btn.is-picked { background: rgba(238,187,102,.25); border-color: var(--docs-gold); }
.docs-helpful-btn:focus-visible { outline: 3px solid var(--docs-gold); outline-offset: 2px; }

.docs-pagenav {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
    margin-top: 28px;
}

.docs-pagenav a {
    display: block;
    padding: 16px 18px;
    border: 1px solid var(--docs-line);
    border-radius: 12px;
    background: #fff;
    text-decoration: none;
    transition: border-color .2s, transform .2s;
}

.docs-pagenav a:hover { border-color: rgba(53,32,112,.4); transform: translateY(-2px); }

.docs-pagenav .docs-pagenav-dir {
    display: block;
    font-size: 11.5px;
    color: var(--docs-muted);
    margin-bottom: 4px;
}

.docs-pagenav .docs-pagenav-name {
    display: block;
    font-size: 14px;
    font-weight: 800;
    color: var(--docs-blue);
}

.docs-pagenav a:last-child { text-align: left; }

/* Empty search state */
.docs-empty {
    text-align: center;
    padding: 48px 20px;
    color: var(--docs-muted);
    font-size: 14px;
}

.docs-empty strong { display: block; color: #1a1a2e; font-size: 15px; margin-bottom: 6px; }

/* ─────────────────────────────────────────────────────────────
   5. Responsive
   ───────────────────────────────────────────────────────────── */

@media (max-width: 960px) {
    .docs-article-grid { grid-template-columns: 1fr; gap: 24px; }
    .docs-toc {
        position: static;
        max-height: none;
        border-inline-start: none;
        padding-inline-start: 0;
        border-top: 1px solid var(--docs-line);
        padding-top: 16px;
    }
}

@media (max-width: 640px) {
    .docs-hero { padding: 48px 0 56px; }
    .docs-body { padding: 40px 0 56px; }
    .docs-pagenav { grid-template-columns: 1fr; }
    .docs-search kbd { display: none; }
    .docs-search input { padding-inline-end: 44px; }
}

/* ─────────────────────────────────────────────────────────────
   6. Reduced motion
   ───────────────────────────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
    .docs-card,
    .docs-pagenav a,
    .docs-helpful-btn { transition: none; }
    .docs-card:hover,
    .docs-pagenav a:hover,
    .docs-helpful-btn:hover { transform: none; }
    .docs-progress { transition: none; }
}

/* ─────────────────────────────────────────────────────────────
   7. ابزارهای کمکی — برچسب دسترس‌پذیر برای ورودی جست‌وجو
   (قانون I.1: برچسب واقعی، نه placeholder، تا صفحه‌خوان درست بخواند)
   ───────────────────────────────────────────────────────────── */

.docs-canvas .docs-sr {
    position: absolute !important;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.docs-canvas .docs-sr:focus {
    position: static !important;
    width: auto; height: auto;
    margin: 0;
    overflow: visible;
    clip: auto;
    white-space: normal;
}

/* کارت مقاله — همان چیدمان کارت ماژول، با ریزفعالت کمتر */
.docs-article-card {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.docs-article-card .docs-card-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: auto;
    padding-top: 4px;
}

.docs-article-card .docs-card-module {
    font-size: 11.5px;
    font-weight: 700;
    color: var(--docs-blue);
    background: rgba(53,32,112,.07);
    border-radius: 999px;
    padding: 2px 10px;
}

.docs-article-card .docs-card-read {
    font-size: 11.5px;
    color: var(--docs-muted);
}

/* جدول داخل مقاله */
.docs-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 20px 0;
    font-size: 13.5px;
    background: #fff;
    border: 1px solid var(--docs-line);
    border-radius: 12px;
    overflow: hidden;
}

.docs-content th,
.docs-content td {
    padding: 11px 14px;
    text-align: right;
    border-bottom: 1px solid var(--docs-line);
    line-height: 1.9;
}

.docs-content th {
    background: rgba(53,32,112,.05);
    font-weight: 800;
    color: var(--docs-blue-dark);
}

.docs-content tr:last-child td { border-bottom: 0; }

/* فراخوانی اقدام پایین صفحهٔ فرود */
.docs-cta {
    background: linear-gradient(160deg, #2a1a5a 0%, #352070 60%, #241548 100%);
    border-radius: 18px;
    padding: 40px 32px;
    text-align: center;
    color: #fff;
}

.docs-cta h2 {
    font-size: clamp(1.2rem, 2.6vw, 1.5rem);
    font-weight: 800;
    color: #fff;
    margin: 0 0 10px;
}

.docs-cta p {
    font-size: 14.5px;
    color: rgba(255,255,255,.78);
    margin: 0 auto 22px;
    max-width: 560px;
    line-height: 2;
}

.docs-cta-acts { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }

.docs-cta-btn {
    display: inline-block;
    padding: 11px 24px;
    border-radius: 11px;
    font-size: 13.5px;
    font-weight: 800;
    text-decoration: none;
    font-family: 'Vazirmatn', Tahoma, sans-serif;
    transition: transform .2s, background .2s, border-color .2s;
}

.docs-cta-btn.is-primary {
    background: var(--docs-gold);
    color: #2a1a5a;
}

.docs-cta-btn.is-primary:hover { transform: translateY(-2px); background: #f5cd85; }

.docs-cta-btn.is-ghost {
    border: 1px solid rgba(255,255,255,.28);
    color: rgba(255,255,255,.9);
}

.docs-cta-btn.is-ghost:hover { border-color: var(--docs-gold); color: #fff; }

.docs-cta-btn:focus-visible { outline: 3px solid var(--docs-gold); outline-offset: 3px; }

/* متادیتای مقاله */
.docs-article-meta {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    font-size: 12.5px;
    color: var(--docs-muted);
    margin-bottom: 26px;
}

.docs-article-meta .docs-article-module {
    font-weight: 800;
    color: var(--docs-blue);
    background: rgba(238,187,102,.16);
    border-radius: 999px;
    padding: 3px 12px;
}

/* پیام «مقاله در حال تکمیل» */
.docs-wip {
    margin: 22px 0;
    padding: 16px 18px;
    border-radius: 12px;
    border: 1px dashed rgba(53,32,112,.3);
    background: rgba(53,32,112,.04);
    font-size: 14px;
    line-height: 2;
    color: #4b5563;
}

@media (max-width: 640px) {
    .docs-cta { padding: 32px 20px; }
}
