:root {
  /* exact beige sampled from your logo background */
  --bg: #f2e8cf;
  --ink: #1e2e1e;
  --accent: #386641;
  --muted: #6a994e;
}

* {
  box-sizing: border-box
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, sans-serif
}

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 20px
}

/* header */
.site-header {
  display: flex;
  align-items: center;
  gap: 16px;
  justify-content: space-between
}

.logo {
  display: inline-flex;
  align-items: center;
  text-decoration: none
}

.logo img {
  height: 100px
}

/* bigger logo on every page */
.nav a {
  color: var(--accent);
  text-decoration: none;
  margin-left: 18px;
  font-weight: 600
}

/* hero */
.hero {
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
  margin: 18px 0
}

.hero img {
  width: 100%;
  height: 360px;
  object-fit: cover;
  border-radius: 14px;
  box-shadow: 0 2px 18px rgba(0, 0, 0, .08)
}

/* cards (softer, translucent) */
.card {
  background: rgba(255, 255, 255, .60);
  /* ~60% transparent */
  border-radius: 14px;
  padding: 18px;
  box-shadow: 0 2px 16px rgba(0, 0, 0, .06)
}

.btn {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  padding: 10px 14px;
  border-radius: 10px;
  text-decoration: none
}

/* grids */
.grid {
  display: grid;
  gap: 18px
}

.grid.two {
  grid-template-columns: 1fr 1fr
}

.grid.three {
  grid-template-columns: repeat(3, 1fr)
}

@media (max-width:900px) {

  .grid.two,
  .grid.three {
    grid-template-columns: 1fr
  }

  .hero img {
    height: 220px
  }
}

footer {
  margin: 40px 0;
  color: #444;
  text-align: center;
  font-size: 14px
}

/* About page layout */
.center {
  max-width: 850px;
  margin: 0 auto;
  text-align: center
}

.profile {
  background: rgba(255, 255, 255, .60);
  border-radius: 16px;
  padding: 16px;
  box-shadow: 0 2px 16px rgba(0, 0, 0, .06)
}

.profile img {
  width: 100%;
  border-radius: 14px;
  margin-bottom: 12px
}

.profile h3 {
  margin: 6px 0 4px
}

.profile p.small {
  margin: 0;
  color: #444;
  font-size: 14px
}

.profile a {
  color: var(--accent);
  text-decoration: none
}

/* Power BI embed: responsive + mobile scaling */
:root{
  /* page size you designed the report for (width / height) */
  --pbi-ar: 1200 / 1640;   /* if your canvas changes, update this */
}

/* wrapper keeps the correct aspect ratio */
.pbi-wrap{
  position: relative;
  width: 100%;
  aspect-ratio: var(--pbi-ar);
  border-radius: 12px;
  box-shadow: 0 2px 16px rgba(0,0,0,.08);
  background: var(--bg);
}

/* iframe fills the wrapper on desktop */
.pbi-wrap .pbi{
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  border-radius: 12px;
}

/* desktop: give it extra height floor if you like */
@media (min-width: 900px){
  .pbi-wrap { min-height: 1350px; } /* same effect as your old rule */
}

/* phones: scale the iframe so the whole report fits without user zoom */
@media (max-width: 900px){
  .pbi-wrap{ --pbi-scale: .45; }              /* tune .55–.65 to taste */

  .pbi-wrap .pbi{
    /* expand the iframe, then scale it down into the wrapper */
    width: calc(100% / var(--pbi-scale));
    height: calc(100% / var(--pbi-scale));
    transform: scale(var(--pbi-scale));
    transform-origin: top left;
  }
}


/* wider container for demo pages */
.container.wide {
  max-width: 1280px;
}

/* Make the entire card clickable but not look like a link */
a.card:link,
a.card:visited {
  display: block;
  color: var(--ink);
  text-decoration: none;
  cursor: pointer;
}

a.card:hover {
  box-shadow: 0 4px 18px rgba(0, 0, 0, .10);
  transform: translateY(-1px);
}

a.card:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 4px;
}

a.card p {
  color: var(--ink);
  text-decoration: none;
  margin: 0.4rem 0 0;
}

a.card h3 {
  margin: 0;
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}

a.card h3::after {
  content: " ↗";
  opacity: 0;
  transition: transform .15s ease, opacity .15s ease;
}

a.card:hover h3::after {
  opacity: 1;
  transform: translateX(2px);
}

/* =========================== BLOG THEME (scoped) Applies only inside: <main class="blog">…</main> =========================== */
/* Provide card + rule vars for the blog look */
:root {
  --rule: #d9d3bd;
  --card: #fffdf5;
}

/* Scope blog color tweaks so they don't leak site-wide */
.blog {
  --ink: #2a2a2a;
  --muted: #6b6b6b;
}

/* Layout and typography */
.blog article {
  max-width: 1100px;
  margin: 0 auto;
}

.blog section {
  margin: 28px 0 46px;
}

.blog article>header h1 {
  margin: 0 0 6px;
  font-size: 28px;
  letter-spacing: .2px;
  color: var(--accent);
}

.blog .small {
  font-size: 13px;
  color: #555
}

/* TOC bar */
.blog .toc {
  margin: 8px 0 18px;
  padding: 8px 0;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule)
}

.blog .toc a {
  margin-right: 14px;
  color: var(--accent);
  text-decoration: none
}

/* Lede card */
.blog .lede.card {
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: 10px;
  box-shadow: none;
  padding: 16px
}

.blog .hr {
  height: 1px;
  background: var(--rule);
  margin: 16px 0
}

/* Definition list spacing */
.blog .deflist dt {
  font-weight: 600
}

.blog .deflist dd {
  margin: 0 0 6px
}

/* Charts & figures */
.blog figure {
  margin: 0
}

.blog figcaption {
  margin-top: 4px;
  color: #444;
  font-size: 14px
}

/* Two-up grid used in the post */
.blog .grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  align-items: start
}

@media (max-width:900px) {
  .blog .grid-2 {
    grid-template-columns: 1fr
  }
}

/* Optional utilities */
.blog .caption {
  color: #6b654f;
  font-size: .9rem;
  margin-top: 4px
}

.blog .callout {
  background: #f4efdf;
  border-left: 4px solid #8a845f;
  padding: 10px 12px
}

/* Make links inside the article use the brand accent */
.blog article a {
  color: var(--accent)
}

/* ==== BLOG LAYOUT (scoped, minimal) ==== */
.blog-wrap {
  --rule: #d9d3bd;
  --card: #fffdf5;
}

.blog-wrap,
.blog-header,
.blog-inner,
.blog-wrap .toc {
  max-width: 1100px;
  margin: 0 auto
}

.blog-header {
  padding: 28px 18px 8px
}

.blog-header h1 {
  margin: 0 0 6px;
  font-size: 28px;
  letter-spacing: .2px;
  color: var(--accent)
}

.blog-header p {
  margin: 6px 0 0;
  color: #6b6b6b
}

.blog-wrap .toc {
  padding: 8px 18px;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule)
}

.blog-wrap .toc a {
  margin-right: 14px;
  color: var(--accent);
  text-decoration: none
}

.blog-inner {
  padding: 0 18px 44px;
  line-height: 1.55
}

.blog-inner section {
  margin: 28px 0 46px
}

.blog-inner h2 {
  margin: 6px 0 10px;
  font-size: 22px;
  color: var(--ink)
}

.blog-inner .small {
  font-size: 13px;
  color: #555
}

.blog-wrap .lede {
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: 10px;
  padding: 16px
}

.blog-wrap .hr {
  height: 1px;
  background: var(--rule);
  margin: 16px 0
}

.blog-wrap .deflist dt {
  font-weight: 600
}

.blog-wrap .deflist dd {
  margin: 0 0 6px 0
}

.blog-wrap figure {
  margin: 0
}

.blog-wrap figcaption {
  margin-top: 4px;
  color: #444;
  font-size: 14px
}

.blog-wrap .grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  align-items: start
}

@media (max-width:900px) {
  .blog-wrap .grid-2 {
    grid-template-columns: 1fr
  }
}

/* --- Charts: containers --- */
.blog-wrap .chart {
  width: 100%;
  min-height: 340px;
  margin: 8px 0 6px
}

.blog-wrap a {
  color: var(--accent)
}

/* --- Mobile chart fixes + sizing (SCOPED) --- */
.blog-wrap .chart,
.blog .chart {
  width: 100%;
  min-height: clamp(220px, 30vw, 360px);
  margin: 8px 0 12px;
}

/* Embedded Vega container always fills width */
.vega-embed {
  width: 100% !important;
  max-width: 100% !important;
  display: block
}

/* MOBILE: keep auto height so charts scale with width */
@media (max-width:900px) {
  .blog figure {
    margin-left: 0;
    margin-right: 0;
    margin-top: 1rem;
    margin-bottom: 1rem
  }

  .vega-embed>canvas,
  .vega-embed>svg {
    height: auto !important
  }
}

/* DESKTOP: let the SPEC control height (important fix) */
@media (min-width:901px) {

  .vega-embed>canvas,
  .vega-embed>svg {
    height: unset !important
  }

  /* if you ever set height:auto elsewhere, this wins on desktop */
}

/* Allow narrow phones to pan the dense 2×2 grid (last chart only) */
.chart-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

@media (max-width: 640px) {
  .chart-scroll .vega-embed {
    min-width: 720px;
  }

  /* gentle pan, not squish */
}

/* Tablet portrait tuning (iPad etc.) */
@media (min-width: 701px) and (max-width: 1024px) and (orientation: portrait){
  /* Lift the container floor so singles don't feel too short,
     but keep it aligned with the JS heights above. */
  .blog .chart, .blog-wrap .chart{
    min-height: clamp(300px, 52vw, 560px);
  }
  /* r1 tends to be sensitive; give it a slightly higher floor */
  #r1.chart{ min-height: 320px; }
}


/* ========================= BLOG-SCOPED TWEAKS ONLY ========================= */
.blog .site-header {
  margin-bottom: 18px
}

.blog article>header {
  margin-top: 4px;
  margin-bottom: 8px
}

.blog article>header h1 {
  font-size: 26px;
  line-height: 1.2;
  margin: 0 0 6px
}

.blog .toc {
  margin: 6px 0 14px;
  padding: 6px 0;
  border-top: 1px solid #ded7ba;
  border-bottom: 1px solid #ded7ba
}

.blog #ending .lede {
  background: #fffdf5;
  border: 1px solid #ded7ba;
  border-radius: 10px;
  padding: 12px 16px;
  box-shadow: none
}

/* Desktop chart whitespace rules */
@media (min-width:901px) {

  .blog .grid-2 .chart,
  .blog .grid-3 .chart {
    min-height: 0
  }

  .blog .desktop-only .chart {
    min-height: 340px
  }

  .blog .chart {
    margin-bottom: .5rem
  }

  .blog figure .small {
    margin-top: .5rem
  }
}

/* Visibility helpers */
.blog .desktop-only {
  display: block
}

.blog .mobile-only {
  display: none
}

@media (max-width:900px) {
  .blog .desktop-only {
    display: none
  }

  .blog .mobile-only {
    display: block
  }
}

/* ==== Chart sizing fix (scoped) ==== */
/* Always fill width */
.vega-embed {
  width: 100% !important;
  max-width: 100% !important;
  display: block;
}

/* Target the real Vega element (it's inside .vega-view, not a direct child) */
.vega-embed .vega-view>canvas,
.vega-embed .vega-view>svg {
  width: 100% !important;
  max-width: 100% !important;
}

/* Desktop: let the spec control height (remove our old auto height) */
@media (min-width: 901px) {

  .vega-embed .vega-view>canvas,
  .vega-embed .vega-view>svg {
    height: unset !important;
  }

  /* don't force a min-height on desktop containers */
  .blog .chart,
  .blog-wrap .chart {
    min-height: 0;
  }
}

/* Mobile: keep friendly auto height + edge-to-edge figures */
@media (max-width: 900px) {
  .blog figure {
    margin-left: 0;
    margin-right: 0;
  }

  .vega-embed .vega-view>canvas,
  .vega-embed .vega-view>svg {
    height: auto !important;
  }

  /* give charts vertical room on phones only */
  .blog .chart,
  .blog-wrap .chart {
    min-height: clamp(260px, 55vw, 420px);
    margin: 8px 0 12px;
  }
}

/* Desktop: let the spec height win (old behaviour) */
@media (min-width: 901px) {

  .vega-embed .vega-view>svg,
  .vega-embed .vega-view>canvas {
    height: unset !important;
  }

  .blog .chart,
  .blog-wrap .chart {
    min-height: 0;
  }

  /* no extra padding below */
}

/* Mobile: keep flexible height */
@media (max-width: 900px) {

  .vega-embed .vega-view>svg,
  .vega-embed .vega-view>canvas {
    height: auto !important;
  }
}

@media (max-width: 900px) {

  /* never force a tall box for the final grid on phones */
  #c4_4 {
    min-height: 0 !important;
  }
}

@media (max-width:900px) {

  /* keep charts inside the column on phones */
  .vega-embed,
  .vega-embed .vega-view {
    max-width: 100% !important;
  }

  .vega-embed {
    overflow-x: clip;
  }

  /* avoid any bleed */
}

/* charts should never overflow or collapse while the URL bar animates */
.chart {
  width: 100%;
  overflow: hidden;
  min-height: 160px;
}

/* let Vega control the height; just scale width */
.chart svg,
.chart canvas {
  display: block;
  max-width: 100%;
  height: auto;
}

/* r1 was most sensitive to the tiny viewport-height changes; give it a floor */
#r1.chart {
  min-height: 240px;
}

/* adjust to taste (220–260) */
/* More air between the logo (header) and the page title */
.site-header {
  margin-bottom: 1rem;
}

/* ~16px */
@media (min-width: 900px) {
  .site-header {
    margin-bottom: 1.25rem;
  }

  /* ~20px on desktop */
}


/* iPad PORTRAIT: tighten chart boxes to remove extra space */
@media (min-width: 768px) and (max-width: 1024px) and (orientation: portrait) {
  /* single charts */
  .blog .chart,
  .blog-wrap .chart {
    /* was effectively ~420px; bring it down */
    min-height: clamp(230px, 36vw, 360px) !important;
    margin: 6px 0 8px !important;   /* slightly tighter spacing */
  }

  /* two-up sections when stacked in one column on iPad portrait */
  .blog .grid-2 .chart,
  .blog-wrap .grid-2 .chart {
    min-height: clamp(200px, 28vw, 300px) !important;
  }

  /* captions a touch tighter too */
  .blog figcaption,
  .blog-wrap figcaption {
    margin-top: 3px;
  }
}

/* Phone LANDSCAPE: let containers match the chart height */
@media (max-width: 900px) and (orientation: landscape) {
  /* singles */
  .blog .chart, .blog-wrap .chart {
    /* keep a floor, but cap near the JS height (≈230px) */
    min-height: clamp(150px, 50vh, 240px);
    margin: 6px 0 8px; /* a touch tighter */
  }
  /* two-up grids */
  .blog .grid-2 .chart, .blog-wrap .grid-2 .chart {
    /* match JS ≈180px */
    min-height: clamp(140px, 45vh, 200px);
  }
}
