/* CSS Variables for theming */
:root {
  --bg-color: #fff;
  --text-color: #222;
  --menu-bg: #f8f9fa;
  --menu-link-color: #495057;
  --border-color: #dee2e6;
  --code-bg: #f0f0f0;
  --accent-color: #2d58b7;
}

[data-theme="dark"] {
  --bg-color: #121212;
  --text-color: #f0f0f0;
  --menu-bg: #1e1e1e;
  --menu-link-color: #e0e0e0;
  --border-color: #404040;
  --code-bg: #2a2a2a;
  --accent-color: #6fa8dc;
}

html {
  margin: 0px;
  height: 100%;
}

body {
  margin: 0;
  padding: 0;
  font-size: 16px; /* Doubled from typical 'small' (usually ~12px) to 16px */
  font-family: "Noto Sans", "Lucida Grande", "Lucida Sans Unicode", Arial, Verdana, Helvetica, sans-serif;
  background-color: var(--bg-color);
  color: var(--text-color);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: background-color 0.3s ease, color 0.3s ease;
}

/* Main container for menu and content */
.main-container {
  display: flex;
  flex: 1;
  min-height: 100vh; /* Allow expansion for long content */
}

/* Content area */
#content {
  flex: 1;
  margin-left: 280px; /* Account for fixed menu width */
  padding: 1em 2em;
  overflow-y: auto;
  background-color: var(--bg-color);
  display: flex;
  flex-direction: column;
  min-height: 100vh; /* Allow expansion for long content */
  box-sizing: border-box; /* Include padding in height calculation */
  transition: background-color 0.3s ease;
}

/* Content wrapper to push footer down */
.content-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 2em); /* Minimum viewport height minus padding */
}

.content-main {
  flex: 1;
  min-height: 0; /* Allow content to shrink if needed */
}

/* Footer styling */
footer {
  margin-top: auto;
  padding: 1em 0;
  text-align: center;
  color: var(--text-color);
  opacity: 0.7;
  font-size: 0.9em;
  border-top: 1px solid var(--border-color);
  transition: color 0.3s ease, border-color 0.3s ease;
  flex-shrink: 0;
}

/* Responsive design */
@media (max-width: 768px) {
  #menu {
    position: relative;
    width: 100%;
    min-width: auto;
    height: auto;
    max-height: 200px;
    border-right: none;
    border-bottom: 1px solid var(--border-color);
  }
  
  #content {
    margin-left: 0;
    padding: 1em;
    min-height: calc(100vh - 200px); /* Account for collapsed menu */
    box-sizing: border-box;
  }
  
  .content-wrapper {
    min-height: calc(100vh - 200px - 2em); /* Minimum height for mobile */
  }
  
  .main-container {
    flex-direction: column;
  }
  
  footer {
    padding: 1em;
  }
}
a {
  color: var(--accent-color);
  text-decoration: none;
  transition: color 0.3s ease;
}

a:hover {
  color: var(--accent-color);
}

a:visited {
  color: var(--accent-color);
}

/* Titles */

.itemTitle {
  color: var(--accent-color);
  transition: color 0.3s ease;
}

h1,
h2,
h3,
tt {
  color: var(--text-color);
  transition: color 0.3s ease;
}

h1 {
  padding-top: 0px;
  margin-top: 0px;
}

h2 {
  color: var(--text-color);
  padding-top: 0.5em;
}

h3 {
  padding-top: 0.5em;
  margin-bottom: -0.25em;
  color: var(--accent-color);
  transition: color 0.3s ease;
}

/* Lists */

ul {
  padding-left: 1.5em;
  margin: 1em 0;
}

ol {
  padding-left: 1.5em;
  margin: 1em 0;
}

li {
  padding-bottom: 0.5em;
  display: list-item;
}

/* Task lists (checkboxes) */
ul.task-list {
  list-style: none;
  padding-left: 0;
}

ul.task-list li {
  display: list-item;
  margin-bottom: 0.5em;
  padding-left: 0;
}

ul.task-list li label {
  display: inline;
  font-weight: normal;
  margin-left: 0.5em;
}

ul.task-list li input[type="checkbox"] {
  margin-right: 0.5em;
}

/* Tables */

tr {
  vertical-align: top;
}

table.ref-arguments {
  border-collapse: collapse;
  width: 100%;
  margin: 1em 0;
  table-layout: auto; /* Allow auto-sizing based on content */
}

table.ref-arguments td {
  padding: 0.75em 1em 0.75em 0;
  vertical-align: top;
  border: none;
  line-height: 1.4;
}

table.ref-arguments td:first-child {
  white-space: nowrap; /* Keep parameter names on one line */
  width: 1%; /* Let it shrink to content size */
  padding-right: 1.5em;
  font-weight: bold;
}

table.ref-arguments td:last-child {
  width: auto; /* Take up remaining space */
}

/* Code */

pre {
  background-color: var(--code-bg);
  border: 1px solid var(--border-color);
  padding: 1em;
  border-radius: 4px;
  overflow-x: auto;
  transition: background-color 0.3s ease, border-color 0.3s ease;
}

code {
  background-color: var(--code-bg);
  padding: 0.2em 0.4em;
  border-radius: 3px;
  font-family: "Hack", "Fira Mono", "Courier New", Courier, monospace;
  transition: background-color 0.3s ease;
}

/* Links inside code blocks */
code a {
  color: var(--accent-color);
  text-decoration: none;
  font-weight: 500;
}

code a:hover {
  color: var(--accent-color);
}

code a:visited {
  color: var(--accent-color);
}

pre code {
  background-color: transparent;
  padding: 0;
}

/* Reference documentation */

.ref-usage {
  background-color: var(--code-bg);
  padding: 1em;
  border-left: 4px solid var(--accent-color);
  margin: 1em 0;
  transition: background-color 0.3s ease, border-color 0.3s ease;
}

/* Vignette code blocks - same styling as ref-usage */
#content pre {
  background-color: var(--code-bg);
  border-left: 4px solid var(--accent-color);
  font-family: "Hack", "Fira Mono", "Courier New", Courier, monospace;
  transition: background-color 0.3s ease, border-color 0.3s ease;
}

.ref-arguments dt {
  font-weight: bold;
  margin-top: 1em;
}

.ref-arguments dd {
  margin-left: 2em;
  margin-bottom: 0.5em;
}

/* Spans */

span.error {
  color: red;
}

span.warning {
  color: purple;
}

span.note {
  color: gray;
}

span.caret {
  color: green;
  font-weight: bold;
}

span.template-highlight {
  color: cyan;
}

/* Navigation */

.nav-active {
  font-weight: bold;
  background-color: var(--accent-color) !important;
  color: var(--bg-color) !important;
  transition: background-color 0.3s ease, color 0.3s ease;
}

/* Images */

IMG.img_slide {
  display: block;
  margin-left: auto;
  margin-right: auto;
}

/* MathJax styling - minimal for SVG rendering */

/* Display math (block equations) */
mjx-container[jax="SVG"][display="true"] {
  display: block;
  text-align: center;
  margin: 1em 0;
}

/* SVG elements should inherit text color for dark mode */
[data-theme="dark"] mjx-container[jax="SVG"] svg {
  color: var(--text-color);
}

/* Styling for executed R examples */
.sourceCode {
  margin-bottom: 0.5em;
}

.sourceCode pre {
  background-color: var(--code-bg);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  padding: 0.8em;
  margin: 0;
}

.output {
  margin-bottom: 1em;
}

.output pre {
  background-color: rgba(0, 0, 0, 0.05);
  border: none;
  border-radius: 4px;
  padding: 0.8em;
  margin: 0;
  color: #666;
}

[data-theme="dark"] .output pre {
  background-color: rgba(255, 255, 255, 0.05);
  color: #ccc;
}

.error pre {
  background-color: rgba(220, 53, 69, 0.1);
  border: 1px solid rgba(220, 53, 69, 0.3);
  border-radius: 4px;
  padding: 0.8em;
  margin: 0;
  color: #dc3545;
}

/* References section styling */
#refs.references {
  margin-bottom: 2em;
}

#refs.references .csl-entry {
  margin-bottom: 1em;
  padding-bottom: 0.5em;
}

/* Add extra spacing for the last reference entry */
#refs.references .csl-entry:last-child {
  margin-bottom: 1.5em;
}
