/**
 * Evolve — comparison tables in post content.
 *
 * Editor tables ship with no styling in this theme, so specification and price tables
 * render as colliding text. This follows the site's own design language: Montserrat for
 * headers, Roboto for data, acid green as the single accent, black/white/grey elsewhere.
 *
 * Tokens are read from the theme when present, with literal fallbacks so the file also
 * holds up if the compiled stylesheet loads after this one.
 */

.ek-table {
  --ek-acid: var(--color-acid, #00be59);
  --ek-black: var(--color-black, #000000);
  --ek-line: var(--color-gray-200, #d9d9d9);
  --ek-zebra: var(--color-gray-50, #f3f3f3);

  position: relative;
  margin: 2.5rem 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--ek-line);
  border-radius: 14px;
  background: #fff;
}

/*
 * Scrollability is signalled by the scrollbar and by the sticky label column's edge
 * shadow. A gradient fade was tried and dropped: an absolutely positioned pseudo-element
 * inside a scroll container travels with the content instead of staying pinned to the
 * right edge, which reads as a rendering fault rather than an affordance.
 */

.ek-table::-webkit-scrollbar { height: 8px; }
.ek-table::-webkit-scrollbar-track { background: var(--ek-zebra); border-radius: 0 0 14px 14px; }
.ek-table::-webkit-scrollbar-thumb { background: var(--ek-line); border-radius: 100px; }
.ek-table::-webkit-scrollbar-thumb:hover { background: #bfbfbf; }

.ek-table > table {
  width: 100%;
  min-width: 32rem;
  border-collapse: collapse;
  font-family: var(--font-ui, "Roboto", sans-serif);
  font-size: 0.9375rem;
  line-height: 1.45;
  color: var(--ek-black);
  margin: 0;
}

/* ---------- header ---------- */

.ek-table thead th {
  background: var(--ek-black);
  color: #fff;
  font-family: var(--font-heading, "Montserrat", sans-serif);
  font-weight: 700;
  font-size: 0.75rem;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  text-align: left;
  padding: 1rem 1.25rem;
  white-space: nowrap;
  vertical-align: middle;
  border: none;
}

.ek-table thead th:first-child {
  border-top-left-radius: 13px;
}

.ek-table thead th:last-child {
  border-top-right-radius: 13px;
}

/* The acid rule under the header is the one accent in the whole component. */
.ek-table thead tr {
  border-bottom: 3px solid var(--ek-acid);
}

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

.ek-table tbody td {
  padding: 0.9375rem 1.25rem;
  border-bottom: 1px solid var(--ek-line);
  vertical-align: top;
  background: #fff;
}

.ek-table tbody tr:nth-child(even) td {
  background: var(--ek-zebra);
}

.ek-table tbody tr:last-child td {
  border-bottom: none;
}

/* First column carries the row label — treat it as a heading, not data. */
.ek-table tbody td:first-child {
  font-family: var(--font-heading, "Montserrat", sans-serif);
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--ek-black);
  white-space: nowrap;
}

/* Keep the label visible while the value columns scroll under it. */
.ek-table thead th:first-child,
.ek-table tbody td:first-child {
  position: sticky;
  left: 0;
  z-index: 1;
}

.ek-table tbody td:first-child::after,
.ek-table thead th:first-child::after {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  width: 1px;
  height: 100%;
  background: var(--ek-line);
}

.ek-table thead th:first-child::after { background: rgba(255, 255, 255, 0.25); }

/* Numbers and prices line up. */
.ek-table tbody td:not(:first-child) {
  font-variant-numeric: tabular-nums;
}

/* A cell spanning the value columns is a shared statement, not a comparison. */
.ek-table tbody td[colspan] {
  font-family: var(--font-ui, "Roboto", sans-serif);
  font-weight: 400;
  white-space: normal;
}

.ek-table tbody tr:hover td {
  background: #eefaf3;
}

.ek-table tbody tr:hover td:first-child {
  background: #e2f6ea;
}

/* ---------- mobile ---------- */

@media (max-width: 640px) {
  .ek-table {
    margin: 2rem -1px;
    border-radius: 12px;
  }

  .ek-table > table {
    min-width: 30rem;
    font-size: 0.875rem;
  }

  .ek-table thead th {
    padding: 0.8125rem 0.875rem;
    font-size: 0.6875rem;
  }

  .ek-table tbody td {
    padding: 0.8125rem 0.875rem;
  }

  .ek-table tbody td:first-child {
    font-size: 0.8125rem;
    max-width: 9.5rem;
    white-space: normal;
  }

  /* The sticky label column needs a visible edge once it overlaps content. */
  .ek-table tbody td:first-child,
  .ek-table thead th:first-child {
    box-shadow: 4px 0 8px -4px rgba(0, 0, 0, 0.18);
  }
}
