/* ──────────────────────────────────────────────────────────────────
   Infra Atlas · shared matrix-instrument styles
   Linked by every matrix page in /<page>/index.html.
   Page-local <style> blocks can override individual rules; the
   --matrix-accent variable lets each page set its row-hover tint.
   ────────────────────────────────────────────────────────────────── */

:root {
  --matrix-accent: var(--accent, #FF7849);
  --matrix-hover: rgba(255, 120, 73, 0.04);
}

/* ─── Focus visibility (matrix pages — nav.js doesn't cover inline svg buttons etc.) ─── */
:focus-visible { outline: 2px solid var(--matrix-accent); outline-offset: 2px; border-radius: 2px; }

/* ─── Matrix table ─── */
.matrix { width: 100%; border-collapse: collapse; min-width: 900px; font-family: var(--sans); font-size: 13px; }
.matrix thead th {
  position: sticky; top: 0; z-index: 10; background: var(--ink-2);
  font-family: var(--mono); font-weight: 500; font-size: 10.5px; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--paper-2);
  padding: 18px 12px 12px; vertical-align: bottom; text-align: center;
  border-bottom: 1px solid var(--line-2); white-space: nowrap;
}
.matrix thead th.feature-col {
  text-align: left; padding-left: 28px; min-width: 260px;
  font-family: var(--serif); font-style: italic; font-size: 16px;
  letter-spacing: 0; text-transform: none; color: var(--paper); font-weight: 400;
}
.matrix th .vendor-tag { display: inline-flex; align-items: center; gap: 6px; }
.matrix th .swatch { width: 6px; height: 6px; border-radius: 1px; }

.matrix tbody tr.category-row td {
  padding: 22px 22px 10px; border-top: 1px dashed var(--line);
  background: linear-gradient(180deg, rgba(0,0,0,0.2), transparent);
}
.matrix tbody tr.category-row td .cat-label {
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.22em;
  text-transform: uppercase; color: var(--paper-3);
  display: flex; align-items: center; gap: 10px;
}
.matrix tbody tr.category-row td .cat-label::after {
  content: ''; flex: 1; height: 1px; background: var(--line);
}
/* row cells — the row-label is a <th scope=row>, the values are <td>, so target both */
.matrix tbody tr.feature-row td,
.matrix tbody tr.feature-row th { padding: 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.matrix tbody tr.feature-row .feature-col {
  padding-left: 28px; color: var(--paper); font-size: 14px; text-align: left;
  border-right: 1px solid var(--line);
}
.matrix tbody tr.feature-row td.cell {
  text-align: center; min-width: 140px; transition: background 0.15s; position: relative;
}
.matrix tbody tr.feature-row td.cell:hover { background: var(--matrix-hover); }
.matrix tbody tr.feature-row:hover { background: linear-gradient(90deg, transparent, var(--matrix-hover), transparent); }
.matrix tbody tr.feature-row.is-hidden,
.matrix tbody tr.category-row.is-hidden { display: none; }
.matrix-wrap { overflow-x: auto; }

/* keep the dimension label visible while the table scrolls sideways — the
   left column sticks; the top-left corner cell sits above both axes */
.matrix .feature-col { position: sticky; left: 0; z-index: 5; }
.matrix tbody tr.feature-row th.feature-col { background: var(--ink-2); }
.matrix thead th.feature-col { z-index: 11; }

/* ─── Cell marks + values ─── */
.cell-mark {
  display: inline-flex; align-items: center; justify-content: center;
  width: 24px; height: 24px; border-radius: 50%;
  font-family: var(--mono); font-size: 14px; font-weight: 500; position: relative;
}
.cell-mark--yes  { background: rgba(111, 231, 181, 0.15); color: var(--yes); }
.cell-mark--no   { background: rgba(244, 123, 123, 0.12); color: var(--no); }
.cell-mark--part { background: rgba(244, 198, 96, 0.15);  color: var(--part); }

.cell-value {
  display: inline-flex; align-items: baseline; justify-content: center;
  gap: 2px; font-family: var(--mono); font-size: 11.5px; line-height: 1.35;
  padding: 4px 8px; border-radius: 3px; max-width: 200px;
}
.cell-value--yes  { color: var(--paper); }
.cell-value--part { color: var(--part); }
.cell-value--no   { color: var(--no); }
.cell-value__star { font-size: 11px; color: var(--matrix-accent); align-self: flex-start; margin-left: 1px; }
/* footnoted cells get a dotted underline — a consistent "click for the sourced
   note" affordance (most cells are sourced, so this also signals the table is
   interactive, which the audit found wasn't discoverable) */
.cell__btn.has-note .cell-value { text-decoration: underline dotted; text-decoration-color: var(--line-3); text-underline-offset: 4px; }
.cell__btn.has-note:hover .cell-value { text-decoration-color: var(--matrix-accent); }

/* ─── Button wrappers — preserve <th>/<td> semantics while keeping cells clickable ─── */
.cell__btn, .feature-col__btn {
  background: none; border: 0; margin: 0; padding: 0;
  color: inherit; font: inherit; line-height: inherit;
  cursor: pointer; width: 100%; display: block;
}
.cell__btn { padding: 4px 0; text-align: center; }
.feature-col__btn { text-align: left; color: var(--paper); }
.feature-col__btn:hover { color: var(--matrix-accent); }
.cell__btn:focus-visible, .feature-col__btn:focus-visible {
  outline: 2px solid var(--matrix-accent); outline-offset: 2px; border-radius: 3px;
}

/* ─── Empty state (no filter results) ─── */
.matrix-empty {
  display: none; padding: 32px 28px; text-align: center;
  font-family: var(--mono); font-size: 12.5px; color: var(--paper-3);
  border: 1px dashed var(--line-2); border-radius: 6px; margin: 24px 0;
}
.matrix-empty.is-shown { display: block; }
.matrix-empty strong { color: var(--paper); font-weight: 500; }

/* ─── Visually-hidden — aria-live regions + sr-only labels ─── */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0;
  margin: -1px; overflow: hidden; clip: rect(0,0,0,0);
  white-space: nowrap; border: 0;
}

/* ─── Drawer (modal slide-in for per-vendor detail) ─── */
.drawer-backdrop {
  position: fixed; inset: 0; background: rgba(10, 9, 7, 0.7);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  z-index: 200; opacity: 0; pointer-events: none; transition: opacity 0.25s;
}
.drawer-backdrop.is-open { opacity: 1; pointer-events: auto; }

.drawer {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: min(640px, 100%); background: var(--ink-2);
  border-left: 1px solid var(--line-2); z-index: 201;
  transform: translateX(100%);
  transition: transform 0.32s cubic-bezier(0.2, 0.8, 0.2, 1);
  display: flex; flex-direction: column;
}
.drawer.is-open { transform: translateX(0); }
.drawer__head { padding: 28px 32px 22px; border-bottom: 1px solid var(--line); position: relative; flex-shrink: 0; }
.drawer__close {
  position: absolute; top: 20px; right: 20px;
  background: transparent; border: 1px solid var(--line-2); color: var(--paper-2);
  font-family: var(--mono); font-size: 14px; line-height: 1;
  padding: 6px 10px; cursor: pointer; border-radius: 2px;
}
.drawer__close:hover { border-color: var(--paper); color: var(--paper); }
.drawer__eyebrow {
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.22em;
  text-transform: uppercase; color: var(--matrix-accent);
}
.drawer__title {
  font-family: var(--serif); font-size: 32px; font-weight: 400;
  letter-spacing: -0.012em; line-height: 1.05; margin-top: 8px;
}
.drawer__desc { margin-top: 12px; font-size: 14px; color: var(--paper-2); line-height: 1.6; }
.drawer__body { padding: 22px 32px 32px; overflow-y: auto; flex: 1; }
.drawer__section { margin-bottom: 24px; }
.drawer__section h4 {
  font-family: var(--mono); font-size: 10.5px; font-weight: 500;
  letter-spacing: 0.18em; text-transform: uppercase; color: var(--paper-3);
  margin-bottom: 12px; display: flex; align-items: center; gap: 10px;
}
.drawer__section h4::after { content: ''; flex: 1; height: 1px; background: var(--line); }

/* Per-vendor detail card inside drawer */
.vendor-row {
  display: grid; grid-template-columns: auto 1fr; gap: 14px;
  padding: 14px 16px; background: var(--surface);
  border: 1px solid var(--line); border-radius: 3px;
  margin-bottom: 6px; align-items: start;
}
.vendor-row__name {
  font-family: var(--mono); font-size: 12.5px; font-weight: 500; color: var(--paper);
  display: flex; align-items: center; gap: 9px;
}
.vendor-row__name .swatch { width: 8px; height: 8px; border-radius: 2px; }
.vendor-row__value { font-family: var(--mono); font-size: 12px; color: var(--paper); margin-top: 6px; }
.vendor-row__value--part { color: var(--part); }
.vendor-row__value--no   { color: var(--no); }
.vendor-row__note {
  font-family: var(--sans); font-size: 12.5px; color: var(--paper-2);
  line-height: 1.55; margin-top: 6px;
}
.vendor-row__src { margin-top: 8px; font-family: var(--mono); font-size: 10.5px; }
.vendor-row__src a {
  color: var(--paper-3); text-decoration: underline;
  text-decoration-color: var(--line-2); text-underline-offset: 3px; word-break: break-all;
}
.vendor-row__src a:hover { color: var(--matrix-accent); }
.vendor-row__mark {
  font-family: var(--mono); font-size: 16px; font-weight: 500;
  width: 30px; height: 30px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
}
.vendor-row__mark--yes  { background: rgba(111, 231, 181, 0.15); color: var(--yes); }
.vendor-row__mark--no   { background: rgba(244, 123, 123, 0.12); color: var(--no); }
.vendor-row__mark--part { background: rgba(244, 198, 96, 0.15);  color: var(--part); }

/* ─── Mobile: collapse the matrix into stacked cards (below 680px) ───
   A 900px+ table can't survive a phone — it forces a pinch-zoom horizontal
   scroll that the audit flagged. Below 680px each dimension row becomes a
   card: the dimension name is the title, and every vendor stacks as a
   labelled row (vendor name via the data-vlabel attribute). The button
   aria-labels already read "<dimension> — <vendor>: <value> (<level>)", so
   screen-reader users keep full context even though the visual label is CSS.
   min-width:0 !important beats the page-local min-width overrides that load
   after this file. Hidden (filtered-out) rows keep higher specificity, so
   the chip filters still work in card mode. */
@media (max-width: 680px) {
  .matrix-wrap { overflow-x: visible; }
  .matrix { display: block; min-width: 0 !important; }
  .matrix thead { display: none; }
  .matrix tbody { display: block; }

  /* category label → a section heading between card groups */
  .matrix tbody tr.category-row { display: block; }
  .matrix tbody tr.category-row td { display: block; padding: 20px 2px 8px; border-top: 0; background: none; }

  /* each dimension row → a card */
  .matrix tbody tr.feature-row {
    display: block; margin: 0 0 12px; padding: 14px 16px;
    border: 1px solid var(--line); border-radius: 6px;
    background: var(--surface, rgba(255, 255, 255, 0.02));
  }
  .matrix tbody tr.feature-row:hover { background: var(--surface, rgba(255, 255, 255, 0.02)); }

  /* drop the sticky-left column + reset the table-cell padding for cards */
  .matrix .feature-col { position: static; }
  .matrix tbody tr.feature-row th.feature-col {
    display: block; width: auto; padding: 0 0 10px; margin-bottom: 8px;
    border-right: 0; border-bottom: 1px solid var(--line-2);
    background: none; font-size: 15px;
  }
  .matrix tbody tr.feature-row .feature-col__btn { width: 100%; }

  /* each vendor cell → a labelled row inside the card */
  .matrix tbody tr.feature-row td.cell {
    display: flex; align-items: center; justify-content: space-between; gap: 14px;
    min-width: 0; padding: 7px 0; border-bottom: 1px dashed var(--line); text-align: left;
  }
  .matrix tbody tr.feature-row td.cell:last-child { border-bottom: 0; padding-bottom: 0; }
  .matrix tbody tr.feature-row td.cell:hover { background: none; }
  .matrix tbody tr.feature-row td.cell::before {
    content: attr(data-vlabel); flex-shrink: 0;
    font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.1em;
    text-transform: uppercase; color: var(--paper-3);
  }
  .matrix tbody tr.feature-row td.cell .cell__btn { width: auto; padding: 0; text-align: right; }
  .matrix .cell-value { max-width: none; padding: 0; justify-content: flex-end; text-align: right; }
}
