/* AI PULSE — Editorial Design v4 */
/* Category nav + Mobile excellence */

:root {
  --white: #FFFFFF;
  --off-white: #F7F7F5;
  --border: #E8E8E4;
  --text-primary: #1A1A1A;
  --text-secondary: #3D3D3D;
  --text-muted: #888888;
  --text-label: #AAAAAA;
  --cat-models: #5B21B6;
  --cat-tools: #1D4ED8;
  --cat-agents: #0F766E;
  --cat-research: #92400E;
  --cat-companies: #991B1B;
  --cat-opensource: #166534;
  --font-serif: Georgia, 'Times New Roman', serif;
  --font-sans: -apple-system, 'Helvetica Neue', Arial, sans-serif;
  --font-mono: 'SF Mono', 'Fira Code', monospace;
}

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: var(--font-sans);
  color: var(--text-primary);
  background: var(--white);
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
}

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

/* Touch performance */
a, button, input, [role="button"] {
  touch-action: manipulation;
}

/* TOP BAR */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 44px;
  padding: 0 32px;
  background: var(--white);
  border-bottom: 2px solid var(--text-primary);
}

.topbar-logo {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-family: var(--font-sans);
}

.topbar-nav {
  display: flex;
  gap: 24px;
  list-style: none;
}

.topbar-nav a {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-primary);
}

@media (hover: hover) {
  .topbar-nav a:hover { text-decoration: underline; }
}

/* CATEGORY PILL BAR — always visible */
.category-pills {
  position: sticky;
  top: 44px;
  z-index: 90;
  display: flex;
  align-items: center;
  gap: 8px;
  height: 44px;
  padding: 0 32px;
  background: var(--white);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.category-pills::-webkit-scrollbar { display: none; }

.category-pills button {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 400;
  color: var(--text-muted);
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 20px;
  cursor: pointer;
  padding: 0 14px;
  height: 32px;
  white-space: nowrap;
  flex-shrink: 0;
  font-family: var(--font-sans);
  transition: all 150ms;
}

.category-pills button .cat-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* Active states per category */
.category-pills button.active {
  font-weight: 600;
  border-color: transparent;
  /* Ensure same size as inactive — no layout shift */
  padding: 0 14px;
  height: 32px;
}

.category-pills button[data-cat="all"].active {
  background: var(--text-primary);
  color: var(--white);
  border-color: transparent;
}

.category-pills button[data-cat="models"].active {
  background: rgba(91, 33, 182, 0.1);
  color: var(--cat-models);
}
.category-pills button[data-cat="tools"].active {
  background: rgba(29, 78, 216, 0.1);
  color: var(--cat-tools);
}
.category-pills button[data-cat="agents"].active {
  background: rgba(15, 118, 110, 0.1);
  color: var(--cat-agents);
}
.category-pills button[data-cat="research"].active {
  background: rgba(146, 64, 14, 0.1);
  color: var(--cat-research);
}
.category-pills button[data-cat="companies"].active {
  background: rgba(153, 27, 27, 0.1);
  color: var(--cat-companies);
}
.category-pills button[data-cat="open source"].active {
  background: rgba(22, 101, 52, 0.1);
  color: var(--cat-opensource);
}

@media (hover: hover) {
  .category-pills button:not(.active):hover {
    color: var(--text-primary);
    border-color: var(--text-muted);
  }
}

/* DATELINE */
.dateline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 32px;
  padding: 0 32px;
  background: var(--off-white);
  border-bottom: 1px solid var(--border);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  font-family: var(--font-sans);
  white-space: nowrap;
  overflow: hidden;
}

@media (max-width: 600px) {
  .dateline {
    padding: 0 16px;
    font-size: 10px;
    letter-spacing: 0.03em;
  }
  #dateline-text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: calc(100% - 70px);
  }
}

/* LEAD STORY */
.lead-story {
  padding: 48px 32px;
  border-bottom: 1px solid var(--border);
}

.category-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 600;
  margin-bottom: 16px;
  font-family: var(--font-sans);
}

.lead-story .lead-headline {
  font-family: var(--font-serif);
  font-size: 44px;
  font-weight: bold;
  line-height: 1.15;
  letter-spacing: -0.01em;
  color: var(--text-primary);
  margin-bottom: 16px;
}

.lead-story .lead-summary {
  font-size: 17px;
  color: var(--text-secondary);
  line-height: 1.65;
  max-width: 720px;
}

.lead-story .lead-meta {
  font-size: 12px;
  font-family: var(--font-mono);
  color: var(--text-muted);
  margin-top: 20px;
}

/* SECONDARY STORIES */
.secondary-stories {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-bottom: 1px solid var(--border);
}

.secondary-card {
  padding: 32px;
}

.secondary-card:first-child {
  border-right: 1px solid var(--border);
}

.secondary-card .card-headline {
  font-family: var(--font-serif);
  font-size: 26px;
  font-weight: bold;
  line-height: 1.2;
  color: var(--text-primary);
  margin-bottom: 12px;
}

.secondary-card .card-summary {
  font-size: 15px;
  color: var(--text-secondary);
  line-height: 1.6;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  cursor: pointer;
  transition: all 0.2s ease;
}
.secondary-card .card-summary.expanded {
  display: block;
  -webkit-line-clamp: unset;
}

.secondary-card .card-meta {
  font-size: 12px;
  font-family: var(--font-mono);
  color: var(--text-muted);
  margin-top: 16px;
}

/* SECTION BREAK */
.section-break {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 24px 32px;
}

.section-break::before,
.section-break::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.section-break span {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--text-label);
  font-family: var(--font-mono);
  white-space: nowrap;
}

/* CATEGORY HEADER in feed */
.category-feed-header {
  padding: 16px 0 8px 0;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-family: var(--font-mono);
  border-bottom: 1px solid currentColor;
  margin-bottom: 0;
}

/* Hide old filter bar — replaced by pills */
.filter-bar { display: none; }

/* MAIN CONTENT */
.main-content {
  display: grid;
  grid-template-columns: 7fr 3fr;
  gap: 0;
  padding: 0 32px;
}

/* STORY FEED */
.story-feed {
  padding-right: 32px;
  border-right: 1px solid var(--border);
}

.story-card {
  padding: 24px 0;
  border-bottom: 1px solid var(--border);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 400ms ease-out, transform 400ms ease-out;
}

.story-card.visible {
  opacity: 1;
  transform: translateY(0);
}

.story-card .card-headline {
  font-family: var(--font-serif);
  font-size: 19px;
  font-weight: bold;
  color: var(--text-primary);
  line-height: 1.3;
  margin-bottom: 8px;
  cursor: pointer;
}

.story-card .card-headline:active {
  opacity: 0.7;
}

@media (hover: hover) {
  .story-card .card-headline:hover { color: var(--cat-companies); }
  .story-card[data-category="Models"] .card-headline:hover { color: var(--cat-models); }
  .story-card[data-category="Tools"] .card-headline:hover { color: var(--cat-tools); }
  .story-card[data-category="Agents"] .card-headline:hover { color: var(--cat-agents); }
  .story-card[data-category="Research"] .card-headline:hover { color: var(--cat-research); }
  .story-card[data-category="Companies"] .card-headline:hover { color: var(--cat-companies); }
  .story-card[data-category="Open Source"] .card-headline:hover { color: var(--cat-opensource); }
}

.story-card .card-summary {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.6;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  cursor: pointer;
  transition: all 0.2s ease;
}
.story-card .card-summary.expanded {
  display: block;
  -webkit-line-clamp: unset;
}

.story-card .card-meta {
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--text-label);
  margin-top: 10px;
}

.take-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); margin-right: 3px; }
.expand-toggle {
  display: inline-block;
  margin-top: 6px;
  background: none;
  border: none;
  padding: 0;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  letter-spacing: 0.03em;
  transition: color 0.15s ease;
}
.expand-toggle:hover { color: var(--text-primary); }
.signal-badge { display: inline-flex; align-items: center; gap: 5px; }
.signal-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); }
.signal-dots { letter-spacing: 3px; font-size: 13px; }
.signal-dots .filled { color: #f59e0b; }
.signal-dots .empty { color: #3a3a3a; }

/* SIDEBAR */
.sidebar {
  padding-left: 32px;
  position: sticky;
  top: 88px;
  align-self: start;
}

.sidebar-section {
  padding: 24px 0;
  border-bottom: 1px solid var(--border);
}

.sidebar-section:last-child { border-bottom: none; }

.sidebar-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-label);
  font-family: var(--font-mono);
  margin-bottom: 12px;
}

.sidebar-theme {
  font-family: var(--font-serif);
  font-size: 17px;
  font-weight: bold;
  line-height: 1.3;
  margin-bottom: 8px;
}

.sidebar-theme-desc {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
}

.signal-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.signal-row .signal-name { color: var(--text-secondary); }
.signal-row .signal-value { font-weight: 600; }

/* Category bars — interactive */
.cat-bar-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  font-size: 13px;
  cursor: pointer;
  border-radius: 4px;
  padding: 4px 0;
  transition: background 150ms;
}

@media (hover: hover) {
  .cat-bar-row:hover { background: var(--off-white); }
}

.cat-bar-name {
  width: 80px;
  color: var(--text-secondary);
  flex-shrink: 0;
}

.cat-bar-track {
  width: 100px;
  height: 3px;
  background: #EEE;
  flex-shrink: 0;
}

.cat-bar-fill {
  height: 100%;
}

.cat-bar-count {
  color: var(--text-primary);
  font-weight: 600;
  font-size: 12px;
}

/* Subscribe */
.subscribe-form {
  display: flex;
  gap: 0;
}

.subscribe-form input {
  flex: 1;
  border: 1px solid var(--border);
  border-right: none;
  padding: 10px;
  font-size: 13px;
  font-family: var(--font-sans);
  border-radius: 0;
  outline: none;
}

.subscribe-form input:focus { border-color: var(--text-muted); }

.subscribe-form button {
  background: var(--text-primary);
  color: var(--white);
  border: none;
  padding: 10px 16px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  cursor: pointer;
  border-radius: 0;
  font-family: var(--font-sans);
}

/* FOOTER */
.site-footer {
  background: var(--text-primary);
  color: var(--white);
  text-align: center;
  padding: 32px;
  font-size: 13px;
  font-family: var(--font-sans);
}

/* ===================== MOBILE ===================== */
@media (max-width: 768px) {
  .topbar-nav { display: none; }
  .topbar { padding: 0 16px; }
  .dateline { padding: 0 16px; font-size: 11px; }

  /* Category pills — touch scrollable */
  .category-pills {
    top: 44px;
    height: 44px;
    padding: 0 16px;
    gap: 6px;
    scroll-snap-type: x mandatory;
  }

  .category-pills button {
    height: 36px;
    padding: 0 12px;
    font-size: 13px;
    flex-shrink: 0;
    scroll-snap-align: start;
    min-height: 44px; /* touch target */
  }

  /* Lead story */
  .lead-story {
    padding: 24px 20px;
  }

  .lead-story .lead-headline {
    font-size: clamp(28px, 6vw, 44px);
  }

  .lead-story .lead-summary {
    font-size: 15px;
  }

  /* Secondary — stack vertically */
  .secondary-stories {
    grid-template-columns: 1fr;
  }

  .secondary-card {
    padding: 20px;
  }

  .secondary-card:first-child {
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .section-break { padding: 20px 16px; }

  /* Main content — full width */
  .main-content {
    grid-template-columns: 1fr;
    padding: 0;
  }

  .story-feed {
    padding-right: 0;
    border-right: none;
  }

  .story-card {
    padding: 20px 16px;
  }

  .story-card .card-headline {
    font-size: 17px;
    font-family: var(--font-serif);
  }

  .story-card .card-summary {
    font-size: 13px;
  }

  .story-card .card-meta {
    font-size: 11px;
  }

  .category-feed-header {
    padding: 16px 16px 8px 16px;
  }

  /* Sidebar — below feed, not sticky */
  .sidebar {
    padding-left: 0;
    position: static;
    border-top: 1px solid var(--border);
    margin-top: 0;
    padding: 0 16px;
  }

  .sidebar-section {
    padding: 20px 0;
  }

  /* Subscribe — stacked */
  .subscribe-form {
    flex-direction: column;
  }

  .subscribe-form input {
    border-right: 1px solid var(--border);
    border-bottom: none;
    font-size: 15px;
    padding: 12px;
  }

  .subscribe-form button {
    padding: 14px;
    font-size: 13px;
  }

  /* Font minimums */
  body { font-size: 15px; }
  .sidebar-theme-desc { font-size: 15px; }
  .signal-row { font-size: 15px; }
  .cat-bar-row { font-size: 13px; }

  .site-footer { font-size: 13px; }
}

/* Error state */
.error-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin: 2rem 0;
}
.error-state button {
  margin-top: 0.5rem;
  padding: 0.4rem 1.2rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--white);
  cursor: pointer;
  font-family: var(--font-sans);
}
