/**
 * Prism.js syntax highlighting theme
 * Adapted for Ferni's light/dark theme system
 */

/* ========================================
   CODE BLOCK WRAPPER
   ======================================== */

pre[class*='language-'] {
  position: relative;
  margin: var(--space-6) 0;
  padding: 0;
  background: var(--bg-code);
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--border-subtle);
}

pre[class*='language-'] > code {
  display: block;
  padding: var(--space-4) var(--space-5);
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  line-height: 1.7;
  color: var(--code-text);
  background: transparent;
  tab-size: 2;
}

/* Inline code */
:not(pre) > code[class*='language-'],
:not(pre) > code {
  padding: 0.15em 0.4em;
  border-radius: var(--radius-xs);
  background: var(--bg-code-inline);
  color: var(--accent-text);
  font-family: var(--font-mono);
  font-size: 0.9em;
}

/* ========================================
   CODE BLOCK HEADER (language badge)
   ======================================== */

pre[class*='language-']::before {
  content: attr(data-language);
  position: absolute;
  top: 0;
  right: 0;
  padding: var(--space-1) var(--space-3);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  background: var(--bg-tertiary);
  border-bottom-left-radius: var(--radius-md);
  opacity: 0.8;
}

/* Language-specific badges */
pre.language-javascript::before,
pre.language-js::before {
  content: 'JS';
}
pre.language-typescript::before,
pre.language-ts::before {
  content: 'TS';
}
pre.language-bash::before,
pre.language-shell::before {
  content: 'BASH';
}
pre.language-json::before {
  content: 'JSON';
}
pre.language-python::before,
pre.language-py::before {
  content: 'PY';
}
pre.language-html::before {
  content: 'HTML';
}
pre.language-css::before {
  content: 'CSS';
}
pre.language-sql::before {
  content: 'SQL';
}
pre.language-yaml::before,
pre.language-yml::before {
  content: 'YAML';
}
pre.language-markdown::before,
pre.language-md::before {
  content: 'MD';
}

/* ========================================
   COPY BUTTON
   ======================================== */

.code-copy-btn {
  position: absolute;
  top: var(--space-2);
  right: var(--space-2);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  color: var(--text-muted);
  cursor: pointer;
  opacity: 0;
  transition: all var(--duration-fast) var(--ease-gentle);
  z-index: 10;
}

pre[class*='language-']:hover .code-copy-btn {
  opacity: 1;
}

.code-copy-btn:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border-color: var(--border-strong);
}

.code-copy-btn:active {
  transform: scale(0.95);
}

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

.code-copy-btn svg {
  width: 16px;
  height: 16px;
}

/* ========================================
   LINE NUMBERS (optional)
   ======================================== */

pre.line-numbers {
  padding-left: 3.5em;
}

.line-numbers-rows {
  position: absolute;
  pointer-events: none;
  top: var(--space-4);
  left: 0;
  width: 3em;
  font-size: var(--text-sm);
  line-height: 1.7;
  letter-spacing: -1px;
  border-right: 1px solid var(--border-subtle);
  user-select: none;
  padding-right: var(--space-2);
  text-align: right;
  color: var(--text-dimmed);
}

.line-numbers-rows > span {
  display: block;
}

/* ========================================
   SYNTAX HIGHLIGHTING - DEFAULT (Dark/Cedar Night)
   ======================================== */

.token.comment,
.token.prolog,
.token.doctype,
.token.cdata {
  color: var(--syntax-comment);
  font-style: italic;
}

.token.punctuation {
  color: var(--syntax-punctuation);
}

.token.namespace {
  opacity: 0.7;
}

.token.property,
.token.tag,
.token.boolean,
.token.number,
.token.constant,
.token.symbol,
.token.deleted {
  color: var(--syntax-number);
}

.token.selector,
.token.attr-name,
.token.string,
.token.char,
.token.builtin,
.token.inserted {
  color: var(--syntax-string);
}

.token.operator,
.token.entity,
.token.url,
.language-css .token.string,
.style .token.string {
  color: var(--syntax-operator);
}

.token.atrule,
.token.attr-value,
.token.keyword {
  color: var(--syntax-keyword);
}

.token.function,
.token.class-name {
  color: var(--syntax-function);
}

.token.regex,
.token.important,
.token.variable {
  color: var(--syntax-variable);
}

/* ========================================
   SYNTAX HIGHLIGHTING - LIGHT THEME
   ======================================== */

[data-theme='light'] .token.comment,
[data-theme='light'] .token.prolog,
[data-theme='light'] .token.doctype,
[data-theme='light'] .token.cdata {
  color: #6e7781;
  font-style: italic;
}

[data-theme='light'] .token.punctuation {
  color: #24292f;
}

[data-theme='light'] .token.namespace {
  opacity: 0.7;
}

[data-theme='light'] .token.property,
[data-theme='light'] .token.tag,
[data-theme='light'] .token.boolean,
[data-theme='light'] .token.number,
[data-theme='light'] .token.constant,
[data-theme='light'] .token.symbol,
[data-theme='light'] .token.deleted {
  color: #0550ae;
}

[data-theme='light'] .token.selector,
[data-theme='light'] .token.attr-name,
[data-theme='light'] .token.string,
[data-theme='light'] .token.char,
[data-theme='light'] .token.builtin,
[data-theme='light'] .token.inserted {
  color: #0a3069;
}

[data-theme='light'] .token.operator,
[data-theme='light'] .token.entity,
[data-theme='light'] .token.url,
[data-theme='light'] .language-css .token.string,
[data-theme='light'] .style .token.string {
  color: #24292f;
}

[data-theme='light'] .token.atrule,
[data-theme='light'] .token.attr-value,
[data-theme='light'] .token.keyword {
  color: #cf222e;
}

[data-theme='light'] .token.function,
[data-theme='light'] .token.class-name {
  color: #8250df;
}

[data-theme='light'] .token.regex,
[data-theme='light'] .token.important,
[data-theme='light'] .token.variable {
  color: #953800;
}

/* ========================================
   SYNTAX HIGHLIGHTING - DARK THEME
   ======================================== */

[data-theme='dark'] .token.comment,
[data-theme='dark'] .token.prolog,
[data-theme='dark'] .token.doctype,
[data-theme='dark'] .token.cdata {
  color: #6a9955;
  font-style: italic;
}

[data-theme='dark'] .token.punctuation {
  color: #d4d4d4;
}

[data-theme='dark'] .token.namespace {
  opacity: 0.7;
}

[data-theme='dark'] .token.property,
[data-theme='dark'] .token.tag,
[data-theme='dark'] .token.boolean,
[data-theme='dark'] .token.number,
[data-theme='dark'] .token.constant,
[data-theme='dark'] .token.symbol,
[data-theme='dark'] .token.deleted {
  color: #b5cea8;
}

[data-theme='dark'] .token.selector,
[data-theme='dark'] .token.attr-name,
[data-theme='dark'] .token.string,
[data-theme='dark'] .token.char,
[data-theme='dark'] .token.builtin,
[data-theme='dark'] .token.inserted {
  color: #ce9178;
}

[data-theme='dark'] .token.operator,
[data-theme='dark'] .token.entity,
[data-theme='dark'] .token.url,
[data-theme='dark'] .language-css .token.string,
[data-theme='dark'] .style .token.string {
  color: #d4d4d4;
}

[data-theme='dark'] .token.atrule,
[data-theme='dark'] .token.attr-value,
[data-theme='dark'] .token.keyword {
  color: #569cd6;
}

[data-theme='dark'] .token.function,
[data-theme='dark'] .token.class-name {
  color: #dcdcaa;
}

[data-theme='dark'] .token.regex,
[data-theme='dark'] .token.important,
[data-theme='dark'] .token.variable {
  color: #9cdcfe;
}

/* ========================================
   IMPORTANT AND BOLD
   ======================================== */

.token.important,
.token.bold {
  font-weight: bold;
}

.token.italic {
  font-style: italic;
}

.token.entity {
  cursor: help;
}

/* ========================================
   DIFF HIGHLIGHTING
   ======================================== */

pre .token.deleted:not(.token) {
  display: block;
  background: var(--error-bg);
  border-left: 3px solid var(--error);
  margin: 0 calc(-1 * var(--space-5));
  padding: 0 var(--space-5);
}

pre .token.inserted:not(.token) {
  display: block;
  background: var(--success-bg);
  border-left: 3px solid var(--success);
  margin: 0 calc(-1 * var(--space-5));
  padding: 0 var(--space-5);
}

/* ========================================
   COMMAND LINE
   ======================================== */

.command-line-prompt {
  border-right: none;
  display: block;
  float: left;
  font-size: 100%;
  letter-spacing: -1px;
  margin-right: var(--space-3);
  pointer-events: none;
  user-select: none;
  color: var(--success);
}

.command-line-prompt > span::before {
  content: '$ ';
  color: var(--success);
}
