/* ===== FONTS ===== */
@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@300;400;500;600;700&family=Source+Code+Pro:wght@300;400;600&display=swap');

/* ===== VARIABLES ===== */
:root {
  --bg: #000000;
  --bg-secondary: #0a0a0a;
  --bg-card: #0d0d0d;
  --border: #1e1e1e;
  --border-hover: #333;
  --text: #ffffff;
  --text-muted: #888;
  --text-dim: #444;
  --accent: #ffffff;
  --btn-bg: #ffffff;
  --btn-text: #000000;
  --font-mono: 'JetBrains Mono', 'Source Code Pro', 'Courier New', monospace;
  --radius: 0px;
  --transition: 0.15s ease;
}

/* ===== RESET ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 14px;
  line-height: 1.7;
  min-height: 100vh;
  overflow-x: hidden;
}

/* ===== SVG ICON COLOR FIX =====
   <img> tags cannot inherit CSS color, so we apply a white filter globally.
   This converts any SVG icon loaded via <img> to white on the dark background.
   Exception: .btn uses black icons (inverted) since it has a white background.  */
.social-link img,
.nav-link img,
.admin-nav-link img,
.edit-entry img,
.post-meta img,
.post-card__meta img,
.section-title img,
.badge img,
.terminal__prompt img {
  filter: brightness(0) invert(1);
}

/* Buttons have white bg so icons need to be black — invert(0) keeps them dark */
.btn img {
  filter: brightness(0);
}

/* Ghost buttons are on dark bg so icons should be white */
.btn--ghost img {
  filter: brightness(0) invert(1);
}

/* ===== NEURON CANVAS ===== */
#neuron-canvas {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  z-index: 0;
  pointer-events: none;
  opacity: 0.4;
}

/* ===== LAYOUT ===== */
.site-wrapper {
  position: relative;
  z-index: 1;
  min-height: 100vh;
}

.container {
  max-width: 860px;
  margin: 0 auto;
  padding: 0 24px;
}

.container--wide {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 24px;
}

/* ===== HEADER ===== */
.site-header {
  border-bottom: 1px solid var(--border);
  background: rgba(0,0,0,0.85);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  max-width: 1100px;
  margin: 0 auto;
}

.site-logo {
  font-family: var(--font-mono);
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
  letter-spacing: -0.5px;
}

.site-logo span { color: var(--text-muted); font-weight: 300; }

.site-nav {
  display: flex;
  align-items: center;
  gap: 8px;
}

.nav-link {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 12px;
  padding: 6px 12px;
  border: 1px solid transparent;
  transition: var(--transition);
  font-family: var(--font-mono);
}

.nav-link:hover {
  color: var(--text);
  border-color: var(--border-hover);
}

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--btn-bg);
  color: var(--btn-text);
  border: 1px solid var(--btn-bg);
  padding: 8px 16px;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: var(--transition);
  white-space: nowrap;
}

.btn:hover {
  background: #e0e0e0;
  border-color: #e0e0e0;
}

.btn:active { transform: translateY(1px); }

.btn--ghost {
  background: transparent;
  color: var(--text);
  border-color: var(--border-hover);
}

.btn--ghost:hover {
  background: rgba(255,255,255,0.05);
  border-color: #555;
}

.btn--danger {
  background: #ff3333;
  color: #fff;
  border-color: #ff3333;
}

.btn--sm {
  padding: 5px 10px;
  font-size: 11px;
}

.btn--icon {
  width: 32px;
  height: 32px;
  padding: 0;
  justify-content: center;
}

.btn img, .btn svg { width: 14px; height: 14px; flex-shrink: 0; }

/* ===== TOP BANNER ===== */
.site-banner {
  width: 100%;
  max-height: 280px;
  overflow: hidden;
  border-bottom: 1px solid var(--border);
  position: relative;
  display: block;
}

.site-banner__img {
  width: 100%;
  height: 280px;
  object-fit: cover;
  object-position: center;
  display: block;
  filter: brightness(0.85);
  transition: filter 0.3s ease;
}

.site-banner:hover .site-banner__img {
  filter: brightness(1);
}

/* ===== HERO / PROFILE ===== */
.hero {
  padding: 64px 0 48px;
  border-bottom: 1px solid var(--border);
}

.hero-inner {
  display: flex;
  align-items: center;
  gap: 40px;
}

.avatar-wrap {
  flex-shrink: 0;
}

.avatar-circle {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  border: 2px solid var(--border-hover);
  object-fit: cover;
  display: block;
}

.avatar-placeholder {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  border: 2px solid var(--border-hover);
  background: var(--bg-card);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  color: var(--text-muted);
}

.hero-text { flex: 1; }

.hero-name {
  font-size: 28px;
  font-weight: 700;
  margin-bottom: 4px;
  letter-spacing: -1px;
}

.hero-handle {
  color: var(--text-muted);
  font-size: 13px;
  margin-bottom: 12px;
}

.hero-tagline {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 16px;
  max-width: 480px;
  line-height: 1.6;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--border-hover);
  padding: 6px 12px;
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 20px;
}

.hero-badge img {
  height: 18px;
  width: auto;
}

.social-links {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.social-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 11px;
  padding: 5px 10px;
  border: 1px solid var(--border);
  transition: var(--transition);
}

.social-link:hover {
  color: var(--text);
  border-color: var(--border-hover);
}

.social-link img, .social-link svg {
  width: 14px; height: 14px;
}

/* ===== SECTION ===== */
.section { padding: 48px 0; }

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 32px;
}

.section-title {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--text-muted);
}

/* ===== POST CARDS (index listing) ===== */
.posts-grid {
  display: flex;
  flex-direction: column;
  gap: 1px;
  border: 1px solid var(--border);
}

.post-card {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  display: grid;
  grid-template-columns: 200px 1fr;
  transition: var(--transition);
}

.post-card:last-child { border-bottom: none; }

.post-card:hover { background: #0f0f0f; }

.post-card__image {
  width: 200px;
  height: 140px;
  object-fit: cover;
  display: block;
  filter: grayscale(30%);
}

.post-card__image-placeholder {
  width: 200px;
  height: 140px;
  background: var(--bg-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  font-size: 28px;
  border-right: 1px solid var(--border);
}

.post-card__body {
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
}

.post-card__meta {
  font-size: 10px;
  color: var(--text-dim);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.post-card__visibility {
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.post-card__title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
  line-height: 1.3;
}

.post-card__caption {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 12px;
  line-height: 1.5;
  flex: 1;
}

.post-card__footer {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* ===== SINGLE POST ===== */
.post-page { padding: 48px 0; }

.post-header { margin-bottom: 32px; }

.post-meta {
  font-size: 10px;
  color: var(--text-dim);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.post-title {
  font-size: 26px;
  font-weight: 700;
  line-height: 1.2;
  margin-bottom: 10px;
  letter-spacing: -0.5px;
}

.post-caption {
  font-size: 12px;
  color: var(--text-muted);
  border-left: 2px solid var(--border-hover);
  padding-left: 12px;
  margin-bottom: 24px;
}

.post-image-wrap {
  margin-bottom: 8px;
}

.post-image {
  width: 100%;
  max-height: 400px;
  object-fit: cover;
  display: block;
  border: 1px solid var(--border);
}

.post-image-caption {
  font-size: 10px;
  color: var(--text-dim);
  margin-top: 4px;
  text-align: center;
}

.post-content {
  border-top: 1px solid var(--border);
  padding-top: 32px;
  font-size: 14px;
  line-height: 1.8;
}

/* Markdown content styles */
.post-content h1,
.post-content h2,
.post-content h3,
.post-content h4 {
  font-family: var(--font-mono);
  font-weight: 700;
  margin: 32px 0 12px;
  color: var(--text);
}

.post-content h1 { font-size: 22px; }
.post-content h2 { font-size: 18px; border-bottom: 1px solid var(--border); padding-bottom: 8px; }
.post-content h3 { font-size: 15px; }

.post-content p { margin-bottom: 16px; }

.post-content a { color: #fff; text-decoration: underline; text-underline-offset: 3px; }
.post-content a:hover { color: var(--text-muted); }

.post-content code {
  background: #111;
  border: 1px solid var(--border);
  padding: 1px 5px;
  font-family: var(--font-mono);
  font-size: 12px;
}

.post-content pre {
  background: #080808;
  border: 1px solid var(--border);
  padding: 20px;
  overflow-x: auto;
  margin: 20px 0;
  position: relative;
}

.post-content pre code {
  background: none;
  border: none;
  padding: 0;
  font-size: 12px;
  line-height: 1.6;
}

.post-content blockquote {
  border-left: 3px solid var(--border-hover);
  padding-left: 16px;
  color: var(--text-muted);
  margin: 20px 0;
}

.post-content ul, .post-content ol {
  margin: 16px 0 16px 24px;
}

.post-content li { margin-bottom: 4px; }

.post-content img {
  max-width: 100%;
  border: 1px solid var(--border);
}

.post-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 20px 0;
  font-size: 12px;
}

.post-content th,
.post-content td {
  border: 1px solid var(--border);
  padding: 8px 12px;
  text-align: left;
}

.post-content th {
  background: var(--bg-secondary);
  font-weight: 600;
}

.post-content hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 32px 0;
}

/* ===== EDIT HISTORY ===== */
.edit-history {
  margin-top: 32px;
  border: 1px solid var(--border);
  padding: 16px;
}

.edit-history__title {
  font-size: 10px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.edit-entry {
  font-size: 11px;
  color: var(--text-dim);
  padding: 6px 0;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
}

.edit-entry:first-of-type { border-top: none; }

/* ===== ADMIN / EDIT POST FORM ===== */
.editor-wrap {
  padding: 48px 0;
}

.editor-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-label {
  font-size: 10px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--text-muted);
}

.form-input,
.form-textarea,
.form-select {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 13px;
  padding: 10px 14px;
  width: 100%;
  outline: none;
  transition: var(--transition);
}

.form-input:focus,
.form-textarea:focus,
.form-select:focus {
  border-color: var(--border-hover);
}

.form-textarea {
  resize: vertical;
  min-height: 300px;
  line-height: 1.6;
}

.form-select {
  cursor: pointer;
}

.form-select option {
  background: var(--bg);
}

/* ===== EDITOR SPLIT ===== */
.editor-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  border: 1px solid var(--border);
}

.editor-pane {
  display: flex;
  flex-direction: column;
}

.editor-pane__header {
  background: var(--bg-secondary);
  padding: 8px 14px;
  font-size: 10px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}

.editor-pane__content {
  background: var(--bg-card);
  border: none;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 16px;
  width: 100%;
  min-height: 400px;
  resize: none;
  outline: none;
  line-height: 1.7;
}

.preview-pane {
  padding: 16px;
  min-height: 400px;
  overflow-y: auto;
  font-size: 13px;
  line-height: 1.7;
}

/* ===== AUTH PAGES ===== */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.auth-box {
  width: 100%;
  max-width: 380px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  padding: 40px;
}

.auth-title {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 6px;
}

.auth-subtitle {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 28px;
}

/* ===== NOTIFICATIONS ===== */
.flash {
  padding: 12px 16px;
  font-size: 12px;
  border: 1px solid;
  margin-bottom: 16px;
}

.flash--error { border-color: #ff3333; color: #ff6666; background: rgba(255,51,51,0.05); }
.flash--success { border-color: #33ff77; color: #33ff77; background: rgba(51,255,119,0.05); }
.flash--info { border-color: var(--border-hover); color: var(--text-muted); }

/* ===== ADMIN PANEL ===== */
.admin-layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  min-height: calc(100vh - 57px);
}

.admin-sidebar {
  border-right: 1px solid var(--border);
  background: var(--bg-secondary);
  padding: 24px 0;
}

.admin-sidebar-title {
  font-size: 9px;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--text-dim);
  padding: 0 16px 12px;
}

.admin-nav-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 12px;
  border-left: 2px solid transparent;
  transition: var(--transition);
}

.admin-nav-link:hover,
.admin-nav-link.active {
  color: var(--text);
  border-left-color: var(--text);
  background: rgba(255,255,255,0.03);
}

.admin-nav-link img, .admin-nav-link svg { width: 14px; height: 14px; }

.admin-main {
  padding: 32px;
  overflow-y: auto;
}

/* ===== TERMINAL ===== */
.terminal {
  background: #080808;
  border: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 12px;
}

.terminal__output {
  height: 400px;
  overflow-y: auto;
  padding: 16px;
  color: #0f0;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}

.terminal__output .t-error { color: #ff4444; }
.terminal__output .t-warn { color: #ffbb00; }
.terminal__output .t-info { color: #44aaff; }
.terminal__output .t-success { color: #44ff88; }

.terminal__input-row {
  display: flex;
  align-items: center;
  border-top: 1px solid var(--border);
  padding: 0 16px;
}

.terminal__prompt {
  color: #0f0;
  font-size: 12px;
  margin-right: 8px;
  white-space: nowrap;
}

.terminal__input {
  flex: 1;
  background: none;
  border: none;
  color: #0f0;
  font-family: var(--font-mono);
  font-size: 12px;
  outline: none;
  padding: 12px 0;
}

/* ===== USERS TABLE ===== */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.data-table th,
.data-table td {
  text-align: left;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
}

.data-table th {
  font-size: 9px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--text-dim);
  font-weight: 400;
}

.data-table tr:hover td { background: rgba(255,255,255,0.02); }

/* ===== PAGINATION ===== */
.pagination {
  display: flex;
  gap: 4px;
  margin-top: 32px;
  justify-content: center;
}

/* ===== FOOTER ===== */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 20px 0;
  text-align: center;
  font-size: 10px;
  color: var(--text-dim);
  letter-spacing: 1px;
}

/* ===== VISIBILITY BADGE ===== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 7px;
  font-size: 9px;
  letter-spacing: 1px;
  text-transform: uppercase;
  border: 1px solid;
}

.badge--public { border-color: #1a4; color: #2b6; }
.badge--private { border-color: #444; color: #888; }

/* ===== LOADING ===== */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px;
  color: var(--text-dim);
  font-size: 12px;
  gap: 8px;
}

.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--text-muted);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ===== EMPTY STATE ===== */
.empty-state {
  text-align: center;
  padding: 64px 24px;
  color: var(--text-dim);
  font-size: 12px;
  border: 1px solid var(--border);
}

.empty-state__icon { font-size: 32px; margin-bottom: 12px; }

/* ===== UTILITY ===== */
.text-muted { color: var(--text-muted); }
.text-dim { color: var(--text-dim); }
.text-center { text-align: center; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.gap-8 { gap: 8px; }
.flex { display: flex; }
.flex-center { display: flex; align-items: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.flex-wrap { flex-wrap: wrap; }

/* ===== RESPONSIVE ===== */
@media (max-width: 680px) {
  .hero-inner { flex-direction: column; gap: 20px; }
  .post-card { grid-template-columns: 1fr; }
  .post-card__image { width: 100%; height: 180px; }
  .post-card__image-placeholder { width: 100%; height: 100px; }
  .editor-split { grid-template-columns: 1fr; }
  .admin-layout { grid-template-columns: 1fr; }
  .admin-sidebar { display: none; }
  .header-inner { padding: 12px 16px; }
}

/* ===== HLJS OVERRIDE ===== */
.hljs {
  background: transparent !important;
  padding: 0 !important;
}

/* ===== PAGE TRANSITIONS ===== */
.page-content {
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ===== HERO BADGE LINK ===== */
a.hero-badge {
  text-decoration: none;
  cursor: pointer;
  transition: border-color var(--transition), color var(--transition);
}

a.hero-badge:hover {
  border-color: var(--text);
  color: var(--text);
}
