/*
    Copyright (C) 2019 Nicolas Bertin

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <https://www.gnu.org/licenses/>.
*/

@CHARSET "ISO-8859-1";

/* Disable bootstrap style */
* {
    -webkit-box-sizing: content-box;
            box-sizing: content-box;
}

/* Custom CSS */
.leaflet-control-layers-toggle {
    background-size: 20px 20px;
    width          : 26px;
    height         : 26px;
}

body {
    color: #444;
}

.map-action-label {
    position: absolute;
    top: 50%;
    left: calc(100% + 8px);
    transform: translateY(-50%);
    width: max-content;
    max-width: calc(100vw - 64px);
    padding: 4px 8px;
    border-radius: 4px;
    background: #17385f;
    color: #fff;
    font-size: 16px;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.map-action:hover > .map-action-label,
.map-action > a:focus-visible + .map-action-label {
    visibility: visible;
    opacity: 1;
    transition: opacity 100ms ease-out 70ms;
}

@media (prefers-reduced-motion: reduce) {
    .map-action:hover > .map-action-label,
    .map-action > a:focus-visible + .map-action-label {
        transition: none;
    }
}

/* Header and footer */
#header, #footer {
    min-width : 1024px;
    position  : fixed;
    display   : block;
    width     : 100%;
    background: #28649c;
    z-index   : 9;
}

#header {
    background    : #0f59c1;
    top           : 0px;
    display       : flex;
    align-items   : center;
    justify-content: space-between;
    min-width     : 0;
    font-size     : 16px;
    vertical-align: middle;
    height        : 48px;
    line-height   : 48px;
}

#footer {
    bottom        : 0px;
    font-size     : 12px;
    text-align    : center;
    vertical-align: middle;
    height        : 20px;
    line-height   : 20px;
}

/* Left (emulator) and right (social/fullscreen) menus */
#menu-left, #menu-right {
    display: flex;
    align-items: center;
}

#menu-left {
    position  : relative;
    padding   : 0 0 0 8px;
    margin    : 0;
    z-index   : 5001;
    text-align: left;
}

#menu-left li {
    padding: 0 8px 0 8px;
}

#menu-right {
    position  : relative;
    padding   : 0 8px 0 0;
    margin    : 0;
    z-index   : 5001;
    text-align: right;
}

#menu-right li {
    padding: 0 8px 0 8px;
}

#header .menu > li > a > .fa,
#header .menu > li > button > .fa {
    font-size: 20px;
}

#id-webwigo-about .modal-title {
    font: inherit;
}

li > a {
    color: #444;
}

.menu-action {
    background: transparent;
    border: 0;
    color: inherit;
    line-height: inherit;
    padding: 0;
}

.menu li .menu-action:hover:not(:disabled) {
    color: #fff;
}

.menu-action.disabled {
    color: #3083ca;
}

.menu li {
    display: inline-block;
}

.disabled {
   pointer-events: none;
   cursor        : default;
   color         : #3083ca;
}

.menu li a {
    text-decoration: none;
}

.menu li a:hover {
    color: #ffffff;
}


/* Toasters */
.tab-toaster {
    position             : fixed;
    top                  : 48px;
    left                 : 138px;
    color                : #444;
    font-size            : 16px;
    line-height          : initial;
    background-color     : #28649c;
    -webkit-border-radius: 0 0 16px 16px;
    border-radius        : 0 0 16px 16px;
    display              : none;
}

#id-tab-gpsr-toaster {
    width                : 320px;
    padding              : 8px 16px 8px 16px;
    z-index              : 5000;
}

#id-tab-load-toaster {
    width                : 512px;
    padding              : 16px 16px 0 16px;
    z-index              : 5000;
}

#id-tab-info-toaster {
    width                : 512px;
    padding              : 16px 16px 16px 16px;
    z-index              : 5000;
}

.info-label {
    display  : table-cell;
    width    : 96px;
    font-size: 16px;
}

.info-value {
    display  : table-cell;
    font-size: 16px;
}

#id-tab-load-toaster, #id-tab-info-toaster {
    max-height: calc(100dvh - 64px);
    overflow: auto;
    overflow-wrap: anywhere;
}

#header:has(#id-tab-load-toaster:not([style*="display: none"]):not(:empty)),
#header:has(#id-tab-info-toaster[style*="display: block"]) {
    z-index: 1000;
}

/* Dialogs */
.vdlg-margin-top {
    max-width: calc(100% - 24px);
}

@media (max-width: 700px) {
    #header .menu > li > a > .fa,
    #header .menu > li > button > .fa {
        font-size: 16px;
    }

    #menu-left, #menu-right {
        white-space: nowrap;
    }

    #menu-left li, #menu-right li {
        padding: 0 3px;
    }

    #id-tab-gpsr-toaster, #id-tab-load-toaster, #id-tab-info-toaster {
        box-sizing: border-box;
        left: 8px;
        max-width: calc(100% - 16px);
    }

    #id-tab-gpsr-toaster {
        padding-left: 8px;
        padding-right: 8px;
    }
}

/* Slides */
.section {
    text-align: center;
}

.map-page {
    text-align: left;
    width     : 100%;
    height    : 100%;
}

.std-page {
}

.std-page h1 {
    margin    : 0 auto;
    font-size : 4em;
    text-align: center;
}

#header, .tab-toaster, #header .menu > li > a {
    color: #fff;
}

#header .menu-action:disabled {
    opacity: .55;
}

#header .menu-action:focus-visible, #header a:focus-visible {
    outline: 2px solid currentColor;
    outline-offset: -2px;
}

#header .menu > li {
    display: flex;
    align-items: center;
    height: 48px;
}

#header .menu > li > button, #header .menu > li > a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    min-width: 44px;
    height: 48px;
    line-height: 20px;
}

#header:has(.toolbar-dropdown.open) {
    z-index: 1000;
}

#header:has(.toolbar-dropdown.open) #id-tab-gpsr-toaster {
    visibility: hidden;
}

#header .toolbar-dropdown > .dropdown-toggle {
    position: relative;
    z-index: 1001;
}

#header .toolbar-dropdown .dropdown-menu {
    min-width: 178px;
    color: #27384a;
}

#id-builder-tools ~ .dropdown-menu {
    width: 224px;
}

#header .toolbar-dropdown .dropdown-menu li {
    display: block;
    padding: 0;
}

#header .toolbar-dropdown .dropdown-menu .menu-action,
#header .toolbar-dropdown .dropdown-menu a {
    display: flex;
    align-items: center;
    box-sizing: border-box;
    color: inherit;
    line-height: 20px;
    width: 100%;
    min-height: 44px;
    padding: 0 12px;
    text-align: left;
}

#header .toolbar-dropdown .dropdown-menu button[aria-pressed] {
    justify-content: space-between;
    gap: 16px;
}

[aria-pressed="true"] .toggle-off,
[aria-pressed="false"] .toggle-on {
    display: none;
}

#header .toolbar-dropdown .dropdown-menu .menu-action:hover:not(:disabled),
#header .toolbar-dropdown .dropdown-menu a:hover {
    color: #163c63;
    background: #e8f1fa;
}

#id-player-status {
    position: fixed;
    z-index: 10;
    left: 54px;
    top: 57px;
    max-width: calc(100% - 90px);
    background: #fff;
    color: #27384a;
    border-radius: 5px;
    box-shadow: 0 1px 6px #0004;
    padding: 8px 12px;
}

.map-page {
    box-sizing: border-box;
    padding: 0;
}

#id-tab-gpsr-toaster {
    pointer-events: none;
    width: auto;
}

#id-tab-gpsr-toaster button, #id-tab-gpsr-toaster .gps-accuracy {
    pointer-events: auto;
}

.mobile-menu-icon.fa, #header .menu > .return-to-map { display: none; }
body:has(:is(#section-code,#section-data).active) #header .menu > .return-to-map { display: flex; }

@media (max-width: 700px), (max-height: 480px) and (pointer: coarse) {
    #header { display: block; }

    #menu-left {
        display: grid;
        grid-auto-columns: minmax(0, 1fr);
        grid-auto-flow: column;
        padding: 0;
    }

    #menu-right { display: none; }

    #tools-label, #id-builder-tools .caret { display: none; }
    #header #id-builder-tools .mobile-menu-icon { display: inline-block; font-size: 20px; }
    #header .menu > li { min-width: 0; padding: 0; }
    #header .menu > li > button, #header .menu > li > a {
        box-sizing: border-box;
        width: 100%;
        height: 48px;
        padding: 0;
    }

    #header #id-menu1-separator, #header #id-fullscreen-btn {
        display: none !important;
    }

    #id-tab-gpsr-toaster { left: 48px; }
    #id-builder-tools ~ .dropdown-menu { left: auto; right: 0; }
}


@media (min-width: 480px) and (max-height: 480px) and (pointer: coarse) {
    #id-builder-tools ~ .dropdown-menu { width: 400px; }
    #header .toolbar-dropdown.open > #id-builder-tools ~ .dropdown-menu {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

#header .toolbar-dropdown .dropdown-menu {
    box-sizing: border-box;
    margin-top: 0;
    max-height: calc(100vh - 48px);
    max-height: calc(100dvh - 48px);
    overflow-y: auto;
}

@media (max-width: 700px) {
    #id-emap .leaflet-bottom.leaflet-right {
        top: 68px;
        bottom: auto;
    }

    #id-emap .leaflet-control-attribution {
        margin-top: 0;
    }
}

#id-webwigo-about,
.console-dialog.ui-dialog {
    position: fixed !important;
    top: auto !important;
    left: 0 !important;
    bottom: var(--webwigo-bottom-inset, 0px);
    width: 100% !important;
    max-width: none;
    height: var(--webwigo-visible-height, 100dvh) !important;
    box-sizing: border-box;
    margin: 0;
}

#id-webwigo-about { padding: 0 !important; }
#id-webwigo-about .modal-dialog { width: 100%; height: 100%; margin: 0; }
#id-webwigo-about .modal-content {
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    height: 100%;
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
    border: 0;
    border-radius: 0;
}
#id-webwigo-about .modal-body { overflow-y: auto; }
.console-dialog.ui-dialog {
    display: flex;
    flex-direction: column;
    border-radius: 0;
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
.console-dialog .ui-dialog-titlebar { flex: none; min-height: 36px; }
.console-dialog .ui-dialog-titlebar-close { width: 40px; height: 40px; margin-top: -20px; }
.console-dialog #id-term { flex: 1; min-height: 0 !important; max-height: none !important; overflow: auto; }

.data-file {
    display: inline-block;
    width: 12%;
    vertical-align: top;
}
.data-file p { margin: 0; font-size: 16px; overflow-wrap: anywhere; }
@media (max-width: 700px) {
    #id-data .row {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(90px, 1fr));
        gap: 8px;
        margin: 0 0 8px;
    }
    #id-data .row::before, #id-data .row::after { display: none; }
    #id-data .data-file { width: auto; }
    #id-data .thumbnail { margin-bottom: 0; }
}

body, .btn, .form-control, .dropdown-menu, .ui-widget, .modal { font-size: 16px; }
.btn, .form-control { box-sizing: border-box; min-height: 44px; }
.leaflet-container .leaflet-bar a { width: 44px; height: 44px; line-height: 44px; }
