/**
 * @file
 * The benefits matrix. Layout ported from the old ePLANeTE Vue "#vue-bt" table;
 * colours mapped onto the edwtfe theme tokens (css/vars.css, color-palette.css).
 */

.benefits-matrix {
  /* Header + row striping: the old ePLANeTE yellow-greens. */
  --bm-header-top: hsl(95.45deg 41.51% 79.22%);
  --bm-header-odd: hsl(61.67deg 75% 71.76%);
  --bm-header-even: hsl(60deg 73.81% 83.53%);
  --bm-leaf-bg: hsl(61.67deg 75% 71.76%);

  /* Score ramp: primary for high→low, danger for negative, grey for none. */
  --bm-high: var(--c-primary-600, #0090c9);
  --bm-medium: var(--c-primary-300, #80d5f5);
  --bm-low: var(--c-primary-100, #d6f1fc);
  --bm-negative: var(--c-danger, #dc3545);
  --bm-none: var(--c-gray-50, #f3f3f3);
}

/* ---- sector pills (matches edwtfe bef/filters .w-pills) ---- */

.bm-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-block: 1rem 1.5rem;
}

.bm-pill {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 20px;
  font-family: var(--f-f, inherit);
  font-size: 18px;
  font-weight: 500;
  line-height: 26px;
  color: var(--body_c, #111);
  white-space: nowrap;
  cursor: pointer;
  background: var(--c-white, #fff);
  border: 1px solid #e6e6e6;
  border-radius: var(--b-r_pill, 100rem);
  transition: border-color 0.2s ease, color 0.2s ease;
}

.bm-pill:hover,
.bm-pill[aria-pressed="true"] {
  border-color: #0081cc;
}

.bm-pill::after {
  content: "";
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  background-image: var(--bm-pill-icon);
  background-position: center;
  background-repeat: no-repeat;
  background-size: contain;
}

/* ---- controls ---- */

.bm-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  align-items: end;
  margin-block: 0 1.5rem;
}

.bm-control {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.bm-control label {
  font-family: var(--f-f, inherit);
  font-size: 0.875rem;
  font-weight: 500;
  color: #222;
}

/* Native <select>, dressed to match the case studies filter controls
   (edwtfe bef/filters: #f6f6f6, borderless, 22px radius, Inter 16px). */
.bm-select {
  min-width: 20rem;
  max-width: 100%;
  padding: 10px 44px 10px 20px;
  font-family: var(--f-f, inherit);
  font-size: 16px;
  font-weight: 400;
  line-height: 1.5;
  color: var(--body_c, #111);
  cursor: pointer;
  background-color: #f6f6f6;
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none' stroke='%2300447C' stroke-width='1.8'%3e%3cpath d='M5 8l5 5 5-5' stroke-linecap='round' stroke-linejoin='round'/%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 20px center;
  background-size: 14px 14px;
  border: none;
  border-radius: 22px;
  -webkit-appearance: none;
  appearance: none;
}

.bm-select:focus-visible {
  outline: 2px solid var(--c-primary, #00aeef);
  outline-offset: 2px;
}

/* Native search input, matching edwtfe bef/filters input.search-input. */
.bm-search {
  width: 20rem;
  max-width: 100%;
  padding: 10px 20px 10px 46px;
  font-family: var(--f-f, inherit);
  font-size: 16px;
  font-weight: 400;
  line-height: 1.5;
  color: var(--body_c, #111);
  background-color: #f6f6f6;
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none' stroke='%2300447C' stroke-width='1.8'%3e%3ccircle cx='9' cy='9' r='6.5'/%3e%3cpath d='M18 18l-4.5-4.5' stroke-linecap='round'/%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: 20px center;
  background-size: 18px 18px;
  border: none;
  border-radius: 22px;
  appearance: none;
}

.bm-search::placeholder {
  color: #555;
}

.bm-search:focus-visible {
  outline: 2px solid var(--c-primary, #00aeef);
  outline-offset: 2px;
}

/* ---- tables ---- */

.bm-tables {
  display: flex;
  flex-direction: column;
  gap: 2.5rem;
}

.bm-table-wrapper {
  max-width: 100%;
  overflow-x: auto;
}

.bm-table-title {
  margin: 0 0 0.5rem;
}

.bm-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}

.bm-table th,
.bm-table td {
  border: 1px solid var(--c-white, #fff);
}

/* ---- head ---- */

.bm-thead th {
  padding: 6px 8px;
  text-align: center;
  font-weight: 600;
  color: var(--c-gray-800, #3d3d3d);
}

.bm-thead tr:nth-child(odd) {
  background: var(--bm-header-odd);
}

.bm-thead tr:nth-child(even) {
  background: var(--bm-header-even);
}

.bm-thead tr:first-child {
  background: var(--bm-header-top);
  text-transform: uppercase;
}

.bm-thead th.bm-code {
  font-size: 0.75rem;
  font-weight: 500;
}

.bm-thead .bm-leaf-row th {
  max-height: 220px;
  padding: 9px;
  text-align: left;
  vertical-align: bottom;
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  background: var(--bm-leaf-bg);
}

.bm-thead .bm-leaf-row .bm-leaf-label {
  /* Vertical text: the inline run is the height; wrapping adds a second
     column of glyphs. Clamp it at two lines. */
  display: -webkit-box;
  overflow: hidden;
  max-height: 220px;
  font-weight: 500;
  white-space: normal;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  -webkit-box-orient: vertical;
}

.bm-legend-cell {
  text-align: center;
  vertical-align: middle;
}

/* ---- body ---- */

.bm-tbody tr {
  height: 60px;
}

.bm-tbody td {
  text-align: center;
}

.bm-tbody td.bm-code {
  padding: 0 0.5rem;
  font-size: 0.8rem;
}

.bm-tbody td.bm-title {
  width: 300px;
  padding: 0 0.75rem;
  text-align: right;
}

.bm-tbody td.bm-title a {
  color: inherit;
  text-decoration: none;
}

.bm-tbody td.bm-title a:hover {
  text-decoration: underline dotted;
}

.bm-tbody tr:nth-child(odd) td.bm-code,
.bm-tbody tr:nth-child(odd) td.bm-title {
  background: var(--bm-header-even);
}

.bm-tbody tr:nth-child(even) td.bm-code,
.bm-tbody tr:nth-child(even) td.bm-title {
  background: var(--bm-header-odd);
}

/* ---- cell levels (shared with the legend swatches) ---- */

.benefits-matrix td.high {
  background: var(--bm-high);
}

.benefits-matrix td.medium {
  background: var(--bm-medium);
}

.benefits-matrix td.low {
  background: var(--bm-low);
}

.benefits-matrix td.negative {
  background: var(--bm-negative);
}

.benefits-matrix td.none {
  background: var(--bm-none);
}

/* ---- legend (BenefitsScaleCaption from the old site) ---- */

.bm-legend {
  max-width: 300px;
  margin: 0 auto;
  font-size: x-small;
}

.bm-legend caption {
  text-align: center;
  caption-side: top;
  background: var(--c-white, #fff);
  border-top: 1px solid var(--c-gray-300, #b7b7b7);
  border-right: 1px solid var(--c-gray-300, #b7b7b7);
  border-left: 1px solid var(--c-gray-300, #b7b7b7);
}

.bm-legend td {
  width: 50%;
  border: 1px solid var(--c-gray-300, #b7b7b7);
}

.bm-legend td:last-child {
  background: var(--c-white, #fff);
  border-left: none;
}

.bm-legend td.none {
  background: var(--bm-none);
}

/* ---- states ---- */

.bm-loader,
.bm-empty {
  padding: 2rem;
  text-align: center;
  color: var(--c-gray-800, #3d3d3d);
}

.bm-tables--onerow .bm-tbody td.bm-title {
  width: auto;
}
