/* "One-minute overview" diagram in "Where do the familiar names fit?".
   Rows are layers, columns are simulator families. Every selector is scoped
   under .sim-layers so nothing leaks into the post. Wide containers get a
   grid; narrow ones (phones) get one block per layer. */

.sim-layers {
  container: sim-layers / inline-size;
  margin: 1.6em 0;
  font-family: var(--font-sans);
}

.sim-layers .sim-layers-table {
  width: calc(100% + 8px);
  margin: -4px -4px 0;
  table-layout: fixed;
  border-collapse: separate;
  border-spacing: 4px;
  font-family: var(--font-sans);
  font-size: 0.78rem;
  line-height: 1.35;
  color: var(--text);
}

/* Reset the post's generic table cell styles. */
.sim-layers .sim-layers-table th,
.sim-layers .sim-layers-table td {
  min-width: 0;
  padding: 7px 9px;
  border: 0;
  background: none;
  text-align: left;
  vertical-align: middle;
}

/* Column headers: the families. */
.sim-layers .sim-layers-table thead th {
  padding: 0 9px 2px;
  font-size: 0.82rem;
  font-weight: 600;
  vertical-align: bottom;
}

.sim-layers .sim-layers-table thead th:first-child { width: 7rem; }

/* The Isaac engine cell carries the most text. */
.sim-layers .sim-layers-table thead th.is-wide { width: 19%; }

/* Group labels: "Inside the simulator" / "Built on top". */
.sim-layers .sim-layers-group th {
  padding: 10px 0 1px;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.sim-layers .sim-layers-group-top th {
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

/* Row headers: the layers. */
.sim-layers .sim-layers-table tbody th[scope="row"] {
  padding-left: 10px;
  padding-right: 6px;
  font-weight: 600;
  line-height: 1.25;
}

.sim-layers .sim-layers-sub {
  display: block;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 400;
}

/* Data cells: quiet tiles. */
.sim-layers .sim-layers-table td {
  border-radius: 6px;
  background: var(--surface);
  font-weight: 500;
}

/* The physics-engine row is the point of the figure. */
.sim-layers .is-engine th[scope="row"] {
  box-shadow: inset 3px 0 0 var(--accent);
}

.sim-layers .sim-layers-table .is-engine td {
  background: color-mix(in srgb, var(--accent) 10%, var(--bg));
  font-weight: 600;
}

/* No dedicated tool in this layer: an empty, outlined slot. */
.sim-layers .sim-layers-table td.is-empty {
  background: none;
  box-shadow: inset 0 0 0 1px var(--border);
  color: var(--muted);
  font-weight: 400;
}

/* Secondary line inside a cell. */
.sim-layers .sim-layers-note {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 400;
}

/* A part that shows up in two families (PhysX, MuJoCo Warp). */
.sim-layers .sim-layers-shared {
  padding: 0 3px;
  border: 1px solid color-mix(in srgb, var(--accent-cool) 80%, var(--bg));
  border-radius: 4px;
  background: var(--bg);
  white-space: nowrap;
}

.sim-layers figcaption {
  margin-top: 10px;
  color: var(--muted);
  font-family: var(--font-sans);
  font-size: 0.8rem;
  line-height: 1.55;
}

.sim-layers .sim-layers-note .sim-layers-shared,
.sim-layers figcaption .sim-layers-shared { color: var(--text); }

/* Narrow containers: one block per layer, each family on its own line. */
@container sim-layers (max-width: 719px) {
  .sim-layers .sim-layers-table,
  .sim-layers .sim-layers-table tbody,
  .sim-layers .sim-layers-table tr,
  .sim-layers .sim-layers-table th,
  .sim-layers .sim-layers-table td {
    display: block;
    width: auto;
  }

  .sim-layers .sim-layers-table {
    margin: 0;
    font-size: 0.82rem;
  }

  /* Family names move into each line, so the header row is only for
     screen readers. */
  .sim-layers .sim-layers-table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
  }

  .sim-layers .sim-layers-group th { padding: 8px 0 6px; }
  .sim-layers .sim-layers-group-top th { margin-top: 6px; padding-top: 14px; }

  .sim-layers .sim-layers-table tbody tr:not(.sim-layers-group) {
    margin-bottom: 6px;
    padding: 9px 12px 8px;
    border-radius: 8px;
    background: var(--surface);
  }

  .sim-layers .sim-layers-table tbody tr.is-engine {
    background: color-mix(in srgb, var(--accent) 10%, var(--bg));
    box-shadow: inset 3px 0 0 var(--accent);
  }

  .sim-layers .sim-layers-table tbody th[scope="row"] {
    padding: 0 0 4px;
  }

  .sim-layers .sim-layers-table .is-engine th[scope="row"] { box-shadow: none; }

  .sim-layers .sim-layers-sub {
    display: inline;
    margin-left: 0.35em;
  }

  .sim-layers .sim-layers-table td,
  .sim-layers .sim-layers-table .is-engine td,
  .sim-layers .sim-layers-table td.is-empty {
    position: relative;
    padding: 3px 0 3px 5.6rem;
    border-radius: 0;
    background: none;
    box-shadow: none;
  }

  .sim-layers .sim-layers-table td::before {
    content: attr(data-family);
    content: attr(data-family) / "";
    position: absolute;
    top: 3px;
    left: 0;
    width: 5.2rem;
    color: var(--muted);
    font-weight: 400;
  }
}
