/* Guided first post — the coach marks drawn for app-first-post.js.
 *
 * Every pulse hangs off ONE root attribute, html[data-ap-first-post="<step>"],
 * and never off a class on the target: the vehicle list rebuilds its whole
 * innerHTML on every checkbox click, so a class put on a row or a checkbox is
 * gone before it paints. A root attribute survives any re-render.
 *
 * Colours are palette tokens that exist in refined AND classic, light AND dark
 * (--brand-500/600, --brand-glow-soft, --text, --text-muted, --border,
 * --surface-1). The eyebrow is --brand-600, not -500: -500 on classic light
 * is 3.4:1, which fails AA for 11px text; -600 measures 4.9–6.7 in all four.
 *
 * Reduced motion keeps a STATIC highlight on every target (the outline or the
 * inset ring sits outside the keyframes, the animation only layers on top), so
 * a dealer with animations off still sees which control to press.
 */

@keyframes apFpRing {
    0%, 100% { outline-offset: 2px; outline-color: var(--brand-500); }
    50%      { outline-offset: 5px; outline-color: color-mix(in srgb, var(--brand-500) 35%, transparent); }
}
@keyframes apFpGlow {
    0%       { box-shadow: 0 0 0 0 color-mix(in srgb, var(--brand-500) 55%, transparent); }
    70%, 100% { box-shadow: 0 0 0 10px color-mix(in srgb, var(--brand-500) 0%, transparent); }
}
@keyframes apFpRow {
    0%, 100% { border-color: var(--border); }
    50%      { border-color: var(--brand-500); }
}
@keyframes apFpInset {
    0%, 100% { background: var(--brand-glow-soft); }
    50%      { background: transparent; }
}

/* ── Step 1: every car you can post ─────────────────────────────────────────
   Founder: "pulsate alll cars to select". Every postable row pulses; a row with
   no photo or one the site no longer lists cannot post, so it stays still. In
   LIVE the demo lot's SAMPLE cars stay still too — a paid account flipped to
   LIVE before its own inventory lands must never be led into publishing one.
   Only the checkbox and the row BORDER move: never a ::before/::after on the
   row, which is a CSS grid and would take a column. */
html[data-ap-first-post="select"]:not([data-ap-first-post-suspended]):not([data-ap-first-post-live]) #vehiclesGrid.vehicles-list > .list-item:not(.no-image):not(.unlisted) > input[type="checkbox"],
html[data-ap-first-post="select"][data-ap-first-post-live]:not([data-ap-first-post-suspended]) #vehiclesGrid.vehicles-list > .list-item:not(.no-image):not(.unlisted):not([onclick*="'SAMPLE"]) > input[type="checkbox"] {
    outline: 2px solid var(--brand-500);
    outline-offset: 2px;
    border-color: var(--brand-500);
    animation: apFpRing 1.6s ease-in-out infinite;
}
html[data-ap-first-post="select"]:not([data-ap-first-post-suspended]):not([data-ap-first-post-live]) #vehiclesGrid.vehicles-list > .list-item:not(.no-image):not(.unlisted):not(.selected),
html[data-ap-first-post="select"][data-ap-first-post-live]:not([data-ap-first-post-suspended]) #vehiclesGrid.vehicles-list > .list-item:not(.no-image):not(.unlisted):not(.selected):not([onclick*="'SAMPLE"]) {
    animation: apFpRow 1.6s ease-in-out infinite;
}

/* ── Step 2: Queue Marketplace and Queue All (they do the same thing) ───────
   Never with a SAMPLE car ticked in LIVE (variant "sample"): that press would
   publish the demo lot's car as a real listing. */
html[data-ap-first-post="queue"]:not([data-ap-first-post-variant="sample"]):not([data-ap-first-post-suspended]) #batchQueueMarketplaceBtn,
html[data-ap-first-post="queue"]:not([data-ap-first-post-variant="sample"]):not([data-ap-first-post-suspended]) #batchQueueAllBtn,
/* ── Step 3, only while the queue is really waiting on the dealer ────────── */
html[data-ap-first-post="start"]:not([data-ap-first-post-suspended]) #queueStartPauseBtn,
html[data-ap-first-post="start"][data-ap-first-post-variant="fb"]:not([data-ap-first-post-suspended]) #fbAuthResumeBtn {
    outline: 2px solid var(--brand-500);
    outline-offset: 2px;
    animation: apFpGlow 1.6s ease-out infinite;
}

/* ── Step 3: the Queue nav item ──────────────────────────────────────────────
   An inset ring + tint, never an outward glow: the sidebar is overflow-x:hidden
   (an outer glow is clipped) and .sidebar-icon.active already owns ::before. */
html[data-ap-first-post="open-queue"]:not([data-ap-first-post-suspended]) #queueNavBtn {
    box-shadow: inset 0 0 0 2px var(--brand-500);
    background: var(--brand-glow-soft);
    color: var(--text);
    animation: apFpInset 1.6s ease-in-out infinite;
}
@media (max-width: 680px) {
    /* The Queue item lives in the drawer on a phone: pulse the Menu button
       until the drawer is open, then the item itself (the rule above). */
    html[data-ap-first-post="open-queue"]:not([data-nav-open="true"]):not([data-ap-first-post-suspended]) #apNavToggle {
        outline: 2px solid var(--brand-500);
        outline-offset: 2px;
        animation: apFpGlow 1.6s ease-out infinite;
    }
}

/* ── Step 3, watching: the queue list, where the car's status moves ─────────
   (Not the progress bar: at 0% a ring round an empty track reads as a blank
   box, and the list row already shows Pending → Posting → Completed.) */
html[data-ap-first-post="watching"]:not([data-ap-first-post-suspended]) #queueList {
    outline: 2px solid var(--brand-500);
    outline-offset: 4px;
    border-radius: var(--r-md, 8px);
    animation: apFpRing 2s ease-in-out infinite;
}

@media (prefers-reduced-motion: reduce) {
    html[data-ap-first-post] #vehiclesGrid .list-item,
    html[data-ap-first-post] #vehiclesGrid .list-item > input[type="checkbox"],
    html[data-ap-first-post] #batchQueueMarketplaceBtn,
    html[data-ap-first-post] #batchQueueAllBtn,
    html[data-ap-first-post] #queueNavBtn,
    html[data-ap-first-post] #queueStartPauseBtn,
    html[data-ap-first-post] #fbAuthResumeBtn,
    html[data-ap-first-post] #apNavToggle,
    html[data-ap-first-post] #queueList {
        animation: none !important;
    }
    /* The static highlight that stays: a heavier outline on the controls. */
    html[data-ap-first-post]:not([data-ap-first-post-suspended]) #vehiclesGrid .list-item > input[type="checkbox"],
    html[data-ap-first-post="queue"]:not([data-ap-first-post-variant="sample"]):not([data-ap-first-post-suspended]) #batchQueueMarketplaceBtn,
    html[data-ap-first-post="queue"]:not([data-ap-first-post-variant="sample"]):not([data-ap-first-post-suspended]) #batchQueueAllBtn,
    html[data-ap-first-post="start"]:not([data-ap-first-post-suspended]) #queueStartPauseBtn {
        outline-width: 3px;
    }
}

/* ── The callout ────────────────────────────────────────────────────────────
   z-index 1001: above the batch bar (1000) and the phone drawer (901), below
   modals (9999) and toasts (10000). It is hidden whenever a modal, the How it
   works guide or the open phone drawer is up, so it never fights them. */
.ap-fp[hidden] { display: none !important; }
.ap-fp {
    position: fixed;
    z-index: 1001;
    width: max-content;
    max-width: min(330px, calc(100vw - 32px));
    box-sizing: border-box;
    background: var(--surface-1);
    color: var(--text);
    border: 1px solid var(--brand-500);
    border-radius: var(--r-lg, 14px);
    box-shadow: var(--shadow-lg);
    padding: 13px 15px 12px;
    font: inherit;
    font-size: 13px;
    line-height: 1.5;
}
.ap-fp-eyebrow {
    margin: 0 0 3px;
    color: var(--brand-600);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .07em;
    text-transform: uppercase;
}
.ap-fp-text { margin: 0; font-weight: 600; color: var(--text); }
.ap-fp-note { margin: 5px 0 0; color: var(--text-muted); font-size: 12px; }
.ap-fp-note:empty { display: none; }
.ap-fp-actions { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
.ap-fp-actions [hidden] { display: none !important; }
.ap-fp-skip {
    margin-left: auto;
    padding: 4px 2px;
    border: 0;
    background: none;
    color: var(--text-muted);
    font: inherit;
    font-size: 12px;
    text-decoration: underline;
    text-underline-offset: 2px;
    cursor: pointer;
}
.ap-fp-skip:hover { color: var(--text); }
.ap-fp button:focus-visible { outline: 3px solid var(--brand-500); outline-offset: 2px; }
.ap-fp-arrow {
    position: absolute;
    width: 12px;
    height: 12px;
    background: var(--surface-1);
    border: 1px solid var(--brand-500);
    transform: rotate(45deg);
    display: none;
}
.ap-fp[data-side="corner"] { max-width: min(400px, calc(100vw - 32px)); }
.ap-fp[data-side="above"] .ap-fp-arrow { display: block; bottom: -7px; border-top-color: transparent; border-left-color: transparent; }
.ap-fp[data-side="below"] .ap-fp-arrow { display: block; top: -7px; border-bottom-color: transparent; border-right-color: transparent; }
.ap-fp[data-side="right"] .ap-fp-arrow { display: block; left: -7px; border-top-color: transparent; border-right-color: transparent; }
/* Screen-reader channel: a live region that exists from page load, because
   one revealed in the same tick as its text is often never announced. */
.ap-fp-sr {
    position: absolute !important;
    width: 1px; height: 1px;
    margin: -1px; padding: 0; border: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}
@media (max-width: 680px) {
    /* A bottom sheet on a phone, lifted above the batch bar by the script. */
    .ap-fp { left: 16px !important; right: 16px !important; width: auto; max-width: none; }
    .ap-fp .ap-fp-arrow { display: none !important; }
}
