/* Guide pages — typography and components on top of the landing page's
   styles.css. All colors inherit the theme variables (contrast verified in
   docs/accessibility.md); layout uses logical properties for RTL. */

.guide {
  max-width: 820px;
  margin-inline: auto;
  padding-inline: 1rem;
  padding-bottom: 3rem;
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
}

@media (min-width: 900px) {
  .guide {
    grid-template-columns: 240px 1fr;
    align-items: start;
  }
  .toc {
    position: sticky;
    top: 1rem;
  }
}

/* --- table of contents ------------------------------------------------ */

.toc {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem 1.25rem;
  font-size: 0.92rem;
}

.toc-title {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 0.5rem;
}

.toc ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.toc a {
  color: var(--text);
  text-decoration: none;
  display: inline-block;
  min-height: 24px;
}

.toc a:hover {
  text-decoration: underline;
}

.toc-l3 {
  padding-inline-start: 1rem;
  font-size: 0.88rem;
}

/* --- guide body -------------------------------------------------------- */

.guide-body {
  min-width: 0;
  font-size: 1.02rem;
  line-height: 1.65;
}

.guide-body h1 {
  font-size: clamp(1.9rem, 5vw, 2.6rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 0.75rem;
  line-height: 1.2;
}

.guide-body h2 {
  font-size: 1.45rem;
  font-weight: 700;
  margin: 2.25rem 0 0.75rem;
  padding-bottom: 0.3rem;
  border-bottom: 1px solid var(--border);
}

.guide-body h3 {
  font-size: 1.15rem;
  font-weight: 700;
  margin: 1.5rem 0 0.5rem;
}

.guide-body h4 {
  font-size: 1rem;
  font-weight: 700;
  margin: 1.25rem 0 0.5rem;
}

.guide-body p {
  margin: 0.6rem 0;
}

.guide-body ul,
.guide-body ol {
  margin: 0.6rem 0;
  padding-inline-start: 1.6rem;
}

.guide-body li {
  margin: 0.3rem 0;
}

.guide-body strong {
  font-weight: 700;
}

/* --- code --------------------------------------------------------------- */

.guide-body code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.88em;
  background: var(--code-bg, var(--panel));
  color: var(--text);
  padding: 0.1em 0.35em;
  border-radius: 6px;
}

.guide-body pre {
  background: var(--code-bg, var(--panel));
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.9rem 1rem;
  overflow-x: auto;
  margin: 0.75rem 0;
  line-height: 1.5;
}

.guide-body pre code {
  background: none;
  padding: 0;
  font-size: 0.9rem;
}

/* --- example code blocks (```epher / ```sh) ------------------------------

   What the reader types: highlighted code plus a copy button at the end.
   Token colors are theme vars; contrast vs --panel (WCAG 1.4.3, ≥ 4.5:1):
     light: kw #a626a4 5.6:1, num/const #8a5f01 5.2:1, fn #2456b8 6.2:1,
            str #1a7f37 4.7:1
     dark:  kw #d386d4 5.4:1, num/const #d19a66 5.7:1, fn #61afef 5.9:1,
            str #56b6c2 5.9:1                                                            */

:root {
  --tok-kw: #a626a4;
  --tok-num: #8a5f01;
  --tok-fn: #2456b8;
  --tok-str: #1a7f37;
}

[data-theme="dark"] {
  --tok-kw: #d386d4;
  --tok-num: #d19a66;
  --tok-fn: #61afef;
  --tok-str: #56b6c2;
}

.example {
  margin: 0.75rem 0;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--code-bg, var(--panel));
  overflow: hidden; /* keep the pre inside the rounded corners */
}

.example pre {
  margin: 0;
  border: none;
  border-radius: 0;
  background: none;
  direction: ltr; /* code stays LTR inside the RTL (Arabic) page */
  text-align: left;
}

.example-bar {
  display: flex;
  justify-content: flex-end; /* inline end in both LTR and RTL */
  padding: 0.3rem 0.45rem;
  border-top: 1px solid var(--border);
}

.copy-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  min-height: 32px; /* target size (WCAG 2.5.8, ≥ 24px) */
  padding: 0.2rem 0.75rem;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
}

.copy-btn:hover {
  background: var(--panel);
}

.copy-btn svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* success state: icon and label swap (never color alone, WCAG 1.4.1) */
.copy-btn .icon-check {
  display: none;
}

.copy-btn.copied .icon-copy {
  display: none;
}

.copy-btn.copied .icon-check {
  display: block;
  stroke: var(--link); /* 5.1:1 light / 7.8:1 dark vs --bg */
}

.example .tok-kw { color: var(--tok-kw); }
.example .tok-num { color: var(--tok-num); }
.example .tok-fn { color: var(--tok-fn); }
.example .tok-str { color: var(--tok-str); }

/* --- notes (blockquote) ------------------------------------------------- */

.guide-body blockquote {
  margin: 1rem 0;
  padding: 0.6rem 1rem;
  border-inline-start: 4px solid var(--accent);
  background: var(--panel);
  border-radius: 0 12px 12px 0;
}

[dir="rtl"] .guide-body blockquote {
  border-radius: 12px 0 0 12px;
}

.guide-body blockquote p {
  margin: 0.25rem 0;
  color: var(--text);
}

/* --- tables ------------------------------------------------------------- */

.table-wrap {
  overflow-x: auto;
  margin: 0.75rem 0;
  border: 1px solid var(--border);
  border-radius: 12px;
}

.guide-body table {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.95rem;
}

.guide-body th,
.guide-body td {
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--border);
  text-align: start;
  vertical-align: top;
}

.guide-body th {
  background: var(--panel);
  font-weight: 700;
}

.guide-body tr:last-child td {
  border-bottom: none;
}

/* --- kbd keys ----------------------------------------------------------- */

.guide-body kbd {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.85em;
  background: var(--panel);
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 6px;
  padding: 0.1em 0.45em;
}
