/* === Reset & Base === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg-primary: #0a0e17;
  --bg-secondary: #111827;
  --bg-card: #1a2332;
  --bg-card-hover: #1f2b3d;
  --border-color: #1e3a5f;
  --border-glow: #00d4ff;
  --text-primary: #e0e7ff;
  --text-secondary: #8892b0;
  --text-muted: #5a6580;
  --accent: #00d4ff;
  --accent-secondary: #7c3aed;
  --accent-gradient: linear-gradient(135deg, #00d4ff, #7c3aed);
  --success: #10b981;
  --danger: #ef4444;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --max-width: 1200px;
  --radius: 8px;
}

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-sans);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.7;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: var(--accent); text-decoration: none; transition: color 0.2s; }
a:hover { color: #33e0ff; }

/* === Layout === */
.container { max-width: var(--max-width); margin: 0 auto; padding: 0 1.5rem; width: 100%; }

/* === Header === */
.header {
  background: rgba(10, 14, 23, 0.95);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
}

.logo {
  font-size: 1.25rem;
  font-weight: 700;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.02em;
}

.nav { display: flex; gap: 1.5rem; align-items: center; }
.nav a {
  color: var(--text-secondary);
  font-size: 0.875rem;
  font-weight: 500;
  transition: color 0.2s;
  position: relative;
}
.nav a:hover { color: var(--accent); }
.nav a::after {
  content: '';
  position: absolute;
  bottom: -4px;
  left: 0;
  width: 0;
  height: 2px;
  background: var(--accent);
  transition: width 0.3s;
}
.nav a:hover::after { width: 100%; }

/* Mobile nav toggle */
.nav-toggle { display: none; background: none; border: none; color: var(--text-primary); font-size: 1.5rem; cursor: pointer; }

/* === Hero === */
.hero {
  padding: 4rem 0 3rem;
  text-align: center;
  position: relative;
}

.hero::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 600px;
  height: 400px;
  background: radial-gradient(ellipse, rgba(0, 212, 255, 0.08), transparent 70%);
  pointer-events: none;
}

.hero h1 {
  font-size: 2.5rem;
  font-weight: 800;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 1rem;
  letter-spacing: -0.03em;
}

.hero p {
  color: var(--text-secondary);
  font-size: 1.1rem;
  max-width: 600px;
  margin: 0 auto;
}

/* === Post Grid === */
.post-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 1.5rem;
  padding-bottom: 4rem;
}

/* === Post Card === */
.post-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 1.5rem;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.post-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--accent-gradient);
  opacity: 0;
  transition: opacity 0.3s;
}

.post-card:hover {
  border-color: rgba(0, 212, 255, 0.3);
  background: var(--bg-card-hover);
  transform: translateY(-2px);
  box-shadow: 0 8px 32px rgba(0, 212, 255, 0.08);
}

.post-card:hover::before { opacity: 1; }

.post-card.pinned {
  border-color: rgba(0, 212, 255, 0.3);
  background: linear-gradient(135deg, rgba(0, 212, 255, 0.05), rgba(124, 58, 237, 0.05));
}

.pin-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
  background: rgba(0, 212, 255, 0.1);
  border: 1px solid rgba(0, 212, 255, 0.2);
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  margin-bottom: 0.75rem;
}

.post-card h2 {
  font-size: 1.1rem;
  font-weight: 600;
  line-height: 1.4;
  margin-bottom: 0.5rem;
}

.post-card h2 a { color: var(--text-primary); }
.post-card h2 a:hover { color: var(--accent); }

.post-meta {
  display: flex;
  gap: 1rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
}

.post-meta .category {
  color: var(--accent-secondary);
  font-weight: 500;
  background: rgba(124, 58, 237, 0.1);
  padding: 0.1rem 0.4rem;
  border-radius: 3px;
}

.post-excerpt {
  color: var(--text-secondary);
  font-size: 0.9rem;
  line-height: 1.6;
  flex: 1;
}

/* === Article === */
.article {
  max-width: 800px;
  margin: 0 auto;
  padding: 2rem 1.5rem 4rem;
}

.article-header {
  margin-bottom: 2.5rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border-color);
}

.article-header h1 {
  font-size: 2rem;
  font-weight: 800;
  line-height: 1.3;
  margin-bottom: 1rem;
  letter-spacing: -0.02em;
}

.article-meta {
  display: flex;
  gap: 1.5rem;
  color: var(--text-muted);
  font-size: 0.875rem;
}

/* Markdown content styles */
.article-content h1, .article-content h2, .article-content h3,
.article-content h4, .article-content h5, .article-content h6 {
  margin-top: 2rem;
  margin-bottom: 0.75rem;
  font-weight: 700;
  line-height: 1.3;
  color: var(--text-primary);
}

.article-content h1 { font-size: 1.75rem; }
.article-content h2 { font-size: 1.5rem; border-bottom: 1px solid var(--border-color); padding-bottom: 0.5rem; }
.article-content h3 { font-size: 1.25rem; }

.article-content p { margin-bottom: 1.25rem; color: var(--text-primary); }

.article-content img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border-color);
  margin: 1rem 0;
}

.article-content code {
  font-family: var(--font-mono);
  font-size: 0.875em;
  background: rgba(0, 212, 255, 0.08);
  color: var(--accent);
  padding: 0.15em 0.4em;
  border-radius: 4px;
}

.article-content pre {
  background: #0d1117;
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 1.25rem;
  overflow-x: auto;
  margin: 1.5rem 0;
  position: relative;
}

.article-content pre code {
  background: none;
  color: var(--text-primary);
  padding: 0;
  font-size: 0.85rem;
  line-height: 1.6;
}

.article-content blockquote {
  border-left: 3px solid var(--accent);
  padding: 0.75rem 1rem;
  margin: 1.5rem 0;
  background: rgba(0, 212, 255, 0.03);
  color: var(--text-secondary);
  border-radius: 0 var(--radius) var(--radius) 0;
}

.article-content ul, .article-content ol {
  padding-left: 1.5rem;
  margin-bottom: 1.25rem;
}

.article-content li {
  margin-bottom: 0.35rem;
  color: var(--text-primary);
}

.article-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
  overflow-x: auto;
  display: block;
}

.article-content th, .article-content td {
  padding: 0.75rem 1rem;
  border: 1px solid var(--border-color);
  text-align: left;
}

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

.article-content hr {
  border: none;
  border-top: 1px solid var(--border-color);
  margin: 2rem 0;
}

.article-content a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-color: rgba(0, 212, 255, 0.3);
  text-underline-offset: 2px;
}
.article-content a:hover {
  text-decoration-color: var(--accent);
}

/* === Footer === */
.footer {
  margin-top: auto;
  padding: 2rem 0;
  border-top: 1px solid var(--border-color);
  text-align: center;
  color: var(--text-muted);
  font-size: 0.8rem;
}

/* === 404 === */
.not-found {
  text-align: center;
  padding: 6rem 1rem;
}
.not-found h1 {
  font-size: 6rem;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.not-found p { color: var(--text-secondary); margin: 1rem 0 2rem; }
.not-found a {
  display: inline-block;
  padding: 0.75rem 2rem;
  background: var(--accent-gradient);
  color: #000;
  font-weight: 600;
  border-radius: var(--radius);
}

/* === Admin === */
.admin-table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
}
.admin-table th, .admin-table td {
  padding: 0.75rem;
  border: 1px solid var(--border-color);
  text-align: left;
  font-size: 0.875rem;
}
.admin-table th { background: var(--bg-card); font-weight: 600; }
.admin-table tr:hover { background: var(--bg-card); }

.btn {
  display: inline-block;
  padding: 0.5rem 1rem;
  font-size: 0.8rem;
  font-weight: 600;
  border-radius: var(--radius);
  border: none;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-primary { background: var(--accent); color: #000; }
.btn-primary:hover { background: #33e0ff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #f87171; }

.form-group { margin-bottom: 1.25rem; }
.form-group label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 0.35rem;
  color: var(--text-secondary);
}
.form-group input, .form-group select, .form-group textarea {
  width: 100%;
  padding: 0.6rem 0.75rem;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.9rem;
  transition: border-color 0.2s;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0, 212, 255, 0.1);
}
.form-group textarea {
  min-height: 400px;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  line-height: 1.6;
  resize: vertical;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.checkbox-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.checkbox-group input[type="checkbox"] {
  width: auto;
  accent-color: var(--accent);
}

/* === Back link === */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  color: var(--text-muted);
  font-size: 0.875rem;
  margin-bottom: 1rem;
  transition: color 0.2s;
}
.back-link:hover { color: var(--accent); }

/* === Responsive === */
@media (max-width: 768px) {
  .hero h1 { font-size: 1.75rem; }
  .hero p { font-size: 1rem; }
  .post-grid { grid-template-columns: 1fr; gap: 1rem; }
  .article-header h1 { font-size: 1.5rem; }
  .article { padding: 1.5rem 1rem 3rem; }
  .form-row { grid-template-columns: 1fr; }
  .header-inner { position: relative; }
  .nav {
    display: none;
    flex-direction: column;
    position: absolute;
    top: 64px;
    left: 0;
    right: 0;
    background: rgba(10, 14, 23, 0.98);
    backdrop-filter: blur(20px);
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    gap: 0.75rem;
  }
  .nav.open { display: flex; }
  .nav a::after { display: none; }
  .nav-toggle { display: block; }
  .admin-table { font-size: 0.75rem; }
  .admin-table th, .admin-table td { padding: 0.5rem; }
}

@media (max-width: 480px) {
  .hero { padding: 2.5rem 0 2rem; }
  .post-card { padding: 1.25rem; }
  .post-card h2 { font-size: 1rem; }
}

/* === Scrollbar === */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg-primary); }
::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* === Selection === */
::selection { background: rgba(0, 212, 255, 0.2); color: var(--text-primary); }
