/* Funnel map (TRK-847): a funnel's steps as cards in a row, with + between them. Tokens come from styles.css. */

.fmap-home { max-width: none; }
.fmap { --fmap-card: 232px; --fmap-link: 56px; min-width: 0; }

/* The row scrolls sideways when the steps don't fit, and snaps to each card */
.fmap-row { list-style: none; margin: 0; padding: 4px 4px 14px; display: flex; align-items: stretch; overflow-x: auto; overscroll-behavior-x: contain; scroll-snap-type: x proximity; scroll-padding: 4px; }
.fmap-step { display: flex; align-items: stretch; flex: 0 0 auto; scroll-snap-align: start; }

/* A step's card. Its name button stretches over the whole card, so a click anywhere opens the editor */
.fmap-card { position: relative; width: var(--fmap-card); display: flex; flex-direction: column; gap: 10px; padding: 10px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; transition: border-color 150ms ease, box-shadow 150ms ease; }
@media (hover: hover) and (pointer: fine) {
  .fmap-card:hover { border-color: color-mix(in srgb, var(--accent) 55%, var(--border)); box-shadow: 0 4px 14px rgba(16, 24, 40, .07); }
}
.fmap-card:has(.fmap-open:focus-visible) { border-color: var(--accent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 30%, transparent); }
.fmap-card:has(.fmap-open:active) { transform: scale(0.99); }

.fmap-card-top { display: flex; align-items: center; gap: 8px; min-height: 28px; }
.fmap-num { font-size: 12px; font-weight: 600; color: var(--muted); font-variant-numeric: tabular-nums; letter-spacing: .01em; }
.fmap-more { position: relative; z-index: 2; margin-left: auto; width: 28px; height: 28px; padding: 0; display: inline-flex; align-items: center; justify-content: center; color: var(--muted); border-radius: 6px; flex-shrink: 0; }
.fmap-more svg { width: 18px; height: 18px; }
.fmap-more[aria-expanded="true"] { background: var(--selected); color: var(--selected-text); }

.fmap-pic { border: 1px solid var(--border); border-radius: 8px; background: var(--sunken); overflow: hidden; }
.fmap-pic .funnel-thumb { width: 100%; }

.fmap-card-body { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.fmap-open { all: unset; cursor: pointer; display: block; min-width: 0; font-weight: 600; font-size: 14px; line-height: 1.35; color: var(--text); }
.fmap-open::after { content: ""; position: absolute; inset: 0; border-radius: 12px; z-index: 1; }
.fmap-open:focus-visible { outline: none; }
/* styles.css shades hovered buttons and nudges pressed ones; the card shows hover itself, and a transform here
   would shrink the card-wide hit area mid-click */
.fmap-open:hover, .fmap-open:active { background: none; border: 0; transform: none; }
.fmap-name { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.fmap-addr { font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fmap-stats { display: flex; flex-wrap: wrap; gap: 2px 10px; font-size: 13px; font-variant-numeric: tabular-nums; }

/* The connector after each card: a line with a + on it. The last one ends the row. */
.fmap-link { flex: 0 0 var(--fmap-link); display: flex; align-items: center; justify-content: center; position: relative; }
.fmap-link.is-end { flex-basis: 52px; justify-content: flex-start; padding-left: 10px; }
.fmap-line { flex: 1 1 auto; height: 2px; background: var(--border); min-width: 6px; }
.fmap-link.is-end .fmap-line { flex: 0 0 10px; }
.fmap-add { position: relative; flex: 0 0 auto; width: 30px; height: 30px; padding: 0; border-radius: 999px; display: inline-flex; align-items: center; justify-content: center; background: var(--surface); color: var(--muted); border: 1px solid var(--border); transition: color 150ms ease, border-color 150ms ease, background-color 150ms ease, transform 120ms ease; touch-action: manipulation; }
.fmap-add::before { content: ""; position: absolute; inset: -7px; border-radius: 999px; } /* a 44px target on touch */
.fmap-add svg { width: 16px; height: 16px; }
@media (hover: hover) and (pointer: fine) {
  .fmap-add:hover:not(:disabled) { color: var(--accent); border-color: var(--accent); }
}
.fmap-add:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.fmap-add:active:not(:disabled) { transform: scale(0.94); }
.fmap-add[aria-expanded="true"] { color: var(--accent-text); background: var(--accent); border-color: var(--accent); }
.fmap-add:disabled { opacity: .45; cursor: not-allowed; }

.fmap-note { margin: 8px 4px 0; font-size: 13px; max-width: 70ch; }

/* The floating menus (+ and …). They sit on the page, not in the scrolling row, so nothing clips them. */
.fmap-menu { position: fixed; right: auto; max-height: min(420px, calc(100dvh - 16px)); overflow-y: auto; overscroll-behavior: contain; min-width: 210px; max-width: min(300px, calc(100vw - 16px)); z-index: 1000; }
.fmap-menu-sep { height: 1px; margin: 4px 6px; background: var(--border); }
.fmap-menu-label { padding: 6px 10px 2px; font-size: 12px; }
.fmap-menu .fmap-menu-group { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.fmap-chev { display: inline-flex; color: var(--muted); transform: rotate(-90deg); transition: transform 150ms ease; }
.fmap-chev svg { width: 14px; height: 14px; }
.fmap-menu-group[aria-expanded="true"] .fmap-chev { transform: none; }
@media (prefers-reduced-motion: reduce) { .fmap-chev { transition: none; } }
.fmap-menu-list { display: flex; flex-direction: column; gap: 2px; padding-left: 10px; margin-left: 10px; border-left: 1px solid var(--border); }
.fmap-menu-list [role="menuitem"] { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* No steps yet */
.fmap-empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px; padding: 40px 20px; max-width: 520px; margin: 8px auto; border: 1px dashed var(--border); border-radius: 12px; background: var(--surface); }
.fmap-empty h2 { margin: 6px 0 0; font-size: 17px; }
.fmap-empty p { margin: 0 0 8px; max-width: 46ch; text-wrap: pretty; }
.fmap-empty-pic .funnel-mini { width: 36px; height: 48px; gap: 4px; padding: 6px; }

/* Cards settle in when the map first draws; nothing moves for people who ask for less motion */
.fmap-animate .fmap-card { animation: fmap-in 220ms cubic-bezier(0.23, 1, 0.32, 1) both; }
@keyframes fmap-in { from { opacity: 0; transform: translateY(4px); } }

/* Phones: the steps stack top to bottom, with the connectors running down */
@media (max-width: 640px) {
  .fmap-row { flex-direction: column; overflow-x: visible; padding: 0; scroll-snap-type: none; }
  .fmap-step { flex-direction: column; align-items: stretch; }
  .fmap-card { width: auto; display: grid; grid-template-columns: 112px minmax(0, 1fr); grid-template-areas: "top top" "pic body"; column-gap: 12px; row-gap: 8px; }
  .fmap-card-top { grid-area: top; }
  .fmap-pic { grid-area: pic; align-self: start; }
  .fmap-card-body { grid-area: body; }
  .fmap-link, .fmap-link.is-end { flex: 0 0 auto; flex-direction: column; height: 52px; padding: 0; justify-content: center; }
  .fmap-link.is-end { height: 44px; justify-content: flex-start; }
  .fmap-line { width: 2px; height: auto; min-height: 6px; flex: 1 1 auto; }
  .fmap-link.is-end .fmap-line { flex: 0 0 8px; }
}

/* New funnel: pick a goal */
.fmap-goal { width: min(640px, calc(100vw - 32px)); }
.fmap-goal .form-actions { margin-top: 16px; }
.fmap-goals { list-style: none; margin: 14px 0 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.fmap-goal-card { display: grid; gap: 3px; width: 100%; height: 100%; padding: 12px 14px; text-align: left; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; transition: border-color 150ms ease; align-content: start; }
.fmap-goal-card .sub { font-size: 13px; }
.fmap-goal-card .fmap-goal-steps { font-size: 12px; margin-top: 4px; overflow-wrap: anywhere; }
.fmap-goal-card.is-blank { border-style: dashed; }
@media (hover: hover) and (pointer: fine) { .fmap-goal-card:hover { border-color: var(--accent); } }
.fmap-goal-card:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.fmap-goal-card:active { transform: scale(0.98); }
.fmap-goal-more { margin: 14px 0 0; font-size: 13px; }
.fmap-goal-more .link { font-size: inherit; padding: 0; }
.fmap-outline { list-style: none; margin: 14px 0 16px; padding: 12px; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 6px; background: var(--sunken); border-radius: 10px; }
.fmap-outline li { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 500; }
.fmap-outline .funnel-mini { width: 22px; height: 30px; }
.fmap-arrow { color: var(--muted); margin-left: 2px; }
/* TRK-898: which page a funnel starts with, where it offers more than one (Sell a product) */
.fmap-first { margin: 14px 0 0; padding: 0; border: 0; min-width: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.fmap-first legend { padding: 0; margin-bottom: 6px; font-size: 12px; color: var(--muted); }
.fmap-first-option { display: flex; align-items: flex-start; gap: 10px; min-width: 0; padding: 10px 12px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; cursor: pointer; transition: border-color 150ms ease; }
.fmap-first-option input { flex-shrink: 0; margin: 3px 0 0; accent-color: var(--accent); }
.fmap-first-option:has(input:checked) { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.fmap-first-option:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (hover: hover) and (pointer: fine) { .fmap-first-option:hover { border-color: var(--accent); } }
.fmap-first-words { display: grid; gap: 2px; min-width: 0; }
.fmap-first-words strong { font-size: 14px; }
.fmap-first-words .sub { font-size: 12px; overflow-wrap: anywhere; }
@media (max-width: 520px) { .fmap-goals, .fmap-first { grid-template-columns: minmax(0, 1fr); } }

/* A website's screen (TRK-853): a top bar, tabs, and its pages as the same cards, in a grid that wraps */
.sites-top { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-bottom: 12px; }
.sites-back { flex: 0 0 auto; }
.sites-top-title { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; min-width: 0; flex: 1 1 320px; }
.sites-top-title .sites-top-name { flex: 0 1 360px; min-width: 0; font-size: 16px; }
.sites-top-addr { font-size: 13px; min-width: 0; overflow-wrap: anywhere; text-underline-offset: 2px; }
.sites-top-actions { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.sites-top-actions .fmap-more { margin-left: 0; width: 32px; height: 32px; }
.sites-tabs { margin-bottom: 16px; }
.sites-tabs button { white-space: nowrap; }
.sites-stack { max-width: 720px; }
.sites-stack > .sites-panel + .sites-panel, .sites-editor .funnel-sections > .sites-panel + .sites-panel { border-top: 1px solid var(--border); padding-top: 18px; margin-top: 8px; }

.sites-cards { list-style: none; margin: 0; padding: 4px; display: grid; grid-template-columns: repeat(auto-fill, minmax(var(--fmap-card), 1fr)); gap: 16px; }
.sites-cards > li { display: flex; min-width: 0; }
.sites-cards .fmap-card { width: auto; flex: 1 1 auto; min-width: 0; }
.sites-card .fmap-card-top { flex-wrap: wrap; row-gap: 4px; }
.sites-tag { font-size: 11px; font-weight: 600; padding: 1px 8px; border-radius: 999px; border: 1px solid var(--border); color: var(--muted); flex-shrink: 0; }

/* The last tile adds a page */
.sites-add-card { flex: 1 1 auto; min-height: 180px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; padding: 16px; background: transparent; border: 1px dashed var(--border); border-radius: 12px; color: var(--muted); font-weight: 600; transition: color 150ms ease, border-color 150ms ease, background-color 150ms ease; touch-action: manipulation; }
.sites-add-icon { width: 36px; height: 36px; border-radius: 999px; display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--border); background: var(--surface); }
.sites-add-icon svg { width: 18px; height: 18px; }
@media (hover: hover) and (pointer: fine) {
  .sites-add-card:hover:not(:disabled) { color: var(--accent); border-color: var(--accent); background: color-mix(in srgb, var(--accent) 5%, transparent); }
}
.sites-add-card:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sites-add-card:active:not(:disabled) { transform: scale(0.99); }
.sites-add-card:disabled { opacity: .5; cursor: not-allowed; }

.sites-dialog { width: min(440px, calc(100vw - 32px)); }
.sites-dialog form { display: grid; gap: 10px; }
.sites-dialog .sites-in-menu { padding-bottom: 0; }
.sites-preview-pick { display: flex; align-items: center; gap: 8px; min-width: 0; }
.sites-preview-pick select { min-width: 0; max-width: 260px; }

@media (max-width: 640px) {
  .sites-cards { grid-template-columns: minmax(0, 1fr); gap: 10px; padding: 0; }
  .sites-add-card { min-height: 64px; flex-direction: row; }
  .sites-add-icon { width: 30px; height: 30px; }
  .sites-top-title { flex-basis: 100%; }
  .sites-top-title .sites-top-name { flex: 1 1 100%; }
  .sites-top-actions { margin-left: 0; width: 100%; }
  .sites-top-actions .primary { margin-left: auto; }
}

/* ---- New website (TRK-852): kinds, themes and pages ---- */
.site-new form { display: grid; gap: 14px; margin-top: 14px; }
.site-new .funnel-field { margin: 0; }
.site-new-themes { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: 6px; }
.site-new-theme { display: grid; gap: 6px; padding: 6px 6px 8px; text-align: left; font-size: 13px; font-weight: 500; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; transition: border-color 150ms ease, box-shadow 150ms ease; }
.site-new-theme > span:last-child { padding: 0 4px; }
.site-new-theme.is-on { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
@media (hover: hover) and (pointer: fine) { .site-new-theme:not(.is-on):hover { border-color: var(--muted); } }
.site-new-theme:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.site-new-theme:active { transform: scale(0.98); }
.site-new-swatch { display: flex; align-items: center; justify-content: space-between; height: 44px; padding: 0 10px; border-radius: 6px; box-shadow: inset 0 0 0 1px rgb(0 0 0 / 8%); }
.site-new-aa { font-size: 20px; line-height: 1; }
.site-new-btn { width: 30px; height: 12px; }
.site-new-pages { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.site-new-page { display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px 5px 8px; font-size: 13px; font-weight: 500; color: var(--muted); background: transparent; border: 1px dashed var(--border); border-radius: 999px; transition: border-color 150ms ease, color 150ms ease, background-color 150ms ease; }
.site-new-page .sub { font-weight: 400; font-size: 12px; }
.site-new-tick { display: inline-grid; place-items: center; width: 16px; height: 16px; font-size: 10px; border-radius: 50%; border: 1px solid var(--border); color: transparent; }
.site-new-page.is-on { color: var(--text); background: var(--surface); border-style: solid; }
.site-new-page.is-on .site-new-tick { background: var(--accent); border-color: var(--accent); color: var(--accent-text, #fff); }
dialog.confirm-box .site-new-page:disabled { opacity: 1; color: var(--text); cursor: default; }
.site-new-page:disabled .sub { color: var(--muted); }
@media (hover: hover) and (pointer: fine) { .site-new-page:not(:disabled):hover { border-color: var(--muted); } }
.site-new-page:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.site-new-page:not(:disabled):active { transform: scale(0.97); }
@media (max-width: 520px) { .site-new-themes { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* ---- Split tests (TRK-862): a step under an A/B test is two branches that fork from the step before and join at
   the next one. The head and the note under it are the same height, so the branches sit on the row's centre line. ---- */
.fmap.has-split .fmap-row { align-items: center; }
.fmap.has-split .fmap-step { align-self: stretch; }
.fmap.has-split .fmap-step:not(.is-split) { align-items: center; }
.fmap-split { --fmap-fork: 18px; --fmap-gap: 12px; --fmap-path: color-mix(in srgb, var(--accent) 45%, var(--border)); display: flex; flex-direction: column; justify-content: center; min-width: 0; }
.fmap-split-head, .fmap-split-foot { height: 28px; display: flex; align-items: center; gap: 8px; padding: 0 var(--fmap-fork); min-width: 0; }
.fmap-split-head .fmap-more { margin-left: auto; }
.fmap-split-foot { margin: 0; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; line-height: 28px; max-width: calc(var(--fmap-card) + 2 * var(--fmap-fork)); box-sizing: border-box; }
.fmap-test-tag { font-size: 11px; font-weight: 600; padding: 1px 8px; border-radius: 999px; border: 1px solid var(--fmap-path); color: var(--text); white-space: nowrap; flex-shrink: 0; }

.fmap-branches { position: relative; display: grid; grid-template-columns: var(--fmap-card); grid-auto-rows: 1fr; row-gap: var(--fmap-gap); padding: 0 var(--fmap-fork); margin: 6px 0; }
.fmap-fork, .fmap-join { position: absolute; top: calc((100% - var(--fmap-gap)) / 4); bottom: calc((100% - var(--fmap-gap)) / 4); width: var(--fmap-fork); border: 2px solid var(--fmap-path); pointer-events: none; box-sizing: border-box; }
.fmap-fork { left: 0; border-right: 0; border-radius: 10px 0 0 10px; }
.fmap-join { right: 0; border-left: 0; border-radius: 0 10px 10px 0; }
.fmap-branch { min-width: 0; }
.fmap-branch .fmap-card-top { min-height: 24px; }

/* The version letter, its share, and a quiet "Ahead" once the test's note says one is clearly ahead */
.fmap-ver { flex: 0 0 auto; width: 22px; height: 22px; border-radius: 999px; display: inline-flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; background: var(--sunken); color: var(--text); border: 1px solid var(--border); }
.fmap-branch[data-version="B"] .fmap-ver, .fmap-winner-choice:nth-child(2) .fmap-ver { background: color-mix(in srgb, var(--accent) 14%, var(--surface)); border-color: var(--fmap-path, color-mix(in srgb, var(--accent) 45%, var(--border))); }
.fmap-share { font-size: 12px; font-weight: 600; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.fmap-ahead { margin-left: auto; font-size: 11px; font-weight: 600; padding: 1px 8px; border-radius: 999px; color: var(--pass); border: 1px solid color-mix(in srgb, var(--pass) 45%, transparent); white-space: nowrap; flex-shrink: 0; }
.fmap-branch.is-ahead { border-color: color-mix(in srgb, var(--pass) 40%, var(--border)); }

/* Version B, to look at */
.fmap-test-box { width: min(480px, calc(100vw - 32px)); }
.fmap-b-box { width: min(980px, calc(100vw - 32px)); }
.fmap-b-box p { max-width: 70ch; text-wrap: pretty; }
.fmap-b-view { height: min(64dvh, 640px); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: #fff; }
.fmap-b-frame { display: block; width: 100%; height: 100%; border: 0; }

/* Pick the winner */
.fmap-winner-note { margin: 4px 0 12px; text-wrap: pretty; }
.fmap-winner-choices { display: grid; gap: 8px; }
.fmap-winner-choice { display: grid; grid-template-columns: auto auto minmax(0, 1fr); align-items: start; gap: 10px; padding: 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); cursor: pointer; transition: border-color 150ms ease, box-shadow 150ms ease; }
.fmap-winner-choice input { margin: 3px 0 0; accent-color: var(--accent); }
.fmap-winner-choice:has(input:checked) { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.fmap-winner-choice:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (hover: hover) and (pointer: fine) { .fmap-winner-choice:not(:has(input:checked)):hover { border-color: var(--muted); } }
.fmap-winner-text { display: grid; gap: 2px; min-width: 0; }
.fmap-winner-text strong { display: flex; align-items: center; gap: 8px; }
.fmap-winner-text .fmap-ahead { margin-left: 0; }
.fmap-winner-name { font-size: 13px; overflow-wrap: anywhere; }
.fmap-winner-nums { font-size: 13px; font-variant-numeric: tabular-nums; }
.fmap-winner-what { min-height: 1.4em; margin: 12px 0 0; text-wrap: pretty; }
@media (prefers-reduced-motion: reduce) { .fmap-winner-choice { transition: none; } }

/* Phones: the branches stack, with one rail down their left side in place of the fork and join */
@media (max-width: 640px) {
  .fmap.has-split .fmap-row { align-items: stretch; }
  .fmap.has-split .fmap-step:not(.is-split) { align-items: stretch; }
  .fmap-split-head, .fmap-split-foot { padding: 0; max-width: none; }
  .fmap-branches { grid-template-columns: minmax(0, 1fr); grid-auto-rows: auto; row-gap: 10px; padding: 0 0 0 14px; }
  .fmap-branches::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 2px; border-radius: 2px; background: var(--fmap-path); }
  .fmap-fork, .fmap-join { display: none; }
  .fmap-branch .fmap-card-top { grid-area: top; }
  .fmap-b-view { height: min(70dvh, 640px); }
}
/* TRK-1156: the Visit snippet line and its Copy button */
.sites-snippet-row { display: flex; gap: 8px; }
.sites-snippet-code { flex: 1; min-width: 0; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
