/* ============================================================
   Component · Services Hub
   Comparison matrix (3 pillars × N rows) + decision helper.
   ============================================================ */

.matrix-shell { position: relative; }

.matrix {
  border-top: 1px solid var(--color-border);
  border-bottom: 1px solid var(--color-border);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.matrix__table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-body);
}
.matrix__table th,
.matrix__table td {
  padding: var(--space-md) var(--space-lg);
  vertical-align: top;
  border-bottom: 1px solid var(--color-border-light);
  text-align: left;
}
.matrix__table tr:last-child th,
.matrix__table tr:last-child td { border-bottom: none; }
.matrix__row-label {
  width: 26%;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--color-ink-muted);
  background: var(--color-surface);
  white-space: nowrap;
}
.matrix__table thead th {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: var(--text-xl);
  color: var(--color-ink);
  background: var(--color-white);
  letter-spacing: -0.015em;
  border-bottom: 1px solid var(--color-ink);
  position: relative;
}
.matrix__table thead .pillar-num {
  display: block;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.18em;
  color: var(--color-ink-muted);
  margin-bottom: var(--space-xs);
}
.matrix__table td { color: var(--color-ink-light); font-size: var(--text-sm); line-height: 1.55; }
.matrix__check {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 1px solid var(--color-accent);
  position: relative;
}
.matrix__check::after {
  content: '';
  position: absolute;
  inset: 3px 3px 3px 3px;
  background: var(--color-accent);
}
.matrix__dash {
  display: inline-block;
  width: 16px;
  height: 1px;
  background: var(--color-border);
  vertical-align: middle;
}

@media (max-width: 768px) {
  .matrix__table { min-width: 640px; }
}

/* ============================================================
   Matrix · reading crosshair, column isolate, entry draw
   The table is meant to be *read across*, so it behaves like a
   drafting crosshair: the column and row under the pointer light
   up, the exact cell gets a selection outline, and a title-block
   readout above the table names what you are currently reading.
   All state classes are applied by services-hub.js.
   ============================================================ */

/* --- Title-block strip above the table --------------------- */
.matrix__bar {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-sm) var(--space-lg);
  padding-bottom: var(--space-sm);
}

.matrix__readout {
  display: flex;
  align-items: baseline;
  justify-content: flex-end;
  gap: var(--space-md);
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--color-ink-muted);
  min-height: 1.6em;
}
.matrix__readout-label { opacity: 0.55; }
.matrix__readout-value {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  color: var(--color-ink);
  transition: color var(--duration-fast) var(--ease-out);
}
.matrix__readout-x { color: var(--color-border); }
.matrix-shell.is-reading .matrix__readout-col { color: var(--color-accent); }
.matrix__readout-row,
.matrix__readout-col {
  transition: opacity var(--duration-fast) var(--ease-out);
}
/* Only the two live fields flicker on change (JS re-triggers) */
.matrix__readout .is-swapping { opacity: 0.25; }

@media (max-width: 768px) {
  .matrix__readout { display: none; } /* no hover to report on touch */
}

/* --- Cell / row / column highlight ------------------------- */
.matrix__table td,
.matrix__table th {
  transition:
    background-color var(--duration-fast) var(--ease-out),
    border-color var(--duration-fast) var(--ease-out),
    color var(--duration-fast) var(--ease-out),
    opacity var(--duration-normal) var(--ease-out);
}

.matrix__table .is-col-hot { background-color: color-mix(in srgb, var(--color-accent) 7%, transparent); }
.matrix__table thead th.is-col-hot { border-bottom-color: var(--color-accent); }
.matrix__table thead th.is-col-hot .pillar-num { color: var(--color-accent); }

.matrix__table tr.is-row-hot .matrix__row-label {
  color: var(--color-ink);
  background-color: color-mix(in srgb, var(--color-accent) 6%, var(--color-surface));
}
/* Row leader — a rule that draws out from the label edge */
.matrix__row-label { position: relative; }
.matrix__row-label::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--color-accent);
  transform: scaleY(0);
  transform-origin: center top;
  transition: transform var(--duration-normal) var(--ease-out);
}
.matrix__table tr.is-row-hot .matrix__row-label::before { transform: scaleY(1); }

/* The exact cell under the pointer — a selection outline, drawn
   with an inset shadow so nothing reflows. */
.matrix__table td.is-cell-hot {
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--color-accent) 65%, transparent);
  background-color: color-mix(in srgb, var(--color-accent) 12%, transparent);
}

/* --- Column isolate --------------------------------------- */
.matrix__controls {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--space-sm) var(--space-md);
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
}
.matrix__controls-label { color: var(--color-ink-muted); opacity: 0.55; }

.matrix__isolate {
  padding: 0 0 3px;
  font: inherit;
  color: var(--color-ink-muted);
  border-bottom: 1px solid transparent;
  transition:
    color var(--duration-fast) var(--ease-out),
    border-color var(--duration-fast) var(--ease-out);
}
.matrix__isolate:hover { color: var(--color-ink); border-bottom-color: var(--color-border); }
.matrix__isolate[aria-pressed='true'] {
  color: var(--color-accent);
  border-bottom-color: var(--color-accent);
}

/* Everything outside the isolated pillar recedes */
.matrix__table .is-dim {
  opacity: 0.26;
  filter: saturate(0.35);
}
.matrix__table .is-locked-col {
  background-color: color-mix(in srgb, var(--color-accent) 5%, transparent);
  box-shadow:
    inset  1px 0 0 0 color-mix(in srgb, var(--color-accent) 45%, transparent),
    inset -1px 0 0 0 color-mix(in srgb, var(--color-accent) 45%, transparent);
}

/* --- Entry draw ------------------------------------------- */
/* Rows wipe in from the left in a top-to-bottom cascade; the check
   marks fill last, so the matrix reads as it is being plotted. */
/* :not(.is-dim) keeps these out of the way of the isolate dimming —
   both rules out-specify `.is-dim` and would otherwise pin the body
   cells at full opacity. */
.matrix-shell[data-reveal] tbody tr > *:not(.is-dim) {
  opacity: 0;
  transform: translateX(-10px);
  transition:
    opacity var(--duration-slow) var(--ease-out),
    transform var(--duration-slow) var(--ease-out),
    background-color var(--duration-fast) var(--ease-out),
    color var(--duration-fast) var(--ease-out);
}
.matrix-shell[data-reveal].is-visible tbody tr > *:not(.is-dim) {
  opacity: 1;
  transform: translateX(0);
}
.matrix-shell[data-reveal] tbody tr:nth-child(1) > *:not(.is-dim):not(.is-locked-col) { transition-delay:  60ms; }
.matrix-shell[data-reveal] tbody tr:nth-child(2) > *:not(.is-dim):not(.is-locked-col) { transition-delay: 130ms; }
.matrix-shell[data-reveal] tbody tr:nth-child(3) > *:not(.is-dim):not(.is-locked-col) { transition-delay: 200ms; }
.matrix-shell[data-reveal] tbody tr:nth-child(4) > *:not(.is-dim):not(.is-locked-col) { transition-delay: 270ms; }
.matrix-shell[data-reveal] tbody tr:nth-child(5) > *:not(.is-dim):not(.is-locked-col) { transition-delay: 340ms; }
.matrix-shell[data-reveal] tbody tr:nth-child(6) > *:not(.is-dim):not(.is-locked-col) { transition-delay: 410ms; }

.matrix__check::after {
  transform: scale(0);
  transition: transform var(--duration-normal) var(--ease-spring) 620ms;
}
.matrix-shell[data-reveal].is-visible .matrix__check::after { transform: scale(1); }

.matrix-shell[data-reveal] .matrix__dash {
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform var(--duration-normal) var(--ease-out) 560ms;
}
.matrix-shell[data-reveal].is-visible .matrix__dash { transform: scaleX(1); }

/* --- Horizontal scroll affordance (touch / narrow) --------- */
.matrix__edge {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 44px;
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--duration-normal) var(--ease-out);
  z-index: 2;
}
.matrix__edge--start {
  left: 0;
  background: linear-gradient(to right, var(--color-surface), transparent);
}
.matrix__edge--end {
  right: 0;
  background: linear-gradient(to left, var(--color-surface), transparent);
}
.matrix-shell.can-scroll-start .matrix__edge--start,
.matrix-shell.can-scroll-end   .matrix__edge--end { opacity: 1; }

@media (prefers-reduced-motion: reduce) {
  /* Selector must mirror the animated rules above, `:not()` included,
     or it loses the specificity match and the wipe still runs. */
  .matrix-shell[data-reveal] tbody tr > *:not(.is-dim) {
    opacity: 1;
    transform: none;
    transition: background-color var(--duration-fast) var(--ease-out),
                color var(--duration-fast) var(--ease-out);
  }
  .matrix__check::after,
  .matrix-shell[data-reveal] .matrix__dash { transform: none; transition: none; }
  .matrix__row-label::before { transition: none; }
}

/* === Decision helper ==================================== */
.decision {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-md);
}
@media (min-width: 768px) { .decision { grid-template-columns: repeat(3, 1fr); } }

.decision__card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  padding: var(--space-lg);
  background: var(--color-white);
  border: 1px solid var(--color-border);
  overflow: hidden;
  transition: border-color var(--duration-fast) var(--ease-out),
              transform var(--duration-normal) var(--ease-out);
}
.decision__card:hover {
  border-color: var(--color-ink);
  transform: translateY(-3px);
}

/* Leader line — a rule drops down the card's left edge on hover,
   the way a callout leader is drawn to the thing it annotates. */
.decision__card::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--color-accent);
  transform: scaleY(0);
  transform-origin: center top;
  transition: transform var(--duration-slow) var(--ease-out);
}
.decision__card:hover::before,
.decision__card:focus-within::before { transform: scaleY(1); }

/* Faint pointer-tracked wash, matching the service cards */
.decision__card::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(
    circle at var(--mx, 50%) var(--my, 0%),
    color-mix(in srgb, var(--color-accent) 9%, transparent) 0%,
    transparent 60%
  );
  opacity: 0;
  transition: opacity var(--duration-normal) var(--ease-out);
  pointer-events: none;
}
.decision__card:hover::after { opacity: 1; }
.decision__card > * { position: relative; z-index: 1; }

/* Title-block index: "IF · 01" */
.decision__index {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding-bottom: var(--space-sm);
  border-bottom: 1px solid var(--color-border-light);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--color-ink-muted);
  transition: color var(--duration-fast) var(--ease-out),
              border-color var(--duration-fast) var(--ease-out);
}
.decision__card:hover .decision__index {
  color: var(--color-accent);
  border-bottom-color: color-mix(in srgb, var(--color-accent) 45%, transparent);
}
.decision__index .num { font-variant-numeric: tabular-nums; }

.decision__q {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  line-height: 1.15;
  color: var(--color-ink);
}
.decision__a {
  font-family: var(--font-body);
  font-size: var(--text-sm);
  color: var(--color-ink-muted);
  line-height: 1.5;
}
.decision__then {
  margin-top: auto;
  padding-top: var(--space-md);
  border-top: 1px solid var(--color-border-light);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.15em;
}
.decision__then a {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--color-accent);
}
.decision__then a { position: relative; }
.decision__then a::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: -3px;
  height: 1px;
  background: var(--color-accent);
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform var(--duration-normal) var(--ease-out);
}
.decision__card:hover .decision__then a::after { transform: scaleX(1); }
.decision__then .arrow { transition: transform var(--duration-normal) var(--ease-out); }
.decision__card:hover .decision__then .arrow { transform: translateX(5px); }

/* Staggered entry, matching the pillar cards' cascade */
.decision__card[data-reveal] {
  opacity: 0;
  transform: translateY(24px);
  transition:
    opacity var(--duration-slow) var(--ease-out) calc(var(--stagger-i, 0) * 90ms),
    transform var(--duration-slow) var(--ease-out) calc(var(--stagger-i, 0) * 90ms),
    border-color var(--duration-fast) var(--ease-out);
}
.decision__card[data-reveal].is-visible { opacity: 1; transform: translateY(0); }
.decision__card[data-reveal].is-visible:hover { transform: translateY(-3px); }

@media (prefers-reduced-motion: reduce) {
  .decision__card[data-reveal] {
    opacity: 1;
    transform: none;
    transition: border-color var(--duration-fast) var(--ease-out);
  }
  .decision__card::before,
  .decision__card::after,
  .decision__then a::after { transition: none; }
