/* Layered over driver.css. Fixes only, not a theme — name the defect each rule fixes. */

.driver-popover.walkthrough-popover {
    /* driver.css caps at 300px */
    width: 440px;
    max-width: calc(100vw - 32px);
    /* driver.css sets no height bound; a long body takes the buttons off-screen */
    max-height: calc(100vh - 32px);
    /* driver.js sets display:block inline; without !important every flex rule is inert */
    display: flex !important;
    flex-direction: column;
}

/* A step with an embedded Loom video gets this added onto `walkthrough-popover`
   (see `hasEmbeddedVideo` in walkthrough.js) - the video's own 16:9 box scales with
   the popover's width, so the 440px default reads as a postage stamp for video. */
.driver-popover.walkthrough-popover.walkthrough-popover--video {
    width: 640px;
}

/* 255 authored chars, no guaranteed spaces, and nothing else bounds it */
.walkthrough-popover .driver-popover-title {
    flex: 0 0 auto;
    overflow-wrap: anywhere;
}

/* The clip boundary — not the popover, whose arrow sits outside that box. Needed
   because the sanitizer allows margins and width, which reach the dashboard. */
.walkthrough-popover .driver-popover-description {
    /* min-height lets the item shrink — what makes it scroll */
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    /* Containing block for a `position: absolute` descendant, or its offset escapes the clip */
    position: relative;
}

.walkthrough-popover .driver-popover-footer {
    flex: 0 0 auto;
}

.walkthrough-popover .driver-popover-footer-btn {
    /* driver.css renders ~23px, under the 24px minimum target */
    padding: 8px 18px;
    font-size: 14px;
    /* Load-bearing for dark — driver.css would paint white behind dark text */
    background-color: transparent;
}

/* driver.css's all:unset leaves a 1.07:1 hover tint as the only focus affordance */
.walkthrough-popover :focus-visible {
    outline: 2px solid #0073ad;
    outline-offset: 2px;
}

.walkthrough-popover .driver-popover-description img {
    display: block;
    max-width: 100%;
    height: auto;
}

.walkthrough-popover .driver-popover-description pre {
    overflow-x: auto;
}

/* No dark theme in driver.css — its defaults land at 1.3:1 to 2.5:1 here */
.foreman-body-dark .driver-popover.walkthrough-popover {
    /* On the wrapper — driver.js appends the arrow here, so arrow rules inherit it */
    --walkthrough-card: #213654;
    background-color: var(--walkthrough-card);
    color: #e5e8e8;
}

.foreman-body-dark .walkthrough-popover .driver-popover-progress-text {
    color: #a6aebb;
}

.foreman-body-dark .walkthrough-popover .driver-popover-footer-btn {
    border-color: #7a8698;
    color: #d3d7dd;
}

.foreman-body-dark .walkthrough-popover .driver-popover-footer-btn:hover,
.foreman-body-dark .walkthrough-popover .driver-popover-footer-btn:focus {
    background-color: rgba(255, 255, 255, 0.08);
}

/* driver.css fades this to 1.13:1 — gone exactly when it is reached for */
.foreman-body-dark .walkthrough-popover .driver-popover-close-btn:hover,
.foreman-body-dark .walkthrough-popover .driver-popover-close-btn:focus {
    color: #ffffff;
}

.foreman-body-dark .walkthrough-popover .driver-popover-description a {
    color: #4cc2ff;
}

.foreman-body-dark .walkthrough-popover :focus-visible {
    outline-color: #4cc2ff;
}

/* 5px border, three sides transparent — a blanket border-color makes it a square */
.foreman-body-dark .walkthrough-popover .driver-popover-arrow-side-left {
    border-left-color: var(--walkthrough-card);
}

.foreman-body-dark .walkthrough-popover .driver-popover-arrow-side-right {
    border-right-color: var(--walkthrough-card);
}

.foreman-body-dark .walkthrough-popover .driver-popover-arrow-side-top {
    border-top-color: var(--walkthrough-card);
}

.foreman-body-dark .walkthrough-popover .driver-popover-arrow-side-bottom {
    border-bottom-color: var(--walkthrough-card);
}

@media (max-width: 480px) {
    .driver-popover.walkthrough-popover {
        width: calc(100vw - 16px);
        max-width: none;
        max-height: 85vh;
    }

    /* Three classes outrank the rule above regardless of the media query */
    .driver-popover.walkthrough-popover.walkthrough-popover--video {
        width: calc(100vw - 16px);
    }
}

/* Stand-in for a target inside the Next iframe: driver.js highlights an Element and has
   no rect-based API, so the runtime puts one at the measured position. `fixed` because
   that rect is in viewport coordinates. */
.walkthrough-iframe-target {
    position: fixed;
}
