/* Copyright (c) 2024-2026 Serhii I. Myshko. Licensed under the MIT License. See LICENSE for details. */

html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

html,
body {
    margin: 0;
    height: 100%;
    background: var(--map-chrome-bg, #f3f3f3);
}

body {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    height: auto;
    display: flex;
    flex-direction: column;
    padding: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px) 0 env(safe-area-inset-left, 0px);
    box-sizing: border-box;
    overflow: hidden;
}

.leaflet-control-screenshot-wrapper {
    display: none;
}

#webBar {
    position: relative;
    flex: none;
    z-index: 1100;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 6px 10px calc(6px + env(safe-area-inset-bottom, 0px));
    background: var(--map-chrome-bg, #ffffff);
    color: var(--map-chrome-text, #1f1f1f);
    border-top: 1px solid var(--map-chrome-border, rgba(0, 0, 0, 0.2));
    font-family: 'IBM Plex Sans', 'Segoe UI', system-ui, sans-serif;
}

#webChrome {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: none;
}

#webLanguage {
    display: flex;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 0 0 1px var(--map-chrome-border, rgba(0, 0, 0, 0.25));
}

#webLanguage button,
.web-chip {
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    line-height: 1;
    padding: 9px 12px;
    border: 0;
    cursor: pointer;
    background: transparent;
    color: inherit;
}

.web-chip {
    border-radius: 8px;
    box-shadow: 0 0 0 1px var(--map-chrome-border, rgba(0, 0, 0, 0.25));
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

a.web-chip {
    text-decoration: none;
}

.web-chip-icon {
    min-width: 36px;
    justify-content: center;
    font-size: 16px;
    padding: 7px 10px;
}

#webLanguage button[aria-pressed='true'] {
    background: var(--map-chrome-hover, #dfe6e9);
    box-shadow: inset 0 -2px 0 currentColor;
}

#webLanguage button:hover,
.web-chip:hover {
    background: var(--map-chrome-hover, #eef2f3);
}

#webLanguage button:focus-visible,
.web-chip:focus-visible,
.about-close:focus-visible {
    outline: 2px solid #2563eb;
    outline-offset: 2px;
}

#webStatus .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #1f8a4c;
}

#webStatus.stale .dot {
    background: #c27a0a;
}

#webText {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
}

#webCredits {
    font-size: 11px;
    line-height: 1.35;
    text-align: center;
    opacity: 0.8;
}

#webCredits .leaflet-control-attribution {
    float: none;
    clear: none;
    margin: 0 !important;
    padding: 0;
    background: none !important;
    border-radius: 0;
    box-shadow: none;
    color: inherit;
    font-size: inherit;
    line-height: inherit;
}

#webCredits a {
    color: inherit !important;
    font-size: inherit;
    text-decoration: none;
}

#webCredits a:hover {
    text-decoration: none;
}

#webNotice {
    margin: 0;
    font-size: 12px;
    line-height: 1.35;
    text-align: center;
}

#map {
    flex: 1 1 auto;
    min-height: 0;
    height: auto;
}

#aboutDialog {
    width: min(680px, calc(100vw - 24px));
    max-height: calc(100vh - 24px);
    padding: 20px 22px 22px;
    border: 1px solid var(--map-chrome-border, rgba(0, 0, 0, 0.3));
    border-radius: 12px;
    background: var(--map-chrome-bg, #ffffff);
    color: var(--map-chrome-text, #1f1f1f);
    font: 14px/1.5 'IBM Plex Sans', 'Segoe UI', system-ui, sans-serif;
    overflow: auto;
}

#aboutDialog::backdrop {
    background: rgba(0, 0, 0, 0.55);
}

#aboutDialog h2 {
    margin: 0 0 8px;
    font-size: 18px;
}

#aboutDialog h3 {
    margin: 18px 0 6px;
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    opacity: 0.75;
}

#aboutDialog p,
#aboutDialog ul {
    margin: 6px 0;
}

#aboutDialog ul {
    padding-left: 20px;
}

#aboutDialog a {
    color: inherit;
    text-decoration: underline;
}

.about-close {
    position: absolute;
    top: 8px;
    right: 10px;
    border: 0;
    background: transparent;
    color: inherit;
    font-size: 26px;
    line-height: 1;
    cursor: pointer;
    padding: 4px 8px;
}

.about-warning {
    padding: 10px 12px;
    border-radius: 8px;
    background: rgba(194, 59, 59, 0.14);
    border: 1px solid rgba(194, 59, 59, 0.5);
}

@media (max-width: 560px) {
    #webBar {
        flex-direction: column;
        align-items: stretch;
        gap: 6px;
    }

    #webChrome {
        justify-content: center;
    }

    #webStatus .label {
        display: none;
    }

    #webNotice {
        font-size: 11px;
    }
}

@media (prefers-reduced-motion: reduce) {
    * {
        scroll-behavior: auto !important;
    }
}

.no-fullscreen .leaflet-control-fullscreen {
    display: none;
}

#threatSheet {
    position: fixed;
    left: 8px;
    right: 8px;
    bottom: calc(var(--web-bar-height, 44px) + 8px);
    z-index: 1050;
    max-width: 440px;
    margin: 0 auto;
    padding: 12px 52px 12px 14px;
    border-radius: 10px;
    background: var(--map-chrome-bg, #f3f3f3);
    color: var(--map-chrome-text, #1f1f1f);
    border: 1px solid var(--map-chrome-border, rgba(0, 0, 0, 0.2));
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.3);
    font-family: 'IBM Plex Sans', 'Segoe UI', system-ui, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    overflow-wrap: anywhere;
}

#threatSheetBody strong {
    font-size: 15px;
}

#threatSheetBody small {
    opacity: 0.75;
}

#threatClose {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 36px;
    height: 36px;
    padding: 0;
    font-size: 22px;
    line-height: 1;
}

@media (min-width: 561px) {
    #threatSheet {
        left: 50%;
        right: auto;
        width: 440px;
        transform: translateX(-50%);
    }
}

@media (max-height: 500px) {
    #webBar {
        gap: 10px;
        padding-top: 4px;
        padding-bottom: calc(4px + env(safe-area-inset-bottom, 0px));
    }

    #webNotice {
        display: none;
    }

    #webCredits {
        font-size: 10px;
        line-height: 1.3;
        text-align: right;
    }

    #webLanguage button,
    .web-chip {
        padding: 6px 10px;
        font-size: 12px;
    }

    #threatSheet {
        left: auto;
        right: 8px;
        width: min(320px, 46vw);
        max-width: none;
        max-height: calc(100% - var(--web-bar-height, 44px) - 16px);
        margin: 0;
        transform: none;
        overflow-y: auto;
        padding: 6px 46px 6px 10px;
        font-size: 13px;
        line-height: 1.35;
    }

    #threatSheetBody strong {
        font-size: 14px;
    }

    #threatClose {
        top: 4px;
        right: 4px;
        width: 32px;
        height: 32px;
    }
}

@media (pointer: coarse) {
    .leaflet-control-fullscreen {
        display: none;
    }
}

body {
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
}

#aboutDialog,
#aboutDialog * {
    -webkit-user-select: text;
    user-select: text;
    -webkit-touch-callout: default;
}

#updateBanner {
    position: fixed;
    z-index: 1200;
    left: 12px;
    right: 12px;
    bottom: calc(var(--web-bar-height, 0px) + 10px);
    margin: 0 auto;
    max-width: 420px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 12px 10px 16px;
    border-radius: 12px;
    background: var(--map-chrome-bg, #ffffff);
    color: var(--map-chrome-text, #1f1f1f);
    box-shadow: 0 0 0 1px var(--map-chrome-border, rgba(0, 0, 0, 0.25)), 0 6px 20px rgba(0, 0, 0, 0.25);
    font: 600 14px 'IBM Plex Sans', 'Segoe UI', system-ui, sans-serif;
}

#updateBanner button {
    flex: none;
    padding: 8px 14px;
    border: 0;
    border-radius: 8px;
    background: #2563eb;
    color: #ffffff;
    font: inherit;
    cursor: pointer;
}
