/* Code Block Styling Improvements */
/* Ensures consistent line heights, spacing, and appearance across all code elements */

/* Base styles for all code elements */
code {
  font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
  font-size: 0.9em;
  line-height: 1.5;
  font-weight: 400;
  font-style: normal;
}

/* Inline code styling */
code:not([class]) {
  background-color: #f6f8fa;
  border: 1px solid #e1e4e8;
  border-radius: 3px;
  padding: 0.2em 0.4em;
  margin: 0;
  font-size: 0.85em;
  line-height: 1.45;
}

/* Dark mode inline code */
@media (prefers-color-scheme: dark) {
  code:not([class]) {
    background-color: #2d3748;
    border-color: #4a5568;
    color: #e2e8f0;
  }
}

/* Code blocks (syntax highlighted) */
.highlight {
  margin: 1em 0;
  border-radius: 6px;
  overflow: hidden;
  background: #272822; /* Monokai background */
}

.highlight pre {
  margin: 0;
  padding: 1em;
  overflow-x: auto;
  line-height: 1.5 !important;
  font-size: 0.9em;
  background: transparent;
  border: none;
}

.highlight code {
  padding: 0;
  margin: 0;
  border: none;
  background: transparent;
  font-size: inherit;
  line-height: inherit;
  color: inherit;
  white-space: pre;
  word-wrap: normal;
  word-break: normal;
}

/* Ensure consistent spacing between lines in code blocks */
.highlight .line {
  display: block;
  line-height: 1.5;
  min-height: 1.5em;
}

/* Fix any potential line height issues with specific syntax elements */
.highlight .c,   /* Comments */
.highlight .c1,  /* Single line comments */
.highlight .cm,  /* Multi-line comments */
.highlight .cp,  /* Preprocessor comments */
.highlight .cs,  /* Comments.Special */
.highlight .k,   /* Keywords */
.highlight .kc,  /* Keyword.Constant */
.highlight .kd,  /* Keyword.Declaration */
.highlight .kn,  /* Keyword.Namespace */
.highlight .kp,  /* Keyword.Pseudo */
.highlight .kr,  /* Keyword.Reserved */
.highlight .kt,  /* Keyword.Type */
.highlight .s,   /* Strings */
.highlight .s1,  /* String.Single */
.highlight .s2,  /* String.Double */
.highlight .se,  /* String.Escape */
.highlight .si,  /* String.Interpol */
.highlight .sr,  /* String.Regex */
.highlight .n,   /* Names */
.highlight .na,  /* Name.Attribute */
.highlight .nb,  /* Name.Builtin */
.highlight .nc,  /* Name.Class */
.highlight .nd,  /* Name.Decorator */
.highlight .ne,  /* Name.Exception */
.highlight .nf,  /* Name.Function */
.highlight .nl,  /* Name.Label */
.highlight .nn,  /* Name.Namespace */
.highlight .nt,  /* Name.Tag */
.highlight .nv,  /* Name.Variable */
.highlight .o,   /* Operators */
.highlight .m,   /* Numbers */
.highlight .mf,  /* Number.Float */
.highlight .mh,  /* Number.Hex */
.highlight .mi,  /* Number.Integer */
.highlight .mo {  /* Number.Oct */
  line-height: 1.5 !important;
  vertical-align: baseline;
}

/* Plain text code blocks (without syntax highlighting) */
pre {
  background-color: #f6f8fa;
  border: 1px solid #e1e4e8;
  border-radius: 6px;
  font-size: 0.9em;
  line-height: 1.5;
  margin: 1em 0;
  overflow-x: auto;
  padding: 1em;
  font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
}

/* Dark mode for plain pre blocks */
@media (prefers-color-scheme: dark) {
  pre {
    background-color: #2d3748;
    border-color: #4a5568;
    color: #e2e8f0;
  }
}

/* Ensure code inside pre has consistent styling */
pre code {
  background: transparent;
  border: none;
  font-size: inherit;
  line-height: inherit;
  padding: 0;
  margin: 0;
  color: inherit;
}

/* Fix Hugo's default chroma highlighting if it conflicts */
.chroma {
  margin: 1em 0;
  border-radius: 6px;
  overflow: hidden;
  background: #272822; /* Monokai background */
}

.chroma pre {
  margin: 0;
  padding: 1em;
  overflow-x: auto;
  line-height: 1.5 !important;
  font-size: 0.9em;
  background: transparent;
  border: none;
}

.chroma code {
  padding: 0;
  margin: 0;
  border: none;
  background: transparent;
  font-size: inherit;
  line-height: inherit;
  color: inherit;
  white-space: pre;
  word-wrap: normal;
  word-break: normal;
}

.chroma .lntd {
  vertical-align: top;
  padding: 0;
  margin: 0;
  border: 0;
  line-height: 1.5;
}

.chroma .lnt {
  margin-right: 0.4em;
  padding: 0 0.4em 0 0.4em;
  color: #7f7f7f;
  line-height: 1.5;
}

.chroma .hl {
  display: block;
  width: 100%;
  background-color: #3c3d38;
  line-height: 1.5;
}

/* Ensure all chroma syntax elements have consistent line height */
.chroma .w,   /* Text.Whitespace */
.chroma .err, /* Error */
.chroma .x,   /* Other */
.chroma .ch,  /* Comment.Hashbang */
.chroma .dl,  /* Literal.Date */
.chroma .fm,  /* Name.Function.Magic */
.chroma .go,  /* Generic.Output */
.chroma .gp,  /* Generic.Prompt */
.chroma .gr,  /* Generic.Error */
.chroma .gt,  /* Generic.Traceback */
.chroma .gh,  /* Generic.Heading */
.chroma .gi,  /* Generic.Inserted */
.chroma .gd,  /* Generic.Deleted */
.chroma .gs,  /* Generic.Strong */
.chroma .gu,  /* Generic.Subheading */
.chroma .ge {  /* Generic.Emph */
  line-height: 1.5 !important;
  vertical-align: baseline;
}

/* Responsive design for code blocks */
@media (max-width: 768px) {
  .highlight pre,
  pre {
    font-size: 0.8em;
    padding: 0.75em;
  }
  
  code:not([class]) {
    font-size: 0.8em;
  }
}

/* Ensure proper box model for all code elements */
code,
pre,
.highlight,
.chroma {
  box-sizing: border-box;
}

/* Fix any potential issues with nested code elements */
.highlight pre code,
.chroma pre code,
pre code {
  display: block;
  width: 100%;
  padding: 0;
  margin: 0;
  line-height: 1.5;
  background: transparent;
  border: none;
  color: inherit;
  font-size: inherit;
  font-family: inherit;
}