/* Regex tester (/regex-tester): what is its own (the pattern and text fields with their colour layer, the status pill,
   the marks, the group colours, the table, the parts and the explanation). Panels, 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 fields would shrink to their own width. */
.rx-landing-app > .ak-stage > * {
    align-self: stretch;
}

/* The colours of capturing groups 1 to 6 (then again from 1): the same in the pattern, the text and the table. */
.rx-landing-app [data-g="1"] { --rx-c: var(--ak-series-1); }
.rx-landing-app [data-g="2"] { --rx-c: var(--ak-series-3); }
.rx-landing-app [data-g="3"] { --rx-c: var(--ak-series-4); }
.rx-landing-app [data-g="4"] { --rx-c: var(--ak-series-6); }
.rx-landing-app [data-g="5"] { --rx-c: var(--ak-series-2); }
.rx-landing-app [data-g="6"] { --rx-c: var(--ak-series-7); }

/* --- The pattern row: / pattern / flags, Copy regex ------------------------------------------------------------- */

.rx-landing-app .rx-pattern-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.35rem;
}

.rx-landing-app .rx-slash,
.rx-landing-app .rx-flags {
    font-family: var(--ak-font-mono);
    font-size: 1.15rem;
    color: var(--ak-muted);
}

.rx-landing-app .rx-flags {
    min-width: 1ch;
    color: var(--ak-accent);
    font-weight: 600;
}

.rx-landing-app .rx-field--pattern {
    flex: 1 1 14rem;
    min-width: 0;
}

/* --- A text area over a <pre> with the same box: the <pre> shows the text in colour and sets the height ----------- */

.rx-landing-app .rx-field {
    position: relative;
    border: 1px solid var(--ak-border);
    border-radius: var(--ak-radius-sm);
    background: var(--ak-field);
}

.rx-landing-app .rx-field:focus-within {
    outline: 2px solid var(--ak-accent);
    outline-offset: 1px;
    border-color: var(--ak-accent);
}

.rx-landing-app .rx-hl,
.rx-landing-app .rx-input {
    box-sizing: border-box;
    margin: 0;
    padding: 0.5rem 0.7rem;
    border: 0;
    font-family: var(--ak-font-mono);
    font-size: 0.95rem;
    font-weight: 400;
    line-height: 1.5;
    letter-spacing: normal;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    word-break: normal;
    tab-size: 4;
    text-align: left;
    direction: ltr;
}

.rx-landing-app .rx-hl {
    min-height: 2.5rem;
    color: var(--ak-text);
    background: transparent;
    pointer-events: none;
}

.rx-landing-app .rx-field--text .rx-hl {
    min-height: 12rem;
}

.rx-landing-app .rx-input {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    resize: none;
    outline: none;
    background: transparent;
    color: transparent;
    caret-color: var(--ak-text);
}

.rx-landing-app .rx-input::placeholder {
    color: var(--ak-muted);
}

.rx-landing-app .rx-input::selection {
    background: color-mix(in srgb, var(--ak-accent) 35%, transparent);
    color: transparent;
}

/* The pattern in colour. Only colours: a bold glyph could be wider and move the caret off its letter. */
.rx-landing-app .rx-t-group { color: var(--rx-c); }
.rx-landing-app .rx-t-paren { color: var(--ak-muted); }
.rx-landing-app .rx-t-set,
.rx-landing-app .rx-t-class { color: var(--ak-info); }
.rx-landing-app .rx-t-quant { color: var(--ak-warning); }
.rx-landing-app .rx-t-anchor,
.rx-landing-app .rx-t-alt { color: var(--ak-danger); }
.rx-landing-app .rx-t-esc { color: var(--ak-success); }
.rx-landing-app .rx-t-ref { color: var(--ak-accent); }

/* The matches: two tints in turn, so neighbours stay apart; an empty match is a thin bar. */
.rx-landing-app mark.rx-m {
    border-radius: 2px;
    color: inherit;
    background: color-mix(in srgb, var(--ak-accent) 24%, transparent);
}

.rx-landing-app mark.rx-m--b {
    background: color-mix(in srgb, var(--ak-accent) 42%, transparent);
}

.rx-landing-app mark.rx-m--empty {
    position: relative;
    background: none;
}

.rx-landing-app mark.rx-m--empty::before {
    content: "";
    position: absolute;
    top: 0;
    bottom: 0;
    left: -1px;
    width: 2px;
    background: var(--ak-accent);
}

/* A group inside a match: its colour as a line under the text. */
.rx-landing-app .rx-g {
    box-shadow: inset 0 -3px 0 var(--rx-c);
}

/* --- Status: a pill (matches, no match, invalid) and the counts --------------------------------------------------- */

.rx-landing-app .rx-status-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem 1rem;
}

.rx-landing-app .rx-status {
    margin: 0;
    padding: 0.25rem 0.7rem;
    border-radius: var(--ak-radius-pill);
    background: var(--ak-panel);
    color: var(--ak-muted);
    font-weight: 600;
}

.rx-landing-app .rx-status.is-valid {
    background: color-mix(in srgb, var(--ak-success) 12%, var(--ak-bg));
    color: var(--ak-success);
}

.rx-landing-app .rx-status.is-invalid {
    background: color-mix(in srgb, var(--ak-danger) 10%, var(--ak-bg));
    color: var(--ak-danger);
}

.rx-landing-app .rx-status.is-busy {
    opacity: 0.6;
}

.rx-landing-app .rx-meta {
    margin: 0;
}

.rx-landing-app .rx-meta > span + span {
    margin-inline-start: 0.9rem;
}

.rx-landing-app .rx-meta-name::after {
    content: ": ";
}

.rx-landing-app .rx-error {
    padding: 0.6rem 0.8rem;
    border: 1px solid var(--ak-danger);
    border-radius: var(--ak-radius);
    background: color-mix(in srgb, var(--ak-danger) 8%, var(--ak-bg));
    color: var(--ak-danger);
}

.rx-landing-app .rx-error-msg {
    margin: 0;
    font-weight: 600;
    overflow-wrap: anywhere;
}

/* --- The matches table ------------------------------------------------------------------------------------------- */

.rx-landing-app .rx-table tbody tr {
    cursor: pointer;
}

.rx-landing-app .rx-table tbody tr:hover,
.rx-landing-app .rx-table tbody tr:focus-visible {
    background: var(--ak-hover);
}

.rx-landing-app .rx-cell {
    max-width: 22rem;
    font-family: var(--ak-font-mono);
    font-size: var(--ak-fs-sm);
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.rx-landing-app .rx-none {
    color: var(--ak-muted);
    font-style: italic;
}

.rx-landing-app .rx-gh {
    white-space: nowrap;
}

.rx-landing-app .rx-gh::before {
    content: "";
    display: inline-block;
    width: 0.65rem;
    height: 0.65rem;
    margin-inline-end: 0.35rem;
    border-radius: 50%;
    background: var(--rx-c);
    vertical-align: baseline;
}

/* --- Replace, split, explain --------------------------------------------------------------------------------------- */

.rx-landing-app .rx-output {
    min-height: 8rem;
}

.rx-landing-app .rx-parts {
    margin: 0;
    padding-inline-start: 2.6rem;
    font-family: var(--ak-font-mono);
    font-size: var(--ak-fs-sm);
}

.rx-landing-app .rx-part {
    padding: 0.15rem 0;
    border-bottom: 1px solid var(--ak-grid);
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.rx-landing-app .rx-part::marker {
    color: var(--ak-muted);
}

.rx-landing-app .rx-explain {
    margin: 0;
    padding: 0;
    list-style: none;
}

.rx-landing-app .rx-x {
    display: flex;
    align-items: baseline;
    gap: 0.7rem;
    padding: 0.3rem 0;
    padding-inline-start: calc(var(--rx-depth, 0) * 1.25rem);
    border-bottom: 1px solid var(--ak-grid);
}

.rx-landing-app .rx-x-code {
    flex: none;
    max-width: 50%;
    padding: 0.05rem 0.4rem;
    border-radius: var(--ak-radius-sm);
    background: var(--ak-panel);
    font-family: var(--ak-font-mono);
    font-size: var(--ak-fs-sm);
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    direction: ltr;
    unicode-bidi: isolate;
}

/* --- Controls ------------------------------------------------------------------------------------------------------ */

.rx-landing-app .rx-flag-list {
    display: grid;
    gap: 0.15rem;
}

.rx-landing-app .rx-modes .ak-seg-btn {
    flex: 1 1 auto;
}
