/* ============================================================
 * News timeline — elegant minimalist design
 * Inspired by Vercel Changelog / Stripe Press / Linear.
 * Uses scoped CSS tokens so dark mode & re-theming are one-liners.
 * ============================================================ */

:root {
  --news-date-w: 84px;
  --news-gap-x: 1.5rem;
  --news-gap-y: 1.15rem;

  --news-fg: #0f172a;
  --news-fg-muted: #64748b;
  --news-fg-dim: #94a3b8;
  --news-bg: transparent;
  --news-bg-hover: rgba(15, 23, 42, 0.025);
  --news-rule: rgba(15, 23, 42, 0.08);
  --news-rule-strong: rgba(15, 23, 42, 0.18);
  --news-accent: #d13126;

  --news-font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "Inter", Roboto, Helvetica, Arial, sans-serif;
  --news-font-mono: ui-monospace, SFMono-Regular, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
}

body.dark {
  --news-fg: #f1f5f9;
  --news-fg-muted: #94a3b8;
  --news-fg-dim: #64748b;
  --news-bg-hover: rgba(255, 255, 255, 0.03);
  --news-rule: rgba(255, 255, 255, 0.09);
  --news-rule-strong: rgba(255, 255, 255, 0.22);
}

/* ------------------------------------------------------------
 * Page wrapper — wider, airier than default article content.
 * ------------------------------------------------------------ */
.news-page {
  max-width: 860px;
  padding-top: 1rem;
  padding-bottom: 5rem;
}
.news-page .article-style {
  color: var(--news-fg-muted);
  font-size: 1rem;
  margin-bottom: 2rem;
}

/* ------------------------------------------------------------
 * List container
 * ------------------------------------------------------------ */
.news-list {
  display: flex;
  flex-direction: column;
  border-top: 1px solid var(--news-rule);
}

/* ------------------------------------------------------------
 * News item — two-column grid: [date] [body]
 * ------------------------------------------------------------ */
.news-item {
  position: relative;
  display: grid;
  grid-template-columns: var(--news-date-w) 1fr;
  gap: var(--news-gap-x);
  padding: var(--news-gap-y) 0;
  border-bottom: 1px solid var(--news-rule);
  transition: background-color 0.25s ease;
}

.news-item:hover {
  background-color: var(--news-bg-hover);
}

/* Subtle left accent bar — only on featured items */
.news-item--featured::before {
  content: "";
  position: absolute;
  left: -10px;
  top: calc(var(--news-gap-y) + 0.35rem);
  bottom: var(--news-gap-y);
  width: 2px;
  background: var(--news-cat-color, var(--news-accent));
  border-radius: 2px;
  opacity: 0.75;
}

/* ------------------------------------------------------------
 * Date column — tabular mono, two-line stack
 * ------------------------------------------------------------ */
.news-date {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  padding-top: 0.35rem;
  font-family: var(--news-font-mono);
  font-size: 0.8125rem; /* 13px */
  font-variant-numeric: tabular-nums;
  line-height: 1.3;
  letter-spacing: 0.01em;
  color: var(--news-fg-dim);
}
.news-date__month {
  text-transform: uppercase;
  font-weight: 600;
  color: var(--news-fg-muted);
  letter-spacing: 0.06em;
}
.news-date__year {
  font-weight: 400;
}

/* ------------------------------------------------------------
 * Body column
 * ------------------------------------------------------------ */
.news-body {
  min-width: 0; /* prevent overflow in grid */
}

.news-meta {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.3rem;
}

/* Category kicker — tiny uppercase label, category-tinted */
.news-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-family: var(--news-font-sans);
  font-size: 0.6875rem; /* 11px */
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--news-cat-color, var(--news-fg-muted));
}
.news-badge__icon {
  font-size: 0.75rem;
  line-height: 1;
  opacity: 0.9;
}

/* Featured dot — small, haloed with the category color */
.news-featured {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--news-cat-color, var(--news-accent));
  box-shadow: 0 0 0 3px rgba(209, 49, 38, 0.12);
}

/* Title — the focal point */
.news-title {
  font-family: var(--news-font-sans);
  font-size: 1rem; /* 16px */
  font-weight: 600;
  line-height: 1.35;
  letter-spacing: -0.005em;
  margin: 0 0 0.25rem;
  color: var(--news-fg);
}
.news-item--featured .news-title {
  font-size: 1.0625rem; /* 17px */
  letter-spacing: -0.01em;
}
.news-title a {
  color: inherit;
  text-decoration: none;
  border-bottom: none !important;
  background-image: linear-gradient(var(--news-cat-color, var(--news-accent)), var(--news-cat-color, var(--news-accent)));
  background-repeat: no-repeat;
  background-position: 0 100%;
  background-size: 0% 1px;
  transition: background-size 0.3s ease, color 0.25s ease;
  padding-bottom: 1px;
}
.news-title a:hover {
  color: var(--news-cat-color, var(--news-accent));
  background-size: 100% 1px;
  border-bottom: none !important;
}

/* Summary — muted, readable */
.news-summary {
  font-family: var(--news-font-sans);
  font-size: 0.875rem; /* 14px */
  color: var(--news-fg-muted);
  line-height: 1.5;
  margin: 0 0 0.45rem;
  max-width: 62ch;
}
.news-summary em {
  color: var(--news-fg);
  font-style: italic;
}

/* Link chips — text + subtle arrow */
.news-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem 1.1rem;
  list-style: none;
  padding: 0;
  margin: 0;
}
.news-links li {
  display: inline-flex;
}
.news-links a {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-family: var(--news-font-sans);
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--news-fg-muted);
  text-decoration: none;
  border-bottom: none !important;
  transition: color 0.2s ease;
}
.news-links a:hover {
  color: var(--news-cat-color, var(--news-accent));
  border-bottom: none !important;
}
.news-links__arrow {
  width: 10px;
  height: 10px;
  opacity: 0.55;
  transition: transform 0.25s ease, opacity 0.25s ease;
  flex-shrink: 0;
}
.news-links a:hover .news-links__arrow {
  transform: translate(2px, -2px);
  opacity: 1;
}

/* ------------------------------------------------------------
 * Year groups (archive page only)
 * ------------------------------------------------------------ */
.news-timeline {
  margin-top: 2.5rem;
}
.news-year-group + .news-year-group {
  margin-top: 2rem;
}
.news-year-header {
  position: sticky;
  top: 68px; /* sit below the site navbar */
  z-index: 2;
  display: flex;
  align-items: baseline;
  gap: 1rem;
  padding: 0.75rem 0 0.65rem;
  background: var(--background, #fff);
  backdrop-filter: saturate(180%) blur(8px);
  -webkit-backdrop-filter: saturate(180%) blur(8px);
  margin-bottom: 0;
}
body.dark .news-year-header {
  background: var(--background, #0b0f17);
}
.news-year {
  font-family: var(--news-font-mono);
  font-size: 0.875rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--news-fg);
  margin: 0;
  padding: 0;
  border: none !important;
  text-align: left;
}
.news-year-rule {
  flex: 1;
  height: 1px;
  background: var(--news-rule);
}
.news-year-count {
  font-family: var(--news-font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.02em;
  color: var(--news-fg-dim);
  font-variant-numeric: tabular-nums;
}

/* ------------------------------------------------------------
 * Archive collapse — progressive disclosure for older news
 * ------------------------------------------------------------ */
.news-archive {
  margin-top: 2.5rem;
  border-top: 1px dashed var(--news-rule-strong);
  padding-top: 0;
}
.news-archive__summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 0;
  font-family: var(--news-font-mono);
  font-size: 0.8125rem;
  letter-spacing: 0.04em;
  color: var(--news-fg-muted);
  transition: color 0.2s ease;
  user-select: none;
}
.news-archive__summary::-webkit-details-marker {
  display: none;
}
.news-archive__summary::marker {
  content: "";
}
.news-archive__summary:hover {
  color: var(--news-fg);
}
.news-archive__label {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 500;
}
.news-archive__chevron {
  transition: transform 0.25s ease;
  flex-shrink: 0;
}
.news-archive[open] .news-archive__chevron {
  transform: rotate(180deg);
}
.news-archive__count {
  font-variant-numeric: tabular-nums;
  color: var(--news-fg-dim);
  font-size: 0.75rem;
}
.news-archive__body {
  padding-top: 0.5rem;
  animation: newsArchiveReveal 0.35s ease both;
}
@keyframes newsArchiveReveal {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}
@media (prefers-reduced-motion: reduce) {
  .news-archive__body { animation: none; }
  .news-archive__chevron { transition: none; }
}

/* ------------------------------------------------------------
 * Homepage widget variant — tighter rhythm, smaller type
 * ------------------------------------------------------------ */
.news-list--widget {
  --news-gap-x: 1.1rem;
  --news-gap-y: 0.7rem;
  --news-date-w: 64px;
  border-top: none;
}
.news-list--widget .news-item {
  padding: 0.7rem 0;
}
.news-list--widget .news-item:first-child {
  padding-top: 0.15rem;
}
.news-list--widget .news-item:last-child {
  border-bottom: none;
}
.news-list--widget .news-item--featured::before {
  left: -8px;
  top: 0.9rem;
  bottom: 0.7rem;
}
.news-list--widget .news-date {
  font-size: 0.75rem;
  padding-top: 0.15rem;
}
.news-list--widget .news-title {
  font-size: 0.9375rem;
  margin-bottom: 0.15rem;
}
.news-list--widget .news-item--featured .news-title {
  font-size: 1rem;
}
.news-list--widget .news-summary {
  font-size: 0.8125rem;
  margin-bottom: 0.3rem;
}
.news-list--widget .news-meta {
  margin-bottom: 0.18rem;
  gap: 0.45rem;
}
.news-list--widget .news-badge {
  font-size: 0.625rem; /* 10px */
  letter-spacing: 0.1em;
}
.news-list--widget .news-links {
  gap: 0.2rem 0.9rem;
}
.news-list--widget .news-links a {
  font-size: 0.75rem;
}

/* ------------------------------------------------------------
 * Single-news page — back link + breathing room
 * ------------------------------------------------------------ */
.news-page--single {
  max-width: 720px;
}
.news-single-back {
  margin: 0 0 1.5rem;
}
.news-single-back a {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-family: var(--news-font-sans);
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--news-fg-muted);
  text-decoration: none;
  border-bottom: none !important;
  transition: color 0.2s ease;
}
.news-single-back a:hover {
  color: var(--news-accent);
  border-bottom: none !important;
}
.news-list--single {
  border-top: none;
}
.news-list--single .news-item {
  border-bottom: 1px solid var(--news-rule);
  padding-bottom: 1.75rem;
}
.news-single-body {
  margin-top: 1.75rem;
  font-size: 1rem;
  line-height: 1.7;
  color: var(--news-fg);
}

/* ------------------------------------------------------------
 * Responsive — stack date above body on narrow screens
 * ------------------------------------------------------------ */
@media (max-width: 640px) {
  :root {
    --news-gap-x: 0.75rem;
    --news-gap-y: 1.3rem;
  }
  .news-item {
    grid-template-columns: 1fr;
    gap: 0.55rem;
  }
  .news-date {
    flex-direction: row;
    gap: 0.4rem;
    padding-top: 0;
    align-items: baseline;
  }
  .news-date__month::after {
    content: "\00a0\2022"; /* bullet separator */
    color: var(--news-fg-dim);
    font-weight: 400;
    margin-left: 0.2rem;
  }
  .news-year-header {
    top: 60px;
  }
  .news-item--featured::before {
    left: -6px;
  }
}

/* ------------------------------------------------------------
 * Accessibility
 * ------------------------------------------------------------ */
.news-item a:focus-visible {
  outline: 2px solid var(--news-cat-color, var(--news-accent));
  outline-offset: 3px;
  border-radius: 2px;
}

@media (prefers-reduced-motion: reduce) {
  .news-item,
  .news-title a,
  .news-links a,
  .news-links__arrow,
  .news-single-back a {
    transition: none;
  }
}
