/* #368 Advanced search. Plain CSS (output.css is precompiled Tailwind, so new utility classes would not
   exist). Colours and fonts come from the new look's tokens (next.css: colours as "r g b" triplets, fonts as
   --font-ui / --font-read) when the page has them and fall back to the same values in the classic UI. Every
   class is prefixed as-. */

.as-page {
    --as-surface: rgb(var(--surface, 251 248 243));
    --as-paper: rgb(var(--paper, 255 253 249));
    --as-ink: rgb(var(--ink, 35 28 23));
    --as-muted: rgb(var(--ink-muted, 107 93 79));
    --as-brand: rgb(var(--brand, 127 92 40));
    --as-rule: rgb(var(--brand-rule, 155 115 58));
    --as-accent: rgb(var(--accent, 131 11 12));
    --as-line: rgb(var(--line, 230 220 203));
    --as-line-strong: rgb(var(--line-strong, 143 127 102));
    --as-hl: rgb(var(--hl, 242 221 176));
    --as-ok: rgb(var(--ok, 27 107 69));
    --as-ok-bg: rgb(var(--ok-bg, 228 242 234));
    --as-danger: rgb(var(--danger, 180 35 24));
    --as-danger-bg: rgb(var(--danger-bg, 251 234 232));
    --as-ui: var(--font-ui, 'Source Sans 3', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif);
    --as-read: var(--font-read, 'STIX Two Text', Georgia, serif);

    flex: 1 1 auto;
    width: 100%;
    overflow-y: auto;
    background: var(--as-surface);
    color: var(--as-ink);
    font-family: var(--as-ui);
    font-size: 15px;
    line-height: 1.45;
}

.as-layout {
    box-sizing: border-box;
    max-width: 84rem;
    margin: 0 auto;
    padding: 1rem;
    display: grid;
    gap: 1.25rem;
    grid-template-columns: minmax(0, 1fr);
    align-items: start;
}

@media (min-width: 768px) {
    .as-layout {
        grid-template-columns: 19rem minmax(0, 1fr);
        padding: 1.25rem 1.5rem 2rem;
    }
    .as-panel {
        position: sticky;
        top: 0;
    }
}

.as-page *, .as-page *::before, .as-page *::after { box-sizing: border-box; }

.as-page h1 {
    font-family: var(--as-read);
    font-size: 1.5rem;
    font-weight: 600;
    margin: 0 0 0.75rem;
    color: var(--as-brand);
}

.as-page a { color: var(--as-brand); }
.as-page a:hover { color: var(--as-accent); }

.as-page :focus-visible {
    outline: 2px solid var(--as-rule);
    outline-offset: 2px;
}

/* --- form panel ------------------------------------------------------------------------------- */

.as-panel {
    background: var(--as-paper);
    border: 1px solid var(--as-line);
    border-radius: 8px;
    padding: 1rem;
}

.as-form { display: flex; flex-direction: column; gap: 0.85rem; }

.as-field { display: flex; flex-direction: column; gap: 0.3rem; min-width: 0; }

.as-label, .as-page legend {
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    color: var(--as-muted);
    padding: 0;
}

.as-page fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }

.as-input, .as-select {
    width: 100%;
    min-height: 2.4rem;
    padding: 0.35rem 0.6rem;
    border: 1px solid var(--as-line-strong);
    border-radius: 6px;
    background: #fff;
    color: var(--as-ink);
    font: inherit;
}

.as-input-read {
    font-family: var(--as-read);
    font-size: 1.1rem;
}

.as-select:disabled, .as-input:disabled {
    background: var(--as-surface);
    color: var(--as-muted);
    cursor: not-allowed;
}

.as-kb {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.85rem;
    color: var(--as-muted);
}

.as-kb select {
    border: 1px solid var(--as-line-strong);
    border-radius: 4px;
    background: #fff;
    padding: 0.1rem 0.25rem;
    font: inherit;
}

.as-segmented {
    display: flex;
    flex-wrap: wrap;
    gap: 0;
}

.as-segmented legend { margin-bottom: 0.3rem; }

.as-segmented input {
    position: absolute;
    opacity: 0;
    width: 1px;
    height: 1px;
}

.as-segmented label {
    flex: 1 1 0;
    text-align: center;
    padding: 0.4rem 0.6rem;
    border: 1px solid var(--as-line-strong);
    background: #fff;
    cursor: pointer;
    font-weight: 600;
    color: var(--as-muted);
}

.as-segmented label:first-of-type { border-radius: 6px 0 0 6px; }
.as-segmented label:last-of-type { border-radius: 0 6px 6px 0; border-left: 0; }
/* three choices with the critical text (#32): the three do not fit in a row in the sidebar (19rem) or on a narrow phone, so
   at every width Transcriptions and Metadata side by side, and "Critical text & / Documentation of variants" under them
   across both, on two lines (the editors, 20 Nov 2026: the Documentation of Variants is not a critical text) */
.as-segmented label:not(:first-of-type) { border-left: 0; }
.as-segmented:has(label:nth-of-type(3)) { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.as-segmented:has(label:nth-of-type(3)) label:nth-of-type(1) { border-radius: 6px 0 0 0; }
.as-segmented:has(label:nth-of-type(3)) label:nth-of-type(2) { border-radius: 0 6px 0 0; }
.as-segmented:has(label:nth-of-type(3)) label:nth-of-type(3) {
    grid-column: 1 / -1; border-top: 0; border-left: 1px solid var(--as-line-strong); border-radius: 0 0 6px 6px;
}
.as-segmented:has(label:nth-of-type(3)) input:checked + label:nth-of-type(3) { border-left-color: var(--as-brand); }

.as-segmented label.as-scope-two-lines { line-height: 1.3; }

.as-segmented input:checked + label {
    background: var(--as-brand);
    border-color: var(--as-brand);
    color: #fff;
}

.as-segmented input:focus-visible + label {
    outline: 2px solid var(--as-rule);
    outline-offset: 2px;
}

.as-options {
    border: 1px solid var(--as-line);
    border-radius: 6px;
    padding: 0.4rem 0.7rem;
}

.as-options summary {
    cursor: pointer;
    font-weight: 600;
    color: var(--as-brand);
}

.as-options[open] summary { margin-bottom: 0.4rem; }

.as-check {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 0 0.5rem;
    align-items: baseline;
    padding: 0.2rem 0;
    cursor: pointer;
}

.as-check input { accent-color: var(--as-brand); margin: 0; }

.as-hint {
    grid-column: 2;
    font-size: 0.8rem;
    color: var(--as-muted);
}

.as-check-disabled { opacity: 0.55; cursor: not-allowed; }

.as-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }

.as-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 2.4rem;
    padding: 0.35rem 1rem;
    border: 1px solid var(--as-brand);
    border-radius: 999px;
    background: #fff;
    color: var(--as-brand);
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
}

.as-button:hover { background: var(--as-surface); color: var(--as-brand); }

.as-primary { background: var(--as-brand); color: #fff; }
.as-primary:hover { background: var(--as-accent); border-color: var(--as-accent); color: #fff; }

.as-danger-button { border-color: var(--as-danger); color: var(--as-danger); }
.as-danger-button:hover { background: var(--as-danger-bg); color: var(--as-danger); }

.as-small {
    min-height: 0;
    padding: 0.1rem 0.6rem;
    font-size: 0.8rem;
}

.as-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 0.9rem;
    border-bottom: 1px solid var(--as-line);
}

.as-tabs a {
    padding: 0.35rem 0.8rem;
    margin-bottom: -1px;
    border-bottom: 2px solid transparent;
    color: var(--as-muted);
    font-weight: 600;
    text-decoration: none;
}

.as-tabs a[aria-current="page"] {
    color: var(--as-brand);
    border-bottom-color: var(--as-rule);
}

/* --- results ---------------------------------------------------------------------------------- */

.as-results { min-width: 0; }

.as-summary {
    margin: 0 0 0.5rem;
    font-size: 1.05rem;
}

.as-summary q { font-family: var(--as-read); quotes: '\2018' '\2019'; }

.as-note, .as-alert, .as-success {
    margin: 0 0 0.75rem;
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
    border: 1px solid var(--as-line);
    background: var(--as-paper);
}

.as-alert { border-color: var(--as-danger); background: var(--as-danger-bg); color: var(--as-danger); }
.as-success { border-color: var(--as-ok); background: var(--as-ok-bg); color: var(--as-ok); }

.as-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    align-items: center;
    margin: 0.25rem 0 0.75rem;
}

.as-group, .as-witness { margin: 0 0 0.6rem; }

.as-group {
    background: var(--as-paper);
    border: 1px solid var(--as-line);
    border-radius: 8px;
}

.as-group > summary, .as-witness > summary {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.4rem 0.6rem;
    cursor: pointer;
    list-style-position: inside;
}

.as-group > summary {
    padding: 0.55rem 0.8rem;
    font-family: var(--as-read);
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--as-brand);
    border-bottom: 1px solid var(--as-line);
}

.as-group:not([open]) > summary { border-bottom: 0; }

.as-group-body { padding: 0.5rem 0.8rem 0.2rem; }

.as-witness > summary {
    font-weight: 600;
    padding: 0.2rem 0;
    color: var(--as-ink);
}

.as-witness-name { overflow-wrap: anywhere; }

.as-count {
    font-family: var(--as-ui);
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--as-muted);
    background: var(--as-surface);
    border: 1px solid var(--as-line);
    border-radius: 999px;
    padding: 0 0.5rem;
}

.as-badge {
    font-family: var(--as-ui);
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 999px;
    padding: 0 0.5rem;
}

.as-public { background: var(--as-ok-bg); color: var(--as-ok); }
.as-private { background: var(--as-hl); color: var(--as-brand); }

.as-group-actions { margin-left: auto; display: inline-flex; gap: 0.3rem; }

.as-rows, .as-hits { list-style: none; margin: 0; padding: 0; }

.as-row {
    padding: 0.45rem 0 0.45rem 0.9rem;
    border-left: 2px solid var(--as-line);
    margin: 0 0 0.35rem;
}

.as-ref {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--as-muted);
    overflow-wrap: anywhere;
}

.as-hit {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.1rem 0.6rem;
    padding: 0.15rem 0;
}

.as-hit-select {
    display: flex;
    gap: 0.5rem;
    align-items: baseline;
    flex: 1 1 20rem;
    min-width: 0;
}

.as-hit-select input { accent-color: var(--as-brand); flex: none; }

.as-kwic {
    flex: 1 1 20rem;
    min-width: 0;
    font-family: var(--as-read);
    font-size: 1.02rem;
    overflow-wrap: anywhere;
    color: var(--as-ink);
    text-decoration: none;
}

a.as-kwic:hover { text-decoration: underline; text-decoration-color: var(--as-rule); color: var(--as-ink); }

.as-loc {
    flex: none;
    font-size: 0.8rem;
    color: var(--as-muted);
    font-variant-numeric: tabular-nums;
}

.as-page mark {
    background: var(--as-hl);
    color: inherit;
    border-bottom: 2px solid var(--as-rule);
    padding: 0 1px;
}

.as-page del {
    background: var(--as-danger-bg);
    color: var(--as-danger);
    text-decoration-thickness: 2px;
}

.as-page ins {
    background: var(--as-ok-bg);
    color: var(--as-ok);
    text-decoration: none;
    border-bottom: 2px solid var(--as-ok);
}

.as-field-label { font-weight: 600; }

.as-sticky-bar {
    position: sticky;
    bottom: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1rem;
    align-items: center;
    padding: 0.6rem 0.8rem;
    margin-top: 0.75rem;
    background: var(--as-paper);
    border: 1px solid var(--as-line-strong);
    border-radius: 8px;
    box-shadow: 0 -2px 8px rgb(0 0 0 / 0.06);
}

.as-recent {
    margin-top: 1rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--as-line);
    font-size: 0.9rem;
}

.as-recent ul { list-style: none; margin: 0.3rem 0 0; padding: 0; }
.as-recent li { padding: 0.2rem 0; }

.as-table { width: 100%; border-collapse: collapse; background: var(--as-paper); }
.as-table th, .as-table td {
    text-align: left;
    padding: 0.4rem 0.6rem;
    border-bottom: 1px solid var(--as-line);
    vertical-align: top;
    overflow-wrap: anywhere;
}
.as-table th { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.03em; color: var(--as-muted); }

.as-narrow { max-width: 56rem; margin: 0 auto; padding: 1rem; }

.as-spaced { margin-top: 1rem; }

.as-list { margin: 0 0 0.75rem; padding-left: 1.25rem; list-style: disc; }

.as-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}
