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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #f5f5f5;
  color: #333;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }

/* ── Sticky Header ───────────────────────────────────────────── */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: #fff;
  border-bottom: 3px solid #ee4c2c;
  box-shadow: 0 1px 4px rgba(0,0,0,.08);
}

.header-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 12px 20px;
}

.header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.logo-group {
  min-width: 0;
}

.logo {
  font-size: 22px;
  font-weight: 700;
  white-space: nowrap;
}
.logo-torch { color: #ee4c2c; }
.logo-digest { color: #222; }

.tagline {
  font-size: 12px;
  color: #888;
  margin-top: 2px;
  line-height: 1.4;
}

/* ── Filter Bar ──────────────────────────────────────────────── */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.filter-bar select {
  height: 34px;
  padding: 0 10px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
  background: #fafafa;
  color: #333;
  outline: none;
  transition: border-color .15s;
}

.filter-bar select:focus {
  border-color: #ee4c2c;
}

.filter-bar label {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 13px;
  color: #555;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
}

.filter-bar input[type="text"] {
  height: 34px;
  padding: 0 10px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
  background: #fafafa;
  color: #333;
  outline: none;
  width: 180px;
  transition: border-color .15s;
}

.filter-bar input[type="text"]:focus {
  border-color: #ee4c2c;
}

.filter-bar input[type="checkbox"] {
  accent-color: #ee4c2c;
}

/* ── Clear Filters Button ───────────────────────────────────── */
#clear-filters {
  display: none;
  height: 34px;
  padding: 0 12px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: #ee4c2c;
  font-size: 13px;
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s;
}

#clear-filters.visible {
  display: inline-flex;
  align-items: center;
}

#clear-filters:hover {
  background: #fff3e0;
}

/* ── View Controls ──────────────────────────────────────────── */
.view-controls {
  max-width: 1400px;
  margin: 0 auto;
  padding: 12px 20px 0;
  display: flex;
  align-items: center;
  gap: 16px;
}

.view-toggle {
  display: flex;
  border: 1px solid #ddd;
  border-radius: 6px;
  overflow: hidden;
  flex-shrink: 0;
}

.view-btn {
  padding: 5px 16px;
  border: none;
  background: #fafafa;
  color: #666;
  font-size: 13px;
  font-family: inherit;
  font-weight: 500;
  cursor: pointer;
  transition: background .15s, color .15s;
}

.view-btn:not(:last-child) {
  border-right: 1px solid #ddd;
}

.view-btn.active {
  background: #ee4c2c;
  color: #fff;
}

.view-btn:not(.active):hover {
  background: #f0f0f0;
}

/* ── Stats Line ──────────────────────────────────────────────── */
.stats-line {
  font-size: 13px;
  color: #888;
}

/* ── Card Grid ───────────────────────────────────────────────── */
.card-grid {
  max-width: 1400px;
  margin: 0 auto;
  padding: 16px 20px 40px;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}

/* ── Status Messages ─────────────────────────────────────────── */
.status-msg {
  max-width: 1400px;
  margin: 0 auto;
  padding: 60px 20px;
  text-align: center;
  font-size: 15px;
  color: #888;
}

.status-msg.error {
  color: #c62828;
}

/* ── Card ────────────────────────────────────────────────────── */
.card {
  display: flex;
  flex-direction: column;
  background: #fff;
  border-radius: 8px;
  border: 1px solid #e8e8e8;
  padding: 14px 16px;
  transition: box-shadow .15s, border-color .15s;
  cursor: pointer;
}

.card:hover {
  box-shadow: 0 4px 14px rgba(0,0,0,.1);
  border-color: #ee4c2c;
}

.card-main {
  flex: 1;
}

/* ── Card Title Row ─────────────────────────────────────────── */
.card-title-row {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  margin-bottom: 4px;
}

.card-title {
  font-size: 14px;
  font-weight: 700;
  color: #222;
  line-height: 1.35;
  flex: 1;
  min-width: 0;
  cursor: pointer;
  text-decoration: none;
}

.card-title:hover {
  color: #ee4c2c;
}

/* ── Copy URL Button ────────────────────────────────────────── */
.copy-url-btn {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: #bbb;
  cursor: pointer;
  opacity: 0;
  transition: opacity .15s, color .15s, background .15s;
  position: relative;
  margin-top: 1px;
}

.card:hover .copy-url-btn {
  opacity: 1;
}

.copy-url-btn:hover {
  background: #f0f0f0;
  color: #555;
}

.copy-url-btn:active {
  background: #e0e0e0;
}

/* ── Copy Tooltip ───────────────────────────────────────────── */
.copy-tooltip {
  position: absolute;
  bottom: calc(100% + 4px);
  left: 50%;
  transform: translateX(-50%);
  background: #333;
  color: #fff;
  font-size: 11px;
  font-weight: 500;
  padding: 3px 8px;
  border-radius: 4px;
  white-space: nowrap;
  pointer-events: none;
  animation: tooltipFade .15s ease;
}

@keyframes tooltipFade {
  from { opacity: 0; transform: translateX(-50%) translateY(2px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ── Audience ────────────────────────────────────────────────── */
.card-audience {
  font-size: 12px;
  color: #777;
  margin-bottom: 8px;
  line-height: 1.4;
}

/* ── Card Meta ───────────────────────────────────────────────── */
.card-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

/* ── Badge Row ───────────────────────────────────────────────── */
.badge-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.badge {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 600;
  white-space: nowrap;
}

/* Track badge colors */
.badge-track-core-compiler        { background: #fff3e0; color: #e65100; }
.badge-track-distributed-training { background: #e3f2fd; color: #1565c0; }
.badge-track-inference-scaling    { background: #fce4ec; color: #c62828; }
.badge-track-edge-ai              { background: #e8f5e9; color: #2e7d32; }
.badge-track-recommendation       { background: #f3e5f5; color: #7b1fa2; }
.badge-track-foundation           { background: #f5f5f5; color: #757575; }

/* Source badge colors */
.badge-source-pytorch     { background: #fff3e0; color: #e65100; }
.badge-source-vllm        { background: #e0f2f1; color: #00695c; }
.badge-source-huggingface { background: #fef3c7; color: #92400e; }

/* Depth badge colors */
.badge-depth-high   { background: #ffebee; color: #c62828; }
.badge-depth-medium { background: #fff8e1; color: #f57f17; }
.badge-depth-low    { background: #f5f5f5; color: #757575; }

/* ── Tech Tags ───────────────────────────────────────────────── */
.tech-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.tech-tag {
  display: inline-block;
  padding: 1px 6px;
  background: #f0f0f0;
  border-radius: 3px;
  font-size: 10px;
  color: #555;
}

/* ── Related Posts ───────────────────────────────────────────── */
.related-posts {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin-bottom: 8px;
  padding: 6px 0;
  border-top: 1px solid #f0f0f0;
}

.related-label {
  font-size: 10px;
  font-weight: 600;
  color: #aaa;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 1px;
}

.related-link {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: #555;
  line-height: 1.3;
  text-decoration: none;
  cursor: pointer;
}

.related-link:hover {
  color: #ee4c2c;
}

.related-link .badge {
  flex-shrink: 0;
  font-size: 9px;
  padding: 1px 5px;
}

/* ── Card Footer ─────────────────────────────────────────────── */
.card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  color: #999;
  border-top: 1px solid #f0f0f0;
  padding-top: 8px;
}

.code-indicator {
  color: #ee4c2c;
  font-weight: 600;
}

/* ── Topics Container ────────────────────────────────────────── */
.topics-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 16px 20px 40px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ── Topic Card ──────────────────────────────────────────────── */
.topic-card {
  background: #fff;
  border-radius: 8px;
  border: 1px solid #e8e8e8;
  padding: 20px 24px;
}

.topic-header {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 10px;
}

.topic-name {
  font-size: 18px;
  font-weight: 700;
  color: #222;
}

.topic-count {
  font-size: 13px;
  color: #999;
  white-space: nowrap;
}

.topic-summary {
  font-size: 14px;
  color: #555;
  line-height: 1.6;
  margin-bottom: 14px;
  white-space: pre-line;
  display: -webkit-box;
  -webkit-line-clamp: 6;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.topic-post-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
  border-top: 1px solid #f0f0f0;
  padding-top: 12px;
}

.topic-post {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}

.topic-post a {
  display: flex;
  align-items: center;
  gap: 6px;
  color: #333;
  text-decoration: none;
  flex: 1;
  min-width: 0;
}

.topic-post a:hover {
  color: #ee4c2c;
}

.topic-toggle {
  display: block;
  margin-top: 8px;
  padding: 4px 0;
  border: none;
  background: none;
  color: #ee4c2c;
  font-size: 12px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
}

.topic-toggle:hover {
  text-decoration: underline;
}

.topic-post-date {
  font-size: 12px;
  color: #aaa;
  white-space: nowrap;
  flex-shrink: 0;
}

/* ── Footer ─────────────────────────────────────────────────── */
.site-footer {
  max-width: 1400px;
  margin: 0 auto;
  padding: 20px 20px 32px;
  text-align: center;
  font-size: 12px;
  color: #aaa;
}

.site-footer a {
  color: #888;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.site-footer a:hover {
  color: #ee4c2c;
}

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 600px) {
  .header-top {
    flex-direction: column;
    align-items: flex-start;
  }

  .filter-bar {
    width: 100%;
    flex-direction: column;
    align-items: stretch;
  }

  .filter-bar select {
    width: 100%;
  }

  .filter-bar label {
    justify-content: flex-start;
  }

  #clear-filters {
    width: 100%;
    justify-content: center;
  }

  .card-grid {
    grid-template-columns: 1fr;
  }

  .view-controls {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
}
