.hd {
  --hd-surface: #f5f0e8;
  --hd-ink: #1c1917;
  --hd-ink-2: #52514e;
  --hd-grid: #e1dbd0;
  --hd-axis: #c3bdb0;
  --hd-border: rgba(28, 25, 23, 0.16);
  --hd-raw: #a8a39a;
  --hd-band: rgba(28, 25, 23, 0.08);
  --hd-ideal: rgba(12, 163, 12, 0.32);
  --hd-s1: #2a78d6;
  --hd-s2: #eb6834;
  --hd-s3: #1baf7a;
  --hd-s4: #eda100;
  --hd-good: #0ca30c;
  --hd-warning: #fab219;
  --hd-critical: #d03b3b;
  color: var(--hd-ink);
}

/* Wider than the site's reading column, so charts can sit side by side. */
.container:has(.hd) {
  box-sizing: border-box;
  max-width: 1280px;
  padding-left: 20px;
  padding-right: 20px;
  width: 100%;
}

#main_content:has(.hd) {
  box-sizing: border-box;
  max-width: none;
  padding-left: 0;
  padding-right: 0;
  width: 100%;
}

html.dark-mode .hd {
  --hd-surface: #1c1917;
  --hd-ink: #f0efec;
  --hd-ink-2: #c3c2b7;
  --hd-grid: #33302c;
  --hd-axis: #48443f;
  --hd-border: rgba(255, 255, 255, 0.16);
  --hd-raw: #6d6962;
  --hd-band: rgba(255, 255, 255, 0.09);
  --hd-ideal: rgba(12, 163, 12, 0.45);
  --hd-s1: #3987e5;
  --hd-s2: #d95926;
  --hd-s3: #199e70;
  --hd-s4: #c98500;
}

.hd-status {
  color: var(--hd-ink-2);
  margin: 0 0 8px;
}

.hd-overview > .hd-block-title:first-child {
  margin-top: 0;
}

.hd-findings {
  margin: 0 0 12px;
  padding-left: 18px;
}

#main_content .hd-findings li {
  margin: 2px 0;
}

.hd-block-title {
  margin: 24px 0 8px;
}

.hd-block-sub {
  color: var(--hd-ink-2);
  font-size: 0.85em;
  margin: -4px 0 10px;
}

.hd-weeks,
.hd-levers {
  display: grid;
  gap: 12px;
}

.hd-weeks {
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
}

.hd-levers {
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr));
}

.hd-week,
.hd-lever {
  border: 1px solid var(--hd-border);
  border-radius: 4px;
  padding: 12px;
}

.hd-week__value {
  display: block;
  font-size: 1.35em;
  font-weight: 700;
  line-height: 1.3;
}

.hd-week__trend,
.hd-lever__verdict {
  display: block;
  font-size: 0.8em;
  font-weight: 700;
}

.hd-lever__habit {
  color: var(--hd-ink-2);
  display: block;
  font-size: 0.85em;
}

.hd-lever__result {
  display: block;
  line-height: 1.35;
  margin: 4px 0;
}

.hd-swatch {
  background: var(--hd-grid);
  border-radius: 2px;
  display: inline-block;
  height: 10px;
  width: 10px;
}

.hd-swatch--dot {
  background: var(--hd-s1);
  border-radius: 50%;
}

.hd-swatch--ideal {
  background: var(--hd-ideal);
}

.hd-swatch--hit {
  background: var(--hd-good);
}

.hd-swatch--miss {
  background: transparent;
  box-shadow: inset 0 0 0 1px var(--hd-raw);
}

.hd-tiles {
  margin-top: 36px;
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  margin-bottom: 8px;
}

.hd-tile {
  border: 1px solid var(--hd-border);
  border-radius: 4px;
  padding: 12px;
}

.hd-tile__label {
  color: var(--hd-ink-2);
  display: block;
  font-size: 0.8em;
}

.hd-tile__value {
  display: block;
  font-size: 1.7em;
  font-weight: 700;
  line-height: 1.3;
}

.hd-tile__reference {
  color: var(--hd-ink-2);
  display: block;
  font-size: 0.75em;
}

.hd-section {
  margin: 36px 0 14px;
}

.hd-section:first-child {
  margin-top: 0;
}

.hd-section__title {
  margin: 0;
}

.hd-section__sub {
  color: var(--hd-ink-2);
  font-size: 0.85em;
  margin: 2px 0 0;
}

.hd-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 460px), 1fr));
}

.hd-chart {
  border: 1px solid var(--hd-border);
  border-radius: 4px;
  margin: 0;
  min-width: 0;
  padding: 14px;
}

.hd-chart--wide {
  grid-column: 1 / -1;
}

.hd-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 10px 0 2px;
}

.hd-tabs button {
  background: transparent;
  border: 1px solid var(--hd-border);
  border-radius: 4px;
  color: var(--hd-ink-2);
  cursor: pointer;
  font: inherit;
  font-size: 0.85em;
  min-height: 32px;
  padding: 2px 12px;
}

.hd-tabs button[aria-pressed="true"] {
  border-color: var(--hd-ink);
  color: var(--hd-ink);
  font-weight: 700;
}

.hd-tabs button:focus-visible {
  outline: 2px solid var(--hd-ink);
  outline-offset: 2px;
}

.hd-frame {
  margin-top: 6px;
  position: relative;
}

.hd-chart__title {
  display: block;
  font-weight: 700;
}

.hd-chart__sub {
  color: var(--hd-ink-2);
  display: block;
  font-size: 0.8em;
}

.hd-legend {
  color: var(--hd-ink-2);
  display: flex;
  flex-wrap: wrap;
  font-size: 0.8em;
  gap: 4px 14px;
  list-style: none;
  margin: 8px 0 4px;
  padding: 0;
}

#main_content .hd-legend li {
  align-items: center;
  display: inline-flex;
  font: inherit;
  gap: 6px;
  margin: 0;
  padding: 0;
}

/* The site theme adds a marker before every list item. */
#main_content .hd-legend li::before {
  content: none;
  display: none;
}

.hd-key {
  border-radius: 2px;
  display: inline-block;
  height: 3px;
  width: 14px;
}

.hd-key--block {
  height: 10px;
  width: 10px;
}

.hd-key--band {
  background: var(--hd-band);
  box-shadow: inset 0 0 0 1px var(--hd-border);
}

.hd-plot {
  display: block;
  height: auto;
  overflow: visible;
  touch-action: pan-y;
  width: 100%;
}

.hd-plot:focus-visible {
  outline: 2px solid var(--hd-ink);
  outline-offset: 2px;
}

.hd-plot text {
  fill: var(--hd-ink-2);
  font-family: inherit;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.hd-plot .hd-guide {
  fill: var(--hd-ink);
  font-size: 10px;
  paint-order: stroke;
  stroke: var(--hd-surface);
  stroke-linejoin: round;
  stroke-width: 3px;
}

.hd-plot .hd-end {
  fill: var(--hd-ink);
  font-weight: 700;
}

.hd-info-button {
  align-items: center;
  background: transparent;
  border: 1px solid var(--hd-ink-2);
  border-radius: 50%;
  color: var(--hd-ink-2);
  cursor: pointer;
  display: inline-flex;
  font: italic 700 10px/1 Georgia, serif;
  height: 15px;
  justify-content: center;
  margin-left: 6px;
  padding: 0;
  position: relative;
  vertical-align: 1px;
  width: 15px;
}

/* Keeps the small icon easy to tap. */
.hd-info-button::after {
  content: "";
  inset: -8px;
  position: absolute;
}

.hd-info-button:hover,
.hd-info-button[aria-expanded="true"] {
  border-color: var(--hd-ink);
  color: var(--hd-ink);
}

.hd-info-button:focus-visible {
  outline: 2px solid var(--hd-ink);
  outline-offset: 2px;
}

.hd-info {
  background: var(--hd-surface);
  border: 1px solid var(--hd-border);
  border-radius: 6px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.28);
  box-sizing: border-box;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 13px;
  line-height: 1.45;
  max-width: min(320px, calc(100vw - 24px));
  padding: 12px;
  position: fixed;
  width: 320px;
  z-index: 20;
}

.hd-info[hidden] {
  display: none;
}

.hd-info__title {
  display: block;
  font-size: 14px;
}

.hd-info__label {
  color: var(--hd-ink-2);
  display: block;
  font-size: 11px;
  font-weight: 700;
  margin-top: 8px;
}

.hd-info__text {
  color: var(--hd-ink);
  margin: 1px 0 0;
}

.hd-tip {
  background: var(--hd-surface);
  border: 1px solid var(--hd-border);
  border-radius: 4px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
  font-size: 0.78em;
  left: 0;
  line-height: 1.5;
  min-width: 130px;
  padding: 6px 8px;
  pointer-events: none;
  position: absolute;
  top: 0;
  z-index: 5;
}

.hd-tip[hidden] {
  display: none;
}

.hd-tip__date {
  font-weight: 700;
}

.hd-tip__row {
  align-items: center;
  display: flex;
  gap: 6px;
  justify-content: space-between;
}

.hd-tip__name {
  align-items: center;
  color: var(--hd-ink-2);
  display: inline-flex;
  gap: 5px;
}

@media (forced-colors: active) {
  .hd-key {
    forced-color-adjust: none;
  }
}
