/* --------------------------------------------------------------------------
   A table builds itself as the page loads (the user, 20 Nov 2026, with a
   recording of a Wealthsimple comparison table: "table construction should
   be like this everywhere with page load"). Its words are there from the
   start; its rules draw across from the left, one row after the one above,
   and the tint behind our column comes down with them. Rows further down
   draw as they come into view. It happens once.

   The tables say how their rules are drawn (compare.css, pricing.css):
     --tb-draw   how far across a row's rule has got (0% to 100%)
     --tb-p      the same for a rule made of one piece per cell (0 to 1),
                 as under the plan table's prices, whose cells stay put
     --tb-fill   how far down a column's tint has come
     --tb-shut   how much of the compare tables' panel is still to come
   table-build.js marks the table (.tb), starts it (.tb-go) and marks each
   row as it comes into view (.tb-in). With Reduce Motion nothing here
   applies and the table is simply there.
   -------------------------------------------------------------------------- */
@property --tb-p {
  syntax: "<number>";
  inherits: true;
  initial-value: 1;
}

/* (If the script never arrives, the table shows whole after a moment.) */
@keyframes tb-safe {
  to {
    --tb-draw: 100%;
    --tb-p: 1;
    --tb-fill: 100%;
    --tb-shut: 0%;
  }
}

@media (prefers-reduced-motion: no-preference) {
  /* Before the script has the table: nothing drawn yet, so the whole
     table never shows for a blink and then goes to be drawn again. */
  @media (scripting: enabled) {
    :is(.cmp-table, .plan-table__grid):not(.tb) {
      --tb-draw: 0%;
      --tb-p: 0;
      --tb-fill: 0%;
      animation: tb-safe .01s 3s forwards;
    }

    .cmp-table-wrap:has(> .cmp-table:not(.tb)) {
      --tb-shut: 100%;
      animation: tb-safe .01s 3s forwards;
    }
  }

  .tb {
    --tb-time: 1s;
    --tb-ease: cubic-bezier(.3, .6, .35, 1);
    --tb-draw: 0%;
    --tb-p: 0;
    --tb-fill: 0%;
  }

  /* A row's rule draws across, after the rows above it in the same
     screenful (--tb-wait, from table-build.js). */
  .tb tr.tb-in {
    --tb-draw: 100%;
    --tb-p: 1;
    transition:
      background-size var(--tb-time) var(--tb-ease) var(--tb-wait, 0ms),
      --tb-p var(--tb-time) var(--tb-ease) var(--tb-wait, 0ms);
  }

  /* Our column's tint comes down as the rules go across. */
  .tb.tb-go {
    --tb-fill: 100%;
  }

  .tb.tb-go col {
    transition: background-size 1.8s cubic-bezier(.3, .5, .5, 1) var(--tb-settle, 0ms);
  }

  .cmp-table-wrap:has(> .cmp-table.tb:not(.tb-go)) {
    --tb-shut: 100%;
  }

  .cmp-table-wrap:has(> .cmp-table.tb-go)::before {
    transition: clip-path calc(var(--tb-rows, 8) * 160ms + 600ms) cubic-bezier(.35, .35, .6, 1) var(--tb-settle, 0ms);
  }
}

@media print {
  :is(.cmp-table, .plan-table__grid),
  :is(.cmp-table, .plan-table__grid) tr,
  .cmp-table-wrap {
    --tb-draw: 100% !important;
    --tb-p: 1 !important;
    --tb-fill: 100% !important;
    --tb-shut: 0% !important;
    animation: none !important;
  }
}
