/*
:filename: wexa_statics/css/extras/bibbook.css
:author: Brigitte Bigi
:contact: contact@sppas.org
:summary: style for a bibliography built from BibTeX data

A bibliography is a table that sorts and whose columns are shown or hidden, so
this stylesheet brings what it is built with. A page loads this one, and knows
nothing of the other two.

-------------------------------------------------------------------------

This file is part of Whakerexa: https://github.com/brigitte-bigi/Whakerexa

Copyright (C) 2023-2026 Brigitte Bigi, CNRS
Laboratoire Parole et Langage, Aix-en-Provence, France

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License
along with this program.  If not, see <https://www.gnu.org/licenses/>.

This banner notice must not be removed.

-------------------------------------------------------------------------

*/

@import url("sortatable.css");
@import url("../toggleselect.css");


/* ----------------------------------------------------------------------- */
/* Searching the bibliography                                              */
/* ----------------------------------------------------------------------- */

/* The field takes the room the line leaves it, and never less than what it
   says it is for: a field whose own placeholder is cut short is a field that
   asks for a word without saying which. The longest of the two languages the
   bibliography is written in sets the width, frame included. */
/* It stops growing at twice what it asks for: past that width a search field
   holds nothing more than it held, and what is next to it would be pushed to
   the far edge of the screen, away from the table it acts upon. */
.bib-search-field {
    flex: 1 1 calc(var(--font-size) * 19);
    max-width: min(100%, calc(var(--font-size) * 38));
}


/* What changed is said, and only said: a reader who sees the table sees the
   rows go, and B20 answers WCAG 4.1.3, which is about what is not seen. The
   region stays in the page and in the accessibility tree; it takes no room and
   draws nothing. */
.bib-announcement {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    border: 0;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}


/* ----------------------------------------------------------------------- */
/* The table                                                               */
/* ----------------------------------------------------------------------- */

/* The number, the year and the type are read as columns, and never wrap.
   Only the cells: the year is also written in the reference itself. */
td.bib-number,
td.bib-year,
td.bib-type {
    width: 1%;
    white-space: nowrap;
    vertical-align: top;
}

td.bib-number {
    font-weight: var(--font-weight-semibold);
}

.bib-reference {
    vertical-align: top;
}

/* The stripes count the references, not the rows: a content that opens is a
   row too, and the colours would shift by one as soon as anything opened.
   Which rows to stripe is decided in the code, and a content takes the colour
   of the reference it belongs to. */
.bib-table tbody tr > td,
.bib-table tbody tr > td * {
    background-color: var(--table-cell-bg-color);
}

.bib-table tbody tr.bib-striped > td,
.bib-table tbody tr.bib-striped > td *:not(.bib-disclosure-control) {
    background-color: var(--table-row-stripped-bg-color);
}

/* A content takes a row of its own, across the whole table. The bar on its
   left is what ties it to the reference above it. */
.bib-opened-row > td {
    border-top: none;
    border-left: calc(3 * var(--border-width-alt)) solid var(--border-color-alt);
}


/* ----------------------------------------------------------------------- */
/* One reference                                                           */
/* ----------------------------------------------------------------------- */

/* A reference is read in three lines: who wrote it, what it is called, and
   where it came out. Each line says which one it is, so that a stylesheet
   can lay them out otherwise: side by side, wrapped, or anything else. */
.bib-line {
    display: block;
}

.bib-title {
    font-weight: var(--font-weight-semibold);
}

/* Where the work was published is written in italics, as bibliographies do,
   and the work itself is not: that is what tells them apart at a glance. */
.bib-journal,
.bib-booktitle {
    font-style: italic;
}

/* A missing field is shown, and stays readable: it is written for whoever
   keeps the BibTeX data, not against the reader. */
.bib-missing {
    color: var(--error-color);
    font-style: italic;
    text-decoration: underline dotted;
}

/* Back to every place of the text where the reference is cited. They stand
   with the addresses, and are numbered in the order of the text: a reference
   cited three times has three of them. */
.bib-backlink {
    margin-right: calc(0.37 * var(--typography-spacing-horizontal));
}


/* ----------------------------------------------------------------------- */
/* What can be reached, and what can be opened                             */
/* ----------------------------------------------------------------------- */

/* What leads elsewhere and what acts here stand side by side, under the
   reference they belong to, and go to the next line when there is no room. */
.bib-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: calc(0.42 * var(--typography-spacing-vertical)) calc(0.62 * var(--typography-spacing-horizontal));
    margin-top: calc(0.25 * var(--typography-spacing-vertical));
    font-size: calc(var(--font-size) * 0.9);
}

/* An address is a link and nothing else: it takes the colors of a link, its
   hover and its focus, and carries the icon that says it leaves the document. */

/* The link says what it leads to; the address it holds waits for the paper. */
.bib-link-address {
    display: none;
}

/* A control acts here and now: it looks like a button, and never like a
   link. What tells them apart has to be seen without reading them.
   The selector reaches past the "td *" rule of wexa.css, which clears the
   background of everything a cell holds. */
.bib-table td .bib-disclosure-control {
    display: inline-flex;
    align-items: center;
    width: auto;
    margin: 0;
    padding: calc(var(--font-size) * 0.2) calc(var(--font-size) * 0.5);
    font-family: inherit;
    font-size: inherit;
    cursor: pointer;
    text-decoration: none;
    color: var(--buttons-fg-color);
    background-color: var(--buttons-bg-color);
    border: var(--border-width) solid var(--border-color);
    border-radius: var(--border-radius);
}

.bib-table td .bib-disclosure-control:hover,
.bib-table td .bib-disclosure-control:focus {
    background-color: var(--buttons-bg-color-hover);
}

/* The control says itself whether it is open: the mark follows what it says,
   and never the other way around. */
/* The mark is drawn, not written: no font of the project holds a chevron, and
   a borrowed glyph comes at the size and the weight of another font. */
.bib-disclosure-control::before {
    content: '';
    display: inline-block;
    vertical-align: middle;
    width: calc(var(--font-size) * 0.42);
    height: calc(var(--font-size) * 0.42);
    margin-right: calc(0.62 * var(--typography-spacing-horizontal));
    margin-left: calc(0.12 * var(--typography-spacing-horizontal));
    border-top: calc(var(--font-size) * 0.13) solid currentColor;
    border-right: calc(var(--font-size) * 0.13) solid currentColor;
    transform: rotate(45deg);
}

.bib-disclosure-control[aria-expanded='true']::before {
    transform: rotate(135deg);
}

/* A content that opens takes the whole width of the table: an abstract read
   in the width of a column is an abstract nobody reads. */
.bib-disclosure-content {
    padding: calc(var(--font-size) * 0.5);
    white-space: pre-wrap;
    font-size: calc(var(--font-size) * 0.9);
}

/* The BibTeX source is read as it was written, and copied as it stands. A
   fixed width font draws wider than the text around it, so it is written
   smaller and its letters are not spaced further apart. */
.bib-disclosure-source {
    font-family: var(--font-family-mono);
    font-size: calc(var(--font-size) * 0.8);
    letter-spacing: 0;
}


/* ----------------------------------------------------------------------- */
/* A citation, in the middle of a sentence                                 */
/* ----------------------------------------------------------------------- */

/* The number is a button, and looks like the sentence it sits in: framing it
   would break the line a reader is following. So it is a fragment of text and
   not a box: wexa.css lays a button out as a flex box that holds a height of
   its own, and such a box takes its baseline from the first thing it holds,
   the mark, instead of from its own number, which then sits under the line. */
.bib-citation-control {
    display: inline;
    min-width: 0;
    min-height: 0;
    overflow: visible;
    vertical-align: baseline;
    padding: 0 calc(var(--font-size) * 0.2);
    font-family: inherit;
    font-size: inherit;
    cursor: pointer;
    color: var(--a-color);
    background: none;
    border: none;
    border-radius: 0;
}

/* The number leads to the bibliography on paper, where nothing opens. */
.bib-citation-anchor {
    display: none;
}

/* What a citation opens stands in the paragraph, and is set apart by a bar
   on its left rather than by a frame that would cut the text. */
.bib-citation-content:not([hidden]) {
    display: block;
    margin: calc(0.42 * var(--typography-spacing-vertical)) 0;
    padding: calc(var(--font-size) * 0.5);
    border-left: calc(3 * var(--border-width-alt)) solid var(--border-color-alt);
    font-size: calc(var(--font-size) * 0.9);
}

.bib-citation-link,
.bib-citation-content .bib-link,
.bib-citation-part {
    display: block;
    margin-top: calc(0.25 * var(--typography-spacing-vertical));
}

.bib-citation-part > b {
    margin-right: calc(0.62 * var(--typography-spacing-horizontal));
}


/* ----------------------------------------------------------------------- */
/* In a slide                                                              */
/* ----------------------------------------------------------------------- */

/* Everything above is written for a page, where a bibliography has all the
   room it needs. A slide has one screen, and shows it to an audience: the
   sizes are given again, and nothing is left to inheritance, because wexa.css
   gives an absolute font-size to every element and its cells carry one of
   their own. */

/* A bibliography laid on several slides holds its columns to the widths they
   were drawn with. Capped at a share of the slide, they would all be given a
   share of what is left, and the narrowest one loses the most: a heading then
   reads without its first letter. */
.slide .bib-table {
    max-width: none;
    margin-top: calc(0.42 * var(--typography-spacing-vertical));
}

.slide .bib-table td,
.slide .bib-table th {
    font-size: calc(var(--font-size) * 0.55);
    padding: calc(var(--font-size) * 0.15) calc(var(--font-size) * 0.3);
}

.slide .bib-table td *,
.slide .bib-table th * {
    font-size: inherit;
}

.slide .bib-actions {
    font-size: calc(var(--font-size) * 0.5);
    margin-top: calc(0.08 * var(--typography-spacing-vertical));
    gap: calc(0.25 * var(--typography-spacing-vertical)) calc(0.37 * var(--typography-spacing-horizontal));
}

.slide .bib-announcement {
    font-size: calc(var(--font-size) * 0.5);
    margin-bottom: calc(0.25 * var(--typography-spacing-vertical));
}

/* A button is at least a character and a half tall, and three characters
   wide, counted on the font size of the document. In a slide, that is far
   more than the reference it stands under: it is counted on the cell. */
.slide .bib-table td .bib-disclosure-control {
    min-height: 0;
    min-width: 0;
    padding: calc(var(--font-size) * 0.1) calc(var(--font-size) * 0.2);
}

/* The icon that says a link leaves the document is drawn from the font size
   of the document, not from the one of the cell it stands in. In a slide, it
   follows the reference it belongs to. */
.slide .bib-table a.external-link::after {
    width: calc(var(--font-size) * 0.45);
    height: calc(var(--font-size) * 0.45);
    padding-top: 0;
    margin-left: calc(0.19 * var(--typography-spacing-horizontal));
    margin-right: calc(0.19 * var(--typography-spacing-horizontal));
}

/* A sort button is drawn in rem by sortatable.css: its padding and its mark
   are as tall in a slide as in a page. Here they follow the head they are in. */
.slide .bib-table .sortatable {
    padding: calc(var(--font-size) * 0.15);
    min-height: 0;
}


.slide .bib-table .sortatable::after {
    width: calc(var(--font-size) * 0.35);
    height: calc(var(--font-size) * 0.25);
    margin-left: calc(0.37 * var(--typography-spacing-horizontal));
}

.slide .bib-table .sortatable:not(.sort-asc):not(.sort-desc)::after {
    width: calc(var(--font-size) * 0.35);
    height: 0;
    border-top-width: calc(var(--font-size) * 0.05);
}

.slide .bib-table .sort-asc::after {
    border-width: 0 calc(var(--font-size) * 0.2) calc(var(--font-size) * 0.2) calc(var(--font-size) * 0.2);
}

.slide .bib-table .sort-desc::after {
    border-width: calc(var(--font-size) * 0.2) calc(var(--font-size) * 0.2) 0 calc(var(--font-size) * 0.2);
}

/* An audience reads what is on the screen and acts on nothing: what acts upon
   the bibliography goes, the search field as the column selector. What is read
   on its own stays, the sorting of a column being written as well as done. B26 */
.slide .bib-controls {
    display: none;
}

/* The number is written twice, once as what opens the reference and once as
   the link that stays on paper. The link is hidden on screen, and slides.css
   gives every link of a slide a display of its own, which shows it again. It
   is hidden here, where the rule is read after that one. */
.slide .bib-citation-anchor {
    display: none;
}

/* REQUIREMENT NOT SATISFIED, AND THE BUG IS NOT FOUND. Following a renvoi in a
   presentation lays the slides over one another and leaves them half drawn.
   The support reached is the right one, the reading stands at it, and nothing
   inside it is touched; what undoes the rendering has not been found, in either
   direction. So what leads from a citation to its reference, and from a
   reference to the places it is cited at, is not shown to an audience: C26 and
   C27 hold on a page and on paper, and not here. What is written stays written,
   and showing these links again is all it takes to try again. */
.slide .bib-citation-link,
.slide .bib-backlink {
    display: none;
}


/* ----------------------------------------------------------------------- */
/* On paper                                                                */
/* ----------------------------------------------------------------------- */

@media print {

    /* What only makes sense on a screen does not print. The year has its own
       column to be sorted on, and sorting is over: it is written in the
       reference itself. */
    .bib-controls,
    .bib-announcement,
    .bib-opened-row,
    .bib-citation-content:not([hidden]),
    .bib-backlink,
    td.bib-year {
        display: none;
    }

    /* The selector reaches past the one that gives these controls their frame
       on screen: what opens on demand cannot be opened on paper. */
    .bib-table td .bib-disclosure-control {
        display: none;
    }

    /* On paper an address is read, not clicked: it is written where it
       stands, and nothing frames it. */
    .bib-actions {
        display: block;
        margin-top: 0;
    }

    .bib-link {
        text-decoration: none;
    }

    /* The number of a citation stays on paper: it is what the bibliography is
       read with. It becomes the link it always was, which a PDF keeps
       clickable, and the button that opens nothing goes away. */
    .bib-citation-control {
        display: none;
    }

    .bib-citation-anchor {
        display: inline;
        color: var(--a-color);
    }

    .bib-disclosure-control::before {
        content: none;
    }

    /* On paper the address takes the place of what the link leads to: it is
       what a reader can copy, and the link is still one in a PDF. */
    .bib-link-label {
        display: none;
    }

    /* One address per line: two of them side by side read as one. A fixed
       width font spaces its letters more than the text around it, so the
       address is written tighter. */
    .bib-link {
        display: block;
        margin-bottom: calc(0.25 * var(--typography-spacing-vertical));
    }

    .bib-link-address {
        display: inline;
        font-family: var(--font-family-mono);
        font-size: calc(var(--font-size) * 0.9);
        letter-spacing: 0;
        word-break: break-all;
    }

    /* On paper a bibliography is a list, not a table: nothing of the table
       itself is seen. Backgrounds are ink spent on saying what the page
       already says, and rules around each reference say it twice. */
    .bib-table tbody tr > td,
    .bib-table tbody tr > td *,
    .bib-table tbody tr.bib-striped > td,
    .bib-table tbody tr.bib-striped > td *:not(.bib-disclosure-control) {
        background-color: transparent;
    }

    .bib-table,
    .bib-table td,
    .bib-table th {
        border: none;
    }

    /* A bibliography of a hundred references runs over several pages: the
       table has to break, which print.css forbids of every table. */
    .bib-table {
        page-break-inside: auto;
        break-inside: auto;
    }

    /* No headers on paper: what they name is sorting, and there is none. */
    .bib-table thead {
        display: none;
    }

    /* A reference is never cut across two pages. */
    .bib-table tbody tr {
        page-break-inside: avoid;
        break-inside: avoid;
    }
}

/* The search field and the column selector share a line, and the second goes
   under the first when the width no longer holds both.

   The line is not halved: a half is a width nobody asked for, and the selector
   held in one of them puts its own text under its own box as soon as the words
   are those of another language. Each takes what it is written for — the
   selector what it holds, the field the rest down to the twelve fonts it asks
   for — and the panel wraps when the two no longer fit. Both come from the
   framework, `.wrap-item` for the one and `.bib-search-field` for the other,
   so nothing is written here. */
.bib-controls {
    align-items: center;
    margin-bottom: calc(0.83 * var(--typography-spacing-vertical));
}


/* What belongs together stands closer: the button that applies is part of the
   selector, where the selector and the search field are two halves of a line. */
.bib-columns {
    display: flex;
    align-items: center;
    gap: calc(var(--wrap-panel-gap) / 2);
}

/* The list of columns takes the half it was given, and the button that applies
   it keeps the width of the mark it carries. */
.bib-columns > details {
    flex: 1 1 0;
}

.bib-columns > button {
    flex: none;
}

/* The mark is drawn at the size of the icons of the framework: an svg carrying
   no size of its own is laid out at the size of an image, which no line holds. */
.bib-columns > button svg {
    display: block;
    width: calc(var(--font-size) * 1.4);
    height: calc(var(--font-size) * 1.4);
}
