/* AI Pulse section — /tech/ai-pulse/ (SHA-59 / PC-17).
   Reuses Clarqo design tokens defined in main.css. Section-local
   tokens are scoped to .ai-pulse so they do not leak elsewhere.
   Mobile-first: stacked cards below 720px, dense table above. */

.ai-pulse {
  --ap-surface:        var(--bg-card, #ffffff);
  --ap-surface-muted:  var(--bg-section, #f0f4f8);
  --ap-border:         var(--border, #e5e7eb);
  --ap-border-strong:  #cbd5e1;
  --ap-text:           var(--text-dark, #0d1117);
  --ap-text-mid:       var(--text-mid, #374151);
  --ap-text-muted:     var(--text-muted, #6b7280);
  --ap-accent:         var(--accent, #c0392b);
  --ap-accent-2:       var(--blue, #2563eb);
  --ap-signal:         #0d9488; /* teal — semantic, AI-generated/live */
  --ap-signal-dim:     #0f766e;
  --ap-good:           #047857;
  --ap-mid:            #b45309;
  --ap-low:            #b91c1c;
  --ap-na:             #94a3b8;
  --ap-shadow:         0 1px 0 rgba(15, 23, 42, 0.04), 0 6px 18px rgba(15, 23, 42, 0.05);

  padding: 32px 0 64px;
  background: var(--bg-page, #f5f5f5);
}

/* ---------- Header band ---------- */
.ai-pulse__header {
  padding: 24px 0 28px;
  border-bottom: 1px solid var(--ap-border);
  margin-bottom: 28px;
}
.ai-pulse__crumbs {
  display: flex;
  gap: 8px;
  align-items: center;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ap-text-muted);
}
.ai-pulse__crumbs a {
  color: var(--ap-accent-2);
}
.ai-pulse__crumbs a:hover { text-decoration: underline; }
.ai-pulse__crumbs-current { color: var(--ap-text-muted); }
.ai-pulse__title {
  margin: 10px 0 8px;
  font-size: clamp(2rem, 3.6vw, 3rem);
  line-height: 1.05;
  letter-spacing: -0.02em;
  color: var(--ap-text);
}
.ai-pulse__deck {
  max-width: 720px;
  font-size: 1.0625rem;
  line-height: 1.55;
  color: var(--ap-text-mid);
  margin: 0 0 14px;
}
.ai-pulse__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  font-size: 13px;
  color: var(--ap-text-muted);
}
.ai-pulse__meta-sep { color: var(--ap-border-strong); }
.ai-pulse__meta-link {
  color: var(--ap-accent-2);
  font-weight: 600;
}
.ai-pulse__meta-link:hover { text-decoration: underline; }

/* ---------- Section headings (reusable inside .ai-pulse) ---------- */
.ai-pulse-section-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px 14px;
  margin: 40px 0 16px;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--ap-text);
}
.ai-pulse-section-head h2 {
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  color: var(--ap-text);
}
.ai-pulse-section-head__sub {
  font-size: 0.85rem;
  color: var(--ap-text-muted);
  margin-left: auto;
}

/* ---------- Winners strip ---------- */
.ai-pulse__winners {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 8px;
}
.ai-pulse-winner {
  background: var(--ap-surface);
  border: 1px solid var(--ap-border);
  border-radius: 8px;
  padding: 18px 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-shadow: var(--ap-shadow);
  position: relative;
  overflow: hidden;
}
.ai-pulse-winner::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  background: var(--ap-signal);
}
.ai-pulse-winner__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.ai-pulse-winner__bucket {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ap-signal-dim);
  background: rgba(13, 148, 136, 0.08);
  padding: 3px 8px;
  border-radius: 999px;
}
.ai-pulse-winner__label {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ap-text-muted);
}
.ai-pulse-winner__model {
  margin: 4px 0 2px;
  font-size: 1.5rem;
  line-height: 1.15;
  letter-spacing: -0.015em;
  color: var(--ap-text);
}
.ai-pulse-winner__provider {
  font-size: 0.85rem;
  color: var(--ap-text-mid);
  margin: 0 0 4px;
}
.ai-pulse-winner__reco {
  font-size: 0.95rem;
  line-height: 1.5;
  color: var(--ap-text-mid);
  margin: 0;
  flex: 1;
}
.ai-pulse-winner__foot {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px dashed var(--ap-border);
  display: flex;
  justify-content: space-between;
  font-size: 0.82rem;
}
.ai-pulse-winner__runner-label {
  color: var(--ap-text-muted);
  text-transform: uppercase;
  font-weight: 600;
  letter-spacing: 0.06em;
}
.ai-pulse-winner__runner { color: var(--ap-text); font-weight: 600; }

/* ---------- Releases strip ---------- */
.ai-pulse-releases__list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0;
  border-top: 1px solid var(--ap-border);
}
.ai-pulse-release {
  display: grid;
  grid-template-columns: 64px 110px 1fr;
  gap: 14px;
  align-items: start;
  padding: 14px 4px;
  border-bottom: 1px solid var(--ap-border);
}
.ai-pulse-release__date {
  font-family: 'JetBrains Mono', ui-monospace, 'SFMono-Regular', monospace;
  font-size: 0.82rem;
  color: var(--ap-text-mid);
  font-weight: 600;
  padding-top: 2px;
}
.ai-pulse-release__kind {
  display: inline-block;
  align-self: start;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 4px;
  white-space: nowrap;
  background: var(--ap-surface-muted);
  color: var(--ap-text-mid);
  border: 1px solid var(--ap-border);
}
.ai-pulse-release__kind--new_model {
  background: rgba(13, 148, 136, 0.1);
  color: var(--ap-signal-dim);
  border-color: rgba(13, 148, 136, 0.3);
}
.ai-pulse-release__kind--version_bump {
  background: rgba(37, 99, 235, 0.08);
  color: #1d4ed8;
  border-color: rgba(37, 99, 235, 0.25);
}
.ai-pulse-release__kind--capability_update {
  background: rgba(245, 158, 11, 0.1);
  color: #b45309;
  border-color: rgba(245, 158, 11, 0.3);
}
.ai-pulse-release__title {
  margin: 0 0 2px;
  font-size: 1rem;
  line-height: 1.35;
  font-weight: 700;
  color: var(--ap-text);
}
.ai-pulse-release__title a:hover { color: var(--ap-accent-2); }
.ai-pulse-release__summary {
  margin: 0;
  font-size: 0.92rem;
  line-height: 1.5;
  color: var(--ap-text-mid);
}
.ai-pulse-release__attrib {
  margin: 4px 0 0;
  font-size: 0.78rem;
  color: var(--ap-text-muted);
}

/* ---------- Matrix controls ---------- */
.ai-pulse-matrix__controls {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: end;
  padding: 12px;
  background: var(--ap-surface-muted);
  border: 1px solid var(--ap-border);
  border-radius: 8px;
  margin-bottom: 12px;
}
.ai-pulse-matrix__control {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 160px;
  flex: 0 1 auto;
}
.ai-pulse-matrix__control--search { flex: 1 1 220px; }
.ai-pulse-matrix__control label {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ap-text-muted);
}
.ai-pulse-matrix__control select,
.ai-pulse-matrix__control input {
  width: 100%;
  font: inherit;
  font-size: 0.92rem;
  padding: 8px 10px;
  border: 1px solid var(--ap-border-strong);
  border-radius: 6px;
  background: var(--ap-surface);
  color: var(--ap-text);
  min-height: 38px;
}
.ai-pulse-matrix__control select:focus,
.ai-pulse-matrix__control input:focus {
  outline: 2px solid var(--ap-accent-2);
  outline-offset: 1px;
  border-color: var(--ap-accent-2);
}
.ai-pulse-matrix__reset {
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 8px 14px;
  min-height: 38px;
  background: transparent;
  border: 1px solid var(--ap-border-strong);
  color: var(--ap-text-mid);
  border-radius: 6px;
  cursor: pointer;
  align-self: end;
}
.ai-pulse-matrix__reset:hover {
  background: var(--ap-surface);
  color: var(--ap-text);
}
.ai-pulse-matrix__reset:focus-visible {
  outline: 2px solid var(--ap-accent-2);
  outline-offset: 1px;
}

/* ---------- Matrix table ---------- */
.ai-pulse-matrix__table-wrap {
  background: var(--ap-surface);
  border: 1px solid var(--ap-border);
  border-radius: 8px;
  overflow-x: auto;
  box-shadow: var(--ap-shadow);
}
.ai-pulse-matrix__table-wrap:focus { outline: 2px solid var(--ap-accent-2); outline-offset: 2px; }
.ai-pulse-matrix__table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
  min-width: 760px;
}
.ai-pulse-matrix__table thead th {
  position: sticky;
  top: 0;
  background: var(--ap-surface);
  text-align: left;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ap-text-muted);
  padding: 12px 14px;
  border-bottom: 2px solid var(--ap-border-strong);
  z-index: 1;
}
.ai-pulse-matrix__table tbody td,
.ai-pulse-matrix__table tbody th {
  padding: 14px;
  border-bottom: 1px solid var(--ap-border);
  vertical-align: top;
  text-align: left;
  background: var(--ap-surface);
}
.ai-pulse-matrix__table tbody tr:last-child td,
.ai-pulse-matrix__table tbody tr:last-child th { border-bottom: none; }
.ai-pulse-row__model {
  font-weight: 700;
  font-size: 1rem;
  color: var(--ap-text);
  width: 220px;
}
.ai-pulse-row__model a { color: inherit; }
.ai-pulse-row__model a:hover { color: var(--ap-accent-2); text-decoration: underline; }
.ai-pulse-row__note {
  display: block;
  font-weight: 400;
  font-size: 0.8rem;
  color: var(--ap-text-muted);
  margin-top: 2px;
  line-height: 1.4;
}
.ai-pulse-row__provider {
  color: var(--ap-text-mid);
  font-size: 0.88rem;
  white-space: nowrap;
}
.ai-pulse-row__provider a { color: inherit; }
.ai-pulse-row__provider a:hover { color: var(--ap-accent-2); }
.ai-pulse-row__released {
  white-space: nowrap;
  color: var(--ap-text-muted);
  font-size: 0.85rem;
}

/* Score cell */
.ai-pulse-row__score {
  min-width: 180px;
}
.ai-pulse-score {
  display: inline-flex;
  flex-direction: column;
  gap: 4px;
  align-items: flex-start;
  width: 100%;
}
.ai-pulse-score__num {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--ap-text);
}
.ai-pulse-score[data-score="0"] .ai-pulse-score__num,
.ai-pulse-score[data-score]:not([data-score=""]) .ai-pulse-score__num {
  color: var(--ap-text);
}
.ai-pulse-score__bar {
  display: block;
  width: 100%;
  max-width: 120px;
  height: 4px;
  background: var(--ap-surface-muted);
  border-radius: 2px;
  overflow: hidden;
}
.ai-pulse-score__bar-fill {
  display: block;
  height: 100%;
  background: var(--ap-signal);
  border-radius: 2px;
}
/* Tier colouring on the fill */
.ai-pulse-score[data-score]:not([data-score=""]) .ai-pulse-score__bar-fill { background: var(--ap-signal); }
.ai-pulse-score--na {
  color: var(--ap-na);
  font-weight: 600;
}
.ai-pulse-row__rationale {
  display: block;
  margin-top: 6px;
  font-size: 0.82rem;
  line-height: 1.45;
  color: var(--ap-text-mid);
}
.ai-pulse-row__evidence {
  color: var(--ap-accent-2);
  font-weight: 700;
  margin-left: 4px;
}
.ai-pulse-row__evidence:hover { text-decoration: underline; }
.ai-pulse-matrix__empty {
  padding: 24px;
  text-align: center;
  color: var(--ap-text-muted);
  font-size: 0.95rem;
}
.ai-pulse-link-btn {
  background: none;
  border: none;
  color: var(--ap-accent-2);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  padding: 0;
  margin-left: 4px;
  text-decoration: underline;
}

/* Hidden rows after filtering */
.ai-pulse-row[hidden] { display: none; }

/* ---------- Coding agents ---------- */
.ai-pulse-agents__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}
.ai-pulse-agent {
  display: grid;
  grid-template-columns: 36px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 14px 16px;
  background: var(--ap-surface);
  border: 1px solid var(--ap-border);
  border-radius: 8px;
}
.ai-pulse-agent__rank {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-weight: 700;
  font-size: 1rem;
  color: var(--ap-text-muted);
  text-align: center;
}
.ai-pulse-agent__name {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--ap-text);
}
.ai-pulse-agent__name a { color: inherit; }
.ai-pulse-agent__name a:hover { color: var(--ap-accent-2); }
.ai-pulse-agent__meta {
  margin: 2px 0 0;
  font-size: 0.78rem;
  color: var(--ap-text-muted);
}
.ai-pulse-agent__note {
  margin: 4px 0 0;
  font-size: 0.88rem;
  color: var(--ap-text-mid);
  line-height: 1.45;
}
.ai-pulse-agent__score {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  padding: 6px 10px;
  background: var(--ap-surface-muted);
  border-radius: 6px;
  min-width: 64px;
}
.ai-pulse-agent__score-num {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--ap-text);
}
.ai-pulse-agent__score-label {
  font-size: 0.62rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ap-text-muted);
}

/* ---------- Methodology ---------- */
.ai-pulse-methodology {
  margin: 40px 0 0;
  padding: 24px;
  background: var(--ap-surface);
  border: 1px solid var(--ap-border);
  border-radius: 8px;
}
.ai-pulse-methodology h2 {
  margin: 0 0 8px;
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--ap-text);
}
.ai-pulse-methodology p {
  margin: 0 0 10px;
  color: var(--ap-text-mid);
  font-size: 0.95rem;
  line-height: 1.55;
}
.ai-pulse-methodology__points {
  margin: 8px 0 0;
  padding-left: 18px;
  color: var(--ap-text-mid);
  font-size: 0.92rem;
  line-height: 1.55;
}
.ai-pulse-methodology__points li { margin-bottom: 4px; }
.ai-pulse-methodology__cta {
  margin-top: 14px;
  font-weight: 600;
}
.ai-pulse-methodology__cta a { color: var(--ap-accent-2); }
.ai-pulse-methodology__cta a:hover { text-decoration: underline; }

/* Promo strip styles live in main.css so they render on tech category pages
   without forcing ai-pulse.css to load there. See `.ai-pulse-promo` in main.css. */

/* ---------- Responsive ---------- */
@media (max-width: 960px) {
  .ai-pulse__winners { grid-template-columns: 1fr 1fr; }
  .ai-pulse-agents__list { grid-template-columns: 1fr; }
  .ai-pulse-section-head { flex-direction: column; align-items: flex-start; }
  .ai-pulse-section-head__sub { margin-left: 0; }
}
@media (max-width: 640px) {
  .ai-pulse { padding: 20px 0 48px; }
  .ai-pulse__winners { grid-template-columns: 1fr; }
  .ai-pulse-release {
    grid-template-columns: 72px 1fr;
    gap: 6px 12px;
  }
  .ai-pulse-release__kind { grid-column: 2; }
  .ai-pulse-release__body { grid-column: 2; }
  .ai-pulse-release__date { grid-column: 1; grid-row: 1 / span 2; }
  .ai-pulse-matrix__controls { gap: 8px; }
  .ai-pulse-matrix__control { min-width: 0; flex: 1 1 140px; }
  .ai-pulse-matrix__reset { width: 100%; flex: 1 1 100%; }
}

/* ---------- Dark theme ---------- */
[data-theme="dark"] .ai-pulse {
  --ap-surface: rgba(255, 255, 255, 0.03);
  --ap-surface-muted: rgba(255, 255, 255, 0.05);
  --ap-border: rgba(255, 255, 255, 0.1);
  --ap-border-strong: rgba(255, 255, 255, 0.2);
  --ap-text: #f3f4f6;
  --ap-text-mid: #d1d5db;
  --ap-text-muted: #9ca3af;
  --ap-shadow: 0 1px 0 rgba(0, 0, 0, 0.3), 0 6px 18px rgba(0, 0, 0, 0.25);
  background: transparent;
}
[data-theme="dark"] .ai-pulse__title { color: var(--ap-text); }
[data-theme="dark"] .ai-pulse__deck { color: var(--ap-text-mid); }
[data-theme="dark"] .ai-pulse-winner__bucket {
  color: #5eead4;
  background: rgba(94, 234, 212, 0.1);
}
[data-theme="dark"] .ai-pulse-section-head {
  border-bottom-color: var(--ap-text);
}
[data-theme="dark"] .ai-pulse-release__kind--new_model {
  background: rgba(94, 234, 212, 0.12);
  color: #5eead4;
  border-color: rgba(94, 234, 212, 0.3);
}
[data-theme="dark"] .ai-pulse-release__kind--version_bump {
  background: rgba(96, 165, 250, 0.1);
  color: #93c5fd;
  border-color: rgba(96, 165, 250, 0.3);
}
[data-theme="dark"] .ai-pulse-release__kind--capability_update {
  background: rgba(252, 211, 77, 0.1);
  color: #fcd34d;
  border-color: rgba(252, 211, 77, 0.3);
}
[data-theme="dark"] .ai-pulse-matrix__table thead th {
  background: rgba(15, 23, 42, 0.6);
}
[data-theme="dark"] .ai-pulse-row__rationale,
[data-theme="dark"] .ai-pulse-release__summary,
[data-theme="dark"] .ai-pulse-agent__note,
[data-theme="dark"] .ai-pulse-methodology p,
[data-theme="dark"] .ai-pulse-methodology__points { color: var(--ap-text-mid); }
[data-theme="dark"] .ai-pulse-matrix__table tbody td,
[data-theme="dark"] .ai-pulse-matrix__table tbody th {
  background: rgba(255, 255, 255, 0.02);
}

@media (prefers-reduced-motion: reduce) {
  .ai-pulse-score__bar-fill { transition: none; }
}
