/* Cloudripper Labs Blog - Inspired by Transformer Circuits */

:root {
  --text-primary: rgba(0, 0, 0, 0.87);
  --text-secondary: rgba(0, 0, 0, 0.67);
  --text-muted: #777;
  --bg-white: #fff;
  --bg-code: #fafafa;
  --border-light: #eee;
  --border-medium: #ccc;
  --accent-green: hsl(125, 45%, 65%);
  --accent-cyan: hsl(180, 50%, 65%);
  --max-width: 1100px;
  --content-width: 700px;
  --toc-width: 220px;
  --side-padding: 24px;
}

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

html {
  font-size: 18px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  margin: 0;
  padding: 0;
  font-family: Georgia, "Times New Roman", serif;
  color: var(--text-primary);
  background: var(--bg-white);
  line-height: 1.7;
}

/* Layout */
.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 var(--side-padding);
}

/* Header */
header {
  padding: 60px 0 40px;
  border-bottom: 1px solid var(--border-light);
  margin-bottom: 60px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 16px;
  text-decoration: none;
  color: inherit;
}

.logo svg {
  width: 48px;
  height: 48px;
}

.logo-text {
  font-size: 1.4rem;
  font-weight: 400;
  letter-spacing: -0.02em;
}

.logo-text .labs {
  color: var(--text-muted);
  font-weight: 300;
}

.logo-separator {
  color: var(--border-medium);
  margin: 0 4px;
  font-weight: 300;
}

.logo-tagline {
  color: var(--text-secondary);
  font-weight: 300;
}

nav {
  margin-top: 20px;
}

nav a {
  color: var(--text-secondary);
  text-decoration: none;
  margin-right: 24px;
  font-size: 0.9rem;
}

nav a:hover {
  color: var(--text-primary);
  text-decoration: underline;
}

/* Typography */
h1, h2, h3, h4 {
  font-weight: 400;
  line-height: 1.3;
  margin-top: 2em;
  margin-bottom: 0.5em;
}

h1 {
  font-size: 2.2rem;
  margin-top: 0;
}

h2 {
  font-size: 1.6rem;
  border-bottom: 1px solid var(--border-light);
  padding-bottom: 0.3em;
}

h3 {
  font-size: 1.2rem;
}

p {
  margin: 1em 0;
}

a {
  color: var(--text-primary);
  text-decoration: underline;
  text-decoration-color: var(--border-medium);
  text-underline-offset: 3px;
}

a:hover {
  text-decoration-color: var(--text-primary);
}

/* Article List (Index) */
.post-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.post-list li {
  margin-bottom: 40px;
  padding-bottom: 40px;
  border-bottom: 1px solid var(--border-light);
}

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

.post-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 8px;
}

.post-title {
  font-size: 1.4rem;
  margin: 0 0 12px;
  font-weight: 400;
}

.post-title a {
  text-decoration: none;
}

.post-title a:hover {
  text-decoration: underline;
}

.post-excerpt {
  color: var(--text-secondary);
  margin: 0;
}

/* Article Content */
article {
  margin-bottom: 80px;
}

article > header {
  border-bottom: 1px solid var(--border-light);
  padding: 0 0 32px 0;
  margin-bottom: 28px;
}

article > header h1 {
  margin-bottom: 12px;
  margin-left: calc(var(--toc-width) + 60px);
}

article > header .subtitle {
  margin: 0 0 28px 0;
  margin-left: calc(var(--toc-width) + 60px);
  color: var(--text-secondary);
  font-size: 1.1rem;
}

/* Article Info Grid (Author, Date, Affiliations) */
.article-info {
  display: flex;
  flex-wrap: wrap;
  gap: 40px;
  margin-bottom: 0;
  margin-left: calc(var(--toc-width) + 60px);
}

.info-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.info-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.info-value {
  font-size: 0.95rem;
  color: var(--text-primary);
}

.info-value a {
  text-decoration: none;
}

.info-value a:hover {
  text-decoration: underline;
}

/* Two-column article layout */
.article-body {
  display: grid;
  grid-template-columns: var(--toc-width) 1fr;
  gap: 60px;
  align-items: start;
}

/* Table of Contents Sidebar */
.toc {
  position: sticky;
  top: 24px;
  max-height: calc(100vh - 48px);
  overflow-y: auto;
  padding-top: 120px;
}

.toc h2 {
  font-size: 0.85rem;
  font-weight: 500;
  margin: 0 0 12px 0;
  padding: 0;
  border: none;
  color: var(--text-secondary);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

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

.toc li {
  margin-bottom: 10px;
  line-height: 1.4;
}

.toc a {
  font-size: 0.85rem;
  color: var(--text-secondary);
  text-decoration: none;
}

.toc a:hover {
  color: var(--text-primary);
}

.toc .toc-secondary {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border-light);
}

.toc .toc-secondary a {
  color: var(--text-muted);
  font-size: 0.8rem;
}

/* Article main content area */
.article-content {
  max-width: var(--content-width);
}

.article-content h2:first-child {
  margin-top: 0;
}

.article-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Code */
code {
  font-family: "SF Mono", Menlo, Monaco, monospace;
  font-size: 0.85em;
  background: var(--bg-code);
  padding: 2px 6px;
  border-radius: 3px;
  border: 1px solid var(--border-light);
}

pre {
  background: var(--bg-code);
  border: 1px solid var(--border-light);
  border-radius: 4px;
  padding: 20px;
  overflow-x: auto;
  line-height: 1.5;
}

pre code {
  background: none;
  border: none;
  padding: 0;
}

/* Blockquotes */
blockquote {
  margin: 1.5em 0;
  padding: 0 0 0 24px;
  border-left: 3px solid var(--border-medium);
  color: var(--text-secondary);
  font-style: italic;
}

/* Figures */
figure {
  margin: 2em 0;
  text-align: center;
}

figure img {
  max-width: 100%;
  height: auto;
}

figcaption {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 12px;
  line-height: 1.5;
}

/* Tables */
table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5em 0;
  font-size: 0.9rem;
}

th, td {
  padding: 12px;
  text-align: left;
  border-bottom: 1px solid var(--border-light);
}

th {
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  border-bottom: 2px solid var(--border-medium);
}

tr:hover td {
  background: var(--bg-code);
}

/* Concept pill for tables */
.concept-pill {
  display: inline-block;
  font-family: "SF Mono", Menlo, Monaco, monospace;
  font-size: 0.8em;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: 12px;
  background: var(--bg-code);
  border: 1px solid var(--border-light);
}

.concept-pill.success {
  background: hsl(125, 45%, 92%);
  border-color: hsl(125, 45%, 75%);
  color: hsl(125, 45%, 30%);
}

.concept-pill.warning {
  background: hsl(45, 90%, 92%);
  border-color: hsl(45, 90%, 70%);
  color: hsl(45, 90%, 25%);
}

.concept-pill.error {
  background: hsl(0, 70%, 95%);
  border-color: hsl(0, 70%, 80%);
  color: hsl(0, 70%, 35%);
}

/* Hit rate styling */
.hit-rate {
  font-family: "SF Mono", Menlo, Monaco, monospace;
  font-weight: 600;
}

/* Evidence colors (matching paper) */
.evidence-strong {
  background: var(--accent-green);
}

.evidence-causal {
  background: var(--accent-cyan);
}

.evidence-suggestive {
  background: hsl(125, 45%, 85%);
}

/* Horizontal Rule */
hr {
  border: none;
  border-top: 1px solid var(--border-light);
  margin: 80px 0;
}

/* Comments */
.comments {
  max-width: var(--content-width);
  margin-left: calc(var(--toc-width) + 60px);
  margin-top: 0;
}

.comments h2 {
  font-size: 1.6rem;
  border-bottom: 1px solid var(--border-light);
  padding-bottom: 0.3em;
}

@media (max-width: 900px) {
  .comments {
    margin-left: 0;
  }
}

/* Footer */
footer {
  padding: 40px 0;
  border-top: 1px solid var(--border-light);
  margin-top: 80px;
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* Responsive */
@media (max-width: 900px) {
  .article-body {
    display: block;
  }

  .toc {
    position: static;
    max-height: none;
    margin-bottom: 40px;
    padding-top: 0;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--border-light);
  }

  article > header h1,
  article > header .subtitle,
  .article-info {
    margin-left: 0;
  }

  .article-info {
    gap: 24px 40px;
  }
}

@media (max-width: 600px) {
  html {
    font-size: 16px;
  }

  header {
    padding: 40px 0 30px;
    margin-bottom: 40px;
  }

  h1 {
    font-size: 1.8rem;
  }

  h2 {
    font-size: 1.4rem;
  }

  hr {
    margin: 50px 0;
  }

  .article-info {
    flex-direction: column;
    gap: 16px;
  }
}

/* Print */
@media print {
  header, footer, nav {
    display: none;
  }

  .container {
    max-width: none;
    padding: 0;
  }

  h2 {
    page-break-before: always;
  }
}
