/* fp-gates: one gate, close up, at dawn. A gold archway with depth stands on the horizon; a block of work waits in front of
   it at the end of its azure trace, a road back to the requirement it came from (generated, reviewed by three parallel
   strands, fixed, verified). The visitor is the person at the gate, and each decision ends in its own picture.
   Approved: the leaves stand open on warm light, the sealed work sits at the next station down the lit way, light spills
   onto the ground, and the next piece of work waits a step back. Sent back: the leaves are shut, nothing shows beyond,
   and the work stands at the gate again with a hollow gold mark after travelling back up its trace to be fixed.
   Every decision drops a mark onto the record under the gate, which starts empty. Azure is the agents' work; gold is the
   person's decision. */
.fp-gates {
  --fg-dur: 380ms;
  padding-block: var(--space-3xl);
}

/* ===== Layout: words on the left, the gate on the right ===== */
.fp-gates__grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); column-gap: var(--gap-columns); row-gap: var(--space-xl); align-items: start; }
.fp-gates__grid > * { min-width: 0; }
.fp-gates__head { grid-column: 1 / 5; grid-row: 1; display: grid; gap: var(--space-lg); }
.fp-gates__head h2 { max-width: 14ch; }
.fp-gates__line { max-width: 30ch; }
.fp-gates__steps { grid-column: 1 / 5; grid-row: 2; align-self: end; }
.fp-gates__stage { grid-column: 5 / -1; grid-row: 1 / span 2; align-self: center; }

/* ===== The four steps: an ordered list with no numerals, each keyed to its part of the scene ===== */
.fp-gates__steps { display: grid; gap: var(--space-lg); margin: 0; padding: 0; list-style: none; }
.fp-gates__step { display: grid; grid-template-columns: 28px minmax(0, 1fr); column-gap: var(--space-md); align-items: start; }
.fp-gates__step p { max-width: 46ch; color: var(--color-ink-2); }
.fp-gates__step strong { font-weight: 500; color: var(--color-ink); }
.fp-gates__key { width: 28px; height: 20px; margin-top: var(--space-2xs); fill: none; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.fp-gates__step--checks .fp-gates__key, .fp-gates__step--trace .fp-gates__key { stroke: var(--color-accent); }
.fp-gates__key-card { fill: color-mix(in oklab, var(--color-accent) 22%, var(--color-paper)); }
.fp-gates__step--gate .fp-gates__key, .fp-gates__step--record .fp-gates__key { stroke: var(--color-gold); }
.fp-gates__key-fill { fill: var(--color-gold); }

/* ===== The scene ===== */
.fp-gates__scene { position: relative; aspect-ratio: 820 / 500; }
.fp-gates__plate { position: absolute; inset: 0; }
.fp-gates__svg {
  position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible;
  --fg-mask: linear-gradient(90deg, transparent, var(--color-ink) 7%, var(--color-ink) 93%, transparent), linear-gradient(transparent, var(--color-ink) 10%, var(--color-ink) 94%, transparent);
  -webkit-mask-image: var(--fg-mask); -webkit-mask-composite: source-in;
  mask-image: var(--fg-mask); mask-composite: intersect;
}
.fp-gates__svg * { vector-effect: non-scaling-stroke; }
.fp-gates__svg--front { pointer-events: none; }
.fp-gates__horizon { stroke: var(--color-rule-2); stroke-width: 1; fill: none; }
.fp-gates__spill { fill: url(#fpg-spill); }
.fp-gates__pool { fill: url(#fpg-pool); }

/* the trace: azure, the agents' work */
.fp-gates__thread { stroke: var(--color-accent); stroke-width: 2; fill: none; stroke-linecap: round; opacity: 0.85; }
.fp-gates__origin { fill: var(--color-paper-2); stroke: var(--color-accent); stroke-width: 1.5; }
.fp-gates__knot { fill: var(--color-paper); stroke: var(--color-accent); stroke-width: 2; }
.fp-gates__knot--fix { transform-box: fill-box; transform-origin: center; }

/* the gate: a dark frame that takes a little of the dawn, one gold line at its opening, two leaves, and the lit way beyond.
   Gold stays a line here; the only solid gold in the section is the decision itself (the Approve button, the seal, the marks). */
.fp-gates__frame { fill: url(#fpg-frame); }
.fp-gates__reveal { fill: color-mix(in oklab, var(--color-gold) 8%, var(--color-paper)); }
.fp-gates__edge { fill: none; stroke: var(--color-gold); stroke-width: 1.5; opacity: 0.85; }
.fp-gates__sill { stroke: var(--color-gold-rule); stroke-width: 2; }
.fp-gates__beyond { fill: url(#fpg-beyond); }
.fp-gates__road { fill: url(#fpg-road); }
.fp-gates__far-in { fill: var(--color-dawn); }
.fp-gates__far { fill: none; stroke: var(--color-gold-ink); stroke-width: 2.5; opacity: 0.55; }
.fp-gates__leaf { transform-box: view-box; }
.fp-gates__leaf--l { transform-origin: 508px 0; }
.fp-gates__leaf--r { transform-origin: 692px 0; }
.fp-gates__leaf-face { fill: url(#fpg-leaf); }
.fp-gates__panel { fill: color-mix(in oklab, var(--color-paper-3) 70%, var(--color-paper-2)); stroke: var(--color-gold-rule); stroke-width: 1; }
.fp-gates__seam-glow { stroke: var(--color-dawn); stroke-width: 9; opacity: 0.22; }
.fp-gates__seam-line { stroke: var(--color-dawn); stroke-width: 1.5; }

/* the record: gold, a person's decisions; filled approved, hollow sent back */
.fp-gates__ledger { stroke: var(--color-gold-rule); stroke-width: 1; }
.fp-gates__mark { fill: var(--color-gold); stroke: var(--color-gold); stroke-width: 1.5; }
.fp-gates__mark--back { fill: var(--color-paper); }

/* the work: a block of azure, sealed in gold when a person approves it */
.fp-gates__work { transform-box: view-box; transform-origin: 0 0; }
.fp-gates__shadow { fill: var(--color-paper); opacity: 0.6; }
.fp-gates__face { fill: color-mix(in oklab, var(--color-accent) 18%, var(--color-paper-2)); stroke: var(--color-accent); stroke-width: 1.5; }
.fp-gates__side { fill: color-mix(in oklab, var(--color-accent) 10%, var(--color-paper)); stroke: var(--color-accent-2); stroke-width: 1; }
.fp-gates__top { fill: color-mix(in oklab, var(--color-accent) 55%, var(--color-paper-3)); stroke: var(--color-accent); stroke-width: 1; }
.fp-gates__diff { stroke: var(--color-accent); stroke-width: 3; opacity: 0.85; }
.fp-gates__diff--fix { transform-box: fill-box; transform-origin: 0 50%; }
.fp-gates__seal path { fill: var(--color-gold); stroke: var(--color-gold); stroke-width: 1; }
.fp-gates__badge { fill: var(--color-paper); stroke: var(--color-gold); stroke-width: 2; }

/* the scene's few words: the copy's own words, set beside the trace */
.fp-gates__tags { position: absolute; inset: 0; margin: 0; padding: 0; list-style: none; pointer-events: none; }
.fp-gates__tags li { position: absolute; left: var(--x); top: var(--y); transform: translate(-100%, -50%); font-size: var(--text-md); line-height: 1; color: var(--color-accent); white-space: nowrap; }

/* ===== The desk: the prompt, the two buttons, what was decided ===== */
.fp-gates__desk { display: grid; justify-items: center; gap: var(--space-md); margin-top: var(--space-xs); text-align: center; }
.fp-gates__you { color: var(--color-gold); }
.fp-gates__btns { display: flex; flex-wrap: wrap; justify-content: center; gap: var(--space-sm); }
.fp-gates__btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-xs);
  min-height: 48px; min-width: 9.5rem; padding-inline: var(--space-lg); border: 1px solid var(--color-gold); border-radius: 0;
  background: var(--color-gold); color: var(--color-gold-ink); font: 500 var(--text-md)/1 var(--font-body); white-space: nowrap; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background-color var(--dur-short) var(--ease-out), border-color var(--dur-short) var(--ease-out), color var(--dur-short) var(--ease-out), transform var(--dur-micro) var(--ease-out);
}
.fp-gates__btn:hover { background: var(--color-dawn); border-color: var(--color-dawn); }
.fp-gates__btn:active { transform: translateY(1px); }
.fp-gates__btn:focus-visible { outline: 2px solid var(--color-focus); outline-offset: 3px; transition: none; }
.fp-gates__btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.fp-gates__btn--back { background: transparent; color: var(--color-ink); border-color: var(--color-gold-rule); }
.fp-gates__btn--back:hover { background: var(--color-gold-wash); border-color: var(--color-gold-2); color: var(--color-ink); }
/* the result line keeps its place before the first decision, so deciding never moves the page */
.fp-gates__said { min-height: 1.6em; color: var(--color-ink); }
@media (max-width: 30rem) { .fp-gates__said { min-height: 3.2em; } }
.fp-gates__outcomes { display: grid; gap: var(--space-2xs); margin: 0; padding: 0; list-style: none; color: var(--color-ink-2); }
.fp-gates__outcome { display: inline-flex; align-items: center; justify-content: center; gap: var(--space-xs); }
.fp-gates__outcome::before { content: ""; width: 9px; height: 9px; flex-shrink: 0; transform: rotate(45deg); border: 1.5px solid var(--color-gold); }
.fp-gates__outcome--yes::before { background: var(--color-gold); }

/* scripting on: the decision is live, and only the latest outcome shows. Scripting off: the scene waits, both outcomes read as text. */
html:not(.js) .fp-gates__btns, html:not(.js) .fp-gates__said { display: none; }
.js .fp-gates__outcomes { display: none; }

/* ===== Narrower ===== */
@media (max-width: 68rem) {
  .fp-gates__head { grid-column: 1 / -1; grid-row: 1; }
  .fp-gates__head h2 { max-width: 22ch; }
  .fp-gates__stage { grid-column: 1 / -1; grid-row: 2; }
  .fp-gates__steps { grid-column: 1 / -1; grid-row: 3; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: var(--gap-columns); row-gap: var(--space-lg); }
}
@media (max-width: 40rem) {
  .fp-gates__steps { grid-template-columns: minmax(0, 1fr); }
  /* the phone keeps the trace and the gate, runs to both edges, and stands taller */
  .fp-gates__scene { aspect-ratio: 680 / 500; margin-inline: calc(-1 * var(--gutter)); overflow: hidden; }
  .fp-gates__plate { inset: 0 auto 0 2.94%; width: 120.59%; }
  .fp-gates__svg { --fg-mask: linear-gradient(transparent, var(--color-ink) 8%, var(--color-ink) 94%, transparent); -webkit-mask-composite: source-over; mask-composite: add; }
  .fp-gates__tags li { font-size: var(--text-sm); }
  .fp-gates__tags .fp-gates__tag--origin { transform: translate(var(--space-sm), -100%); }
  .fp-gates__tag--wide { display: none; } /* on a phone the trace keeps three of its words, so none crowd */
  .fp-gates__btns { width: 100%; }
  .fp-gates__btn { flex: 1 1 8rem; min-width: 0; padding-inline: var(--space-md); }
}
