/* ============================================================
   docs.css — Documentation page styles.
   Uses only CSS variables from variables.css — same system
   as changelog.css. No hardcoded colours anywhere.
   ============================================================ */

/* ── Page header ── */
.doc-page-header {
  margin-bottom: 0.5rem;
}

.doc-page-title {
  font-size: clamp(1.7rem, 4vw, 2.4rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.15;
  color: var(--text);
}

/* ── Body container ── */
.doc-body {
  max-width: 720px;
}

/* ════════════════════════════════════════════════════════════
   HEADINGS
   ════════════════════════════════════════════════════════════ */
.doc-heading--1 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
  margin: 2.4rem 0 0.8rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border);
}
.doc-heading--1:first-child { border-top: none; padding-top: 0; margin-top: 0; }

.doc-heading--2 {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text);
  margin: 2.2rem 0 0.7rem;
  padding-top: 1.8rem;
  border-top: 1px solid var(--border);
}
.doc-heading--2:first-child { border-top: none; padding-top: 0; margin-top: 0; }

.doc-heading--3 {
  font-size: 0.97rem;
  font-weight: 700;
  color: var(--text);
  margin: 1.6rem 0 0.5rem;
}

.doc-heading--4 {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--accent2);
  margin: 1.2rem 0 0.4rem;
  letter-spacing: 0.02em;
}

/* ════════════════════════════════════════════════════════════
   PARAGRAPH
   ════════════════════════════════════════════════════════════ */
.doc-paragraph {
  font-size: 0.88rem;
  line-height: 1.75;
  color: var(--muted);
  margin: 0 0 0.9rem;
}

/* ════════════════════════════════════════════════════════════
   INLINE ELEMENTS  (code, bold, links)
   Same rules as changelog — uses var(--accent2), var(--surface)
   ════════════════════════════════════════════════════════════ */
.doc-paragraph code,
.doc-list-item code,
.doc-note-text code,
.doc-table th code,
.doc-table td code,
.doc-heading--1 code,
.doc-heading--2 code,
.doc-heading--3 code,
.doc-heading--4 code {
  font-family: 'SFMono-Regular', 'Consolas', 'Liberation Mono', monospace;
  font-size: 0.82em;
  font-weight: 500;
  color: var(--accent2);
  background: color-mix(in srgb, var(--accent) 10%, var(--surface));
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.05em 0.35em;
  white-space: nowrap;
  display: inline-block;
  vertical-align: baseline;
  line-height: 1.5;
}

/* Inside table cells, code stays as one unit but cell text can still wrap around it */
.doc-table th code,
.doc-table td code {
  white-space: nowrap;
  display: inline-block;
  word-break: normal;
  overflow-wrap: normal;
}

[data-theme="light"] .doc-paragraph code,
[data-theme="light"] .doc-list-item code,
[data-theme="light"] .doc-note-text code,
[data-theme="light"] .doc-table td code {
  background: color-mix(in srgb, var(--accent) 10%, var(--card));
}

.doc-paragraph a,
.doc-list-item a,
.doc-note-text a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
  transition: border-color 0.18s, color 0.18s;
}
.doc-paragraph a:hover,
.doc-list-item a:hover,
.doc-note-text a:hover {
  color: var(--accent2);
  border-bottom-color: var(--accent2);
}

/* ════════════════════════════════════════════════════════════
   LIST
   ════════════════════════════════════════════════════════════ */
.doc-list {
  list-style: none;
  padding: 0;
  margin: 0 0 1rem;
}

.doc-list-item {
  display: block;
  position: relative;
  padding: 0.35rem 1rem 0.35rem 2.2rem;
  font-size: 0.88rem;
  line-height: 1.65;
  color: var(--muted);
  transition: background 0.15s;
}
.doc-list-item:hover {
  background: color-mix(in srgb, var(--accent) 5%, transparent);
}

/* Bullet — accent colour, same as changelog section items */
.doc-list-item::before {
  content: '';
  position: absolute;
  left: 0.85rem;
  top: 0.72em;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
  opacity: 0.7;
  transition: opacity 0.2s;
}
.doc-list-item:hover::before { opacity: 1; }

.doc-list-item-text { display: inline; }

/* Ordered list */
.doc-list--ordered {
  counter-reset: ol-counter;
}
.doc-list--ordered .doc-list-item {
  counter-increment: ol-counter;
  padding-left: 2.4rem;
}
.doc-list--ordered .doc-list-item::before {
  content: counter(ol-counter);
  background: transparent;
  border-radius: 0;
  width: auto;
  height: auto;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--accent);
  opacity: 1;
  top: 0.42em;
  left: 0.6rem;
}

/* ════════════════════════════════════════════════════════════
   CODE BLOCK
   ════════════════════════════════════════════════════════════ */
.doc-code-wrap {
  position: relative;
  margin: 0.8rem 0 1.2rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--card);
  overflow: hidden;
  transition: border-color 0.22s;
}
.doc-code-wrap:hover {
  border-color: color-mix(in srgb, var(--accent) 40%, var(--border));
}

.doc-code-lang {
  display: block;
  padding: 0.32rem 1rem;
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent);
  opacity: 0.7;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--accent) 5%, var(--surface));
}

.doc-code-wrap pre {
  margin: 0;
  padding: 1rem 1.2rem;
  overflow-x: auto;
  background: transparent;
}

.doc-code-wrap pre code {
  font-family: 'SFMono-Regular', 'Consolas', 'Liberation Mono', monospace;
  font-size: 0.8rem;
  line-height: 1.65;
  color: var(--text);
  background: none;
  border: none;
  padding: 0;
  white-space: pre;
  display: block;
  border-radius: 0;
}

/* ════════════════════════════════════════════════════════════
   NOTE / CALLOUT
   ════════════════════════════════════════════════════════════ */
.doc-note {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  margin: 0.8rem 0 1rem;
  padding: 0.75rem 1rem;
  background: color-mix(in srgb, var(--accent) 6%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--accent) 25%, var(--border));
  border-left: 3px solid var(--accent);
  border-radius: 0 6px 6px 0;
  font-size: 0.83rem;
  line-height: 1.6;
  color: var(--muted);
}

.doc-note-icon {
  flex-shrink: 0;
  color: var(--accent);
  margin-top: 0.1em;
  opacity: 0.8;
}

.doc-note-text { flex: 1; }

/* ════════════════════════════════════════════════════════════
   TABLE
   ════════════════════════════════════════════════════════════ */
.doc-table-wrap {
  margin: 0.8rem 0 1.2rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  overflow-x: auto;
  transition: border-color 0.22s;
}
.doc-table-wrap:hover {
  border-color: color-mix(in srgb, var(--accent) 40%, var(--border));
}

.doc-table {
  width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
  font-size: 0.82rem;
}
/* 3-column tables: first col wider, other two share remaining space */
.doc-table th:first-child,
.doc-table td:first-child { width: 42%; }
.doc-table th:nth-child(2),
.doc-table td:nth-child(2) { width: 26%; }
.doc-table th:nth-child(3),
.doc-table td:nth-child(3) { width: 32%; }

/* 4-column tables */
.doc-table:has(th:nth-child(4)) {
  table-layout: auto;
}
.doc-table:has(th:nth-child(4)) th:nth-child(1),
.doc-table:has(th:nth-child(4)) td:nth-child(1) { width: 16%; }
.doc-table:has(th:nth-child(4)) th:nth-child(2),
.doc-table:has(th:nth-child(4)) td:nth-child(2) { width: 42%; }
.doc-table:has(th:nth-child(4)) th:nth-child(3),
.doc-table:has(th:nth-child(4)) td:nth-child(3) { width: 21%; }
.doc-table:has(th:nth-child(4)) th:nth-child(4),
.doc-table:has(th:nth-child(4)) td:nth-child(4) { width: 21%; }


.doc-table th {
  padding: 0.6rem 1rem;
  text-align: left;
  font-weight: 700;
  color: var(--text);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  word-break: break-word;
}

.doc-table td {
  padding: 0.5rem 1rem;
  color: var(--muted);
  border-bottom: 1px solid color-mix(in srgb, var(--border) 50%, transparent);
  line-height: 1.55;
  word-break: break-word;
  overflow-wrap: break-word;
}

.doc-table tr:last-child td { border-bottom: none; }
.doc-table tr:hover td {
  background: color-mix(in srgb, var(--accent) 5%, transparent);
}

/* ════════════════════════════════════════════════════════════
   RULE
   ════════════════════════════════════════════════════════════ */
.doc-rule {
  height: 1px;
  background: var(--border);
  margin: 1.8rem 0;
}

/* ════════════════════════════════════════════════════════════
   MOBILE
   ════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
  .doc-body { max-width: 100%; }
  .doc-heading--2 { font-size: 1.05rem; }
  .doc-heading--3 { font-size: 0.92rem; }
  .doc-list-item  { padding: 0.3rem 0.8rem 0.3rem 1.8rem; }
  .doc-list-item::before { left: 0.55rem; }
  .doc-code-wrap pre { padding: 0.75rem 0.9rem; }
  .doc-table th,
  .doc-table td  { padding: 0.45rem 0.75rem; }
}

/* ── Prev / Next page navigation ── */
.doc-page-nav {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

.doc-nav-link {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  padding: 0.7rem 1rem;
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  font-family: inherit;
  text-align: left;
  max-width: 48%;
  transition: border-color 0.2s, background 0.2s;
}
.doc-nav-link:hover {
  border-color: var(--accent);
  background: var(--glow);
}
.doc-nav-link--next {
  margin-left: auto;
  text-align: right;
  align-items: flex-end;
}

/* Label ("← Назад" / "Далее →") */
.doc-nav-link > .t {
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
}

/* Page title inside nav button */
.doc-nav-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
}

@media (max-width: 600px) {
  .doc-page-nav { flex-direction: column; }
  .doc-nav-link { max-width: 100%; }
  .doc-nav-link:last-child { margin-left: 0; }
}

/* Fragment wrapper — small top padding so first heading isn't flush to top */
.doc-fragment {
  padding-top: 0;
}

/* First heading inside doc-body has no top margin/border/padding */
.doc-body > .doc-heading--2:first-child,
.doc-body > .doc-heading--3:first-child,
.doc-body > .doc-heading--4:first-child,
.doc-body > h2:first-child,
.doc-body > h3:first-child,
.doc-body > h4:first-child {
  margin-top: 0;
  padding-top: 0;
  border-top: none;
}

/* Also kill top margin on doc-body itself */
.doc-body {
  margin-top: 0;
}

/* ── C# syntax highlighting ── */
.doc-code-wrap pre code .hl-k { color: #4ccbad !important; }
.doc-code-wrap pre code .hl-t { color: #7dd3f0 !important; }
.doc-code-wrap pre code .hl-s { color: #ce9178 !important; }
.doc-code-wrap pre code .hl-c { color: #6a9955 !important; font-style: italic; }
.doc-code-wrap pre code .hl-a { color: #dcdcaa !important; }

[data-theme="light"] .doc-code-wrap pre code .hl-k { color: #0a6e5a !important; }
[data-theme="light"] .doc-code-wrap pre code .hl-t { color: #1a6fa8 !important; }
[data-theme="light"] .doc-code-wrap pre code .hl-s { color: #a31515 !important; }
[data-theme="light"] .doc-code-wrap pre code .hl-c { color: #4a7c3f !important; }
[data-theme="light"] .doc-code-wrap pre code .hl-a { color: #795e26 !important; }

/* ════════════════════════════════════════════════════════════
   DIAGRAMS
   ════════════════════════════════════════════════════════════ */

/* ── Shared ── */
.dgm-flow-label code,
.dgm-tl-label,
.dgm-hier-box code,
.dgm-arch-item {
  font-family: 'SFMono-Regular', 'Consolas', 'Liberation Mono', monospace;
  font-size: 0.8rem;
}

/* ── Flow diagram ── */
.dgm-flow-title {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 0.6rem;
  letter-spacing: 0.02em;
}

.dgm-flow {
  display: flex;
  flex-direction: column;
  margin: 0.8rem 0 1.2rem;
  padding: 1.2rem 1.4rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.dgm-flow-item {
  display: flex;
  gap: 0;
  min-height: 2.2rem;
}

.dgm-flow-connector {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 20px;
  flex-shrink: 0;
}

.dgm-flow-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  margin-top: 0.4rem;
  flex-shrink: 0;
  z-index: 1;
}
.dgm-flow-dot--child {
  width: 8px;
  height: 8px;
  background: color-mix(in srgb, var(--accent) 60%, var(--border));
}

.dgm-flow-line {
  width: 2px;
  flex: 1;
  background: color-mix(in srgb, var(--accent) 25%, var(--border));
  min-height: 0.6rem;
}

.dgm-flow-content {
  flex: 1;
  padding: 0.3rem 0 0.5rem 0.7rem;
}

.dgm-flow-label code {
  color: var(--text);
  background: color-mix(in srgb, var(--accent) 8%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--accent) 20%, var(--border));
  border-radius: 4px;
  padding: 0.15em 0.5em;
  display: inline-block;
}

.dgm-flow-note {
  font-size: 0.74rem;
  color: var(--muted);
  margin-top: 0.2rem;
  padding-left: 0.1rem;
}

.dgm-flow-children {
  margin-left: 1rem;
  margin-top: 0.3rem;
  padding-left: 0.8rem;
  border-left: 2px solid color-mix(in srgb, var(--accent) 20%, var(--border));
}

/* ── Hierarchy diagram ── */
.dgm-hierarchy {
  margin: 0.8rem 0 1.2rem;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.dgm-hier-node {
  display: flex;
  flex-direction: column;
  padding-left: calc(var(--depth, 0) * 2rem);
}
.dgm-hier-node + .dgm-hier-node { margin-top: 0.5rem; }

.dgm-hier-box {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  border-left: 3px solid var(--accent);
  font-size: 0.82rem;
  align-self: flex-start;
}
.dgm-hier-node[style*="--depth:1"] .dgm-hier-box {
  border-left-color: color-mix(in srgb, var(--accent) 55%, var(--border));
}
.dgm-hier-node[style*="--depth:2"] .dgm-hier-box {
  border-left-color: color-mix(in srgb, var(--accent) 30%, var(--border));
}

.dgm-hier-box code { color: var(--text); background: none; border: none; padding: 0; }
.dgm-hier-sub { font-size: 0.72rem; color: var(--muted); }

.dgm-hier-children {
  margin-left: 1.5rem;
  margin-top: 0.4rem;
  padding-left: 0.8rem;
  border-left: 2px dashed color-mix(in srgb, var(--accent) 30%, var(--border));
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

/* ── Timeline diagram ── */
.dgm-timeline {
  margin: 0.8rem 0 1.2rem;
  display: flex;
  flex-direction: column;
  gap: 1.4rem;
}

.dgm-tl-group-label {
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent);
  opacity: 0.8;
  margin-bottom: 0.5rem;
}

.dgm-tl-items {
  display: flex;
  flex-direction: column;
  padding: 0.6rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.dgm-tl-item {
  display: flex;
  gap: 0;
  min-height: 2rem;
}

.dgm-tl-connector {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 18px;
  flex-shrink: 0;
}

.dgm-tl-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--accent);
  margin-top: 0.45rem;
  flex-shrink: 0;
}

.dgm-tl-line {
  width: 2px;
  flex: 1;
  background: color-mix(in srgb, var(--accent) 22%, var(--border));
  min-height: 0.4rem;
}
.dgm-tl-item:last-child .dgm-tl-line { display: none; }

.dgm-tl-body {
  flex: 1;
  padding: 0.25rem 0 0.5rem 0.7rem;
}

.dgm-tl-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.dgm-tl-label {
  color: var(--text);
  background: color-mix(in srgb, var(--accent) 8%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--accent) 20%, var(--border));
  border-radius: 4px;
  padding: 0.1em 0.45em;
  font-size: 0.79rem;
}

.dgm-tl-order {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--accent) 25%, transparent);
  border-radius: 3px;
  padding: 0.1em 0.4em;
  font-family: 'SFMono-Regular', 'Consolas', monospace;
}

.dgm-tl-sub {
  font-size: 0.73rem;
  color: var(--muted);
  margin-top: 0.15rem;
}

/* ── Architecture diagram ── */
.dgm-arch {
  margin: 0.8rem 0 1.2rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: color-mix(in srgb, var(--accent) 3%, var(--surface));
  padding: 1.2rem;
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}

.dgm-arch-outer-label {
  font-size: 0.6rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.2rem;
}

.dgm-arch-box {
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  padding: 0.8rem 1rem;
}

.dgm-arch-box-label {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--accent2);
  letter-spacing: 0.05em;
  margin-bottom: 0.5rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--border);
}

.dgm-arch-item {
  font-size: 0.78rem;
  color: var(--muted);
  padding: 0.18rem 0;
}
.dgm-arch-item:not(:last-child) {
  border-bottom: 1px solid color-mix(in srgb, var(--border) 40%, transparent);
}

@media (max-width: 768px) {
  .dgm-flow, .dgm-tl-items { padding: 0.8rem; }
  .dgm-flow-label code, .dgm-tl-label { font-size: 0.72rem; }
}
