/* Root variables for light mode (default) */
:root {
  --q-primary: #fff;
  --q-secondary: #5c80a8;
  --q-font-family-base: 'Arial', sans-serif;
  --q-heading-font-family: 'Georgia', serif;
  --q-text-color: #222222;
  --q-background-color: #fff;
  --q-accent: #222;
  --q-accent-light: #fff4e6;
  --q-border-radius: 8px;

  --background: #333;
  --highlight: #39AC4C;
}

/* Dark mode variables */
@media (prefers-color-scheme: dark) {
  :root {
    --q-primary: #121212;
    --q-secondary: #5c80a8;
    --q-font-family-base: 'Arial', sans-serif;
    --q-heading-font-family: 'Georgia', serif;
    --q-text-color: #fff;
    --q-background-color: #121212;
    --q-accent: #b3b3b3;
    --q-accent-light: #333;

    --background: #121212;
    --highlight: #5c80a8;
  }
}

/* General body styles */
body {
  font-family: var(--q-font-family-base);
  color: var(--q-text-color);
  background-color: var(--q-background-color);
  margin: 0;
  padding: 0;
  transition: background-color 0.3s, color 0.3s;
}

/* Theme Switcher */
.theme-switch {
  --background: var(--q-background-color);
  --text: var(--q-text-color);
  width: 70px;
  height: 30px;
  background: var(--highlight);
  border-radius: 50px;
  position: relative;
  margin: 1rem;
}

.theme-switch .switch {
  background: var(--background);
  width: 24px;
  height: 24px;
  border-radius: 100%;
  position: absolute;
  top: 3px;
  left: 4px;
  transition: 0.5s all ease;
}

.light-theme {
  --background: #FFF;
  --text: #000;
  background: var(--background);
}

.light-theme .theme-switch {
  background: var(--text);
}

.light-theme .theme-switch .switch {
  transform: translateX(37px);
}

/* Navbar */
.navbar {
  background-color: var(--q-secondary);
  color: #fff;
  padding: 1rem 2rem;
  border-bottom: 3px solid var(--q-primary);
}

.navbar a {
  color: #fff;
  text-decoration: none;
  font-weight: bold;
  margin-right: 1.5rem;
  transition: color 0.2s;
}

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

/* Headings */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--q-heading-font-family);
  color: var(--q-secondary);
  margin-top: 1.5em;
}

/* Links */
a {
  color: var(--q-secondary);
  text-decoration: underline;
  transition: color 0.2s;
  text-underline-offset: 3px;
}

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

/* Fix for Quarto about section links */
div.quarto-about-trestles .about-entity .about-link,
div.quarto-about-marquee .about-link {
  color: var(--q-secondary) !important;
  text-decoration: none;
  border: solid 1px;
}

div.quarto-about-trestles .about-entity .about-link:hover {
  color: var(--q-accent) !important;
  text-decoration: underline;
}

div.quarto-post a {
  color: var(--q-text-color) !important;
  text-decoration: none;
}

/* Buttons */
.button, button, input[type="submit"] {
  background-color: var(--q-secondary);
  color: #fff;
  border: none;
  border-radius: var(--q-border-radius);
  padding: 0.6em 1.2em;
  font-family: var(--q-font-family-base);
  font-size: 1em;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}

.button:hover, button:hover, input[type="submit"]:hover {
  background-color: var(--q-primary);
  color: var(--q-secondary);
  border: 1px solid var(--q-secondary);
}

/* Card styles */
.card {
  background: var(--q-accent-light);
  border: 1px solid #eaeaea;
  border-radius: var(--q-border-radius);
  box-shadow: 0 2px 8px rgba(231, 117, 0, 0.08);
  padding: 1.5rem;
  margin-bottom: 2rem;
}

/* Accent highlight */
.accent {
  background: var(--q-accent);
  color: var(--q-secondary);
  padding: 0.2em 0.6em;
  border-radius: var(--q-border-radius);
  font-weight: bold;
}

/* Table styles */
table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
  font-size: 1em;
}

th, td {
  border: 1px solid #ddd;
  padding: 0.75em;
  text-align: left;
}

th {
  background-color: var(--q-secondary);
  color: #fff;
  font-family: var(--q-heading-font-family);
}

tr:nth-child(even) {
  background-color: #f5f5f5;
}

/* Scrollable container */
.scrollable {
  max-height: 75vh;
  overflow-y: auto;
  padding-right: 1em;
  box-sizing: border-box;
  border-radius: var(--q-border-radius);
  background-color: var(--q-background-color);
  font-size: 0.8em; /* smaller font for scrollable panels */
}

.scrollable > * {
  max-width: 100%;
  margin-left: auto;
  margin-right: auto;
}

.scrollable img,
.scrollable svg,
.scrollable canvas {
  max-width: 100%;
  height: auto;
  display: block;
  margin-left: auto;
  margin-right: auto;
}

.scrollable pre {
  overflow: auto !important;
  max-height: 400px;
}

/* Webkit scrollbar appearance */
.scrollable::-webkit-scrollbar {
  width: 10px;
}

.scrollable::-webkit-scrollbar-thumb {
  background-color: rgba(100, 100, 100, 0.5);
  border-radius: 10px;
}

/* Code blocks and inline code */
pre, code {
  background-color: var(--q-accent-light);
  color: var(--q-text-color);
  font-family: 'Fira Mono', 'Consolas', 'Menlo', 'Monaco', monospace;
  border-radius: 6px;
  padding: 0.5em 0.75em;
  font-size: 1em;
}

/* Black x- and y axes / general plot responsiveness */
.reveal .slides section img,
.reveal .slides section svg,
.reveal .slides section canvas {
  max-width: 100% !important;
  height: auto !important;
  display: block;
  margin-left: auto;
  margin-right: auto;
}

/* Dark mode adjustments */
@media (prefers-color-scheme: dark) {
  body {
    background-color: var(--q-background-color);
    color: var(--q-text-color);
  }

  pre, code {
    background-color: #1e1e1e;
    color: #e0e0e0;
  }

  .scrollable {
    background-color: #121212;
  }

  table {
    background-color: #121212;
    color: #e0e0e0;
  }

  th {
    background-color: #283d3b;
    color: #fff;
  }

  td {
    background-color: #1a1a1a;
    color: #e0e0e0;
  }

  tr:nth-child(even) {
    background-color: #222;
  }
}

/* Responsive adjustments */
@media (max-width: 600px) {
  .navbar {
    padding: 1rem;
  }
  .card {
    padding: 1rem;
  }
  th, td {
    padding: 0.5em;
  }
}
