/* ═══════════════════════════════════════════════════════════════════════════
   EaglePress — Shared Content Rendering CSS
   Injected into every page (admin + frontend) so that markdown-rendered
   output looks identical in Preview Mode and Published Mode regardless of
   which theme is active.
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Prose content (universal markdown typography) ───────────────────────── */
.ep-prose {
  line-height: 1.75;
  word-break: break-word;
  overflow-wrap: break-word;
}
.ep-prose > * + * { margin-top: 1.1em; }
.ep-prose h1, .ep-prose h2, .ep-prose h3,
.ep-prose h4, .ep-prose h5, .ep-prose h6 {
  margin-top: 1.8em;
  margin-bottom: 0.45em;
  line-height: 1.25;
  font-weight: 700;
}
.ep-prose > h1:first-child,
.ep-prose > h2:first-child,
.ep-prose > h3:first-child { margin-top: 0; }
.ep-prose h1 { font-size: 2em; }
.ep-prose h2 { font-size: 1.5em; }
.ep-prose h3 { font-size: 1.25em; }
.ep-prose h4 { font-size: 1.1em; }
.ep-prose h5 { font-size: 1em; }
.ep-prose h6 { font-size: 0.9em; opacity: 0.7; }
.ep-prose p  { margin: 0 0 0.9em; }
.ep-prose p:last-child { margin-bottom: 0; }
.ep-prose ul, .ep-prose ol {
  margin: 0.6em 0 0.9em;
  padding-left: 1.7em;
}
.ep-prose li { margin-bottom: 0.3em; }
.ep-prose li > ul, .ep-prose li > ol { margin-top: 0.25em; margin-bottom: 0; }
.ep-prose ul { list-style-type: disc; }
.ep-prose ul ul { list-style-type: circle; }
.ep-prose ol { list-style-type: decimal; }
.ep-prose blockquote {
  margin: 1.4em 0;
  padding: 0.7em 1.1em;
  border-left: 4px solid #3b82f6;
  background: rgba(59,130,246,0.06);
  border-radius: 0 4px 4px 0;
}
.ep-prose blockquote p { margin: 0; }
.ep-prose a { color: #2563eb; text-decoration: underline; }
.ep-prose a:hover { color: #1d4ed8; }
.ep-prose strong { font-weight: 700; }
.ep-prose em { font-style: italic; }
.ep-prose hr {
  border: none;
  border-top: 2px solid #e5e7eb;
  margin: 1.8em 0;
}
.ep-prose img {
  max-width: 100%;
  height: auto;
  border-radius: 4px;
  display: block;
  margin: 1em auto;
}
/* dark-mode adjustments */
[data-theme="dark"] .ep-prose a { color: #60a5fa; }
[data-theme="dark"] .ep-prose a:hover { color: #93c5fd; }
[data-theme="dark"] .ep-prose blockquote {
  border-left-color: #3b82f6;
  background: rgba(59,130,246,0.1);
}
[data-theme="dark"] .ep-prose hr { border-top-color: #374151; }

/* ── Code blocks ─────────────────────────────────────────────────────────── */
.ep-code-block {
  --cb-bg: #0d1117;
  --cb-border: #30363d;
  --cb-toolbar-bg: #161b22;
  --cb-toolbar-border: #30363d;
  --cb-lang-color: #8b949e;
  --cb-select-bg: #21262d;
  --cb-select-text: #c9d1d9;
  --cb-select-border: #30363d;
  --cb-select-arrow: %238b949e;
  --cb-select-focus: #58a6ff;
  --cb-code-text: #e6edf3;
  position: relative;
  margin: 1.5em 0;
  border-radius: 6px;
  overflow: hidden;
  background: var(--cb-bg);
  border: 1px solid var(--cb-border);
  transition: background 0.15s ease, border-color 0.15s ease;
}
.ep-code-block[data-mode="light"] {
  --cb-bg: #f6f8fa;
  --cb-border: #d0d7de;
  --cb-toolbar-bg: #f0f1f3;
  --cb-toolbar-border: #d0d7de;
  --cb-lang-color: #57606a;
  --cb-select-bg: #eaeef2;
  --cb-select-text: #24292f;
  --cb-select-border: #d0d7de;
  --cb-select-arrow: %2357606a;
  --cb-select-focus: #0969da;
  --cb-code-text: #24292f;
}
.ep-code-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 14px;
  background: var(--cb-toolbar-bg);
  border-bottom: 1px solid var(--cb-toolbar-border);
  transition: background 0.15s ease, border-color 0.15s ease;
}
.ep-code-toolbar-selects {
  display: flex;
  align-items: center;
  gap: 6px;
}
.ep-code-lang-name {
  color: var(--cb-lang-color);
  font-size: 11px;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  user-select: none;
}
.ep-code-lang-select,
.ep-code-theme-select {
  -webkit-appearance: none;
  appearance: none;
  background: var(--cb-select-bg);
  color: var(--cb-select-text);
  border: 1px solid var(--cb-select-border);
  border-radius: 4px;
  font-size: 11px;
  padding: 3px 22px 3px 8px;
  cursor: pointer;
  outline: none;
  background-repeat: no-repeat;
  background-position: right 6px center;
  background-size: 8px;
  transition: border-color 0.15s, color 0.15s;
}
.ep-code-lang-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%238b949e'/%3E%3C/svg%3E");
}
.ep-code-theme-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%238b949e'/%3E%3C/svg%3E");
}
.ep-code-lang-select:hover, .ep-code-lang-select:focus,
.ep-code-theme-select:hover, .ep-code-theme-select:focus {
  border-color: var(--cb-select-focus);
  color: var(--cb-code-text);
}
.ep-code-wrap-label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--cb-lang-color);
  font-size: 11px;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  cursor: pointer;
  user-select: none;
}
.ep-code-wrap-toggle {
  margin: 0;
  cursor: pointer;
  accent-color: #D4AF37;
}
input.ep-code-wrap-toggle:checked {
  outline: 2px solid #D4AF37;
  outline-offset: 1px;
}
.ep-code-block.ep-code-wrap pre {
  white-space: pre-wrap;
  word-break: normal;
  overflow-wrap: break-word;
  overflow-x: hidden;
}
.ep-code-block.ep-code-wrap pre code {
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: anywhere;
  overflow-x: hidden;
}
.ep-code-block pre {
  margin: 0;
  padding: 1em 1.2em;
  overflow-x: auto;
  background: transparent;
  border: none;
  border-radius: 0;
  border-left: none;
}
.ep-code-block pre code {
  background: transparent !important;
  border: none;
  padding: 0;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 13.5px;
  line-height: 1.6;
  color: var(--cb-code-text);
  border-radius: 0;
}
.ep-code-block[data-lang="markdown"] pre code { line-height: 1.85; }
.ep-code-block[data-lang="markdown"] .hljs-section {
  font-weight: 700; font-size: 1.04em; letter-spacing: 0.01em; display: inline;
}
.ep-code-block[data-lang="markdown"] .hljs-strong  { color: inherit; font-weight: 800; }
.ep-code-block[data-lang="markdown"] .hljs-emphasis { font-style: italic; }
.ep-code-block[data-lang="markdown"] .hljs-quote    { font-style: italic; opacity: 0.78; }
.ep-code-block[data-lang="markdown"] .hljs-code {
  background: rgba(110,118,129,0.18); border-radius: 3px; padding: 0.05em 0.35em; font-size: 0.88em;
}
.ep-code-block[data-lang="markdown"] .hljs-link {
  text-decoration: underline; text-underline-offset: 2px; text-decoration-thickness: 1px;
}
.ep-code-block[data-lang="markdown"] .hljs-bullet   { font-weight: 600; }
.ep-inline-code-wrap[data-lang="markdown"] .hljs-section { font-weight: 700; }
.ep-inline-code-wrap[data-lang="markdown"] .hljs-strong  { color: inherit; font-weight: 800; }
.ep-inline-code-wrap[data-lang="markdown"] .hljs-emphasis { font-style: italic; }
.ep-inline-code-wrap[data-lang="markdown"] .hljs-bullet  { font-weight: 600; }
.ep-code-block[data-inline-formatted="true"] pre code strong,
.ep-inline-code-wrap[data-inline-formatted="true"] code strong {
  color: var(--cb-code-text, #e6edf3) !important;
  font-weight: 800 !important;
}

/* ── Inline code ─────────────────────────────────────────────────────────── */
.ep-inline-code-wrap {
  position: relative;
  display: inline;
}
.ep-inline-code-wrap code {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 0.875em;
  background: rgba(110, 118, 129, 0.15);
  border: 1px solid rgba(110, 118, 129, 0.25);
  border-radius: 4px;
  padding: 0.1em 0.4em;
}
.ep-inline-lang-select {
  -webkit-appearance: none;
  appearance: none;
  position: absolute;
  top: -22px;
  right: -2px;
  background: #161b22;
  color: #8b949e;
  border: 1px solid #30363d;
  border-radius: 3px;
  font-size: 10px;
  padding: 1px 16px 1px 5px;
  cursor: pointer;
  outline: none;
  opacity: 0;
  pointer-events: none;
  z-index: 10;
  transition: opacity 0.15s;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='5'%3E%3Cpath d='M0 0l4 5 4-5z' fill='%238b949e'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 4px center;
  background-size: 6px;
}
.ep-inline-code-wrap:hover .ep-inline-lang-select,
.ep-inline-lang-select:focus {
  opacity: 1;
  pointer-events: auto;
}

/* ── Tables ──────────────────────────────────────────────────────────────── */
table.ep-table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5em 0;
  font-size: 0.95em;
}
table.ep-table th,
table.ep-table td {
  padding: 10px 14px;
  border: 1px solid rgba(110, 118, 129, 0.3);
  text-align: left;
  vertical-align: top;
}
table.ep-table th {
  background: rgba(110, 118, 129, 0.08);
  font-weight: 600;
}
table.ep-table tr:nth-child(even) td {
  background: rgba(110, 118, 129, 0.04);
}

/* ── Code block separator ────────────────────────────────────────────────── */
.ep-code-sep { display: block; width: 100%; margin: 6px 0; }
.ep-code-sep-line { border-top: 1px solid currentColor; opacity: 0.35; }
.ep-code-sep-dots {
  display: block;
  width: 100%;
  text-align: center;
  font-size: 14px;
  letter-spacing: 5px;
  opacity: 0.65;
}

/* ── Dark mode overrides ─────────────────────────────────────────────────── */
[data-theme="dark"] table.ep-table th { background: rgba(255,255,255,0.06); }
[data-theme="dark"] table.ep-table th,
[data-theme="dark"] table.ep-table td { border-color: rgba(255,255,255,0.12); }
[data-theme="dark"] table.ep-table tr:nth-child(even) td { background: rgba(255,255,255,0.03); }

/* ── Notepad++ Syntax Theme ─────────────────────────────────────────────────
   Custom light theme. CSS variables cover toolbar colours without needing JS.
   .ep-fstring is added by highlight_custom_improved.js to distinguish f-strings
   (which contain .hljs-subst) from plain strings.                              */
[data-code-theme="notepadpp"] {
  --cb-bg:             #ffffff;
  --cb-toolbar-bg:     #f0f0f0;
  --cb-border:         #d0d0d0;
  --cb-toolbar-border: #d0d0d0;
  --cb-code-text:      #000000;
  --cb-lang-color:     #808080;
  --cb-select-bg:      #e8e8e8;
  --cb-select-text:    #000000;
  --cb-select-border:  #d0d0d0;
}
[data-code-theme="notepadpp"] .hljs                         { background:#ffffff; color:#000000 }
[data-code-theme="notepadpp"] .hljs-comment,
[data-code-theme="notepadpp"] .hljs-doctag                  { color:#808080 }
[data-code-theme="notepadpp"] .hljs-keyword                 { color:#000000; font-weight:bold }
[data-code-theme="notepadpp"] .hljs-literal                 { color:#000080 }
[data-code-theme="notepadpp"] .hljs-number                  { color:#c000c0 }
[data-code-theme="notepadpp"] .hljs-operator                { color:#8b0000 }
[data-code-theme="notepadpp"] .hljs-string:not(.ep-fstring) { color:#cc0000 }
[data-code-theme="notepadpp"] .hljs-string.ep-fstring       { color:#ff8c00; font-weight:bold }
[data-code-theme="notepadpp"] .hljs-subst                   { color:#4fc3f7; font-weight:bold }
[data-code-theme="notepadpp"] .hljs-template-tag            { color:#ff8c00; font-weight:bold }
[data-code-theme="notepadpp"] .hljs-template-variable       { color:#4fc3f7; font-weight:bold }
[data-code-theme="notepadpp"] .hljs-built_in                { color:#800080 }
[data-code-theme="notepadpp"] .hljs-title,
[data-code-theme="notepadpp"] .hljs-title.function_,
[data-code-theme="notepadpp"] .hljs-title.class_            { color:#006400 }
[data-code-theme="notepadpp"] .hljs-type                    { color:#000080 }
[data-code-theme="notepadpp"] .hljs-meta                    { color:#808000 }
[data-code-theme="notepadpp"] .hljs-meta .hljs-string,
[data-code-theme="notepadpp"] .hljs-meta .hljs-keyword      { color:#808000 }
[data-code-theme="notepadpp"] .hljs-variable,
[data-code-theme="notepadpp"] .hljs-symbol                  { color:#87ceeb }
[data-code-theme="notepadpp"] .hljs-regexp                  { color:#800080 }
[data-code-theme="notepadpp"] .hljs-tag                     { color:#555555 }
[data-code-theme="notepadpp"] .hljs-name                    { color:#00ced1; font-weight:bold }
[data-code-theme="notepadpp"] .hljs-attr,
[data-code-theme="notepadpp"] .hljs-attribute               { color:#cc0000 }
[data-code-theme="notepadpp"] .hljs-selector-tag,
[data-code-theme="notepadpp"] .hljs-selector-class,
[data-code-theme="notepadpp"] .hljs-selector-id,
[data-code-theme="notepadpp"] .hljs-selector-attr,
[data-code-theme="notepadpp"] .hljs-selector-pseudo         { color:#000080 }
[data-code-theme="notepadpp"] .hljs-section                 { color:#000080; font-weight:bold }
[data-code-theme="notepadpp"] .hljs-bullet                  { color:#8b0000 }
[data-code-theme="notepadpp"] .hljs-quote                   { color:#808080; font-style:italic }
[data-code-theme="notepadpp"] .hljs-emphasis                { font-style:italic }
[data-code-theme="notepadpp"] .hljs-strong                  { font-weight:bold }
[data-code-theme="notepadpp"] .hljs-link                    { color:#0000cc; text-decoration:underline }
[data-code-theme="notepadpp"] .hljs-code                    { color:#cc0000 }
[data-code-theme="notepadpp"] .hljs-formula                 { color:#000080 }
[data-code-theme="notepadpp"] .hljs-addition                { color:#006400; background:#f0fff0 }
[data-code-theme="notepadpp"] .hljs-deletion                { color:#8b0000; background:#fff0f0 }

/* ── Kate Syntax Theme ──────────────────────────────────────────────────────
   Based on KDE Kate editor's Default colour scheme (KSyntaxHighlighting).
   Light theme. Token mapping follows Kate's dsKeyword/dsString/dsFunction etc. */
[data-code-theme="kate"] {
  --cb-bg:             #ffffff;
  --cb-toolbar-bg:     #f4f4f4;
  --cb-border:         #c8c8c8;
  --cb-toolbar-border: #c8c8c8;
  --cb-code-text:      #1f1c1b;
  --cb-lang-color:     #898887;
  --cb-select-bg:      #e8e8e8;
  --cb-select-text:    #1f1c1b;
  --cb-select-border:  #c8c8c8;
}
[data-code-theme="kate"] .hljs                         { background:#ffffff; color:#1f1c1b }
[data-code-theme="kate"] .hljs-comment                 { color:#898887 }
[data-code-theme="kate"] .hljs-doctag                  { color:#607880 }
[data-code-theme="kate"] .hljs-keyword                 { color:#1f1c1b; font-weight:bold }
[data-code-theme="kate"] .hljs-literal                 { color:#0057ae }
[data-code-theme="kate"] .hljs-number                  { color:#b08000 }
[data-code-theme="kate"] .hljs-operator                { color:#1f1c1b }
[data-code-theme="kate"] .hljs-string:not(.ep-fstring) { color:#bf0303 }
[data-code-theme="kate"] .hljs-string.ep-fstring       { color:#ff5500; font-weight:bold }
[data-code-theme="kate"] .hljs-subst                   { color:#3daee9; font-weight:bold }
[data-code-theme="kate"] .hljs-template-tag            { color:#ff5500; font-weight:bold }
[data-code-theme="kate"] .hljs-template-variable       { color:#3daee9 }
[data-code-theme="kate"] .hljs-built_in                { color:#644a9b }
[data-code-theme="kate"] .hljs-title,
[data-code-theme="kate"] .hljs-title.function_         { color:#644a9b }
[data-code-theme="kate"] .hljs-title.class_            { color:#0057ae }
[data-code-theme="kate"] .hljs-type                    { color:#0057ae }
[data-code-theme="kate"] .hljs-meta                    { color:#006e28 }
[data-code-theme="kate"] .hljs-meta .hljs-string,
[data-code-theme="kate"] .hljs-meta .hljs-keyword      { color:#006e28 }
[data-code-theme="kate"] .hljs-variable,
[data-code-theme="kate"] .hljs-symbol                  { color:#0057ae }
[data-code-theme="kate"] .hljs-regexp                  { color:#924c9d }
[data-code-theme="kate"] .hljs-tag                     { color:#1f1c1b }
[data-code-theme="kate"] .hljs-name                    { color:#0057ae }
[data-code-theme="kate"] .hljs-attr,
[data-code-theme="kate"] .hljs-attribute               { color:#bf0303 }
[data-code-theme="kate"] .hljs-selector-tag            { color:#0057ae }
[data-code-theme="kate"] .hljs-selector-class          { color:#644a9b }
[data-code-theme="kate"] .hljs-selector-id             { color:#bf0303 }
[data-code-theme="kate"] .hljs-selector-attr,
[data-code-theme="kate"] .hljs-selector-pseudo         { color:#0057ae }
[data-code-theme="kate"] .hljs-section                 { color:#0057ae; font-weight:bold }
[data-code-theme="kate"] .hljs-bullet                  { color:#b08000 }
[data-code-theme="kate"] .hljs-quote                   { color:#898887; font-style:italic }
[data-code-theme="kate"] .hljs-emphasis                { font-style:italic }
[data-code-theme="kate"] .hljs-strong                  { font-weight:bold }
[data-code-theme="kate"] .hljs-link                    { color:#0057ae; text-decoration:underline }
[data-code-theme="kate"] .hljs-code                    { color:#bf0303 }
[data-code-theme="kate"] .hljs-formula                 { color:#0057ae }
[data-code-theme="kate"] .hljs-addition                { color:#006e28; background:#f0fff4 }
[data-code-theme="kate"] .hljs-deletion                { color:#bf0303; background:#fff0f0 }
