/* Custom CSS overrides for Bootstrap */

:root {
  /* Light mode colors */
  --cream-bg: #faf8f3;
  --slate-text: #2d3748;
  --slate-text-dark: #1a202c;
  --light-cream: #fefcf7;
  --section-cream-light: #fcfaf6;
  --section-cream-dark: #f0ede5;
  --border-color: rgba(45, 55, 72, 0.2);
  --gradient-start: #f5f2ea;
  --main-bg: #fefdfb;
  --code-bg: rgba(45, 55, 72, 0.1);
  --text-muted: #6c757d;
  --btn-text: #fefcf7;
  --card-bg: #ffffff;
  --card-border: rgba(45, 55, 72, 0.125);
}

/* Dark mode - automatically applied based on system preference */
@media (prefers-color-scheme: dark) {
  :root {
    --cream-bg: #1a1714;
    --slate-text: #e8e4db;
    --slate-text-dark: #f5f2ec;
    --light-cream: #232019;
    --section-cream-light: #211e1a;
    --section-cream-dark: #141210;
    --border-color: rgba(232, 228, 219, 0.15);
    --gradient-start: #1f1b17;
    --main-bg: #1c1815;
    --code-bg: rgba(232, 228, 219, 0.1);
    --text-muted: #b8b0a3;
    --btn-text: #1a1714;
    --card-bg: #232019;
    --card-border: rgba(232, 228, 219, 0.1);
  }

  .format-icon {
    filter: invert(1) brightness(0.9) sepia(0.2) hue-rotate(15deg) !important;
  }

  .navbar-toggler-icon {
    filter: invert(1) brightness(0.9) sepia(0.2) hue-rotate(15deg);
  }
}

/* Global background and text colors */
html {
  background-color: var(--cream-bg);
  height: 100%;
}

body {
  background-color: var(--cream-bg);
  color: var(--slate-text);
  font-family: "Merriweather", ui-serif, Georgia, "Iowan Old Style", "Palatino Linotype", serif;
  min-height: 100%;
  display: flex;
  flex-direction: column;
}

/* Headers */

h4 {
    margin-top: 1em;
}

/* Site-wide link styling */
a {
  color: var(--slate-text);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

a:hover {
  text-decoration-thickness: 2px;
}

/* Make main content grow to fill available space */
main {
  flex: 1;
}

/* Main wrapper with gradient background */
.main-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: linear-gradient(to bottom, var(--gradient-start) 0%, var(--cream-bg) 200px);
}

.main-wrapper main {
  flex: 1;
}

/* Override Bootstrap's default navbar styling */
.navbar-light {
  background-color: var(--light-cream) !important;
  border-bottom: 1px solid var(--border-color);
}

.navbar-light .navbar-nav .nav-link {
  color: var(--slate-text);
  position: relative;
  transition: all 0.2s ease;
}

.navbar-light .navbar-nav .nav-link:hover,
.navbar-light .navbar-nav .nav-link.active {
  color: var(--slate-text);
  opacity: 1;
}

/* Desktop navigation indicator - triangle below */
@media (min-width: 576px) {
  .navbar-light .navbar-nav .nav-link:hover::after,
  .navbar-light .navbar-nav .nav-link.active::after {
    content: "";
    position: absolute;
    bottom: -8px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-bottom: 4px solid var(--slate-text);
  }
}

/* Mobile navigation indicator - right-facing arrow to the left */
@media (max-width: 575.98px) {
  .navbar-light .navbar-nav .nav-link:hover::before,
  .navbar-light .navbar-nav .nav-link.active::before {
    content: "";
    position: absolute;
    left: -12px;
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border-top: 4px solid transparent;
    border-bottom: 4px solid transparent;
    border-left: 4px solid var(--slate-text);
  }
}

/* Custom section backgrounds */
.section-cream-light {
  background-color: var(--section-cream-light);
}

.section-cream-dark {
  background-color: var(--section-cream-dark);
}


/* Custom button styles */
.btn-primary {
  --bs-btn-bg: var(--slate-text);
  --bs-btn-border-color: var(--slate-text);
  --bs-btn-color: var(--btn-text);
  --bs-btn-hover-bg: var(--slate-text-dark);
  --bs-btn-hover-border-color: var(--slate-text-dark);
  --bs-btn-hover-color: var(--btn-text);
  --bs-btn-active-bg: var(--slate-text-dark);
  --bs-btn-active-border-color: var(--slate-text-dark);
  --bs-btn-active-color: var(--btn-text);
  --bs-btn-focus-shadow-rgb: 45, 55, 72;
}

.btn-success {
  background-color: #7CB342;
  border-color: #7CB342;
}

.btn-success:hover {
  background-color: #689F38;
  border-color: #689F38;
}

.btn-outline-primary {
  --bs-btn-color: var(--slate-text);
  --bs-btn-border-color: var(--slate-text);
  --bs-btn-hover-color: var(--light-cream);
  --bs-btn-hover-bg: var(--slate-text);
  --bs-btn-hover-border-color: var(--slate-text);
  --bs-btn-active-color: var(--light-cream);
  --bs-btn-active-bg: var(--slate-text);
  --bs-btn-active-border-color: var(--slate-text);
  --bs-btn-focus-shadow-rgb: 45, 55, 72;
}

/* Custom code tag styling */
code {
  background-color: var(--code-bg);
  color: var(--slate-text);
  padding: 0.2em 0.4em;
  border-radius: 6px;
  font-size: 0.9em;
}

/* Fix Chroma syntax highlighting spacing */
.highlight pre code span {
  display: inline !important;
  padding: 0;
  margin: 0;
}

/* Code block container styling */
.highlight pre {
  padding: 0.75rem;
  border-radius: 8px;
  overflow-x: auto;
}

.highlight pre code {
  padding: 0;
  background: transparent;
}

/* Override Bootstrap text-primary to match theme */
.text-primary {
  color: var(--slate-text) !important;
}

.text-muted {
  color: var(--text-muted) !important;
}

/* Content page background - only for pages without main-wrapper */
body > main {
  background-color: var(--main-bg);
}

/* Blog post styling */
.blog-content {
  line-height: 1.7;
}

.blog-content p {
  margin-bottom: 1.2rem;
}

.blog-content ul, .blog-content ol {
  margin-bottom: 1.5rem;
}

.blog-content li {
  margin-bottom: 0.5rem;
}

/* Override for specific components that need different styling */
.btn {
  text-decoration: none !important;
}

.navbar a,
.pagination a {
  text-decoration: none;
}

.footnote-ref {
  margin-left: 0.125rem;
}

/* Pagination styling */
.pagination .page-link {
  color: var(--slate-text);
  background-color: var(--light-cream);
  border: 1px solid var(--border-color);
  text-decoration: none;
}

.pagination .page-link:hover {
  color: var(--slate-text);
  background-color: var(--section-cream-light);
  border-color: var(--border-color);
  text-decoration: none;
}

.pagination .page-item.active .page-link {
  color: var(--light-cream);
  background-color: var(--slate-text);
  border-color: var(--slate-text);
}

.format-icon {
  opacity: 0.75;
}

/* Card styling */
.card {
  background-color: var(--card-bg);
  border-color: var(--card-border);
}

.card-body {
  color: var(--slate-text);
}

/* Image inset styling */
img.leftinset {
  float: left;
  margin-right: 1.5rem;
  margin-bottom: 1rem;
  max-width: 50%;
  height: auto;
}

/* Beta warning stripe */
.beta::before {
  content: "";
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 20px;
  background-image: url('../img/bg_beta_bar.png');
  background-repeat: repeat-x;
  background-size: auto 20px;
  z-index: 1050;
  margin-top: calc(var(--bs-navbar-height, 56px));
}

@media (min-resolution: 2dppx) {
  .beta::before {
    background-image: url('../img/bg_beta_bar@2x.png');
  }
}

/* Accordion styling */
.accordion-button:not(.collapsed) {
  background-color: var(--section-cream-light);
  border-color: var(--border-color);
  color: var(--slate-text);
}

.accordion-button:focus {
  box-shadow: 0 0 0 0.25rem var(--border-color);
  border-color: var(--border-color);
}

/* Footer link styling */
footer a {
  text-decoration: none;
}

footer a:hover {
  text-decoration: underline;
}

/* Info box styling */
.info-box {
  background-color: var(--section-cream-dark);
  border-left: 4px solid var(--slate-text);
  padding: 1rem 1.25rem;
  margin-bottom: 1.5rem;
  border-radius: 4px;
}

.info-box p:last-child {
  margin-bottom: 0;
}

/* Content table styling */
.content-table {
  width: 100%;
  margin-bottom: 1.5rem;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.9em;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border-color);
}

.content-table thead {
  background-color: var(--section-cream-dark);
  border-bottom: 2px solid var(--border-color);
}

.content-table th {
  padding: 0.25rem 0.5rem;
  font-weight: 600;
  border-bottom: 2px solid var(--border-color);
}

.content-table th:first-child {
  border-top-left-radius: 8px;
}

.content-table th:last-child {
  border-top-right-radius: 8px;
}

.content-table td {
  padding: 0.25rem 0.5rem;
  border-bottom: 1px solid var(--border-color);
}

.content-table tbody tr:last-child td {
  border-bottom: none;
}

.content-table tbody tr:last-child td:first-child {
  border-bottom-left-radius: 8px;
}

.content-table tbody tr:last-child td:last-child {
  border-bottom-right-radius: 8px;
}

.content-table tbody tr:nth-child(odd) {
  background-color: var(--section-cream-light);
}
