/* ============================================================
   Insights — Research & Publications
   Layered on top of styles.css. Reuses the same design tokens
   (--accent-red, --font-heading, --radius-*) so the publication
   pages read as part of the same system.
   ============================================================ */

:root {
  --doc-measure: 68ch;
  --doc-sidebar: 250px;
}

/* ============================================================
   1. Shared: page hero
   ============================================================ */

.insights-hero {
  padding: 140px 0 56px;
  background: var(--bg-primary);
  position: relative;
  overflow: hidden;
}

.insights-hero .hero-grid-bg {
  mask-image: radial-gradient(ellipse at 35% 45%, black 12%, transparent 62%);
  -webkit-mask-image: radial-gradient(ellipse at 35% 45%, black 12%, transparent 62%);
}

.insights-hero-inner {
  position: relative;
  z-index: 1;
  max-width: 760px;
}

.insights-hero-title {
  font-size: clamp(2.1rem, 5.2vw, 3.2rem);
  font-weight: 800;
  letter-spacing: -0.035em;
  line-height: 1.08;
  margin-bottom: 16px;
}

.insights-hero-desc {
  font-size: 1.08rem;
  color: var(--text-secondary);
  line-height: 1.8;
  max-width: 620px;
  text-align: left;
}

/* Credibility strip under the hero copy */
.insights-meta-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 28px;
  margin-top: 26px;
}

.insights-meta-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.84rem;
  color: var(--text-muted);
  font-weight: 500;
}

.insights-meta-item svg {
  width: 15px;
  height: 15px;
  color: var(--accent-red);
  flex-shrink: 0;
}

/* ============================================================
   2. Index: filters
   ============================================================ */

.insight-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 36px;
}

.insight-filter {
  font-family: var(--font-body);
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-secondary);
  background: transparent;
  border: 1px solid var(--border-medium);
  border-radius: 100px;
  padding: 7px 16px;
  cursor: pointer;
  transition: all var(--transition-smooth);
  white-space: nowrap;
}

.insight-filter:hover {
  border-color: var(--border-accent);
  color: var(--accent-red);
}

.insight-filter.active {
  background: var(--accent-red);
  border-color: var(--accent-red);
  color: #fff;
}

/* ============================================================
   3. Index: cards
   ============================================================ */

.insight-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--accent-red);
  background: var(--accent-red-soft);
  border: 1px solid var(--border-accent);
  border-radius: 100px;
  padding: 4px 11px;
}

.insight-badge svg {
  width: 12px;
  height: 12px;
}

/* --- Featured document --- */
.insight-featured {
  display: grid;
  grid-template-columns: 1.35fr 1fr;
  gap: 0;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-card);
  margin-bottom: 40px;
  transition: box-shadow var(--transition-smooth), transform var(--transition-smooth);
}

.insight-featured:hover {
  box-shadow: var(--shadow-hover);
  transform: translateY(-2px);
}

.insight-featured-body {
  padding: 36px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.insight-featured-title {
  font-size: clamp(1.35rem, 2.6vw, 1.75rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.25;
}

.insight-featured-title a { color: var(--text-primary); }
.insight-featured:hover .insight-featured-title a { color: var(--accent-red); }

.insight-featured-abstract {
  color: var(--text-secondary);
  font-size: 0.95rem;
  line-height: 1.8;
  text-align: left;
}

/* Right rail: an at-a-glance summary block */
.insight-featured-aside {
  background: #FAFAFA;
  border-left: 1px solid var(--border-subtle);
  padding: 36px 30px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 18px;
}

.insight-aside-row {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.insight-aside-label {
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.insight-aside-value {
  font-family: var(--font-heading);
  font-size: 0.98rem;
  font-weight: 600;
  color: var(--text-primary);
}

/* --- Standard cards --- */
.insights-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(330px, 1fr));
  gap: 22px;
}

.insight-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 26px;
  box-shadow: var(--shadow-subtle);
  transition: all var(--transition-smooth);
}

.insight-card:hover {
  border-color: var(--border-accent);
  box-shadow: var(--shadow-hover);
  transform: translateY(-3px);
}

.insight-card.filtered-out { display: none; }

.insight-card-title {
  font-size: 1.12rem;
  font-weight: 700;
  letter-spacing: -0.015em;
  line-height: 1.35;
}

.insight-card-title a { color: var(--text-primary); }
.insight-card:hover .insight-card-title a { color: var(--accent-red); }

.insight-card-abstract {
  color: var(--text-secondary);
  font-size: 0.9rem;
  line-height: 1.75;
  text-align: left;
  flex-grow: 1;
}

.insight-card-footer {
  display: flex;
  align-items: center;
  gap: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border-subtle);
  font-size: 0.78rem;
  color: var(--text-muted);
}

.insight-card-footer span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.insight-card-footer svg {
  width: 13px;
  height: 13px;
}

.insight-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.insight-tag {
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--bg-glass);
  border-radius: 5px;
  padding: 3px 9px;
}

/* Empty state, shown when a filter matches nothing */
.insights-empty {
  display: none;
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.insights-empty.visible { display: block; }

/* ============================================================
   4. Document page
   ============================================================ */

.reading-progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  width: 0%;
  background: linear-gradient(90deg, var(--accent-red), var(--accent-red-light));
  z-index: 2000;
  transition: width 0.08s linear;
}

.doc-hero {
  padding: 130px 0 40px;
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border-subtle);
}

.doc-breadcrumb {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 22px;
}

.doc-breadcrumb a { color: var(--text-muted); }
.doc-breadcrumb a:hover { color: var(--accent-red); }
.doc-breadcrumb svg { width: 13px; height: 13px; }

.doc-title {
  font-size: clamp(1.9rem, 4.4vw, 2.85rem);
  font-weight: 800;
  letter-spacing: -0.035em;
  line-height: 1.12;
  margin: 14px 0 18px;
  max-width: 22ch;
}

.doc-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 22px;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.doc-meta > span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.doc-meta svg { width: 14px; height: 14px; }

.doc-author {
  font-weight: 600;
  color: var(--text-primary);
}

/* --- Abstract card --- */
.doc-abstract {
  background: var(--accent-red-soft);
  border: 1px solid var(--border-accent);
  border-left: 3px solid var(--accent-red);
  border-radius: var(--radius-md);
  padding: 22px 26px;
  margin: 34px 0 0;
}

.doc-abstract-label {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent-red);
  margin-bottom: 8px;
}

.doc-abstract p {
  font-size: 1rem;
  line-height: 1.8;
  color: var(--text-primary);
  text-align: left;
  margin: 0;
}

/* --- Layout: sticky TOC + article --- */
.doc-layout {
  display: grid;
  grid-template-columns: var(--doc-sidebar) minmax(0, 1fr);
  gap: 56px;
  align-items: start;
  padding: 56px 0 80px;
}

.doc-toc {
  position: sticky;
  top: 100px;
  max-height: calc(100vh - 140px);
  overflow-y: auto;
  padding-right: 8px;
}

.doc-toc-label {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 14px;
}

.doc-toc ul {
  list-style: none;
  border-left: 1px solid var(--border-subtle);
}

.doc-toc li a {
  display: block;
  padding: 6px 0 6px 14px;
  margin-left: -1px;
  border-left: 2px solid transparent;
  font-size: 0.84rem;
  line-height: 1.5;
  color: var(--text-secondary);
  transition: all 0.2s ease;
}

.doc-toc li a:hover {
  color: var(--accent-red);
  border-left-color: var(--border-accent);
}

.doc-toc li a.active {
  color: var(--accent-red);
  font-weight: 600;
  border-left-color: var(--accent-red);
}

.doc-toc li.toc-l3 a {
  padding-left: 26px;
  font-size: 0.79rem;
  color: var(--text-muted);
}

/* --- Article typography --- */
.doc-body {
  max-width: var(--doc-measure);
  font-size: 1.02rem;
  line-height: 1.85;
  color: var(--text-primary);
}

.doc-body p {
  margin-bottom: 1.35em;
  text-align: justify;
  hyphens: auto;
  -webkit-hyphens: auto;
}

.doc-body > *:first-child { margin-top: 0; }

.doc-h2 {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.3;
  margin: 2.4em 0 0.8em;
  padding-top: 0.4em;
  border-top: 1px solid var(--border-subtle);
  scroll-margin-top: 96px;
  position: relative;
}

.doc-h3 {
  font-size: 1.16rem;
  font-weight: 650;
  letter-spacing: -0.01em;
  margin: 2em 0 0.7em;
  scroll-margin-top: 96px;
  position: relative;
}

.doc-body h4 {
  font-size: 1.02rem;
  font-weight: 600;
  margin: 1.6em 0 0.5em;
}

/* Hover-revealed heading anchor */
.doc-anchor {
  position: absolute;
  left: -1.1em;
  color: var(--border-medium);
  font-weight: 400;
  opacity: 0;
  transition: opacity 0.2s ease;
  text-decoration: none;
}

.doc-h2:hover .doc-anchor,
.doc-h3:hover .doc-anchor { opacity: 1; }
.doc-anchor:hover { color: var(--accent-red); }

.doc-body ul,
.doc-body ol {
  margin: 0 0 1.35em 1.3em;
}

.doc-body li {
  margin-bottom: 0.55em;
  padding-left: 0.25em;
}

.doc-body li::marker { color: var(--accent-red); }

.doc-body strong { font-weight: 650; }

.doc-body hr {
  border: none;
  border-top: 1px solid var(--border-subtle);
  margin: 2.5em 0;
}

/* --- Callout (from blockquote) --- */
.doc-callout {
  background: #FAFAFA;
  border-left: 3px solid var(--accent-red);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 18px 24px;
  margin: 1.8em 0;
}

.doc-callout p {
  margin-bottom: 0.6em;
  font-size: 1.03rem;
  font-weight: 500;
  color: var(--text-primary);
  text-align: left;
}

.doc-callout p:last-child { margin-bottom: 0; }

/* --- Tables --- */
.doc-table-wrap {
  overflow-x: auto;
  margin: 1.8em 0;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  -webkit-overflow-scrolling: touch;
}

.doc-table-wrap table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  min-width: 460px;
}

.doc-table-wrap th {
  background: #FAFAFA;
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-secondary);
  text-align: left;
  padding: 13px 16px;
  border-bottom: 1px solid var(--border-medium);
  white-space: nowrap;
}

.doc-table-wrap td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: top;
}

.doc-table-wrap tr:last-child td { border-bottom: none; }
.doc-table-wrap tbody tr:hover { background: var(--accent-red-soft); }

/* --- Figures --- */
.doc-figure {
  margin: 2em 0;
}

.doc-figure img {
  width: 100%;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  display: block;
}

.doc-figure figcaption {
  margin-top: 10px;
  font-size: 0.82rem;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.6;
}

/* --- Code --- */
.doc-body code {
  font-family: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, monospace;
  font-size: 0.86em;
  background: var(--bg-glass);
  color: var(--accent-red);
  padding: 2px 6px;
  border-radius: 4px;
}

.doc-body pre {
  background: #1A1A1A;
  border-radius: var(--radius-md);
  padding: 20px 22px;
  overflow-x: auto;
  margin: 1.8em 0;
  font-size: 0.86rem;
  line-height: 1.65;
}

.doc-body pre code {
  background: none;
  color: #E8E8E8;
  padding: 0;
  font-size: inherit;
}

/* --- Footnotes / references list --- */
.doc-body h2#references + ol,
.doc-body h2#references + ul {
  font-size: 0.9rem;
  color: var(--text-secondary);
}

/* ============================================================
   5. Document footer: CTA + related
   ============================================================ */

.doc-cta {
  max-width: var(--doc-measure);
  margin-top: 60px;
  padding: 34px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
}

.doc-cta h3 {
  font-size: 1.28rem;
  letter-spacing: -0.02em;
  margin-bottom: 10px;
}

.doc-cta p {
  color: var(--text-secondary);
  font-size: 0.95rem;
  line-height: 1.8;
  text-align: left;
  margin-bottom: 20px;
}

.doc-cta-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.doc-related {
  max-width: var(--doc-measure);
  margin-top: 52px;
}

.doc-related-label {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.doc-related-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px;
}

.doc-related-item {
  display: block;
  padding: 18px 20px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  transition: all var(--transition-smooth);
}

.doc-related-item:hover {
  border-color: var(--border-accent);
  box-shadow: var(--shadow-subtle);
  transform: translateY(-2px);
}

.doc-related-type {
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--accent-red);
}

.doc-related-title {
  font-family: var(--font-heading);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.4;
  margin-top: 5px;
}

/* ============================================================
   6. Responsive
   ============================================================ */

@media (max-width: 1024px) {
  .doc-layout {
    grid-template-columns: 1fr;
    gap: 0;
  }

  /* TOC collapses into a disclosure above the article */
  .doc-toc {
    position: static;
    max-height: none;
    margin-bottom: 34px;
    padding: 18px 20px;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    background: #FAFAFA;
  }

  .insight-featured { grid-template-columns: 1fr; }
  .insight-featured-aside {
    border-left: none;
    border-top: 1px solid var(--border-subtle);
    flex-direction: row;
    flex-wrap: wrap;
    gap: 28px;
    padding: 24px 30px;
  }
}

@media (max-width: 768px) {
  .insights-hero { padding: 116px 0 40px; }
  .doc-hero { padding: 110px 0 32px; }
  .doc-title { max-width: none; }
  .doc-body { font-size: 1rem; }
  .doc-body p { text-align: left; }
  .insights-grid { grid-template-columns: 1fr; }
  .insight-featured-body { padding: 28px 24px; }
  .doc-cta { padding: 26px 22px; }
  .doc-anchor { display: none; }
}

/* ============================================================
   7. Print — "Download PDF" is print-to-PDF, so this matters
   ============================================================ */

@media print {
  .navbar,
  .footer,
  .doc-toc,
  .doc-cta,
  .doc-related,
  .doc-engage,
  .doc-comments,
  .reading-progress,
  .doc-breadcrumb,
  .page-loader,
  .doc-anchor { display: none !important; }

  body {
    font-size: 11pt;
    line-height: 1.6;
    color: #000;
    background: #fff;
  }

  .doc-hero { padding: 0 0 18pt; border-bottom: 1pt solid #ccc; }
  .doc-layout { display: block; padding: 18pt 0 0; }
  .doc-body { max-width: none; font-size: 11pt; }
  .container { max-width: none; padding: 0; }

  .doc-h2 {
    font-size: 15pt;
    page-break-after: avoid;
    break-after: avoid;
  }

  .doc-h3 {
    font-size: 12.5pt;
    page-break-after: avoid;
    break-after: avoid;
  }

  .doc-figure,
  .doc-table-wrap,
  .doc-callout {
    page-break-inside: avoid;
    break-inside: avoid;
  }

  .doc-abstract {
    background: #f7f7f7 !important;
    border: 1pt solid #ccc;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .doc-body pre {
    background: #f4f4f4;
    color: #000;
    border: 1pt solid #ddd;
  }

  .doc-body pre code { color: #000; }

  /* Surface link targets in the printed artefact */
  .doc-body a[href^="http"]::after {
    content: " (" attr(href) ")";
    font-size: 9pt;
    color: #555;
  }

  @page { margin: 18mm 16mm; }
}

/* ============================================================
   8. Engagement bar — like / comment / share
   Mirrors the notes cards so the two sections feel like one site.
   ============================================================ */

.doc-engage {
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: var(--doc-measure);
  margin-top: 40px;
  padding-top: 22px;
  border-top: 1px solid var(--border-subtle);
}

.doc-react,
.doc-engage-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 16px;
  background: transparent;
  border: 1px solid var(--border-medium);
  border-radius: 100px;
  color: var(--text-secondary);
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-smooth);
}

.doc-react:hover,
.doc-engage-btn:hover {
  border-color: var(--border-accent);
  color: var(--accent-red);
}

.doc-react.fired {
  border-color: var(--border-accent);
  color: var(--accent-red);
  background: var(--accent-red-soft);
}

/* Share sits at the right-hand end */
.doc-share-wrap {
  position: relative;
  margin-left: auto;
}

.doc-share-dropdown {
  position: absolute;
  right: 0;
  bottom: calc(100% + 8px);
  min-width: 190px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-hover);
  padding: 6px;
  opacity: 0;
  visibility: hidden;
  transform: translateY(6px);
  transition: all 0.2s ease;
  z-index: 60;
}

.doc-share-dropdown.open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.doc-share-option {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 12px;
  background: none;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-family: var(--font-body);
  font-size: 0.85rem;
  text-align: left;
  cursor: pointer;
  transition: all 0.15s ease;
}

.doc-share-option:hover {
  background: var(--accent-red-soft);
  color: var(--accent-red);
}

/* ---- Comments ---- */

.doc-comments {
  max-width: var(--doc-measure);
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  transition: max-height 0.4s ease, opacity 0.3s ease, margin 0.3s ease;
}

.doc-comments.open {
  max-height: 2000px;
  opacity: 1;
  margin-top: 24px;
}

.doc-comment {
  padding: 14px 18px;
  background: #FAFAFA;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  margin-bottom: 10px;
}

.doc-comment-author {
  font-family: var(--font-heading);
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--text-primary);
}

.doc-comment-body {
  font-size: 0.92rem;
  line-height: 1.7;
  color: var(--text-secondary);
  margin-top: 4px;
  white-space: pre-wrap;
}

.doc-comment-time {
  font-size: 0.74rem;
  color: var(--text-muted);
  margin-top: 6px;
}

.doc-comment-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 18px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
}

.doc-comment-name,
.doc-comment-text {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-primary);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 0.9rem;
  line-height: 1.6;
}

.doc-comment-name:focus,
.doc-comment-text:focus {
  border-color: var(--accent-red);
  outline: none;
}

.doc-comment-text { resize: vertical; }

.doc-comment-form .btn { align-self: flex-start; }

@media (max-width: 768px) {
  .doc-engage { flex-wrap: wrap; gap: 8px; }
  .doc-share-wrap { margin-left: 0; }
  .doc-share-dropdown { right: auto; left: 0; }
}
