/* ==========================================================================
   MacroSpyder Research Hub & Article Reader Stylesheet
   Dedicated styling for /analysis (Hub) and /analysis/{slug} (Reader)
   ========================================================================== */

/* Scoped Design Tokens for Research Hub & Reader */
:root {
  --reader-max-w: 820px;
  --hub-max-w: 1240px;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Hanken Grotesk', system-ui, -apple-system, sans-serif;
  line-height: 1.6;
  margin: 0;
  padding: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Reading Progress Bar */
#reading-progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  width: 0%;
  background: linear-gradient(90deg, #10b981, #3b82f6);
  z-index: 99999;
  transition: width 0.1s ease-out;
}

/* Container Shells */
.research-shell {
  width: 100%;
  max-width: var(--hub-max-w);
  margin: 0 auto;
  padding: 32px 20px 80px 20px;
  box-sizing: border-box;
  flex: 1;
}
.reader-shell {
  width: 100%;
  max-width: var(--reader-max-w);
  margin: 0 auto;
  padding: 24px 20px 80px 20px;
  box-sizing: border-box;
  flex: 1;
}

/* Breadcrumbs */
.ms-breadcrumbs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-3);
  margin-bottom: 24px;
}
.ms-breadcrumbs a {
  color: var(--text-2);
  text-decoration: none;
  transition: color 0.15s ease;
}
.ms-breadcrumbs a:hover {
  color: var(--accent);
}
.ms-breadcrumbs .sep {
  opacity: 0.5;
}
.ms-breadcrumbs .current {
  color: var(--text);
  font-weight: 600;
  max-width: 320px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Article Reader Header */
.article-header {
  margin-bottom: 28px;
}
.article-badges-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
}
.badge-category {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 3px 10px;
  border-radius: 999px;
  background: rgba(16, 185, 129, 0.12);
  color: #10b981;
  border: 1px solid rgba(16, 185, 129, 0.3);
}
.badge-paid {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 3px 10px;
  border-radius: 999px;
  background: rgba(245, 158, 11, 0.15);
  color: #f59e0b;
  border: 1px solid rgba(245, 158, 11, 0.35);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.article-h1 {
  font-size: clamp(24px, 4vw, 36px);
  font-weight: 800;
  line-height: 1.3;
  margin: 0 0 16px 0;
  color: var(--text);
  letter-spacing: -0.02em;
}
.article-meta-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  color: var(--text-2);
}
.article-author-info {
  display: flex;
  align-items: center;
  gap: 10px;
}
.author-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, #0a9d62, #4f8ef7);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: #ffffff;
  font-size: 14px;
  flex-shrink: 0;
}
.author-name {
  font-weight: 600;
  color: var(--text);
}
.meta-sub {
  font-size: 12px;
  color: var(--text-3);
}

/* Action Buttons Bar */
.article-actions-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.btn-action-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 12px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  background: var(--surface-2);
  color: var(--text-2);
  border: 1px solid var(--border);
  cursor: pointer;
  text-decoration: none;
  transition: all 0.15s ease;
}
.btn-action-pill:hover {
  background: var(--hover);
  color: var(--text);
  border-color: var(--border-strong);
}
.btn-action-pill.accent {
  background: rgba(16, 185, 129, 0.12);
  color: #10b981;
  border-color: rgba(16, 185, 129, 0.3);
}
.btn-action-pill.accent:hover {
  background: rgba(16, 185, 129, 0.2);
}

/* Cover Banner */
.article-cover-wrap {
  margin: 24px 0 32px 0;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid var(--border);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.25);
}
.article-cover-img {
  width: 100%;
  height: auto;
  max-height: 440px;
  object-fit: cover;
  display: block;
}
.article-cover-gradient {
  width: 100%;
  min-height: 220px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

/* Key Summary Callout */
.article-summary-box {
  background: var(--surface-2);
  border-left: 4px solid #10b981;
  border-radius: 0 12px 12px 0;
  padding: 20px 24px;
  margin-bottom: 32px;
  font-size: 16px;
  line-height: 1.65;
  color: var(--text);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.05);
}
.summary-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #10b981;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Rich Content Styles */
.article-body-content {
  font-size: 16px;
  line-height: 1.8;
  color: var(--text);
  word-wrap: break-word;
}
.article-body-content p {
  margin-bottom: 22px;
}
.article-body-content h2 {
  font-size: 22px;
  font-weight: 700;
  margin: 40px 0 16px 0;
  color: var(--text);
  line-height: 1.35;
}
.article-body-content h3 {
  font-size: 18px;
  font-weight: 600;
  margin: 32px 0 14px 0;
  color: var(--text);
  line-height: 1.4;
}
.article-body-content ul, .article-body-content ol {
  margin: 0 0 24px 24px;
  padding: 0;
}
.article-body-content li {
  margin-bottom: 8px;
}
.article-body-content blockquote {
  border-left: 3px solid var(--accent);
  padding: 12px 20px;
  margin: 24px 0;
  background: var(--surface-2);
  border-radius: 0 8px 8px 0;
  font-style: italic;
  color: var(--text-2);
}
.article-body-content img {
  max-width: 100%;
  height: auto;
  border-radius: 10px;
  margin: 24px auto;
  display: block;
  border: 1px solid var(--border);
}
.article-body-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 28px 0;
  font-size: 14px;
}
.article-body-content th, .article-body-content td {
  padding: 10px 14px;
  border: 1px solid var(--border);
  text-align: left;
}
.article-body-content th {
  background: var(--surface-2);
  font-weight: 600;
}

/* Embedded Interactive Chart Cards */
.embedded-chart-card {
  margin: 28px 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 18px;
  box-sizing: border-box;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.embedded-chart-card:hover {
  border-color: var(--border-strong, rgba(255, 255, 255, 0.16));
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.12);
}
.embedded-chart-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-bottom: 12px;
  margin-bottom: 12px;
  border-bottom: 1px dashed var(--border);
}
.embedded-chart-title-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14.5px;
  font-weight: 700;
  color: var(--text);
}
.embedded-chart-svg-icon {
  color: #38bdf8;
  flex-shrink: 0;
}
.embedded-chart-meta-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.embedded-chart-sid-tag {
  font-family: var(--font-mono, monospace);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--text-3);
  background: var(--surface-2);
  padding: 3px 8px;
  border-radius: 4px;
  border: 1px solid var(--border);
  text-transform: uppercase;
}
.embedded-chart-btn-terminal {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  font-weight: 600;
  color: #10b981;
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.3);
  border-radius: 6px;
  padding: 4px 10px;
  text-decoration: none;
  transition: all 0.15s ease;
  cursor: pointer;
}
.embedded-chart-btn-terminal:hover {
  background: #10b981;
  color: #ffffff;
  border-color: #10b981;
}
.embedded-chart-canvas-box {
  width: 100%;
  height: 290px;
  position: relative;
}
.embedded-chart-loading,
.embedded-chart-empty {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--text-3);
  font-size: 12.5px;
}
.embedded-chart-spinner {
  width: 24px;
  height: 24px;
  border: 2px solid var(--border);
  border-top-color: #38bdf8;
  border-radius: 50%;
  animation: ms-spin 0.8s linear infinite;
}
@keyframes ms-spin {
  to { transform: rotate(360deg); }
}
.embedded-chart-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-top: 10px;
  margin-top: 6px;
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--text-3);
}
.embedded-chart-foot-range {
  font-family: var(--font-mono, monospace);
}

/* Paywall Lock Box */
.article-paywall-gate {
  position: relative;
  margin-top: -60px;
  padding-top: 100px;
  background: linear-gradient(to bottom, transparent, var(--bg) 40%, var(--bg) 100%);
  text-align: center;
  z-index: 10;
}
.paywall-card {
  background: var(--surface);
  border: 1px solid rgba(245, 158, 11, 0.35);
  border-radius: 16px;
  padding: 36px 28px;
  max-width: 580px;
  margin: 0 auto;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.4);
}
.paywall-icon {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: rgba(245, 158, 11, 0.15);
  color: #f59e0b;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px auto;
}
.paywall-title {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 10px;
  color: var(--text);
}
.paywall-desc {
  font-size: 14px;
  color: var(--text-2);
  line-height: 1.6;
  margin-bottom: 24px;
}
.paywall-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
}
.btn-upgrade-main {
  background: #10b981;
  color: #000000;
  font-weight: 700;
  font-size: 14px;
  padding: 11px 24px;
  border-radius: 8px;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: filter 0.15s ease;
}
.btn-upgrade-main:hover {
  filter: brightness(1.1);
}
.btn-login-secondary {
  background: var(--surface-2);
  color: var(--text);
  font-weight: 600;
  font-size: 14px;
  padding: 11px 20px;
  border-radius: 8px;
  text-decoration: none;
  border: 1px solid var(--border);
}

/* Tags Bar */
.article-tags-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 36px 0 28px 0;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}
.article-tag-item {
  font-size: 12px;
  color: var(--text-2);
  background: var(--surface-2);
  padding: 4px 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  text-decoration: none;
  transition: all 0.15s ease;
}
.article-tag-item:hover {
  color: var(--accent);
  border-color: var(--accent);
}

/* QR Code & Share Card */
.article-qr-card {
  margin: 36px 0;
  padding: 22px 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  align-items: center;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}
.qr-img-box {
  background: #ffffff;
  padding: 6px;
  border-radius: 10px;
  width: 106px;
  height: 106px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}
.qr-img-box img {
  width: 94px;
  height: 94px;
  object-fit: contain;
  display: block;
}
.qr-info-content {
  flex: 1;
  min-width: 240px;
}
.qr-badge-title {
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: #10b981;
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
}
.qr-desc {
  font-size: 13px;
  color: var(--text-2);
  line-height: 1.5;
  margin: 0 0 14px 0;
}

/* Related Articles Section */
.related-section {
  margin-top: 56px;
  padding-top: 36px;
  border-top: 1px solid var(--border);
}
.related-title {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 20px;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ─────────────────────────────────────────────────────────────────────────
   RESEARCH HUB (LISTING VIEW) STYLES
   ───────────────────────────────────────────────────────────────────────── */
.hub-hero {
  text-align: center;
  max-width: 760px;
  margin: 0 auto 36px auto;
}
.hub-eyebrow {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #10b981;
  margin-bottom: 12px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.hub-h1 {
  font-size: clamp(26px, 4vw, 40px);
  font-weight: 800;
  letter-spacing: -0.025em;
  line-height: 1.25;
  margin: 0 0 14px 0;
  color: var(--text);
}
.hub-sub {
  font-size: 16px;
  color: var(--text-2);
  line-height: 1.6;
  margin: 0 0 24px 0;
}

/* Hub Search & Filter Bar */
.hub-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 32px;
  padding: 14px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
}
.hub-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  overflow-x: auto;
}
.hub-chip-btn {
  padding: 6px 14px;
  border-radius: 8px;
  font-size: 12.5px;
  font-weight: 600;
  background: var(--surface-2);
  color: var(--text-2);
  border: 1px solid var(--border);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
}
.hub-chip-btn:hover {
  color: var(--text);
  background: var(--hover);
}
.hub-chip-btn.active {
  background: #10b981;
  color: #000000;
  border-color: #10b981;
}
.hub-search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 12px;
  width: 100%;
  max-width: 260px;
}
.hub-search-input {
  background: transparent;
  border: none;
  outline: none;
  font-size: 13px;
  color: var(--text);
  width: 100%;
}
.hub-search-input::placeholder {
  color: var(--text-3);
}

/* Article Cards Grid */
.article-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(330px, 1fr));
  gap: 24px;
  margin-bottom: 56px;
}
.art-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  text-decoration: none;
  color: inherit;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
  position: relative;
}
.art-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.2);
  border-color: var(--accent);
}
.art-card-thumb {
  height: 180px;
  width: 100%;
  position: relative;
  overflow: hidden;
  background: var(--surface-2);
}
.art-card-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.3s ease;
}
.art-card:hover .art-card-img {
  transform: scale(1.04);
}
.art-card-content {
  padding: 20px;
  flex: 1;
  display: flex;
  flex-direction: column;
}
.art-card-tag-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.art-card-h3 {
  font-size: 17px;
  font-weight: 700;
  line-height: 1.4;
  margin: 0 0 10px 0;
  color: var(--text);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.art-card-summary {
  font-size: 13.5px;
  color: var(--text-2);
  line-height: 1.55;
  margin: 0 0 18px 0;
  flex: 1;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.art-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-3);
}

/* Pillars Quick Jump Banner */
.hub-pillars-banner {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 28px 24px;
  margin-top: 40px;
}
.pillars-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-top: 18px;
}
.pillar-card-link {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  text-decoration: none;
  color: inherit;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  transition: all 0.15s ease;
}
.pillar-card-link:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}
.pillar-card-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* Toast Notification */
#ms-toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  padding: 10px 18px;
  background: #10b981;
  color: #000000;
  font-size: 13px;
  font-weight: 600;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
  z-index: 999999;
  opacity: 0;
  transform: translateY(10px);
  transition: all 0.2s ease;
  pointer-events: none;
}
#ms-toast.show {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 768px) {
  .research-shell, .reader-shell {
    padding: 18px 14px 60px 14px;
  }
  .article-meta-row {
    flex-direction: column;
    align-items: flex-start;
  }
  .article-actions-bar {
    width: 100%;
    justify-content: flex-start;
  }
  .hub-toolbar {
    flex-direction: column;
    align-items: stretch;
  }
  .hub-search-box {
    max-width: 100%;
  }
  .article-grid {
    grid-template-columns: 1fr;
  }
}
