/* ==========================================================================
   "One table" diagram (Fig.01), shared by about.php (hero) and index.php (03 What we do).
   Markup: parts/one-table.php. Pausing while off screen: assets/js/site.js.
   The seats we've run (left, each in its colour from the About page's section 03) wire
   into one table of three disciplines, which wires out to what we build (right, mint).
   Wires are 1px boxes placed by percentage inside .tf-wire. The seat and build lists use equal 1fr
   rows with no gap, so row i of n is always centred at (2i+1)/2n and the wires meet every chip at any
   width; the partial writes that value into --y. The out-bus spans first to last row via --bus.
   Motion is CSS only: a one-time build-up, then an 8s loop in which each seat lights up, the
   table pulses and the builds light in turn. site.js holds the build-up (.is-paused) until the
   diagram scrolls into view. All of it is animation, so with reduced motion (site.css 16) the
   finished, fully wired diagram is what shows.
   ========================================================================== */
/* The page's idea in one picture: the seats we've run (left, each in its colour from section 03) wire
   into one table of three disciplines, which ships the builds (right, in the mint signal colour).
   Wires are 1px boxes placed by percentage inside .tf-wire. The seat and build lists use equal 1fr
   rows with no gap, so row i of n is always centred at (2i+1)/2n and the wires meet every chip at any
   width; about.php writes that value into --y.
   Motion is CSS only: a one-time build-up on load, then an 8s loop in which each seat lights up, the
   table pulses and the builds light in turn. All of it is animation, so with reduced motion
   (site.css 16) the finished, fully wired diagram is what shows. */
.tf {
    --loop: 8s; --d: 3.2s; /* loop length, and when the loop first starts (after the build-up) */
    position: relative; min-width: 0; border: 1px solid var(--line-2); border-radius: 14px; overflow: hidden;
    background:
        radial-gradient(circle, rgba(255, 255, 255, .05) 1px, transparent 1.2px) 0 0 / 16px 16px,
        radial-gradient(70% 60% at 50% 58%, rgba(98, 232, 180, .06), transparent 70%),
        rgba(13, 15, 18, .88);
    box-shadow: 0 50px 120px -40px rgba(0, 0, 0, .9), 0 0 0 1px rgba(0, 0, 0, .5);
    animation: tf-rise .6s var(--ease) both .1s;
}
/* Same gliding top-edge highlight as the homepage console */
.tf::before {
    content: ''; position: absolute; top: 0; left: 0; z-index: 2; width: 40%; height: 1px;
    background: linear-gradient(90deg, transparent, rgba(98, 232, 180, .55), transparent);
    animation: edge-glide 9s ease-in-out infinite;
}
.tf-bar { display: flex; align-items: center; justify-content: space-between; gap: 16px; height: 42px; padding: 0 18px; background: var(--bg-2); border-bottom: 1px solid var(--line); }
.tf-bar .mono-label { display: inline-flex; align-items: center; font-size: 11px; white-space: nowrap; }
.tf-bar .mono-idx { margin-right: 10px; font-size: 11px; }
.tf-bar-meta i { margin: 0 6px; font-size: 12px; color: var(--signal); }

.tf-body {
    display: grid; row-gap: 12px; padding: 20px 22px 24px;
    /* Chips and table take their content width; the wires get whatever is left */
    grid-template-columns: auto minmax(40px, 1fr) auto minmax(40px, 1fr) auto;
    grid-template-areas: "hin . . . hout" "seats win core wout builds";
}
.tf-head { font-size: 11px; }
.tf-head.is-in { grid-area: hin; }
.tf-head.is-out { grid-area: hout; }
.tf-seats { grid-area: seats; display: grid; grid-template-rows: repeat(4, 1fr); }
.tf-builds { grid-area: builds; display: grid; grid-auto-rows: 1fr; }
.tf-seats > li, .tf-builds > li { display: flex; align-items: center; padding: 5px 0; }
.tf-seats > li:nth-child(1), .tf-wire.is-in > i:nth-child(1) { --c: var(--signal); }
.tf-seats > li:nth-child(2), .tf-wire.is-in > i:nth-child(2) { --c: var(--sky); }
.tf-seats > li:nth-child(3), .tf-wire.is-in > i:nth-child(3) { --c: var(--violet); }
.tf-seats > li:nth-child(4), .tf-wire.is-in > i:nth-child(4) { --c: var(--amber); }
.tf-builds, .tf-wire.is-out, .tf-trunk { --c: var(--signal); }

.tf-chip {
    position: relative; display: flex; align-items: center; gap: 10px; width: 100%; min-height: 34px; padding: 6px 10px;
    border: 1px solid var(--line-2); border-radius: 9px; background: var(--bg-1);
    font-size: 13px; line-height: 1.25; color: var(--fg-2);
}
.tf-seats .tf-chip { min-height: 44px; padding: 6px 12px 6px 6px; font-size: 14px; font-weight: 500; color: var(--fg); }
.tf-ico {
    flex: none; display: grid; place-items: center; width: 30px; height: 30px; border-radius: 7px; font-size: 15px;
    color: var(--c); background: color-mix(in srgb, var(--c) 11%, transparent); border: 1px solid color-mix(in srgb, var(--c) 28%, transparent);
}
.tf-builds .tf-chip > i { flex: none; font-size: 15px; color: var(--signal); }
/* Ports: where a wire plugs into a chip or the table */
.tf-chip::after, .tf-core::before, .tf-core::after {
    content: ''; position: absolute; top: 50%; width: 5px; height: 5px; margin-top: -2.5px; border-radius: 50%;
    background: var(--bg); box-shadow: inset 0 0 0 1px var(--fg-3);
}
.tf-seats .tf-chip::after, .tf-core::after { right: -3px; }
.tf-builds .tf-chip::after, .tf-core::before { left: -3px; }

.tf-wire { position: relative; }
.tf-wire.is-in { grid-area: win; }
.tf-wire.is-out { grid-area: wout; }
.tf-wire > * { position: absolute; display: block; background: var(--line-3); }
.tf-wire > i { top: var(--y); height: 1px; transform-origin: left; }
.tf-wire.is-in > i { left: 0; right: 50%; }
.tf-wire.is-out > i { left: 50%; right: 0; }
.tf-wire > i::after { content: ''; position: absolute; top: -2px; width: 5px; height: 5px; border-radius: 50%; background: inherit; } /* junction on the bus */
.tf-wire.is-in > i::after { right: -2px; }
.tf-wire.is-out > i::after { left: -2px; }
.tf-bus { left: 50%; width: 1px; }
.is-in > .tf-bus { top: 12.5%; bottom: 12.5%; }                       /* first to last of 4 rows */
.is-out > .tf-bus { top: var(--bus); bottom: var(--bus); }            /* first to last build row: 100% / (2n) */
.tf-trunk { top: 50%; height: 1px; transform-origin: left; }
.is-in > .tf-trunk { left: 50%; right: 0; }
.is-out > .tf-trunk { left: 0; right: 50%; }

.tf-core {
    grid-area: core; align-self: center; position: relative; padding: 14px 14px 8px;
    border: 1px solid var(--line-3); border-radius: 12px;
    background: radial-gradient(120% 80% at 50% 0%, rgba(98, 232, 180, .09), transparent 70%), var(--bg-2);
    box-shadow: 0 0 0 4px rgba(98, 232, 180, .03), 0 24px 60px -24px rgba(0, 0, 0, .8);
}
.tf-core-head { display: flex; align-items: center; gap: 10px; padding-bottom: 12px; margin-bottom: 4px; border-bottom: 1px solid var(--line); }
.tf-core-head .mark { width: 26px; height: 26px; }
.tf-core-head .wordmark { font-size: 15px; }
.tf-core li { display: flex; align-items: center; gap: 10px; padding: 7px 0; font-size: 13px; line-height: 1.25; color: var(--fg-2); }
.tf-core li i { flex: none; width: 16px; font-size: 15px; text-align: center; }
.tf-core li:nth-child(1) i { color: var(--signal); }
.tf-core li:nth-child(2) i { color: var(--sky); }
.tf-core li:nth-child(3) i { color: var(--violet); }

/* Build-up on load: panel, seats, wires in, table, wires out, then the builds one by one */
.tf-seats .tf-chip { animation: tf-in .45s var(--ease) both calc(.4s + var(--i) * .08s), tf-chip-lit var(--loop) ease-in-out infinite calc(var(--d) + var(--i) * .45s); }
.tf-wire.is-in > i { animation: tf-draw .35s var(--ease) both calc(.75s + var(--i) * .06s), tf-wire-lit var(--loop) ease-in-out infinite calc(var(--d) + .15s + var(--i) * .45s); }
.is-in > .tf-bus { animation: tf-draw-y .35s var(--ease) both 1.05s; }
.is-in > .tf-trunk { animation: tf-draw .3s var(--ease) both 1.25s, tf-wire-lit var(--loop) ease-in-out infinite calc(var(--d) + 1.8s); }
.tf-core { animation: tf-pop .45s var(--ease) both 1.35s, tf-core-lit var(--loop) ease-in-out infinite calc(var(--d) + 1.9s); }
.is-out > .tf-trunk { animation: tf-draw .3s var(--ease) both 1.7s, tf-wire-lit var(--loop) ease-in-out infinite calc(var(--d) + 2.15s); }
.is-out > .tf-bus { animation: tf-draw-y .35s var(--ease) both 1.85s; }
.tf-wire.is-out > i { animation: tf-draw .3s var(--ease) both calc(1.95s + var(--i) * .05s), tf-wire-lit var(--loop) ease-in-out infinite calc(var(--d) + 2.35s + var(--i) * .22s); }
.tf-builds .tf-chip { animation: tf-in .4s var(--ease) both calc(2.05s + var(--i) * .09s), tf-chip-lit var(--loop) ease-in-out infinite calc(var(--d) + 2.45s + var(--i) * .22s); }
@keyframes tf-rise { from { opacity: 0; transform: translateY(14px); } }
@keyframes tf-in { from { opacity: 0; transform: translateX(-8px); } }
@keyframes tf-draw { from { transform: scaleX(0); } }
@keyframes tf-draw-y { from { transform: scaleY(0); } }
@keyframes tf-pop { from { opacity: 0; transform: scale(.94); } }
/* site.js adds .is-paused while the diagram is off screen (and before it is first seen) */
.tf.is-paused, .tf.is-paused *, .tf.is-paused *::before, .tf.is-paused *::after { animation-play-state: paused; }
/* Loop: a short light in each element's colour, then rest */
@keyframes tf-chip-lit {
    0%, 16%, 100% { border-color: var(--line-2); box-shadow: 0 0 0 0 transparent, 0 0 0 0 transparent; }
    4%, 9% { border-color: color-mix(in srgb, var(--c) 60%, transparent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--c) 10%, transparent), 0 0 22px -6px var(--c); }
}
@keyframes tf-wire-lit {
    0%, 16%, 100% { background-color: var(--line-3); box-shadow: 0 0 0 transparent; }
    4%, 9% { background-color: var(--c); box-shadow: 0 0 8px var(--c); }
}
@keyframes tf-core-lit {
    0%, 18%, 100% { border-color: var(--line-3); box-shadow: 0 0 0 4px rgba(98, 232, 180, .03), 0 24px 60px -24px rgba(0, 0, 0, .8); }
    5%, 10% { border-color: rgba(98, 232, 180, .55); box-shadow: 0 0 0 4px rgba(98, 232, 180, .1), 0 24px 60px -16px rgba(98, 232, 180, .35); }
}

/* Phones: the diagram turns vertical */
@media (max-width: 640px) {
    /* Diagram turns vertical: seats in a 2x2 grid fork into one wire down to the table, which forks out to the builds */
    .tf-bar { padding: 0 14px; }
    .tf-body { grid-template-columns: minmax(0, 1fr); grid-template-areas: "hin" "seats" "win" "core" "wout" "builds"; row-gap: 0; padding: 18px 14px 18px; }
    .tf-head.is-in { margin-bottom: 10px; }
    .tf-head.is-out { grid-area: wout; align-self: center; }  /* shares the out-wire row, left of the fork */
    .tf-seats, .tf-builds { grid-template-rows: none; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
    .tf-seats > li, .tf-builds > li { align-items: stretch; padding: 0; }  /* chips fill the row, so a wrapped label doesn't leave its neighbour short */
    .tf-seats .tf-chip { font-size: 13.5px; }
    .tf-chip::after { display: none; }
    .tf-core { justify-self: center; width: min(100%, 340px); }
    .tf-core::before, .tf-core::after { top: auto; left: 50%; right: auto; margin: 0 0 0 -2.5px; }
    .tf-core::before { top: -3px; }
    .tf-core::after { bottom: -3px; }
    .tf-wire { height: 44px; }
    .tf-wire > * { display: none; }
    /* Fork: a bracket between the two chip-column centres ((100% - 8px gap) / 4 in from each side) */
    .tf-wire::before {
        content: ''; position: absolute; left: calc(25% - 2px); right: calc(25% - 2px); height: 16px;
        border: 1px solid var(--line-3); border-radius: 0 0 6px 6px; border-top: 0;
    }
    .tf-wire.is-in::before { top: 0; }
    .tf-wire.is-out::before { bottom: 0; border-radius: 6px 6px 0 0; border: 1px solid var(--line-3); border-bottom: 0; }
    /* Trunk between the fork and the table, with a light running down it */
    .tf-wire::after {
        content: ''; position: absolute; left: 50%; width: 1px; margin-left: -.5px;
        background: linear-gradient(transparent, var(--signal), transparent) no-repeat, var(--line-3);
        background-size: 100% 60%, 100% 100%;
        animation: tf-flow 2.4s linear infinite 2s;
    }
    .tf-wire.is-in::after { top: 15px; bottom: 0; }
    .tf-wire.is-out::after { top: 0; bottom: 15px; animation-delay: 3.2s; }
}
@keyframes tf-flow { from { background-position: 0 -200%, 0 0; } to { background-position: 0 300%, 0 0; } }
