/*
 * Denso plugin - styles ResourceSpace loads on every page while the plugin is active.
 */

/*
 * The search bar filters by year only (DENSO-1583). Core has no switch for the month on its own -
 * $simple_search_date takes the year with it - so the select is hidden rather than removed. It
 * stays in the form with its empty value, which the search reads as "any month".
 */
#basicmonth {
    display: none;
}

/*
 * Result cards show the whole title (DENSO-1583), and some titles are a filename with no space to
 * break at - "SDS_252-8392-G_ND-OIL-11_CZ_cs_1.4_18.06.2025_8392.pdf" - which would run out of the
 * card. Such a title breaks wherever it has to; one with spaces still breaks between words.
 * Since ResourceSpace 11.0 core keeps a card's title on one line and ends it with an ellipsis, so
 * the wrapping has to be switched back on here.
 */
.resource-card-title {
    max-width: 100%;
    white-space: normal;
    overflow-wrap: anywhere;
}

/*
 * The file's Information value - Bulletin, Leaflet, Safety Data Sheets - as a pill under the title.
 * The plugin adds the field to the card (denso_show_information_on_results()), and core marks it
 * with a class carrying the field's ref, which differs between environments. The title is the only
 * other field on a card and has the -title class instead, so this matches Information alone.
 */
.resource-card-content-top .resource-card-field {
    display: inline-block;
    max-width: 100%;
    padding: var(--space-4) var(--space-8);
    border-radius: var(--space-16);
    background: var(--colour-surface-200);
    color: var(--colour-typography-700);
    font-size: 12px;
    line-height: 120%;
    white-space: normal;
    overflow-wrap: anywhere;
}

/* Core renders the element for a file with no value too, empty but for whitespace, so :empty
   does not match it; its title attribute carries the value and is empty with it. */
.resource-card-content-top .resource-card-field[title=""] {
    display: none;
}

/*
 * The state of a file. Nearly every file is active, so saying so on every card is noise; any other
 * state - deleted, archived, pending - is worth seeing, but should not compete with the title.
 */
.resource-card-status.active {
    display: none;
}

.resource-card-pill.resource-card-status {
    padding: 2px var(--space-6);
    font-size: 11px;
    color: var(--colour-typography-600);
    background: var(--colour-surface-200);
}

/*
 * List view on a phone (DRS-3, T9). Core gives every metadata column word-break: break-word, which
 * lets a cell shrink to a single character, so the table always squeezes into the screen and titles
 * wrap a few letters per line. Here the title keeps a readable width and wraps between words, the
 * short columns stay on one line, and the table grows wider than the screen - .Listview scrolls it
 * sideways. overflow-wrap: break-word (not anywhere) still breaks a filename with no spaces, without
 * letting the cell shrink below its min-width.
 */
@media (max-width: 768px) {
    .ListviewStyle td.ListSearch {
        word-break: normal;
        overflow-wrap: break-word;
    }

    .ListviewStyle th,
    .ListviewStyle td:not(:has(.ListTitle)) {
        white-space: nowrap;
    }

    .ListviewStyle td.ListSearch:has(.ListTitle) {
        min-width: 15em;
    }
}

/*
 * The pager above search results (DRS-3). Core floats the left blocks at 85% and pins the pager to
 * the right with position: absolute, so whenever the left blocks reach the right edge - a narrow
 * window, a long result count - "Page 1 of 209" is drawn on top of the view switcher. As flex items
 * the two share the row instead: the pager keeps the top right while the left blocks have room to
 * wrap, and moves to its own line when they do not.
 */
.SearchSticky .TopInpageNav {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    column-gap: var(--space-16);
}

.SearchSticky .TopInpageNavLeft {
    float: none;
    width: auto;
    flex: 1 1 20em;
    min-width: 0;
}

.SearchSticky .TopInpageNavRight {
    position: static;
    flex: 0 0 auto;
    margin-left: auto;
}

/* Core's float clearer would be a flex item too and add a gap of its own. */
.SearchSticky .TopInpageNav > .clearerleft {
    display: none;
}

/*
 * A select is as wide as its longest option, and the Actions menu has long ones, so on a phone its
 * block plus the 20px gap core puts after every block ran past the screen and the page scrolled
 * sideways. The blocks are capped at the room they have, and the select narrows with them.
 */
.SearchSticky .TopInpageNavLeft .InpageNavLeftBlock {
    max-width: calc(100% - 20px);
}

.SearchSticky .TopInpageNavLeft .InpageNavLeftBlock select {
    max-width: 100%;
    box-sizing: border-box;
}

/*
 * The list's box is a flex item of #CentralSpaceResources, and a flex item never gets narrower than
 * its content by default, so a table wider than the screen stretched the box and the whole page
 * scrolled sideways. Letting the box shrink keeps the table inside .Listview, which scrolls it.
 */
#CentralSpaceResources > .BasicsBox:has(> .Listview) {
    min-width: 0;
}
