/* Scripted product simulations (mk-sim.js): the frame, the step list and a few
   scene primitives the solution pages share. Page-specific scenes add their
   own rules in the page's custom-css block. Black/orange tokens come from
   connected-pages.css (body.mk-secondary-page). */

.mk-sim {
    --sim-accent: #f59e0b;
    --sim-accent-2: #ffbb45;
    --sim-ok: #35c46f;
    --sim-warn: #f59e0b;
    --sim-bad: #f87171;
    --sim-info: #7cb7ff;
    --sim-line: rgba(255, 255, 255, 0.10);
    --sim-surface: rgba(255, 255, 255, 0.035);
    --sim-muted: #aaa69c;
    display: grid;
    grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
    gap: clamp(20px, 3vw, 44px);
    align-items: center;
}
.mk-sim--flip { grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr); }
.mk-sim--flip .mk-sim-ui { order: -1; }
@media (max-width: 991px) {
    .mk-sim, .mk-sim--flip { grid-template-columns: minmax(0, 1fr); }
    .mk-sim--flip .mk-sim-ui { order: 0; }
}

/* ---- Tabs (several simulations in one place) ---------------------------- */
/* The landing page's switcher (landing-live.css .ll-dot): hairline pills, the chosen one filled with the text colour. */
.mk-sim-tabs {
    display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin-bottom: clamp(18px, 2.4vw, 28px);
}
.mk-sim-tabs [role="tab"] {
    all: unset; box-sizing: border-box; cursor: pointer;
    display: inline-flex; align-items: center; gap: 0.45rem;
    min-height: 40px; padding: 0 14px; border-radius: 999px;
    font-size: 14px; font-weight: 500; color: #aaa69c;
    border: 1px solid rgba(255, 255, 255, 0.16); background: none;
    transition: color 0.2s ease, border-color 0.2s ease, background-color 0.2s ease;
}
.mk-sim-tabs [role="tab"] .az-ic { color: #f59e0b; }
.mk-sim-tabs [role="tab"]:hover { color: #f6f4ee; border-color: #f6f4ee; }
.mk-sim-tabs [role="tab"][aria-selected="true"] { color: #000; background: #f6f4ee; border-color: #f6f4ee; }
.mk-sim-tabs [role="tab"][aria-selected="true"] .az-ic { color: #000; }
.mk-sim-tabs [role="tab"]:focus-visible { outline: 2px solid #f59e0b; outline-offset: 3px; }
@media (max-width: 575px) {
    .mk-sim-tabs { flex-wrap: nowrap; justify-content: flex-start; overflow-x: auto; scrollbar-width: none; margin-inline: -16px; padding-inline: 16px; }   /* from the start: a centred row that overflows cannot be scrolled back to its first tab */
    .mk-sim-tabs::-webkit-scrollbar { display: none; }
    .mk-sim-tabs [role="tab"] { flex-shrink: 0; }
}

/* ---- Stage ------------------------------------------------------------ */
.mk-sim-stage { position: relative; min-width: 0; transition: opacity 0.45s ease; }
.mk-sim.is-rewinding .mk-sim-stage { opacity: 0; }
.mk-sim [data-sim-at] {
    opacity: 0;
    transform: translateY(6px);
    transition: opacity 0.45s ease, transform 0.55s cubic-bezier(0.16, 1, 0.3, 1);
}
.mk-sim [data-sim-at].is-in { opacity: 1; transform: none; }
/* Swaps in place: several elements stacked in one grid cell, one is-in at a time */
.mk-sim-swap { display: grid; }
.mk-sim-swap > * { grid-area: 1 / 1; }
/* Collapsing rows: an element that takes no room until its beat */
.mk-sim [data-sim-at].mk-sim-grow { display: grid; grid-template-rows: 0fr; transition: opacity 0.45s ease, grid-template-rows 0.5s cubic-bezier(0.16, 1, 0.3, 1); transform: none; }
.mk-sim [data-sim-at].mk-sim-grow.is-in { grid-template-rows: 1fr; }
.mk-sim-grow > * { overflow: hidden; min-height: 0; }

/* ---- Step list and caption -------------------------------------------- */
.mk-sim-ui { min-width: 0; }
.mk-sim-kicker {
    display: inline-block; margin-bottom: 0.7rem;
    font-size: 0.68rem; font-weight: 700; letter-spacing: 0.16em; text-transform: uppercase; color: var(--sim-accent);
}
.mk-sim-title { font-size: clamp(1.45rem, 2.2vw, 1.95rem); font-weight: 700; line-height: 1.15; color: #fff; margin: 0 0 0.6rem; }
.mk-sim-lede { color: var(--sim-muted); font-size: 0.98rem; line-height: 1.65; margin: 0 0 1.2rem; }
.mk-sim-steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.35rem; counter-reset: sim; }
.mk-sim-steps li { counter-increment: sim; }
.mk-sim-step {
    all: unset; box-sizing: border-box; cursor: pointer;
    display: grid; grid-template-columns: 1.7rem minmax(0, 1fr); align-items: center; column-gap: 0.65rem;
    width: 100%; padding: 0.55rem 0.7rem; border-radius: 12px;
    color: var(--sim-muted); font-size: 0.9rem; line-height: 1.35;
    border: 1px solid transparent;
    transition: background-color 0.25s ease, border-color 0.25s ease, color 0.25s ease;
}
.mk-sim-step::before {
    content: counter(sim);
    display: grid; place-items: center; width: 1.7rem; height: 1.7rem; border-radius: 50%;
    font-size: 0.72rem; font-weight: 700; color: var(--sim-muted);
    border: 1px solid var(--sim-line); background: rgba(255, 255, 255, 0.03);
    transition: inherit;
}
.mk-sim-step:hover { color: #f6f4ee; background: rgba(255, 255, 255, 0.03); }
.mk-sim-step:focus-visible { outline: 2px solid var(--sim-accent); outline-offset: 2px; }
.mk-sim-step-label { grid-column: 2; }
.mk-sim-step-bar {
    grid-column: 2; grid-row: 2; height: 2px; margin-top: 0.45rem; border-radius: 999px;
    background: rgba(255, 255, 255, 0.08); overflow: hidden; display: none;
}
.mk-sim-step-bar > span {
    display: block; height: 100%; background: var(--sim-accent);
    transform: scaleX(var(--sim-p, 0)); transform-origin: left;
}
.mk-sim-steps li.is-active .mk-sim-step { color: #f6f4ee; background: rgba(245, 158, 11, 0.07); border-color: rgba(245, 158, 11, 0.28); }
.mk-sim-steps li.is-active .mk-sim-step::before { color: #111; background: var(--sim-accent); border-color: var(--sim-accent); }
.mk-sim-steps li.is-active .mk-sim-step-bar { display: block; }
.mk-sim-steps li.is-done .mk-sim-step::before { color: var(--sim-ok); border-color: rgba(53, 196, 111, 0.45); }
/* The sentences are read with their step; the visible caption repeats the current one */
.mk-sim-step-say {
    position: absolute; width: 1px; height: 1px; overflow: hidden;
    clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}
.mk-sim-say {
    min-height: 3.3em; margin: 0.9rem 0 0.2rem; padding-left: 0.9rem;
    border-left: 2px solid var(--sim-accent);
    color: #e7e9ef; font-size: 0.95rem; line-height: 1.6;
}
.mk-sim-controls { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.9rem; }
.mk-sim-controls button {
    all: unset; box-sizing: border-box; cursor: pointer;
    display: inline-flex; align-items: center; gap: 0.4rem;
    padding: 0.42rem 0.85rem; border-radius: 999px; font-size: 0.78rem; font-weight: 600;
    color: #e7e9ef; border: 1px solid var(--sim-line); background: rgba(255, 255, 255, 0.03);
}
.mk-sim-controls button:hover { border-color: rgba(245, 158, 11, 0.5); }
.mk-sim-controls button:focus-visible { outline: 2px solid var(--sim-accent); outline-offset: 2px; }
.mk-sim-note { margin-top: 0.9rem; font-size: 0.74rem; color: #8b877e; line-height: 1.5; }

/* ---- Scene primitives --------------------------------------------------- */
.mk-sim-screen { position: relative; padding: 1rem; min-height: 380px; }
.mk-sim-head { display: flex; align-items: center; gap: 0.6rem; margin-bottom: 0.8rem; }
.mk-sim-head h4 { margin: 0; font-size: 0.92rem; font-weight: 700; color: #fff; letter-spacing: -0.01em; }
.mk-sim-head small { margin-left: auto; font-size: 0.66rem; color: var(--sim-muted); }
.mk-sim-row {
    display: flex; align-items: center; gap: 0.6rem; min-width: 0;
    padding: 0.55rem 0.7rem; border-radius: 10px; margin-bottom: 0.4rem;
    background: var(--sim-surface); border: 1px solid var(--sim-line);
    font-size: 0.74rem; color: #e7e9ef;
}
.mk-sim-row > .az-ic { flex-shrink: 0; color: var(--sim-accent); }
.mk-sim-row .grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mk-sim-row .sub { display: block; font-size: 0.64rem; color: var(--sim-muted); }
.mk-sim-chip {
    display: inline-flex; align-items: center; gap: 0.3rem; flex-shrink: 0; white-space: nowrap;
    padding: 0.18rem 0.5rem; border-radius: 999px; font-size: 0.62rem; font-weight: 700;
    border: 1px solid currentColor; background: rgba(255, 255, 255, 0.03);
    color: var(--sim-muted);
}
.mk-sim-chip--ok { color: var(--sim-ok); background: rgba(53, 196, 111, 0.08); }
.mk-sim-chip--warn { color: var(--sim-warn); background: rgba(245, 158, 11, 0.08); }
.mk-sim-chip--bad { color: var(--sim-bad); background: rgba(248, 113, 113, 0.08); }
.mk-sim-chip--info { color: var(--sim-info); background: rgba(124, 183, 255, 0.08); }
.mk-sim-btn {
    display: inline-flex; align-items: center; gap: 0.35rem; white-space: nowrap;
    padding: 0.38rem 0.7rem; border-radius: 8px; font-size: 0.68rem; font-weight: 700;
    color: #111; background: var(--sim-accent);
}
.mk-sim-btn--ghost { color: #e7e9ef; background: transparent; border: 1px solid var(--sim-line); }
.mk-sim-toast {
    position: absolute; left: 1rem; right: 1rem; bottom: 1rem; z-index: 3;
    display: flex; align-items: center; gap: 0.55rem;
    padding: 0.65rem 0.8rem; border-radius: 12px; font-size: 0.74rem; color: #e7e9ef; line-height: 1.4;
    background: rgba(12, 14, 18, 0.97); border: 1px solid rgba(53, 196, 111, 0.45);
    box-shadow: 0 18px 40px -18px rgba(0, 0, 0, 0.9);
}
.mk-sim-toast > .az-ic { color: var(--sim-ok); flex-shrink: 0; }
.mk-sim [data-sim-at].mk-sim-toast { transform: translateY(14px); }
.mk-sim [data-sim-at].mk-sim-toast.is-in { transform: none; }
/* A finger tap: place with --x / --y (percent of the positioned parent) */
.mk-sim-tap {
    position: absolute; left: var(--x, 50%); top: var(--y, 50%); z-index: 4;
    width: 26px; height: 26px; margin: -13px 0 0 -13px; border-radius: 50%;
    background: rgba(255, 255, 255, 0.22); border: 1.5px solid rgba(255, 255, 255, 0.75);
    pointer-events: none;
}
.mk-sim [data-sim-at].mk-sim-tap { transform: scale(0.6); }
.mk-sim [data-sim-at].mk-sim-tap.is-in { transform: scale(1); animation: mk-sim-tap 1.1s ease-out 0.25s 1 both; }
@keyframes mk-sim-tap {
    0% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.55); }
    100% { box-shadow: 0 0 0 18px rgba(245, 158, 11, 0); opacity: 0; }
}
/* A highlight pulse on the beat an element first appears in */
.mk-sim .mk-sim-flash.is-now { animation: mk-sim-flash 1.2s ease-out 1 both; }
@keyframes mk-sim-flash {
    0% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.6); }
    100% { box-shadow: 0 0 0 12px rgba(245, 158, 11, 0); }
}

/* Phone frame for Employee AZ scenes */
.mk-sim-phone {
    position: relative; width: min(268px, 100%); margin: 0 auto;
    border-radius: 34px; border: 1px solid rgba(255, 255, 255, 0.16);
    background: #08090c; padding: 12px 10px 16px;
    box-shadow: 0 30px 70px -30px rgba(0, 0, 0, 0.95), 0 0 60px -30px rgba(245, 158, 11, 0.4);
}
.mk-sim-phone-notch { width: 72px; height: 7px; border-radius: 999px; background: rgba(255, 255, 255, 0.12); margin: 0 auto 10px; }
.mk-sim-phone-screen {
    position: relative; min-height: 430px; border-radius: 22px; overflow: hidden;
    background: #0d0f14; padding: 12px;
}

@media (max-width: 575px) {
    .mk-sim-screen { padding: 0.75rem; min-height: 340px; }
    .mk-sim-phone-screen { min-height: 400px; }
}

/* The controls do nothing until mk-sim.js has taken over */
.mk-sim:not([data-sim-ready]) .mk-sim-controls { visibility: hidden; }

@media (prefers-reduced-motion: reduce) {
    .mk-sim-stage, .mk-sim [data-sim-at], .mk-sim-step, .mk-sim-step::before { transition: none !important; }
    .mk-sim [data-sim-at].is-in, .mk-sim .mk-sim-flash.is-now { animation: none !important; }
    /* A tap only makes sense in motion: resting on a beat it would cover the button */
    .mk-sim .mk-sim-tap { display: none; }
}
@media print {
    .mk-sim-controls { display: none; }
}
