/* Shared screen styles for the home and content templates. */
a:focus-visible, .menu-toggle:focus-visible {
    outline: 2px solid #568ebb;
    outline-offset: 3px;
}

.menu-toggle {
    display: none;
}

@media screen and (max-width: 1050px) {
    html, body {
        height: auto;
        font-size: 15px;
        line-height: 1.6;
    }

    #wrap, #header, #innenfuss, #bild {
        width: 100%;
    }

    #wrap {
        min-height: 0;
    }

    #header {
        padding-top: 12px;
    }

    #main, #rahmen, #metanavi {
        box-sizing: border-box;
        width: calc(100% - 40px);
        margin-left: auto;
        margin-right: auto;
    }

    #rahmen {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        height: auto;
        padding: 12px 0;
        gap: 12px;
    }

    #jh {
        grid-column: 1;
        grid-row: 1;
        order: -1;
        width: auto;
        float: none;
        text-align: left;
    }

    #jh a {
        display: inline-block;
        padding: 8px 0;
        font-size: 22px;
    }

    #nav {
        grid-column: 1 / -1;
        float: none;
        width: auto;
        height: auto;
        margin: 0;
        letter-spacing: 0.03em;
    }

    #nav.menu-enhanced:not(.menu-open) {
        display: none;
    }

    .menu-toggle {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        grid-column: 2;
        grid-row: 1;
        align-self: center;
        flex-shrink: 0;
        width: 44px;
        height: 44px;
        padding: 10px;
        border: 1px solid currentColor;
        border-radius: 4px;
        color: #568ebb;
        background: white;
        cursor: pointer;
    }

    .menu-toggle-icon {
        position: relative;
        width: 22px;
        height: 18px;
    }

    .menu-toggle-icon span {
        position: absolute;
        left: 0;
        width: 22px;
        height: 2px;
        background: currentColor;
    }

    .menu-toggle-icon span:nth-child(1) { top: 0; }
    .menu-toggle-icon span:nth-child(2) { top: 8px; }
    .menu-toggle-icon span:nth-child(3) { top: 16px; }
    .menu-toggle[aria-expanded="true"] span span:nth-child(1) { top: 8px; transform: rotate(45deg); }
    .menu-toggle[aria-expanded="true"] span span:nth-child(2) { opacity: 0; }
    .menu-toggle[aria-expanded="true"] span span:nth-child(3) { top: 8px; transform: rotate(-45deg); }

    #nav > ul {
        display: block;
        border-top: 1px solid #d6e4ef;
    }

    #nav > ul > li {
        border-bottom: 1px solid #d6e4ef;
    }

    #nav ul li {
        float: none;
        min-width: 0;
    }

    #nav ul li a, #nav .menu li ul li a {
        box-sizing: border-box;
        width: auto;
        min-height: 44px;
        padding: 10px 0;
        line-height: 24px;
        overflow-wrap: anywhere;
        background: transparent;
    }

    /* Keep all destinations available without hover on touch screens. */
    #nav .menu li ul {
        position: static;
        display: block;
        background: transparent;
        font-size: 14px;
        padding-bottom: 4px;
    }

    #nav .menu li ul li a {
        padding-left: 20px;
    }

    #main {
        overflow: visible;
        padding-bottom: 32px;
    }

    #content, #sidebar {
        float: none;
        width: 100%;
        margin: 0;
        padding: 28px 0 0;
        overflow-wrap: anywhere;
    }

    #sidebar {
        text-align: left;
        font-size: 13px;
        line-height: 1.6;
    }

    #sidebar:empty {
        display: none;
    }

    h1, h2, h3, h4 {
        font-size: 1em;
    }

    img {
        max-width: 100%;
        height: auto;
    }

    #content table.stuecke, #content table.regie, #content table.masken {
        width: 100%;
        table-layout: fixed;
    }

    #content table.stuecke td.links {
        width: 28%;
    }

    #content table.regie td.regie_links {
        width: 55%;
    }

    #content table.regie td.regie_mitte {
        width: auto;
    }

    #content table.stuecke td, #content table.regie td {
        height: auto;
        padding: 0 12px 16px 0;
    }

    #content table.masken td {
        width: auto;
    }

    #content table.masken td.rand {
        width: 10px;
    }

    #footer {
        height: auto;
        margin-top: 0;
    }

    #innenfuss img, #bild img {
        display: block;
        width: 100%;
    }

    #metanavi {
        margin-top: 0;
        padding-bottom: 20px;
        font-size: 12px;
    }

    #metanavi ul, #subnav ul {
        display: flex;
        flex-wrap: wrap;
        justify-content: flex-end;
        gap: 4px 12px;
    }

    #metanavi a, #subnav ul li a {
        display: inline-block;
        padding: 10px 0;
        line-height: 24px;
    }

    .home #wrap {
        display: flex;
        flex-direction: column;
        margin-top: 0;
    }

    .home #header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
        font-size: clamp(18px, 4vw, 24px);
        box-sizing: border-box;
        height: auto;
        padding: 12px 20px;
        order: 0;
    }

    .home .menu-toggle {
        color: #545a94;
    }

    .home #nav {
        order: 1;
        margin: 0 20px 12px;
    }

    .home #bild {
        order: 2;
    }

    .home #subnav {
        order: 3;
        margin: 12px 20px;
        float: none;
        font-size: 12px;
        letter-spacing: normal;
    }
}

@media screen and (max-width: 600px) {
    /* These tables contain image galleries, so stack their cells on phones. */
    #content table.masken, #content table.masken tbody,
    #content table.masken tr, #content table.masken td {
        display: block;
        width: 100%;
    }

    #content table.masken td {
        padding-bottom: 12px;
    }

    #content table.masken td.rand {
        display: none;
    }
}
