/* MVTLoop participant: A/B comparison task (abCompare.js). Uses the study's brand tokens. */
.ab-card [hidden] { display: none !important; }
.ab-card { --ab-a: var(--brand-primary, #5146d8); --ab-b: #0e7490; /* fixed teal so B never blends with a purple or blue brand */ }
.ab-loading { text-align: center; padding: 48px 24px; display: grid; justify-items: center; gap: 14px; }
.ab-kicker { margin-bottom: 6px; }
.ab-title-row { display: flex; align-items: center; gap: 14px; margin-bottom: 12px; }
.ab-title-row .screen-title { margin: 0; }
/* Rich-text bold inside the task box stays inline (the box's own heading is the only label). */
.ab-card .task-instruction-box .ab-rich strong { display: inline; font-size: inherit; letter-spacing: normal; text-transform: none; color: inherit; margin: 0; }
.ab-card .task-instruction-box .ab-rich > :first-child { margin-top: 0; }
.ab-card .task-instruction-box .ab-rich > :last-child { margin-bottom: 0; }

/* Version badges: large, unmistakable A / B */
.ab-badge { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 8px; font-weight: 800; font-size: .95rem; line-height: 1; color: #fff; background: var(--ab-a); flex: none; font-family: var(--font-display, inherit); }
.ab-badge-B { background: var(--ab-b); }
.ab-badge-lg { width: 52px; height: 52px; border-radius: 14px; font-size: 1.7rem; box-shadow: var(--shadow-sm, 0 2px 6px rgba(0,0,0,.12)); }

/* Stage and panes */
.ab-stage { margin: 18px 0 8px; display: grid; gap: 16px; }
.ab-stage-compare { grid-template-columns: 1fr 1fr; }
.ab-pane { position: relative; display: flex; flex-direction: column; min-width: 0; border: 1px solid var(--border, #dde1ea); border-radius: var(--radius-lg, 14px); background: var(--surface, #fff); overflow: hidden; }
.ab-pane[data-slot="A"] { border-top: 4px solid var(--ab-a); }
.ab-pane[data-slot="B"] { border-top: 4px solid var(--ab-b); }
.ab-pane-head { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-bottom: 1px solid var(--border, #dde1ea); flex-wrap: wrap; }
.ab-pane-name { font-size: 1.05rem; }
.ab-pane-tools { margin-left: auto; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ab-pane-tools .btn svg, .ab-flip-btn svg, .ab-full-close svg { width: 16px; height: 16px; }
.ab-full-btn, .ab-flip-btn, .ab-full-close { display: inline-flex; align-items: center; gap: 6px; }
.ab-view-switch { margin: 0; }
.ab-pane-body { position: relative; flex: 1; min-height: 0; background: var(--canvas-2, #f4f5f9); }
.ab-scroll { max-height: min(72vh, 820px); overflow: auto; overscroll-behavior: contain; }
.ab-scroll:focus-visible { outline: 3px solid var(--ring, rgba(81,70,216,.35)); outline-offset: -3px; }
.ab-scroll img { display: block; width: 100%; height: auto; user-select: none; }
.ab-kind-figma iframe { display: block; width: 100%; height: min(72vh, 820px); min-height: 420px; border: 0; background: #fff; }
.ab-full-close { display: none; position: absolute; right: 14px; bottom: 14px; z-index: 2; }

/* Full screen (works on phones too: a fixed overlay, not the Fullscreen API) */
body.ab-full-open { overflow: hidden; }
.ab-pane.is-full { position: fixed; inset: 0; z-index: 2000; border-radius: 0; border-width: 0; border-top-width: 4px; }
.ab-pane.is-full .ab-full-btn { display: none; }
.ab-pane.is-full .ab-full-close { display: inline-flex; }
.ab-pane.is-full .ab-scroll { max-height: none; height: 100%; }
.ab-pane.is-full .ab-pane-body { display: flex; flex-direction: column; }
.ab-pane.is-full .ab-kind-image .ab-scroll { flex: 1; }
.ab-pane.is-full .ab-kind-figma iframe { height: 100%; min-height: 0; flex: 1; }

/* Toolbar: Side by side / One at a time, then ‹ A | B › with the arrow keys */
.ab-toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 14px; }
.ab-seg { display: inline-flex; padding: 3px; gap: 3px; border-radius: 999px; background: var(--canvas-2, #f1f2f7); border: 1px solid var(--border, #dde1ea); }
.ab-seg button { border: 0; background: transparent; color: var(--ink-soft, #4b5568); font: inherit; font-weight: 600; font-size: .9rem; padding: 7px 14px; border-radius: 999px; cursor: pointer; display: inline-flex; align-items: center; gap: 8px; min-height: 36px; }
.ab-seg button[aria-pressed="true"], .ab-seg button[aria-selected="true"] { background: var(--surface, #fff); color: var(--ink, #172033); box-shadow: var(--shadow-sm, 0 1px 3px rgba(0,0,0,.12)); }
.ab-seg button:focus-visible, .ab-step-btn:focus-visible, .ab-cmp-pill:focus-visible { outline: 3px solid var(--ring, rgba(81,70,216,.35)); outline-offset: 1px; }
.ab-seg .ab-badge { width: 22px; height: 22px; font-size: .8rem; border-radius: 6px; }
.ab-stepper { display: none; align-items: center; gap: 6px; }
.ab-toolbar.is-flip .ab-stepper { display: inline-flex; }
.ab-step-btn { width: 40px; height: 40px; border-radius: 999px; border: 1px solid var(--border-strong, #c7ccd8); background: var(--surface, #fff); color: var(--ink, #172033); display: inline-grid; place-items: center; cursor: pointer; flex: none; }
.ab-step-btn svg { width: 18px; height: 18px; }
.ab-step-btn:hover:not(:disabled) { border-color: var(--brand-primary, #5146d8); color: var(--brand-primary, #5146d8); }
.ab-step-btn:disabled { opacity: .35; cursor: default; }
.ab-key-hint { display: none; color: var(--ink-muted, #6b7385); }
.ab-toolbar.is-flip .ab-key-hint { display: inline; }

/* Comparison 1 · 2 · 3: jump back to any comparison already reached */
.ab-cmp-nav ol { list-style: none; display: flex; gap: 8px; margin: 4px 0 14px; padding: 0; flex-wrap: wrap; }
.ab-cmp-pill { min-width: 40px; height: 36px; padding: 0 12px; border-radius: 999px; border: 1.5px solid var(--border-strong, #c7ccd8); background: var(--surface, #fff); color: var(--ink-soft, #4b5568); font: inherit; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; gap: 6px; cursor: pointer; }
.ab-cmp-pill svg { width: 14px; height: 14px; }
.ab-cmp-pill.is-done { border-color: var(--success, #12794f); color: var(--success, #12794f); }
.ab-cmp-pill.is-current { background: var(--brand-primary, #5146d8); border-color: var(--brand-primary, #5146d8); color: var(--brand-on-primary, #fff); cursor: default; }
.ab-cmp-pill:disabled:not(.is-current) { opacity: .45; cursor: default; }

/* Flip view: one version at full width, same position */
.ab-stage-compare.is-flip { grid-template-columns: 1fr; }
.ab-stage-compare.is-flip[data-active="A"] .ab-pane[data-slot="B"],
.ab-stage-compare.is-flip[data-active="B"] .ab-pane[data-slot="A"] { display: none; }

/* After trying a version */
.ab-after { margin-top: 20px; display: grid; gap: 22px; padding: 18px; border-radius: var(--radius-lg, 14px); background: var(--canvas-2, #f6f7fb); border: 1px solid var(--border, #dde1ea); }
.ab-question .question-label { display: block; margin-bottom: 10px; }
.ab-success { display: flex; gap: 10px; flex-wrap: wrap; }
.ab-success-btn { min-width: 96px; min-height: 44px; padding: 10px 18px; border-radius: var(--radius-md, 10px); border: 1.5px solid var(--border-strong, #c7ccd8); background: var(--surface, #fff); color: var(--ink, #172033); font: inherit; font-weight: 600; cursor: pointer; }
.ab-success-btn:hover { border-color: var(--brand-secondary, #8d86f0); }
.ab-success-btn.selected { background: var(--brand-primary, #5146d8); border-color: var(--brand-primary, #5146d8); color: var(--brand-on-primary, #fff); }
.ab-success-btn:focus-visible, .ab-choice-card:focus-visible, .ab-choice-none:focus-visible { outline: 3px solid var(--ring, rgba(81,70,216,.35)); outline-offset: 2px; }
.ab-ease { flex-wrap: nowrap; }
.ab-end-banner { margin-top: 14px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 12px 16px; border-radius: var(--radius-md, 10px); background: var(--success-light, #e7f6ee); border: 1px solid var(--success, #12794f); }
.ab-end-banner[hidden] { display: none; }
.ab-end-banner .btn { margin-left: auto; }

/* Choice */
.ab-choice { margin-top: 26px; }
.ab-choice-q { font-size: 1.3rem; margin: 0 0 14px; font-family: var(--font-display, inherit); }
.ab-choice-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.ab-choice-card { display: flex; flex-direction: column; gap: 10px; padding: 12px; border-radius: var(--radius-lg, 14px); border: 2px solid var(--border, #dde1ea); background: var(--surface, #fff); color: var(--ink, #172033); font: inherit; cursor: pointer; text-align: left; transition: border-color var(--transition, .15s), box-shadow var(--transition, .15s), transform var(--transition, .15s); }
.ab-choice-card:hover { border-color: var(--brand-secondary, #8d86f0); transform: translateY(-1px); }
.ab-choice-card.selected { border-color: var(--brand-primary, #5146d8); box-shadow: 0 0 0 4px rgba(var(--brand-rgb, 81,70,216), .18); }
.ab-thumb { display: block; height: 150px; border-radius: var(--radius-md, 10px); overflow: hidden; background: var(--canvas-2, #f1f2f7); }
.ab-thumb img { width: 100%; height: 100%; object-fit: cover; object-position: top; display: block; }
.ab-thumb-proto { display: grid; place-items: center; align-content: center; gap: 8px; color: var(--ink-muted, #6b7385); }
.ab-thumb-proto svg { width: 72px; height: auto; }
.ab-choice-label { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.1rem; }
.ab-choice-none { margin-top: 12px; width: 100%; min-height: 46px; border-radius: var(--radius-md, 10px); border: 1.5px dashed var(--border-strong, #c7ccd8); background: transparent; color: var(--ink-soft, #4b5568); font: inherit; font-weight: 600; cursor: pointer; }
.ab-choice-none.selected { border-style: solid; border-color: var(--brand-primary, #5146d8); color: var(--ink, #172033); background: var(--surface, #fff); box-shadow: 0 0 0 4px rgba(var(--brand-rgb, 81,70,216), .14); }
.ab-why { margin-top: 16px; }
.ab-why[hidden] { display: none; }
.ab-why .question-label { display: block; margin-bottom: 8px; }
.ab-why textarea { width: 100%; }

/* Footer */
.ab-footer { justify-content: space-between; }
/* The step's main action (Done / Continue / Compare) stays on screen while the design scrolls. */
.ab-screen .ab-footer { position: sticky; bottom: 0; z-index: 40; margin-top: 24px; padding: 14px 0 calc(14px + env(safe-area-inset-bottom, 0px)); background: var(--surface, #fff); border-top: 1px solid var(--border, #dde1ea); box-shadow: 0 -14px 18px -16px rgba(23, 32, 51, .35); }
.ab-after, .ab-choice, .ab-why { scroll-margin-bottom: 120px; }
.ab-footer-main { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-left: auto; justify-content: flex-end; }
.ab-gate:empty, .ab-gate[hidden] { display: none; }

@media (max-width: 760px) {
  .ab-stage-compare { grid-template-columns: 1fr; }
  .ab-mode { display: none; }
  .ab-toolbar .ab-stepper { display: flex; flex: 1; }
  .ab-toolbar .ab-tabs { flex: 1; }
  .ab-toolbar .ab-tabs button { flex: 1; justify-content: center; }
  .ab-toolbar .ab-tabs button { white-space: nowrap; padding: 7px 10px; }
  .ab-toolbar .ab-tabs .ab-badge { display: none; }
  .ab-step-btn { width: 38px; height: 38px; }
  .ab-screen .ab-footer-main .btn { white-space: nowrap; padding-left: 14px; padding-right: 14px; }
  .ab-key-hint, .ab-toolbar.is-flip .ab-key-hint { display: none; }
  .ab-scroll { max-height: 62vh; }
  .ab-kind-figma iframe { height: 62vh; min-height: 360px; }
  .ab-pane-head { padding: 8px 10px; }
  .ab-pane-tools .ab-full-btn span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .ab-choice-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .ab-thumb { height: 110px; }
  .ab-choice-label { font-size: 1rem; }
  .ab-badge-lg { width: 44px; height: 44px; font-size: 1.4rem; }
  .ab-ease .scale-btn { min-width: 0; flex: 1; padding-left: 0; padding-right: 0; }
  /* One compact row on phones: Back + the step's main action. */
  .ab-screen .ab-footer.action-footer { flex-direction: row; align-items: center; flex-wrap: nowrap; gap: 10px; margin-top: 18px; padding-top: 10px; padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px)); }
  .ab-screen .ab-footer.action-footer .participant-back-button { flex: none; padding-inline: 14px; }
  .ab-footer-main { flex: 1; min-width: 0; flex-wrap: nowrap; }
  .ab-footer-main .btn { flex: 1; justify-content: center; }
  .ab-screen .ab-footer .ab-gate { display: none; }
}
@media (prefers-reduced-motion: reduce) { .ab-choice-card { transition: none; } .ab-choice-card:hover { transform: none; } }
