/* fp-stack: the factory as one body with your tools docked into it. Your work tools plug into its top edge; switch to
   Consolidated and that module drops into a bay inside the body and sits there, quieter, tied to the backlog it became,
   while each kind of work names the tool it stands in for. Code, models, cloud and data, frameworks and traces dock
   under the body and never move: the factory builds on them. Ink at rest; azure is agents at work; gold is your choice
   to switch the tools off. */
.fp-stack {
  --fs-gap: 12px; /* the docking gap between a module and the body */
  --fs-pad: var(--space-xl); /* the body's inner edge */
  --fs-top-light: inset 0 1px 0 color-mix(in oklab, var(--color-ink) 14%, transparent);
  --fs-face: linear-gradient(to bottom, color-mix(in oklab, var(--color-paper-3) 92%, var(--color-ink)), var(--color-paper-3) 38%, color-mix(in oklab, var(--color-paper-3) 55%, var(--color-paper-2)));
  --fs-cast: 0 22px 34px -20px color-mix(in oklab, var(--color-accent-ink) 92%, transparent);
  --fs-seat: color-mix(in oklab, var(--color-paper) 62%, var(--color-paper-2));
  --fs-move: 400ms;
  padding-block: 0;
}

/* ===== Head: the h2, its line, and the label for the modules ===== */
.fp-stack__head { grid-row: 1; grid-column: 1 / 9; display: flex; flex-direction: column; align-items: flex-start; gap: var(--space-lg); }
.fp-stack__head h2 { max-width: 20ch; }
.fp-stack__line { max-width: 46ch; }
.fp-stack__cap { margin-top: var(--space-md); margin-bottom: calc(var(--fs-gap) + var(--space-md)); }

/* ===== The rig: dock row, body, base row, on the page's twelve columns ===== */
.fp-stack__rig { position: relative; isolation: isolate; display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); column-gap: var(--gap-columns); }

/* ===== A module: a tool group, a lit block plugged into the body by a key ===== */
.fp-stack__mod {
  position: relative; display: flex; flex-direction: column; gap: var(--space-md); min-width: 0; margin: 0;
  padding: var(--space-md) var(--space-lg) var(--space-lg);
  background:
    radial-gradient(ellipse 60% 70% at calc(var(--space-lg) + 20px) 0, color-mix(in oklab, var(--color-ink) 9%, transparent), transparent 100%),
    var(--fs-face);
  box-shadow: var(--fs-top-light), inset 0 0 0 1px color-mix(in oklab, var(--color-rule-2) 75%, transparent), inset 0 -3px 0 color-mix(in oklab, var(--color-paper) 55%, transparent), var(--fs-cast);
}
.fp-stack__mod::before { /* the key: two prongs that plug the module into the body */
  content: ""; position: absolute; left: var(--space-lg); top: calc(-1 * var(--fs-gap)); width: 40px; height: var(--fs-gap);
  background: linear-gradient(to right, var(--color-rule-2) 0 8px, transparent 8px 32px, var(--color-rule-2) 32px);
  transition: opacity var(--dur-short) var(--ease-out);
}
.fp-stack__mod::after { /* the current through the key: an agent working with this tool */
  content: ""; position: absolute; left: calc(var(--space-lg) + 8px); top: calc(-1 * var(--fs-gap) + 3px); width: 24px; height: calc(var(--fs-gap) - 6px);
  background: var(--color-accent); opacity: 0.55; transition: opacity var(--dur-short) var(--ease-out);
}
.fp-stack__mod:hover::after { opacity: 1; }
.fp-stack__group { font-size: var(--text-sm); font-weight: 500; line-height: 1.3; color: var(--color-ink-2); }
.fp-stack__tools { display: flex; flex-wrap: wrap; gap: var(--space-sm) var(--space-lg); margin: 0; padding: 0; list-style: none; }
.fp-stack__tool { display: flex; align-items: center; gap: var(--space-xs); min-height: 32px; font-size: var(--text-md); font-weight: 500; line-height: 1.2; color: var(--color-ink); white-space: nowrap; }
.fp-stack__mark { flex: none; width: 24px; height: 24px; color: var(--color-ink); transform: scale(var(--s, 1)); }
.fp-stack__does { margin-top: auto; font-size: var(--text-md); line-height: 1.45; color: var(--color-ink-2); }

/* ===== The dock: your work tools, plugged into the body's top edge ===== */
.fp-stack__dock { grid-row: 1; grid-column: 9 / 13; align-self: end; position: relative; z-index: 3; margin: 0 var(--fs-pad) var(--fs-gap) 0; } /* the same width as the bay it drops into */
.fp-stack__mod--work::before { top: auto; bottom: calc(-1 * var(--fs-gap)); }
.fp-stack__mod--work::after { top: auto; bottom: calc(-1 * var(--fs-gap) + 3px); }
.fp-stack__mod--work { transition: transform var(--fs-move) var(--ease-in-out); }
.fp-stack__mod--work.is-moving { z-index: 4; }

/* ===== The body: the factory, the brightest thing here ===== */
.fp-stack__body {
  position: relative; z-index: 2; grid-row: 2; grid-column: 1 / -1;
  display: grid; grid-template-columns: subgrid; grid-template-rows: 6px auto 1fr;
  padding-bottom: var(--fs-pad);
  background:
    radial-gradient(ellipse 40% 80% at 12% 112%, color-mix(in oklab, var(--color-dawn) 15%, transparent), transparent 100%),
    radial-gradient(ellipse 30% 60% at 84% 0%, color-mix(in oklab, var(--color-ink) 7%, transparent), transparent 100%),
    linear-gradient(to bottom, color-mix(in oklab, var(--color-paper-3) 86%, var(--color-ink)), var(--color-paper-3) 22%, color-mix(in oklab, var(--color-paper-3) 72%, var(--color-paper-2)));
  box-shadow: inset 0 1px 0 color-mix(in oklab, var(--color-ink) 18%, transparent), inset 0 0 0 1px var(--color-rule-2), var(--shadow-card);
}
/* the slot your work tools plug into */
.fp-stack__slot { grid-row: 1; grid-column: 9 / 13; margin-inline: 0 var(--fs-pad); background: var(--fs-seat); box-shadow: inset 0 2px 3px color-mix(in oklab, var(--color-accent-ink) 80%, transparent), inset 0 0 0 1px var(--color-rule-2); }

.fp-stack__name { grid-row: 2; grid-column: 1 / 9; display: flex; align-items: center; gap: var(--space-sm); padding: var(--space-xl) 0 0 var(--fs-pad); font: 500 var(--text-title)/1 var(--font-display); font-stretch: 112%; letter-spacing: -0.01em; color: var(--color-ink); }
.fp-stack__name img { width: 32px; height: auto; flex: none; }

/* what moves inside */
.fp-stack__inside { grid-row: 3; grid-column: 1 / 9; padding: var(--space-lg) 0 0 var(--fs-pad); }
.fp-stack__ilab { margin-bottom: var(--space-sm); }
.fp-stack__body .label { color: var(--color-ink-2); } /* holds 4.5:1 at the gradient's lightest */
.fp-stack__work { margin: 0; padding: 0; list-style: none; }
.fp-stack__work li {
  position: relative; display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); column-gap: var(--gap-columns); align-items: baseline;
  padding-block: var(--space-sm); border-top: 1px solid color-mix(in oklab, var(--color-rule-2) 70%, var(--color-paper-3));
}
.fp-stack__w { color: var(--color-ink); }
.fp-stack__p { color: var(--color-ink-2); }

/* the side: the bay the work tools drop into, the switch, the closing line */
.fp-stack__side { grid-row: 2 / 4; grid-column: 9 / 13; display: flex; flex-direction: column; gap: var(--space-lg); padding: var(--space-xl) var(--fs-pad) 0 0; }
.fp-stack__bay {
  position: relative; display: flex; flex-direction: column; min-height: var(--fs-bay, 184px);
  background: linear-gradient(to bottom, color-mix(in oklab, var(--color-paper-2) 70%, var(--color-paper)), color-mix(in oklab, var(--color-paper-3) 60%, var(--color-paper-2)));
  box-shadow: inset 0 2px 6px color-mix(in oklab, var(--color-accent-ink) 70%, transparent), inset 0 0 0 1px var(--color-rule-2);
}
.fp-stack__bay::before { /* the socket the module's key fits */
  content: ""; position: absolute; left: var(--space-lg); top: var(--space-sm); width: 40px; height: 6px;
  background: linear-gradient(to right, var(--fs-seat) 0 8px, transparent 8px 32px, var(--fs-seat) 32px);
  box-shadow: 0 1px 0 color-mix(in oklab, var(--color-ink) 10%, transparent);
}
html:not(.js) .fp-stack__bay { display: none; }
.fp-stack__close { max-width: 30ch; color: var(--color-ink-2); }

/* seated: the module sits flat in its bay, quieter, its key put away */
.fp-stack__bay .fp-stack__mod--work { flex: 1; }
.fp-stack__bay .fp-stack__mod--work::before, .fp-stack__bay .fp-stack__mod--work::after { opacity: 0; }
.fp-stack__mod--work > * { position: relative; z-index: 1; }
.fp-stack__mod--work .fp-stack__shade { position: absolute; inset: 0; z-index: 0; background: var(--fs-seat); box-shadow: inset 0 0 0 1px var(--color-rule-2); opacity: 0; transition: opacity 240ms var(--ease-out); pointer-events: none; }
.fp-stack__bay .fp-stack__shade { opacity: 1; transition-delay: 260ms; }
.fp-stack__bay .fp-stack__tool, .fp-stack__bay .fp-stack__mark { color: var(--color-ink-2); }

/* the tie: the seated tools and the backlog they became share one azure line across the column gap */
.fp-stack__work li:first-child::after {
  content: ""; position: absolute; left: 100%; top: 50%; width: var(--gap-columns); height: 1px; background: var(--color-accent);
  transform: scaleX(0); transform-origin: right; transition: transform 160ms var(--ease-out);
}
.js [data-state="all"] .fp-stack__work li:first-child::after { transform: none; transition: transform 240ms var(--ease-out) 340ms; }

/* the switch: your choice of view. Consolidated is the choice to switch tools off, so its light is gold. */
.fp-stack__switch { display: flex; align-self: flex-start; box-shadow: inset 0 0 0 1px var(--color-rule-2); }
.fp-stack__set {
  position: relative; display: inline-flex; align-items: center; gap: var(--space-xs); min-height: 44px; margin: 0; padding: 0 var(--space-md);
  border: 0; border-radius: 0; background: transparent; color: var(--color-ink-2); font: 500 var(--text-sm)/1 var(--font-body); white-space: nowrap; cursor: pointer;
  transition: background-color var(--dur-short) var(--ease-out), color var(--dur-short) var(--ease-out);
  -webkit-tap-highlight-color: transparent;
}
.fp-stack__set::before { content: ""; width: 8px; height: 8px; flex: none; box-shadow: inset 0 0 0 1px var(--color-muted); }
.fp-stack__set:hover { background: color-mix(in oklab, var(--color-paper-3) 70%, var(--color-ink)); color: var(--color-ink); }
.fp-stack__set:active { transform: translateY(1px); }
.fp-stack__set:focus-visible { outline: 2px solid var(--color-focus); outline-offset: 2px; z-index: 1; transition: none; }
.fp-stack__set:disabled { opacity: 0.5; cursor: not-allowed; }
.fp-stack__set[aria-pressed="true"] { background: var(--color-paper); color: var(--color-ink); cursor: default; }
.fp-stack__set[aria-pressed="true"]::before { background: var(--color-ink); box-shadow: none; }
.fp-stack__set--all[aria-pressed="true"]::before { background: var(--color-gold); }
html:not(.js) .fp-stack__switch { display: none; }

/* ===== The base: what the factory builds on. Docked, lit from the body above, and it stays. ===== */
.fp-stack__base {
  position: relative; grid-row: 3; grid-column: 1 / -1; display: grid; grid-template-columns: 1.15fr 1.5fr 1.5fr 1.15fr 0.95fr; gap: var(--fs-gap) var(--space-md);
  margin: var(--fs-gap) 0 0; padding: 0; list-style: none;
}
.fp-stack__base::before { /* the floor the modules stand on, in the page's dawn light */
  content: ""; position: absolute; z-index: -1; inset: 30% -4% -56px; pointer-events: none;
  background: radial-gradient(ellipse 50% 55% at 50% 70%, color-mix(in oklab, var(--color-dawn) 11%, transparent), transparent 100%);
}
.fp-stack__mod--models .fp-stack__tools, .fp-stack__mod--cloud .fp-stack__tools { display: grid; grid-template-columns: repeat(2, max-content); }

/* ===== The state change (scripting on). The module's flight is set by script (FLIP); CSS holds the rest. ===== */
.js .fp-stack__p { opacity: 0; transform: translateX(-8px); transition: opacity 160ms var(--ease-out), transform 160ms var(--ease-out); }
.js [data-state="all"] .fp-stack__p { opacity: 1; transform: none; transition-duration: 300ms; }
.js [data-state="all"] li:nth-child(1) .fp-stack__p { transition-delay: 300ms; }
.js [data-state="all"] li:nth-child(2) .fp-stack__p { transition-delay: 360ms; }
.js [data-state="all"] li:nth-child(3) .fp-stack__p { transition-delay: 405ms; }
.js [data-state="all"] li:nth-child(4) .fp-stack__p { transition-delay: 435ms; }
.js [data-state="all"] li:nth-child(5) .fp-stack__p { transition-delay: 455ms; }
@media (prefers-reduced-motion: reduce) {
  .js .fp-stack__p, .fp-stack__mod--work, .fp-stack__shade, .fp-stack__work li:first-child::after { transition: none !important; }
}

/* ===== Narrower ===== */
@media (max-width: 72rem) {
  .fp-stack__head { grid-column: 1 / 8; }
  .fp-stack__dock, .fp-stack__slot, .fp-stack__side { grid-column: 8 / 13; }
  .fp-stack__name, .fp-stack__inside { grid-column: 1 / 8; }
  .fp-stack__mod--work { padding-inline: var(--space-md); }
  .fp-stack__bay::before { left: var(--space-md); }
  .fp-stack__mod--work::before { left: var(--space-md); } .fp-stack__mod--work::after { left: calc(var(--space-md) + 8px); }
  .fp-stack__base { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .fp-stack__mod--code, .fp-stack__mod--models, .fp-stack__mod--cloud { grid-column: span 2; }
  .fp-stack__mod--fw, .fp-stack__mod--traces { grid-column: span 3; }
}
@media (max-width: 60rem) {
  .fp-stack { --fs-pad: var(--space-lg); }
  .fp-stack__rig { grid-template-columns: minmax(0, 1fr); }
  .fp-stack__head, .fp-stack__dock, .fp-stack__body, .fp-stack__base { grid-column: 1; grid-row: auto; }
  .fp-stack__dock { margin-inline: var(--fs-pad); }
  .fp-stack__dock:empty { margin-bottom: 0; }
  .fp-stack__body { grid-template-columns: minmax(0, 1fr); grid-template-rows: 6px auto auto auto; }
  .fp-stack__slot, .fp-stack__name, .fp-stack__side, .fp-stack__inside { grid-column: 1; }
  .fp-stack__slot { grid-row: 1; margin-inline: var(--fs-pad); }
  .fp-stack__name { grid-row: 2; padding: var(--fs-pad) var(--fs-pad) 0; }
  .fp-stack__side { grid-row: 3; padding: var(--fs-pad) var(--fs-pad) 0; }
  .fp-stack__inside { grid-row: 4; padding: var(--space-xl) var(--fs-pad) 0; }
  .fp-stack__work li:first-child::after { display: none; }
  .fp-stack__base { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .fp-stack__mod--code, .fp-stack__mod--models, .fp-stack__mod--cloud, .fp-stack__mod--fw { grid-column: auto; }
  .fp-stack__mod--traces { grid-column: 1 / -1; }
}
@media (max-width: 40rem) {
  .fp-stack__work li { grid-template-columns: minmax(0, 1fr); row-gap: var(--space-2xs); }
  /* one column: in Day one the line is not there at all, so no gap opens; it arrives with Consolidated */
  .js [data-state="day"] .fp-stack__p { display: none; }
  .fp-stack__base { grid-template-columns: minmax(0, 1fr); }
  .fp-stack__mod--traces { grid-column: auto; }
  .fp-stack__mod { padding-inline: var(--space-md); }
  .fp-stack__mod::before { left: var(--space-md); } .fp-stack__mod::after { left: calc(var(--space-md) + 8px); }
}
@media (max-width: 40rem) and (prefers-reduced-motion: no-preference) {
  @starting-style { .js [data-state="all"] .fp-stack__p { opacity: 0; transform: translateX(-8px); } }
}
