/* ============================================
   ARTICLES: the index (/articles/) and single articles.
   The pages are generated by scripts/build-articles.js; the styles are hand-written here.
   Colours come from tokens.css, so dark mode follows automatically.
   ============================================ */

.articles {
  padding: 7rem 1.5rem 4rem;
}

.articles__inner {
  max-width: 46rem;           /* ~70 characters per line at body size: comfortable for long reads */
  margin: 0 auto;
}

.articles__wide {
  max-width: 64rem;
  margin: 0 auto;
}

/* ---------- Breadcrumb ---------- */

.article-crumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0 0 2rem;
  padding: 0;
  list-style: none;
  font-size: 0.875rem;
  color: var(--color-text-tertiary);
}

.article-crumbs li + li::before {
  content: "/";
  margin-right: 0.4rem;
  opacity: 0.6;
}

.article-crumbs a {
  color: var(--color-text-secondary);
}

/* ---------- Index page ---------- */

.articles-hero {
  margin-bottom: 3rem;
}

.articles-hero h1 {
  font-size: var(--font-size-4xl);
  line-height: var(--line-height-tight);
  letter-spacing: var(--letter-spacing-tight);
  margin-bottom: 1rem;
}

.articles-hero p {
  font-size: var(--font-size-lg);
  color: var(--color-text-secondary);
  line-height: var(--line-height-relaxed);
  max-width: 40rem;
}

.article-list {
  display: grid;
  gap: 1.5rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.article-card {
  position: relative;
  padding: 2rem;
  background: var(--color-surface-primary);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-xl);
  transition: border-color var(--duration-normal), box-shadow var(--duration-normal), transform var(--duration-normal);
}

.article-card:hover,
.article-card:focus-within {
  border-color: var(--color-brand-accent);
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
}

.article-card h2 {
  font-size: var(--font-size-2xl);
  line-height: var(--line-height-tight);
  margin: 0.5rem 0 0.75rem;
}

/* The title link covers the whole card, so the card is one large click target. */
.article-card h2 a {
  color: var(--color-text-primary);
  text-decoration: none;
}

.article-card h2 a::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
}

.article-card p {
  color: var(--color-text-secondary);
  line-height: var(--line-height-relaxed);
}

.article-card__more {
  display: inline-block;
  margin-top: 1rem;
  font-weight: var(--font-weight-semibold);
  color: var(--color-brand-primary);
}

[data-theme="dark"] .article-card__more {
  color: var(--color-brand-accent);
}

.articles-empty {
  color: var(--color-text-secondary);
}

/* ---------- Meta line (shared by cards and article header) ---------- */

.article-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.75rem;
  font-size: 0.875rem;
  color: var(--color-text-tertiary);
}

.article-meta__kind {
  padding: 0.15em 0.6em;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: var(--font-weight-semibold);
  text-transform: uppercase;
  letter-spacing: var(--letter-spacing-wide);
  color: var(--color-brand-primary);
  background: rgba(26, 53, 94, 0.1);
}

[data-theme="dark"] .article-meta__kind {
  color: var(--color-brand-accent);
  background: rgba(255, 189, 3, 0.12);
}

/* ---------- Single article ---------- */

.article-header {
  margin-bottom: 2.5rem;
  padding-bottom: 2rem;
  border-bottom: 1px solid var(--color-border-subtle);
}

.article-header h1 {
  font-size: var(--font-size-4xl);
  line-height: var(--line-height-tight);
  letter-spacing: var(--letter-spacing-tight);
  margin: 1rem 0;
}

.article-dek {
  font-size: var(--font-size-xl);
  line-height: var(--line-height-snug);
  color: var(--color-text-secondary);
  margin-bottom: 1.5rem;
}

.article-byline {
  font-size: 0.9375rem;
  color: var(--color-text-secondary);
}

.article-byline strong {
  color: var(--color-text-primary);
}

.article-draft-banner {
  margin-bottom: 2rem;
  padding: 0.75rem 1rem;
  border: 2px dashed var(--color-warning);
  border-radius: var(--radius-md);
  font-weight: var(--font-weight-semibold);
}

/* ---------- Article body (rendered Markdown) ---------- */

.prose {
  font-size: var(--font-size-base);
  line-height: 1.75;
  color: var(--color-text-primary);
}

.prose > * + * {
  margin-top: 1.25em;
}

.prose h2 {
  margin-top: 2.5em;
  font-size: var(--font-size-2xl);
  line-height: var(--line-height-tight);
}

.prose h3 {
  margin-top: 2em;
  font-size: var(--font-size-xl);
  line-height: var(--line-height-snug);
}

.prose h2 + *,
.prose h3 + * {
  margin-top: 0.75em;
}

/* Heading anchors appear on hover, so readers can link to a section. */
.prose .heading-anchor {
  margin-left: 0.4em;
  color: var(--color-text-tertiary);
  text-decoration: none;
  opacity: 0;
  transition: opacity var(--duration-fast);
}

.prose h2:hover .heading-anchor,
.prose h3:hover .heading-anchor,
.prose .heading-anchor:focus {
  opacity: 1;
}

.prose a {
  color: var(--color-brand-secondary);
  text-decoration: underline;
  text-underline-offset: 0.15em;
}

[data-theme="dark"] .prose a {
  color: var(--color-brand-accent);
}

.prose ul,
.prose ol {
  padding-left: 1.5rem;
}

.prose ul { list-style: disc; }
.prose ol { list-style: decimal; }

.prose li + li {
  margin-top: 0.5em;
}

.prose blockquote {
  margin-left: 0;
  padding: 0.25rem 0 0.25rem 1.25rem;
  border-left: 4px solid var(--color-brand-accent);
  color: var(--color-text-secondary);
  font-style: italic;
}

.prose hr {
  border: 0;
  border-top: 1px solid var(--color-border-subtle);
  margin: 3em 0;
}

.prose code {
  font-family: var(--font-family-mono);
  font-size: 0.875em;
  padding: 0.1em 0.35em;
  border-radius: 4px;
  background: rgba(127, 127, 127, 0.15);
}

.prose pre {
  overflow-x: auto;
  padding: 1.25rem;
  border-radius: var(--radius-lg);
  background: var(--color-surface-tertiary);
  font-size: 0.875rem;
  line-height: 1.55;
}

.prose pre code {
  padding: 0;
  background: none;
  font-size: inherit;
}

/* ASCII diagrams keep their alignment, so they never wrap. */
.prose pre.diagram {
  white-space: pre;
}

.prose figure.prompt {
  margin-left: 0;
  margin-right: 0;
  border: 2px solid var(--color-brand-accent);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.prompt__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.6rem 1rem;
  background: rgba(255, 189, 3, 0.15);
  font-size: 0.875rem;
  font-weight: var(--font-weight-semibold);
}

.prompt__copy {
  padding: 0.3rem 0.8rem;
  border: 1px solid currentColor;
  border-radius: var(--radius-md);
  background: transparent;
  color: inherit;
  font: inherit;
  cursor: pointer;
}

.prompt__copy:hover,
.prompt__copy:focus-visible {
  background: var(--color-surface-primary);
}

.prose figure.prompt pre {
  margin: 0;
  border-radius: 0;
  white-space: pre-wrap;      /* prompts are prose: wrap them so nothing hides off-screen */
  background: var(--color-surface-secondary);
  font-size: 0.9375rem;
}

/* ---------- Article footer ---------- */

.article-footer {
  margin-top: 4rem;
  padding-top: 2rem;
  border-top: 1px solid var(--color-border-subtle);
}

.article-footer h2 {
  font-size: var(--font-size-lg);
  margin-bottom: 0.75rem;
}

.article-footer p {
  color: var(--color-text-secondary);
  line-height: var(--line-height-relaxed);
  margin-bottom: 1.5rem;
}

.article-footer__links {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
}

@media (max-width: 768px) {
  .articles {
    padding: 5.5rem 1rem 3rem;
  }

  .article-card {
    padding: 1.5rem;
  }
}

@media print {
  .site-header,
  .site-footer,
  .prompt__copy,
  .article-footer__links {
    display: none;
  }
}
