/* #403 Phase 3 (roadmap idea 3): permalinks and "Cite this" (js/permalinks.js), in both looks: loaded by the critical
   text page and the witness view in the classic look and the new one, in the classic colours (bblue-500 brown
   rgb(155 115 58), the grey label boxes, the amber of the apparatus flash). */

/* ---------- passage labels: Copy link ---------- */
#text-container .left-note[id] { position: relative; cursor: pointer; }
/* the passage the address names (and the one last clicked) */
#text-container .left-note.permalink-target { outline: 2px solid #d97706; outline-offset: 1px; }
/* the chosen label keeps its button shown, in room of its own, so that it covers none of the text ([id]: above the
   new look's margin on .left-note) */
#text-container .left-note.permalink-active[id] { margin-right: 1.6rem; }

/* the button sits just right of its label and takes no room in the line: hidden (and not clickable, so it never
   catches a click meant for a lemma) until the label is hovered (then it lies over the text for a moment) or chosen,
   or the button has keyboard focus */
#text-container .permalink-copy {
    position: absolute; left: 100%; top: 50%; transform: translateY(-50%); z-index: 5;
    margin: 0 0 0 3px; padding: 2px; line-height: 0; font-size: .875rem;
    color: rgb(155 115 58); background: #fff; border: 1px solid rgb(155 115 58); border-radius: 3px;
    opacity: 0; pointer-events: none; transition: opacity .12s ease;
    -webkit-user-select: none; user-select: none;
}
#text-container .permalink-copy svg { width: 1em; height: 1em; display: block; }
/* a lemma's highlight that runs over a label marks every element it passes (highlightText: bg-gray-900 text-white),
   the icon's among them: the icon keeps its colour */
#text-container .permalink-copy svg, #text-container .permalink-copy path { color: inherit; background: none; }
/* ...and the label looks as it did before it had a button, when it was one of those elements: white text (the page's
   .left-note grey box wins over bg-gray-900) */
#text-container .left-note[id]:has(> .permalink-copy .text-white) { color: #fff; }
#text-container .left-note:hover > .permalink-copy,
#text-container .left-note.permalink-active > .permalink-copy,
#text-container .permalink-copy:focus-visible,
#text-container .permalink-copy.is-copied { opacity: 1; pointer-events: auto; }
@media (hover: hover) {
    #text-container .permalink-copy:hover { background: rgb(155 115 58); color: #fff; }
}
#text-container .permalink-copy:focus-visible { outline: 2px solid rgb(131 11 12); outline-offset: 2px; }
/* "Link copied", for a moment, beside the button */
#text-container .permalink-copy.is-copied::after {
    content: attr(data-copied); position: absolute; left: 100%; top: 50%; transform: translateY(-50%); margin-left: 4px;
    pointer-events: none;  /* a click on the text under it is the text's */
    padding: 2px 6px; border-radius: 3px; background: rgb(17 24 39); color: #fff; white-space: nowrap;
    font: 600 .75rem/1.3 ui-sans-serif, system-ui, sans-serif;
}
/* touch screens: a larger button (24 px and up), shown on the label last tapped */
@media (pointer: coarse) {
    #text-container .permalink-copy { padding: 5px; font-size: 1rem; }
    #text-container .left-note.permalink-active[id] { margin-right: 2.25rem; }
}
@media (prefers-reduced-motion: reduce) { #text-container .permalink-copy { transition: none; } }
/* a printed page has no buttons to press, nor a passage chosen */
@media print {
    #text-container .permalink-copy { display: none; }
    #text-container .left-note.permalink-target { outline: none; }
    #text-container .left-note.permalink-active[id] { margin-right: 4px; }
}

/* text only screen readers hear */
.permalink-sr { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden;
    clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* ---------- witness view: Cite this ---------- */
.cite-button { display: inline-flex; align-items: center; gap: 2px; margin-left: .25rem; padding: 0 .25rem;
    min-height: 1.5rem; border-radius: 4px; font-size: .875rem; white-space: nowrap; }
.cite-button svg { width: 1.25rem; height: 1.25rem; }
@media (hover: hover) { .cite-button:hover { background-color: rgb(155 115 58 / .15); } }

#cite-dialog { width: min(40rem, calc(100vw - 2rem)); max-height: calc(100vh - 2rem); padding: 0; border: 0;
    border-radius: .5rem; background: #fff; color: #000; box-shadow: 0 10px 30px rgb(0 0 0 / .3); overflow: auto; }
#cite-dialog::backdrop { background: rgb(75 85 99 / .5); }
#cite-dialog:not([open]) { display: none; }
#cite-dialog[data-fallback][open] { position: fixed; top: 1rem; left: 0; right: 0; margin: 0 auto; z-index: 1000; }
#cite-dialog .cite-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem;
    padding: .625rem 1rem; background: rgb(155 115 58); color: #fff; }
#cite-dialog .cite-head h2 { margin: 0; font-size: 1.25rem; font-weight: 700; }
#cite-dialog .cite-head button { line-height: 0; padding: .25rem; border-radius: 4px; color: #fff; }
#cite-dialog .cite-head button svg { width: 1.5rem; height: 1.5rem; }
@media (hover: hover) { #cite-dialog .cite-head button:hover { background: rgb(255 255 255 / .2); } }
#cite-dialog .cite-body { display: flex; flex-direction: column; gap: .75rem; padding: 1rem; }
#cite-dialog .cite-note { margin: 0; font-size: .8125rem; color: rgb(75 85 99); }
#cite-dialog textarea { width: 100%; min-height: 8rem; padding: .5rem; resize: vertical; font: inherit; line-height: 1.5;
    border: 2px solid rgb(155 115 58); border-radius: .25rem; background: #fff; color: #000; }
#cite-dialog .cite-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }
#cite-dialog .cite-actions button { padding: .375rem .875rem; border-radius: .375rem; font-weight: 600;
    border: 1px solid rgb(155 115 58); }
#cite-dialog .cite-actions .cite-primary { background: rgb(155 115 58); color: #fff; }
#cite-dialog .cite-actions .cite-secondary { background: #fff; color: rgb(155 115 58); }
@media (hover: hover) {
    #cite-dialog .cite-actions .cite-primary:hover { background: rgb(132 98 49); }
    #cite-dialog .cite-actions .cite-secondary:hover { background: rgb(155 115 58 / .15); }
}
#cite-dialog [role="status"] { font-size: .875rem; color: rgb(21 128 61); }
#cite-dialog dl { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: .25rem .75rem; margin: 0;
    font-size: .875rem; }
#cite-dialog dt { color: rgb(75 85 99); }
#cite-dialog dd { margin: 0; overflow-wrap: anywhere; }
#cite-dialog dd a { color: #1d4ed8; text-decoration: underline; }
#cite-dialog :focus-visible { outline: 2px solid rgb(131 11 12); outline-offset: 2px; }
#cite-dialog .cite-head :focus-visible { outline-color: #fff; }
@media (pointer: coarse) {
    #cite-dialog .cite-actions button { min-height: 2.75rem; }
    #cite-dialog .cite-head button { min-width: 2.75rem; min-height: 2.75rem; display: inline-flex; align-items: center;
        justify-content: center; }
}
