/* Forest Sand / Earthpunk Color Palette */

:root,
[data-theme="light"] {
  color-scheme: light; /* native scrollbars, form controls and media players follow the theme */

  --neutral-100: #f0f0e8;
  --neutral-200: #e0e0d8;
  --neutral-300: #ccd5c4;
  --neutral-400: #a7b397;
  --neutral-500: #778868;
  --neutral-600: #556246;
  --neutral-700: #3a4830;
  --neutral-800: #2c3b2d;
  --neutral-900: #1c2a1d;

  --accent-main: #e5e8e0;
  --accent-dark: #2c3b2d;
  --accent-gray: #3a5a40;
  --accent-light: #588157;
  --accent-light-2: #a3b18a;
  --accent-solarized: #dad7cd21;
  --accent-active: #e9c46a;
  --accent-inactive: #00000045;
  --accent-highlight: #80b192;
  --accent-alt: #bb5a41;
  --accent-alt2: #e76f51;
  --accent-emphasis: #859900;
  --alt: #5a5044;

  --text: #2c3b2d;
  --text-dim: #59654d; /* AA contrast (>= 4.5:1) on --bg and --bg-alt */
  --text-alt: #e5e8e0;
  --text-alt-dim: #e5e8e085;
  --bg: var(--neutral-100);
  --bg-alt: var(--neutral-200);
  --surface: rgba(255, 255, 252, 0.72);
  --surface-hover: rgba(255, 255, 252, 0.96);
  --border-subtle: rgba(58, 90, 64, 0.16);
  --border-strong: rgba(58, 90, 64, 0.36);
  --grid-dot: rgba(58, 90, 64, 0.14);
  --paper-noise-bg: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cfilter id='p' x='0%25' y='0%25' width='100%25' height='100%25' color-interpolation-filters='sRGB'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch' result='n'/%3E%3CfeDiffuseLighting in='n' lighting-color='%23f5f3ea' surfaceScale='0.95'%3E%3CfeDistantLight azimuth='45' elevation='70'/%3E%3C/feDiffuseLighting%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23p)' opacity='0.17'/%3E%3C/svg%3E");
  --tag-card-text: #f0f0e8;

  /* Math & prose callouts */
  --text-math: #2c3b2d;
  --text-blockquote: #2c3b2d;
  --bg-blockquote: linear-gradient(135deg, #f9f9f5 0%, #e7ece1 100%);
  --bg-definition: linear-gradient(135deg, rgba(249, 249, 245, 0.9) 0%, rgba(227, 234, 225, 0.7) 100%);

  /* Forest Sand Light Syntax Highlighting */
  --text-code: #1a1a1a;
  --text-string: #8c6a00;
  --text-number: #d33682;
  --text-keyword: #006400;
  --text-comment: #657474;
  --text-function: #8f5902;
  --text-constant: #cb4b16;
  --text-emphasis: #657b83;
  --bg-code: #fdf6e3;
  --border-code: #eee8d5;
  --syntax-err: var(--accent-alt2);
  --syntax-del: #a00;
  --syntax-ins: #0a0;
}

[data-theme="dark"] {
  color-scheme: dark;

  --neutral-100: #061106;
  --neutral-200: #050605;
  --neutral-300: #292e25;
  --neutral-400: #3c4631;
  --neutral-500: #5e724c;
  --neutral-600: #a7b397;
  --neutral-700: #ccd5c4;
  --neutral-800: #e5e8e0;
  --neutral-900: #f6f7f4;

  --accent-main: rgb(85, 98, 70);
  --accent-dark: #dad7cd;
  --accent-gray: #a3b18a;
  --accent-light: #588157;
  --accent-light-2: #3a5a40;
  --accent-solarized: #0d0e0c7a;
  --accent-active: #f1d29e;
  --accent-inactive: #dad7cd21;
  --accent-highlight: #a7b397;
  --accent-alt: #e76f51;
  --accent-alt2: #bb5a41;
  --accent-emphasis: #859900;
  --alt: #6d1b1b;

  --text: #afb4ad;
  --text-dim: #a3b18a;
  --text-alt: #151915;
  --text-alt-dim: #0d0e0d6b;
  --bg: var(--neutral-100);
  --bg-alt: var(--neutral-200);
  --surface: rgba(20, 30, 20, 0.78);
  --surface-hover: rgba(28, 42, 28, 0.94);
  --border-subtle: rgba(163, 177, 138, 0.16);
  --border-strong: rgba(163, 177, 138, 0.36);
  --grid-dot: rgba(163, 177, 138, 0.13);
  --paper-noise-bg: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cfilter id='p' x='0%25' y='0%25' width='100%25' height='100%25' color-interpolation-filters='sRGB'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch' result='n'/%3E%3CfeDiffuseLighting in='n' lighting-color='%23d8e0d2' surfaceScale='1.1'%3E%3CfeDistantLight azimuth='45' elevation='66'/%3E%3C/feDiffuseLighting%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23p)' opacity='0.048'/%3E%3C/svg%3E");
  --tag-card-text: #f6f7f4;

  /* Math & prose callouts */
  --text-math: #dad8d8;
  --text-blockquote: #d5dbd0;
  --bg-blockquote: linear-gradient(135deg, #121a12 0%, #1b241a 100%);
  --bg-definition: linear-gradient(135deg, rgba(18, 26, 18, 0.9) 0%, rgba(27, 36, 26, 0.8) 100%);

  /* Forest Sand Dark Syntax Highlighting */
  --text-code: #d3d7cf;
  --text-string: #c8965d;
  --text-number: rgb(185, 91, 91);
  --text-keyword: #8fa87a;
  --text-comment: #6c848c;
  --text-function: #c9a252;
  --text-constant: #cb4b16;
  --text-emphasis: #839496;
  --bg-code: #090908;
  --border-code: #3828288c;
  --syntax-err: var(--accent-alt);
  --syntax-del: #f66;
  --syntax-ins: #6f6;
}

/* Diagrams with white backgrounds adapt cleanly to both themes */
[data-theme="light"] .invertable img,
[data-theme="light"] .invertable svg {
  filter: none;
  mix-blend-mode: multiply;
  transition: filter 400ms ease;
}

[data-theme="dark"] .invertable img,
[data-theme="dark"] .invertable svg {
  filter: invert(1) hue-rotate(180deg) brightness(0.92);
  mix-blend-mode: lighten;
  transition: filter 400ms ease;
}

/* Light-rendered transparent matplotlib charts auto-invert cleanly in dark mode
   (tag a code cell with `no_invert` to opt out for dark heatmaps / photos). */
[data-theme="dark"] .jp-Cell:not(.celltag_no_invert) .jp-RenderedImage img {
  filter: invert(1) hue-rotate(180deg) brightness(0.95);
  transition: filter 400ms ease;
}
