@font-face {
    font-family: "Amiri";
    font-style: italic;
    font-weight: 400;
    font-display: swap;
    src: local("Amiri-Italic"), url("webfonts/amiri-v24-latin-italic.woff2") format("woff2");
}

@font-face {
    font-family: "Work Sans";
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: local("Work Sans Regular"), url("webfonts/work-sans-v17-latin-regular.woff2") format("woff2");
}

@font-face {
    font-family: "Work Sans";
    font-style: normal;
    font-weight: 600;
    font-display: swap;
    src: local("Work Sans Bold"), url("webfonts/work-sans-v17-latin-600.woff2") format("woff2");
}

@font-face {
    font-family: "Work Sans";
    font-style: italic;
    font-weight: 400;
    font-display: swap;
    src: local("Work Sans Italic"), url("webfonts/work-sans-v17-latin-italic.woff2") format("woff2");
}

@font-face {
    font-family: "Work Sans";
    font-style: italic;
    font-weight: 600;
    font-display: swap;
    src: local("Work Sans Bold Italic"), url("webfonts/work-sans-v17-latin-600italic.woff2") format("woff2");
}

@font-face {
    font-family: "Visby CF";
    font-style: normal;
    font-weight: 600;
    font-display: swap;
    src: local("Visby CF Demi"), url("webfonts/visby_cf-demibold.woff2") format("woff2");
}

* {
    box-sizing: border-box;
}

html {
    color-scheme: light dark;

    font-size: 1.125rem;

    --logo-color1: #386641;
    --logo-color2: #6A994E;
    --logo-color3: #A7C957;
    --logo-color4: #F2E8CF;
    --logo-color5: #495CBA;

    --background-color: light-dark( var( --logo-color4 ), var( --logo-color1 ) );
    --em-background-color: light-dark( white, var(--logo-color2 ) );

    &:has(dialog[open]){
        overflow: hidden;
    }
}

body {
    margin: 0;
    line-height: 1.35;
    font-family: "Work Sans", sans-serif;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;

    color: light-dark( black, white );
    background-color: var( --background-color );

    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
}

a{
    text-decoration-thickness: 0.07em;
    text-underline-offset: 0.2em;
    color: light-dark( var(--logo-color5), var(--logo-color4) );

    &:hover, &:visited{
        color: light-dark( var( --logo-color1 ), var( --logo-color4 ) );
    }
}

main {
    width: 90%;
    max-width: 900px;
    margin-inline: auto;

    min-height: calc( 100vh - 162px );

    padding-block: 2rem;

    @media (width <= 600px){
        padding-block: 1rem;
    }
}

.karte main{
    width: 100%;
    max-width: none;
    padding-block: 0;
}

form:not([method="dialog"]) {
    margin-bottom: 2rem;

    background-color: light-dark( var(--logo-color3), var(--logo-color2) );
    padding: 1.25rem 1rem;
}

.error {
    display: none;
    margin-top: 0;
    padding-inline: 0.2em;
}

form{
    &.has-error .error {
        display: block;
    }

    &.has-error input {
        border-color: red;
    }

    input {
        font: inherit;
        padding: 0.5em;
        width: 100%;
        margin-bottom: 0.5em;
        border: 2px solid black;

        color: black;
        background-color: light-dark( white, var( --logo-color4 ) );
    }

    label {
        display: block;
        margin-bottom: 0.25em;
        font-weight: bold;
    }
}


button {
    display: block;
    width: max-content;
    font: inherit;
    cursor: pointer;

    background-color: black;
    color: white;
    border-radius: 0;
    border: 3px solid black;
    padding: 0.5em 1em;
    transition: 0.2s ease-out;
    line-height: 1;

    &:hover {
        background-color: transparent;
        color: black;
    }
}

blockquote {
    font-style: italic;
    font-family: "Amiri", serif;
    font-size: 1.3rem;
}

h1,
h2 {
    font-family: "Visby CF", sans-serif;
    scroll-margin-block-start: 50px;
}

h1{
    line-height: 1.1;
}

.start main h1,
.page main h1 {
    margin-top: 1.5em;

    @media (width <= 900px){
        margin-top: 0.5em;
    }
}

.start ul li,
.page ul li {
    margin-bottom: 0.3em;
}

.page{
    .table-wrapper{
        width: 100%;
        overflow: auto clip;

        table{
            border-collapse: collapse;
        }

        th,
        td {
            border: 1px solid;
            padding: 0.2em 0.4em;
        }
    }
}

.quellen-subliste{
    display: flex;
    flex-wrap: wrap;
    gap: 0 1ch;
    list-style-type: "";
}

h2 {
    margin-top: 1.5em;
}

footer {
    border-top: 5px solid white;
    background-color: lightgrey;

    background: linear-gradient(to right, 
    var( --logo-color1 ), 
    var( --logo-color1 ) 20%, 
    var( --logo-color2 ) 20%, 
    var( --logo-color2 ) 40%, 
    var( --logo-color3 ) 40%, 
    var( --logo-color3 ) 60%, 
    var( --logo-color4 ) 60%, 
    var( --logo-color4 ) 80%, 
    var( --logo-color5 ) 80%);

    color: light-dark( black, white );

    padding: 1em;
    margin-top: 3rem;
    display: flex;
    gap: 1em;
    justify-content: end;

    a{
        color: currentColor;

        &:hover,
        &:visited{
            color: currentColor;
        }
    }
}

.karte {
    min-height: 100vh;
    display: grid;
    grid-template-rows: auto 1fr auto;

    footer{
        margin-top: 0;
    }
}

.map-wrapper {
    position: relative;
    height: 100%;
}

#map {
    height: 100%;
}

.attribution {
    position: absolute;
    bottom: 10px;
    right: 10px;
    background-color: white;
    padding: 2px 4px;
    font-size: 12px;

    a {
        color: black;
    }
}

#legend {
    position: fixed;
    top: 10rem;
    right: max(1rem, env(safe-area-inset-right));
    background-color: var( --background-color );
    padding: 0.2em 0.5em;
    z-index: 2;

    &[open]{
        padding: 0.5em;
        padding-top: 0.1em;
    }
}

#jahr-range-input{
    position: fixed;
    top: 4rem;
    right: max(1rem, env(safe-area-inset-right));
    background-color: var( --background-color );
    padding: 0.2em 0.5em;
    z-index: 1;
    margin: 0;

    @media (width <= 600px){
        top: 4.8rem;
        right: 0.5rem;
    }

    label{
        display: block;
        text-align: center;
    }

    .range-wrapper{
        display: grid;
        grid-template-columns: repeat( var(--years, 5), minmax(0, 1fr));
        column-gap: 0.5em;

        &[data-years="5"]{ --years: 5; }
        &[data-years="6"]{ --years: 6; }
        &[data-years="7"]{ --years: 7; }
        &[data-years="8"]{ --years: 8; }
        &[data-years="9"]{ --years: 9; }
        &[data-years="10"]{ --years: 10; }

        input{
            grid-column: 1 / -1;
            margin-inline: 1.5ch;
        }

        div{
            grid-column: 1 / -1;
            display: grid;
            grid-template-columns: subgrid;
            text-align: center;
        }
    }
}


#layers{
    ul {
        list-style: none;
        padding: 0;
        margin: 0;

        display: flex;
        flex-wrap: wrap;
        gap: 0.25em 0.5em;

        li{
            display: block;
        }
    }
}

.bold{
    font-size: 1.2rem;
    font-weight: bold;
    font-family: "Visby CF", sans-serif;
}

header {
    .inner {
        width: 90%;
        margin: 0.5em auto;

        display: flex;
        gap: 0.5rem 2rem;
        align-items: center;
        justify-content: space-between;
        flex-wrap: wrap;
    }

    h1 {
        margin: 0;
        font-size: 1.2rem;
    }

    a {
        color: inherit;
        text-decoration: none;
    }

    nav{
        ul {
            display: flex;
            gap: 1rem;
            list-style-type: none;
            padding: 0;
            margin: 0;
        }

        a[aria-current="page"],
        a:hover {
            text-decoration: underline;
            text-decoration-thickness: 0.07em;
        }
    }

    form {
        margin: 0;
        padding: 0;
        background-color: transparent;

        display: flex;

        label {
            display: none;
        }

        input {
            padding-block: 0.2em;
            margin-bottom: 0;

        }

        button {
            padding: 0.2em 0.4em;
            height: 1.98em;
            border: none;
        }

        button:hover {
            background-color: grey;
        }
    }
}



.flaeche {
    text-align: right;
}

.stats main {
    width: 100%;
    max-width: none;
}

.content-width {
    width: 90%;
    max-width: 75rem;
    margin-inline: auto;

    /*
    padding-top: 3rem;
    padding-bottom: 3rem;

     */

}

.stats_alle .content-width{
    margin-inline: 0;
    padding-left: 5%;
}

.breadcrumb {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.4em;
    font-size: 0.85em;
    margin-block: 1rem 0.5rem;
}

.breadcrumb .breadcrumb-sep {
    opacity: 0.5;
}

.breadcrumb [aria-current="page"] {
    opacity: 0.7;
}

.map-preview-link {
    display: inline-block;
    text-decoration: none;
    margin-block: 1rem;
}

.map-preview {
    display: block;
    width: 100%;
    max-width: 400px;
    height: auto;
    aspect-ratio: 3 / 2;
    object-fit: cover;
    border-radius: 6px;
    border: 1px solid light-dark( var(--logo-color2), var(--logo-color4) );
}

.map-preview-cta {
    display: inline-block;
    margin-top: 0.4rem;
}

.kg-summary {
    background-color: var( --em-background-color );
    border-inline-start: 4px solid var( --logo-color2 );
    border-radius: 4px;
    padding: 1rem 1.25rem;
    margin-block: 1.5rem;
}

.kg-summary p {
    margin-block: 0;
}

.kg-summary .kg-summary-meta {
    margin-top: 0.5rem;
    font-size: 0.8em;
    opacity: 0.7;
}

.stats{
    overflow-x: clip;

    h3{
        margin-top: 2lh;
    }

    .table-container .content-width{
        padding-block: 0;
    }

    th,
    td {
        border: 1px solid;
        padding: 2px 6px;
    }

    .table-wrapper{
        overflow: auto clip;
        padding-bottom: .5em;

        table{
            display: grid;
            grid-template-columns: repeat( var( --cols ), auto );

            width: fit-content;
            padding-inline: 5%;

            thead, tbody, tfoot{

                padding-right: 1em;

                &, tr{
                    grid-column: 1 / -1;
                    display: grid;
                    grid-template-columns: subgrid;
                }
            }

            th, td{
                display: grid;
                align-content: center;
            }

            thead th{
                position: sticky;
                top: 0;
                background-color: var( --background-color );
                z-index: 2;
            }

            tbody{
                max-height: 80svh;
                overflow-y: auto;
                overflow-x: clip;

                box-sizing: border-box;

                .kg-name,
                .sticky-th{
                    position: sticky;
                    left: 0;
                    background-color: var( --background-color );
                }

                tr:nth-child(even){
                    .kg-name,
                    .sticky-th{
                        background-color: var( --em-background-color );
                    }
                }
            }

            tfoot th,
            tfoot td{
                position: sticky;
                bottom: 0;
                background-color: var( --background-color );
            }
        }
        
    }

    table{
        tbody td,
        tfoot td {
            text-align: right;
            white-space: nowrap;

            font-feature-settings: "tnum" on;
            font-size: 0.8em;
        }

        tbody th {
            text-align: left;
            font-size: 0.8em;
        }

        tbody tr:nth-child(even) {
            background-color: var( --em-background-color );

            th{
                background-color: var( --em-background-color );
            }
        }

        tfoot tr{
            background-color: var( --em-background-color );
        }

        a,
        a:visited{
            color: inherit;
            text-decoration: none;
        }

        a:hover,
        a:focus{
            text-decoration: underline;
        }
    }

}

.stats{
    --cols: 11;
}

.stats_alle{
    --cols: 31;

    &.veraenderung-cols-1{ --cols: calc( 2 + 29 * 2 ); }
    &.veraenderung-cols-2{ --cols: calc( 2 + 29 * 3 ); }
    &.veraenderung-cols-3{ --cols: calc( 2 + 29 * 4 ); }
    &.veraenderung-cols-4{ --cols: calc( 2 + 29 * 5 ); }
    &.veraenderung-cols-5{ --cols: calc( 2 + 29 * 6 ); }
    &.veraenderung-cols-6{ --cols: calc( 2 + 29 * 7 ); }
}

thead th.active{
    text-decoration: underline;
    text-decoration-thickness: 0.07em;
    text-underline-offset: 0.2em;
}


.settings{
    width: max-content;
    max-width: 90vw;

    fieldset{
        display: flex;
        flex-wrap: wrap;
        gap: 0rem 2rem;
        border-color: currentColor;
    }

    label{
        display: flex;
        column-gap: 0.5rem;
        align-items: center;
    }

    input{
        margin: 0;
        width: auto;
    }

    button{
        margin-top: 1em;
    }
}

.luftbild-wrapper,
.changes-wrapper{
    display: flex;
    gap: 0.3em;
    align-items: center;
}

.changes-wrapper{
    margin-top: 0.5rem;
}



@media screen and (width <= 600px){
    html{
        font-size: 1rem;
        --header-height: 4.375rem;
    }

    blockquote{
        margin-inline: 20px;
        font-size: 1.2rem;
    }

    .karte{
        main{
            display: flex;
            flex-direction: column;
            height: calc( 100svh - var( --header-height ) );
        }

        #legend{
            position: static;
        }

        #legend ul{
            display: flex;
            flex-wrap: wrap;
            gap: 0.5em;
        }
    }
}

#search-overlay{
    border: none;
    padding: 0;
    width: 90%;
    background-color: var( --background-color );

    @media (max-width: 900px){
        width: 100%;
    }

    form{
        margin: 1rem;
    }

    form[method="dialog"] {
        margin-left: auto;
        width: max-content;
        margin-bottom: 2rem;
        position: sticky;
        top: 1rem;

        button:hover{
            background-color: white;
        }
    }

    .suche-kg-liste{
        display: grid;
        grid-template-columns: auto auto auto auto;
        column-gap: 1em;
        row-gap: 2px;
        overflow-x: auto;
        padding: 1rem;

        li{
            display: grid;
            grid-column: 1 / -1;
            grid-template-columns: subgrid;

            &.hidden{
                display: none;
            }

            a{
                display: grid;
                grid-column: 1 / -1;
                grid-template-columns: subgrid;
                line-height: 1;
                white-space: nowrap;

                padding: 0.5em;

                border: 1px solid light-dark( var( --logo-color1 ),  var( --logo-color4 ) );
                border-radius: 4px;

                text-decoration: none;
                color: currentColor;
                transition: 0.2s ease-out;

                &:hover{
                    background-color: light-dark( var( --logo-color4 ), var( --logo-color2 ) );
                }
            }
        }

        .liste-header{
            font-weight: bold;
        }
    }
}

#search-overlay::backdrop{
    background-color: rgba(0,0,0,0.6);
}

.ergebnisse-count-wrapper{
    margin: 1rem;
}

.tag-input{
    position: relative;
    cursor: pointer;

    border: 1px solid black;
    padding: 0.2em 0.5em;
    line-height: 1;
    border-radius: 1em;

    input{
        position: absolute;
        opacity: 0;
        cursor: pointer;
        height: 0;
        width: 0;
    }

    &:has(input:checked), &:focus, &:hover {
        background-color: black;
        color: white;
    }
}

.num-value{
    font-variant-numeric: tabular-nums;
    font-feature-settings: "tnum" on;
}

label:has(input[disabled]){
    color: grey;
    cursor: not-allowed;
}

.chart-wrapper{
    width: min( 400px, 100%);
    padding: 1em;
    margin-top: 1rem;

    #groupsLegend{
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
        gap: 0.8em 1.1em;
        margin-bottom: 0.8em;
        font-size: 0.8rem;
        color: light-dark( #1a1a1a, #fff );
    }
}

.linechart-wrapper{
    width: min( 600px, 100%);
    margin-top: 1rem;
}

.start .linechart-wrapper{
    margin-block: 1lh;
}

.movers-chart-wrapper{
    width: min( 600px, 100%);
    aspect-ratio: 3 / 1;
    min-height: 11rem;
    margin-top: 1rem;

    color: #C46C4D;
}

#groupsLegend {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 14px;
    margin-bottom: 10px;
    font-size: 12px;
}
#groupsLegend .legend-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
#groupsLegend .legend-swatch {
    display: inline-block;
    width: 11px;
    height: 11px;
    border-radius: 2px;
    flex-shrink: 0;
}

/*
.delta-positive { color: #C46C4D; }
.delta-negative { color: #7BAFD4; }
*/