/* ============================================================
   Custom overrides for Beautiful Jekyll
   ============================================================ */

/* --- Google Fonts ------------------------------------------ */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

/* ============================================================
   Theme variables
   Light values are the default; dark values override on
   html[data-theme="dark"], which is set by theme.js before
   first paint (via head-extra.html) to avoid FOUC.
   ============================================================ */

:root {
  /* Code block */
  --code-bg:          #f6f8fa;
  --code-text:        #24292f;
  --code-border:      #d0d7de;
  /* Copy button */
  --copy-bg:          rgba(0, 0, 0, 0.05);
  --copy-color:       #57606a;
  --copy-border:      rgba(0, 0, 0, 0.12);
  --copy-hover-bg:    rgba(0, 0, 0, 0.10);
  --copy-hover-color: #24292f;
  /* Misc */
  --tag-bg:           #eef0f7;
  --tag-color:        #3949ab;
  --tag-hover-bg:     #5c6bc0;
  --tag-hover-color:  #ffffff;
  --card-bg:          #ffffff;
  --card-border:      #e8eaf0;
  --hr-color:         #e8eaf0;
  --inline-code-bg:   #eef0f7;
  --inline-code-color:#c2185b;
  --search-focus:     rgba(92, 107, 192, 0.15);
  --navbar-shadow:    rgba(0, 0, 0, 0.07);
  --card-shadow:      rgba(0, 0, 0, 0.08);
}

html[data-theme="dark"] {
  /* Beautiful Jekyll core vars — override what the theme injects on :root */
  --page-col:         #13131f !important;
  --text-col:         #cdd6f4 !important;
  --link-col:         #89b4fa !important;
  --hover-col:        #b4befe !important;
  --navbar-col:       #1e1e2e !important;
  --navbar-text-col:  #cdd6f4 !important;
  --navbar-border-col:#313244 !important;
  --footer-col:       #11111b !important;
  --footer-text-col:  #a6adc8 !important;
  --footer-link-col:  #cdd6f4 !important;
  --footer-hover-col: #ffffff !important;
  /* Code block */
  --code-bg:          #1e1e2e;
  --code-text:        #cdd6f4;
  --code-border:      transparent;
  /* Copy button */
  --copy-bg:          rgba(255, 255, 255, 0.08);
  --copy-color:       #a6adc8;
  --copy-border:      rgba(255, 255, 255, 0.15);
  --copy-hover-bg:    rgba(255, 255, 255, 0.18);
  --copy-hover-color: #cdd6f4;
  /* Misc */
  --tag-bg:           #313244;
  --tag-color:        #89b4fa;
  --tag-hover-bg:     #45475a;
  --tag-hover-color:  #cdd6f4;
  --card-bg:          #1e1e2e;
  --card-border:      #313244;
  --hr-color:         #313244;
  --inline-code-bg:   #313244;
  --inline-code-color:#f38ba8;
  --search-focus:     rgba(137, 180, 250, 0.15);
  --navbar-shadow:    rgba(0, 0, 0, 0.3);
  --card-shadow:      rgba(0, 0, 0, 0.25);
}

/* Direct element overrides for dark mode (fallback for anything
   that bypasses CSS variables in the Beautiful Jekyll stylesheet) */
/* Also set variables on body — Beautiful Jekyll may re-declare them
   there, which would shadow the html-level override via inheritance. */
html[data-theme="dark"] body {
  --page-col:         #13131f !important;
  --text-col:         #cdd6f4 !important;
  --link-col:         #89b4fa !important;
  --hover-col:        #b4befe !important;
  --navbar-col:       #1e1e2e !important;
  --navbar-border-col:#313244 !important;
  background-color: #13131f;
  color: #cdd6f4;
}

/* Post page elements */
html[data-theme="dark"] h1,
html[data-theme="dark"] h2,
html[data-theme="dark"] h3,
html[data-theme="dark"] h4,
html[data-theme="dark"] h5,
html[data-theme="dark"] h6 {
  color: #cdd6f4;
}

html[data-theme="dark"] p,
html[data-theme="dark"] li,
html[data-theme="dark"] td,
html[data-theme="dark"] th,
html[data-theme="dark"] blockquote {
  color: #cdd6f4;
}

html[data-theme="dark"] a {
  color: #89b4fa;
}

html[data-theme="dark"] a:hover {
  color: #b4befe;
}

/* Post header (intro-header without a cover image) */
html[data-theme="dark"] .intro-header {
  background-color: #1e1e2e;
}

html[data-theme="dark"] .intro-header .post-heading h1,
html[data-theme="dark"] .intro-header .page-heading h1 {
  color: #cdd6f4;
}

html[data-theme="dark"] .intro-header .post-heading .post-subheading,
html[data-theme="dark"] .intro-header .post-heading .post-meta {
  color: #a6adc8;
}

/* Category / tag pages */
html[data-theme="dark"] .tag-btn {
  background-color: #313244;
  color: #cdd6f4;
}

/* Pagination */
html[data-theme="dark"] .pagination .page-item .page-link {
  background-color: #1e1e2e;
  border-color: #313244;
  color: #89b4fa;
}

html[data-theme="dark"] .pagination .page-item.active .page-link {
  background-color: #5c6bc0;
  border-color: #5c6bc0;
  color: #ffffff;
}

html[data-theme="dark"] .navbar-custom {
  background-color: #1e1e2e !important;
  border-color: #313244 !important;
}

html[data-theme="dark"] .navbar-custom .navbar-brand,
html[data-theme="dark"] .navbar-custom .nav-link {
  color: #cdd6f4 !important;
}

html[data-theme="dark"] .navbar-custom .nav-link:hover {
  color: #b4befe !important;
}

html[data-theme="dark"] footer {
  background-color: #11111b;
}

html[data-theme="dark"] .post-preview {
  background-color: #1e1e2e;
  border-color: #313244;
}

html[data-theme="dark"] .post-preview .post-title a,
html[data-theme="dark"] .post-preview .post-meta {
  color: #cdd6f4;
}

html[data-theme="dark"] hr {
  border-top-color: #313244;
}

/* ============================================================
   Base typography
   ============================================================ */
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 16px;
  line-height: 1.8;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6 {
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: -0.02em;
}

/* ============================================================
   Navbar
   ============================================================ */
.navbar-custom {
  box-shadow: 0 1px 4px var(--navbar-shadow);
  transition: background-color 0.2s, border-color 0.2s;
}

.navbar-custom .navbar-brand,
.navbar-custom .nav-link {
  font-weight: 500;
  letter-spacing: 0.01em;
}

/* ============================================================
   Theme toggle button (injected by theme.js)
   ============================================================ */
.theme-toggle-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  border-radius: 6px;
  line-height: 1;
  opacity: 0.75;
  transition: opacity 0.15s, background 0.15s;
  display: flex;
  align-items: center;
}

.theme-toggle-btn:hover {
  opacity: 1;
  background: rgba(128, 128, 128, 0.12);
}

.theme-toggle-btn svg {
  width: 18px;
  height: 18px;
  display: block;
}

/* ============================================================
   Post preview cards
   ============================================================ */
.post-preview {
  border-radius: 12px;
  padding: 1.5rem 1.75rem;
  margin-bottom: 1.5rem;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  transition: box-shadow 0.2s ease, transform 0.2s ease, background-color 0.2s, border-color 0.2s;
}

.post-preview:hover {
  box-shadow: 0 6px 24px var(--card-shadow);
  transform: translateY(-2px);
}

.post-preview .post-title a,
.post-preview .post-title {
  font-size: 1.25rem;
  font-weight: 600;
}

/* ============================================================
   Post content
   ============================================================ */
.post-content {
  font-size: 1.0125rem;
}

.post-content p {
  margin-bottom: 1.4em;
}

/* ============================================================
   Inline code
   ============================================================ */
p code, li code, td code {
  background: var(--inline-code-bg);
  color: var(--inline-code-color);
  padding: 0.15em 0.45em;
  border-radius: 5px;
  font-family: 'JetBrains Mono', 'Fira Code', ui-monospace, monospace;
  font-size: 0.875em;
}

/* ============================================================
   Code blocks — adapt to current theme
   ============================================================ */
.highlighter-rouge {
  position: relative;
  border-radius: 10px;
  overflow: hidden;
  margin: 1.75em 0;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  border: 1px solid var(--code-border);
  transition: border-color 0.2s;
}

.highlight,
.highlighter-rouge .highlight {
  background: var(--code-bg) !important;
  border-radius: 10px;
  padding: 1.25rem 1.5rem;
  overflow-x: auto;
  margin: 0;
  transition: background-color 0.2s;
}

.highlight pre {
  margin: 0;
  padding: 0;
  background: transparent;
}

.highlight code,
.highlighter-rouge code {
  font-family: 'JetBrains Mono', 'Fira Code', ui-monospace, monospace;
  font-size: 0.875rem;
  line-height: 1.65;
  color: var(--code-text);
  transition: color 0.2s;
}

/* ============================================================
   Copy button — adapts to theme
   ============================================================ */
.copy-code-button {
  position: absolute;
  top: 0.6rem;
  right: 0.6rem;
  background: var(--copy-bg);
  color: var(--copy-color);
  border: 1px solid var(--copy-border);
  border-radius: 6px;
  padding: 0.2rem 0.65rem;
  font-size: 0.75rem;
  font-family: 'Inter', sans-serif;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  z-index: 10;
  line-height: 1.6;
}

.copy-code-button:hover {
  background: var(--copy-hover-bg);
  color: var(--copy-hover-color);
}

.copy-code-button.copied {
  background: rgba(166, 227, 161, 0.2);
  color: #40a02b;
  border-color: rgba(64, 160, 43, 0.35);
}

html[data-theme="dark"] .copy-code-button.copied {
  color: #a6e3a1;
}

/* ============================================================
   Links
   ============================================================ */
a {
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
}

/* ============================================================
   Tags
   ============================================================ */
.blog-tags a {
  display: inline-block;
  background: var(--tag-bg);
  color: var(--tag-color);
  border-radius: 20px;
  padding: 0.1em 0.75em;
  font-size: 0.8rem;
  font-weight: 500;
  margin: 0.15em 0.15em;
  transition: background 0.15s, color 0.15s;
  text-decoration: none;
}

.blog-tags a:hover {
  background: var(--tag-hover-bg);
  color: var(--tag-hover-color);
  text-decoration: none;
}

/* ============================================================
   Dividers
   ============================================================ */
hr {
  border: none;
  border-top: 1px solid var(--hr-color);
  margin: 2em 0;
  transition: border-color 0.2s;
}

/* ============================================================
   Search input
   ============================================================ */
#search-input {
  border-radius: 8px;
  border: 1px solid var(--card-border);
  padding: 0.5rem 1rem;
  font-family: 'Inter', sans-serif;
  background: var(--card-bg);
  color: var(--text-col, inherit);
  transition: box-shadow 0.15s, border-color 0.15s, background-color 0.2s;
}

#search-input:focus {
  outline: none;
  border-color: var(--link-col, #5c6bc0);
  box-shadow: 0 0 0 3px var(--search-focus);
}
