
:root {
  --max-width: 700px;
  --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  --font-mono: "SF Mono", Consolas, "Liberation Mono", Menlo, monospace;
  --bg-color: #ffffff;
  --text-color: #1a1a2e;
  --text-muted: #6b7280;
  --link-color: #b44e2d;
  --link-hover: #943f24;
  --border-color: #e5e7eb;
  --code-bg: #f6f8fa;
  --code-border: #e5e7eb;
  --header-bg: #ffffff;
  --highlight-bg: rgba(180, 78, 45, 0.08);

  /* x-ocaml interactive cells */
  --xo-font-size: 0.875rem;
  --xo-bg: var(--code-bg);
  --xo-text: var(--text-color);
  --xo-gutter-bg: var(--code-bg);
  --xo-gutter-text: var(--text-muted);
  --xo-gutter-border: var(--border-color);
  --xo-stdout-bg: rgba(180, 78, 45, 0.06);
  --xo-stdout-text: var(--link-color);
  --xo-stderr-bg: rgba(218, 9, 9, 0.06);
  --xo-stderr-text: #cf222e;
  --xo-meta-bg: var(--code-bg);
  --xo-meta-text: var(--text-muted);
  --xo-tooltip-bg: var(--bg-color);
  --xo-tooltip-text: var(--text-color);
  --xo-tooltip-border: var(--border-color);
  --xo-btn-bg: var(--code-bg);
  --xo-btn-border: var(--border-color);
  --xo-btn-text: var(--text-muted);
  --xo-btn-hover-bg: var(--text-muted);
  --xo-btn-hover-text: var(--bg-color);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg-color: #0d1117;
    --text-color: #e6edf3;
    --text-muted: #8b949e;
    --link-color: #e07850;
    --link-hover: #f09070;
    --border-color: #30363d;
    --code-bg: #161b22;
    --code-border: #30363d;
    --header-bg: #161b22;
    --highlight-bg: rgba(224, 120, 80, 0.12);

    /* x-ocaml interactive cells - dark overrides */
    --xo-stdout-bg: rgba(88, 166, 255, 0.08);
    --xo-stdout-text: #79c0ff;
    --xo-stderr-bg: rgba(248, 81, 73, 0.08);
    --xo-stderr-text: #f85149;
  }
}

/* Reset */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

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

a {
  color: var(--link-color);
  text-decoration: none;
}

a:hover {
  color: var(--link-hover);
  text-decoration: underline;
}

/* Header */
.jon-shell-header {
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: calc(var(--max-width) + 300px);
  margin: 0 auto;
  padding: 16px 20px;
  font-size: 14px;
  border-bottom: 1px solid var(--border-color);
}

.jon-shell-header > a {
  font-weight: 600;
  color: var(--text-color);
  text-decoration: none;
}

.jon-shell-header > a:hover {
  color: var(--link-color);
}

.jon-shell-header nav {
  display: flex;
  gap: 20px;
  margin-left: auto;
}

.jon-shell-header nav a {
  color: var(--text-muted);
  text-decoration: none;
}

.jon-shell-header nav a:hover {
  color: var(--link-color);
}

/* Main content */
.jon-shell-main {
  max-width: calc(var(--max-width) + 300px);
  margin: 0 auto;
  padding: 24px 20px 60px;
  display: flex;
  gap: 32px;
}

.jon-shell-main .odoc-content {
  flex: 1;
  min-width: 0;
}

/* Sidebar */
.jon-shell-sidebar {
  width: 260px;
  flex-shrink: 0;
  font-size: 0.85rem;
  line-height: 1.5;
  position: sticky;
  top: 24px;
  align-self: flex-start;
  max-height: calc(100vh - 48px);
  overflow-y: auto;
}

/* Collapse the top two wrapper levels so content aligns with header */
.jon-shell-sidebar > ul > li > ul,
.jon-shell-sidebar > ul > li > ul > li > ul {
  padding-left: 0;
  margin-left: 0;
  border-left: none;
}

.jon-shell-sidebar ul ul {
  padding-left: 12px;
  margin-left: 4px;
  border-left: 1px solid var(--border-color);
}

.jon-shell-sidebar li {
  margin: 0;
}

.jon-shell-sidebar a,
.jon-shell-sidebar .sidebar-label {
  display: block;
  padding: 2px 8px;
  color: var(--text-muted);
  text-decoration: none;
  border-radius: 4px;
}

.jon-shell-sidebar a:hover {
  color: var(--link-color);
  background: var(--highlight-bg);
  text-decoration: none;
}

.jon-shell-sidebar a.current_unit {
  color: var(--link-color);
  font-weight: 600;
}

/* Collapsible entries — small inline chevron before the link */
.jon-shell-sidebar .sidebar-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  cursor: pointer;
  color: var(--text-muted);
  opacity: 0.55;
  font-size: 1em;
  vertical-align: middle;
  flex-shrink: 0;
  transition: opacity 0.15s, transform 0.15s;
  user-select: none;
}

.jon-shell-sidebar .sidebar-toggle:hover {
  opacity: 0.8;
}

.jon-shell-sidebar .sidebar-toggle::before {
  content: "\25B8";
  display: block;
  transition: transform 0.15s;
}

.jon-shell-sidebar li:not(.collapsed) > .sidebar-toggle::before {
  transform: rotate(90deg);
}

.jon-shell-sidebar li.collapsed > ul {
  display: none;
}

/* Items with children: put toggle and link on same line */
.jon-shell-sidebar li:has(> .sidebar-toggle) {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
}

.jon-shell-sidebar li:has(> .sidebar-toggle) > a,
.jon-shell-sidebar li:has(> .sidebar-toggle) > .sidebar-label {
  flex: 1;
  min-width: 0;
}

.jon-shell-sidebar li:has(> .sidebar-toggle) > ul {
  flex-basis: 100%;
}

/* Items without children: indent to align with toggle items */
.jon-shell-sidebar li:not(:has(> .sidebar-toggle)) > a,
.jon-shell-sidebar li:not(:has(> .sidebar-toggle)) > .sidebar-label {
  margin-left: 20px;
}

/* Ensure collapsed children are fully hidden including overflow */
.jon-shell-sidebar li.collapsed > ul {
  display: none !important;
}

/* Hide the bare "index" text breadcrumb from odoc sidebar */
.jon-shell-sidebar > ul > li:last-child:not(:has(a)) {
  display: none;
}

/* Hide the top-level wrapper entries (e.g. "OCaml package documentation" >
   "reference") — they waste space and add confusing nesting. Show their
   children directly. */
.jon-shell-sidebar > ul > li > .sidebar-toggle,
.jon-shell-sidebar > ul > li > a,
.jon-shell-sidebar > ul > li > .sidebar-label,
.jon-shell-sidebar > ul > li > ul > li > .sidebar-toggle,
.jon-shell-sidebar > ul > li > ul > li > a,
.jon-shell-sidebar > ul > li > ul > li > .sidebar-label {
  display: none;
}

/* Hero intro - side-by-side text + photo */
.hero-intro {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2rem;
  align-items: start;
  margin-bottom: 0.5rem;
}
.hero-intro .hero-text {
  min-width: 0;
}
.hero-intro .hero-text > p {
  margin-top: 0;
}
.hero-photo {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  object-fit: cover;
  box-shadow: 0 0 0 1px var(--border-color);
  margin-top: 4px;
}
@media (max-width: 700px) {
  .hero-intro {
    grid-template-columns: 1fr;
    gap: 1rem;
  }
  .hero-intro .hero-photo {
    order: -1;
  }
}

/* Typography */
.jon-shell-main h1 {
  font-size: 2rem;
  font-weight: 700;
  line-height: 1.2;
  margin-bottom: 24px;
}

.jon-shell-main h2 {
  font-size: 1.5rem;
  font-weight: 600;
  margin-top: 40px;
  margin-bottom: 16px;
}

.jon-shell-main h3 {
  font-size: 1.25rem;
  font-weight: 600;
  margin-top: 32px;
  margin-bottom: 12px;
}

.jon-shell-main h4,
.jon-shell-main h5,
.jon-shell-main h6 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-top: 24px;
  margin-bottom: 8px;
}

.jon-shell-main p {
  margin-bottom: 16px;
}

.jon-shell-main ul,
.jon-shell-main ol {
  margin-bottom: 16px;
  padding-left: 28px;
}

/* Sidebar lists reset — must come after .jon-shell-main ul to win cascade */
.jon-shell-sidebar ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.jon-shell-main li {
  margin-bottom: 4px;
}

.jon-shell-main blockquote {
  border-left: 3px solid var(--border-color);
  margin: 16px 0;
  padding: 8px 16px;
  color: var(--text-muted);
}

.jon-shell-main table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 16px;
  font-size: 0.95em;
}

.jon-shell-main th,
.jon-shell-main td {
  padding: 10px 12px;
  border: 1px solid var(--border-color);
  text-align: left;
}

.jon-shell-main th {
  background: var(--code-bg);
  font-weight: 600;
}

/* Code */
.jon-shell-main code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  background: var(--code-bg);
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid var(--code-border);
}

.jon-shell-main pre {
  background: var(--code-bg);
  border: 1px solid var(--code-border);
  border-radius: 6px;
  padding: 16px;
  overflow-x: auto;
  margin-bottom: 16px;
}

.jon-shell-main pre code {
  background: none;
  border: none;
  padding: 0;
  font-size: 0.875rem;
  line-height: 1.5;
}

/* odoc specifics */
.odoc-spec {
  margin: 16px 0;
  padding: 12px 16px;
  background: var(--code-bg);
  border: 1px solid var(--code-border);
  border-radius: 6px;
  border-left: 3px solid var(--link-color);
}

.odoc-spec code {
  background: none;
  border: none;
  padding: 0;
}

.spec {
  font-family: var(--font-mono);
  font-size: 0.9rem;
}

.spec-doc {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border-color);
  font-size: 0.95rem;
}

.comment-delim {
  display: none;
}

.odoc-include {
  margin: 16px 0;
  padding: 12px;
  border: 1px solid var(--border-color);
  border-left: 3px solid var(--text-muted);
  border-radius: 6px;
}

.odoc-include > details > summary {
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 0.9rem;
}

/* Source links float right inside spec blocks and headings */
a.source_link {
  float: right;
  color: var(--text-muted);
  font-family: var(--font-body);
  font-size: 0.8rem;
  font-weight: normal;
}

a.source_link:hover {
  color: var(--link-color);
}

/* Source code pages */
.source_container {
  display: flex;
  margin-top: 0;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  line-height: 1.4;
  background: var(--code-bg);
  border: 1px solid var(--code-border);
  border-radius: 6px;
  overflow-x: auto;
}

.source_line_column {
  padding: 12px 0;
  text-align: right;
  color: var(--text-muted);
  background: var(--code-bg);
  border-right: 1px solid var(--code-border);
  user-select: none;
}

.source_line {
  padding: 0 12px;
}

.source_code {
  flex-grow: 1;
  padding: 12px 16px;
  color: var(--text-color);
  overflow-x: auto;
}

.source_code pre {
  margin: 0;
  background: none;
  border: none;
  padding: 0;
}

.source_code code {
  background: none;
  border: none;
  padding: 0;
  font-size: inherit;
}

.odoc-src pre a {
  color: inherit;
}

/* Source directory listings */
.odoc-directory::before {
  content: "\01F4C1";
  margin-right: 0.3em;
}

/* Source code syntax highlighting */
:root {
  --src-keyword: #cf222e;
  --src-uident: #0550ae;
  --src-lident: var(--text-color);
  --src-literal: #0a3069;
  --src-comment: var(--text-muted);
  --src-docstring: #116329;
  --src-separator: #953800;
  --src-parens: #953800;
  --src-operator: #8250df;
  --src-underscore: var(--text-muted);
}

@media (prefers-color-scheme: dark) {
  :root {
    --src-keyword: #ff7b72;
    --src-uident: #79c0ff;
    --src-lident: var(--text-color);
    --src-literal: #a5d6ff;
    --src-comment: var(--text-muted);
    --src-docstring: #7ee787;
    --src-separator: #d29922;
    --src-parens: #d29922;
    --src-operator: #d2a8ff;
    --src-underscore: var(--text-muted);
  }
}

/* Keywords */
.AND, .ANDOP, .AS, .ASSERT,
.BAR, .BEGIN,
.CLASS, .CONSTRAINT,
.DO, .DONE, .DOWNTO,
.ELSE, .END, .EXCEPTION, .EXTERNAL,
.FOR, .FUN, .FUNCTION, .FUNCTOR,
.IF, .IN, .INCLUDE, .INHERIT, .INITIALIZER,
.LAZY, .LESSMINUS, .LET, .LETOP,
.MATCH, .METHOD, .MINUSGREATER, .MODULE, .MUTABLE,
.NEW, .NONREC,
.OBJECT, .OF, .OPEN,
.PERCENT, .PRIVATE,
.REC,
.SEMISEMI, .SIG, .STRUCT,
.THEN, .TO, .TRY, .TYPE,
.VAL, .VIRTUAL,
.WHEN, .WITH, .WHILE {
  color: var(--src-keyword);
}

/* Separators */
.COMMA, .COLON, .COLONGREATER, .SEMI {
  color: var(--src-separator);
}

/* Parens */
.BARRBRACKET,
.LBRACE, .LBRACELESS,
.LBRACKET, .LBRACKETAT, .LBRACKETATAT, .LBRACKETATATAT,
.LBRACKETBAR, .LBRACKETGREATER, .LBRACKETLESS,
.LBRACKETPERCENT, .LBRACKETPERCENTPERCENT,
.LPAREN, .RBRACE, .RBRACKET, .RPAREN {
  color: var(--src-parens);
}

/* Operators */
.BANG, .PREFIXOP,
.INFIXOP0, .INFIXOP1, .INFIXOP2, .INFIXOP3, .INFIXOP4,
.BARBAR, .PLUS, .STAR, .AMPERAMPER, .AMPERAND, .COLONEQUAL,
.GREATER, .LESS, .MINUS, .MINUSDOT, .MINUSGREATER,
.OR, .PLUSDOT, .PLUSEQ, .EQUAL {
  color: var(--src-operator);
}

/* Upper case idents */
.UIDENT, .COLONCOLON, .TRUE, .FALSE {
  color: var(--src-uident);
}

/* Lower case idents */
.LIDENT, .QUESTION, .QUOTE, .TILDE {
  color: var(--src-lident);
}

/* Literals */
.STRING, .CHAR, .INT, .FLOAT, .QUOTED_STRING_EXPR, .QUOTED_STRING_ITEM {
  color: var(--src-literal);
}

.UNDERSCORE {
  color: var(--src-underscore);
}

.DOCSTRING {
  color: var(--src-docstring);
}

.COMMENT {
  color: var(--src-comment);
  font-style: italic;
}

.anchor {
  color: var(--text-muted);
  text-decoration: none;
  margin-left: 4px;
  opacity: 0;
  transition: opacity 0.15s;
}

h1:hover .anchor, h2:hover .anchor, h3:hover .anchor,
h4:hover .anchor, h5:hover .anchor, h6:hover .anchor,
.spec:hover .anchor {
  opacity: 1;
}

.anchor:hover {
  color: var(--link-color);
}

:target {
  background: var(--highlight-bg);
  border-radius: 4px;
}

/* Footer */
.jon-shell-footer {
  max-width: calc(var(--max-width) + 300px);
  margin: 0 auto;
  padding: 24px 20px;
  border-top: 1px solid var(--border-color);
  font-size: 14px;
  color: var(--text-muted);
}

/* Responsive */
@media (max-width: 800px) {
  .jon-shell-sidebar {
    display: none;
  }

  .jon-shell-main {
    max-width: var(--max-width);
  }

  .jon-shell-header {
    max-width: var(--max-width);
  }

  .jon-shell-footer {
    max-width: var(--max-width);
  }
}

@media (max-width: 600px) {
  body {
    font-size: 16px;
  }

  .jon-shell-header {
    flex-direction: column;
    gap: 8px;
    align-items: flex-start;
  }

  .jon-shell-main h1 {
    font-size: 1.6rem;
  }
}
/* Sidebar toggle button */
.jon-shell-sidebar-toggle {
  background: none;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  color: var(--text-muted);
  font-size: 14px;
  cursor: pointer;
  padding: 2px 6px;
  line-height: 1;
  transition: color 0.15s, border-color 0.15s;
}
.jon-shell-sidebar-toggle:hover {
  color: var(--link-color);
  border-color: var(--link-color);
}

/* Hidden sidebar state */
body.sidebar-hidden .jon-shell-sidebar { display: none; }

/* ================================================================
   Scrollycode theming
   Maps jon-shell variables to --sc-* custom properties.
   The extension's structural CSS uses these properties for styling.
   ================================================================ */

/* Theme custom properties — map shell vars to scrollycode contract */
.sc-container {
  --sc-font-display: var(--font-body);
  --sc-font-body: var(--font-body);
  --sc-font-code: var(--font-mono);
  --sc-bg: var(--bg-color);
  --sc-text: var(--text-color);
  --sc-text-dim: var(--text-muted);
  --sc-accent: var(--link-color);
  --sc-accent-soft: var(--highlight-bg);
  --sc-code-bg: #1a1a2e;
  --sc-code-text: #d4d0c8;
  --sc-code-gutter: #3a3a52;
  --sc-border: var(--border-color);
  --sc-focus-bg: var(--highlight-bg);
  --sc-panel-radius: 12px;
  --sc-mobile-step-bg: rgba(255,255,255,0.5);

  /* Syntax highlighting */
  --sc-hl-keyword: #f0a6a0;
  --sc-hl-type: #8ec8e8;
  --sc-hl-string: #b8d89a;
  --sc-hl-comment: #6a6a82;
  --sc-hl-number: #ddb97a;
  --sc-hl-module: #e8c87a;
  --sc-hl-operator: #c8a8d8;
  --sc-hl-punct: #7a7a92;
}

/* Hero: centered for jon-shell */
.sc-container .sc-hero {
  border-bottom: 1px solid var(--sc-border);
  text-align: center;
}
.sc-container .sc-hero p {
  margin: 0 auto;
}

/* Dark mode overrides */
@media (prefers-color-scheme: dark) {
  .sc-container {
    --sc-code-bg: #0f0f18;
    --sc-code-text: #c8c5d8;
    --sc-code-gutter: #2a2a3e;
    --sc-mobile-step-bg: rgba(255,255,255,0.04);

    /* Dark syntax colors */
    --sc-hl-keyword: #ff7eb3;
    --sc-hl-type: #7dd3fc;
    --sc-hl-string: #4ade80;
    --sc-hl-comment: #4a4a62;
    --sc-hl-number: #fbbf24;
    --sc-hl-module: #c4b5fd;
    --sc-hl-operator: #67e8f9;
    --sc-hl-punct: #4a4a62;
  }
}
