/* Dark-mode fixes for embedded notebooks + code blocks.
 *
 * nb.css ships a LIGHT JupyterLab theme via --jp-* variables (white layout
 * colors, dark fonts) with no dark counterpart. Under furo's dark mode those
 * light values collide with the dark page: embedded notebooks show white
 * boxes / unreadable dark-on-dark text (e.g. tutorial_namd, tutorial_ciopt).
 *
 * Since nb.css and the notebook HTML color everything through --jp-* vars, we
 * simply remap the key variables to the JupyterLab Dark palette, scoped to
 * furo's dark selectors. Light mode is untouched (nb.css :root still applies).
 * Loaded LAST in html_css_files so it overrides nb.css. */

@media (prefers-color-scheme: dark) {
  body:not([data-theme="light"]) {
    --jp-layout-color0: #131416;
    --jp-layout-color1: #1a1c1e;
    --jp-layout-color2: #26282b;
    --jp-layout-color3: #3a3d41;
    --jp-layout-color4: #4d5155;

    --jp-content-font-color0: rgba(255, 255, 255, 1);
    --jp-content-font-color1: rgba(255, 255, 255, 0.92);
    --jp-content-font-color2: rgba(255, 255, 255, 0.70);
    --jp-content-font-color3: rgba(255, 255, 255, 0.50);
    --jp-ui-font-color0: rgba(255, 255, 255, 1);
    --jp-ui-font-color1: rgba(255, 255, 255, 0.87);
    --jp-ui-font-color2: rgba(255, 255, 255, 0.54);
    --jp-ui-font-color3: rgba(255, 255, 255, 0.38);

    --jp-border-color0: #4d5155;
    --jp-border-color1: #3a3d41;
    --jp-border-color2: #303336;
    --jp-border-color3: #26282b;

    --jp-cell-editor-background: #1a1c1e;
    --jp-cell-editor-border-color: #303336;
    --jp-cell-editor-active-background: #26282b;
    --jp-cell-editor-active-border-color: #2196f3;
    --jp-cell-prompt-not-active-font-color: rgba(255, 255, 255, 0.5);

    --jp-content-link-color: #6ba5ff;
    --jp-rendermime-table-row-background: #1a1c1e;
    --jp-rendermime-table-row-hover-background: rgba(33, 150, 243, 0.12);

    --jp-mirror-editor-keyword-color: #c792ea;
    --jp-mirror-editor-atom-color: #bd93f9;
    --jp-mirror-editor-number-color: #f78c6c;
    --jp-mirror-editor-def-color: #82aaff;
    --jp-mirror-editor-variable-color: #eeffff;
    --jp-mirror-editor-variable-2-color: #7fdbca;
    --jp-mirror-editor-variable-3-color: #82aaff;
    --jp-mirror-editor-punctuation-color: #89ddff;
    --jp-mirror-editor-property-color: #80cbc4;
    --jp-mirror-editor-operator-color: #89ddff;
    --jp-mirror-editor-comment-color: #7a8b99;
    --jp-mirror-editor-string-color: #c3e88d;
    --jp-mirror-editor-string-2-color: #f07178;
    --jp-mirror-editor-meta-color: #82aaff;
    --jp-mirror-editor-builtin-color: #82aaff;
    --jp-mirror-editor-tag-color: #ff5370;
    --jp-mirror-editor-attribute-color: #c792ea;
    --jp-mirror-editor-header-color: #82aaff;
    --jp-mirror-editor-link-color: #80cbc4;
    --jp-mirror-editor-error-color: #ff5370;
  }
}

/* Same overrides for the explicit dark toggle (OS in light mode). */
body[data-theme="dark"] {
  --jp-layout-color0: #131416;
  --jp-layout-color1: #1a1c1e;
  --jp-layout-color2: #26282b;
  --jp-layout-color3: #3a3d41;
  --jp-layout-color4: #4d5155;

  --jp-content-font-color0: rgba(255, 255, 255, 1);
  --jp-content-font-color1: rgba(255, 255, 255, 0.92);
  --jp-content-font-color2: rgba(255, 255, 255, 0.70);
  --jp-content-font-color3: rgba(255, 255, 255, 0.50);
  --jp-ui-font-color0: rgba(255, 255, 255, 1);
  --jp-ui-font-color1: rgba(255, 255, 255, 0.87);
  --jp-ui-font-color2: rgba(255, 255, 255, 0.54);
  --jp-ui-font-color3: rgba(255, 255, 255, 0.38);

  --jp-border-color0: #4d5155;
  --jp-border-color1: #3a3d41;
  --jp-border-color2: #303336;
  --jp-border-color3: #26282b;

  --jp-cell-editor-background: #1a1c1e;
  --jp-cell-editor-border-color: #303336;
  --jp-cell-editor-active-background: #26282b;
  --jp-cell-editor-active-border-color: #2196f3;
  --jp-cell-prompt-not-active-font-color: rgba(255, 255, 255, 0.5);

  --jp-content-link-color: #6ba5ff;
  --jp-rendermime-table-row-background: #1a1c1e;
  --jp-rendermime-table-row-hover-background: rgba(33, 150, 243, 0.12);

  --jp-mirror-editor-keyword-color: #c792ea;
  --jp-mirror-editor-atom-color: #bd93f9;
  --jp-mirror-editor-number-color: #f78c6c;
  --jp-mirror-editor-def-color: #82aaff;
  --jp-mirror-editor-variable-color: #eeffff;
  --jp-mirror-editor-variable-2-color: #7fdbca;
  --jp-mirror-editor-variable-3-color: #82aaff;
  --jp-mirror-editor-punctuation-color: #89ddff;
  --jp-mirror-editor-property-color: #80cbc4;
  --jp-mirror-editor-operator-color: #89ddff;
  --jp-mirror-editor-comment-color: #7a8b99;
  --jp-mirror-editor-string-color: #c3e88d;
  --jp-mirror-editor-string-2-color: #f07178;
  --jp-mirror-editor-meta-color: #82aaff;
  --jp-mirror-editor-builtin-color: #82aaff;
  --jp-mirror-editor-tag-color: #ff5370;
  --jp-mirror-editor-attribute-color: #c792ea;
  --jp-mirror-editor-header-color: #82aaff;
  --jp-mirror-editor-link-color: #80cbc4;
  --jp-mirror-editor-error-color: #ff5370;
}
