/* ============================================
   RUNCIBLE ECONOMICS — Guardian-inspired styles
   ============================================ */

/* Fonts are loaded via <link> tags in each HTML file for better performance */

/* --- Reset & base ----------------------------------------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --brand-blue:    #052962;
  --brand-mid:     #506991;
  --accent-red:    #C70000;
  --accent-orange: #E05E00;
  --accent-green:  #00882B;
  --accent-purple: #7D0068;
  --text-primary:  #121212;
  --text-muted:    #767676;
  --border:        #DCDCDC;
  --bg-page:       #F6F6F6;
  --bg-white:      #FFFFFF;
  --col-max:       1200px;
  --font-serif:    'Source Serif 4', Georgia, serif;
  --font-display:  'Libre Baskerville', Georgia, serif;
  --font-sans:     'Inter', system-ui, sans-serif;
}

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: var(--font-sans);
  background: var(--bg-page);
  color: var(--text-primary);
  line-height: 1.5;
}

a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; height: auto; }

/* --- Layout helpers --------------------------------------- */
.container {
  max-width: var(--col-max);
  margin: 0 auto;
  padding: 0 16px;
}

/* ============================================================
   MASTHEAD
   ============================================================ */
.masthead {
  background: var(--brand-blue);
  color: #fff;
  padding: 0 0 0;
  border-bottom: 1px solid rgba(255,255,255,0.15);
}

.masthead__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px 10px;
  max-width: var(--col-max);
  margin: 0 auto;
}

.masthead__wordmark {
  font-family: var(--font-display);
  font-size: clamp(1.6rem, 4vw, 2.6rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1;
  color: #fff;
}

.masthead__wordmark span {
  color: #90c3f5;
}

.masthead__tagline {
  font-family: var(--font-sans);
  font-size: 0.72rem;
  font-weight: 300;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.6);
  margin-top: 4px;
}

.masthead__date {
  font-size: 0.78rem;
  color: rgba(255,255,255,0.55);
  font-weight: 300;
  text-align: right;
  display: none;
}

@media (min-width: 640px) { .masthead__date { display: block; } }

/* --- Navigation ------------------------------------------- */
.site-nav {
  background: var(--brand-blue);
  border-top: 1px solid rgba(255,255,255,0.12);
}

.site-nav__list {
  display: flex;
  list-style: none;
  max-width: var(--col-max);
  margin: 0 auto;
  padding: 0 12px;
  gap: 0;
  overflow-x: auto;
  scrollbar-width: none;
}

.site-nav__list::-webkit-scrollbar { display: none; }

.site-nav__item a {
  display: block;
  padding: 8px 12px;
  font-size: 0.82rem;
  font-weight: 500;
  color: rgba(255,255,255,0.8);
  white-space: nowrap;
  border-top: 3px solid transparent;
  transition: color 0.15s, border-color 0.15s;
}

.site-nav__item a:hover,
.site-nav__item.active a {
  color: #fff;
  border-top-color: #fff;
}

.site-nav__item--macro a  { border-top-color: transparent; }
.site-nav__item--trade a  { }
.site-nav__item--policy a { }
.site-nav__item--data a   { }

/* ============================================================
   HERO SECTION (featured article)
   ============================================================ */
.hero {
  background: var(--bg-white);
  border-bottom: 1px solid var(--border);
}

.hero__inner {
  max-width: var(--col-max);
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr;
  gap: 0;
}

@media (min-width: 768px) {
  .hero__inner {
    grid-template-columns: 1fr 380px;
  }
}

.hero__content {
  padding: 20px 20px 20px 16px;
  border-right: 1px solid var(--border);
}

.hero__kicker {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent-red);
  margin-bottom: 8px;
}

.hero__headline {
  font-family: var(--font-display);
  font-size: clamp(1.6rem, 3.5vw, 2.4rem);
  font-weight: 700;
  line-height: 1.15;
  margin-bottom: 12px;
}

.hero__headline a:hover { text-decoration: underline; }

.hero__standfirst {
  font-family: var(--font-serif);
  font-size: 1.05rem;
  color: #333;
  line-height: 1.55;
  margin-bottom: 16px;
}

.hero__meta {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.hero__media {
  overflow: hidden;
  max-height: 320px;
}

.hero__media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* ============================================================
   MAIN LAYOUT
   ============================================================ */
.page-body {
  max-width: var(--col-max);
  margin: 0 auto;
  padding: 0 16px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 24px;
  margin-top: 24px;
}

@media (min-width: 900px) {
  .page-body {
    grid-template-columns: 1fr 280px;
    gap: 32px;
  }
}

/* ============================================================
   SECTION LABELS
   ============================================================ */
.section-label {
  font-family: var(--font-sans);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-primary);
  padding-bottom: 8px;
  border-top: 3px solid var(--brand-blue);
  margin-bottom: 16px;
  padding-top: 6px;
}

/* ============================================================
   ARTICLE CARDS
   ============================================================ */
.card-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0;
}

@media (min-width: 600px) {
  .card-grid--three {
    grid-template-columns: repeat(3, 1fr);
  }
  .card-grid--two {
    grid-template-columns: repeat(2, 1fr);
  }
}

.card {
  background: var(--bg-white);
  border-bottom: 1px solid var(--border);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: background 0.1s;
}

@media (min-width: 600px) {
  .card-grid--three .card,
  .card-grid--two .card {
    border-bottom: none;
    border-right: 1px solid var(--border);
  }
  .card-grid--three .card:last-child,
  .card-grid--two .card:last-child {
    border-right: none;
  }
}

.card:hover { background: #fafafa; }

.card__media {
  overflow: hidden;
  margin: -16px -16px 8px;
  aspect-ratio: 16/9;
}

.card__media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}

.card:hover .card__media img { transform: scale(1.02); }

.card__tag {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.tag--macro       { color: var(--accent-red); }
.tag--datacharts  { color: var(--accent-green); }
.tag--explainers  { color: var(--accent-purple); }

.card__headline {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1.25;
}

.card__headline a:hover { text-decoration: underline; }

.card__standfirst {
  font-size: 0.88rem;
  color: #444;
  line-height: 1.5;
  font-family: var(--font-serif);
}

.card__meta {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: auto;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar__block {
  background: var(--bg-white);
  border: 1px solid var(--border);
  padding: 16px;
  margin-bottom: 20px;
}

.sidebar__block p {
  font-size: 0.88rem;
  color: #444;
  line-height: 1.55;
  margin-top: 8px;
  font-family: var(--font-serif);
}

.sidebar__block .section-label {
  margin-bottom: 12px;
}

.sidebar__list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.sidebar__list li {
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-family: var(--font-display);
  font-size: 0.9rem;
  font-weight: 700;
  line-height: 1.3;
}

.sidebar__list li:last-child { border-bottom: none; }
.sidebar__list li a:hover { text-decoration: underline; }

.sidebar__list .meta {
  font-family: var(--font-sans);
  font-size: 0.7rem;
  font-weight: 400;
  color: var(--text-muted);
  display: block;
  margin-top: 2px;
}

/* ============================================================
   FOOTER
   ============================================================ */
.site-footer {
  background: var(--brand-blue);
  color: rgba(255,255,255,0.7);
  margin-top: 48px;
  padding: 32px 16px;
}

.site-footer__inner {
  max-width: var(--col-max);
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr;
  gap: 24px;
}

@media (min-width: 640px) {
  .site-footer__inner {
    grid-template-columns: 2fr 1fr 1fr;
  }
}

.site-footer__brand {
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 700;
  color: #fff;
  margin-bottom: 8px;
}

.site-footer p {
  font-size: 0.82rem;
  line-height: 1.6;
}

.site-footer h4 {
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #fff;
  margin-bottom: 10px;
}

.site-footer ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.site-footer ul li a {
  font-size: 0.82rem;
  color: rgba(255,255,255,0.65);
  transition: color 0.15s;
}

.site-footer ul li a:hover { color: #fff; }

.site-footer__bottom {
  max-width: var(--col-max);
  margin: 24px auto 0;
  padding-top: 16px;
  border-top: 1px solid rgba(255,255,255,0.15);
  font-size: 0.75rem;
  color: rgba(255,255,255,0.4);
}

/* ============================================================
   ARTICLE PAGE
   ============================================================ */
.article-header {
  background: var(--bg-white);
  border-bottom: 1px solid var(--border);
  padding: 28px 16px 0;
}

.article-header__inner {
  max-width: 720px;
  margin: 0 auto;
}

.article-header__kicker {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent-red);
  margin-bottom: 10px;
}

.article-header__headline {
  font-family: var(--font-display);
  font-size: clamp(1.7rem, 4vw, 2.8rem);
  font-weight: 700;
  line-height: 1.12;
  margin-bottom: 14px;
}

.article-header__standfirst {
  font-family: var(--font-serif);
  font-size: 1.1rem;
  color: #333;
  line-height: 1.6;
  margin-bottom: 18px;
  font-weight: 300;
}

.article-header__meta {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.78rem;
  color: var(--text-muted);
  padding: 12px 0;
  border-top: 1px solid var(--border);
}

.article-header__meta strong { color: var(--text-primary); }

.article-hero-image {
  width: 100%;
  max-height: 480px;
  object-fit: cover;
  display: block;
}

/* --- Article body ----------------------------------------- */
.article-body {
  max-width: 720px;
  margin: 32px auto;
  padding: 0 16px;
}

.article-body p {
  font-family: var(--font-serif);
  font-size: 1.05rem;
  line-height: 1.75;
  margin-bottom: 1.4em;
  color: #1a1a1a;
}

.article-body p:first-of-type::first-letter {
  font-family: var(--font-display);
  font-size: 4em;
  font-weight: 700;
  float: left;
  line-height: 0.8;
  margin: 0.05em 0.08em 0 0;
  color: var(--brand-blue);
}

.article-body h2 {
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 700;
  margin: 2em 0 0.6em;
  line-height: 1.25;
}

.article-body h3 {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 700;
  margin: 1.6em 0 0.5em;
}

/* Pull quote */
.pull-quote {
  border-left: 4px solid var(--brand-blue);
  margin: 2em 0;
  padding: 4px 0 4px 20px;
}

.pull-quote p {
  font-family: var(--font-display);
  font-size: 1.25rem !important;
  font-weight: 700;
  color: var(--brand-blue) !important;
  line-height: 1.4 !important;
  margin: 0 !important;
}

.pull-quote p::first-letter { all: unset; }

/* Key stats row */
.stat-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 1px;
  background: var(--border);
  margin: 2em -16px;
  border-top: 3px solid var(--brand-blue);
}

.stat-block {
  background: var(--bg-white);
  padding: 20px 16px;
  text-align: center;
}

.stat-block__number {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 700;
  color: var(--brand-blue);
  line-height: 1;
  margin-bottom: 4px;
}

.stat-block__label {
  font-size: 0.78rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* Media embeds */
.embed-wrap {
  margin: 2em -16px;
  background: #000;
}

.embed-wrap--chart {
  margin: 2em 0;
  background: var(--bg-white);
  border: 1px solid var(--border);
  padding: 20px;
}

.embed-wrap--chart canvas { width: 100% !important; }

/* iframe chart — for standalone HTML chart files or third-party embeds
   (Datawrapper, Flourish, Observable, D3, Plotly, etc.)
   Default height is 500px; override inline if your chart needs more or less. */
.embed-wrap--iframe {
  margin: 2em 0;
  border: 1px solid var(--border);
  background: var(--bg-white);
  overflow: hidden;
}

.embed-wrap--iframe iframe {
  display: block;
  width: 100%;
  height: 500px;    /* adjust per chart — or override inline with style="height:Xpx" */
  border: none;
}

.embed-wrap figcaption,
.embed-caption {
  font-size: 0.78rem;
  color: var(--text-muted);
  padding: 8px 16px;
  border-top: 1px solid var(--border);
  background: #fafafa;
}

.embed-wrap video,
.embed-wrap iframe {
  display: block;
  width: 100%;
  aspect-ratio: 16/9;
  border: none;
}

.embed-wrap img {
  width: 100%;
  max-height: 500px;
  object-fit: contain;
  background: #f0f0f0;
}

/* GIF inline */
.gif-wrap {
  margin: 1.5em 0;
  text-align: center;
}

.gif-wrap img {
  max-height: 320px;
  margin: 0 auto;
  border: 1px solid var(--border);
}

/* Interactive chart container (Chart.js canvas) */
.chart-container {
  position: relative;
  width: 100%;
  height: 340px;
}

/* ============================================================
   UTILITY
   ============================================================ */
.visually-hidden {
  position: absolute; width: 1px; height: 1px;
  overflow: hidden; clip: rect(0,0,0,0);
}

.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 24px 0;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
