/* TRK-953: New funnel's gallery (funnel-gallery-view-953.js), made for funnels: funnels under their goal, each a row
   of its steps in order, and a full preview with the steps numbered down the side. From New website's gallery
   (site-gallery.css) it borrows only the search box, chips, desktop/phone toggle and preview frame. */

dialog.fmap-goal:not(.site-new)[open]:has(.fg-view, .fg-preview) { display: flex; flex-direction: column; width: min(1120px, calc(100vw - 32px)); height: min(900px, calc(100dvh - 32px)); max-height: none; overflow: hidden; }
dialog.fmap-goal:not(.site-new):has(.fg-view, .fg-preview) .fmap-goal-body { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.fg-view, .fg-preview { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.fg-view[hidden] { display: none; }

.fg-head > h2, .fg-head > .sub { padding-right: 32px; }
.fg-head > .sub { margin: 0; text-wrap: pretty; }
.fg-tools { display: grid; gap: 10px; margin-top: 14px; }
/* Search and the kind side by side; the kind goes under the search on a phone. The kind fills its cell, not the
   width the app measures for selects (styles.css) */
.fg-find { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 220px); gap: 8px; }
.fg-find > select.fg-kind { width: 100%; height: 40px; min-width: 0; font-size: 16px; border-radius: 999px; padding: 0 12px; }

.fg-scroll { --fg-w: 132px; flex: 1; min-height: 0; margin: 10px -24px -24px; padding: 0 24px 24px; overflow: auto; overscroll-behavior: contain; }
.fg-scroll .fmap-goal-more { margin: 22px 0 0; }
.fg-groups { --fg-scale: 0.1; }

/* A goal: its name and line, then its funnels, one per row */
.fg-group { padding-top: 18px; }
.fg-group-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 10px; padding-bottom: 6px; }
dialog.confirm-box .fg-group-head h3 { margin: 0; font-size: 16px; font-weight: 600; }
dialog.confirm-box .fg-group-head .sub { margin: 0; font-size: 13px; text-wrap: pretty; }
.fg-rows { list-style: none; margin: 0; padding: 0; }
.fg-row { display: grid; grid-template-columns: minmax(0, 220px) minmax(0, 1fr); gap: 24px; padding: 16px 0; border-top: 1px solid var(--border); }

.fg-row-head { display: grid; align-content: start; gap: 2px; min-width: 0; }
.fg-open { justify-self: start; padding: 0; font-size: 15px; font-weight: 600; text-align: left; color: var(--text); background: none; border: 0; border-radius: 4px; overflow-wrap: anywhere; }
.fg-open:hover { background: none; text-decoration: underline; text-underline-offset: 3px; }
.fg-open:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.fg-kind-name { font-weight: 400; color: var(--muted); }
.fg-count { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
dialog.confirm-box .fg-why { margin: 4px 0 0; font-size: 13px; text-wrap: pretty; }

/* The steps in order, joined by a thin line; each a small preview of its page with its number and name */
.fg-path { list-style: none; margin: 0; padding: 2px 0 4px; display: flex; gap: 22px; overflow-x: auto; scrollbar-width: thin; scroll-snap-type: x proximity; }
.fg-step { position: relative; flex: 0 0 var(--fg-w); min-width: 0; scroll-snap-align: start; }
.fg-step + .fg-step::before { content: ""; position: absolute; top: calc(var(--fg-w) * 0.375); left: -18px; width: 14px; border-top: 1.5px solid var(--border); }
.fg-step-open { display: grid; gap: 7px; width: 100%; padding: 0; text-align: left; color: var(--text); background: none; border: 0; border-radius: 8px; touch-action: manipulation; }
.fg-step-open:hover { background: none; }
.fg-step-open:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.fg-thumb { position: relative; display: block; aspect-ratio: 4 / 3; overflow: hidden; background: var(--fg-bg, var(--sunken)); border: 1px solid var(--border); border-radius: 8px; transition: border-color 150ms ease, box-shadow 150ms ease; contain: strict; }
.fg-thumb iframe { position: absolute; top: 0; left: 0; border: 0; transform: scale(var(--fg-scale)); transform-origin: 0 0; pointer-events: none; opacity: 0; transition: opacity 200ms ease; }
.fg-thumb.is-drawn iframe { opacity: 1; }
@media (hover: hover) and (pointer: fine) { .fg-step-open:hover .fg-thumb { border-color: var(--muted); box-shadow: 0 4px 12px -6px rgb(16 24 40 / 0.3); } }
.fg-step-open:active .fg-thumb { transform: scale(0.98); }
.fg-step-name { display: flex; align-items: center; gap: 6px; min-width: 0; font-size: 13px; line-height: 1.3; overflow-wrap: anywhere; }
.fg-num { display: inline-grid; place-items: center; flex-shrink: 0; min-width: 20px; height: 20px; padding: 0 5px; font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--muted); background: var(--sunken); border-radius: 999px; }

.fg-blank { display: grid; gap: 2px; margin-top: 18px; padding: 14px 16px; border: 1px dashed var(--border); border-radius: var(--radius); }
.fg-blank-open { display: inline-flex; align-items: center; gap: 8px; justify-self: start; padding: 0; font-size: 15px; font-weight: 600; color: var(--text); background: none; border: 0; }
.fg-blank-open:hover { background: none; text-decoration: underline; text-underline-offset: 3px; }
dialog.confirm-box .fg-blank .sub { margin: 0; font-size: 13px; }
.fg-empty { padding: 28px 0 10px; }

/* ---- The full preview: the steps down the side, the step itself beside them ---- */
.fg-pbar { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "back back" "title actions"; align-items: end; gap: 2px 16px; padding-right: 32px; }
.fg-back { grid-area: back; justify-self: start; margin-bottom: 4px; }
.fg-ptitle { grid-area: title; min-width: 0; }
dialog.confirm-box .fg-ptitle h2 { margin: 0; overflow-wrap: anywhere; }
.fg-ptitle h2:focus { outline: none; }
dialog.confirm-box .fg-ptitle p { margin: 2px 0 0; text-wrap: pretty; }
.fg-pactions { grid-area: actions; display: flex; align-items: center; gap: 10px; }
.fg-use { min-height: 36px; padding: 6px 18px; }

.fg-pbody { display: grid; grid-template-columns: 196px minmax(0, 1fr); gap: 20px; flex: 1; min-height: 0; margin-top: 16px; }
.fg-rail { position: relative; display: flex; flex-direction: column; gap: 4px; align-self: start; }
.fg-rail::before { content: ""; position: absolute; top: 18px; bottom: 18px; left: 22px; border-left: 1.5px solid var(--border); }
.fg-rail-step { position: relative; display: flex; align-items: center; gap: 10px; min-height: 36px; padding: 6px 12px; font-size: 14px; text-align: left; color: var(--muted); background: transparent; border: 1px solid transparent; border-radius: 8px; overflow-wrap: anywhere; touch-action: manipulation; }
.fg-rail-step .fg-num { background: var(--surface); box-shadow: 0 0 0 1.5px var(--border); }
.fg-rail-step[aria-pressed="true"] { color: var(--text); font-weight: 600; background: var(--sunken); border-color: var(--border); }
.fg-rail-step[aria-pressed="true"] .fg-num { color: var(--primary-text); background: var(--primary); box-shadow: none; }
@media (hover: hover) and (pointer: fine) { .fg-rail-step:not([aria-pressed="true"]):hover { color: var(--text); background: var(--sunken); } }
.fg-rail-step:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.fg-pmain { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
dialog.confirm-box .fg-purpose { margin: 0 0 10px; font-size: 13px; text-wrap: pretty; }

@media (max-width: 720px) {
  .fg-row { grid-template-columns: minmax(0, 1fr); gap: 12px; }
}
@media (max-width: 560px) {
  dialog.fmap-goal:not(.site-new)[open]:has(.fg-view, .fg-preview) { width: calc(100vw - 16px); height: calc(100dvh - 16px); padding: 18px 16px; }
  .fg-find { grid-template-columns: minmax(0, 1fr); }
  .fg-scroll { --fg-w: 112px; margin: 8px -16px -18px; padding: 0 16px 18px; }
  .fg-path { margin: 0 -16px; padding: 2px 16px 4px; scroll-padding: 0 16px; }
  .fg-pbar { grid-template-columns: minmax(0, 1fr); grid-template-areas: "back" "title" "actions"; gap: 6px; }
  .fg-pactions { justify-content: space-between; }
  .fg-use { flex: 1; }
  /* The steps go in one row above the step on a phone */
  .fg-pbody { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); gap: 8px; margin-top: 12px; }
  .fg-rail { flex-direction: row; overflow-x: auto; scrollbar-width: none; margin: 0 -16px; padding: 0 16px; }
  .fg-rail::-webkit-scrollbar { display: none; }
  .fg-rail::before { display: none; }
  .fg-rail-step { flex-shrink: 0; font-size: 13px; padding: 5px 10px; gap: 7px; }
}
@media (prefers-reduced-motion: reduce) { .fg-thumb iframe { transition: none; } .fg-step-open:active .fg-thumb { transform: none; } }
