/* Dark Mode CSS Variables */
:root {
  --bg-body: #f3f4f6;
  --bg-primary: #ffffff;
  --bg-header: #ffffff;
  --bg-footer: #000000;
  --bg-code: #eeeeee;
  --bg-highlight: #1e1e1e;
  --text-primary: #000000;
  --text-secondary: #4b5563;
  --text-link: #0074d9;
  --text-footer: #ffffff;
  --border-primary: #e5e7eb;
  --border-secondary: #94a3b8;
  --bg-hover: #dbeafe;
  --accent: #2563eb;
}

html.dark {
  --bg-body: #1f2937;
  --bg-primary: #374151;
  --bg-header: #111827;
  --bg-footer: #111827;
  --bg-code: #4b5563;
  --bg-highlight: #1e1e1e;
  --text-primary: #f9fafb;
  --text-secondary: #d1d5db;
  --text-link: #60a5fa;
  --text-footer: #e5e7eb;
  --border-primary: #4b5563;
  --border-secondary: #6b7280;
  --bg-hover: #1e3a5f;
  --accent: #60a5fa;
}

/* Body background */

/* ===== Typography ===== */

body {
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.7;
}

/* ===== Card Visual Distinction ===== */

.px-8.py-5.bg-white {
  border: 1px solid var(--border-primary);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.px-8.py-5.bg-white:hover {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}

/* ===== Accent Colors ===== */

.article h1,
.article h2,
.article h3,
.article h4 {
  color: var(--accent);
}

.px-8.py-5.bg-white > .text-sm {
  color: var(--text-secondary);
  font-style: italic;
}

/* Post listing metadata */
.post-meta {
  text-align: center;
  color: var(--text-secondary);
  font-size: 0.875rem;
  margin-bottom: 1em;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5em;
  flex-wrap: wrap;
}

.post-dot {
  opacity: 0.5;
}

.post-badge {
  display: inline-block;
  padding: 0.15em 0.6em;
  background-color: var(--accent);
  color: #ffffff;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

html.dark .post-badge {
  color: #111827;
}

/* ===== Code Block Styling ===== */

body {
  background-color: var(--bg-body) !important;
  color: var(--text-primary);
}

/* Header */
header {
  background-color: var(--bg-header) !important;
  color: var(--text-primary);
}

header h1 a {
  color: var(--text-primary) !important;
}

header p {
  color: var(--text-secondary) !important;
}

/* Content cards (posts, sidebar) */
.px-8.py-5.bg-white {
  background-color: var(--bg-primary) !important;
  color: var(--text-primary);
}

/* Sidebar elements */
.text-xl {
  color: var(--text-primary);
}

/* Footer */
footer {
  background-color: var(--bg-footer) !important;
  color: var(--text-footer);
}

/* Links */
.article a {
  color: var(--text-link);
}

.text-blue-600 {
  color: var(--text-link) !important;
}

/* Code blocks - always dark for consistency */
code {
  background-color: #1e1e1e !important;
  color: #d4d4d4 !important;
}

/* Inline code (not inside pre blocks) */
:not(pre) > code {
  background-color: #1e1e1e !important;
  color: #d4d4d4 !important;
  padding: 0.15em 0.4em;
  border-radius: 3px;
}

/* Chroma-highlighted code block container */
.highlight {
  background: #1e1e1e !important;
  margin-bottom: 1em;
  overflow-x: auto;
  border: 1px solid #374151;
  position: relative;
}

.highlight pre {
  padding: 1em !important;
  margin: 0 !important;
  padding-right: 4em !important;
}

.highlight pre,
.highlight code {
  background: transparent !important;
}

/* Copy-to-clipboard button */
.code-copy-btn {
  position: absolute;
  top: 0.5em;
  right: 0.5em;
  background: #374151;
  color: #d4d4d4;
  border: 1px solid #4b5563;
  border-radius: 4px;
  padding: 0.25em 0.6em;
  font-size: 0.75rem;
  font-family: inherit;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.2s ease;
  z-index: 10;
}

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

.code-copy-btn:hover {
  background: #4b5563;
}

/* Generic pre overflow for any code blocks */
pre {
  overflow-x: auto;
}

/* Borders */
.border-gray-200 {
  border-color: var(--border-primary) !important;
}

.border-slate-400 {
  border-color: var(--border-secondary) !important;
}

/* Search input */
input[name="q"] {
  background-color: var(--bg-body) !important;
  color: var(--text-primary) !important;
  border-color: var(--border-primary) !important;
}

/* Hover states */
.btn-paginate {
  background-color: var(--bg-primary) !important;
  color: var(--text-primary) !important;
  border-color: var(--border-primary) !important;
}

.btn-paginate:hover {
  background-color: var(--bg-hover) !important;
}

/* Read More links */
.text-blue-600 a {
  color: var(--text-link) !important;
}

/* Pagination active state */
.bg-blue-300 {
  background-color: var(--bg-hover) !important;
}

/* Hover states on pagination */
.hover\:bg-blue-100:hover {
  background-color: var(--bg-hover) !important;
}

/* Make entire pagination button clickable */
.btn-paginate a {
  display: block;
  margin: -0.5rem -1rem;
  padding: 0.5rem 1rem;
}

/* Theme toggle button */
.theme-toggle {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: none;
  border: 2px solid var(--border-primary);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.3s ease;
  padding: 0;
}

.theme-toggle:hover {
  background-color: var(--bg-hover);
  border-color: var(--text-link);
}

.theme-toggle svg {
  width: 20px;
  height: 20px;
  color: var(--text-primary);
}

.theme-toggle .icon-sun,
.theme-toggle .icon-moon {
  display: none;
}

html.dark .theme-toggle .icon-moon {
  display: none;
}

html.dark .theme-toggle .icon-sun {
  display: block;
}

html:not(.dark) .theme-toggle .icon-moon {
  display: block;
}

html:not(.dark) .theme-toggle .icon-sun {
  display: none;
}

/* Smooth transitions for theme switching */
html.dark body,
html.dark header,
html.dark footer,
html.dark .px-8.py-5.bg-white,
html.dark .btn-paginate,
html.dark input[name="q"] {
  transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

body, header, footer, .px-8.py-5.bg-white, .btn-paginate, input[name="q"] {
  transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}
