/* ════════════════════════════════════════════
   APC Milestone Track + APC Milestone Item — Frontend styles
   Parent stylesheet covers all child (.apc-milestone-item) selectors too.
   ════════════════════════════════════════════ */

.apc-milestone-track {
    --apc-mt-accent:      var(--wp--custom--ruvi-blue, #155DFC);
    --apc-mt-fg:           #0b0f19;
    --apc-mt-fg-muted:    rgba(11, 15, 25, 0.6);
    --apc-mt-border:      rgba(11, 15, 25, 0.1);
    --apc-mt-bg:           #ffffff;
    --apc-mt-card-min-height: 280px;
    /* Extra floor added on top of --apc-mt-card-min-height on small
       screens only (see the mobile media query below) — not settable
       via the block editor, purely a layout safety margin so wrapped
       eyebrow/heading/description text has room within the fixed-height
       card instead of being clipped by .apc-mi-media's overflow:hidden. */
    --apc-mt-mobile-floor: 0px;
    --apc-mt-steps-count: 4;

    color: var(--apc-mt-fg);
}

.apc-milestone-track,
.apc-milestone-track *,
.apc-milestone-track *::before,
.apc-milestone-track *::after {
    box-sizing: border-box;
}

/* ── Step row: connecting line + progress fill + icon/label buttons ── */
.apc-milestone-track__steps {
    position: relative;
    margin-bottom: 40px;
    padding: 0 8px;
}

.apc-milestone-track__line {
    position: absolute;
    top: 20px;
    left: 0;
    right: 0;
    height: 1px;
    background: var(--apc-mt-border);
}

.apc-milestone-track__line-fill {
    position: absolute;
    top: 20px;
    left: 0;
    height: 1px;
    width: 0%;
    background: var(--apc-mt-accent);
    transition: width 0.4s ease;
}

.apc-milestone-track__steps-row {
    position: relative;
    display: grid;
    grid-template-columns: repeat(var(--apc-mt-steps-count), 1fr);
    gap: 16px;
}

.apc-mt-step-btn {
    appearance: none;
    -webkit-appearance: none;
    font: inherit;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 0;
    border: none;
    background: none;
    color: inherit;
    cursor: pointer;
    padding: 0;
}

.apc-mt-step-icon {
    position: relative;
    z-index: 1;
    width: 40px;
    height: 40px;
    border-radius: 999px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 12px;
    background: var(--apc-mt-bg);
    border: 2px solid var(--apc-mt-border);
    transition: background 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}

.apc-mt-step-icon svg {
    width: 14px;
    height: 14px;
    color: var(--apc-mt-fg-muted);
    opacity: 0.6;
    transition: color 0.3s ease, opacity 0.3s ease;
}

.apc-mt-step-label {
    font-size: 0.75rem;
    line-height: 1.3;
    color: var(--apc-mt-fg-muted);
    opacity: 0.6;
    font-weight: 400;
    transition: color 0.2s ease, opacity 0.2s ease, font-weight 0.2s ease;
}

/* Completed steps (before the active one) */
.apc-mt-step-btn.is-done .apc-mt-step-icon {
    background: color-mix(in srgb, var(--apc-mt-accent) 25%, var(--apc-mt-bg));
    border-color: color-mix(in srgb, var(--apc-mt-accent) 38%, var(--apc-mt-bg));
}

.apc-mt-step-btn.is-done .apc-mt-step-icon svg {
    color: var(--apc-mt-accent);
    opacity: 0.8;
}

.apc-mt-step-btn.is-done .apc-mt-step-label {
    opacity: 1;
}

/* Active step */
.apc-mt-step-btn.is-active .apc-mt-step-icon {
    background: var(--apc-mt-accent);
    border-color: var(--apc-mt-accent);
    box-shadow: 0 0 24px color-mix(in srgb, var(--apc-mt-accent) 33%, transparent);
}

.apc-mt-step-btn.is-active .apc-mt-step-icon svg {
    color: #fff;
    opacity: 1;
}

.apc-mt-step-btn.is-active .apc-mt-step-label {
    color: var(--apc-mt-fg);
    opacity: 1;
    font-weight: 500;
}

/* ── Card: media panel, one apc-milestone-item visible at a time ── */
.apc-milestone-track__card {
    border-radius: 24px;
    overflow: hidden;
    background-color: transparent;
    opacity: 0;
    transform: translateY(24px);
    transition: opacity 0.8s cubic-bezier(0.16, 1, 0.3, 1),
                transform 0.8s cubic-bezier(0.16, 1, 0.3, 1),
                background-color 3s cubic-bezier(0.16, 1, 0.3, 1);
}

.apc-milestone-track__card.apc-milestone-track__card--visible {
    opacity: 1;
    transform: translateY(0);
    background-color: var(--apc-mt-bg);
}

/* No-JS fallback, and browsers without IntersectionObserver support
   (frontend.js also force-adds --visible immediately in that case) —
   never leave the card permanently invisible or backgroundless. */
.apc-milestone-track:not(.apc-milestone-track--js) .apc-milestone-track__card {
    opacity: 1;
    transform: none;
    background-color: var(--apc-mt-bg);
}

/* Fixed height: min-height is the RangeControl-configured card height
   (--apc-mt-card-min-height) plus an internal --apc-mt-mobile-floor
   that only has a value on small screens (see media query below).
   max() combines them without fighting the inline custom property
   render.php sets on .apc-milestone-track — that inline value always
   wins over anything the stylesheet tries to set on the same variable
   name, so the mobile floor lives in its own variable instead. */
.apc-milestone-track__items {
    position: relative;
    display: flex;
    flex-direction: column;
    min-height: max(var(--apc-mt-card-min-height), var(--apc-mt-mobile-floor));
    touch-action: pan-y;
}

.apc-milestone-track__items > .wp-block-apc-milestone-item {
    display: contents;
}

/* Absolutely stacked so every item fills the same box and only .is-active
   is visible — the outgoing item fully exits left before the incoming
   one enters from the right (timed in frontend.js), so the two are
   never both partially visible at once. */
.apc-milestone-item {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    opacity: 0;
    transform: translateX(14px);
    pointer-events: none;
    /* Must match PANEL_SWITCH_MS in frontend.js — keep the two in sync */
    transition: opacity 0.26s ease, transform 0.26s ease;
    backface-visibility: hidden;
}

.apc-milestone-item.is-active {
    opacity: 1;
    transform: translateX(0);
    pointer-events: auto;
}

.apc-milestone-item--offset-left {
    transform: translateX(-14px);
}

.apc-milestone-item--offset-right {
    transform: translateX(14px);
}

.apc-milestone-item--no-transition {
    transition: none !important;
}

/* Before JS runs, or if JS fails, show every item stacked so content
   isn't hidden */
.apc-milestone-track:not(.apc-milestone-track--js) .apc-milestone-item {
    position: static;
    opacity: 1;
    transform: none;
    pointer-events: auto;
    margin-bottom: 2px;
}

.apc-milestone-track:not(.apc-milestone-track--js) .apc-milestone-track__steps-row {
    display: none;
}

/* Media (image + gradient + eyebrow/heading/description) */
.apc-mi-media {
    position: relative;
    flex: 1;
    overflow: hidden;
    min-height: 220px;
    background: none;
}

.apc-mi-media-img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.apc-mi-media-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(
        180deg,
        color-mix(in srgb, var(--apc-mt-bg) 55%, transparent) 0%,
        var(--apc-mt-bg) 100%
    );
}

.apc-mi-media-content {
    position: relative;
    height: 100%;
    padding: 20px 24px;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
}

.apc-mi-eyebrow {
    font-size: 0.9rem;
	font-weight: 600;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    margin: 0 0 12px;
    color: var(--apc-mt-accent);
}

.apc-milestone-track--no-eyebrow .apc-mi-eyebrow {
    display: none;
}

.apc-mi-heading {
    font-weight: 600;
    margin: 0 0 12px;
    font-size: clamp(32px, 1.75rem + ((1vw - 3.2px) * 0.305), 33px) !important;
    max-width: 32rem;
    color: var(--apc-mt-fg);
}

.apc-mi-description {
    font-size: 1.125rem;
    margin: 0;
    max-width: 30rem;
    color: var(--apc-mt-fg-muted);
}

/* ── Mobile floor: give the fixed-height card enough room on small
   screens for wrapped eyebrow/heading/description text before the
   desktop layout (with its own wider padding below) takes over. ── */
@media (max-width: 899px) {
    .apc-milestone-track {
        --apc-mt-mobile-floor: 400px;
    }
}

/* ── Desktop (>=900px) ── */
@media (min-width: 900px) {
    .apc-mi-media-content {
        padding: 24px;
    }

    .apc-mi-heading {
        font-size: 1.875rem;
    }

    /* Card sits centered at half width on desktop instead of stretching
       full-width — mobile keeps the full-width card via the default
       (no max-width) rule above this breakpoint. */
    .apc-milestone-track__card {
        max-width: 100%;
        margin-left: auto;
        margin-right: auto;
    }
}