/* The "Try it" panel under each ```regex block (see shared/regex-tester.js).
   Uses the theme variables that shared/library.css maps from the brand palette. */

.regex-try-button,
.regex-try-reset {
    font: inherit;
    font-size: 0.9em;
    color: var(--links);
    background: none;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 2px 10px;
    cursor: pointer;
}
.regex-try-button {
    display: block;
    margin: -8px 0 16px;
}
.regex-try-button::before {
    content: "▸ ";
}
.regex-try-button[aria-expanded="true"]::before {
    content: "▾ ";
}
.regex-try-button:hover,
.regex-try-reset:hover {
    border-color: var(--links);
}

.regex-try {
    display: grid;
    gap: 6px;
    margin: -8px 0 20px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    font-size: 0.93em;
}
.regex-try[hidden],
.regex-try [hidden] {
    display: none;
}

.regex-try-label {
    margin: 6px 0 0;
    color: var(--muted);
    font-size: 0.9em;
}
.regex-try input:not([type]),
.regex-try textarea {
    box-sizing: border-box;
    width: 100%;
    font: inherit;
    color: var(--fg);
    background: var(--field);
    border: 1px solid var(--searchbar-border-color);
    border-radius: 6px;
    padding: 6px 8px;
}
.regex-try textarea {
    resize: vertical;
    field-sizing: content;
    min-height: 3lh;
    max-height: 14lh;
}
.regex-try input:disabled {
    opacity: 0.5;
}
.regex-try :focus-visible {
    outline: 2px solid var(--links);
    outline-offset: 1px;
}

.regex-try-flags {
    display: flex;
    flex-wrap: wrap;
    gap: 2px 18px;
    font-size: 0.9em;
    color: var(--muted);
}
.regex-try-flags label,
.regex-try-replace label {
    cursor: pointer;
    white-space: nowrap;
}
.regex-try-replace {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 6px;
}
.regex-try-replace label {
    color: var(--muted);
    font-size: 0.9em;
}
.regex-try-replace input:not([type]) {
    flex: 1;
    width: auto;
    min-width: 0;
}

.regex-try-status {
    margin: 10px 0 0;
    padding-top: 10px;
    border-top: 1px solid var(--line);
    font-weight: 600;
}
.regex-try-status.error {
    color: #b3261e;
    font-weight: 400;
}
.coal .regex-try-status.error,
.navy .regex-try-status.error,
.ayu .regex-try-status.error {
    color: #f2b8b5;
}

.regex-try-preview {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    background: var(--field);
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 6px 8px;
    min-height: 1lh;
}
.regex-try mark {
    color: inherit;
    background: color-mix(in srgb, var(--links) 25%, transparent);
    border-radius: 2px;
}
.regex-try mark.alt {
    background: color-mix(in srgb, var(--links) 45%, transparent);
}
/* An empty match is a position, not text: draw it as a caret. */
.regex-try mark.empty {
    display: inline-block;
    width: 0;
    height: 1.2em;
    vertical-align: text-bottom;
    background: none;
    border-left: 2px solid var(--links);
    margin-inline: -1px;
}

.regex-try-matches {
    margin: 4px 0 0;
    padding-left: 2.5em;
    max-height: 18em;
    overflow-y: auto;
}
.regex-try-matches li {
    margin: 2px 0;
}
.regex-try-matches code,
.regex-try-groups code {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}
.regex-try-groups {
    display: flex;
    flex-wrap: wrap;
    gap: 0 16px;
    font-size: 0.9em;
    color: var(--muted);
}
.regex-try-more {
    list-style: none;
    color: var(--muted);
}

.regex-try-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    margin-top: 8px;
    font-size: 0.85em;
    color: var(--muted);
}
