/* ─── Reset & Base ─── */
body, html {
  margin: 0;
}
html {
  overflow-x: clip;
}
body, html, .wealth-wrapper-outer, .wealth-row {
  min-height: 100%;
}

/* ─── Title Screen ─── */
.title-screen {
  width: 100%;
  height: 100vh;
  height: 100dvh;
  position: relative;
}
h1 {
  text-align: center;
  font-size: 60px;
  line-height: 0.9;
  width: 100%;
  margin-top: 100px;
}
.inspired-by {
  position: absolute;
  bottom: 16px;
  right: 1em;
  font-size: 12px;
  color: #00000055;
  margin: 0;
}
.inspired-by a {
  color: inherit;
  text-decoration: underline;
}
a {
    color: inherit;
}
.scroll-this-way {
  width: 165px;
  height: 360px;
  position: absolute;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 48px;
  font-size: 30px;
  color: #00000033;
  background-image: url(img/down.svg);
  background-repeat: no-repeat;
  background-size: 50%;
  background-position: 50px 50px;
  animation: bouncy-arrow 3s infinite;
}
.language-menu {
  position: absolute;
  top: 18px;
  right: 18px;
  z-index: 4;
}
.language-menu-trigger {
  border: 0;
  background: transparent;
  color: #333;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.04em;
  cursor: pointer;
  padding: 2px 0;
}
.language-menu-trigger:hover,
.language-menu-trigger:focus-visible {
  color: #000;
  outline: none;
}
.language-menu-panel {
  margin-top: 8px;
  min-width: 92px;
  border: 1px solid rgba(0, 0, 0, 0.18);
  background: #e0e0e0;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.12);
  border-radius: 4px;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.language-menu-panel[hidden] {
  display: none;
}
.language-menu-item {
  border: 0;
  border-radius: 4px;
  background: transparent;
  text-align: left;
  font-size: 13px;
  padding: 6px 8px;
  color: #222;
  cursor: pointer;
}
.language-menu-item:hover,
.language-menu-item:focus-visible {
  background: #f2f2f2;
  outline: none;
}
.language-menu-item.is-active,
.language-menu-item:disabled {
  color: #000;
  cursor: default;
  background: #f8f8f8;
}
@keyframes bouncy-arrow {
  0%   { background-position: 50px 50px; }
  20%  { background-position: 50px 50px; }
  25%  { background-position: 50px 70px; }
  30%  { background-position: 50px 45px; }
  35%  { background-position: 50px 70px; }
  40%  { background-position: 50px 50px; }
  100% { background-position: 50px 50px; }
}

/* ─── Layout ─── */
.wealth-wrapper-outer {
  font-family: sans-serif;
  overflow: visible;
  display: block;
}
.wealth-row {
  display: flex;
  flex-direction: column;
}
.wealth-wrapper {
  margin: 3em 1em;
}

/* ─── Arrow ─── */
.arrow {
  margin-top: -7.5px;
  margin-left: 5px;
}

/* ─── Wealth Bars ─── */
.wealth {
  background-color: black;
  align-items: center;
  display: flex;
  flex-direction: column;
}
.title {
  margin-bottom: 5px;
}
.wealth-title {
  align-self: flex-start;
  margin-bottom: 5px;
  margin-top: 0;
  color: black;
  background: transparent;
  box-sizing: border-box;
}
.wealth > .wealth-title {
  flex-basis: auto;
  padding: 10px;
}
.billion .wealth > .wealth-title {
  flex-basis: auto;
  position: static;
}
.wealth-header {
  position: sticky;
  top: 0;
  z-index: 3;
  align-self: flex-start;
  width: calc(100% - 90px);
}
.wealth-header .wealth-title {
  padding-left: 4px;
}

/* ─── Calibration Bars ─── */
.one-thousand {
  width: 1px;
  height: 1px;
  margin-top: 5px;
}
.median {
  height: 200px;
  width: 100%;
}
.median .wealth {
  width: 7.94px;
  height: 7.94px;
}
.million {
  height: 200px;
  width: 100%;
}
.million .wealth {
  width: 33.62px;
  height: 33.62px;
  background-color: #4CAF50;
}
.billion .wealth {
  height: var(--billion-h, 2000px);
  width: var(--bar-width-billion, 500px);
  background-color: #03A9F4;
}
.richest .wealth {
  height: var(--richest-h);
  width: var(--bar-width, 500px);
  background-color: #ff5c5c;
}
.all-billionaires .wealth {
  margin-top: 1000px;
  height: var(--all-billionaires-h);
  width: var(--bar-width, 500px);
  background-color: #571212;
}

.scroll-progress-track {
  position: relative;
  width: 24px;
  height: 175px;
  margin: 4px 33px;
  overflow: hidden;
  background: #e0e0e0;
  border: 3px solid #000;
}
.scroll-progress-track[hidden] {
  display: none;
}

.scroll-progress-fill {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 0;
  background: #333;
}

#richest-scroll-fill {
  background: #28b10b;
}

#allBillionaires-scroll-fill {
  background: #28b10b;
}

#allBillionaires-title {
  align-self: flex-start;
  margin-bottom: 5px;
  margin-top: 0;
  color: #e1e1e1;
  background: transparent;
  box-sizing: border-box;
}

/* ─── Ruler & Scale Key ─── */
.ruler {
  background-image: url('img/ruler-vert.svg');
  background-repeat: repeat-y;
  background-position: right 0;
  background-size: 30px 160px;
}
#allBillionaires.wealth.ruler{
  background-image: url('img/ruler-vert-allbillionaires.svg');
  background-repeat: repeat-y;
  background-position: right 0;
  background-size: 30px 160px;
}

.key {
  position: sticky;
  top: 0;
  align-self: flex-end;
  margin-right: 35px;
  margin-left: 0;
  width: 25px;
  height: 160px;
  flex-shrink: 0;
  background: url(img/scale-vert.svg) no-repeat right center;
  background-size: 9px 160px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
}
.key > span {
  display: inline-block;
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  font-size: 11px;
  white-space: nowrap;
  padding: 1px 0;
}
.richest .key {
  margin-right: 35px;
}
.all-billionaires .key {
  color: #e1e1e1;
  margin-right: 35px;
  background: url(img/scale-vert-allbillionaires.svg) no-repeat right center;
}


.counter {
  color: black;
  padding: 5px;
  min-width: 140px;
  background: transparent;
}

#richest-counter {
  margin-left: 28px;
}

#allBillionaires-counter {
  margin-left: 28px;
  color: #e1e1e1;
}

.title a {
  color: inherit;
}

/* ─── Infoboxes (comparison items inside bars) ─── */
.infobox {
  z-index: 1;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  content-visibility: auto;
  contain-intrinsic-size: auto 100vh;
}
.infobox .title,
.infobox .comparison-rect-wrapper {
  font-weight: normal;
  line-height: 1.4;
  width: 75vw;
  max-width: 600px;
  text-align: center;
  margin-left: auto;
  margin-right: auto;
}
.infobox ul {
  text-align: left;
  display: inline-block;
  margin: 0.5em auto;
}
.share-inline-row {
  margin-top: 12px;
}
.share-inline-btn {
  background: #e0e0e0;
  color: #000;
  border-width: 3px;
  border-radius: 4px;
  font-size: 14px;
  font-weight: 600;
  padding: 9px 14px;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}
.share-inline-btn:hover,
.share-inline-btn:focus-visible {
  background: #a6a6a6;
  outline: none;
}

/* ─── Sticky centering for infobox content ─── */
.text-infobox .title,
.infobox .comparison-rect-wrapper:not(.comparison-rect-large) {
  position: sticky;
  top: 50%;
  transform: translateY(-50%);
  margin-left: auto;
  margin-right: auto;
  margin-top: 25vh;
  margin-bottom: 25vh;
}
.cause-card,
.summary-card,
.comparison-image-wrapper {
  position: sticky;
  top: 50%;
  transform: translateY(-50%);
}

/* ─── Comparison Rectangles ─── */
.infobox .comparison-rect-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
}
.comparison-rect {
  margin-top: 8px;
}
.comparison-rect-label {
  color: inherit;
}
.comparison-rect-medium .comparison-rect {
  margin-top: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.comparison-rect-medium .comparison-rect-label {
  text-align: center;
}
.comparison-rect-large {
  width: 90%;
  max-width: none;
  margin-left: auto;
  margin-right: auto;
}
.comparison-rect-large .comparison-rect {
  margin-top: 0;
}
.comparison-rect-large .comparison-rect-label {
  position: sticky;
  top: 50%;
  transform: translateY(-50%);
  display: block;
  text-align: center;
  z-index: 1;
  margin-top: 25vh;
  margin-bottom: 25vh;
}

/* ─── Bar Segments ─── */
.bar-segment {
  display: block;
}
.all-billionaires .wealth-header,
.all-billionaires .key {
  z-index: 3;
}
.all-billionaires .infobox {
  height: auto;
  min-height: 100vh;
  color: #e1e1e1;
}

/* ─── Image Comparisons ─── */
.comparison-image-wrapper {
  width: 75vw;
  max-width: 700px;
  text-align: center;
}
.comparison-image-wrapper .title {
  margin-bottom: 12px;
}
.comparison-image {
  max-width: 100%;
  height: auto;
  border-radius: 6px;
}

/* ─── Cause Cards ─── */
.cause-card {
  width: 75vw;
  max-width: 560px;
}
.cause-pie {
  position: relative;
  display: inline-block;
  margin-bottom: 12px;
}
.cause-pie .piechart-outer {
  width: 120px;
  height: 120px;
  transform: rotate(-38deg);
  background: #fff;
  border-radius: 50%;
}
.cause-pie .piechart-inner {
  fill: #28b10b;
  stroke: #fff;
  stroke-width: 32;
}
.pie-label {
  position: absolute;
  left: 130px;
  top: 42px;
  font-size: 20px;
  font-weight: bold;
  white-space: nowrap;
  color:#000000c9;
}
.cause-card .pie-label {
  position: absolute;
  left: 130px;
  top: 42px;
  font-size: 20px;
  font-weight: bold;
  white-space: nowrap;
  color:#a5a5a5;
}
.cause-title {
  margin: 8px 0 4px;
  font-size: 22px;
}
.cause-cost {
  font-size: 15px;
  color: #e1e1e1;
  margin-bottom: 8px;
}
.cause-desc {
  line-height: 1.5;
  margin-bottom: 10px;
}
.cause-desc a {
  color: inherit;
}
.cause-deaths {
  background: #000;
  border-left: 4px solid #902323;
  padding: 8px 12px;
  margin: 10px 0;
  font-size: 14px;
}
.pocket-change {
  background: #f3f8ff;
  border-left: 4px solid #1565C0;
  padding: 8px 12px;
  margin: 10px 0;
  font-size: 14px;
  font-style: italic;
}
.cause-source {
  font-size: 12px;
  color: #e1e1e1;
  margin-top: 8px;
}
.cause-source a {
  color: inherit;
}

/* ─── Summary Cards ─── */
.summary-card {
  width: 75vw;
  max-width: 560px;
}
.side-by-side-chart {
  margin: 16px 0;
}
.bar-row {
  display: flex;
  align-items: center;
  margin: 4px 0;
  font-size: 13px;
}
.bar-label {
  width: 160px;
  flex-shrink: 0;
  text-align: right;
  padding-right: 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.bar-track {
  flex: 1;
  height: 18px;
  background: #e8e8e8;
  border-radius: 3px;
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  background: #c3aa2a;
  border-radius: 3px;
  min-width: 2px;
}
.bar-amount {
  width: 70px;
  flex-shrink: 0;
  padding-left: 8px;
  font-weight: bold;
  white-space: nowrap;
}
.summary-total {
  margin: 12px 0;
  font-size: 16px;
  padding: 8px 0;
  border-top: 2px solid #333;
}
.summary-pie {
  margin-top: 12px;
}
.summary-pie .piechart-outer {
  width: 180px;
  height: 180px;
}

/* ─── Death Ticker ─── */
.death-ticker {
  position: fixed;
  bottom: 12px;
  right: 53px;
  z-index: 100;
  background: #050505;
  color: #000;
  padding: 10px 16px 8px 12px;
  border: 3px solid;
  border-color: #902323;
  border-radius: 4px;
  font-family: sans-serif;
  font-size: 13px;
  font-weight: 400;
  max-width: 400px;
  max-height: calc(80vh - 40px);
  overflow-y: auto;
  box-shadow: 0 4px 20px rgba(0,0,0,0.2);
}
.death-ticker-close {
  position: absolute;
  top: 3px;
  right: 2px;
  background: none;
  border: none;
  color: #fff;
  font-size: 20px;
  font-weight: 400;
  cursor: pointer;
  z-index: 101;
  opacity: 0.7;
  transition: opacity 0.2s;
}
.death-ticker-close:hover {
  opacity: 1;
}
.death-ticker-reopen {
  position: fixed;
  bottom: 16px;
  right: 53px;
  z-index: 101;
  background: #050505;
  color: #fff;
  padding: 12px 16px 10px 16px;
  border: 3px solid;
  border-color: #902323;
  border-radius: 4px;
  width: 44px;
  height: 44px;
  font-size: 22px;
  font-weight: 400;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.8;
  transition: opacity 0.2s;
}
.death-ticker-reopen:hover {
  opacity: 1;
}
.next-message-btn {
  position: fixed;
  bottom: 16px;
  left: calc(max(16px, env(safe-area-inset-left)) + 14px);
  z-index: 101;
  background: #e0e0e0;
  color: #000;
  border-width: 3px;
  border-radius: 4px;
  height: 44px;
  padding: 0 16px;
  font-size: 14px;
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
  cursor: pointer;
  opacity: 0.88;
  transition: opacity 0.2s;
}
.next-message-btn:hover {
  background: #a6a6a6;
}
.next-message-btn:disabled,
.next-message-btn.is-scrolling {
  opacity: 0.45;
  cursor: default;
}
.death-ticker-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  margin-bottom: 6px;
  margin-right: 10px;
}
.ticker-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 2px 0;
}
.ticker-count {
  font-weight: bold;
  font-size: 15px;
  color: #ff6b6b;
  margin-right: 8px;
  font-variant-numeric: tabular-nums;
}
.ticker-label {
  color: #ccc;
}
.ticker-total {
  border-top: 1px solid rgb(255 255 255 / 31%);
  margin-top: 4px;
  padding-top: 6px;
  font-weight: bold;
}
.ticker-total {
  font-size: 17px;
  color: #ff4444;
}
.ticker-count {
    font-size: 24px;
    color: #ff4444;
}
.ticker-total .ticker-label {
  color: #fff;
}
.ticker-group + .ticker-group {
  margin-top: 5px;
  padding-top: 5px;
  border-top: 1px solid rgb(255 255 255 / 31%);
}
.ticker-group-total .ticker-label {
  color: #fff;
  font-size: 10px;
  font-weight: bold;
}
.ticker-count-group {
  color: #ff8c8c;
  font-size: 14px;
}
.ticker-group-causes {
  color: #9fb0bc;
  font-size: 10px;
  line-height: 1.3;
  margin: 1px 0 0 0;
  text-align: right;
}
.ticker-item {
  padding-left: 8px;
}
.ticker-item .ticker-count {
  font-size: 12px;
  color: #cc5555;
}
.ticker-item .ticker-label {
  font-size: 11px;
  color: #999;
}

/* ─── Mobile ─── */
@media (max-width: 450px) {
  .language-menu {
    top: 12px;
    right: 12px;
  }
  .language-menu-trigger,
  .language-menu-item {
    font-size: 12px;
  }

  h1 {
    font-size: 40px;
  }
  h3 {
    font-size: 14px;
  }
  .wealth-title {
    font-size: 19px;
  }

  .bar-label {
    width: 90px;
    font-size: 11px;
  }
  .bar-amount {
    width: 55px;
    font-size: 11px;
  }
  .pie-label {
    left: 100px;
    top: 35px;
    font-size: 16px;
  }
  .cause-pie .piechart-outer {
    width: 90px;
    height: 90px;
  }

  /* Death ticker */
  .death-ticker {
    bottom: 4px;
    right: 4px;
    font-size: 11px;
    max-width: 200px;
  }
  .next-message-btn {
    bottom: 8px;
    left: calc(max(8px, env(safe-area-inset-left)) + 10px);
    height: 38px;
    padding: 0 12px;
    font-size: 12px;
  }
  .ticker-count {
    font-size: 13px;
  }
}

/* ─── Desktop ─── */
@media (min-width: 1000px) {
  .infobox .title,
  .infobox .comparison-rect-wrapper {
    max-width: 750px;
  }
  .text-infobox .title {
    max-width: 550px;
  }
}
