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

:root {
  --coral: #d1684e;
  --coral-light: #e8856e;
  --bg: #faf8f6;
  --bg-code: #f0ece8;
  --text: #2c2825;
  --text-muted: #6b6360;
  --text-light: #918a86;
  --border: #e0dbd6;
  --font-body: 'Georgia', 'Times New Roman', serif;
  --font-mono: 'SF Mono', 'Menlo', 'Consolas', monospace;
  --font-heading: -apple-system, 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
  --max-width: 640px;
}

html {
  font-size: 18px;
  line-height: 1.7;
  color: var(--text);
  background: var(--bg);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

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

/* === Header === */
.site-header {
  padding: 2rem 0;
  border-bottom: 1px solid var(--border);
}

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

.site-title {
  font-family: var(--font-heading);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
  letter-spacing: -0.02em;
}

.site-title:hover {
  color: var(--coral);
}

nav a {
  font-family: var(--font-heading);
  font-size: 0.85rem;
  color: var(--text-muted);
  text-decoration: none;
  margin-left: 1.5rem;
  text-transform: lowercase;
  letter-spacing: 0.02em;
}

nav a:hover, nav a.active {
  color: var(--coral);
}

/* === Main Content === */
main {
  flex: 1;
  padding: 3rem 0;
}

/* === Home === */
.home-intro {
  margin-bottom: 3rem;
  padding-bottom: 2rem;
  border-bottom: 1px solid var(--border);
}

.home-intro h1 {
  font-family: var(--font-heading);
  font-size: 2rem;
  font-weight: 700;
  margin-bottom: 0.75rem;
  letter-spacing: -0.03em;
  color: var(--text);
}

.home-intro p {
  color: var(--text-muted);
  font-size: 1.05rem;
  margin-bottom: 0.5rem;
}

.home-intro a {
  color: var(--coral);
  text-decoration: none;
  border-bottom: 1px solid transparent;
}

.home-intro a:hover {
  border-bottom-color: var(--coral);
}

.recent-posts h2 {
  font-family: var(--font-heading);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-light);
  margin-bottom: 1.5rem;
}

/* === Post Previews === */
.post-preview {
  margin-bottom: 2rem;
}

.post-preview time {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-light);
}

.post-preview h3 {
  font-family: var(--font-heading);
  font-size: 1.2rem;
  font-weight: 600;
  margin: 0.25rem 0 0.4rem;
  letter-spacing: -0.02em;
}

.post-preview h3 a {
  color: var(--text);
  text-decoration: none;
}

.post-preview h3 a:hover {
  color: var(--coral);
}

.post-preview p {
  color: var(--text-muted);
  font-size: 0.95rem;
  line-height: 1.6;
}

/* === Tags === */
.tags {
  margin: 0.3rem 0 0.5rem;
}

.tag {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--coral);
  text-decoration: none;
  border: 1px solid var(--coral);
  border-radius: 3px;
  padding: 0.1em 0.5em;
  margin-right: 0.4em;
  opacity: 0.8;
}

.tag:hover {
  opacity: 1;
  background: var(--coral);
  color: white;
}

/* === Single Post === */
.post-header {
  margin-bottom: 2rem;
}

.post-header h1 {
  font-family: var(--font-heading);
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.2;
  margin-bottom: 0.5rem;
}

.post-header time {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-light);
}

/* === Post Content === */
.post-content h2 {
  font-family: var(--font-heading);
  font-size: 1.4rem;
  font-weight: 700;
  margin: 2rem 0 0.75rem;
  letter-spacing: -0.02em;
}

.post-content h3 {
  font-family: var(--font-heading);
  font-size: 1.15rem;
  font-weight: 600;
  margin: 1.5rem 0 0.5rem;
}

.post-content p {
  margin-bottom: 1.2rem;
}

.post-content a {
  color: var(--coral);
  text-decoration: none;
  border-bottom: 1px solid transparent;
}

.post-content a:hover {
  border-bottom-color: var(--coral);
}

.post-content blockquote {
  border-left: 3px solid var(--coral);
  padding: 0.5rem 0 0.5rem 1.25rem;
  margin: 1.5rem 0;
  color: var(--text-muted);
  font-style: italic;
}

.post-content code {
  font-family: var(--font-mono);
  font-size: 0.85em;
  background: var(--bg-code);
  padding: 0.15em 0.4em;
  border-radius: 3px;
}

.post-content pre {
  background: var(--bg-code);
  padding: 1rem 1.25rem;
  border-radius: 6px;
  overflow-x: auto;
  margin: 1.5rem 0;
}

.post-content pre code {
  background: none;
  padding: 0;
  font-size: 0.8rem;
}

.post-content ul, .post-content ol {
  margin: 0 0 1.2rem 1.5rem;
}

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

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

/* === Tables === */
.post-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.2rem 0;
  font-size: 0.88rem;
  line-height: 1.5;
}

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

.post-content th {
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-muted);
  border-bottom: 2px solid var(--border);
}

.post-content tr:last-child td {
  border-bottom: none;
}

.post-content tbody tr:hover {
  background: var(--bg-code);
}

/* Allow wide tables to scroll horizontally */
.post-content .table-wrap {
  overflow-x: auto;
  margin: 1.2rem -0.5rem;
  padding: 0 0.5rem;
}

/* === Conversation blocks === */
.conversation {
  margin: 1.5rem 0;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  line-height: 1.8;
}

.conversation .human {
  color: var(--text);
}

.conversation .ai {
  color: var(--coral);
}

.conversation .label {
  font-weight: 700;
  display: inline;
}

/* === Footer === */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 1.5rem 0;
  margin-top: 2rem;
}

.site-footer p {
  font-family: var(--font-heading);
  font-size: 0.75rem;
  color: var(--text-light);
  text-align: center;
}

.site-footer a {
  color: var(--text-light);
  text-decoration: none;
}

.site-footer a:hover {
  color: var(--coral);
}

/* === Dark Mode (system preference) === */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1a1816;
    --bg-code: #252220;
    --text: #e8e2dc;
    --text-muted: #a89f98;
    --text-light: #786e68;
    --border: #3a3532;
    --coral: #e8856e;
    --coral-light: #f0a08a;
  }

  .tag {
    border-color: var(--coral);
    color: var(--coral);
  }

  .tag:hover {
    background: var(--coral);
    color: var(--bg);
  }

  .post-preview h3 a {
    color: var(--text);
  }

  img {
    opacity: 0.9;
  }
}

/* === Responsive === */
@media (max-width: 600px) {
  html { font-size: 16px; }
  .site-header .container { flex-direction: column; gap: 0.5rem; }
  nav a { margin-left: 0; margin-right: 1rem; }
  .home-intro h1 { font-size: 1.6rem; }
  .post-header h1 { font-size: 1.6rem; }
  main { padding: 2rem 0; }
}
