/* Research by Happily — shared article stylesheet
   Used by every /research/{slug}/index.html technical article. */

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

:root {
  --bg: #F6F3EE;
  --bg-warm: #EDE9E1;
  --bg-card: #FFFFFF;
  --text: #1E1E1E;
  --text-mid: #4A4A4A;
  --text-muted: #7A7570;
  --text-light: #AAA5A0;
  --purple: #4C32CC;
  --purple-soft: #6B52E7;
  --purple-light: #EDE8FF;
  --purple-glow: rgba(76,50,204,0.15);
  --purple-deep: #3A24A0;
  --green: #0DD379;
  --green-bg: #E6FAF0;
  --amber: #F5B800;
  --amber-bg: #FFF8E0;
  --coral: #F2542D;
  --coral-bg: #FDEBE6;
  --border: #E5E0DA;
  --border-light: #EEEBE6;
  --shadow-sm: 0 1px 2px rgba(30,30,30,0.04), 0 2px 8px rgba(30,30,30,0.03);
  --shadow: 0 1px 3px rgba(30,30,30,0.05), 0 6px 20px rgba(30,30,30,0.04);
  --shadow-lg: 0 4px 12px rgba(30,30,30,0.06), 0 16px 40px rgba(30,30,30,0.06);
  --radius: 16px;
  --radius-sm: 10px;
  --font-display: 'Fraunces', Georgia, serif;
  --font-sans: 'Hanken Grotesk', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

html { font-size: 16px; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; scroll-behavior: smooth; }

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
}

body::after {
  content: '';
  position: fixed;
  inset: 0;
  opacity: 0.3;
  pointer-events: none;
  z-index: 9999;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.04'/%3E%3C/svg%3E");
}

.container {
  max-width: 760px;
  margin: 0 auto;
  padding: 20px 24px 100px;
  position: relative;
}

/* --- Header --- */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0 40px;
}

.wordmark {
  font-family: var(--font-sans);
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.02em;
  color: var(--purple);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 7px;
  transition: opacity 0.2s;
}
.wordmark:hover { opacity: 0.7; }
.wordmark-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--purple); }

.back-link {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: color 0.2s, gap 0.2s;
}
.back-link:hover { color: var(--purple); gap: 9px; }

/* --- Article hero --- */
.article-kicker {
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--purple);
  margin-bottom: 18px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.article-kicker::before { content: ''; width: 24px; height: 1.5px; background: var(--purple); }

.article-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(2.1rem, 5.5vw, 3rem);
  line-height: 1.08;
  letter-spacing: -0.025em;
  color: var(--text);
  margin-bottom: 20px;
}
.article-title em { font-style: italic; font-weight: 500; color: var(--purple); }

.article-deck {
  font-family: var(--font-display);
  font-size: 1.18rem;
  line-height: 1.55;
  color: var(--text-mid);
  margin-bottom: 24px;
}

.article-byline {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  font-weight: 500;
  color: var(--text-light);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding-bottom: 32px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 32px;
}
.article-byline .dot { width: 3px; height: 3px; border-radius: 50%; background: var(--text-light); }

/* --- Key-stats strip --- */
.stats-strip {
  display: flex;
  gap: 1px;
  background: var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin: 32px 0;
}
.stat-cell { flex: 1; background: var(--bg-card); padding: 20px 14px; text-align: center; }
.stat-value {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 1.4rem;
  color: var(--purple);
  letter-spacing: -0.03em;
  line-height: 1;
  margin-bottom: 6px;
}
.stat-desc { font-size: 0.73rem; color: var(--text-muted); font-weight: 500; line-height: 1.35; }

/* --- Prose --- */
.prose { font-size: 1.04rem; line-height: 1.75; color: var(--text-mid); }
.prose > p { margin-bottom: 22px; }
.prose > p:first-of-type { font-size: 1.1rem; }
.prose strong { font-weight: 600; color: var(--text); }
.prose em { font-style: italic; }
.prose a { color: var(--purple); text-decoration: underline; text-underline-offset: 2px; text-decoration-thickness: 1px; }
.prose a:hover { text-decoration-thickness: 2px; }

.prose h2 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.55rem;
  line-height: 1.2;
  letter-spacing: -0.02em;
  color: var(--text);
  margin: 52px 0 16px;
  padding-top: 8px;
}
.prose h3 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.18rem;
  line-height: 1.3;
  color: var(--text);
  margin: 36px 0 12px;
}

.prose ul, .prose ol { margin: 0 0 22px 1.1rem; }
.prose li { margin-bottom: 9px; padding-left: 4px; }
.prose ul li::marker { color: var(--purple); }

.prose code {
  font-family: var(--font-mono);
  font-size: 0.85em;
  background: var(--bg-warm);
  padding: 2px 6px;
  border-radius: 5px;
  color: var(--purple-deep);
}

/* --- Section eyebrow --- */
.eyebrow {
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--purple);
  margin: 52px 0 -4px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.eyebrow::before { content: ''; width: 20px; height: 1.5px; background: var(--purple); }

/* --- Lead-in / pull stat --- */
.lead-stat {
  font-family: var(--font-display);
  font-size: 1.5rem;
  line-height: 1.35;
  color: var(--text);
  font-weight: 500;
  border-left: 3px solid var(--purple);
  padding: 6px 0 6px 24px;
  margin: 32px 0;
}
.lead-stat strong { color: var(--purple); font-weight: 700; }

/* --- Methodology box --- */
.method-box {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-left: 4px solid var(--purple);
  border-radius: var(--radius);
  padding: 24px 28px;
  margin: 32px 0;
  box-shadow: var(--shadow-sm);
}
.method-box-title {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--purple);
  margin-bottom: 16px;
}
.method-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px 28px;
}
.method-item { }
.method-item dt {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-light);
  margin-bottom: 3px;
}
.method-item dd {
  font-size: 0.92rem;
  color: var(--text-mid);
  line-height: 1.5;
}
.method-item dd strong { color: var(--text); font-weight: 600; }

/* --- Figures / charts --- */
.figure {
  margin: 32px 0;
}
.figure img,
.figure svg {
  width: 100%;
  height: auto;
  display: block;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  overflow: hidden;
}

/* --- Inline interactive charts --- */
/* Chart figures embed the chart's SVG directly (not an <img>): the chart's
   text becomes crawlable page content and the chart is interactive in place.
   /research/charts.js wires the hover behaviour; .webp/.png stay for OG tags
   and homepage thumbnails only. */
.figure svg .datum {
  transition: fill-opacity 0.15s ease, stroke-opacity 0.15s ease;
  cursor: pointer;
}
svg.ix-focus .datum:not(.ix-on) {
  fill-opacity: 0.26;
  stroke-opacity: 0.26;
}
.ix-tip {
  position: fixed;
  z-index: 50;
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, -128%);
  transition: opacity 0.12s ease;
  background: #2A2A2A;
  color: #fff;
  border-radius: 7px;
  padding: 7px 10px;
  box-shadow: 0 6px 20px rgba(42,42,42,0.28);
  white-space: nowrap;
  font-family: var(--font-sans);
}
.ix-tip b { font-size: 0.78rem; font-weight: 700; }
.ix-tip span {
  display: block;
  font-size: 0.6rem;
  font-weight: 600;
  opacity: 0.6;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-bottom: 2px;
}
.ix-tip em {
  display: block;
  font-size: 0.62rem;
  font-style: normal;
  opacity: 0.7;
  margin-top: 3px;
}
@media (prefers-reduced-motion: reduce) {
  .figure svg .datum, .ix-tip { transition: none; }
}
.figcaption {
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.55;
  margin-top: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  align-items: baseline;
}
.figcaption .fig-label {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--purple);
}
.chart-link {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--purple);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
  transition: gap 0.2s;
}
.chart-link:hover { gap: 8px; }
.chart-link svg { width: 11px; height: 11px; }

/* --- Data tables --- */
.table-wrap { overflow-x: auto; margin: 28px 0; -webkit-overflow-scrolling: touch; }
table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  min-width: 440px;
}
table.data caption {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-light);
  text-align: left;
  margin-bottom: 10px;
}
table.data th, table.data td {
  text-align: left;
  padding: 11px 14px;
  border-bottom: 1px solid var(--border-light);
}
table.data thead th {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
  border-bottom: 1.5px solid var(--border);
}
table.data tbody tr:last-child td { border-bottom: none; }
table.data .num { text-align: right; font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
table.data tbody tr:hover { background: var(--bg-warm); }
table.data .row-em td { font-weight: 600; color: var(--text); }
table.data .row-em { background: var(--purple-light); }

/* --- Inline bar table (for chartless articles) --- */
.bartable { margin: 28px 0; display: flex; flex-direction: column; gap: 12px; }
.bartable-caption {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-light);
  margin-bottom: 4px;
}
.bar-row { display: grid; grid-template-columns: 150px 1fr auto; gap: 14px; align-items: center; }
.bar-label { font-size: 0.85rem; color: var(--text-mid); }
.bar-track { background: var(--bg-warm); border-radius: 6px; height: 26px; overflow: hidden; }
.bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--purple-soft), var(--purple));
  border-radius: 6px;
}
.bar-val {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  min-width: 48px;
  text-align: right;
}

/* --- Callout --- */
.callout {
  border-radius: var(--radius-sm);
  padding: 18px 22px;
  margin: 28px 0;
  font-size: 0.95rem;
  line-height: 1.6;
  border: 1px solid var(--border-light);
}
.callout-label {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 6px;
}
.callout.info { background: var(--purple-light); border-color: #DDD3FF; }
.callout.info .callout-label { color: var(--purple); }
.callout.tip { background: var(--green-bg); border-color: #BCEED3; }
.callout.tip .callout-label { color: #08915280; color: #097A45; }
.callout.warning { background: var(--amber-bg); border-color: #F0E2AE; }
.callout.warning .callout-label { color: #A07A00; }
.callout p { color: var(--text-mid); }
.callout p + p { margin-top: 10px; }

/* --- Related research --- */
.related {
  margin: 56px 0 0;
}
.related-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}
.related-card {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 18px 20px;
  text-decoration: none;
  transition: all 0.25s cubic-bezier(0.4,0,0.2,1);
  display: block;
}
.related-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow);
  border-color: var(--purple-light);
}
.related-card-tag {
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.related-card-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1rem;
  line-height: 1.3;
  color: var(--text);
  letter-spacing: -0.01em;
}

/* --- Buttons --- */
.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: var(--purple);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 16px 38px;
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 0.96rem;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.4,0,0.2,1);
  box-shadow: 0 2px 12px var(--purple-glow), 0 1px 3px rgba(76,50,204,0.2);
  text-decoration: none;
}
.btn-primary:hover {
  background: var(--purple-deep);
  transform: translateY(-2px);
  box-shadow: 0 4px 24px var(--purple-glow), 0 2px 8px rgba(76,50,204,0.25);
}
.btn-primary svg { width: 16px; height: 16px; transition: transform 0.25s cubic-bezier(0.4,0,0.2,1); }
.btn-primary:hover svg { transform: translateX(4px); }

/* --- Final CTA --- */
.final-cta {
  text-align: center;
  padding: 52px 32px;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
  margin-top: 56px;
}
.final-cta::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--purple) 0%, var(--purple-soft) 40%, var(--green) 100%);
}
.final-cta-headline {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(1.5rem, 4vw, 1.9rem);
  line-height: 1.15;
  color: var(--text);
  margin-bottom: 14px;
  letter-spacing: -0.02em;
}
.final-cta-headline em { font-style: italic; font-weight: 500; color: var(--purple); }
.final-cta-body {
  font-family: var(--font-display);
  font-size: 1rem;
  line-height: 1.65;
  color: var(--text-muted);
  max-width: 420px;
  margin: 0 auto 28px;
}
.final-cta-sub { margin-top: 16px; font-size: 0.76rem; color: var(--text-light); }

/* --- References --- */
.references { margin: 40px 0 0; }
.references ol { margin: 0 0 0 1.2rem; font-size: 0.86rem; color: var(--text-muted); line-height: 1.6; }
.references li { margin-bottom: 8px; }
.references a { color: var(--purple); }

/* --- Footer --- */
.footer-line {
  text-align: center;
  padding: 40px 0 16px;
  font-size: 0.78rem;
  color: var(--text-light);
  line-height: 1.6;
  border-top: 1px solid var(--border);
  margin-top: 48px;
}
.footer-line a { color: var(--text-muted); text-decoration: none; font-weight: 600; }
.footer-line a:hover { color: var(--purple); }

/* --- Scroll reveal --- */
.reveal {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 0.7s cubic-bezier(0.4,0,0.2,1), transform 0.7s cubic-bezier(0.4,0,0.2,1);
}
.reveal.visible { opacity: 1; transform: translateY(0); }

/* --- Responsive --- */
@media (max-width: 640px) {
  .container { padding: 16px 18px 80px; }
  .stats-strip { flex-direction: column; }
  .method-grid { grid-template-columns: 1fr; }
  .related-grid { grid-template-columns: 1fr; }
  .bar-row { grid-template-columns: 110px 1fr auto; gap: 10px; }
  .lead-stat { font-size: 1.25rem; }
  .final-cta { padding: 40px 22px; }
}

@media (prefers-reduced-motion: reduce) {
  .reveal { opacity: 1; transform: none; transition: none; }
  html { scroll-behavior: auto; }
}
