/* ==============================================================================
   NOTHING HEXO THEME - CODE HIGHLIGHT STYLES
   Minimalist dark obsidian terminal code blocks with line numbers & copy button
   ============================================================================== */

figure.highlight {
  position: relative;
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  margin: 1.6em 0;
  overflow: hidden;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
  max-width: 100%;
}

figure.highlight:hover {
  border-color: var(--border-light);
}

/* Code Table Structure */
figure.highlight table {
  border-collapse: collapse;
  margin: 0;
  width: 100%;
  max-width: 100%;
  table-layout: fixed;
  border: none;
  display: table;
}

figure.highlight tr {
  background: transparent !important;
  border: none;
}

figure.highlight td {
  padding: 0;
  border: none;
  vertical-align: top;
}

/* Line Numbers Gutter */
figure.highlight td.gutter {
  width: 44px;
  min-width: 44px;
  max-width: 44px;
  user-select: none;
  text-align: right;
  border-right: 1px solid var(--border);
  vertical-align: top;
}

figure.highlight td.gutter pre {
  margin: 0;
  padding: 14px 10px 14px 12px;
  font-family: 'LetteraMono', monospace;
  font-size: 12px;
  line-height: 1.6;
  color: var(--text-dim);
  overflow: hidden;
  white-space: pre;
}

/* Code Area */
figure.highlight td.code {
  padding: 0;
  vertical-align: top;
  width: calc(100% - 44px);
  max-width: calc(100% - 44px);
  overflow: hidden;
}

figure.highlight td.code pre {
  margin: 0;
  padding: 14px 16px;
  font-family: 'LetteraMono', monospace;
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-main);
  background: transparent;
  border: none;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  white-space: pre;
  word-wrap: normal;
  max-width: 100%;
  box-sizing: border-box;
}

/* Reset code tags inside pre */
figure.highlight pre code,
pre code {
  padding: 0 !important;
  background: transparent !important;
  border: none !important;
  border-radius: 0 !important;
  font-family: inherit !important;
  font-size: inherit !important;
  white-space: pre !important;
  word-wrap: normal !important;
}

/* Pre tag directly (when no line numbers) */
pre:not(.highlight pre) {
  font-family: 'LetteraMono', monospace;
  font-size: 13px;
  line-height: 1.6;
  padding: 14px 16px;
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  white-space: pre;
  word-wrap: normal;
  margin: 1.5em 0;
  max-width: 100%;
  box-sizing: border-box;
}

/* Minimalist Nothing-style scrollbars for code blocks */
figure.highlight td.code pre::-webkit-scrollbar,
pre:not(.highlight pre)::-webkit-scrollbar {
  height: 5px;
  width: 5px;
}

figure.highlight td.code pre::-webkit-scrollbar-track,
pre:not(.highlight pre)::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.04);
  border-radius: 3px;
}

figure.highlight td.code pre::-webkit-scrollbar-thumb,
pre:not(.highlight pre)::-webkit-scrollbar-thumb {
  background: var(--border-light);
  border-radius: 3px;
  transition: background-color 0.2s ease;
}

figure.highlight td.code pre::-webkit-scrollbar-thumb:hover,
pre:not(.highlight pre)::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

figure.highlight td.code pre,
pre:not(.highlight pre) {
  scrollbar-width: thin;
  scrollbar-color: var(--border-light) transparent;
}

/* Copy Button */
.code-copy-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  padding: 3px 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-family: 'LetteraMono', monospace;
  font-size: 10px;
  text-transform: uppercase;
  color: var(--text-muted);
  cursor: pointer;
  opacity: 0;
  transition: all 0.2s ease;
  z-index: 10;
}

figure.highlight:hover .code-copy-btn,
pre:hover .code-copy-btn {
  opacity: 1;
}

.code-copy-btn:hover {
  color: var(--text-main);
  border-color: var(--text-muted);
}

.code-copy-btn.copied {
  color: var(--red);
  border-color: var(--red);
}

/* Syntax Highlighting Tokens (Highlight.js mapping) */
.hljs-keyword,
.hljs-selector-tag,
.hljs-subst {
  color: var(--red);
  font-weight: 500;
}

.hljs-string,
.hljs-title,
.hljs-section,
.hljs-attribute,
.hljs-literal,
.hljs-template-tag,
.hljs-template-variable,
.hljs-type,
.hljs-addition {
  color: #56b6c2;
}

.hljs-comment,
.hljs-quote,
.hljs-deletion,
.hljs-meta {
  color: #5c6370;
  font-style: italic;
}

.hljs-number,
.hljs-regexp,
.hljs-link {
  color: #d19a66;
}

.hljs-variable,
.hljs-params {
  color: #e5c07b;
}

.hljs-function {
  color: #61afef;
}

.hljs-built_in,
.hljs-name {
  color: #e06c75;
}
