/* ========== Color Scheme ========== */
:root {
  /* Warm charcoal palette with emerald accent */
  --color-bg: #0d0f12;
  --color-surface: #16191d;
  --color-border: #2a2f36;
  --color-text: #e8eaed;
  --color-text-muted: #8b9298;
  --color-accent: #10b981;
  --color-accent-hover: #34d399;
  --color-accent-soft: rgba(16, 185, 129, 0.15);
}

/* ========== Global Reset ========== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* ========== Body & Typography ========== */
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background-color: var(--color-bg);
  color: var(--color-text);
  line-height: 1.7;
  font-size: 1.0625rem;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ========== Navigation Bar ========== */
.navbar {
  background-color: var(--color-bg);
  border-bottom: 1px solid var(--color-border);
  padding: 1rem 2rem;
  position: sticky;
  top: 0;
  z-index: 100;
}

.nav-container {
  max-width: 1000px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.logo {
  font-weight: 800;
  font-size: 1.25rem;
  letter-spacing: -0.02em;
  text-decoration: none;
  color: var(--color-text);
  transition: color 0.2s ease;
}

.logo-icon {
  display: inline-block;
  margin-right: 0.35rem;
  font-size: 1rem;
  color: var(--color-accent);
  opacity: 0.9;
  transform: rotate(-45deg);
  vertical-align: middle;
}

.logo:hover .logo-icon,
.logo:focus-visible .logo-icon {
  color: var(--color-accent-hover);
}

.logo:hover,
.logo:focus-visible {
  color: var(--color-accent);
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

.nav-links a {
  margin-left: 1.5rem;
  text-decoration: none;
  color: var(--color-text-muted);
  font-weight: 500;
  font-size: 0.95rem;
  transition: color 0.2s ease;
  position: relative;
}

.nav-links a::after {
  content: '';
  position: absolute;
  bottom: -4px;
  left: 0;
  width: 0;
  height: 2px;
  background: var(--color-accent);
  transition: width 0.25s ease;
}

.nav-links a:hover,
.nav-links a:focus-visible {
  color: var(--color-text);
}

.nav-links a:hover::after,
.nav-links a:focus-visible::after {
  width: 100%;
}

.nav-links a:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

/* ========== Main Container ========== */
.container {
  max-width: 720px;
  margin: 4rem auto;
  padding: 0 1.5rem;
  animation: fadeIn 0.6s ease-in;
}

/* ========== Headings ========== */
h1, h2, h3 {
  font-weight: 800;
  letter-spacing: -0.025em;
  margin-bottom: 1rem;
}

h1 {
  font-size: 2.5rem;
  line-height: 1.2;
  margin-top: 0;
}

h2 {
  font-size: 1.625rem;
  margin-top: 2.5rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--color-border);
}

h3 {
  font-size: 1.3rem;
  margin-top: 2rem;
}

h4 {
  font-size: 1.125rem;
  margin-top: 1.5rem;
  font-weight: 600;
}

p {
  margin-bottom: 1.25rem;
}

/* ========== Buttons ========== */
.btn {
  display: inline-block;
  background: linear-gradient(135deg, var(--color-accent), #06b6d4);
  padding: 0.8rem 1.6rem;
  border-radius: 12px;
  color: white;
  text-decoration: none;
  font-weight: 600;
  font-size: 0.95rem;
  transition: 0.3s ease;
}

.btn:hover,
.btn:focus-visible {
  transform: translateY(-3px);
  box-shadow: 0 10px 25px rgba(16, 185, 129, 0.3);
}

.btn:focus-visible {
  outline: 2px solid white;
  outline-offset: 2px;
}

/* ========== Footer ========== */
.footer {
  text-align: center;
  padding: 3rem 0;
  color: var(--color-text-muted);
  font-size: 0.9rem;
}

/* ========== Post Styling ========== */
.post-date {
  color: var(--color-text-muted);
  margin-bottom: 2rem;
  font-size: 0.95rem;
}

/* ========== Prev/Next Post Navigation ========== */
.post-nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-top: 3rem;
  padding-top: 2rem;
  border-top: 1px solid var(--color-border);
}

.post-nav-link {
  display: block;
  padding: 1rem 1.25rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  text-decoration: none;
  color: var(--color-text);
  transition: border-color 0.2s ease, background 0.2s ease;
}

.post-nav-link .post-nav-title {
  position: relative;
  display: inline-block;
}

.post-nav-link .post-nav-title::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 0;
  height: 1px;
  background: var(--color-accent);
  transition: width 0.25s ease;
}

.post-nav-link:hover .post-nav-title::after,
.post-nav-link:focus-visible .post-nav-title::after {
  width: 100%;
}

.post-nav-link:hover,
.post-nav-link:focus-visible {
  border-color: var(--color-accent);
  background: var(--color-accent-soft);
}

.post-nav-link:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

.post-nav-prev {
  text-align: left;
}

.post-nav-next {
  text-align: right;
  grid-column: 2;
}

.post-nav-prev:only-child,
.post-nav-next:only-child {
  grid-column: 1 / -1;
}

.post-nav-label {
  display: block;
  font-size: 0.8rem;
  color: var(--color-text-muted);
  margin-bottom: 0.25rem;
}

.post-nav-title {
  font-weight: 600;
  font-size: 0.95rem;
}

/* ========== Homepage Post List with Thumbnails ========== */
.home .post-list-heading {
  font-size: 1.75rem;
  margin-bottom: 2rem;
}

.post-list {
  list-style: none;
}

.post-preview-item {
  margin-bottom: 2.5rem;
  opacity: 0;
  animation: cardSlideIn 0.5s ease forwards;
}

.post-preview-link {
  display: block;
  text-decoration: none;
  color: inherit;
  border-radius: 16px;
  overflow: hidden;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.post-preview-link:hover,
.post-preview-link:focus-visible {
  transform: translateY(-4px);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.4);
  border-color: var(--color-accent);
}

.post-preview-link:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

.post-preview-thumbnail {
  width: 100%;
  height: 200px;
  overflow: hidden;
}

.post-preview-thumbnail img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.3s ease;
}

.post-preview-link:hover .post-preview-thumbnail img,
.post-preview-link:focus-visible .post-preview-thumbnail img {
  transform: scale(1.05);
}

.post-preview-content {
  padding: 1.5rem;
}

.post-preview-content .post-meta {
  display: block;
  color: var(--color-text-muted);
  font-size: 0.85rem;
  margin-bottom: 0.5rem;
}

.post-preview-title {
  font-size: 1.35rem;
  margin: 0 0 0.5rem 0;
  color: var(--color-text);
}

.post-preview-excerpt {
  color: var(--color-text-muted);
  font-size: 0.95rem;
  margin: 0;
  line-height: 1.55;
}

.rss-subscribe {
  margin-top: 2rem;
  color: var(--color-text-muted);
  font-size: 0.9rem;
}

.rss-subscribe a {
  color: var(--color-accent);
  text-decoration: none;
  position: relative;
}

.rss-subscribe a::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 0;
  height: 1px;
  background: var(--color-accent);
  transition: width 0.25s ease;
}

.rss-subscribe a:hover::after,
.rss-subscribe a:focus-visible::after {
  width: 100%;
}

.rss-subscribe a:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

/* ========== Post Content (inside articles) ========== */
.post-content {
  font-size: 1.0625rem;
  line-height: 1.75;
}

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

.post-content ul {
  list-style-type: disc;
}

.post-content ol {
  list-style-type: decimal;
}

.post-content li {
  margin-bottom: 0.5rem;
}

.post-content blockquote {
  margin: 1.5rem 0;
  padding: 1rem 1.5rem;
  border-left: 4px solid var(--color-accent);
  background: var(--color-surface);
  border-radius: 0 8px 8px 0;
  color: var(--color-text-muted);
}

.post-content code {
  font-family: 'JetBrains Mono', 'Fira Code', ui-monospace, monospace;
  font-size: 0.9em;
  padding: 0.2em 0.4em;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  color: var(--color-text);
}

.post-content pre {
  margin: 1.5rem 0;
  padding: 1rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  overflow-x: auto;
}

.post-content pre code {
  padding: 0;
  background: none;
  border: none;
}

.post-content a {
  color: var(--color-accent);
  text-decoration: none;
  position: relative;
}

.post-content a::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 0;
  width: 0;
  height: 1px;
  background: var(--color-accent-hover);
  transition: width 0.25s ease;
}

.post-content a:hover,
.post-content a:focus-visible {
  color: var(--color-accent-hover);
}

.post-content a:hover::after,
.post-content a:focus-visible::after {
  width: 100%;
}

.post-content a:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

.post-content img {
  max-width: 100%;
  height: auto;
  border-radius: 12px;
}

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

/* ========== 404 Page ========== */
.page-404 {
  text-align: center;
  padding: 4rem 2rem;
}

.page-404 h1 {
  font-size: 4rem;
  margin: 0 0 1rem 0;
  letter-spacing: -2px;
}

.page-404 p {
  margin-bottom: 0.75rem;
}

.page-404 .btn {
  margin-top: 2rem;
}

/* ========== Animations ========== */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

/* ========== Space background ========== */
.space-bg {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  pointer-events: none;
  z-index: -1;
  /* Deep space gradient overlay (subtle nebula hint) */
  background:
    radial-gradient(ellipse 80% 50% at 50% 0%, rgba(88, 101, 242, 0.06) 0%, transparent 50%),
    radial-gradient(ellipse 60% 40% at 80% 100%, rgba(139, 92, 246, 0.05) 0%, transparent 45%),
    radial-gradient(ellipse 50% 30% at 10% 80%, rgba(59, 130, 246, 0.04) 0%, transparent 40%),
    /* Starfield - brighter, more numerous */
    radial-gradient(2px 2px at 8% 12%, rgba(255, 255, 255, 0.15), transparent),
    radial-gradient(2px 2px at 22% 18%, rgba(255, 255, 255, 0.12), transparent),
    radial-gradient(3px 3px at 38% 8%, rgba(255, 255, 255, 0.25), transparent),
    radial-gradient(2px 2px at 52% 25%, rgba(255, 255, 255, 0.1), transparent),
    radial-gradient(2px 2px at 68% 15%, rgba(255, 255, 255, 0.14), transparent),
    radial-gradient(3px 3px at 85% 22%, rgba(255, 255, 255, 0.2), transparent),
    radial-gradient(2px 2px at 95% 40%, rgba(255, 255, 255, 0.12), transparent),
    radial-gradient(2px 2px at 5% 45%, rgba(255, 255, 255, 0.1), transparent),
    radial-gradient(2px 2px at 18% 55%, rgba(255, 255, 255, 0.15), transparent),
    radial-gradient(3px 3px at 45% 48%, rgba(255, 255, 255, 0.22), transparent),
    radial-gradient(2px 2px at 62% 58%, rgba(255, 255, 255, 0.11), transparent),
    radial-gradient(2px 2px at 78% 52%, rgba(255, 255, 255, 0.13), transparent),
    radial-gradient(2px 2px at 92% 68%, rgba(255, 255, 255, 0.1), transparent),
    radial-gradient(2px 2px at 12% 75%, rgba(255, 255, 255, 0.14), transparent),
    radial-gradient(3px 3px at 28% 88%, rgba(255, 255, 255, 0.2), transparent),
    radial-gradient(2px 2px at 55% 82%, rgba(255, 255, 255, 0.12), transparent),
    radial-gradient(2px 2px at 72% 78%, rgba(255, 255, 255, 0.15), transparent),
    radial-gradient(2px 2px at 88% 92%, rgba(255, 255, 255, 0.11), transparent),
    radial-gradient(2px 2px at 42% 35%, rgba(255, 255, 255, 0.08), transparent),
    radial-gradient(2px 2px at 15% 32%, rgba(255, 255, 255, 0.1), transparent),
    radial-gradient(2px 2px at 75% 42%, rgba(255, 255, 255, 0.09), transparent),
    radial-gradient(2px 2px at 35% 65%, rgba(255, 255, 255, 0.11), transparent),
    radial-gradient(2px 2px at 58% 70%, rgba(255, 255, 255, 0.1), transparent);
  background-repeat: no-repeat;
}

/* Subtle twinkle on brightest stars */
@keyframes twinkle {
  0%, 100% { opacity: 0.6; }
  50% { opacity: 1; }
}

.space-bg::before,
.space-bg::after {
  content: '';
  position: absolute;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.5);
  animation: twinkle 4s ease-in-out infinite;
  pointer-events: none;
}

.space-bg::before {
  top: 12%;
  left: 38%;
  box-shadow: 0 0 6px rgba(255, 255, 255, 0.4);
}

.space-bg::after {
  top: 52%;
  left: 42%;
  animation-delay: 2s;
  box-shadow: 0 0 6px rgba(255, 255, 255, 0.3);
}

.footer-star {
  color: var(--color-accent);
  font-size: 0.75em;
  opacity: 0.85;
  margin-right: 0.25rem;
}

.footer-tagline {
  display: block;
  margin-top: 0.5rem;
  font-size: 0.8rem;
  color: var(--color-text-muted);
  opacity: 0.8;
}

/* ========== Reduced motion ========== */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .post-preview-item {
    opacity: 1;
  }

  .space-bg::before,
  .space-bg::after {
    animation: none;
  }
}

/* ========== Post Cover Image (on post page) ========== */
.post-cover {
  margin-bottom: 2rem;
}

.post-cover img {
  width: 100%;
  max-height: 400px;
  object-fit: cover;
  border-radius: 20px;
  display: block;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
}