/* Roadmap idea 6 and #332: the critical-text navigator (js/cte_nav.js) and the About window, in both looks, in the
   classic colours: the witness view's toolbar grey (bgray-500) with black dividers, the brown of the tabs and pickers
   (bblue-500 rgb(155 115 58)), the grey of the ☰ it replaces (gray-300), maroon (bred-500) for keyboard focus. The new
   look's rules are scoped to html[data-ui="next"] at the end. */

/* ---------- the toolbar under the tabs ---------- */
#cte-nav {
    position: relative; z-index: 21; flex: none;
    display: flex; flex-wrap: wrap; align-items: center; gap: .25rem .75rem;
    padding: .25rem .5rem; background: rgb(240 240 240); border-bottom: 1px solid #000;
    font-size: .875rem; line-height: 1.25rem; color: #000;
}
#cte-nav .cte-nav-group { display: inline-flex; align-items: center; gap: .25rem; margin: 0; }
/* the dividers of the witness view's toolbar */
#cte-nav :is(.cte-lemma, .cte-nav-passages, .cte-nav-goto, .cte-nav-find, .cte-nav-reimport) {
    border-left: 1px solid #000; padding-left: .75rem; }
/* Go to and Find are items of the toolbar on a wide screen; on a phone (new look) they open from a button */
#cte-nav .cte-nav-search { display: contents; }
#cte-nav button.cte-nav-search-toggle { display: none; }
#cte-nav .cte-nav-label { font-size: .75rem; white-space: nowrap; }

#cte-nav .cte-nav-button {
    display: inline-flex; align-items: center; gap: .25rem; padding: .125rem .5rem; border-radius: .25rem;
    background: rgb(209 213 219); color: #000; white-space: nowrap; cursor: pointer; font: inherit;
}
#cte-nav .cte-nav-button svg, #cte-nav .cte-nav-caret { width: .75rem; height: .75rem; flex: none; }
#cte-nav .cte-nav-step, #cte-nav .cte-nav-search-toggle {
    display: inline-flex; flex: none; align-items: center; justify-content: center; width: 1.5rem; height: 1.5rem; padding: 0;
    border-radius: .25rem; background: none; color: inherit; cursor: pointer;
}
#cte-nav .cte-nav-step svg, #cte-nav .cte-nav-search-toggle svg { width: 1.25rem; height: 1.25rem; }
#cte-nav .cte-nav-step:disabled { opacity: .3; cursor: default; }
@media (hover: hover) {
    #cte-nav .cte-nav-button:hover, #cte-nav .cte-nav-step:not(:disabled):hover, #cte-nav .cte-nav-search-toggle:hover {
        background: #fff; }
}
#cte-nav :is(.cte-nav-select, .cte-nav-input) {
    height: 1.75rem; padding: 0 .375rem; border: 2px solid rgb(155 115 58); border-radius: .25rem; background: #fff;
    color: #000; font: inherit; min-width: 0;
}
/* Philipp (24 Nov 2026): as wide as the longest passage name where its line of the toolbar has the room, else as the
   room the line leaves (at least 10rem), measured by js/cte_nav.js (fitPicker, rowFit), up to 30rem. It was 10rem
   (13.5rem below), and collection 129's names were cut. A phone's picker takes its line's room (below) */
#cte-nav .cte-nav-select { width: var(--cte-nav-fit, auto); max-width: 30rem; }
#cte-nav .cte-nav-select:disabled { opacity: .6; }
/* #403: Passages names a passage by the editors' number and, when it is another name, its label after it (cte_nav.js:
   "5" with "3.1.4"). A native drop-down shows an option's text alone, "5 (3.1.4)" (phones, Safari, Firefox); where the
   list can be styled (a customizable select: Chrome and Edge, with a mouse) the label is small and grey, without the
   brackets. The control itself keeps its look. */
#cte-nav .cte-nav-select option .cte-nav-second { font-variant-numeric: tabular-nums; }
@supports (appearance: base-select) {
    @media (hover: hover) and (pointer: fine) {
        #cte-nav .cte-nav-select, #cte-nav .cte-nav-select::picker(select) { appearance: base-select; }
        #cte-nav .cte-nav-select { display: inline-flex; align-items: center; gap: .25rem; padding: 0 .25rem 0 .375rem;
            white-space: nowrap; overflow: hidden; cursor: default; }
        #cte-nav .cte-nav-select::picker-icon { flex: none; font-size: .75em; color: rgb(75 85 99); }
        /* a hidden copy measured without its arrow (js/cte_nav.js, optionFit): where only the arrow is cut, the name
           shows whole and Passages has no title */
        #cte-nav .cte-nav-select.cte-nav-bare { gap: 0; }
        #cte-nav .cte-nav-select.cte-nav-bare::picker-icon { display: none; }
        #cte-nav .cte-nav-select::picker(select) {
            max-height: min(26rem, 60vh); overflow-y: auto; margin: 2px 0; padding: .25rem 0; border: 1px solid rgb(155 115 58);
            border-radius: .25rem; background: #fff; color: #000; box-shadow: 0 6px 18px rgb(0 0 0 / .18); font: inherit; }
        #cte-nav .cte-nav-select option { display: flex; align-items: baseline; gap: 0; padding: .125rem .75rem .125rem .5rem;
            white-space: nowrap; font-variant-numeric: tabular-nums; }
        #cte-nav .cte-nav-select option::checkmark { display: none; }
        #cte-nav .cte-nav-select option:checked { background: rgb(155 115 58 / .16); font-weight: 600; }
        #cte-nav .cte-nav-select option:focus-visible { outline: 2px solid rgb(131 11 12); outline-offset: -2px; }
        #cte-nav .cte-nav-select option .cte-nav-paren { display: none; }
        #cte-nav .cte-nav-select option .cte-nav-second { margin-left: .625em; font-size: .8em; font-weight: 400; color: rgb(75 85 99); }
    }
}
#cte-nav #cte-nav-goto { width: 6.5rem; }
#cte-nav #cte-nav-find { width: 13rem; }
#cte-nav .cte-nav-input[aria-invalid="true"] { border-color: rgb(131 11 12); }
#cte-nav :is(button, summary, select, input, a):focus-visible { outline: 2px solid rgb(131 11 12); outline-offset: 1px; }
#cte-nav .cte-nav-count { white-space: nowrap; font-variant-numeric: tabular-nums; }
#cte-nav.is-finding .cte-nav-count { min-width: 4.5rem; }
#cte-nav [data-find] { display: none; }
#cte-nav.is-finding [data-find] { display: inline-flex; }
/* Find reads the text pane only: said while something is searched (and to screen readers, aria-describedby) */
#cte-nav .cte-nav-note { display: none; font-size: .75rem; color: #4b5563; white-space: nowrap; }
#cte-nav.is-finding .cte-nav-note { display: inline; }
#cte-nav .cte-nav-reimport a { white-space: nowrap; display: inline-flex; align-items: center; gap: .3em; }
/* an arrow into a tray (Martin, 9 Nov 2026), drawn in the link's colour; the text keeps its underline */
#cte-nav .cte-nav-reimport-icon { flex: none; width: 1.15em; height: 1.15em; }

/* the navigator's messages (Back at …, Passage …, There is no passage …): over the foot of the text pane, in the
   classic white and brown of the toolbar's panels. They take no room, so the text never moves as they come and go;
   clicks go through to the text, except on their link */
#content-text { position: relative; }
.cte-nav-status {
    position: absolute; right: 1.5rem; bottom: .75rem; z-index: 16; max-width: min(34rem, calc(100% - 2.5rem));
    padding: .375rem .75rem; border: 1px solid rgb(155 115 58); border-radius: .375rem; background: #fff;
    box-shadow: 0 4px 14px rgb(0 0 0 / .16); font-size: .8125rem; line-height: 1.25rem; color: #374151;
    pointer-events: none;
}
.cte-nav-status:empty { display: none; }
.cte-nav-status a { pointer-events: auto; color: rgb(155 115 58); text-decoration: underline; white-space: nowrap; }
.cte-nav-status a:focus-visible { outline: 2px solid rgb(131 11 12); outline-offset: 1px; }

/* Lemma settings (editors): a menu that works without the script too (<details>) */
#cte-nav .cte-lemma { position: relative; display: inline-block; }
#cte-nav .cte-lemma > summary { list-style: none; }
#cte-nav .cte-lemma > summary::-webkit-details-marker { display: none; }
#cte-nav .cte-lemma[open] > summary { background: #fff; }
#cte-nav .cte-lemma-panel {
    position: absolute; top: calc(100% + 6px); left: 0; z-index: 40; width: 22rem; max-width: calc(100vw - 1rem);
    display: flex; flex-direction: column; gap: .5rem; padding: .75rem; background: #fff;
    border: 1px solid rgb(155 115 58); border-radius: .375rem; box-shadow: 0 6px 18px rgb(0 0 0 / .18);
}
#cte-nav .cte-lemma-panel label { font-weight: 600; }
#cte-nav .cte-lemma-panel .cte-nav-input { width: 100%; height: 2rem; }
#cte-nav .cte-lemma-panel p { margin: 0; font-size: .8125rem; color: #374151; }
#cte-nav .cte-lemma-actions { display: flex; justify-content: flex-end; gap: .5rem; }
#cte-nav .cte-nav-primary {
    padding: .25rem .875rem; border-radius: .25rem; background: rgb(155 115 58); color: #fff; font-weight: 600;
    cursor: pointer; font: inherit; font-weight: 600;
}
@media (hover: hover) { #cte-nav .cte-nav-primary:hover { background: rgb(132 98 49); } }

/* ---------- Find: the hits in the text pane (CSS Custom Highlight API; nothing is added to the page) ---------- */
::highlight(cte-find) { background-color: #fef08a; color: #000; }
::highlight(cte-find-current) { background-color: #fb923c; color: #000; }
/* a browser without highlights: a box over the current hit */
.cte-find-box { position: fixed; inset: 0; z-index: 15; pointer-events: none; }
.cte-find-box > div { position: fixed; background: rgb(251 146 60 / .4); outline: 2px solid #ea580c; border-radius: 2px; }
@media (forced-colors: active) {
    ::highlight(cte-find) { background-color: Mark; color: MarkText; }
    ::highlight(cte-find-current) { background-color: Highlight; color: HighlightText; }
}

/* ---------- About this edition (#332): the About tab's page, in a window over the text ---------- */
.cte-about-dialog {
    width: 44rem; max-width: calc(100vw - 2rem); max-height: calc(100vh - 4rem); padding: 0; border: 0;
    border-radius: .5rem; box-shadow: 0 10px 30px rgb(0 0 0 / .3); color: #000;
}
.cte-about-dialog::backdrop { background: rgb(75 85 99 / .5); }
.cte-about-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .75rem 1rem .75rem 1.5rem;
    background: rgb(155 115 58); color: #fff; }
.cte-about-head h2 { margin: 0; font-size: 1.5rem; line-height: 2rem; font-weight: 700; }
.cte-about-head button { display: inline-flex; padding: .25rem; border-radius: .25rem; background: none; color: inherit; cursor: pointer; }
.cte-about-head button svg { width: 1.5rem; height: 1.5rem; }
.cte-about-head button:focus-visible { outline: 2px solid #fff; outline-offset: 1px; }
.cte-about-body { padding: 1rem 1.5rem 1.5rem; overflow-y: auto; max-height: calc(100vh - 9rem); }
.cte-about-body .cte-about-loading { color: #4b5563; }

.cte-about { font-size: .9375rem; line-height: 1.5; }
.cte-about h3 { margin: 1.25rem 0 .5rem; font-size: 1.125rem; font-weight: 700; color: rgb(155 115 58); }
.cte-about h3:first-child { margin-top: 0; }
.cte-about dl { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: .25rem 1rem; margin: 0; }
.cte-about dt { font-weight: 600; }
.cte-about dd { margin: 0; overflow-wrap: anywhere; }
.cte-about dd + dd { grid-column: 2; }
.cte-about ul.cte-about-list { margin: 0; padding: 0; list-style: none; }
.cte-about .cte-about-empty { color: #4b5563; font-style: italic; }
.cte-about .cte-about-source { margin-top: 1.25rem; padding-top: .75rem; border-top: 1px solid #e5e7eb; font-size: .8125rem; color: #4b5563; }
.cte-about .cte-about-source a { color: rgb(155 115 58); text-decoration: underline; }
@media (max-width: 639px) {
    .cte-about dl { grid-template-columns: minmax(0, 1fr); }
    .cte-about dd, .cte-about dd + dd { grid-column: 1; margin-bottom: .25rem; }
    .cte-about-body { padding: .75rem 1rem 1rem; }
}

@media print {
    #cte-nav { display: none; }
    .cte-nav-status { display: none; }
}

/* ---------- the new look ---------- */
html[data-ui="next"] #cte-nav { font-family: var(--font-ui); font-size: .9375rem; gap: .3125rem .875rem; padding: .3125rem .625rem; }
html[data-ui="next"] #cte-nav .cte-nav-label { font-size: .8125rem; }
html[data-ui="next"] #cte-nav .cte-nav-button {
    height: 2rem; padding: 0 .625rem; border: 1px solid rgb(var(--brown) / .55); border-radius: 6px; background: #fff;
    color: rgb(46 35 22); font-weight: 600; transition: background-color .12s ease; }
html[data-ui="next"] #cte-nav .cte-nav-step, html[data-ui="next"] #cte-nav .cte-nav-search-toggle {
    width: 2rem; height: 2rem; border-radius: 6px; color: rgb(46 35 22 / .85); }
html[data-ui="next"] #cte-nav :is(.cte-nav-select, .cte-nav-input) { height: 2rem; border-radius: 6px; }
html[data-ui="next"] #cte-nav .cte-lemma[open] > summary { background: var(--tint); }
@media (hover: hover) {
    html[data-ui="next"] #cte-nav .cte-nav-button:hover, html[data-ui="next"] #cte-nav .cte-nav-step:not(:disabled):hover,
    html[data-ui="next"] #cte-nav .cte-nav-search-toggle:hover { background: var(--tint); }
}
html[data-ui="next"] #cte-nav .cte-lemma-panel { border-radius: 8px; }
html[data-ui="next"] .cte-nav-status { font-family: var(--font-ui); border-radius: 8px; }
html[data-ui="next"] .cte-about-dialog { font-family: var(--font-ui); border-radius: 10px; }
html[data-ui="next"] .cte-about-head h2 { font-family: 'STIX Two Text', Georgia, serif; font-weight: 600; }

/* phones, in both looks (the classic toolbar wrapped to five lines): Apparatuses and the passages on one line (the
   passage picker takes the room left), Go to and Find open from the magnifier button at its end; editors' Lemma
   settings and Re-import XML on the next line */
@media (max-width: 767px) {
    #cte-nav { gap: .25rem .375rem; padding: .25rem .5rem; }
    #cte-nav .cte-nav-passages { flex: 1 1 9rem; min-width: 0; border-left: 0; padding-left: 0; }
    #cte-nav .cte-nav-passages :is(.cte-nav-label, [data-step="first"], [data-step="last"]) { display: none; }
    #cte-nav .cte-nav-select { flex: 1 1 auto; max-width: none; width: 100%; }
    #cte-nav button.cte-nav-search-toggle { display: inline-flex; }
    #cte-nav .cte-nav-search-toggle[aria-expanded="true"] { background: #fff; }
    #cte-nav .cte-nav-search { display: none; }
    #cte-nav.is-searching .cte-nav-search { display: flex; flex-direction: column; gap: .25rem; flex: 1 1 100%; }
    #cte-nav .cte-nav-search > form { border-left: 0; padding-left: 0; display: flex; flex-wrap: wrap; width: 100%; }
    #cte-nav .cte-nav-search .cte-nav-input { flex: 1 1 0; width: auto !important; }
    #cte-nav .cte-nav-find .cte-nav-note { flex: 1 1 100%; white-space: normal; }
    #cte-nav :is(.cte-lemma, .cte-nav-reimport) { order: 2; border-left: 0; padding-left: 0; }
    #cte-nav .cte-lemma-panel { position: fixed; left: .5rem; right: .5rem; top: auto; width: auto; margin-top: .375rem; }
    html[data-ui="next"] #cte-nav { gap: .25rem .375rem; padding: .25rem .5rem; }
    html[data-ui="next"] #cte-nav .cte-nav-search-toggle[aria-expanded="true"] { background: var(--tint); }
    .cte-nav-status { right: .75rem; bottom: .5rem; max-width: calc(100% - 1.5rem); }
}
/* touch: 40 px targets */
@media (pointer: coarse) {
    html[data-ui="next"] #cte-nav .cte-nav-step, html[data-ui="next"] #cte-nav .cte-nav-search-toggle { width: 2.5rem; height: 2.5rem; }
    html[data-ui="next"] #cte-nav :is(.cte-nav-select, .cte-nav-input, .cte-nav-button) { height: 2.5rem; }
    html[data-ui="next"] #cte-nav .cte-nav-primary { min-height: 2.5rem; }
    html[data-ui="next"] .cte-about-head button { padding: .5rem; margin: -.25rem; }
}

/* the About tab as a page of its own (pages/cte_about.html) */
.cte-about-page { width: 100%; max-width: 46rem; margin: 0 auto; padding: 1.5rem 1rem 2.5rem; }
.cte-about-page > h2 { margin: 0 0 1rem; font-size: 1.5rem; line-height: 2rem; font-weight: 700; }
html[data-ui="next"] .cte-about-page > h2 { font-family: 'STIX Two Text', Georgia, serif; font-weight: 600; }
