/* Recursion Visualizer (/recursion-visualizer): what is its own (the status line, the code with its current and waiting
   lines, the call stack, the tree that scrolls sideways, the output). Panels, tiles, buttons, fields and colours come
   from the app kit (css/app-kit, docs/app-kit.md). Loaded only on this app's page (StylePaths). */

/* On a phone the site's photo-app rule (seo-pages.css) sets align-items: start on every stage, which beats the kit's
   stretch: the panels would shrink to their own width. */
.rv-landing-app > .ak-stage > * {
    align-self: stretch;
}

.rv-landing-app .rv-result {
    font-family: var(--ak-font-mono);
    overflow-wrap: anywhere;
}

/* --- Status and playback ----------------------------------------------------------------------------------------- */

.rv-landing-app .rv-status {
    min-height: 3em;
    margin: 0 0 0.6rem;
    padding: 0.5rem 0.75rem;
    border-inline-start: 4px solid var(--ak-accent);
    border-radius: var(--ak-radius-sm);
    background: color-mix(in srgb, var(--ak-accent) 7%, var(--ak-bg));
    line-height: 1.5;
    overflow-wrap: anywhere;
}

.rv-landing-app .rv-status[data-rv-event="ret"],
.rv-landing-app .rv-status[data-rv-event="memo"] {
    border-inline-start-color: var(--ak-success);
    background: color-mix(in srgb, var(--ak-success) 7%, var(--ak-bg));
}

.rv-landing-app .rv-status[data-rv-event="memo"] {
    border-inline-start-color: var(--ak-warning);
}

.rv-landing-app .rv-status[data-rv-event="overflow"] {
    border-inline-start-color: var(--ak-danger);
    background: color-mix(in srgb, var(--ak-danger) 8%, var(--ak-bg));
    color: var(--ak-danger);
}

.rv-landing-app .rv-actions {
    align-items: center;
}

.rv-landing-app .rv-step-no {
    margin-inline-start: auto;
    white-space: nowrap;
}

/* --- Code and stack side by side, one above the other on a narrow screen ------------------------------------------- */

.rv-landing-app .rv-columns {
    display: grid;
    grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
    align-items: start;
    gap: var(--ak-space-3, 0.75rem);
}

@media (max-width: 760px) {
    .rv-landing-app .rv-columns {
        grid-template-columns: minmax(0, 1fr);
    }
}

.rv-landing-app .rv-code {
    margin: 0;
    padding: 0;
    list-style: none;
    counter-reset: rv-line;
    overflow-x: auto;
    font-family: var(--ak-font-mono);
    font-size: var(--ak-fs-sm);
    line-height: 1.7;
    direction: ltr;
    text-align: left;
}

.rv-landing-app .rv-code > li {
    counter-increment: rv-line;
    padding-inline-end: 0.5rem;
    border-radius: var(--ak-radius-sm);
    white-space: pre;
}

.rv-landing-app .rv-code > li::before {
    content: counter(rv-line);
    display: inline-block;
    width: 2.2em;
    margin-inline-end: 0.6rem;
    color: var(--ak-muted);
    text-align: right;
}

.rv-landing-app .rv-code > li.is-waiting {
    background: color-mix(in srgb, var(--ak-accent) 10%, transparent);
}

.rv-landing-app .rv-code > li.is-current {
    background: color-mix(in srgb, var(--ak-accent) 26%, transparent);
    box-shadow: inset 3px 0 0 var(--ak-accent);
    font-weight: 600;
}

.rv-landing-app .rv-stack {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    max-height: 26rem;
    overflow-y: auto;
    margin: 0;
    padding: 0;
    list-style: none;
}

.rv-landing-app .rv-frame {
    display: flex;
    gap: 0.6rem;
    align-items: flex-start;
    padding: 0.4rem 0.6rem;
    border: 1px solid var(--ak-border);
    border-radius: var(--ak-radius-sm);
    background: var(--ak-bg);
}

.rv-landing-app .rv-frame.is-top {
    border-color: var(--ak-accent);
    box-shadow: inset 4px 0 0 var(--ak-accent);
}

.rv-landing-app .rv-frame.is-overflow {
    border-color: var(--ak-danger);
    box-shadow: inset 4px 0 0 var(--ak-danger);
}

.rv-landing-app .rv-frame-depth {
    min-width: 1.6em;
    color: var(--ak-muted);
    font-size: var(--ak-fs-sm);
    text-align: end;
}

.rv-landing-app .rv-frame-body {
    display: flex;
    flex-wrap: wrap;
    gap: 0.2rem 0.6rem;
    align-items: baseline;
    min-width: 0;
}

.rv-landing-app .rv-frame-call {
    font-family: var(--ak-font-mono);
    font-weight: 600;
    overflow-wrap: anywhere;
    direction: ltr;
    unicode-bidi: isolate;
}

.rv-landing-app .rv-frame-state {
    color: var(--ak-muted);
    font-size: var(--ak-fs-sm);
}

.rv-landing-app .rv-got-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    width: 100%;
}

.rv-landing-app .rv-got {
    padding: 0 0.4rem;
    border-radius: var(--ak-radius-pill);
    background: color-mix(in srgb, var(--ak-success) 12%, var(--ak-bg));
    color: var(--ak-success);
    font-family: var(--ak-font-mono);
    font-size: var(--ak-fs-sm);
    direction: ltr;
    unicode-bidi: isolate;
}

.rv-landing-app .rv-got--memo {
    background: color-mix(in srgb, var(--ak-warning) 14%, var(--ak-bg));
    color: var(--ak-warning);
}

.rv-landing-app .rv-empty {
    color: var(--ak-muted);
}

/* --- The call tree: a canvas as wide as it needs, scrolling sideways in its panel ---------------------------------- */

.rv-landing-app .rv-tree-wrap {
    overflow-x: auto;
    overflow-y: hidden;
    direction: ltr;
}

.rv-landing-app .rv-tree {
    display: block;
}

/* --- Output --------------------------------------------------------------------------------------------------------- */

.rv-landing-app .rv-output {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem 0.5rem;
    max-height: 12rem;
    margin: 0;
    padding: 0;
    overflow-y: auto;
    list-style: none;
    font-family: var(--ak-font-mono);
    font-size: var(--ak-fs-sm);
}

.rv-landing-app .rv-output > li {
    padding: 0.1rem 0.5rem;
    border: 1px solid var(--ak-border);
    border-radius: var(--ak-radius-sm);
    background: var(--ak-bg);
    white-space: pre;
}

.rv-landing-app .rv-param {
    font-family: var(--ak-font-mono);
    font-weight: 700;
}
