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

/* --- Design Tokens & Variables --- */
:root {
  --bg: #1d2229;
  --bg-offset: #12171d;
  --text: #d8dde2;
  --muted: #a3abb2;
  --accent: #b6c61d;
  --accent-muted: rgba(182, 198, 29, 0.12);
  --accent-bright: #d6e74f;
  --border: #313841;
  --border-focus: #47505a;
  --font-sans: 'Verdana', 'Arial', sans-serif;
  --font-mono: 'Courier New', monospace;
  --max-width: 68ch;
  --transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

html[data-theme="now"] {
  --bg:#294A3A;
  --bg-offset: #294A3A;
  --text: #f6f2ff;
  --muted: rgba(246, 242, 255, 0.82);
  --accent: #7ef0c3;
  --accent-muted: rgba(126, 240, 195, 0.12);
  --accent-bright: #f7f4ff;
  --border: rgba(255, 255, 255, 0.14);
  --border-focus: rgba(255, 255, 255, 0.26);
  --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, monospace;
}

/* --- Base Reset & Setup --- */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  background:
    radial-gradient(circle at top, rgba(182, 198, 29, 0.08), transparent 30%),
    linear-gradient(180deg, #2a3038 0%, var(--bg) 36%, #161a20 100%);
  background-color: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.55;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

html[data-theme="now"] {
  background: var(--bg);
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  padding: 0 1.5rem;
  background-color: var(--bg);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.025), transparent 20%),
    transparent;
}

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

/* --- Header Section --- */
header {
  border-bottom: 1px solid var(--border);
  padding: 2.5rem 0 1.5rem 0;
  margin-bottom: 3rem;
}

header .header-inner {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

header h1 a {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 1.1rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent-bright);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  transition: var(--transition);
  text-shadow: 0 0 10px rgba(182, 198, 29, 0.18);
}

html[data-theme="now"] header h1 a {
  text-shadow: 0 0 10px rgba(124, 92, 255, 0.12);
}

header h1 a::before {
  content: '';
  display: inline-block;
  width: 8px;
  height: 8px;
  background-color: var(--accent);
  box-shadow: 0 0 8px rgba(182, 198, 29, 0.55);
}

html[data-theme="now"] header h1 a::before {
  border-radius: 50%;
  box-shadow: 0 0 8px rgba(124, 92, 255, 0.45);
}

header h1 a:hover {
  color: var(--accent-bright);
}

header nav {
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

header nav a {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--muted);
  text-decoration: none;
  transition: var(--transition);
  padding: 0.2rem 0.35rem;
}

header nav a:hover, header nav a.active {
  color: var(--accent-bright);
}

.theme-toggle {
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.02);
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  padding: 0.2rem 0.5rem;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
}

.theme-toggle:hover {
  color: var(--accent-bright);
  border-color: var(--border-focus);
}

/* --- Main Content --- */
main {
  flex: 1;
  padding-bottom: 4rem;
}

/* --- Post List (Homepage) --- */
.posts-list {
  display: flex;
  flex-direction: column;
}

.post-row {
  border-bottom: 1px solid var(--border);
  padding: 1.75rem 0;
  text-decoration: none;
  color: inherit;
  display: grid;
  grid-template-columns: 140px 1fr;
  align-items: baseline;
  gap: 1.5rem;
  transition: var(--transition);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.015), transparent);
}

.post-row:first-of-type {
  border-top: 1px solid var(--border);
}

.post-row:hover {
  background-color: rgba(182, 198, 29, 0.04);
  padding-left: 0.75rem;
  padding-right: 0.75rem;
  border-color: var(--border-focus);
  box-shadow: inset 0 0 0 1px rgba(182, 198, 29, 0.08);
}

html[data-theme="now"] .post-row:hover {
  background-color: var(--bg-offset);
  box-shadow: inset 0 0 0 1px rgba(124, 92, 255, 0.08);
}

.post-row-meta {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.post-row-title-container {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.post-row-title {
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: -0.015em;
  color: var(--text);
  line-height: 1.3;
  transition: var(--transition);
}

.post-row:hover .post-row-title {
  color: var(--accent-bright);
}

.post-row-excerpt {
  font-size: 0.95rem;
  color: var(--muted);
  font-weight: 300;
  line-height: 1.5;
}

.archive-link {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 1.75rem;
  padding: 0.8rem 1rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--accent-bright);
  text-decoration: none;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  transition: var(--transition);
  background: rgba(255, 255, 255, 0.02);
}

.archive-link:hover {
  background-color: rgba(182, 198, 29, 0.08);
  border-color: var(--border-focus);
}

html[data-theme="now"] .archive-link:hover {
  background-color: var(--bg-offset);
}

.archive-header {
  margin-bottom: 2rem;
}

.archive-header h2 {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin-bottom: 0.5rem;
  color: var(--accent-bright);
}

.archive-header p {
  color: var(--muted);
  font-size: 0.95rem;
}

/* --- Post Detail Page --- */
article {
  animation: fadeIn 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

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

.post-header {
  margin-bottom: 2.5rem;
}

.post-header-meta {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.post-header-meta .tag {
  background-color: var(--accent-muted);
  color: var(--accent-bright);
  padding: 0.15rem 0.4rem;
  border-radius: 3px;
  font-size: 0.75rem;
}

.post-title {
  font-size: 2.25rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.25;
  color: var(--accent-bright);
  text-shadow: 0 0 12px rgba(182, 198, 29, 0.14);
}

html[data-theme="now"] .post-title {
  text-shadow: none;
}

/* --- Editorial Rich Content Typography --- */
.post-body {
  font-size: 1.05rem;
  line-height: 1.75;
  font-weight: 400;
}

.post-body p {
  margin-bottom: 1.5rem;
}

.post-body h2 {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 2.5rem 0 1rem 0;
  color: var(--text);
}

.post-body h3 {
  font-size: 1.25rem;
  font-weight: 600;
  margin: 2rem 0 1rem 0;
  color: var(--text);
}

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

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

.post-body li::marker {
  color: var(--accent);
}

.post-body blockquote {
  border-left: 3px solid var(--accent);
  padding: 0.5rem 0 0.5rem 1.5rem;
  margin: 2rem 0;
  font-style: italic;
  color: var(--muted);
  font-size: 1.1rem;
}

.post-body code {
  font-family: var(--font-mono);
  font-size: 0.85em;
  background-color: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  padding: 0.15rem 0.35rem;
  border-radius: 4px;
  color: var(--accent-bright);
}

.post-body pre {
  background-color: var(--bg-offset);
  border: 1px solid var(--border);
  padding: 1.25rem;
  border-radius: 6px;
  margin: 1.75rem 0;
  overflow-x: auto;
}

.post-body pre code {
  background-color: transparent;
  border: none;
  padding: 0;
  border-radius: 0;
  font-size: 0.9em;
  color: var(--text);
  display: block;
}

/* --- Back Link Style --- */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  text-decoration: none;
  margin-bottom: 2rem;
  transition: var(--transition);
  padding: 0.2rem 0.4rem;
}

.back-link:hover {
  color: var(--text);
  transform: translateX(-3px);
}

html[data-theme="now"] .back-link:hover {
  color: var(--accent-bright);
}

/* --- Status States (Loading, 404, Error) --- */
.state-container {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  padding: 4rem 0;
  animation: fadeIn 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.state-title {
  font-family: var(--font-mono);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--accent-bright);
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

html[data-theme="now"] .state-title {
  text-shadow: none;
}

.state-title::before {
  content: '»';
  color: var(--accent-bright);
  font-weight: 900;
}

.state-desc {
  font-size: 1rem;
  color: var(--muted);
  margin-bottom: 2rem;
  max-width: 50ch;
}

.state-pulse {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--accent);
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0% {
    transform: scale(0.8);
    opacity: 0.5;
  }
  50% {
    transform: scale(1.2);
    opacity: 1;
  }
  100% {
    transform: scale(0.8);
    opacity: 0.5;
  }
}

/* --- Footer Section --- */
footer {
  border-top: 1px solid var(--border);
  padding: 2rem 0;
  margin-top: 4rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

footer p {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--muted);
}

footer .footer-links {
  display: flex;
  gap: 1rem;
}

footer .footer-links a {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--muted);
  text-decoration: none;
  transition: var(--transition);
}

footer .footer-links a:hover {
  color: var(--accent-bright);
}

/* --- Responsive Adjustments --- */
@media (max-width: 640px) {
  html {
    font-size: 15px;
  }
  
  header {
    padding: 1.5rem 0 1rem 0;
    margin-bottom: 2rem;
  }
  
  .post-row {
    grid-template-columns: 1fr;
    gap: 0.5rem;
    padding: 1.5rem 0;
  }
  
  .post-row-meta {
    flex-direction: row;
    gap: 1rem;
  }

  header nav {
    gap: 0.75rem 1rem;
  }
  
  .post-title {
    font-size: 1.8rem;
  }
  
  footer {
    flex-direction: column;
    gap: 1rem;
    align-items: flex-start;
    padding: 1.5rem 0;
  }
}
