/* ==========================================================================
   Responsive layer.

   Loaded last, after structure.css and custom-sitmp.css. The desktop canvas
   (>= 1200px) is deliberately left untouched - everything here only collapses
   the float based layout on narrower viewports.

   Breakpoints: 1200 / 992 / 768 / 576 px.
   ========================================================================== */

/* the drawer styles below set display on lists, which would otherwise beat the
   browser default for [hidden] and leave collapsed submenus open */
[hidden] {
    display: none !important;
}

/* --- skip link ------------------------------------------------------------ */

A.skipLink {
    position: absolute;
    top: 0;
    left: 0;
    z-index: 1100;
    padding: 12px 20px;
    font-family: 'Roboto Condensed Regular';
    font-size: 16px;
    line-height: 20px;
    text-decoration: none;
    background-color: var(--c-white);
    color: var(--c-blue-dark);
    transform: translateY(-120%);
}
A.skipLink:focus {
    transform: translateY(0px);
}
MAIN:focus {
    outline: none;
}

/* --- off-canvas menu ------------------------------------------------------ */

/* the two bar buttons only exist below the breakpoint */
DIV.barControls {
    display: none;
}
BUTTON.barToggle {
    display: inline-block;
    width: 44px;
    height: 44px;
    margin: 0 0 0 8px;
    padding: 0;
    font-size: 20px;
    line-height: 44px;
    background: none;
    background-color: var(--c-white);
    border: 1px solid var(--c-border-control);
    color: var(--c-blue);
    cursor: pointer;
}
BUTTON.barToggle[aria-expanded="true"] {
    background-color: var(--c-blue);
    color: var(--c-white);
}
DIV.mobileMenu {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: 1060;
    box-sizing: border-box;
    width: min(320px, 85vw);
    padding: 0 16px 24px;
    overflow-y: auto;
    text-align: left;
    background-color: var(--c-white);
    transition: transform 0.2s ease-out;
    transform: translateX(100%);
}
DIV.mobileMenu.is-open {
    transform: translateX(0px);
}
DIV.mobileMenu__overlay {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 1050;
    background-color: rgba(0, 0, 0, 0.5);
    opacity: 0;
    transition: opacity 0.2s ease-out;
}
DIV.mobileMenu__overlay.is-open {
    opacity: 1;
}
/* sticky alone is not enough: the items below are positioned too and would
   paint over the heading, and the background has to span the drawer padding */
DIV.mobileMenu__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 2;
    margin: 0 -16px;
    padding: 12px 16px;
    background-color: var(--c-white);
    border-bottom: 1px solid var(--c-border-control);
}
SPAN.mobileMenu__title {
    font-family: 'Roboto Condensed Regular';
    font-size: 20px;
    line-height: 24px;
    text-transform: uppercase;
    color: var(--c-blue-dark);
}
BUTTON.mobileMenu__close {
    width: 44px;
    height: 44px;
    padding: 0;
    font-size: 20px;
    background: none;
    border: 0;
    color: var(--c-blue-dark);
    cursor: pointer;
}
BODY.is-menuOpen {
    overflow: hidden;
}

/* Items relocated into the drawer lose the styling that was scoped to their
   original parents, so the drawer restyles them from scratch. */
DIV.mobileMenu__body {
    font-size: 16px;
    line-height: 20px;
}
DIV.mobileMenu__body UL {
    display: block;
    margin: 0;
    padding: 0;
    list-style: none;
}
DIV.mobileMenu__body LI {
    display: block;
    margin: 0;
}
DIV.mobileMenu__body NAV#mainMenu UL LI A {
    display: block;
    float: none;
    width: auto;
    margin: 0;
    padding: 12px 8px;
    font-family: 'Roboto Condensed Regular';
    font-size: 1.25em;
    line-height: 1.2;
    text-align: left;
    text-decoration: none;
    background: none;
    border: 0;
    border-bottom: 1px solid var(--c-blue-light);
    color: var(--c-blue-dark);
}
/* the child combinator keeps the highlight on the active row itself,
   a descendant selector would paint its whole open submenu */
DIV.mobileMenu__body NAV#mainMenu LI.active > A,
DIV.mobileMenu__body NAV#mainMenu LI A:hover {
    background-color: var(--c-blue-light);
}
/* nested levels: the toggle sits in a contrasting square at the row's end */
DIV.mobileMenu__body NAV#mainMenu LI {
    position: relative;
}
DIV.mobileMenu__body NAV#mainMenu LI.hasSubmenu > A {
    padding-right: 52px;
}
BUTTON.mobileMenu__sub {
    position: absolute;
    top: 0;
    right: 0;
    box-sizing: border-box;
    width: 44px;
    height: 44px;
    padding: 0;
    font-size: 14px;
    line-height: 44px;
    background: none;
    background-color: white;
    border: none;
    border-left: 1px solid var(--c-blue-light);
    border-right: 1px solid var(--c-blue-light);
    color: var(--c-blue-dark);
    cursor: pointer;
}
BUTTON.mobileMenu__sub:hover,
BUTTON.mobileMenu__sub[aria-expanded="true"] {
    background-color: var(--c-blue-pale);
}
DIV.mobileMenu__body NAV#mainMenu UL UL {
    margin-left: 12px;
    border-left: 2px solid var(--c-blue-light);
}
DIV.mobileMenu__body NAV#mainMenu UL UL LI A {
    padding-left: 12px;
    font-family: 'Roboto Regular';
    font-size: 1.1em;
    line-height: 1.3;
}
DIV.mobileMenu__body NAV#mainMenu UL UL UL LI A {
    font-size: 1.05em;
}

/* the home item is icon only in the bar, in the drawer it gets its label */
DIV.mobileMenu__body NAV#mainMenu UL LI:first-child A SPAN {
    position: static;
    width: auto;
    height: auto;
    margin: 0 0 0 10px;
    overflow: visible;
    clip: auto;
    white-space: normal;
}
DIV.mobileMenu__body DIV.lowerPart,
DIV.mobileMenu__body DIV.lowerPart DIV.leftCol,
DIV.mobileMenu__body DIV.lowerPart DIV.rightCol {
    display: block;
    float: none;
    width: auto;
    margin: 0;
    padding: 0;
}
DIV.mobileMenu__body DIV.lowerPart {
    padding-top: 16px;
}
DIV.mobileMenu__body UL.buttons LI A {
    display: block;
    float: none;
    width: auto;
    margin: 0 0 8px;
    padding: 12px 16px;
    font-family: 'Roboto Condensed Regular';
    font-size: 1.1em;
    line-height: 1.25;
    text-align: left;
    text-decoration: none;
    background-color: var(--c-white);
    border: 1px solid var(--c-border-control);
    color: var(--c-blue);
}
DIV.mobileMenu__body UL.buttons LI.firstVisit A {
    background-color: var(--c-blue-light);
    color: var(--c-blue-dark);
}
DIV.mobileMenu__body UL.buttons LI.myAccount A {
    background-color: var(--c-blue);
    border-color: var(--c-blue);
    color: var(--c-white);
}
DIV.mobileMenu__body UL.buttons LI A .icon {
    margin-right: 10px;
}DIV.mobileMenu__body DIV.fontSizeChange UL {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin-top: 6px;
}
DIV.mobileMenu__body DIV.fontSizeChange SPAN {
    display: block;
    margin: 0;
    font-family: 'Roboto Condensed Regular';
    font-size: 16px;
    line-height: 20px;
    color: var(--c-blue-dark);
}
DIV.mobileMenu__body DIV.fontSizeChange BUTTON {
    margin: 0;
    padding: 6px 10px;
    background: none;
    border: 1px solid var(--c-border-control);
    color: var(--c-blue-dark);
    cursor: pointer;
}
DIV.mobileMenu__body DIV.fontSizeChange BUTTON.medium {
    font-size: 16px;
}
DIV.mobileMenu__body DIV.fontSizeChange BUTTON.big {
    font-size: 20px;
}
DIV.mobileMenu__body DIV.fontSizeChange BUTTON[aria-pressed="true"] {
    background-color: var(--c-blue-light);
}

/* --- breadcrumbs ---------------------------------------------------------- */
/* only shown where the menu bar is replaced by the drawer, see below */
.breadcrumbBar {
    display: none;
}

/* --- shared: media and CMS tables ---------------------------------------- */

/* Wrapper injected by responsive.js around tables in editorial content.
   Keyboard users reach the scroll area through the tabindex it adds. */
DIV.tableScroll {
    margin-bottom: 46px;
    overflow-x: auto;
}
DIV.tableScroll TABLE {
    margin-bottom: 0;
}

/* Tables inside the narrow side column wrap instead of scrolling - a 270px
   box is too cramped for horizontal scrolling to be usable. */
DIV.sideBox TABLE,
DIV.sideBox TABLE TBODY,
DIV.sideBox TABLE TR {
    width: 100%;
}
DIV.sideBox TABLE TD {
    white-space: normal;
}

/* --- below the fixed 1170px canvas --------------------------------------- */
@media (max-width: 1199px) {
    .contentContainer DIV.content {
        box-sizing: border-box;
        width: auto;
        padding-left: var(--layout-gutter);
        padding-right: var(--layout-gutter);
    }
    .header DIV.leftCol {
        width: 57%;
    }
    .header DIV.rightCol {
        width: 36%;
    }
    /* fixed pixel buttons become a wrapping row */
    .header UL.buttons {
        display: flex;
        flex-wrap: wrap;
        gap: 10px;
    }
    .header UL.buttons LI,
    .header UL.buttons LI.last,
    .header UL.buttons LI.myAccount {
        display: block;
        float: none;
    }
    .header UL.buttons LI A,
    .header UL.buttons LI.last A,
    .header UL.buttons LI.firstVisit A,
    .header UL.buttons LI.myAccount A {
        float: none;
        width: auto;
        margin: 0;
        padding-left: 16px;
        padding-right: 16px;
    }

    .mainContent DIV.contentArea {
        width: calc(100% - 300px);
    }
    /* an empty container, so its border reads as a separator line and needs
       room around it */
    DIV.newBooks {
        width: auto;
        margin-top: 25px;
        margin-bottom: 25px;
    }
    .banners DIV.content {
        gap: 20px 30px;
    }

    /* --- drawer mode: the bar holds the logo and the two buttons only ------ */
    /* the lower part moves into the drawer, so the bar needs its own bottom
       padding, otherwise the buttons sit on the edge of the header band */
    .has-drawer .header DIV.upperPart {
        margin-bottom: 0;
        padding-top: 16px;
        padding-bottom: 16px;
    }
    .has-drawer .header DIV.upperPart DIV.leftCol {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        justify-content: space-between;
        float: none;
        width: auto;
    }
    .has-drawer .header A.logo {
        float: none;
        margin-bottom: 0;
    }
    /* no width:auto here - the SVG has no intrinsic size, so the width
       attribute has to keep doing the sizing */
    .has-drawer .header A.logo IMG {
        max-width: 200px;
        height: auto;
    }
    .has-drawer DIV.barControls {
        display: flex;
    }
    .has-drawer .header DIV.searchForm {
        display: none;
        order: 3;
        flex-basis: 100%;
        box-sizing: border-box;
        float: none;
        width: 100%;
        max-width: none;
        margin-top: 15px;
    }
    .has-drawer .header DIV.searchForm.is-open {
        display: block;
    }
    /* the main menu lives in the drawer, the blue bar would stay empty */
    .has-drawer .contentContainer.menu {
        display: none;
    }
    /* the drawer carries the whole tree, so the side section menu would only
       repeat it. Without the drawer (no JS) it stays, it is the only sub level
       navigation then. */
    .has-drawer DIV.submenu {
        display: none;
    }

    /* the home link and the section context live in the menu bar, which the
       drawer replaces - the trail brings both back. Without the drawer the bar
       is still there, so the trail stays hidden. */
    .has-drawer .breadcrumbBar {
        display: block;
        padding: 10px 0;
        border-bottom: 1px solid var(--c-border);
    }
    .breadcrumbs__list {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        gap: 4px 6px;
        margin: 0;
        padding: 0;
        list-style: none;
        font-size: 0.95em;
        line-height: 1.3;
    }
    .breadcrumbs__item {
        display: flex;
        align-items: center;
        gap: 6px;
        margin: 0;
        padding: 0;
        color: var(--c-text-muted);
    }
    /* the separator repeats the arrow the side menu uses, as a mask so it
       takes the text colour and is never read out */
    .breadcrumbs__item + .breadcrumbs__item::before {
        content: "";
        flex: none;
        width: 0.5em;
        height: 0.6em;
        background-color: currentColor;
        -webkit-mask: url('/img/knihovnamp/submenu_li.svg') no-repeat center / contain;
        mask: url('/img/knihovnamp/submenu_li.svg') no-repeat center / contain;
    }
    .breadcrumbs__item A {
        display: flex;
        align-items: center;
        /* 24px minimum target size, the row keeps its compact height */
        min-height: 24px;
        color: var(--c-blue);
    }
    .breadcrumbs__item--home A {
        justify-content: center;
        min-width: 24px;
        font-size: 1.1em;
    }
    .breadcrumbs__item--current {
        font-family: 'Roboto Medium';
    }

    /* the three footer columns no longer fit side by side: contacts and links
       share the first row, find-us-on spans the one below */
    DIV.footerNavigation DIV.content {
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    }
    DIV.footerNavigation .links {
        padding-right: 0;
        border-right: 0;
    }
    DIV.footerNavigation .socialMedia {
        grid-column: 1 / -1;
        margin-top: 10px;
        padding-top: 20px;
        padding-left: 0;
        border-top: 1px solid var(--c-blue-rule);
    }

    /* bottom bar: one centred line per block */
    DIV.footer DIV.content {
        flex-direction: column;
        align-items: center;
    }
    DIV.footer DIV.copyright,
    DIV.footer DIV.pristupnost,
    DIV.footer DIV.design {
        text-align: center;
    }
}

/* --- tablet and below: single column -------------------------------------- */
@media (max-width: 991px) {
    .header DIV.upperPart {
        margin-bottom: 20px;
        padding-top: 20px;
    }
    .header DIV.lowerPart {
        padding-bottom: 20px;
    }
    /* display:block matters as much as float:none here - the desktop rules
       set display:inline, and an inline box drops vertical margins */
    .header DIV.leftCol,
    .header DIV.rightCol {
        display: block;
        float: none;
        width: auto;
    }    .header A.logo {
        display: block;
        margin-bottom: 15px;
    }    .header DIV.fontSizeChange {
        display: block;
        margin-top: 15px;
        text-align: left;
    }

    /* the two button lists stack, so the second one needs the row gap the
       flex gap only provides inside a single list */
    .header DIV.lowerPart DIV.rightCol {
        margin-top: 10px;
    }

    /* provisional: horizontal menu wraps until the off-canvas drawer lands */
    DIV.menu UL {
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
    }
    DIV.menu UL LI {
        display: block;
    }
    DIV.menu UL LI A,
    DIV.menu UL LI:first-child A {
        float: none;
        margin-left: 0;
        padding: 10px 12px;
        font-size: 18px;
        line-height: 22px;
    }

    .mainContent {
        padding-top: 25px;
        padding-bottom: 30px;
    }
    .mainContent DIV.contentArea,
    .mainContent DIV.sideColumn,
    .mainContent.homepage DIV.contentArea,
    .mainContent.homepage DIV.sideColumn {
        float: none;
        width: auto;
    }
    /* display:contents lifts the side widgets into the page grid, so the
       opening hours boxes can be ordered above the article content */
    .mainContent DIV.content {
        display: grid;
        grid-template-columns: minmax(0, 1fr);
        align-items: start;
        gap: 20px;
    }
    .mainContent DIV.sideColumn {
        display: contents;
    }
    .mainContent DIV.content > DIV.clearfix {
        display: none;
    }
    /* catalogue and opening hours lead the page, the Ukrainian block and the
       calendar follow the content, the city logo closes the page */
    .mainContent DIV.sideBox {
        order: 1;
    }
    .mainContent DIV.contentArea {
        order: 2;
    }
    .mainContent DIV.sideBox--ukrajina,
    .mainContent DIV.calendarBox {
        order: 3;
    }
    .mainContent DIV.newBooks {
        order: 4;
    }
    /* the city logo stays at the very bottom, centred on the page axis */
    .mainContent DIV.sideColumn > A.cityLogo {
        order: 5;
        justify-self: center;
    }
    .mainContent DIV.content > * {
        margin-bottom: 0;
    }

    /* side column widgets were pinned to 267-270px */
    DIV.sideBox,
    DIV.submenu,
    DIV.calendarBox,
    #jqueryCalendar,
    #jqueryCalendar DIV.ui-datepicker,
    #jqueryCalendar TABLE.ui-datepicker-calendar {
        box-sizing: border-box;
        width: 100%;
        margin-left: 0;
        margin-right: 0;
    }
    /* the wrapper has to keep overlapping the box border, otherwise the frame
       shows around the folded corner graphic */
    DIV.sideBox DIV.backgroundWrapper {
        box-sizing: border-box;
        width: calc(100% + 2px);
        margin: -1px;
    }

}

/* --- tablets: two widgets fit next to each other --------------------------- */
@media (min-width: 576px) and (max-width: 991px) {
    .mainContent DIV.content {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    /* subpages open with a single widget, so the calendar takes the empty cell
       next to it instead of trailing the content; the homepage already fills
       that row with the catalogue and the opening hours */
    .mainContent:not(.homepage) DIV.calendarBox {
        order: 1;
    }
    .mainContent DIV.contentArea,
    .mainContent DIV.newBooks,
    .mainContent DIV.sideColumn > A.cityLogo {
        grid-column: 1 / -1;
    }
}

/* --- phones --------------------------------------------------------------- */
@media (max-width: 767px) {
    /* the icon and the generous type do not fit next to a full width form */
    .newsletterBar P {
        padding-left: 0;
        font-size: 22px;
        line-height: 26px;
        background-image: none;
    }
    FORM.newsletterForm {
        flex: 1 1 100%;
    }
    /* editorial tables: 40px side padding alone forced a scrollbar */
    TABLE TD,
    TABLE TH {
        padding-left: 12px;
        padding-right: 12px;
    }
    TABLE TD.first,
    TABLE TH.first {
        padding-left: 12px;
    }
    DIV.sideBox TABLE TD {
        padding-left: 0;
        padding-right: 8px;
    }

    /* single column, the vertical rules become horizontal ones */
    DIV.footerNavigation DIV.content {
        grid-template-columns: minmax(0, 1fr);
    }
    DIV.footerNavigation .contacts,
    DIV.footerNavigation .links,
    DIV.footerNavigation .socialMedia {
        min-width: 0;
    }
    DIV.footerNavigation .links {
        padding-top: 20px;
        padding-bottom: 20px;
        padding-left: 0;
        border-left: 0;
        border-top: 1px solid var(--c-blue-rule);
        border-bottom: 1px solid var(--c-blue-rule);
    }
    DIV.footerNavigation .socialMedia {
        margin-top: 0;
        border-top: 0;
    }
    UL.gallery {
        grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
        gap: 12px;
    }
}

@media (max-width: 575px) {
    DIV.footerNavigation .links,
    DIV.footerNavigation .socialMedia {
        grid-template-columns: minmax(0, 1fr);
    }
    /* the three column listing becomes one card per event */
    TABLE.fulltbl,
    TABLE.fulltbl TBODY,
    TABLE.fulltbl TR,
    TABLE.fulltbl TD {
        display: block;
        width: auto;
    }
    /* the table background would show through between the cards */
    TABLE.fulltbl {
        background: none;
    }
    TABLE.fulltbl THEAD {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip: rect(0, 0, 0, 0);
    }
    TABLE.fulltbl TR {
        margin-bottom: 12px;
        padding: 8px 12px;
        background-color: var(--c-white);
        border: 1px solid var(--c-border);
    }
    TABLE.fulltbl TD {
        padding: 4px 0;
    }
    TABLE.fulltbl TD::before {
        content: attr(data-label) ": ";
        font-family: 'Roboto Medium';
    }
    .news {
        flex-direction: column;
        gap: 10px;
    }
    .news__image {
        margin-top: 0;
    }
    DIV.print {
        display: block;
        margin-right: 0;
        margin-bottom: 10px;
    }
}

/* --- motion ---------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* --- print ---------------------------------------------------------------- */

@media print {
    /* navigation, widgets and controls carry no meaning on paper, and the side
       column stretched the calendar across the whole page */
    .header,
    .contentContainer.menu,
    DIV.mobileMenu,
    DIV.mobileMenu__overlay,
    .banners,
    DIV.footerNavigation,
    DIV.sideColumn,
    DIV.submenu,
    DIV.newBooks,
    DIV.searchForm,
    DIV.filtrakci FORM,
    .paging,
    A.skipLink,
    BUTTON.printPage,
    #return-to-top {
        display: none !important;
    }

    BODY {
        font-size: 11pt;
        line-height: 1.4;
        background: none;
        color: #000;
    }
    .contentContainer,
    .contentContainer DIV.content,
    .mainContent,
    .mainContent DIV.contentArea {
        display: block;
        box-sizing: border-box;
        float: none;
        width: auto;
        max-width: none;
        margin: 0;
        padding: 0;
    }
    .mainContent {
        padding-bottom: 12pt;
    }
    H1,
    H2,
    H3 {
        color: #000;
        page-break-after: avoid;
    }
    IMG {
        max-width: 100% !important;
        page-break-inside: avoid;
    }
    A {
        color: #000;
        text-decoration: underline;
    }
    /* the target of a link is lost on paper */
    DIV.contentArea A[href^="http"]::after {
        content: " (" attr(href) ")";
        font-size: 0.85em;
        word-break: break-all;
    }
    DIV.footer {
        padding-top: 8pt;
        border-top: 1px solid #000;
    }
}
