/* Article step blocks: labels + copy button — shared by docs/*.html */
.step-block { margin: 1.35rem 0; }
.step-block pre {
  margin-top: 0;
  border-top-left-radius: 0;
  border-top-right-radius: 0;
  position: relative;
}
.step-header {
  display: flex;
  align-items: stretch;
  justify-content: space-between;
  gap: 0;
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: 8px 8px 0 0;
  overflow: hidden;
  font-family: var(--font-sans, system-ui, sans-serif);
}
.step-label {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 0.78rem;
  font-weight: 650;
  padding: 0.45rem 0.75rem;
  line-height: 1.4;
  border: none;
  border-radius: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
  white-space: normal;
}
.step-label--read {
  background: color-mix(in srgb, #9ca3af 18%, var(--surface));
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: 8px 8px 0 0;
}
.step-block--read .step-header { display: block; border: none; }
.step-block--read .step-label--read { display: block; }
.step-label--copy { background: color-mix(in srgb, #3b82f6 14%, var(--surface)); color: var(--accent, #2563eb); }
.step-label--run { background: color-mix(in srgb, #22c55e 14%, var(--surface)); color: #15803d; }
.step-label--sql { background: color-mix(in srgb, #f59e0b 16%, var(--surface)); color: #b45309; }
[data-theme="dark"] .step-label--run { color: #86efac; }
[data-theme="dark"] .step-label--sql { color: #fcd34d; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .step-label--run { color: #86efac; }
  :root:not([data-theme="light"]) .step-label--sql { color: #fcd34d; }
}
.step-copy-btn {
  flex-shrink: 0;
  align-self: stretch;
  padding: 0 0.85rem;
  border: none;
  border-left: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.step-copy-btn:hover { background: var(--surface-hover, #f0f2f5); color: var(--accent, #2563eb); }
.step-copy-btn.copied { color: #15803d; }
[data-theme="dark"] .step-copy-btn.copied { color: #86efac; }

.howto-legend {
  font-family: var(--font-sans, system-ui, sans-serif);
  font-size: 0.92rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.1rem 1.25rem;
  margin: 1.5rem 0 2rem;
}
.howto-legend h2 { font-size: 1.15rem; margin: 0 0 0.75rem; font-family: inherit; }
.howto-legend ul { margin: 0.5rem 0 0; padding-left: 1.2rem; }
.howto-legend li { margin: 0.4rem 0; }
.howto-swatch {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  margin-right: 0.35rem;
  vertical-align: middle;
}
.swatch-read { background: #e5e7eb; color: #374151; }
.swatch-copy { background: #dbeafe; color: #1e40af; }
.swatch-run { background: #dcfce7; color: #166534; }
.swatch-sql { background: #fef3c7; color: #92400e; }
.swatch-output { background: #e2e8f0; color: #334155; }
[data-theme="dark"] .swatch-read { background: #374151; color: #e5e7eb; }
[data-theme="dark"] .swatch-copy { background: #1e3a5f; color: #93c5fd; }
[data-theme="dark"] .swatch-run { background: #14532d; color: #86efac; }
[data-theme="dark"] .swatch-sql { background: #78350f; color: #fcd34d; }
[data-theme="dark"] .swatch-output { background: #334155; color: #e2e8f0; }
.part-goal {
  font-family: var(--font-sans, system-ui, sans-serif);
  font-size: 0.92rem;
  background: color-mix(in srgb, var(--accent, #2563eb) 8%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--accent, #2563eb) 28%, var(--border));
  border-radius: 8px;
  padding: 0.9rem 1.1rem;
  margin: 0.75rem 0 1.25rem;
}
.part-goal strong { color: var(--accent, #2563eb); }

.read-time {
  font-family: var(--font-sans, system-ui, sans-serif);
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text-muted, #5c6370);
  margin: 0.2rem 0 0.85rem;
}
.doc-card-tags {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0.5rem;
}
.doc-card-tags .doc-tag { margin-bottom: 0; }
.doc-read {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 500;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  border: 1px solid var(--border, #e2e6ec);
  color: var(--text-muted, #5c6370);
  white-space: nowrap;
}
.intro-tag-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.85rem;
}
.intro-tag-row .intro-tag { margin-bottom: 0; }
.intro-tag-row .js-read-time {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted, #5c6370);
}

/* Do not set max-width here — each article keeps ~740px via its own stylesheet. */
.article-wrap,
main.article-wrap {
  direction: ltr;
  text-align: left;
  min-width: 0;
  box-sizing: border-box;
}

.docs-list,
.doc-card,
.intro,
#quiz-area {
  direction: ltr;
  text-align: left;
}

code {
  overflow-wrap: anywhere;
  word-break: break-word;
}
pre code {
  overflow-wrap: normal;
  word-break: normal;
}

/* Command sample output (do not paste into a terminal) */
.cmd-output {
  margin: 0.35rem 0 1.5rem;
  max-width: 100%;
  min-width: 0;
}
.cmd-output-caption {
  font-family: var(--font-sans, system-ui, sans-serif);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  margin: 0 0 0.4rem;
}
.cmd-output pre {
  margin: 0 0 0.65rem;
  border-left: 4px solid #64748b;
  background: var(--code-bg, #f5f5f5);
  overflow-x: auto;
  white-space: pre;
  word-wrap: normal;
  font-size: 13px;
  max-width: 100%;
}
.cmd-output-explain {
  font-family: var(--font-sans, system-ui, sans-serif);
  font-size: 0.9rem;
  margin: 0;
  color: var(--text);
  line-height: 1.55;
  overflow-wrap: anywhere;
}
.cmd-output-explain code {
  overflow-wrap: anywhere;
  word-break: break-word;
}

.table-scroll {
  display: block;
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 1.25rem 0;
  min-width: 0;
}

.back-to-toc {
  position: fixed;
  z-index: 90;
  inset-inline-end: 1rem;
  bottom: 1.15rem;
  width: 2.75rem;
  height: 2.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  border: 1px solid var(--border, #e2e6ec);
  background: var(--surface, #fff);
  color: var(--accent, #2563eb);
  box-shadow: 0 6px 20px color-mix(in srgb, #000 14%, transparent);
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity 0.2s, transform 0.2s;
  text-decoration: none;
}
.back-to-toc.is-visible {
  opacity: 1;
  pointer-events: auto;
  transform: none;
}
.back-to-toc:hover { color: var(--accent-hover, #1d4ed8); }
.back-to-toc svg { width: 1.35rem; height: 1.35rem; display: block; }

/* Header / footer back links */
a.back-home,
a.nav-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--font-sans, var(--font, "Vazirmatn", system-ui, sans-serif));
  font-size: 0.8125rem;
  font-weight: 500;
  line-height: 1.35;
  letter-spacing: 0;
  color: var(--text) !important;
  text-decoration: none !important;
  padding: 0.5rem 0.95rem 0.5rem 0.75rem;
  border-radius: 999px;
  border: 1px solid var(--border, #e2e6ec);
  background: var(--surface, #fff);
  box-shadow: 0 1px 2px color-mix(in srgb, #000 5%, transparent);
  transition:
    color 0.15s ease,
    border-color 0.15s ease,
    background 0.15s ease,
    box-shadow 0.15s ease,
    transform 0.15s ease;
  max-width: 100%;
}
a.back-home:hover,
a.nav-chip:hover {
  color: var(--accent, #2563eb) !important;
  border-color: color-mix(in srgb, var(--accent, #2563eb) 42%, var(--border, #e2e6ec));
  background: color-mix(in srgb, var(--accent, #2563eb) 9%, var(--surface, #fff));
  box-shadow: 0 6px 18px color-mix(in srgb, var(--accent, #2563eb) 16%, transparent);
  transform: translateY(-1px);
}
a.back-home:active,
a.nav-chip:active {
  transform: translateY(0);
  box-shadow: 0 1px 2px color-mix(in srgb, #000 6%, transparent);
}
.nav-chip-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.35rem;
  height: 1.35rem;
  flex-shrink: 0;
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent, #2563eb) 12%, transparent);
  color: var(--accent, #2563eb);
}
.nav-chip-icon svg {
  width: 0.85rem;
  height: 0.85rem;
  display: block;
}
html[dir="rtl"] a.nav-chip[data-nav-kind="back"] .nav-chip-icon svg {
  transform: scaleX(-1);
}

/*
 * Site chrome follows html[dir] (FA = RTL).
 * Docs listing + article body stay English LTR; footer/header flip back to chrome dir.
 */
html[dir="rtl"] main.docs-listing,
html[dir="rtl"] main.article-wrap,
html[dir="rtl"] main,
html[dir="rtl"] .intro {
  direction: ltr;
  text-align: left;
  unicode-bidi: isolate;
}
html[dir="rtl"] .site-header,
html[dir="rtl"] body > header,
html[dir="rtl"] .article-footer,
html[dir="rtl"] body > footer {
  direction: rtl;
  unicode-bidi: isolate;
  text-align: start;
}
.nav-chip-label {
  overflow-wrap: anywhere;
  min-width: 0;
  font-family: inherit;
  font-weight: inherit;
}
.article-footer {
  gap: 0.75rem !important;
  align-items: center;
}
footer a.back-home,
footer a.nav-chip {
  margin: 0.25rem;
}

@media (max-width: 720px) {
  a.back-home,
  a.nav-chip {
    font-size: 0.75rem;
    padding: 0.45rem 0.8rem 0.45rem 0.65rem;
  }
  .site-header-inner,
  .header-inner {
    gap: 0.65rem;
  }
}

.directive-box,
.formula,
.example,
.warn-box,
.part-goal,
.howto-legend {
  max-width: 100%;
  overflow-wrap: break-word;
  word-wrap: break-word;
  min-width: 0;
}
.directive-box h4,
.directive-box code,
.formula,
.example code {
  overflow-wrap: anywhere;
  word-break: break-word;
}
.directive-box h4 {
  max-width: 100%;
  font-size: 0.95rem;
  line-height: 1.45;
  margin: 0 0 0.5rem;
}
.directive-box h4 code {
  display: inline;
  font-size: 0.88em;
  white-space: normal;
}

/* Wide reference tables: card stack on narrow screens when cells have data-label */
@media (max-width: 860px) {
  .table-scroll--stack {
    overflow: visible;
  }
  .ref-table.stack-mobile,
  table.stack-mobile,
  .ref-table.stack-mobile thead,
  table.stack-mobile thead,
  .ref-table.stack-mobile tbody,
  table.stack-mobile tbody {
    display: block;
    width: 100%;
    max-width: 100%;
  }
  .ref-table.stack-mobile thead,
  table.stack-mobile thead {
    display: none;
  }
  .ref-table.stack-mobile tr,
  table.stack-mobile tr {
    display: block;
    width: 100%;
    box-sizing: border-box;
    margin: 0 0 0.85rem;
    padding: 0.75rem 0.85rem;
    border: 1px solid var(--border, #e2e6ec);
    border-radius: 8px;
    background: var(--surface, #fff);
  }
  .ref-table.stack-mobile td,
  table.stack-mobile td,
  .ref-table.stack-mobile th,
  table.stack-mobile th {
    display: block;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    border: none;
    padding: 0.35rem 0;
    text-align: start !important;
    font-size: 0.85rem;
    line-height: 1.45;
    overflow-wrap: anywhere;
    word-break: break-word;
    white-space: normal;
  }
  .ref-table.stack-mobile td + td,
  table.stack-mobile td + td {
    border-top: 1px solid var(--border, #e2e6ec);
    margin-top: 0.35rem;
    padding-top: 0.5rem;
  }
  .ref-table.stack-mobile td[data-label]::before,
  table.stack-mobile td[data-label]::before {
    content: attr(data-label);
    display: block;
    font-family: var(--font-sans, system-ui, sans-serif);
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    color: var(--text-muted, #5c6370);
    margin-bottom: 0.2rem;
  }
}

@media (max-width: 720px) {
  .step-header {
    flex-direction: column;
    align-items: stretch;
    flex-wrap: nowrap;
  }
  .step-label {
    display: block;
    width: 100%;
    box-sizing: border-box;
    font-size: 0.7rem;
    padding: 0.55rem 0.7rem;
    line-height: 1.45;
  }
  .step-label--run,
  .step-label--copy,
  .step-label--sql,
  .step-label--read {
    /* Keep colored bar fully visible; never clip label text */
    overflow: visible;
  }
  .step-copy-btn {
    width: 100%;
    border-left: none;
    border-top: 1px solid var(--border);
    padding: 0.5rem 0.75rem;
    align-self: stretch;
  }
  .directive-box,
  .formula,
  .example,
  .warn-box,
  .part-goal {
    padding: 12px;
    font-size: 15px;
  }
  .howto-legend {
    padding: 0.9rem 1rem;
  }
  .cmd-output pre {
    font-size: 12px;
    white-space: pre;
  }
  .directive-box h4 {
    font-size: 0.82rem;
  }
  pre {
    font-size: 12.5px;
    padding: 12px;
  }

  .table-scroll:not(.table-scroll--stack) {
    margin: 1rem 0;
  }

  .table-scroll .ref-table:not(.stack-mobile),
  .table-scroll table:not(.stack-mobile) {
    font-size: 0.75rem;
  }
  .table-scroll .ref-table:not(.stack-mobile) th,
  .table-scroll .ref-table:not(.stack-mobile) td,
  .table-scroll table:not(.stack-mobile) th,
  .table-scroll table:not(.stack-mobile) td {
    padding: 0.4rem 0.35rem;
    white-space: normal;
    overflow-wrap: anywhere;
  }
}
