/* ============================================================
   Obsidian Publish — Vercel-inspired Developer Blog Theme
   ============================================================ */

/* ── Fonts ──────────────────────────────────────────────────── */
@import url('https://cdn.jsdelivr.net/gh/orioncactus/pretendard@v1.3.9/dist/web/variable/pretendardvariable-dynamic-subset.min.css');
@import url('https://fonts.googleapis.com/css2?family=Geist:wght@300..900&family=Geist+Mono:wght@300..700&display=swap');
@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;600;700&display=swap');

/* ── CSS Variables: Light ──────────────────────────────────── */
.theme-light {
  --background-primary: #ffffff;
  --background-primary-alt: #fafafa;
  --background-secondary: #f5f5f5;
  --background-secondary-alt: #ebebeb;
  --text-normal: #171717;
  --text-muted: #666666;
  --text-faint: #999999;
  --text-accent: #0070f3;
  --text-accent-hover: #005bc4;
  --interactive-normal: #f5f5f5;
  --interactive-hover: #ebebeb;
  --interactive-accent: #0070f3;
  --interactive-accent-hover: #005bc4;
  --background-modifier-border: #eaeaea;
  --background-modifier-border-hover: #d4d4d4;
  --background-modifier-border-focus: #0070f3;
  --code-background: #f6f8fa;
  --code-border: #eaeaea;
  --code-normal: #171717;
  --token-comment: #6e7781;
  --token-keyword: #cf222e;
  --token-function: #8250df;
  --token-class: #953800;
  --token-string: #0a3069;
  --token-number: #0550ae;
  --token-operator: #cf222e;
  --token-punctuation: #6e7781;
  --token-property: #0550ae;
  --token-decorator: #953800;
  --token-parameter: #953800;
  --nav-item-color: #666666;
  --nav-item-color-active: #171717;
  --nav-item-background-active: #f0f0f0;
  --tag-background: #f0f0f0;
  --tag-color: #444444;
  --callout-bg: #f6f8fa;
  --callout-border: #d0d7de;
  --hl-blue: rgba(0, 112, 243, 0.1);
  --hl-red: rgba(235, 55, 65, 0.1);
  --hl-green: rgba(46, 160, 67, 0.1);
}

/* ── CSS Variables: Dark ───────────────────────────────────── */
.theme-dark {
  --background-primary: #2a2a2a;
  --background-primary-alt: #303030;
  --background-secondary: #353535;
  --background-secondary-alt: #3a3a3a;
  --text-normal: #ededed;
  --text-muted: #a1a1a1;
  --text-faint: #777777;
  --text-accent: #0070f3;
  --text-accent-hover: #3291ff;
  --interactive-normal: #3a3a3a;
  --interactive-hover: #444444;
  --interactive-accent: #0070f3;
  --interactive-accent-hover: #3291ff;
  --background-modifier-border: #4a4a4a;
  --background-modifier-border-hover: #5a5a5a;
  --background-modifier-border-focus: #0070f3;
  --code-background: #323232;
  --code-border: #4a4a4a;
  --code-normal: #e6edf3;
  --token-comment: #6a737d;
  --token-keyword: #ff7b72;
  --token-function: #d2a8ff;
  --token-class: #f0c674;
  --token-string: #a5d6ff;
  --token-number: #79c0ff;
  --token-operator: #ff7b72;
  --token-punctuation: #8b949e;
  --token-property: #79c0ff;
  --token-decorator: #ffa657;
  --token-parameter: #ffa657;
  --nav-item-color: #999999;
  --nav-item-color-active: #ededed;
  --nav-item-background-active: #3a3a3a;
  --tag-background: #3a3a3a;
  --tag-color: #a1a1a1;
  --callout-bg: #323232;
  --callout-border: #4a4a4a;
  --hl-blue: rgba(0, 112, 243, 0.15);
  --hl-red: rgba(235, 55, 65, 0.15);
  --hl-green: rgba(46, 160, 67, 0.15);
}

/* ── Global Typography ─────────────────────────────────────── */
body {
  font-family: 'Pretendard Variable', 'Geist', -apple-system, BlinkMacSystemFont,
    'Segoe UI', Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: 'ss01', 'ss02', 'cv01';
  letter-spacing: -0.011em;
  transition: background-color 0.2s ease, color 0.2s ease;
}

/* ── Body Text ─────────────────────────────────────────────── */
.markdown-rendered {
  font-size: 16px;
  line-height: 1.75;
  color: var(--text-normal);
  max-width: 680px;
  margin: 0 auto;
  padding-left: 1.5em;
  padding-right: 1.5em;
}

.markdown-rendered p {
  margin-bottom: 1.25em;
  word-break: keep-all;
  overflow-wrap: break-word;
}

/* ── Headings ──────────────────────────────────────────────── */
.markdown-rendered h1, .markdown-rendered h2, .markdown-rendered h3,
.markdown-rendered h4, .markdown-rendered h5, .markdown-rendered h6 {
  font-family: 'Geist', 'Pretendard Variable', sans-serif;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.3;
  color: var(--text-normal);
  margin-top: 2em;
  margin-bottom: 0.75em;
}

.markdown-rendered h1 {
  font-size: 1.6em;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.2;
  margin-top: 0;
  padding-bottom: 0.3em;
  border-bottom: 1px solid var(--background-modifier-border);
}

.markdown-rendered h2 {
  font-size: 1.5em;
  padding-bottom: 0.25em;
  border-bottom: 1px solid var(--background-modifier-border);
}

.markdown-rendered h3 { font-size: 1.25em; }
.markdown-rendered h4 { font-size: 1.1em; }
.markdown-rendered h5 { font-size: 1em; color: var(--text-muted); }
.markdown-rendered h6 { font-size: 0.9em; color: var(--text-muted); }

/* ── Page Header ──────────────────────────────────────────── */
.page-header {
  font-size: 2.2em;
  word-break: keep-all;
  overflow-wrap: break-word;
}

/* ── Links ─────────────────────────────────────────────────── */
.markdown-rendered a {
  color: var(--text-accent);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 0.15s ease;
}

.markdown-rendered a:hover {
  color: var(--text-accent-hover);
  border-bottom-color: var(--text-accent-hover);
}

/* ── Inline Code ───────────────────────────────────────────── */
.markdown-rendered code:not(pre code) {
  font-family: 'JetBrains Mono', 'Geist Mono', monospace;
  font-size: 0.875em;
  padding: 0.15em 0.4em;
  border-radius: 6px;
  background: var(--code-background);
  border: 1px solid var(--code-border);
  color: var(--code-normal);
  font-feature-settings: 'liga' 0;
  word-break: break-word;
}

/* ============================================================
   CODE BLOCK — Vercel Blog Style
   ============================================================ */

/* Base pre */
.markdown-rendered pre:not(.frontmatter):not(.language-mermaid) {
  font-family: 'JetBrains Mono', 'Geist Mono', monospace;
  font-size: 13.5px;
  line-height: 1.7;
  background: var(--code-background);
  border: 1px solid var(--code-border);
  border-radius: 8px;
  padding: 0;
  margin: 1.5em 0;
  overflow: hidden;
  tab-size: 2;
  -moz-tab-size: 2;
  position: relative;
}

.markdown-rendered pre:not(.frontmatter):not(.language-mermaid) code {
  font-family: inherit;
  font-size: inherit;
  line-height: inherit;
  background: none;
  border: none;
  border-radius: 0;
  color: var(--code-normal);
  display: block;
  white-space: pre !important;
}

/* Wrapper: header + pre */
.code-block-wrapper {
  border: 1px solid var(--code-border);
  border-radius: 8px;
  margin: 1.5em 0;
  overflow: hidden;
}

.code-block-wrapper pre {
  margin: 0 !important;
  border: none !important;
  overflow: hidden !important;
}

/* Language header */
.code-lang-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 2px 6px 2px 14px;
  font-family: 'Geist', 'Pretendard Variable', sans-serif;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  background: var(--code-background);
  border-bottom: 1px solid var(--code-border);
  letter-spacing: 0.02em;
  line-height: 1.5;
}

/* Line numbers + content layout */
.code-content-wrapper {
  display: flex;
  overflow: visible;
  position: relative;
  padding: 1em 0;
}

.line-numbers-gutter {
  display: flex;
  flex-direction: column;
  padding: 0 0 0 1em;
  text-align: right;
  color: var(--text-faint);
  font-family: 'JetBrains Mono', 'Geist Mono', monospace;
  font-size: 13.5px;
  line-height: 1.7;
  user-select: none;
  -webkit-user-select: none;
  flex-shrink: 0;
  min-width: 2.5em;
}

.line-numbers-gutter span {
  display: block;
  padding-right: 0.75em;
}

.code-content {
  flex: 1;
  min-width: 0;
  overflow-x: auto;
  overflow-y: hidden;
}

.code-content code {
  padding: 0 1.25em 0 1em;
  width: fit-content;
  min-width: 100%;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

/* Line highlights */
.code-line {
  display: block;
  min-height: 1lh;
}

.code-line-highlight {
  margin: 0 -1.25em 0 -1em;
  padding: 0 1.25em 0 1em;
}

.code-line-highlight.hl-blue  { background: var(--hl-blue); }
.code-line-highlight.hl-red   { background: var(--hl-red); }
.code-line-highlight.hl-green { background: var(--hl-green); }

.line-numbers-gutter .highlighted {
  color: var(--text-accent);
  background: var(--hl-blue);
  margin-left: -1em;
  padding-left: 1em;
}

.line-numbers-gutter .hl-red {
  color: #eb3741;
  background: var(--hl-red);
}

.line-numbers-gutter .hl-green {
  color: #2ea043;
  background: var(--hl-green);
}

/* Copy button */
.code-lang-header .copy-code-button {
  position: static;
  background: transparent;
  border: 1px solid var(--code-border);
  border-radius: 6px;
  color: var(--text-faint);
  padding: 4px 8px;
  margin-left: auto;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.2s ease, color 0.15s ease, background 0.15s ease;
  font-size: 12px;
  line-height: 1;
  flex-shrink: 0;
}

.code-block-wrapper:hover .copy-code-button { opacity: 1; }

.code-lang-header .copy-code-button:hover {
  color: var(--text-normal);
  background: var(--interactive-hover);
  border-color: var(--background-modifier-border-hover);
}

/* ── Syntax Highlighting (variable-based) ─────────────────── */
.token.comment, .token.prolog, .token.doctype { color: var(--token-comment); font-style: italic; }
.token.keyword, .token.tag, .token.builtin { color: var(--token-keyword); }
.token.function, .token.method { color: var(--token-function); }
.token.class-name { color: var(--token-class); }
.token.string, .token.attr-value, .token.template-string, .token.triple-quoted-string { color: var(--token-string); }
.token.number, .token.boolean { color: var(--token-number); }
.token.operator { color: var(--token-operator); }
.token.punctuation { color: var(--token-punctuation); }
.token.property, .token.constant { color: var(--token-property); }
.token.decorator, .token.annotation { color: var(--token-decorator); }
.token.parameter { color: var(--token-parameter); }

/* ── Code Theme Presets ───────────────────────────────────── */
/* Usage: document.body.classList.add('code-theme-catppuccin'); */

.theme-dark.code-theme-catppuccin {
  --code-background: #1e1e2e; --code-border: #313244; --code-normal: #cdd6f4;
  --token-comment: #6c7086; --token-keyword: #cba6f7; --token-function: #89b4fa;
  --token-class: #f9e2af; --token-string: #a6e3a1; --token-number: #fab387;
  --token-operator: #89dceb; --token-punctuation: #9399b2; --token-property: #f5c2e7;
  --token-decorator: #f38ba8; --token-parameter: #eba0ac;
}

.theme-light.code-theme-catppuccin {
  --code-background: #eff1f5; --code-border: #ccd0da; --code-normal: #4c4f69;
  --token-comment: #9ca0b0; --token-keyword: #8839ef; --token-function: #1e66f5;
  --token-class: #df8e1d; --token-string: #40a02b; --token-number: #fe640b;
  --token-operator: #04a5e5; --token-punctuation: #7c7f93; --token-property: #ea76cb;
  --token-decorator: #d20f39; --token-parameter: #e64553;
}

.theme-dark.code-theme-github {
  --code-background: #0d1117; --code-border: #30363d; --code-normal: #e6edf3;
  --token-comment: #8b949e; --token-keyword: #ff7b72; --token-function: #d2a8ff;
  --token-class: #f0c674; --token-string: #a5d6ff; --token-number: #79c0ff;
  --token-operator: #ff7b72; --token-punctuation: #8b949e; --token-property: #79c0ff;
  --token-decorator: #ffa657; --token-parameter: #ffa657;
}

.theme-dark.code-theme-onedark {
  --code-background: #282c34; --code-border: #3e4452; --code-normal: #abb2bf;
  --token-comment: #5c6370; --token-keyword: #c678dd; --token-function: #61afef;
  --token-class: #e5c07b; --token-string: #98c379; --token-number: #d19a66;
  --token-operator: #56b6c2; --token-punctuation: #abb2bf; --token-property: #e06c75;
  --token-decorator: #d19a66; --token-parameter: #e06c75;
}

/* ============================================================
   CONTENT ELEMENTS
   ============================================================ */

/* ── Blockquote ────────────────────────────────────────────── */
.markdown-rendered blockquote {
  border-left: 3px solid var(--background-modifier-border);
  padding: 0.25em 1em;
  margin: 1.5em 0;
  color: var(--text-muted);
  background: transparent;
}

/* ── Callouts ──────────────────────────────────────────────── */
.markdown-rendered .callout {
  background: var(--callout-bg);
  border: 1px solid var(--callout-border);
  border-radius: 8px;
  padding: 0.75em 1em;
  margin: 1.5em 0;
}

.markdown-rendered .callout-title {
  font-family: 'Geist', 'Pretendard Variable', sans-serif;
  font-weight: 600;
  font-size: 0.9em;
  letter-spacing: -0.01em;
}

/* ── Tables ────────────────────────────────────────────────── */
.markdown-rendered table { width: 100%; border-collapse: collapse; margin: 1.5em 0; font-size: 0.9em; }
.markdown-rendered th { font-weight: 600; text-align: left; padding: 0.75em 1em; border-bottom: 2px solid var(--background-modifier-border); font-family: 'Geist', 'Pretendard Variable', sans-serif; }
.markdown-rendered td { padding: 0.75em 1em; border-bottom: 1px solid var(--background-modifier-border); }
.markdown-rendered tr:last-child td { border-bottom: none; }

/* ── Lists ─────────────────────────────────────────────────── */
.markdown-rendered ul, .markdown-rendered ol { padding-left: 1.5em; margin-bottom: 1.25em; }
.markdown-rendered li { margin-bottom: 0.35em; line-height: 1.7; }
.markdown-rendered li > p { margin-bottom: 0.5em; }

/* ── HR ────────────────────────────────────────────────────── */
.markdown-rendered hr { border: none; height: 1px; background: var(--background-modifier-border); margin: 2em 0; }

/* ── Tags ──────────────────────────────────────────────────── */
.tag { background: var(--tag-background); color: var(--tag-color); border-radius: 9999px; padding: 0.15em 0.65em; font-size: 0.8em; font-weight: 500; border: 1px solid var(--background-modifier-border); transition: background 0.15s ease; }
.tag:hover { background: var(--interactive-hover); text-decoration: none; }

/* ── Images ────────────────────────────────────────────────── */
.markdown-rendered img { border-radius: 8px; border: 1px solid var(--background-modifier-border); max-width: 100%; margin: 1em 0; }

/* ============================================================
   NAVIGATION & SIDEBAR
   ============================================================ */
.publish-site-header { border-bottom: 1px solid var(--background-modifier-border); }
.site-body-left-column-site-name { font-family: 'Geist', 'Pretendard Variable', sans-serif; font-weight: 700; font-size: 1.4em; letter-spacing: -0.02em; }
.nav-view-outer { font-size: 1.1em; line-height: 1.5; }
.tree-item-inner { font-family: 'Pretendard Variable', 'Geist', sans-serif; padding: 0.3em 0.5em; border-radius: 6px; color: var(--nav-item-color); transition: all 0.15s ease; }
.tree-item-inner:hover { color: var(--nav-item-color-active); background: var(--nav-item-background-active); }
.tree-item-inner.is-active { color: var(--nav-item-color-active); background: var(--nav-item-background-active); font-weight: 600; }
.site-body-left-column { border-right: 1px solid var(--background-modifier-border); }

/* ── Home Button ───────────────────────────────────────────── */
.home-btn {
  display: flex; align-items: center; justify-content: center;
  width: 44px; height: 44px;
  border: 1px solid var(--background-modifier-border);
  border-radius: 8px;
  background: var(--background-primary);
  color: var(--text-muted);
  cursor: pointer; transition: all 0.15s ease;
  position: fixed; top: 16px; left: 16px; z-index: 100;
  text-decoration: none;
}

.home-btn:hover { color: var(--text-accent); background: var(--interactive-hover); border-color: var(--background-modifier-border-hover); }
.home-btn svg { width: 22px; height: 22px; }

/* ── Sidebar Toggle Button ─────────────────────────────────── */
.sidebar-toggle-btn {
  display: flex; align-items: center; justify-content: center;
  width: 44px; height: 44px;
  border: 1px solid var(--background-modifier-border);
  border-radius: 8px;
  cursor: pointer; transition: all 0.15s ease;
  position: fixed; top: 68px; left: 16px; z-index: 100;
}

.sidebar-toggle-btn svg { width: 24px; height: 24px; transform: scaleX(-1); }
.sidebar-toggle-btn:hover { color: var(--text-normal); background: var(--interactive-hover); border-color: var(--background-modifier-border-hover); }
.sidebar-collapsed .sidebar-toggle-btn svg { transform: scaleX(1); }

/* ============================================================
   GLOBAL & UTILITIES
   ============================================================ */

/* Hide scrollbar on page body only */
body::-webkit-scrollbar { width: 0; height: 0; }
body { scrollbar-width: none; }

/* Thin scrollbar for code blocks */
.code-content::-webkit-scrollbar { height: 6px; }
.code-content::-webkit-scrollbar-thumb { background: var(--background-modifier-border); border-radius: 3px; }
.code-content { scrollbar-width: thin; }

.graph-view.color-fill { color: var(--text-accent); }
.graph-view.color-circle { color: var(--text-muted); }
.graph-view.color-line { color: var(--background-modifier-border); }

/* ── Mermaid ───────────────────────────────────────────────── */
.markdown-rendered .mermaid {
  overflow-x: auto; max-width: 100%; width: 100%;
  scrollbar-width: thin;
  display: flex; justify-content: center;
}

.markdown-rendered .mermaid::-webkit-scrollbar { height: 6px; }
.markdown-rendered .mermaid::-webkit-scrollbar-thumb { background: var(--background-modifier-border); border-radius: 3px; }

::selection { background: rgba(0, 112, 243, 0.2); }

/* ── Responsive ────────────────────────────────────────────── */
@media (max-width: 768px) {
  .markdown-rendered { font-size: 15px; line-height: 1.7; padding: 0 1em; }
  .markdown-rendered h1 { font-size: 1.3em; }
  .markdown-rendered h2 { font-size: 1.3em; }
  .markdown-rendered pre { font-size: 12.5px; padding: 0.75em 1em; margin-left: -1em; margin-right: -1em; border-radius: 0; }
  .sidebar-toggle-btn, .home-btn { display: none !important; }
}