/* ===== Article Kit - Thinking Machines Layout ===== */

/* Article Container */
.article {
  max-width: 72ch;
  margin: 0 auto;
  padding: 0 1rem;
  line-height: 1.7;
  color: var(--text);
}

/* Typography Hierarchy */
.article h1 {
  font-size: 2.25rem;
  font-weight: 700;
  line-height: 1.2;
  margin: 2rem 0 1rem;
  color: var(--heading);
  text-wrap: balance;
}

.article h2 {
  font-size: 1.875rem;
  font-weight: 600;
  line-height: 1.3;
  margin: 2.5rem 0 1rem;
  color: var(--heading);
  border-bottom: 2px solid var(--border);
  padding-bottom: 0.5rem;
}

.article h3 {
  font-size: 1.5rem;
  font-weight: 600;
  line-height: 1.4;
  margin: 2rem 0 0.75rem;
  color: var(--heading);
}

.article h4 {
  font-size: 1.25rem;
  font-weight: 600;
  line-height: 1.4;
  margin: 1.5rem 0 0.5rem;
  color: var(--heading);
}

.article h5,
.article h6 {
  font-size: 1.125rem;
  font-weight: 600;
  line-height: 1.4;
  margin: 1.25rem 0 0.5rem;
  color: var(--heading);
}

/* Paragraphs and Text */
.article p {
  margin: 1rem 0;
  text-align: justify;
  hyphens: auto;
}

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

.article p:last-child {
  margin-bottom: 0;
}

/* Lists */
.article ul,
.article ol {
  margin: 1rem 0;
  padding-left: 1.5rem;
}

.article li {
  margin: 0.5rem 0;
  line-height: 1.6;
}

.article li p {
  margin: 0.25rem 0;
}

/* Code and Pre */
.article code {
  background: var(--code-bg);
  color: var(--code-text);
  padding: 0.125rem 0.375rem;
  border-radius: 0.25rem;
  font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace;
  font-size: 0.875em;
}

.article pre {
  background: var(--code-bg);
  color: var(--code-text);
  padding: 1.5rem;
  border-radius: 0.5rem;
  overflow-x: auto;
  margin: 1.5rem 0;
  border: 1px solid var(--border);
  position: relative;
}

.article pre code {
  background: none;
  padding: 0;
  color: inherit;
  font-size: 0.875rem;
  line-height: 1.5;
}

/* Code Copy Button */
.code-container {
  position: relative;
}

.code-copy {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  background: var(--accent);
  color: white;
  border: none;
  padding: 0.375rem 0.75rem;
  border-radius: 0.25rem;
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.code-container:hover .code-copy {
  opacity: 1;
}

.code-copy:active {
  transform: translateY(1px);
}

/* Blockquotes */
.article blockquote {
  border-left: 4px solid var(--accent);
  background: var(--blockquote-bg);
  margin: 1.5rem 0;
  padding: 1rem 1.5rem;
  font-style: italic;
  color: var(--muted);
}

.article blockquote p {
  margin: 0;
}

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

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

.article th {
  background: var(--table-header-bg);
  font-weight: 600;
  color: var(--heading);
}

.article tr:hover {
  background: var(--table-hover-bg);
}

/* Figures */
.article figure {
  margin: 2rem 0;
  text-align: center;
}

.article figcaption {
  font-size: 0.875rem;
  color: var(--muted);
  margin-top: 0.5rem;
  font-style: italic;
}

.article img {
  max-width: 100%;
  height: auto;
  border-radius: 0.5rem;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

/* Callouts */
.callout {
  background: var(--callout-bg);
  border: 1px solid var(--callout-border);
  border-radius: 0.5rem;
  padding: 1.25rem;
  margin: 1.5rem 0;
  position: relative;
}

.callout::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: var(--accent);
  border-radius: 0.5rem 0 0 0.5rem;
}

.callout.info {
  --callout-bg: #f0f9ff;
  --callout-border: #0ea5e9;
}

.callout.warning {
  --callout-bg: #fefce8;
  --callout-border: #eab308;
}

.callout.danger {
  --callout-bg: #fef2f2;
  --callout-border: #ef4444;
}

.callout.success {
  --callout-bg: #f0fdf4;
  --callout-border: #22c55e;
}

.callout-title {
  font-weight: 600;
  margin: 0 0 0.5rem 0;
  color: var(--heading);
}

.callout p {
  margin: 0.5rem 0;
}

.callout p:last-child {
  margin-bottom: 0;
}

/* Table of Contents */
.toc {
  background: var(--toc-bg);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  padding: 1.5rem;
  margin: 2rem 0;
}

.toc-title {
  font-weight: 600;
  margin: 0 0 1rem 0;
  color: var(--heading);
  font-size: 1.125rem;
}

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

.toc-list li {
  margin: 0.5rem 0;
}

.toc-list a {
  color: var(--text);
  text-decoration: none;
  padding: 0.25rem 0;
  display: block;
  border-radius: 0.25rem;
  transition: background-color 0.2s ease;
}

.toc-list a:hover {
  background: var(--hover-bg);
  color: var(--accent);
}

.toc-list .toc-h2 {
  padding-left: 0;
  font-weight: 500;
}

.toc-list .toc-h3 {
  padding-left: 1rem;
  font-size: 0.875rem;
  color: var(--muted);
}

.toc-list .toc-h4 {
  padding-left: 2rem;
  font-size: 0.875rem;
  color: var(--muted);
}

/* Responsive Design */
@media (max-width: 768px) {
  .article {
    padding: 0 0.75rem;
  }
  
  .article h1 {
    font-size: 1.875rem;
  }
  
  .article h2 {
    font-size: 1.5rem;
  }
  
  .article pre {
    padding: 1rem;
    font-size: 0.8125rem;
  }
  
  .code-copy {
    opacity: 1; /* Always show on mobile */
  }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
  .article {
    --code-bg: #1e1e1e;
    --code-text: #d4d4d4;
    --blockquote-bg: #2a2a2a;
    --table-header-bg: #2a2a2a;
    --table-hover-bg: #1a1a1a;
    --callout-bg: #1a1a1a;
    --callout-border: #404040;
    --toc-bg: #1a1a1a;
    --hover-bg: #2a2a2a;
  }
}

/* Figure styles (moved from figure.html) */
.figure {
  margin: 2rem 0;
  text-align: center;
}

.figure-container {
  position: relative;
  display: inline-block;
  max-width: 100%;
}

.figure img {
  max-width: 100%;
  height: auto;
  border-radius: 0.5rem;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  transition: transform 0.2s ease;
}

.figure img:hover {
  transform: scale(1.02);
}

.figure-caption {
  font-size: 0.875rem;
  color: var(--muted);
  margin-top: 0.75rem;
  font-style: italic;
  line-height: 1.5;
  max-width: 100%;
}

.figure-number {
  font-weight: 600;
  color: var(--accent);
}

/* ToC active state (moved from toc.html) */
.toc-list a.active {
  background: var(--accent);
  color: white;
  font-weight: 500;
}

.toc-list a.active:hover {
  background: var(--accent);
  color: white;
}

/* Print styles */
@media print {
  .article {
    max-width: none;
    padding: 0;
  }
  
  .code-copy,
  .toc {
    display: none;
  }
  
  .article h1,
  .article h2,
  .article h3 {
    page-break-after: avoid;
  }
  
  .article pre,
  .article blockquote {
    page-break-inside: avoid;
  }
  
  .figure img {
    box-shadow: none;
  }
  
  .figure img:hover {
    transform: none;
  }
  
  .callout {
    break-inside: avoid;
    box-shadow: none;
  }
}
