/* ================================================================
   BigLedger — /modules/ pages (dark theme reading layout)
   Loaded only by layouts/partials/module-page.html.
================================================================ */

:root {
  --modp-bg: #100b0d;
  --modp-card: #1d1518;
  --modp-border: #2e2226;
  --modp-text: #f4eff0;
  --modp-text-2: #b3a6aa;
  --modp-red: #e5333f;
}

html, body { background: var(--modp-bg); }
body {
  color: var(--modp-text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}
.bl-network-bg { display: none; }

/* ── Layout ─────────────────────────────────────────────────── */
/* Three columns (explorer / content / toc) only fit past 1400px; the two
   narrower breakpoints below progressively drop the explorer, then the toc,
   back to the original two- and one-column layouts. */
.modp-wrap {
  display: grid;
  grid-template-columns: 296px minmax(0, 700px) 230px;
  justify-content: center;
  gap: 40px;
  max-width: 1320px;
  margin: 0 auto;
  padding: 48px 24px 96px;
}
.modp-wrap.modp-no-toc { grid-template-columns: 296px minmax(0, 700px); }
.modp-main { min-width: 0; }

@media (max-width: 1399px) {
  .modp-wrap { grid-template-columns: minmax(0, 800px) 240px; gap: 56px; max-width: 1160px; }
  .modp-wrap.modp-no-toc { grid-template-columns: minmax(0, 800px); }
  .modp-explorer { display: none !important; }
}
@media (max-width: 1100px) {
  .modp-wrap { grid-template-columns: minmax(0, 800px); }
  .modp-toc { display: none !important; }
}

/* ── Two-pane module explorer ───────────────────────────────── */
.modp-explorer {
  display: none; /* shown at >=1400px only, see breakpoint above */
  flex-direction: row;
  position: sticky; top: 96px; align-self: start;
  width: 296px; max-height: calc(100vh - 120px);
  background: var(--modp-card); border: 1px solid var(--modp-border); border-radius: 14px;
  overflow: hidden;
}
@media (min-width: 1400px) { .modp-explorer { display: flex; } }

.modp-explorer-cats {
  width: 106px; flex: none;
  border-right: 1px solid var(--modp-border);
  padding: 14px 7px; overflow-y: auto;
  display: flex; flex-direction: column; gap: 2px;
}
.modp-cat-btn {
  display: block; width: 100%; text-align: left;
  background: none; border: none; cursor: pointer;
  font: inherit; font-size: 12px; font-weight: 600; line-height: 1.35;
  color: var(--modp-text-2); padding: 8px 8px; border-radius: 8px;
  transition: color 0.15s, background 0.15s;
}
.modp-cat-btn:hover { background: rgba(255, 255, 255, 0.03); color: var(--modp-text); }
.modp-cat-btn.active { background: rgba(229, 51, 63, 0.12); color: var(--modp-red); }

.modp-explorer-mods { flex: 1; min-width: 0; padding: 14px 10px; overflow-y: auto; }
.modp-cat-panel[hidden] { display: none; }
.modp-explorer-mod {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 8px 10px; border-radius: 8px; text-decoration: none;
  font-size: 12.5px; color: var(--modp-text-2);
  transition: color 0.15s, background 0.15s;
}
.modp-explorer-mod:hover { background: rgba(255, 255, 255, 0.03); color: var(--modp-text); }
.modp-explorer-mod.current { background: rgba(229, 51, 63, 0.1); color: var(--modp-red); font-weight: 600; }
.modp-explorer-mod span:first-child { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.modp-explorer-count { font-size: 11px; color: #8d7d82; flex: none; font-variant-numeric: tabular-nums; }
.modp-explorer-mod.current .modp-explorer-count { color: var(--modp-red); }

/* ── Breadcrumb, title, badges ──────────────────────────────── */
.modp-crumb {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  font-size: 13px; color: var(--modp-text-2); margin-bottom: 20px;
}
.modp-crumb a { color: var(--modp-text-2); text-decoration: none; transition: color 0.15s; }
.modp-crumb a:hover { color: var(--modp-text); }
.modp-crumb > span:not(:last-child) { color: #6d5c61; }

.modp-main h1 {
  font-size: clamp(30px, 4.5vw, 40px); font-weight: 800; letter-spacing: -0.025em;
  line-height: 1.15; margin: 0 0 14px; color: var(--modp-text);
}
.modp-badges { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 16px; }
.modp-badge {
  display: inline-flex; align-items: center;
  height: 24px; padding: 0 11px; border-radius: 999px;
  font-size: 12px; font-weight: 600; white-space: nowrap;
}
.modp-badge-red {
  background: rgba(229, 51, 63, 0.14);
  border: 1px solid rgba(229, 51, 63, 0.3);
  color: var(--modp-red);
}
.modp-badge-neutral {
  background: transparent;
  border: 1px solid var(--modp-border);
  color: var(--modp-text-2);
}
.modp-tagline { font-size: 16.5px; line-height: 1.65; color: var(--modp-text-2); margin: 0 0 8px; }

/* ── Content typography ─────────────────────────────────────── */
.modp-content { font-size: 16.5px; line-height: 1.7; color: var(--modp-text-2); }

.modp-content h1, .modp-content h2, .modp-content h3, .modp-content h4 {
  color: var(--modp-text); letter-spacing: -0.015em; line-height: 1.3;
  scroll-margin-top: 88px;
}
.modp-content h1, .modp-content h2 {
  font-size: 23px; font-weight: 700; margin: 44px 0 14px;
  padding-bottom: 10px; border-bottom: 1px solid var(--modp-border);
}
.modp-content h2::before {
  content: ''; display: inline-block;
  width: 9px; height: 9px; border-radius: 3px;
  background: var(--modp-red); margin-right: 12px;
  vertical-align: 2px;
}
.modp-content h3 { font-size: 18px; font-weight: 650; margin: 32px 0 10px; }
.modp-content h4 { font-size: 15.5px; font-weight: 600; margin: 24px 0 8px; }

.modp-content p { margin: 0 0 16px; }
.modp-content strong { color: var(--modp-text); font-weight: 600; }
.modp-content a { color: var(--modp-red); text-decoration: none; }
.modp-content a:hover { text-decoration: underline; }
.modp-content ul, .modp-content ol { margin: 0 0 16px; padding-left: 24px; }
.modp-content li { margin: 4px 0; }
.modp-content li::marker { color: rgba(229, 51, 63, 0.6); }
.modp-content hr { border: none; border-top: 1px solid var(--modp-border); margin: 36px 0; }
.modp-content img { max-width: 100%; height: auto; border-radius: 14px; border: 1px solid var(--modp-border); }
.modp-content blockquote {
  margin: 0 0 16px; padding: 4px 20px;
  border-left: 3px solid var(--modp-red); color: var(--modp-text-2); font-style: italic;
}

.modp-content table {
  display: block; overflow-x: auto;
  width: max-content; max-width: 100%;
  border-collapse: collapse; margin: 0 0 20px;
  font-size: 14px; line-height: 1.55;
}
.modp-content th, .modp-content td {
  border: 1px solid var(--modp-border); padding: 9px 14px; text-align: left;
}
.modp-content th { background: var(--modp-card); color: var(--modp-text); font-weight: 600; }
.modp-content tr:nth-child(even) td { background: rgba(255, 255, 255, 0.015); }

.modp-content code {
  font-family: 'JetBrains Mono', 'Fira Code', monospace; font-size: 0.86em;
  background: var(--modp-card); border: 1px solid var(--modp-border);
  border-radius: 6px; padding: 2px 6px; color: var(--modp-text);
}
.modp-content pre {
  background: var(--modp-card); border: 1px solid var(--modp-border);
  border-radius: 14px; padding: 16px 20px; margin: 0 0 20px;
  overflow-x: auto; font-size: 13.5px; line-height: 1.6;
}
.modp-content pre code { background: none; border: none; padding: 0; }
.modp-content .highlight { margin: 0 0 20px; }
.modp-content .highlight pre { margin: 0; }

/* Hextra callouts → red-tinted with red left border */
.modp-content [class*="hx:rounded-lg"][class*="hx:border"] {
  background: rgba(229, 51, 63, 0.08) !important;
  border: 1px solid rgba(229, 51, 63, 0.28) !important;
  border-left: 3px solid var(--modp-red) !important;
  border-radius: 14px !important;
  color: var(--modp-text-2) !important;
  margin: 0 0 20px; padding-top: 12px; padding-bottom: 12px;
}
.modp-content [class*="hx:rounded-lg"][class*="hx:border"] strong { color: var(--modp-text); }
.modp-content [class*="hx:rounded-lg"][class*="hx:border"] p { margin: 0; }

/* ── Numbered applet cards ──────────────────────────────────── */
.modp-applet-card {
  display: flex; gap: 18px;
  background: var(--modp-card); border: 1px solid var(--modp-border);
  border-radius: 14px; padding: 18px 22px; margin: 0 0 12px;
  transition: transform 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease;
}
.modp-applet-card:hover {
  transform: translateY(-2px);
  border-color: rgba(229, 51, 63, 0.4);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.4);
}
.modp-applet-num {
  flex-shrink: 0; padding-top: 3px;
  font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums;
  color: var(--modp-red);
}
.modp-applet-body { min-width: 0; flex: 1; }
.modp-content h3.modp-applet-name {
  font-size: 15.5px; font-weight: 600; margin: 0 0 5px; line-height: 1.4;
  border: none; padding: 0;
}
.modp-content h3.modp-applet-name a { color: var(--modp-text); }
.modp-content h3.modp-applet-name a:hover { color: var(--modp-red); text-decoration: none; }
.modp-applet-tagline { font-size: 13.5px !important; line-height: 1.55; color: var(--modp-text-2); margin: 0 0 8px !important; }
.modp-content ul.modp-applet-bullets {
  margin: 0 0 8px; padding-left: 18px;
}
.modp-content ul.modp-applet-bullets li { font-size: 12.5px; line-height: 1.55; color: #8d7d82; margin: 2px 0; }
.modp-applet-meta { font-size: 12px !important; color: #8d7d82; margin: 0 0 4px !important; }

/* ── Setup timeline ─────────────────────────────────────────── */
.modp-timeline { display: flex; flex-direction: column; margin: 0 0 20px; }
.modp-step {
  position: relative; display: flex; gap: 16px;
  padding: 0 0 22px 0;
}
.modp-step::before {
  content: ''; position: absolute; left: 13px; top: 30px; bottom: 0;
  width: 2px; background: var(--modp-border);
}
.modp-step:last-child::before { display: none; }
.modp-step-num {
  flex-shrink: 0; width: 27px; height: 27px; border-radius: 50%;
  background: var(--modp-red); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 12.5px; font-weight: 700;
  position: relative; z-index: 1;
}
.modp-step-body { min-width: 0; padding-top: 3px; font-size: 14.5px; }
.modp-step-body > strong { display: block; margin-bottom: 4px; font-size: 15px; }
.modp-step-body ul { margin: 4px 0 0; }
.modp-step-body li { font-size: 13.5px; color: var(--modp-text-2); }

/* ── Definition tables ──────────────────────────────────────── */
.modp-content table.modp-deftable {
  display: table; width: 100%;
  border: 1px solid var(--modp-border); border-radius: 14px;
  border-collapse: separate; border-spacing: 0; overflow: hidden;
}
.modp-content .modp-deftable td {
  border: none; border-bottom: 1px solid var(--modp-border);
  padding: 11px 16px; font-size: 13.5px; vertical-align: top;
}
.modp-content .modp-deftable tr:last-child td { border-bottom: none; }
.modp-content .modp-deftable .modp-deftable-term {
  width: 34%; color: var(--modp-text); font-weight: 600; white-space: normal;
}

/* ── Use-case cards ─────────────────────────────────────────── */
.modp-usecase-grid {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px; margin: 18px 0 20px;
}
.modp-usecase-card {
  background: var(--modp-card); border: 1px solid var(--modp-border);
  border-radius: 14px; padding: 18px 20px;
}
.modp-content .modp-usecase-card h3 {
  font-size: 15px; font-weight: 650; margin: 0 0 8px;
}
.modp-usecase-card ul { margin: 0; padding-left: 18px; }
.modp-usecase-card li { font-size: 13px; color: var(--modp-text-2); margin: 3px 0; }
.modp-usecase-card p { font-size: 13.5px; margin: 0 0 8px; }

/* ── Troubleshooting accordions ─────────────────────────────── */
.modp-acc {
  background: var(--modp-card); border: 1px solid var(--modp-border);
  border-radius: 14px; margin: 0 0 10px; overflow: hidden;
}
.modp-acc summary {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 14px 18px; cursor: pointer; list-style: none;
  font-size: 14.5px; font-weight: 600; color: var(--modp-text);
  transition: background 0.15s;
}
.modp-acc summary::-webkit-details-marker { display: none; }
.modp-acc summary:hover { background: rgba(255, 255, 255, 0.02); }
.modp-acc summary svg {
  width: 13px; height: 13px; flex-shrink: 0; color: var(--modp-red);
  transition: transform 0.2s ease;
}
.modp-acc[open] summary svg { transform: rotate(180deg); }
.modp-acc[open] summary { border-bottom: 1px solid var(--modp-border); }
.modp-acc-body { padding: 14px 18px; font-size: 13.5px; }
.modp-acc-body ul { margin: 0; }
.modp-acc-body p { margin: 0 0 8px; }

/* ── Related-documentation link cards ───────────────────────── */
.modp-linkgrid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px; margin: 0 0 20px;
}
.modp-content a.modp-linkcard {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: var(--modp-card); border: 1px solid var(--modp-border);
  border-radius: 14px; padding: 13px 16px;
  font-size: 13.5px; font-weight: 600; color: var(--modp-text);
  transition: transform 0.15s ease, border-color 0.15s ease;
}
.modp-content a.modp-linkcard:hover {
  transform: translateY(-2px); border-color: rgba(229, 51, 63, 0.4);
  text-decoration: none;
}
.modp-content a.modp-linkcard a { color: inherit; }
.modp-linkcard-arrow { color: var(--modp-red); flex-shrink: 0; }

/* ── Chapter navigation ─────────────────────────────────────── */
.modp-chapter { margin-top: 64px; padding-top: 28px; border-top: 1px solid var(--modp-border); }
.modp-chapter-label {
  text-align: center; margin: 0 0 16px;
  font-size: 12px; font-weight: 700; letter-spacing: 0.07em; text-transform: uppercase;
  color: var(--modp-text-2);
}
.modp-chapter-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.modp-chapter-card {
  display: flex; flex-direction: column; gap: 4px;
  background: var(--modp-card); border: 1px solid var(--modp-border);
  border-radius: 14px; padding: 16px 20px; min-width: 0;
  text-decoration: none;
  transition: transform 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease;
}
a.modp-chapter-card:hover {
  transform: translateY(-2px);
  border-color: rgba(229, 51, 63, 0.4);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.4);
}
.modp-chapter-next { text-align: right; }
.modp-chapter-empty { visibility: hidden; }
.modp-chapter-dir {
  font-size: 11.5px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--modp-red);
}
.modp-chapter-name {
  font-size: 14.5px; font-weight: 600; color: var(--modp-text); line-height: 1.4;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.modp-chapter-count { font-size: 12px; color: var(--modp-text-2); }

.modp-allmods-btn {
  display: flex; align-items: center; gap: 8px;
  margin: 18px auto 0; padding: 9px 18px;
  background: transparent; border: 1px solid var(--modp-border); border-radius: 999px;
  color: var(--modp-text-2); font: inherit; font-size: 13px; font-weight: 600;
  cursor: pointer; transition: color 0.15s, border-color 0.15s;
}
.modp-allmods-btn:hover { color: var(--modp-text); border-color: #453338; }
.modp-allmods-btn svg { width: 11px; height: 11px; transition: transform 0.2s; }
.modp-allmods-btn.open svg { transform: rotate(180deg); }

.modp-allmods {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 8px; margin-top: 16px;
}
.modp-allmods-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; border: 1px solid var(--modp-border); border-radius: 10px;
  text-decoration: none; min-width: 0;
  transition: border-color 0.15s, background 0.15s;
}
.modp-allmods-item:hover { border-color: #453338; background: rgba(255, 255, 255, 0.02); }
.modp-allmods-num {
  font-size: 11.5px; font-weight: 700; font-variant-numeric: tabular-nums;
  color: #8d7d82; flex-shrink: 0;
}
.modp-allmods-name {
  flex: 1; font-size: 13px; font-weight: 500; color: var(--modp-text-2);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.modp-allmods-count { font-size: 11.5px; color: #8d7d82; flex-shrink: 0; }
.modp-allmods-item.current {
  border-color: var(--modp-red); background: rgba(229, 51, 63, 0.1);
}
.modp-allmods-item.current .modp-allmods-num,
.modp-allmods-item.current .modp-allmods-name { color: var(--modp-red); font-weight: 700; }

/* ── "On this page" side menu ───────────────────────────────── */
.modp-toc {
  position: sticky; top: 96px;
  align-self: start;
  max-height: calc(100vh - 120px); overflow-y: auto;
  padding-top: 62px;
}
.modp-toc-title {
  display: block;
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.09em;
  color: #8d7d82; margin-bottom: 12px; padding-left: 14px;
}
.modp-toc nav { display: flex; flex-direction: column; gap: 6px; padding-left: 14px; }
.modp-toc nav a {
  display: block; font-size: 12.5px; line-height: 1.4;
  color: var(--modp-text-2); text-decoration: none;
  padding: 7px 13px;
  border: 1px solid var(--modp-border); border-radius: 999px;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
}
.modp-toc nav a:hover { color: var(--modp-text); border-color: #453338; }
.modp-toc nav a.active {
  background: rgba(229, 51, 63, 0.12); border-color: var(--modp-red);
  color: var(--modp-red); font-weight: 600;
}

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 1100px) {
  .modp-wrap { grid-template-columns: minmax(0, 800px); }
  .modp-toc { display: none !important; }
}
@media (max-width: 640px) {
  .modp-usecase-grid { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .modp-wrap { padding: 36px 18px 72px; }
  .modp-applet-card { flex-direction: column; gap: 8px; padding: 16px 18px; }
  .modp-chapter-cards { grid-template-columns: 1fr; }
  .modp-chapter-next { text-align: left; }
  .modp-chapter-empty { display: none; }
}
