/*
    Layout and accessibility fixes on top of Global.css. This file is linked after the
    ~/Content/css bundle in _CustomerLayout and _varioOnlineLayout, so equal selectors win
    here. Each block names the problem it solves; remove a block to get the old behaviour.
*/

/* --- 1. Fluid width between 1281 and 1512px ------------------------------------------
   Header, container and #placeHolder had a fixed width of 1512px and only switched to 100%
   below 1281px. On 1366 or 1440px wide screens the page scrolled sideways and "Abmelden"
   and the "Bearbeiten" links were outside the window. */
@media only screen and (min-width: 1281px) {
    html body .containerSize,
    html body .headerHight,
    html body #placeHolder,
    html body .container,
    html body .containerMiddle,
    html body .footer-container,
    html body .footer-container-loginPage,
    html body .divFooter {
        width: 100% !important;
        max-width: 1512px;
        box-sizing: border-box;
    }

    html body #menuGroupId {
        flex: 0 0 26%;
        width: 26%;
        max-width: 398px;
    }

    html body .subMenu-item,
    html body .subMenu-item_Selected {
        width: auto;
    }

    html body .containersidePnannel {
        width: auto;
        flex: 1 1 0;
        min-width: 0; /* lets wide tables scroll inside instead of widening the page */
    }
}

/* --- 2. Visible keyboard focus (WCAG 2.4.7) --------------------------------------------
   Global.css removes the outline of every focused link, button and field. :focus-visible
   shows a ring for keyboard users only, mouse clicks keep the old look. */
html body a:focus-visible,
html body button:focus-visible,
html body input:focus-visible,
html body select:focus-visible,
html body textarea:focus-visible,
html body summary:focus-visible,
html body [tabindex]:focus-visible,
html body [role="button"]:focus-visible,
html body .btn:focus-visible {
    outline: 3px solid var(--Pink-01) !important;
    outline-offset: 2px !important;
}

/* Menu entries turn pink on focus, so their ring is drawn inside in white. */
html body a.menuGroup-item:focus-visible,
html body a.subMenu-item:focus-visible,
html body a.subMenu-item_Selected:focus-visible {
    outline: 3px solid var(--White, #fff) !important;
    outline-offset: -5px !important;
}

/* --- 3. Links that are only recognisable by colour (WCAG 1.4.1) ------------------------ */
html body a[id^="linkInstallAddress_"] {
    text-decoration: underline;
}

/* --- 4. Controls big enough to hit (WCAG 2.5.8: at least 24 x 24px) -------------------- */
html body input[type="radio"],
html body input[type="checkbox"] {
    min-width: 24px;
    min-height: 24px;
}

/* Pagination arrows of the tables are spans; they are made keyboard operable in
   createArrowPaginationWithCustomSpans() and get a matching hit area here. */
html body [id$="eftArrow"][role="button"],
html body [id$="ightArrow"][role="button"] {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    min-height: 44px;
    cursor: pointer;
}

    html body [id$="eftArrow"][aria-disabled="true"],
    html body [id$="ightArrow"][aria-disabled="true"] {
        opacity: 0.4;
        cursor: default;
    }

/* Group headings of the document archive contain a button (DocumentArchive.ts) so they open
   with the keyboard as well; it looks like the plain heading text. */
html body #treeview .parent > i.indicator,
html body #treeview .parent > h3 {
    vertical-align: middle;
}

html body #treeview .parent > h3 > .treeToggle {
    background: none;
    border: 0;
    padding: 0;
    margin: 0;
    font: inherit;
    color: inherit;
    text-align: left;
    cursor: pointer;
}

/* Space below an opened group; it used to be three <br /> directly in the <ul>, which is
   invalid list markup for screen readers. */
html body #treeview .parent > ul {
    padding-bottom: 4.5em;
}

/* --- 5. Mobile menu button ------------------------------------------------------------
   The menu toggles are <button>s now (keyboard and screen reader); keep the old look and
   give them a 44px touch area in the top right corner. */
html body #divIconClick button {
    background: none;
    border: 0;
    padding: 0;
    color: inherit;
    font-size: 22px;
    line-height: 1;
}

@media only screen and (max-width: 767px) {
    html body header.containerSize {
        position: relative;
    }

    html body #divIconClick {
        position: absolute;
        top: 0;
        right: 0;
        float: none;
        margin-top: 0;
        width: 48px !important;
        height: 48px !important;
        padding: 0 !important;
        display: flex;
        align-items: center;
        justify-content: center;
    }

        html body #divIconClick button {
            width: 48px;
            height: 48px;
        }

    /* The header took almost half of the first screen on a phone. */
    html body .headerHight {
        height: auto;
        padding: 12px 64px 12px 16px;
        box-sizing: border-box;
    }

    html body pageHeader #logo-img img {
        margin-left: 0 !important;
        max-height: 56px;
        width: auto;
    }

    html body pageHeader .pd48 {
        padding: 8px 0 0 0 !important;
        margin-top: 0 !important;
        gap: 12px !important;
        font-size: 15px;
    }

    /* Page titles wrapped into two huge lines. */
    html body h1 {
        font-size: clamp(1.75rem, 7vw, 2.25rem);
        line-height: 1.2;
        overflow-wrap: anywhere;
    }

}

/* --- 5b. Tables as cards on phones ----------------------------------------------------
   The document archive and the usage data had to be swiped sideways on a phone, the
   "Download" column was outside the screen. Below 768px every row becomes a card and each
   value is shown with the column name from its data-label attribute. The header row stays
   in the page for screen readers but is not shown. */
@media only screen and (max-width: 767px) {
    html body table.tblDocArchive,
    html body table#usageDtl {
        display: block;
        border: 0;
        width: 100% !important;
        height: auto !important;
    }

        html body table.tblDocArchive thead,
        html body table#usageDtl thead {
            position: absolute;
            width: 1px;
            height: 1px;
            overflow: hidden;
            clip: rect(0 0 0 0);
            white-space: nowrap;
        }

        html body table.tblDocArchive tbody,
        html body table#usageDtl tbody {
            display: block;
        }

            html body table.tblDocArchive tbody tr,
            html body table#usageDtl tbody tr {
                display: block;
                width: auto !important; /* Global.css fixes rows 2-6 to 153 x 64px */
                height: auto !important;
                margin-bottom: 8px;
                padding: 8px 16px !important;
                background: var(--White, #fff);
                border: 1px solid var(--Gray-03, #ddd);
            }

            html body table.tblDocArchive tbody td[data-label],
            html body table#usageDtl tbody td[data-label] {
                display: flex;
                justify-content: space-between;
                align-items: baseline;
                gap: 16px;
                width: auto !important;
                height: auto !important;
                padding: 6px 0 !important;
                border: 0 !important;
                text-align: right;
                overflow-wrap: anywhere;
            }

                html body table.tblDocArchive tbody td[data-label]::before,
                html body table#usageDtl tbody td[data-label]::before {
                    content: attr(data-label);
                    font-weight: 700;
                    text-align: left;
                }
}

/* --- 6. Room for the chat button ---------------------------------------------------------
   The round chat button is fixed in the bottom right corner and covered the last lines and
   the right table arrow of a page, on phones and on PCs. */
html body main {
    padding-bottom: 96px;
}

/* --- 7. Less motion for people who asked for it (WCAG 2.3.3) --------------------------- */
@media (prefers-reduced-motion: reduce) {
    html body *,
    html body *::before,
    html body *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}
