/*
 * KLIMA³ – zusätzliche Gestaltung für einen qgis2web/OpenLayers-Export
 * Datei zuletzt in index.html einbinden, damit diese Regeln Vorrang haben.
 */

:root {
    /* Farben aus der KLIMA³-Wort-/Bildmarke */
    --klima-blue: #005091;
    --klima-turquoise: #4FBAB7;
    --klima-green: #6B9A3C;
    --klima-grey: #BCB9B6;

    --klima-text: #23343d;
    --klima-muted: #66757c;
    --klima-line: #dce5e7;
    --klima-surface: #ffffff;
    --klima-surface-soft: #f4f8f8;
    --klima-shadow: 0 6px 24px rgba(0, 68, 111, 0.18);

    /* Hier lässt sich die Breite des Detailfensters zentral ändern. */
    --klima-panel-width: clamp(390px, 39vw, 680px);
    --klima-info-panel-width: clamp(520px, 42vw, 760px);
    --klima-control-size: 44px;
    --klima-radius: 25px;

    /* Position des Bedienblocks unterhalb des Kartentitels. */
    --klima-controls-left: 0px;
    --klima-zoom-top: 120px;
    --klima-info-top: 60px;
    --klima-search-top: -35px;
}

.info-kasten {
    background-color: var(--klima-turquoise);
    border-left: 5px solid var(--klima-blue);
    border-radius: 6px;
    padding: 12px 15px;
    margin: 12px 0;
    color: #1f1f1f;
    line-height: 1.5;
}

html,
body {
    font-family: "Segoe UI", Roboto, Arial, sans-serif;
    color: var(--klima-text);
}

#map {
    transition: none !important;
}

/* Karte bleibt bei beiden Panels unverändert */
body.klima-info-open #map,
body.klima-details-open #map,
body.klima-info-open.klima-details-open #map {
    width: 100% !important;
    margin-left: 0 !important;
}

/* Rechtes Panel: liegt über der Karte */
body.klima-details-open #map {
    width: 100% !important;
    margin-left: 0 !important;
}

/* Linkes Panel */
body.klima-info-open #map {
    width: 100% !important;
    margin-left: 0 !important;
}

/* --------------------------------------------------------------------------
   Einheitliche Kartenbedienelemente
   -------------------------------------------------------------------------- */

.ol-control,
.photon-geocoder-autocomplete,
.layer-switcher {
    font-family: inherit;
}

.ol-control:not(.ol-attribution),
.photon-geocoder-autocomplete {
    border: 0 !important;
    border-radius: var(--klima-radius) !important;
    background: rgba(255, 255, 255, 0.97) !important;
    box-shadow: var(--klima-shadow);
}

.ol-control button {
    color: var(--klima-blue) !important;
    /* background-color statt background: So bleiben Plugin-Icons erhalten. */
    background-color: var(--klima-surface) !important;
    border: 0 !important;
    transition: color 150ms ease, background-color 150ms ease;
}

.ol-control button:hover,
.ol-control button:focus-visible {
    color: #ffffff !important;
    background: var(--klima-blue) !important;
    outline: none;
}

/* Zoom + / − */
.ol-zoom {
    top: var(--klima-zoom-top) !important;
    left: var(--klima-controls-left) !important;
    overflow: hidden;
    padding: 0 !important;
}

.ol-zoom button {
    width: var(--klima-control-size) !important;
    height: var(--klima-control-size) !important;
    margin: 0 !important;
    border-radius: 0 !important;
    font-size: 25px !important;
    font-weight: 400 !important;
    line-height: var(--klima-control-size) !important;
}

.ol-zoom-in {
    border-bottom: 1px solid var(--klima-line) !important;
}

/* Maßstab und Quellenangabe etwas ruhiger */
.ol-scale-line {
    padding: 3px 8px !important;
    border-radius: 6px !important;
    background: rgba(0, 68, 111, 0.78) !important;
}

.ol-attribution {
    color: var(--klima-muted);
    background: rgba(255, 255, 255, 0.9) !important;
}

/* --------------------------------------------------------------------------
   Adresssuche – berücksichtigt mehrere qgis2web/Photon-Versionen
   -------------------------------------------------------------------------- */

.photon-geocoder-autocomplete,
.ol-geocoder,
.gcd-gl-control {
    top: var(--klima-search-top) !important;
    left: var(--klima-controls-left) !important;
    min-height: var(--klima-control-size);
    overflow: visible !important;
    padding: 0 !important;
}

#gcd-button-control,
.photon-geocoder-autocomplete button,
.ol-geocoder button {
    width: var(--klima-control-size) !important;
    height: var(--klima-control-size) !important;
    border-radius: var(--klima-radius) !important;
    color: var(--klima-blue) !important;
    background: var(--klima-surface) !important;
}

.photon-input,
.ol-geocoder input,
.gcd-gl-input {
    width: min(300px, calc(100vw - 110px)) !important;
    height: var(--klima-control-size) !important;
    box-sizing: border-box;
    padding: 0 14px !important;
    color: var(--klima-text) !important;
    background: var(--klima-surface) !important;
    border: 0 !important;
    border-left: 1px solid var(--klima-line) !important;
    border-radius: 0 var(--klima-radius) var(--klima-radius) 0 !important;
    font: 15px/1.2 inherit !important;
}

.photon-input:focus,
.ol-geocoder input:focus,
.gcd-gl-input:focus {
    outline: 3px solid rgba(53, 185, 184, 0.38) !important;
    outline-offset: -3px;
}

ul.photon-autocomplete,
.ol-geocoder ul {
    margin-top: 6px !important;
    overflow: hidden;
    border: 0 !important;
    border-radius: var(--klima-radius) !important;
    box-shadow: var(--klima-shadow);
}

ul.photon-autocomplete li,
.ol-geocoder li {
    padding: 9px 12px !important;
    border-bottom: 1px solid var(--klima-line) !important;
}

ul.photon-autocomplete li:hover,
.ol-geocoder li:hover {
    background: var(--klima-turquoise) !important;
}

/* --------------------------------------------------------------------------
   Eigenes Infofeld: unabhängig vom qgis2web-Abstract-Plugin
   -------------------------------------------------------------------------- */

#abstract.klima-plugin-abstract-hidden {
    display: none !important;
}

#klima-info-control {
    position: fixed;
    top: var(--klima-info-top);
    left: 8px;
    z-index: 9500;
}

#klima-info-button {
    display: grid;
    width: var(--klima-control-size);
    height: var(--klima-control-size);
    box-sizing: border-box;
    place-items: center;
    padding: 0;
    color: #ffffff;
    background: var(--klima-blue);
    border: 0;
    border-radius: 50%;
    box-shadow: var(--klima-shadow);
    font: 700 22px/1 Georgia, serif;
    cursor: pointer;
}

#klima-info-button:hover,
#klima-info-button:focus-visible,
.klima-info-open #klima-info-button {
    color: #ffffff;
    background: var(--klima-turquoise);
}

#klima-info-panel {
    position: fixed;
    inset: 0 auto 0 0;
    display: block;
    width: var(--klima-info-panel-width);
    height: 100dvh;
    box-sizing: border-box;
    overflow-y: auto;
    padding: 62px 34px 30px;
    color: var(--klima-text);
    background: var(--klima-surface);
    border: 0;
    border-radius: 0;
    box-shadow: 10px 0 28px rgba(0, 68, 111, 0.18);
    z-index: 10000;
    font-size: 16px;
    line-height: 1.5;

    /* Geschlossener Zustand */
    transform: translateX(-100%);
    visibility: hidden;

    /* Ein- und Ausgleiten */
    transition:
        transform 500ms ease,
        visibility 0s linear 500ms;
}

body.klima-info-open #klima-info-panel {
    transform: translateX(0);
    visibility: visible;
    transition-delay: 0s;
}

#klima-info-panel::before {
    content: "";
    position: absolute;
    inset: 0 0 auto 0;
    height: 8px;
    background: linear-gradient(
        90deg,
        var(--klima-blue) 0 34%,
        var(--klima-turquoise) 34% 68%,
        var(--klima-green) 68% 86%,
        var(--klima-green) 86% 100%
    );
}

#klima-info-panel h2 {
    margin: 0 48px 22px 0;
    padding-bottom: 12px;
    color: var(--klima-blue);
    border-bottom: 3px solid var(--klima-turquoise);
    font-size: clamp(24px, 2.2vw, 34px);
    line-height: 1.18;
}

#klima-info-panel p {
    margin: 0 0 14px;
}

#klima-info-panel p:last-child {
    margin-bottom: 0;
}

#klima-info-panel ul {
    margin: -4px 0 18px;
    padding-left: 24px;
}

#klima-info-panel li {
    margin-bottom: 6px;
}

#klima-info-panel a {
    color: var(--klima-blue);
    text-decoration-thickness: 1px;
    text-underline-offset: 2px;
}

#klima-info-panel a:hover {
    color: var(--klima-green);
}

.klima-info-close {
    position: absolute;
    top: 17px;
    right: 22px;
    display: grid;
    width: 38px;
    height: 38px;
    place-items: center;
    padding: 0;
    color: var(--klima-blue);
    background: transparent;
    border: 0;
    border-radius: 50%;
    font: 32px/1 "Segoe UI", Arial, sans-serif;
    cursor: pointer;
    text-indent: 1px; /* positiv nach rechts, negativ nach links */
    padding-bottom: 6px; /* Pfeil etwas nach oben */
}

.klima-info-close:hover,
.klima-info-close:focus-visible {
    color: #ffffff;
    background: var(--klima-blue);
}

/* --------------------------------------------------------------------------
   Layer-/Legendenfenster
   -------------------------------------------------------------------------- */

.layer-switcher {
    top: 18px !important;
    right: 18px !important;
    padding: 0 !important;
    border-radius: var(--klima-radius) !important;
}

.layer-switcher > button {
    display: block !important;
    width: var(--klima-control-size) !important;
    height: var(--klima-control-size) !important;
    border-radius: var(--klima-radius) !important;
    color: transparent !important;
    background-color: #ffffff !important;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Cpath d='M16 4 29 11 16 18 3 11Z' fill='%2359cbd0' stroke='%232a9aaa' stroke-width='1.3' stroke-linejoin='round'/%3E%3Cpath d='m5 15 11 6 11-6' fill='none' stroke='%23756e6b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3Cpath d='m5 20 11 6 11-6' fill='none' stroke='%23756e6b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") !important;
    background-repeat: no-repeat !important;
    background-position: center !important;
    background-size: 29px 29px !important;
    box-shadow: var(--klima-shadow);
}

.layer-switcher > button:hover,
.layer-switcher > button:focus-visible {
    background-color: var(--klima-turquoise) !important;
}

/* Im geöffneten Zustand dient derselbe Button als Schließen-Schaltfläche. */
.layer-switcher.shown > button {
    display: grid !important;
    place-items: center;
    color: var(--klima-blue) !important;
    background-image: none !important;
    font-size: 0 !important;
}

.layer-switcher.shown > button::after {
    content: "\00bb";
    display: block;
    font: 700 25px/1 Arial, sans-serif;
    transform: translateY(-5px);
}

.layer-switcher .panel {
    width: min(390px, calc(100vw - 36px));
    max-height: calc(100vh - 92px);
    box-sizing: border-box;
    padding: 17px 18px !important;
    color: var(--klima-text);
    background: rgba(255, 255, 255, 0.98) !important;
    border: 0 !important;
    border-top: 5px solid var(--klima-turquoise) !important;
    border-radius: var(--klima-radius) !important;
    box-shadow: var(--klima-shadow);
}

.layer-switcher li {
    margin-top: 7px !important;
}

.layer-switcher label {
    color: var(--klima-text) !important;
    line-height: 1.35;
}

.layer-switcher li.group > label {
    color: var(--klima-blue) !important;
    font-weight: 700 !important;
}

.layer-switcher input[type="checkbox"],
.layer-switcher input[type="radio"] {
    accent-color: var(--klima-blue);
}

/* --------------------------------------------------------------------------
   Popup als festes Detailfenster rechts
   -------------------------------------------------------------------------- */

#popup.klima-details-panel,
.ol-popup.klima-details-panel {
    position: fixed !important;
    inset: 0 0 0 auto !important;
    width: var(--klima-panel-width) !important;
    height: 100dvh !important;
    min-width: 0 !important;
    max-width: none !important;
    box-sizing: border-box;
    overflow: hidden;
    margin: 0 !important;
    padding: 55px 32px 28px !important;
    animation: klima-panel-slide-in 500ms ease-out both;
    color: var(--klima-text) !important;
    background: var(--klima-surface) !important;
    border: 0 !important;
    border-radius: 0 !important;
    box-shadow: -10px 0 28px rgba(0, 68, 111, 0.18) !important;
    z-index: 10000 !important;
}

@keyframes klima-panel-slide-in {
    from {
        transform: translateX(100%);
    }

    to {
        transform: translateX(0);
    }
}

#popup.klima-details-panel.klima-panel-closing {
    animation: klima-panel-slide-out 500ms ease-in both !important;
}

@keyframes klima-panel-slide-out {
    from {
        transform: translateX(0);
    }

    to {
        transform: translateX(100%);
    }
}

/* KLIMA³-Farbband am oberen Rand */
#popup.klima-details-panel::before {
    content: "";
    position: absolute;
    inset: 0 0 auto 0;
    display: block !important;
    height: 8px;
    background: linear-gradient(
        90deg,
        var(--klima-blue) 0 34%,
        var(--klima-turquoise) 34% 68%,
        var(--klima-green) 68% 86%,
        var(--klima-green) 86% 100%
    );
    border: 0 !important;
}

#popup.klima-details-panel::after {
    display: none !important;
}

#popup.klima-details-panel #popup-content {
    width: 100% !important;
    max-width: none !important;
    height: calc(100dvh - 83px) !important;
    max-height: none !important;
    box-sizing: border-box;
    overflow-x: hidden;
    overflow-y: auto;
    padding: 0 8px 18px 0 !important;
    color: var(--klima-text);
    font-size: 16px;
    line-height: 1.5;
    scrollbar-color: var(--klima-turquoise) var(--klima-surface-soft);
}

#popup.klima-details-panel .ol-popup-closer {
    position: absolute !important;
    top: 14px !important;
    right: 22px !important;
    display: grid !important;
    width: 38px !important;
    height: 38px !important;
    place-items: center;
    color: var(--klima-blue) !important;
    background: transparent !important;
    border-radius: 50% !important;
    font-size: 0 !important;
    line-height: 1 !important;
    text-decoration: none !important;
}

#popup.klima-details-panel .ol-popup-closer::after {
    content: "\2192" !important;
    display: block !important;
    color: inherit;
    font: 32px/1 "Segoe UI", Arial, sans-serif !important;
    transform: translate(-1px, -4px);
}

#popup.klima-details-panel .ol-popup-closer:hover,
#popup.klima-details-panel .ol-popup-closer:focus-visible {
    color: #ffffff !important;
    background: var(--klima-blue) !important;
    outline: none;
}

#popup.klima-details-panel h1,
#popup.klima-details-panel h2,
#popup.klima-details-panel h3 {
    margin: 0 0 14px;
    color: var(--klima-blue);
    line-height: 1.18;
}

#popup.klima-details-panel h2 {
    padding-bottom: 11px;
    border-bottom: 3px solid var(--klima-turquoise);
    font-size: clamp(23px, 2.2vw, 34px);
}

#popup.klima-details-panel p {
    margin: 0 0 14px;
}

#popup.klima-details-panel ul {
    margin: 0 0 16px;
    padding-left: 22px;
}

#popup.klima-details-panel table {
    width: 100% !important;
    border-collapse: collapse !important;
    table-layout: auto;
}

#popup.klima-details-panel th,
#popup.klima-details-panel td {
    padding: 10px 8px !important;
    vertical-align: top !important;
    border: 0 !important;
    border-bottom: 1px solid var(--klima-line) !important;
    text-align: left !important;
}

#popup.klima-details-panel th {
    width: 34%;
    color: var(--klima-blue) !important;
    background: var(--klima-surface-soft) !important;
    font-weight: 700 !important;
}

#popup.klima-details-panel tr:hover td {
    background: transparent !important;
}

#popup.klima-details-panel tr:hover th {
    background: var(--klima-surface-soft) !important;
}

#popup.klima-details-panel a:not(.ol-popup-closer) {
    color: var(--klima-blue) !important;
    font-weight: 600;
    text-decoration-thickness: 1px;
    text-underline-offset: 3px;
}

#popup.klima-details-panel a:not(.ol-popup-closer):hover {
    color: var(--klima-green) !important;
}

/* Barrierearme Tastaturmarkierung */
a:focus-visible,
button:focus-visible,
input:focus-visible {
    outline: 3px solid var(--klima-turquoise) !important;
    outline-offset: 2px;
}

/* --------------------------------------------------------------------------
   Smartphone / schmale Fenster
   -------------------------------------------------------------------------- */

@media (max-width: 900px) {
    :root {
        --klima-panel-width: 100vw;
        --klima-info-panel-width: 100vw;
    }

    body.klima-details-open #map,
    body.klima-info-open #map,
    body.klima-info-open.klima-details-open #map {
        width: 100% !important;
        margin-left: 0;
    }

    #popup.klima-details-panel,
    .ol-popup.klima-details-panel {
        padding: 55px 20px 22px !important;
    }

    #popup.klima-details-panel #popup-content {
        padding-right: 2px !important;
    }

    #klima-info-panel {
        padding: 58px 22px 26px;
    }

    .layer-switcher .panel {
        max-height: calc(100dvh - 90px);
    }
}

@media (prefers-reduced-motion: reduce) {
    #map,
    #klima-info-panel,
    .ol-control button {
        transition: none !important;
    }
}

#project-branding {
    position: fixed;
    left: 18px;
    bottom: 18px;
    z-index: 9000;
    width: 370px;
    display: grid;
    grid-template-columns: 155px 135px;
    align-items: center;
    gap: 22px;
    box-sizing: border-box;
    padding: 15px 22px 13px;
    background: rgba(255, 255, 255, 0.94);
    border: 1px solid rgba(0, 94, 138, 0.12);
    border-radius: 12px;
    box-shadow: 0 4px 18px rgba(32, 55, 70, 0.16);
    backdrop-filter: blur(6px);
}

#project-branding .logo-maisach {
    width: 145px;
    height: auto;
}

#project-branding .logo-klima {
    width: 120px;
    height: auto;
    padding-left: 16px;
    border-left: 1px solid #dce4e6;
}

/* Kartentitel: nur ein abgerundeter Kasten */
.top-left-title {
    padding: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
}

.top-left-title .project-title {
    margin: 0 !important;
    padding: 6px 10px !important;

    background: #ffffff !important;
    border: 0 !important;
    border-radius: 25px !important;
    box-shadow: var(--klima-shadow);
}

/* Startfenster */
.start-modal {
    position: fixed;
    inset: 0;
    z-index: 20000;

    display: flex;
    align-items: center;
    justify-content: center;

    padding: 20px;
    background: rgba(0, 0, 0, 0.35);
}

.start-modal-box {
    position: relative;
    width: min(460px, calc(100vw - 40px));
    max-height: calc(100vh - 40px);
    overflow-y: auto;

    padding: 30px;
    background: #ffffff;
    border-radius: 20px;
    box-shadow: 0 12px 35px rgba(0, 0, 0, 0.25);
}

.start-modal-box h2 {
    margin: 0 35px 15px 0;
    color: #006a91;
}

.start-modal-box p {
    margin: 0 0 22px;
    line-height: 1.5;
}

.start-modal-close {
    position: absolute;
    top: 12px;
    right: 15px;

    border: 0;
    background: transparent;
    color: #006a91;
    font-size: 30px;
    line-height: 1;
    cursor: pointer;
}

.start-modal-confirm {
    padding: 10px 18px;
    border: 0;
    border-radius: 22px;
    background: #006a91;
    color: #ffffff;
    font-weight: 600;
    cursor: pointer;
}

.start-modal-confirm:hover {
    background: #008c95;
}

.start-modal.is-closed {
    display: none;
}