/* State of States (2016 and 2020 editions) – site styles (Bootstrap 5.3 + these overrides). Kingmakers brand: charcoal + green. */
:root {
  --sos-ink: #1f2933;
  --sos-muted: #5b6670;          /* 5.9:1 on white */
  --sos-brand: #2f7d2b;          /* darker take on the old #5dbb58 for text contrast */
  --sos-brand-bright: #5dbb58;
  --sos-nav: #1d2530;
  --sos-orange: #b8501f;         /* tiles: old #e97745 / #7d158d / #a2e000, adjusted for 4.5:1 with white text */
  --sos-purple: #7d158d;
  --sos-lime: #4f7a00;
  --sos-green: #3d6b37;
  --sos-red: #b3261e;
  --bs-body-font-size: 1rem;     /* 16px base */
  --bs-body-line-height: 1.5;
  --bs-link-color-rgb: 33, 98, 30;
  --bs-link-hover-color-rgb: 20, 70, 18;
}

html { scroll-padding-top: 5rem; }
body { color: var(--sos-ink); background: #f6f7f8; overflow-x: hidden; }
img { max-width: 100%; height: auto; }
a { text-underline-offset: .15em; }
.icon { width: 1em; height: 1em; fill: currentColor; vertical-align: -.125em; flex: none; }
.icon-xl { width: 4rem; height: 4rem; }
.visually-hidden-focusable:focus { position: fixed !important; top: .5rem; left: .5rem; z-index: 2000; background: #fff; padding: .5rem 1rem; }
.tabular { font-variant-numeric: tabular-nums; }

/* ---------- navbar ---------- */
.sos-navbar { background: var(--sos-nav); }
.sos-navbar .navbar-brand img { height: 34px; width: auto; }
.sos-navbar .nav-link { color: #e8ecef; padding: .75rem .9rem; min-height: 44px; display: flex; align-items: center; gap: .4rem; }
.sos-navbar .nav-link:hover, .sos-navbar .nav-link:focus-visible { color: #fff; background: rgba(255,255,255,.08); }
.sos-navbar .nav-link.active { color: #fff; box-shadow: inset 0 -3px 0 var(--sos-brand-bright); }
.sos-navbar .navbar-toggler { border-color: var(--sos-brand-bright); min-width: 44px; min-height: 44px; }
.sos-navbar .dropdown-item { padding: .6rem 1rem; min-height: 44px; display: flex; align-items: center; gap: .5rem; }
.sos-states-menu { max-height: min(70vh, 32rem); overflow-y: auto; min-width: 16rem; }
.sos-states-menu .dropdown-item img { width: 24px; height: 24px; }
@media (min-width: 1200px) {
  .sos-states-menu { columns: 2; column-gap: 0; min-width: 26rem; }
  .sos-states-menu li { break-inside: avoid; }
}
/* edition switcher: "2016 Rankings | 2020 Rankings" (shared partial _EditionSwitcher) */
.sos-editions { display: flex; border: 1px solid rgba(255,255,255,.35); border-radius: .4rem; overflow: hidden; }
.sos-edition { display: flex; align-items: center; justify-content: center; min-height: 40px; padding: .35rem .7rem; color: #e8ecef; text-decoration: none; white-space: nowrap; }
.sos-edition + .sos-edition { border-left: 1px solid rgba(255,255,255,.35); }
.sos-edition:hover, .sos-edition:focus-visible { color: #fff; background: rgba(255,255,255,.1); }
.sos-edition.is-current { background: var(--sos-brand-bright); color: #0e1f0d; font-weight: 600; }
.sos-editions-item { display: flex; align-items: center; padding-inline: .4rem; }
.sos-navbar .nav-link { white-space: nowrap; }
@media (min-width: 1200px) and (max-width: 1399.98px) {
  /* the edition switcher made the xl navbar ~120px wider: tighten spacing so it stays on one line at 1200px */
  .sos-navbar .nav-link { padding-inline: .55rem; }
  .sos-edition { padding-inline: .5rem; }
  .sos-editions-item { padding-inline: .25rem; }
}
@media (max-width: 1199.98px) {
  .sos-editions-item { padding: .5rem 0; }
  .sos-editions { flex: 1; }
  .sos-edition { flex: 1; min-height: 44px; }
}
@media (max-width: 1199.98px) {
  .sos-navbar .navbar-collapse { max-height: calc(100vh - 60px); overflow-y: auto; padding-bottom: 1rem; }
  .sos-navbar .dropdown-menu { background: #26303c; border: 0; }
  .sos-navbar .dropdown-item { color: #e8ecef; }
  .sos-navbar .dropdown-item:hover, .sos-navbar .dropdown-item:focus { background: rgba(255,255,255,.1); color: #fff; }
  .sos-states-menu { max-height: 50vh; }
}

/* ---------- page chrome ---------- */
main { padding-block: 1.25rem 2.5rem; }
.sos-page-title { font-size: clamp(1.6rem, 1.2rem + 1.8vw, 2.4rem); font-weight: 700; margin-bottom: .75rem; }
.breadcrumb { font-size: .95rem; margin-bottom: .75rem; }
.breadcrumb a { display: inline-block; padding-block: .35rem; }
.sos-card { background: #fff; border-radius: .5rem; box-shadow: 0 1px 2px rgba(16,24,40,.08); padding: 1.25rem; }
.sos-intro p:last-child { margin-bottom: 0; }
.sos-intro li { margin-bottom: .35rem; }
.sos-intro li a, .sos-footnote a, .sos-prose a { display: inline-block; padding-block: .2rem; }
.sos-section-title { font-size: 1.25rem; font-weight: 700; letter-spacing: .02em; color: var(--sos-muted); text-transform: uppercase; margin: 1.75rem 0 .75rem; }
.sos-footnote { color: var(--sos-muted); font-size: .95rem; margin-top: 1.25rem; }
.sos-footer { background: var(--sos-nav); color: #cfd6dc; padding-block: 1.25rem; font-size: .95rem; }
.sos-footer a { color: #fff; display: inline-block; padding: .4rem .25rem; }
.sos-prose { max-width: 75ch; }
.sos-prose img { display: block; margin: 1rem auto; }
.sos-formula { text-align: center; font-weight: 700; font-size: 1.15rem; overflow-wrap: anywhere; }

/* ---------- home ---------- */
.sos-hero-img { display: block; border-radius: .5rem; background: #fff; }
.sos-hero-img img { border-radius: .5rem; }
.sos-zoom-hint { font-size: .9rem; color: var(--sos-muted); display: flex; gap: .35rem; align-items: center; justify-content: center; margin-top: .4rem; }
dialog.sos-lightbox { border: 0; padding: 0; max-width: 100vw; max-height: 100vh; width: 100vw; height: 100vh; background: #000; }
dialog.sos-lightbox::backdrop { background: rgba(0,0,0,.85); }
.sos-lightbox-scroll { width: 100%; height: 100%; overflow: auto; -webkit-overflow-scrolling: touch; touch-action: pan-x pan-y pinch-zoom; }
.sos-lightbox-scroll img { max-width: none; width: max(100%, 1400px); }
.sos-lightbox--small .sos-lightbox-scroll { background: #fff; }
.sos-lightbox--small .sos-lightbox-scroll img { width: max(100%, 900px); } /* 2016 map: 437px original, shown at ~2x so the labels can be read */
.sos-lightbox-close { position: fixed; top: .75rem; right: .75rem; width: 48px; height: 48px; border-radius: 50%; border: 0; background: #fff; display: grid; place-items: center; }

/* ---------- rankings table / cards ---------- */
.sos-toolbar { display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; justify-content: space-between; margin-bottom: .75rem; }
.sos-search { position: relative; flex: 1 1 16rem; max-width: 24rem; }
.sos-search .form-control { padding-left: 2.4rem; min-height: 44px; font-size: 1rem; }
.sos-search .icon { position: absolute; left: .85rem; top: 50%; transform: translateY(-50%); color: var(--sos-muted); }
.sos-count { color: var(--sos-muted); font-size: .95rem; }
.sos-rank-table { width: 100%; border-collapse: separate; border-spacing: 0; background: #fff; border-radius: .5rem; box-shadow: 0 1px 2px rgba(16,24,40,.08); }
.sos-rank-table th, .sos-rank-table td { padding: .6rem .75rem; vertical-align: middle; }
.sos-rank-table thead th { position: sticky; top: var(--sos-sticky-top, 0px); z-index: 2; background: #e9eef2; color: #2b3640; font-size: .8rem; letter-spacing: .03em; text-transform: uppercase; border-bottom: 2px solid #cfd8df; }
.sos-rank-table thead th:first-child { border-top-left-radius: .5rem; }
.sos-rank-table thead th:last-child { border-top-right-radius: .5rem; }
.sos-rank-table tbody tr:nth-child(even) { background: #f7f9fa; }
.sos-rank-table tbody tr:hover { background: #eef6ed; }
.sos-rank-table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.sos-rank-table td a { display: inline-block; padding-block: .35rem; }
.sos-rank { display: inline-grid; place-items: center; min-width: 2.6rem; height: 2.6rem; padding: 0 .4rem; border-radius: 1.3rem; background: var(--sos-nav); color: #fff; font-weight: 700; font-variant-numeric: tabular-nums; }
.sos-rank--top { background: var(--sos-brand); }
.sos-state { display: flex; align-items: center; gap: .65rem; font-weight: 600; font-size: 1.05rem; }
.sos-state img { width: 40px; height: 40px; object-fit: contain; flex: none; }
.sos-state a { min-height: 44px; display: inline-flex; align-items: center; }
.sos-empty { padding: 2rem; text-align: center; color: var(--sos-muted); }

@media (max-width: 767.98px) {
  /* below 768px each row becomes a compact card */
  .sos-rank-table { background: transparent; box-shadow: none; }
  .sos-rank-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .sos-rank-table, .sos-rank-table tbody, .sos-rank-table tr, .sos-rank-table td, .sos-rank-table tbody th { display: block; }
  .sos-rank-table tbody tr { display: grid; grid-template-columns: auto 1fr; gap: .25rem .75rem; background: #fff !important; border-radius: .5rem; box-shadow: 0 1px 2px rgba(16,24,40,.1); padding: .75rem; margin-bottom: .6rem; }
  .sos-rank-table td, .sos-rank-table tbody th { padding: 0; }
  .sos-rank-table .sos-col-rank { grid-row: 1 / span 1; align-self: center; }
  .sos-rank-table .sos-col-state { align-self: center; }
  .sos-rank-table td.num { grid-column: 1 / -1; display: flex; justify-content: space-between; gap: 1rem; text-align: right; white-space: normal; border-top: 1px solid #edf0f2; padding-top: .35rem; }
  .sos-rank-table td.num::before { content: attr(data-label); text-align: left; color: var(--sos-muted); font-size: .85rem; text-transform: uppercase; letter-spacing: .02em; flex: 1 1 50%; }
  .sos-rank-table td.num > * { flex: 0 1 auto; overflow-wrap: anywhere; }
}

/* ---------- state pages ---------- */
.sos-overall { text-align: center; color: #3b4462; }
.sos-overall .value { font-size: clamp(4rem, 3rem + 5vw, 7rem); font-weight: 800; line-height: 1; display: block; }
.sos-overall .label { font-weight: 700; letter-spacing: .05em; }
.sos-overall a { color: inherit; text-decoration: none; display: block; }
.sos-overall a:hover .label { text-decoration: underline; }
.sos-stat { text-align: center; padding: .75rem .5rem; }
.sos-stat .value { display: block; font-size: clamp(1.5rem, 1.1rem + 1.4vw, 2.3rem); font-weight: 700; line-height: 1.15; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.sos-stat .label { display: block; font-weight: 600; font-size: .95rem; margin-top: .2rem; }
.sos-stat--box { border-radius: .5rem; color: #fff; }
.sos-tiles { display: grid; gap: .75rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 15rem), 1fr)); margin-block: 1.25rem; }
.sos-tile { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1rem 1.25rem; border-radius: .6rem; color: #fff; text-decoration: none; min-height: 7rem; }
.sos-tile:hover, .sos-tile:focus-visible { color: #fff; filter: brightness(1.08); text-decoration: none; }
.sos-tile .icon { width: 3.25rem; height: 3.25rem; opacity: .9; }
.sos-tile .rank { text-align: right; }
.sos-tile .rank b { display: block; font-size: .8rem; letter-spacing: .06em; }
.sos-tile .rank { min-width: 0; }
.sos-tile .rank-num { display: block; font-size: 2.6rem; font-weight: 800; line-height: 1; }
.sos-tile .name { display: block; font-size: 1.1rem; font-weight: 600; margin-top: .35rem; overflow-wrap: break-word; }
.sos-tile--orange { background: var(--sos-orange); }
.sos-tile--purple { background: var(--sos-purple); }
.sos-tile--lime { background: var(--sos-lime); }
.sos-tile .rank-note { display: block; font-size: 1rem; font-weight: 700; }
.sos-key-figure { text-align: center; color: #3b4462; }
.sos-key-figure .value { display: block; font-size: clamp(1.8rem, 1.4rem + 1.6vw, 2.8rem); font-weight: 700; line-height: 1.1; overflow-wrap: anywhere; }
.sos-key-figure .label { font-weight: 600; font-size: .95rem; }
.sos-perf { border-radius: .6rem; color: #fff; padding: 1rem 1.25rem; margin-top: 1.25rem; }
.sos-perf h2 { font-size: 1.25rem; display: flex; gap: .5rem; align-items: center; }
.sos-perf table { width: 100%; color: inherit; font-size: 1.05rem; }
.sos-perf th, .sos-perf td { padding: .45rem .25rem; border-bottom: 1px solid rgba(255,255,255,.25); }
.sos-perf td:last-child, .sos-perf th:last-child { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.sos-perf a { color: #fff; display: inline-block; padding-block: .3rem; }
.sos-perf--good { background: #3f6a36; }
.sos-perf--bad { background: var(--sos-red); }
.sos-gender { display: flex; gap: 1.25rem; justify-content: center; flex-wrap: wrap; font-size: 1.6rem; font-weight: 700; }
.sos-gender span { display: inline-flex; align-items: center; gap: .3rem; }

/* text colours carried over from the old pages (darkened where needed for 4.5:1 contrast) */
.fg-green { color: #2f7a22; } .fg-pink { color: #b3248b; } .fg-blue { color: #2b1bb8; } .fg-teal { color: #3a7360; }
.fg-amber { color: #8a5a00; } .fg-sage { color: #3f7a4b; } .fg-maroon { color: #8f2e2e; } .fg-brown { color: #8a5728; }
.fg-olive { color: #5d5c1e; } .fg-forest { color: #116b03; } .fg-sea { color: #34735a; } .fg-plum { color: #585074; }
.fg-violet { color: #a12f6c; } .fg-slate { color: #5d6684; } .fg-navy { color: #1c3755; } .fg-rust { color: #b4501f; }
.fg-grey { color: #6b6262; } .fg-dpurple { color: #7d158d; } .fg-lime { color: #4f7a00; } .fg-ochre { color: #9a5a12; } .fg-steel { color: #4a6f6d; }
.bg-forest { background: #3b6b3c; } .bg-navy { background: #1d2e58; }

/* ---------- charts ---------- */
.sos-chart { background: #fff; border-radius: .5rem; box-shadow: 0 1px 2px rgba(16,24,40,.08); padding: .75rem 1rem 1rem; margin: 0 0 1rem; }
.sos-chart figcaption { font-weight: 600; font-size: .98rem; margin-bottom: .5rem; }
.sos-chart-canvas { position: relative; width: 100%; }
.sos-chart details { margin-top: .5rem; font-size: .9rem; }
.sos-chart summary { cursor: pointer; color: var(--bs-link-color); min-height: 44px; display: flex; align-items: center; }
.sos-chart .table { font-size: .9rem; margin-bottom: 0; }
.sos-pie { text-align: center; }
.sos-pie .sos-chart-canvas { max-width: 220px; margin-inline: auto; }
.sos-pie figcaption { order: 2; font-size: .85rem; margin: .4rem 0 0; }
.sos-chart-wrap { overflow-x: auto; }
.h-150 { height: 150px; } .h-200 { height: 200px; } .h-300 { height: 300px; }
@media (max-width: 575.98px) { .h-300 { height: 260px; } }

/* ---------- all states grid ---------- */
.sos-state-grid { display: grid; gap: .75rem; grid-template-columns: repeat(auto-fill, minmax(9.5rem, 1fr)); }
.sos-state-card { display: flex; flex-direction: column; align-items: center; gap: .4rem; padding: 1rem .5rem; background: #fff; border-radius: .5rem; box-shadow: 0 1px 2px rgba(16,24,40,.08); text-decoration: none; color: var(--sos-ink); font-weight: 600; text-align: center; min-height: 44px; }
.sos-state-card:hover, .sos-state-card:focus-visible { box-shadow: 0 0 0 3px var(--sos-brand-bright); color: var(--sos-ink); }
.sos-state-card img { width: 64px; height: 64px; object-fit: contain; }
.sos-state-card small { color: var(--sos-muted); font-weight: 400; }

/* ---------- indicators overview ---------- */
.sos-indicator-table th[scope=rowgroup] { background: #e9eef2; font-size: 1.05rem; }
.sos-indicator-table td, .sos-indicator-table th { padding: .55rem .75rem; }
.sos-indicator-table a { display: inline-block; padding-block: .25rem; }

/* ---------- forms ---------- */
.form-control, .btn { min-height: 44px; font-size: 1rem; }

/* ---------- 2016 Business Environment page ---------- */
.sos-pairs { display: grid; grid-template-columns: auto 1fr; gap: .35rem 1rem; margin: 0; align-items: baseline; }
.sos-pairs dt { font-weight: 700; display: flex; gap: .4rem; align-items: baseline; }
.sos-pairs dd { margin: 0; font-variant-numeric: tabular-nums; }
.sos-mini-table { table-layout: fixed; width: 100%; }
.sos-mini-table caption { caption-side: top; font-weight: 700; color: var(--sos-ink); padding: .6rem .75rem .25rem; }
.sos-mini-table caption .icon { margin-right: .35rem; }
.sos-mini-table col.sos-col-label { width: 34%; }
.sos-mini-table th, .sos-mini-table td { overflow-wrap: anywhere; }
.sos-mini-table th, .sos-mini-table td { padding: .45rem .6rem; font-size: .95rem; }
.sos-mini-table thead th { font-size: .8rem; color: var(--sos-muted); font-weight: 600; vertical-align: bottom; }
.sos-mini-table tbody th { font-size: .85rem; }
.sos-db-card h3 { min-height: 2.5em; }