@import url("https://fonts.googleapis.com/css2?family=Crimson+Pro:ital,wght@0,500;0,600;0,700;1,500&family=DM+Mono:ital,wght@0,400;0,500;1,400&family=Lora:ital,wght@0,400;0,500;0,600;1,400;1,500&display=swap");

/* --------------------------------------------------------------------------
   Programmering i kjemi – et varmt, moderne og boklig Jupyter Book-tema
   -------------------------------------------------------------------------- */

:root {
  --chem-paper: #faf7f2;
  --chem-paper-deep: #f2ece0;
  --chem-paper-dark: #e8decd;
  --chem-ink: #2a2218;
  --chem-ink-muted: #675d51;
  --chem-line: #ddd0b8;
  --chem-petrol: #1d4a4d;
  --chem-petrol-dark: #15383b;
  --chem-petrol-soft: #dce8e5;
  --chem-copper: #99542f;
  --chem-copper-soft: #ead5c5;
  --chem-code: #f4efe6;
  --chem-shadow: 0 18px 50px rgba(61, 45, 28, 0.09);

  --pst-color-primary: var(--chem-petrol);
  --pst-color-link: var(--chem-copper);
  --pst-color-link-hover: var(--chem-petrol);
  --pst-color-background: var(--chem-paper);
  --pst-color-on-background: var(--chem-ink);
  --pst-color-surface: var(--chem-paper-deep);
  --pst-color-border: var(--chem-line);
  --pst-font-family-base: "Lora", Georgia, serif;
  --pst-font-family-heading: "Crimson Pro", Georgia, serif;
  --pst-font-family-monospace: "DM Mono", "SFMono-Regular", Consolas, monospace;
}

html[data-theme="dark"] {
  --chem-paper: #192326;
  --chem-paper-deep: #222f32;
  --chem-paper-dark: #2b3a3d;
  --chem-ink: #f3ede3;
  --chem-ink-muted: #c8bfb3;
  --chem-line: #405154;
  --chem-petrol: #8fc0ba;
  --chem-petrol-dark: #b7d9d4;
  --chem-petrol-soft: #293f40;
  --chem-copper: #e2a078;
  --chem-copper-soft: #4d352c;
  --chem-code: #202c2f;
  --chem-shadow: 0 18px 50px rgba(0, 0, 0, 0.18);

  --pst-color-primary: var(--chem-petrol);
  --pst-color-link: var(--chem-copper);
  --pst-color-link-hover: #f0b68f;
  --pst-color-background: var(--chem-paper);
  --pst-color-on-background: var(--chem-ink);
  --pst-color-surface: var(--chem-paper-deep);
  --pst-color-border: var(--chem-line);
}

html {
  scroll-behavior: smooth;
}

body {
  background: var(--chem-paper);
  color: var(--chem-ink);
  font-family: "Lora", Georgia, serif !important;
  font-size: 1.08rem;
  line-height: 1.78;
  text-rendering: optimizeLegibility;
}

p,
li,
td,
th,
blockquote {
  font-family: "Lora", Georgia, serif;
}

::selection {
  background: var(--chem-copper-soft);
  color: var(--chem-ink);
}

/* Layout and reading width */

.bd-page-width {
  max-width: 1520px;
}

.bd-main .bd-content .bd-article-container {
  max-width: 860px;
}

.bd-article {
  padding-top: clamp(1.5rem, 3vw, 3.1rem);
}

.bd-article > p {
  margin-bottom: 1.25rem;
}

/* Typography */

h1,
h2,
h3,
h4,
h5,
h6,
.navbar-brand,
.caption-text,
.admonition-title,
.prev-next-title {
  color: var(--chem-ink);
  font-family: "Crimson Pro", Georgia, serif !important;
  font-weight: 600;
  letter-spacing: -0.018em;
}

h1 {
  margin-bottom: 1.35rem;
  font-size: clamp(2.65rem, 6vw, 4.65rem);
  font-weight: 600;
  line-height: 0.98;
  letter-spacing: -0.045em;
}

h2 {
  margin-top: 3.6rem;
  margin-bottom: 1.15rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--chem-line);
  font-size: clamp(2rem, 3.6vw, 2.65rem);
  line-height: 1.08;
}

h3 {
  margin-top: 2.3rem;
  font-size: 1.65rem;
  line-height: 1.2;
}

h4,
h5,
h6 {
  margin-top: 1.9rem;
}

a {
  color: var(--chem-copper);
  text-decoration-color: color-mix(in srgb, var(--chem-copper) 36%, transparent);
  text-decoration-thickness: 0.08em;
  text-underline-offset: 0.17em;
  transition: color 160ms ease, text-decoration-color 160ms ease;
}

a:hover {
  color: var(--chem-petrol);
  text-decoration-color: currentColor;
}

blockquote {
  margin: 2rem 0;
  padding: 0.35rem 0 0.35rem 1.45rem;
  border-left: 3px solid var(--chem-copper);
  color: var(--chem-ink-muted);
  font-size: 1.08em;
  font-style: italic;
}

hr {
  margin: 3rem 0;
  border-color: var(--chem-line);
  opacity: 1;
}

/* Primary navigation */

.bd-sidebar-primary {
  background: var(--chem-paper-deep);
  border-right: 1px solid var(--chem-line);
}

.bd-sidebar-primary .sidebar-primary-items__start {
  padding-top: 1rem;
}

.navbar-brand.logo {
  margin: 0.15rem 0 1.1rem;
  padding: 0.85rem;
  border-radius: 16px;
  background: color-mix(in srgb, var(--chem-paper) 70%, transparent);
}

.navbar-brand.logo img {
  max-height: 88px;
  transition: transform 180ms ease;
}

.navbar-brand.logo:hover img {
  transform: translateY(-2px);
}

.bd-links .caption {
  margin-top: 1.45rem;
  margin-bottom: 0.35rem;
  padding: 0 0.7rem;
}

.bd-links .caption-text {
  color: var(--chem-petrol-dark);
  font-size: 0.83rem;
  font-weight: 700;
  letter-spacing: 0.075em;
  line-height: 1.35;
  text-transform: uppercase;
}

.bd-sidebar-primary .bd-links .nav-link,
.bd-sidebar-primary .bd-links li > a {
  margin: 0.08rem 0;
  padding: 0.48rem 0.72rem;
  border-radius: 9px;
  color: var(--chem-ink-muted);
  font-family: "Crimson Pro", Georgia, serif;
  font-size: 1.02rem;
  font-weight: 500;
  line-height: 1.25;
  text-decoration: none;
  transition: background-color 150ms ease, color 150ms ease, transform 150ms ease;
}

.bd-sidebar-primary .bd-links .nav-link:hover,
.bd-sidebar-primary .bd-links li > a:hover {
  background: color-mix(in srgb, var(--chem-petrol-soft) 72%, transparent);
  color: var(--chem-petrol-dark);
  transform: translateX(2px);
}

.bd-sidebar-primary .bd-links .current > a,
.bd-sidebar-primary .bd-links .active > a,
.bd-sidebar-primary .bd-links a.current,
.bd-sidebar-primary .bd-links a.active {
  background: var(--chem-petrol-soft);
  color: var(--chem-petrol-dark);
  font-weight: 700;
  box-shadow: inset 3px 0 0 var(--chem-copper);
}

.bd-sidebar-secondary {
  color: var(--chem-ink-muted);
  font-size: 0.88rem;
}

.bd-sidebar-secondary .onthispage {
  color: var(--chem-petrol-dark);
  font-family: "Crimson Pro", Georgia, serif;
  font-size: 1.05rem;
  font-weight: 700;
}

.bd-sidebar-secondary .nav-link {
  color: var(--chem-ink-muted);
  text-decoration: none;
}

.bd-sidebar-secondary .nav-link.active,
.bd-sidebar-secondary .nav-link:hover {
  color: var(--chem-copper);
}

/* Search and top controls */

.search-button__button,
form.bd-search,
.bd-search .form-control {
  border-color: var(--chem-line) !important;
  background: var(--chem-paper) !important;
  color: var(--chem-ink) !important;
  font-family: "Lora", Georgia, serif;
}

.bd-search .form-control:focus {
  border-color: var(--chem-petrol) !important;
  box-shadow: 0 0 0 0.2rem color-mix(in srgb, var(--chem-petrol) 16%, transparent);
}

#pst-back-to-top {
  background: var(--chem-petrol-dark);
  color: var(--chem-paper);
  box-shadow: var(--chem-shadow);
}

/* Code and notebook cells */

code,
tt,
pre,
.highlight,
.highlight pre,
.cell_input,
.cell_output pre {
  font-family: "DM Mono", "SFMono-Regular", Consolas, monospace !important;
}

code.literal,
p code,
li code,
td code {
  padding: 0.14em 0.35em;
  border: 1px solid var(--chem-line);
  border-radius: 5px;
  background: var(--chem-code);
  color: var(--chem-petrol-dark);
  font-size: 0.86em;
}

div.highlight,
pre,
.cell_input {
  border: 1px solid var(--chem-line) !important;
  border-radius: 12px !important;
  background: var(--chem-code) !important;
  box-shadow: 0 9px 28px rgba(61, 45, 28, 0.06);
}

div.highlight pre,
.cell_input pre {
  padding: 1.15rem 1.25rem !important;
  border: 0 !important;
  background: transparent !important;
  box-shadow: none;
  font-size: 0.88rem;
  line-height: 1.62;
}

.cell_input {
  position: relative;
  overflow: hidden;
  border-left: 4px solid var(--chem-petrol) !important;
}

.cell_output {
  margin-top: 0.65rem;
  padding-left: 1rem;
  border-left: 2px solid var(--chem-copper-soft);
  color: var(--chem-ink);
}

.cell_output .output,
.cell_output pre {
  background: transparent !important;
  box-shadow: none;
}

.copybtn {
  border-color: var(--chem-line) !important;
  background: var(--chem-paper) !important;
  color: var(--chem-ink-muted) !important;
}

/* Admonitions and learning boxes */

.admonition {
  margin: 2rem 0;
  overflow: hidden;
  border: 1px solid var(--chem-line) !important;
  border-left: 4px solid var(--chem-petrol) !important;
  border-radius: 12px !important;
  background: color-mix(in srgb, var(--chem-paper-deep) 64%, var(--chem-paper)) !important;
  box-shadow: 0 10px 30px rgba(61, 45, 28, 0.06);
}

.admonition > .admonition-title {
  margin: 0 !important;
  padding: 0.72rem 1rem !important;
  border-bottom: 1px solid var(--chem-line);
  background: var(--chem-petrol-soft) !important;
  color: var(--chem-petrol-dark) !important;
  font-size: 1.16rem;
}

.admonition > :not(.admonition-title) {
  margin-right: 1rem;
  margin-left: 1rem;
}

.admonition.warning,
.admonition.caution,
.admonition.attention {
  border-left-color: var(--chem-copper) !important;
}

.admonition.warning > .admonition-title,
.admonition.caution > .admonition-title,
.admonition.attention > .admonition-title {
  background: var(--chem-copper-soft) !important;
  color: var(--chem-ink) !important;
}

/* Tables, figures and mathematics */

table.table {
  margin: 1.8rem 0;
  overflow: hidden;
  border: 1px solid var(--chem-line);
  border-radius: 10px;
  color: var(--chem-ink);
  box-shadow: 0 8px 24px rgba(61, 45, 28, 0.05);
}

table.table thead th {
  border-color: var(--chem-line);
  background: var(--chem-paper-dark);
  color: #5a3010;
  font-family: "Crimson Pro", Georgia, serif;
  font-size: 1.02rem;
  font-weight: 700;
}

html[data-theme="dark"] table.table thead th {
  color: var(--chem-ink);
}

table.table tbody tr:nth-child(even) {
  background: color-mix(in srgb, var(--chem-paper-deep) 68%, transparent);
}

table.table td,
table.table th {
  border-color: var(--chem-line);
}

figure,
.figure {
  margin-top: 2.2rem;
  margin-bottom: 2.2rem;
}

figcaption,
.caption-text {
  color: var(--chem-ink-muted);
}

.math,
.MathJax {
  color: var(--chem-ink);
}

/* Homepage */

.chem-home-kicker {
  margin: 0 0 0.65rem;
  color: var(--chem-copper);
  font-family: "DM Mono", monospace;
  font-size: 0.76rem;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.chem-home-lead {
  max-width: 760px;
  margin-bottom: 1.35rem;
  color: var(--chem-ink-muted);
  font-size: clamp(1.14rem, 2vw, 1.35rem);
  line-height: 1.67;
}

.chem-home-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin: 1.6rem 0 1.2rem;
}

.chem-button {
  display: inline-flex;
  align-items: center;
  min-height: 46px;
  padding: 0.68rem 1.1rem;
  border: 1px solid var(--chem-petrol-dark);
  border-radius: 999px;
  background: var(--chem-petrol-dark);
  color: var(--chem-paper) !important;
  font-family: "DM Mono", monospace;
  font-size: 0.79rem;
  font-weight: 500;
  letter-spacing: 0.025em;
  text-decoration: none !important;
  box-shadow: 0 8px 22px rgba(29, 74, 77, 0.16);
  transition: transform 160ms ease, box-shadow 160ms ease, background-color 160ms ease;
}

.chem-button:hover {
  background: var(--chem-petrol);
  color: var(--chem-paper) !important;
  transform: translateY(-2px);
  box-shadow: 0 12px 28px rgba(29, 74, 77, 0.2);
}

.chem-button--secondary {
  border-color: var(--chem-line);
  background: transparent;
  color: var(--chem-petrol-dark) !important;
  box-shadow: none;
}

.chem-button--secondary:hover {
  border-color: var(--chem-petrol);
  background: var(--chem-petrol-soft);
  color: var(--chem-petrol-dark) !important;
}

.chem-home-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  margin: 1.35rem 0 2.6rem;
}

.chem-home-tags span {
  padding: 0.33rem 0.68rem;
  border: 1px solid var(--chem-line);
  border-radius: 999px;
  color: var(--chem-ink-muted);
  font-family: "DM Mono", monospace;
  font-size: 0.7rem;
  letter-spacing: 0.035em;
}

.chem-section-intro {
  max-width: 660px;
  color: var(--chem-ink-muted);
}

.chem-topic-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  margin: 1.65rem 0 3rem;
}

.chem-topic-card {
  position: relative;
  display: flex;
  min-height: 220px;
  flex-direction: column;
  padding: 1.35rem 1.45rem 1.25rem;
  overflow: hidden;
  border: 1px solid var(--chem-line);
  border-radius: 15px;
  background: color-mix(in srgb, var(--chem-paper-deep) 62%, var(--chem-paper));
  color: var(--chem-ink) !important;
  text-decoration: none !important;
  box-shadow: 0 9px 30px rgba(61, 45, 28, 0.055);
  transition: transform 180ms ease, border-color 180ms ease, box-shadow 180ms ease;
}

.chem-topic-card::after {
  position: absolute;
  right: -34px;
  bottom: -52px;
  width: 130px;
  height: 130px;
  border: 22px solid color-mix(in srgb, var(--chem-copper-soft) 58%, transparent);
  border-radius: 50%;
  content: "";
  transition: transform 220ms ease;
}

.chem-topic-card:hover {
  border-color: color-mix(in srgb, var(--chem-copper) 55%, var(--chem-line));
  color: var(--chem-ink) !important;
  transform: translateY(-4px);
  box-shadow: var(--chem-shadow);
}

.chem-topic-card:hover::after {
  transform: scale(1.08);
}

.chem-topic-number {
  color: var(--chem-copper);
  font-family: "DM Mono", monospace;
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.08em;
}

.chem-topic-card h3 {
  margin: 0.5rem 0 0.45rem;
  color: var(--chem-petrol-dark);
  font-size: 1.62rem;
}

.chem-topic-card p {
  max-width: 92%;
  margin: 0 0 1.2rem;
  color: var(--chem-ink-muted);
  font-size: 0.92rem;
  line-height: 1.58;
}

.chem-topic-link {
  z-index: 1;
  margin-top: auto;
  color: var(--chem-copper);
  font-family: "DM Mono", monospace;
  font-size: 0.72rem;
  font-weight: 500;
}

.chem-use-panel {
  margin: 1.6rem 0 2.4rem;
  padding: clamp(1.3rem, 3vw, 2rem);
  border: 1px solid var(--chem-line);
  border-radius: 15px;
  background: var(--chem-paper-deep);
}

.chem-use-panel h3 {
  margin-top: 0;
  color: var(--chem-petrol-dark);
}

.chem-use-panel ol {
  margin-bottom: 0;
  padding-left: 1.35rem;
}

.chem-use-panel li {
  margin: 0.6rem 0;
  padding-left: 0.35rem;
}

/* Footer and page navigation */

.prev-next-area {
  margin-top: 4rem;
  padding-top: 1.4rem;
  border-top: 1px solid var(--chem-line);
}

.prev-next-area a {
  border-color: var(--chem-line) !important;
  border-radius: 12px;
  background: var(--chem-paper-deep);
  color: var(--chem-ink);
  text-decoration: none;
  transition: border-color 160ms ease, transform 160ms ease;
}

.prev-next-area a:hover {
  border-color: var(--chem-copper) !important;
  transform: translateY(-2px);
}

.prev-next-subtitle {
  color: var(--chem-copper);
  font-family: "DM Mono", monospace;
  font-size: 0.7rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

footer,
.bd-footer {
  border-top-color: var(--chem-line);
  background: var(--chem-paper-deep);
  color: var(--chem-ink-muted);
  font-size: 0.84rem;
}

/* Responsive refinements */

@media (max-width: 959px) {
  body {
    font-size: 1.02rem;
  }

  .bd-header {
    border-bottom: 1px solid var(--chem-line);
    background: var(--chem-paper-deep);
  }

  .chem-topic-grid {
    grid-template-columns: 1fr;
  }

  .chem-topic-card {
    min-height: 190px;
  }
}

@media (max-width: 575px) {
  h1 {
    font-size: 2.65rem;
  }

  h2 {
    margin-top: 2.8rem;
    font-size: 2rem;
  }

  .bd-article {
    padding-top: 1.25rem;
  }

  .chem-home-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .chem-button {
    justify-content: center;
  }

  .chem-topic-card {
    min-height: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
