/* Assert and Reflect - Design System */
:root {
  --bg: #0d1117;
  --bg-elevated: #161b22;
  --text: #e6edf3;
  --text-muted: #8b949e;
  --accent: #58a6ff;
  --accent-hover: #79b8ff;
  --border: #30363d;
  --card-bg: #161b22;
  --font-sans: "Source Sans 3", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-serif: "Source Serif 4", Georgia, serif;
  --font-mono: "JetBrains Mono", "Fira Code", monospace;
}

[data-theme="light"] {
  --bg: #ffffff;
  --bg-elevated: #f6f8fa;
  --text: #1f2328;
  --text-muted: #656d76;
  --accent: #0969da;
  --accent-hover: #0550ae;
  --border: #d0d7de;
  --card-bg: #f6f8fa;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

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

/* Typography */
h1, h2, h3, h4 {
  font-family: var(--font-serif);
  font-weight: 600;
  line-height: 1.3;
}

h1 { font-size: 2rem; }
h2 { font-size: 1.5rem; margin-top: 2rem; }
h3 { font-size: 1.25rem; margin-top: 1.5rem; }

p {
  margin: 0 0 1rem;
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: color 0.2s ease;
}

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

/* Layout */
.main {
  flex: 1;
  max-width: 720px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
  width: 100%;
}

/* Header & Nav */
.site-header {
  border-bottom: 1px solid var(--border);
  background: var(--bg-elevated);
}

.nav {
  max-width: 720px;
  margin: 0 auto;
  padding: 1rem 1.5rem;
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
}

.nav a {
  color: var(--text);
  font-weight: 500;
}

.nav a:hover {
  color: var(--accent);
}

.theme-toggle {
  margin-left: auto;
  padding: 0.35rem 0.75rem;
  background: var(--border);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 0.875rem;
  cursor: pointer;
  border-radius: 6px;
  transition: background 0.2s, color 0.2s;
}

.theme-toggle:hover {
  background: var(--accent);
  color: var(--bg);
}

/* Search */
.search-container {
  margin-right: 0.5rem;
}

.search-wrap {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.search-trigger {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-muted);
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s;
}

.search-trigger:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.search-expand {
  display: flex;
  flex-direction: column;
  position: relative;
  width: 0;
  overflow: hidden;
  opacity: 0;
  transition: width 0.2s ease, opacity 0.2s ease;
}

.search-expand.search-expanded {
  opacity: 1;
}

.search-open .search-expand {
  width: 220px;
  opacity: 1;
  overflow: visible; /* allow dropdown to extend below */
}

.search-input {
  width: 100%;
  padding: 0.4rem 0.6rem;
  font-size: 0.9rem;
  font-family: var(--font-sans);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
}

.search-input::placeholder {
  color: var(--text-muted);
}

.search-input:focus {
  outline: none;
  border-color: var(--accent);
}

.search-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  margin-top: 0.25rem;
  max-height: 320px;
  overflow-y: auto;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  z-index: 100;
}

.search-results-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.search-results-list li a {
  display: block;
  padding: 0.6rem 0.75rem;
  color: var(--text);
  text-decoration: none;
  border-bottom: 1px solid var(--border);
  transition: background 0.15s;
}

.search-results-list li:last-child a {
  border-bottom: none;
}

.search-results-list li a:hover,
.search-result-selected a {
  background: var(--bg);
}

.search-result-title {
  display: block;
  font-weight: 500;
  margin-bottom: 0.2rem;
}

.search-result-desc {
  display: block;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.15rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.search-result-tags {
  font-size: 0.75rem;
  color: var(--accent);
}

.search-results-empty,
.search-results-loading,
.search-results-hint {
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
  color: var(--text-muted);
  margin: 0;
}

.search-results-list mark {
  background: var(--accent);
  color: var(--bg);
  padding: 0 0.1em;
  border-radius: 2px;
}

/* Hero */
.hero {
  text-align: center;
  padding: 3rem 0 2rem;
}

.hero h1 {
  font-size: 1.75rem;
  margin-bottom: 0.5rem;
}

.hero .tagline {
  font-size: 1.25rem;
  color: var(--text-muted);
  font-style: italic;
  max-width: 36ch;
  margin: 0 auto;
}

/* Pillars */
.pillars {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
  margin: 3rem 0;
}

@media (min-width: 600px) {
  .pillars {
    grid-template-columns: repeat(3, 1fr);
  }
}

.pillar-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.5rem;
  transition: border-color 0.2s, transform 0.2s;
}

.pillar-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}

.pillar-card h3 {
  margin-top: 0;
  font-size: 1.1rem;
}

.pillar-card p {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

.pillar-card a {
  font-size: 0.9rem;
  font-weight: 500;
}

/* Posts Section */
.posts-section h2 {
  margin-top: 0;
  margin-bottom: 1rem;
}

.posts-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.posts-list li {
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border);
}

.posts-list li:last-child {
  border-bottom: none;
}

.posts-list a {
  font-weight: 500;
}

.posts-list .excerpt {
  display: block;
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

.posts-list .meta {
  display: block;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

/* Post Page */
.post-main {
  padding-top: 2rem;
}

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

.post-header h1 {
  margin-bottom: 0.5rem;
}

.post-meta {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin: 0;
}

.post-category-tag {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent);
  background: transparent;
  border: 1px solid var(--accent);
  border-radius: 4px;
  padding: 0.2rem 0.5rem;
  margin-bottom: 0.75rem;
}

.post-tags {
  margin: 0.75rem 0 0;
  font-size: 0.9rem;
}

.post-tag {
  display: inline-block;
  color: var(--text-muted);
  padding: 0.15rem 0.4rem;
  margin-right: 0.5rem;
  margin-bottom: 0.25rem;
  border-radius: 4px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
}

.post-tag:hover {
  color: var(--accent);
  border-color: var(--accent);
}

/* Breadcrumb */
.breadcrumb {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-bottom: 1.5rem;
}

.breadcrumb ol {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
}

.breadcrumb li + li::before {
  content: ' › ';
  margin-right: 0.35rem;
  color: var(--text-muted);
}

.breadcrumb li[aria-current="page"] {
  color: var(--text);
}

.breadcrumb a:hover {
  text-decoration: underline;
}

/* Related posts */
.related-posts {
  margin-top: 2.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

.related-posts h2 {
  font-size: 1.1rem;
  margin-top: 0;
  margin-bottom: 0.75rem;
}

.related-posts ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.related-posts li {
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
}

.related-posts li:last-child {
  border-bottom: none;
}

.related-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-left: 0.5rem;
}

.post-byline {
  margin-top: 1.5rem;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.post-content {
  font-size: 1.05rem;
}

.post-content code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  background: var(--bg-elevated);
  padding: 0.2em 0.4em;
  border-radius: 4px;
  border: 1px solid var(--border);
}

.post-content pre {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1rem;
  overflow-x: auto;
}

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

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

/* Author Bio */
.author-bio {
  margin-top: 2.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
  font-size: 0.9rem;
  color: var(--text-muted);
}

.author-bio .author-name {
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: 1rem;
  color: var(--text);
  margin-bottom: 0.25rem;
}

/* Newsletter */
.newsletter-section {
  margin-top: 2.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

.newsletter-section p {
  font-size: 0.95rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

.newsletter-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: flex-start;
  max-width: 420px;
}

.newsletter-form input[type="email"] {
  flex: 1;
  min-width: 200px;
  padding: 0.5rem 0.75rem;
  font-size: 0.95rem;
  font-family: var(--font-sans);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
}

.newsletter-form input[type="email"]::placeholder {
  color: var(--text-muted);
}

.newsletter-form input[type="email"]:focus {
  outline: none;
  border-color: var(--accent);
}

.newsletter-form button[type="submit"] {
  padding: 0.5rem 1rem;
  font-size: 0.95rem;
  font-family: var(--font-sans);
  font-weight: 500;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}

.newsletter-form button[type="submit"]:hover {
  background: var(--accent);
  color: var(--bg);
  border-color: var(--accent);
}

.newsletter-privacy {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.5rem;
}

/* Footer */
.site-footer {
  border-top: 1px solid var(--border);
  text-align: center;
  padding: 1.5rem;
  font-size: 0.875rem;
  color: var(--text-muted);
}


/* Page Title */
.page-title {
  margin-bottom: 0.25rem;
}

.author-role {
  font-size: 1.1rem;
  color: var(--text-muted);
  margin-bottom: 1.5rem;
}

.start-here-links {
  list-style: none;
  padding: 0;
  margin: 0;
}

.start-here-links li {
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
}

.start-here-links li:last-child {
  border-bottom: none;
}

.loading {
  color: var(--text-muted);
}

/* Accessibility - visually hidden but available to screen readers */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
