/* ═══════════════════════════════════════════
   styles.css — MyProject Documentation
   ═══════════════════════════════════════════ */

/* ── Design tokens ── */
:root {
  --bg:            #ffffff;
  --bg-alt:        #f7f4ef;
  --sidebar-bg:    #f0ebe0;
  --sidebar-bdr:   #e2dbd0;
  --accent:        #1a4731;
  --accent-light:  #2d6a4f;
  --accent-muted:  #e8f4ee;
  --text:          #1a1a1a;
  --text-2:        #4a4a45;
  --text-3:        #8a8882;
  --code-bg:       #1c2128;
  --code-text:     #e2e8f0;
  --border:        #e8e3da;
  --nav-act-bg:    #e0f0e8;
  --chart-1:       #1a4731;
  --chart-2:       #2d6a4f;
  --chart-3:       #52b788;
  --chart-4:       #b7e4c7;
  --font-h:        'DM Serif Display', Georgia, serif;
  --font-b:        'Lora', Georgia, serif;
  --font-m:        'JetBrains Mono', 'Courier New', monospace;
  --sw:            272px;   /* sidebar width   */
  --hh:            58px;    /* header height   */
  --fh:            50px;    /* footer height   */
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
  font-family: var(--font-b);
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.75;
}

/* ════════════════════════════
   HEADER
════════════════════════════ */
header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--hh);
  background: var(--accent);
  display: flex;
  align-items: center;
  padding: 0 24px;
  z-index: 200;
  box-shadow: 0 1px 0 rgba(0,0,0,0.18);
}

.h-logo {
  font-family: var(--font-h);
  font-size: 1.3rem;
  color: #fff;
  letter-spacing: 0.01em;
  display: flex;
  align-items: baseline;
  gap: 6px;
}
.h-logo em { color: rgba(255,255,255,0.45); font-style: italic; font-size: 1.05rem; }

.h-tag {
  margin-left: auto;
  font-family: var(--font-m);
  font-size: 0.68rem;
  color: rgba(255,255,255,0.38);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.h-ver {
  margin-left: 16px;
  font-family: var(--font-m);
  font-size: 0.68rem;
  background: rgba(255,255,255,0.1);
  color: rgba(255,255,255,0.6);
  padding: 2px 8px;
  border-radius: 100px;
}

/* ════════════════════════════
   LAYOUT
════════════════════════════ */
.layout {
  display: flex;
  min-height: 100vh;
  padding-top: var(--hh);
  padding-bottom: var(--fh);
}

/* ════════════════════════════
   SIDEBAR
════════════════════════════ */
aside {
  position: fixed;
  top: var(--hh);
  bottom: var(--fh);
  left: 0;
  width: var(--sw);
  background: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-bdr);
  overflow-y: auto;
  padding: 20px 0 32px;
  z-index: 100;
}

.nav-label {
  font-family: var(--font-m);
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--text-3);
  padding: 20px 22px 6px;
}

nav ul { list-style: none; }

nav ul li > a,
nav ul li > button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 7px 22px;
  font-family: var(--font-b);
  font-size: 0.88rem;
  color: var(--text-2);
  cursor: pointer;
  background: none;
  border: none;
  border-left: 2px solid transparent;
  text-decoration: none;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

nav ul li > a:hover,
nav ul li > button:hover {
  color: var(--accent);
  background: rgba(26,71,49,0.06);
}

nav ul li.active > a,
nav ul li.active > button {
  color: var(--accent);
  border-left-color: var(--accent);
  background: var(--nav-act-bg);
  font-weight: 500;
}

/* Collapsible subtopics */
.subtopics { overflow: hidden; max-height: 0; transition: max-height 0.28s ease; }
.subtopics.open { max-height: 2000px; }

.subtopics li > a,
.subtopics li > button {
  padding-left: 38px;
  font-size: 0.83rem;
  color: var(--text-3);
  border-left: none;
}

.subtopics li.active > a,
.subtopics li.active > button {
  color: var(--accent);
  background: rgba(26,71,49,0.05);
  font-weight: 500;
}

/* Chevron expand icon */
.chev {
  float: right;
  transition: transform 0.22s ease;
  font-style: normal;
  font-family: var(--font-m);
  font-size: 0.75rem;
  color: var(--text-3);
}
.has-ch.open .chev { transform: rotate(90deg); }

/* ════════════════════════════
   MAIN CONTENT
════════════════════════════ */
main {
  margin-left: var(--sw);
  flex: 1;
  padding: 52px 68px 80px;
  max-width: 920px;
}

.topic { display: none; }
.topic.active {
  display: block;
  animation: fadeUp 0.22s ease;
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ════════════════════════════
   TYPOGRAPHY
════════════════════════════ */
h1 {
  font-family: var(--font-h);
  font-size: 2.5rem;
  line-height: 1.18;
  margin-bottom: 6px;
}

.subtitle {
  font-size: 1rem;
  color: var(--text-3);
  font-style: italic;
  margin-bottom: 36px;
  padding-bottom: 28px;
  border-bottom: 1px solid var(--border);
}

h2 {
  font-family: var(--font-h);
  font-size: 1.5rem;
  margin: 44px 0 12px;
}

h3 {
  font-family: var(--font-m);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-3);
  margin: 28px 0 8px;
}

p  { color: var(--text-2); margin-bottom: 14px; }
a  { color: var(--accent); text-decoration: none; border-bottom: 1px solid rgba(26,71,49,0.25); }
a:hover { border-bottom-color: var(--accent); }
ul, ol { padding-left: 22px; color: var(--text-2); margin-bottom: 14px; }
li { margin-bottom: 6px; }
hr { border: none; border-top: 1px solid var(--border); margin: 40px 0; }

/* ════════════════════════════
   CALLOUT BOX
════════════════════════════ */
.callout {
  border-left: 3px solid var(--accent);
  background: var(--accent-muted);
  padding: 12px 16px;
  border-radius: 0 6px 6px 0;
  margin: 20px 0;
}
.callout p { margin: 0; font-size: 0.9rem; }

.c-label {
  font-family: var(--font-m);
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent);
  margin-bottom: 3px;
}

/* ════════════════════════════
   CODE BLOCKS
════════════════════════════ */
.code-block {
  background: var(--code-bg);
  border-radius: 8px;
  overflow: hidden;
  margin: 20px 0;
}

.code-hdr {
  display: flex;
  align-items: center;
  padding: 9px 14px;
  background: rgba(255,255,255,0.035);
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

.dots { display: flex; gap: 5px; margin-right: 10px; }
.dots span { width: 10px; height: 10px; border-radius: 50%; background: rgba(255,255,255,0.12); }

.lang {
  font-family: var(--font-m);
  font-size: 0.65rem;
  color: rgba(255,255,255,0.28);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.copy-btn {
  margin-left: auto;
  font-family: var(--font-m);
  font-size: 0.65rem;
  color: rgba(255,255,255,0.3);
  background: none;
  border: 1px solid rgba(255,255,255,0.1);
  cursor: pointer;
  padding: 2px 10px;
  border-radius: 4px;
  transition: all 0.15s;
}
.copy-btn:hover { background: rgba(255,255,255,0.08); color: rgba(255,255,255,0.7); }

pre { padding: 20px; overflow-x: auto; }
pre code { font-family: var(--font-m); font-size: 0.8rem; line-height: 1.75; color: var(--code-text); }

/* Inline code */
p code, li code, td code {
  font-family: var(--font-m);
  font-size: 0.8em;
  background: #eee9e0;
  color: #2a2a2a;
  padding: 1px 5px;
  border-radius: 3px;
}

/* Syntax highlight tokens */
.kw  { color: #c792ea; }  /* keywords  */
.str { color: #c3e88d; }  /* strings   */
.cm  { color: #4a5568; }  /* comments  */
.fn  { color: #82aaff; }  /* functions */
.nb  { color: #f78c6c; }  /* numbers   */
.ty  { color: #ffcb6b; }  /* types     */

/* ════════════════════════════
   IMAGE PLACEHOLDERS
════════════════════════════ */
.img-ph {
  background: var(--bg-alt);
  border: 2px dashed var(--border);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--text-3);
  font-family: var(--font-m);
  font-size: 0.72rem;
  margin: 22px 0;
  padding: 40px 20px;
  text-align: center;
}
.img-ph svg { opacity: 0.35; }

/* ════════════════════════════
   CHART CONTAINERS
════════════════════════════ */
.chart-wrap {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 26px;
  margin: 20px 0;
}

.chart-ttl {
  font-family: var(--font-m);
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-3);
  margin-bottom: 18px;
}

.chart-legend { display: flex; gap: 18px; margin-top: 12px; }

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-m);
  font-size: 0.68rem;
  color: var(--text-3);
}

.legend-line { width: 16px; height: 2px; border-radius: 2px; }

/* ════════════════════════════
   TABLES
════════════════════════════ */
table { width: 100%; border-collapse: collapse; margin: 20px 0; font-size: 0.9rem; }

th {
  font-family: var(--font-m);
  font-size: 0.67rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-3);
  text-align: left;
  padding: 10px 14px;
  border-bottom: 2px solid var(--border);
}

td { padding: 10px 14px; border-bottom: 1px solid var(--border); color: var(--text-2); }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--bg-alt); }

/* ════════════════════════════
   BADGES
════════════════════════════ */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 100px;
  font-family: var(--font-m);
  font-size: 0.64rem;
  font-weight: 500;
}
.b-g { background: #d1fae5; color: #065f46; }
.b-a { background: #fef3c7; color: #92400e; }
.b-r { background: #fee2e2; color: #991b1b; }
.b-b { background: #dbeafe; color: #1e40af; }

/* ════════════════════════════
   NUMBERED STEPS
════════════════════════════ */
.steps { list-style: none; counter-reset: s; padding-left: 0; }

.steps li {
  counter-increment: s;
  display: flex;
  gap: 14px;
  margin-bottom: 18px;
  color: var(--text-2);
}

.steps li::before {
  content: counter(s);
  min-width: 26px;
  height: 26px;
  background: var(--accent);
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-m);
  font-size: 0.7rem;
  flex-shrink: 0;
  margin-top: 3px;
}

/* ════════════════════════════
   VERSION PILL
════════════════════════════ */
.v-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--accent-muted);
  color: var(--accent);
  padding: 3px 10px 3px 6px;
  border-radius: 100px;
  font-family: var(--font-m);
  font-size: 0.68rem;
  margin-bottom: 14px;
}
.v-dot { width: 6px; height: 6px; background: var(--accent); border-radius: 50%; }

/* ════════════════════════════
   FOOTER
════════════════════════════ */
footer {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: var(--fh);
  background: var(--bg);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  z-index: 200;
}

.f-copy { font-family: var(--font-m); font-size: 0.72rem; color: var(--text-3); }

.to-top {
  margin-left: auto;
  font-family: var(--font-m);
  font-size: 0.7rem;
  color: var(--accent);
  background: none;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 5px;
  transition: opacity 0.18s;
}
.to-top:hover { opacity: 0.65; }

/* ════════════════════════════
   CUSTOM SCROLLBARS
════════════════════════════ */
aside::-webkit-scrollbar        { width: 3px; }
aside::-webkit-scrollbar-thumb  { background: var(--sidebar-bdr); border-radius: 2px; }

pre::-webkit-scrollbar        { height: 3px; }
pre::-webkit-scrollbar-thumb  { background: rgba(255,255,255,0.1); border-radius: 2px; }

/* ════════════════════════════
   COMPARISON TABLE
════════════════════════════ */
.compare-table {
  width: 100%;
  border-collapse: collapse;
  margin: 24px 0;
  font-size: 0.9rem;
  table-layout: fixed;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.compare-table td:first-child,
.compare-table th:first-child { width: 38%; color: var(--text-2); }

.compare-table thead tr { background: none; }

.compare-table .col-option {
  background: var(--accent);
  color: #fff;
  font-family: var(--font-h);
  font-size: 1rem;
  font-weight: 400;
  text-align: center;
  text-transform: none;
  padding: 14px 20px;
  border-bottom: none;
}
.compare-table .col-option:first-of-type { border-radius: 8px 0 0 0; }
.compare-table .col-option:last-of-type  { border-radius: 0 8px 0 0; }
.compare-table .col-label-hdr { background: transparent; border-bottom: none; }

.compare-table .section-row td {
  background: var(--sidebar-bg);
  font-family: var(--font-m);
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-3);
  padding: 8px 16px;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.compare-table tbody tr:not(.section-row) td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
  color: var(--text-2);
}
.compare-table tbody tr:not(.section-row):last-child td { border-bottom: none; }
.compare-table tbody tr:not(.section-row):hover td { background: var(--accent-muted); }

.compare-table td.val {
  text-align: center;
  font-family: var(--font-m);
  font-size: 0.8rem;
}

.compare-table .yes::before     { content: '✓'; color: #2d6a4f; font-weight: 700; }
.compare-table .no::before      { content: '✗'; color: #b91c1c; font-weight: 700; }
.compare-table .partial::before { content: '◑'; color: #b45309; }

.doc-img {
  display: block;
  width: 100%;
  max-width: 711px;
  height: auto;
  border-radius: 8px;
  /* border: 1px solid var(--border); */
  margin: 16px 0 32px;
}

[id^="note-"] {
  scroll-margin-top: calc(var(--hh) + 16px);
}

/* ════════════════════════════
   BYTE FRAME
════════════════════════════ */
.byte-frame {
  display: flex;
  flex-direction: column;
  margin: 20px 0 32px;
  font-family: var(--font-m);
  overflow-x: auto;
}

.byte-frame-cells {
  display: flex;
  border: 1px solid var(--border);
  border-radius: 8px 8px 0 0;
  overflow: hidden;
}

.byte-cell {
  flex: 1;
  min-width: 64px;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}
.byte-cell:last-child { border-right: none; }

.byte-cell-index {
  font-size: 0.6rem;
  color: var(--text-3);
  text-align: center;
  padding: 4px 4px 2px;
  background: var(--sidebar-bg);
  border-bottom: 1px solid var(--border);
  letter-spacing: 0.05em;
}

.byte-cell-label {
  font-size: 0.75rem;
  font-weight: 500;
  text-align: center;
  padding: 10px 6px;
  background: var(--bg-alt);
  color: var(--text);
  letter-spacing: 0.03em;
}

/* Colour variants */
.byte-cell.bc-accent .byte-cell-label { background: var(--accent);       color: #fff; }
.byte-cell.bc-muted  .byte-cell-label { background: var(--accent-muted); color: var(--accent); }
.byte-cell.bc-dim    .byte-cell-label { background: var(--sidebar-bg);   color: var(--text-3); }

/* Description rows below the cells */
.byte-frame-desc {
  display: flex;
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 8px 8px;
  overflow: hidden;
}

.byte-desc {
  flex: 1;
  min-width: 64px;
  padding: 8px 8px;
  border-right: 1px solid var(--border);
  font-size: 0.68rem;
  color: var(--text-3);
  text-align: center;
  background: var(--bg);
  line-height: 1.4;
}
.byte-desc:last-child { border-right: none; }

/* ════════════════════════════
   ENUM TABLE
════════════════════════════ */
.enum-table {
  width: 100%;
  border-collapse: collapse;
  margin: 20px 0 32px;
  font-size: 0.9rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.enum-table thead th {
  background: var(--sidebar-bg);
  font-family: var(--font-m);
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-3);
  padding: 10px 16px;
  text-align: left;
  border-bottom: 2px solid var(--border);
}

.enum-table tbody tr:hover td { background: var(--accent-muted); }

.enum-table tbody td {
  padding: 11px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
  color: var(--text-2);
}
.enum-table tbody tr:last-child td { border-bottom: none; }

/* Value column — monospace pill */
.enum-table .enum-val {
  font-family: var(--font-m);
  font-size: 0.78rem;
  color: var(--accent);
  white-space: nowrap;
  width: 1%;
}

/* Numeric column */
.enum-table .enum-num {
  font-family: var(--font-m);
  font-size: 0.78rem;
  color: var(--text-3);
  white-space: nowrap;
  width: 1%;
  text-align: center;
}

/* Description column */
.enum-table .enum-desc {
  color: var(--text-2);
  font-size: 0.88rem;
}

/* Optional default marker */
.enum-default {
  display: inline-block;
  margin-left: 8px;
  font-family: var(--font-m);
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  background: var(--accent-muted);
  color: var(--accent);
  padding: 1px 7px;
  border-radius: 100px;
  vertical-align: middle;
}

/* ════════════════════════════
   API DIRECTION
════════════════════════════ */
.api-direction {
  display: inline-flex;
  align-items: stretch;
  gap: 0;
  margin: 4px 0 24px;
  font-family: var(--font-m);
  font-size: 0.78rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.api-dir-node {
  padding: 7px 16px;
  background: var(--sidebar-bg);
  color: var(--text-2);
  letter-spacing: 0.04em;
  display: flex;
  align-items: center;
}

.api-dir-node.sender {
  background: var(--accent);
  color: #fff;
}

.api-dir-node.receiver {
  background: var(--accent-muted);
  color: var(--accent);
}

.api-dir-arrow {
  display: flex;
  align-items: center;
  padding: 0 14px;
  background: var(--bg-alt);
  color: var(--text-3);
  font-size: 1.4rem;
  user-select: none;
}

.api-dir-label {
  font-family: var(--font-m);
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-3);
  margin-bottom: 6px;
}

figure img {
  display: block;
  margin-bottom: 0;
}

figcaption {
  font-size: 0.85em;
  font-style: italic;
  text-align: center;
  margin-top: 0.2em;
}

.mermaid text.noteText { 
  dominant-baseline: top;
}