* {
    box-sizing: border-box;
}

html, body {
    overscroll-behavior-y: none;
    user-select: none;
}
body {
     overflow-y: scroll;
     touch-action: none;
}

body {
    --c-bg-primary: white;
    --c-bg-secondary: #f6f6f6;
    --c-bg-secondary-transparent: rgb(250, 250, 250, .85);
    --c-bg-secondary-active: #FFF;
    --c-fg-primary: black;
    --c-fg-secondary: #333;
    --c-border-secondary: #CCC;
    --c-fg-accent: rgb(27, 92, 233);
    --c-fg-grey: #999;

    --info-panel-margin: .7rem;
    --ui-hide-time: .2s;
}

body.dark {
    --c-bg-primary: black;
    --c-bg-secondary-transparent: rgb(34, 34, 34, .9);
    --c-bg-secondary: #191919;
    --c-bg-secondary-active: #333;
    --c-fg-primary: white;
    --c-fg-secondary: #EEE;
    --c-border-secondary: #555;
    --c-fg-accent: rgb(130, 190, 240);
    --c-fg-grey: rgb(179, 179, 179);
}

body {
    margin: 0;
    padding: 0;
    height: 100vh;
    width: 100vw;
    font-family: "Helvetica Neue", Arial, Helvetica, sans-serif;
    display: flex;
    flex-direction: column;
    background-color: var(--c-bg-secondary);
    color: var(--c-fg-primary);
    /* among other things, prevent scrolling in mobile Chrome, which handles the title height bar weirdly */
    overflow: hidden;
}

a[href] {
    color: var(--c-fg-accent);
    text-decoration: none;
}

a[href]:hover {
    text-decoration: underline;
}

[sidebarjs-container] {
    background-color: var(--c-bg-secondary);
}

[sidebarjs-container]>section {
    padding: .5rem .5rem;
}

@media (min-width: 1025px) {
    [sidebarjs-content] {
        width: -webkit-calc(100% - 300px);
        width: calc(100% - 250px);
    }

    [sidebarjs].sidebarjs--responsive {
        width: 250px;
    }
}

.map {
    flex: 1;
}

.provider-section {
    margin-top: .5rem
}

.provider-section-header {
    margin-bottom: .2rem;
    font-size: .8rem;
    font-weight: bold;
    text-transform: uppercase;
    color: var(--c-fg-secondary);
    cursor: pointer;
}

.provider-group-toggle img {
    cursor: pointer;
    display: inline-block;
    height: 2rem;
    margin-right: .5rem;
    max-width: 2rem;
    font-size: .7rem;
    text-align: center;
    word-break: break-all;
    overflow: hidden;
}


.provider-group-toggle:not(.active) {
    opacity: .5;
}

.provider-group-toggle.loading {
    animation: fade .6s infinite;
}

@keyframes fade {
    0% {
        opacity: .1;
    }

    50% {
        opacity: .8;
    }
}

html,
body {
    background-color: var(--c-bg-primary);
}

.maplibregl-popup-close-button {
    display: none;
}

.maplibregl-popup-content {
    background-color: var(--c-bg-secondary);
    padding: .3rem .4rem;
}

.maplibregl-popup-anchor-bottom .maplibregl-popup-tip {
    border-top-color: var(--c-bg-secondary);
}

.maplibregl-popup:hover .maplibregl-popup-content {
    background-color: var(--c-bg-secondary-active);
}

.maplibregl-popup:hover .maplibregl-popup-tip {
    border-top-color: var(--c-bg-secondary-active);
}

.maplibregl-ctrl-group {
    background-color: var(--c-bg-secondary);
}

.maplibregl-ctrl button .maplibregl-ctrl-icon {
    color: var(--c-fg-secondary);
}

.maplibregl-ctrl button:not(:disabled):hover {
    background-color: var(--c-bg-secondary-active);
}

/*
    DARK THEME
*/
.dark .maplibregl-ctrl button .maplibregl-ctrl-icon {
    filter: invert(1) hue-rotate(180deg);
}

#navigation-sidebar {
    position: absolute;
    top: 1rem;
    left: 1rem;
    max-height: calc(100vh - 2rem);
    /* height: calc(100vh - 2rem); */
    
    min-width: 100px;
    opacity: 1;
    display: flex;
    flex-direction: column;

    transition: opacity var(--ui-hide-time) ease;
    opacity: 1;
}

#panel-container {
    flex: 1;
    display: flex;
    overflow-y: auto;
    overflow-x: hidden;
}

.info-panel:not(.hidden) {
    background-color: var(--c-bg-secondary-transparent);
    box-shadow: rgba(0, 0, 0, .3) 0 0 5px;
}

#providers {
    flex: 1;
}

.lucide {
    vertical-align: middle;
}

#panel-container .info-panel {
    width: 100%;
    flex: 1;
    overflow-y: auto;
    height: 100%;
    transition: height .3s ease;
}

.sheet .info-panel {
    background-color: var(--c-bg-secondary);
}

.hiding.info-panel {
    opacity: 0;
}

.hidden.info-panel {
    display: none;
}

.info-panel> :not(.info-panel-img):not(.info-panel-wide) {
    margin: var(--info-panel-margin);
}

.info-panel h2 img {
    vertical-align: middle;
}

/*
.info-panel > .info-panel-close {
    top: -.5rem;
    right: -28px;
    position: absolute;
    width: 20px;
    height: 20px;
    background: var(--c-bg-secondary-transparent);
    text-align: center;
    padding-top: 2px;
}*/

.info-panel .vehicle {
    margin: .3rem;
    background-color: var(--c-bg-secondary-transparent);
    padding: .5rem;
    display: flex;
    color: inherit;
    text-decoration: none !important;
}

.info-panel .vehicle[href]:hover,
.info-panel .vehicle[href]:focus {
    background-color: var(--c-bg-secondary);
}

.info-panel .vehicle .deeplink-ico {
    display: flex;
    align-items: center;
}

.info-panel .vehicle .flex-main {
    flex: 1;
    padding: 0 .5rem;
}

.info-panel .vehicle .flex-additional-data {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
}

.info-panel .vehicle .flex-additional-data>div {
    display: flex;
    align-items: center;
    justify-content: center;
}

.info-panel .vehicle .vehicle-image {
    width: 5rem;
    object-fit: contain;
}

.info-panel-img {
    max-height: 150px;
    margin-bottom: var(--info-panel-margin);
}

.info-panel-img>img {
    width: 100%;
    max-height: 150px;
    object-fit: cover;
    object-position: bottom;
}

.line {
    color: white;
    background: red;
    border-radius: .3rem;
    padding: 3px 6px;
}

.line:not(:last-child) {
    margin-right: .3rem;
}

.info-panel .lines {
    padding: .7rem 0;
}

.info-panel .itinerary {
    cursor: pointer;
    margin: 0 !important;
    padding: var(--info-panel-margin);
}

.info-panel .itinerary:hover,
.info-panel .itinerary:focus {
    background-color: var(--c-bg-secondary-transparent);
}

.itinerary .icon {
    height: 1rem;
}

.itinerary-step {
    display: block;
    margin: .3em 0;
    padding-left: .2em;
}

.sharing-chip {
    background-color: var(--c-bg-primary);
    padding: .2em .2em;
    border-radius: 5px;
}

.sharing-chip img {
    height: 1em;
    margin-bottom: -.1rem;
}

button {
    background-color: var(--c-bg-primary);
    color: var(--c-fg-secondary);
    padding: .2rem;
    outline: none;
    border: none;
}

button:hover,
button:focus,
button:active {
    background-color: var(--c-bg-secondary);
    color: var(--c-fg-secondary);
}

input,
select {
    background-color: var(--c-bg-secondary);
    color: var(--c-fg-secondary);
    border: none;
}

#search {
    background-color: var(--c-bg-secondary-transparent);
}

.search-bar {
    display: flex;
}

.search-bar input[type=text] {
    flex: 1;
    font-size: 1.2rem;
    background-color: var(--c-bg-secondary);
    color: var(--c-fg-secondary);
    border: none;
    outline: none;
    padding: .4rem;
}

.search-bar button {
    padding: .1rem .8rem;
}

.search-bar:first-child:last-child .clear-search-btn {
    display: none;
}

/* We don't have multi-point routing yet */
.search-bar:first-child .clear-search-btn {
    display: none;
}

.search-bar .add-search-btn {
    display: none;
}

.search-bar .drag-handle {
    padding-top: .4rem;
    padding-left: .4rem;
    padding-right: .4rem;
    cursor: grab;
    display: none;
}

#search-results {
    overflow-y: auto;
}

#search-results>* {
    padding: .4rem;
    cursor: pointer;
}

#search-results>*:hover,
#search-results>*:focus {
    background-color: var(--c-bg-secondary-transparent);
}

#nav-options {
    background-color: var(--c-bg-secondary);
    padding: 5px 0;
    display: flex;
    justify-content: space-around;
}

#transit-type {
    flex: 0;
    max-width: 50%;
}

#nav-options[hidden] {
    display: none;
}

.placed-marker {
    height: 24px;
    width: 24px;
    background-color: var(--c-bg-secondary-transparent);
    border-radius: 50%;
    text-align: center;
}

.legs {
    white-space: nowrap;
    display: flex;
    flex-direction: row;
    /* wrap */
    flex-wrap: wrap;
    max-height: 100%;
    overflow-y: auto;
    overflow-x: hidden;
    margin: .3rem 0;
}

.leg {
    height: 1rem;
    display: inline-block;
    text-align: center;
    font-size: .8rem;
    overflow: hidden;
    background-color: rgb(200, 200, 200, .5);
}

.leg-GAP {
    background-color: transparent;
    box-sizing: border-box;
}

.leg.leg-GAP:first-child {
    display: none;
}

.legs-full {
    transition: max-height .3s ease;
    max-height: 0;
    overflow-y: hidden;
    font-size: .9em;
    color: var(--c-fg-secondary);
}

.expanded .legs-full {
    max-height: 100vh;
}

.maplibregl-ctrl button .maplibregl-ctrl-icon,
.maplibregl-ctrl button .maplibregl-ctrl-icon {
    line-height: 29px;
    /* This is inverted in dark mode */
    color: black;
    font-weight: bold;
}


/* MIXINS */
/* TOGGLE STYLING */
.toggle {
    box-sizing: border-box;
    display: flex;
}

.toggle input {
    width: 0;
    height: 0;
    position: absolute;
    left: -9999px;
}

.toggle input+label {
    flex: 1;
    color: var(--c-fg-secondary);

    padding: 0.75rem 2rem;

    line-height: 140%;
    font-weight: 600;
    text-align: center;

    transition: border-color 0.15s ease-out, color 0.25s ease-out, background-color 0.15s ease-out, box-shadow 0.15s ease-out;


    border-bottom: .3rem transparent solid;
}

.toggle input:checked+label {
    background-color: var(--c-bg-primary);
    color: var(--c-fg-primary);

    z-index: 1;
    border-bottom-color: var(--c-fg-secondary);
}

.toggle input+label:hover {
    border-bottom-color: var(--c-fg-primary);
}

.passed {
    font-size: smaller;
    color: #999;
    text-decoration: line-through;
}

.detail-row {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    width: 100%;
    /* fit inside parent */
    box-sizing: border-box;

}

/* banded rows */
.detail-row:nth-child(even) {
    background-color: var(--c-bg-secondary-transparent);
}

.detail-stop-name {
    margin: .2rem;
    font-weight: bold;
    display: flex;
    flex-direction: row;
    align-items: center;
}

.detail-route-name {
    margin: .2rem;
}

.detail-stop-time {
    margin: .2rem;
    text-align: right;
}

/*
    loader
*/
.lds-facebook {
    position: relative;
    width: 80px;
    height: 80px;
    margin: 0 auto;
}

.lds-facebook div {
    display: inline-block;
    position: absolute;
    left: 4px;
    width: 12px;
    background: #fff9;
    animation: lds-facebook 1.2s cubic-bezier(0, 0.5, 0.5, 1) infinite;
}

.lds-facebook div:nth-child(1) {
    left: 4px;
    animation-delay: -0.24s;
}

.lds-facebook div:nth-child(2) {
    left: 24px;
    animation-delay: -0.12s;
}

.lds-facebook div:nth-child(3) {
    left: 45px;
    animation-delay: 0;
}

.center-badge {
    font-size: .75rem;
    width: 1.5rem;
    border-radius: 10%;
    color: white;
    /* TODO: maybe yellow would be better? */
    background-color: var(--c-fg-accent);
    font-weight: bold;
    margin-right: .5rem;
    padding: .2rem;
    /* dont allow text wrapping */
    white-space: nowrap;
}

.arrivals-route {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.arrivals-route-first-row {
    width: 100%;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
}

.route-number {
    font-size: 1.5rem;
    font-weight: bold;
    width: 3rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10%;
    color: white;
    text-align: center;
}

.route-name {
    text-align: center;
}

.route-first-arrival {
    display: flex;
    flex-direction: row;
    font-size: 1.25rem;
    align-items: center;
    justify-content: center;
    margin-right: 1rem;
}

.route-first-arrival>svg {
    height: 1em;
    fill: currentColor;
}

.arrivals-route-second-row {
    margin-top: .25rem;
    width: 100%;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-evenly;
}

.arrivals-route-second-row>.route-second-arrival {
    font-size: .75rem;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
}

.arrivals-route-second-row>.route-second-arrival>svg {
    height: 1em;
    fill: currentColor;
}

.bus-arrival {
    width: auto;
    display: flex;
    flex-direction: column;
    margin: 0;
    padding: 0;
}

.bus-arrival-stop {
    display: flex;
    flex-direction: row;
    align-items: center;
}

.bus-arrival-stop-icon {
    flex: 0;
    height: auto;
    padding: 0;
    margin: -.2rem;
}

.bus-arrival-stop-icon img {
    height: 2rem;
    padding: 0;
    margin: 0;
}

.bus-arrival-stop-name {
    flex: 1;
    font-size: 1rem;
    margin-left: .5rem;
}

.bus-arrival-stop-eta {
    flex: 0;
    font-size: 1rem;
    font-weight: bold;
    margin-left: .5rem;
    white-space: nowrap;
}

.bus-info {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    margin: 0;
    padding: 0;
}

.bus-info-item {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    margin: 0;
    padding: 0;
}

.bus-info-item-label {
    font-weight: bold;
    flex: 0;
    white-space: nowrap;
}

.bus-info-item-value {
    flex: 1;
    text-align: right;
}

.itinerary-entry {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    margin: 0;
    padding: 0;
}

.itinerary-entry>svg {
    height: .8rem;
    fill: currentColor;
}

.bus-wrapper {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    vertical-align: center;
    margin: 0;
    padding: .05rem .25rem;
    background-color: var(--c-bg-primary);
    color: var(--c-fg-primary);
    border-radius: 10%;
    font-size: .9rem
}

.bus-wrapper>svg {
    height: .8rem;
    fill: currentColor;
}

.bus-wrapper.inverse {
    color: var(--c-bg-primary);
}

.itinerary-entry-text {
    font-size: .9rem;
    color: var(--c-fg-secondary);
}

.leg-join-icon {
    color: var(--c-fg-secondary);
}

.times {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    margin: 0;
    padding: 0;
    position: relative;
}

.times>.itinerary-entry {
    flex: 0;
    /* wrap no */
    white-space: nowrap;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center
}

.times>.times-line {
    flex: 1;
    /* make a line in the center */
    border-bottom: 1px solid var(--c-fg-primary);
    margin: 0 .5rem;
}


@keyframes lds-facebook {
    0% {
        top: 4px;
        height: 64px;
    }

    50%,
    100% {
        top: 24px;
        height: 24px;
    }
}

.load-more-itineraries {
    display: block;
    margin: 0 auto;
}

#open-sidebar {
    display: none;
}

@media only screen and (max-width: 48em) {
    .toggle input+label {
        padding: 0.75rem 0.25rem;
        flex: 0 0 50%;
        display: flex;
        justify-content: center;
        align-items: center;
    }

    #navigation-sidebar {
        left: 0;
        top: 0;
        width: 100vw;
        height: 100vh;
        box-sizing: border-box;
        /* transition: background-color .3s ease; */
    }

    /* #navigation-sidebar.hidden {
        height: auto;
        background-color: transparent;
    } */

    .info-panel {
        padding: .5rem;
    }

    #search {
        margin: 10px;
        margin-bottom: 0;
        margin-right: 49px;

        /* match the map UI since it's so close to it */
        box-shadow: 0 0 0 2px rgba(0,0,0,.1);
    }

    #open-sidebar {
        display: unset;
    }
}

/*

    UI HIDING

*/

#navigation-sidebar,
.maplibregl-control-container {
    transition: opacity var(--ui-hide-time) ease;
}

.ui-hiding #navigation-sidebar,
.ui-hiding .maplibregl-control-container {
    opacity: 0;
}

.ui-hidden #navigation-sidebar,
.ui-hidden .maplibregl-control-container {
    display: none;
}


/*

    BOTTOM SHEET

*/

/* Copyright (c) 2022 Ivan Teplov */

.sheet {
    pointer-events: none;
    --default-transitions: transform 0.5s, border-radius 0.5s;

    position: fixed;
    
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 2;
    visibility: visible;
    transition: opacity 0.5s, visibility 0.5s;

    z-index: 99999;
}

.sheet[aria-hidden="true"] {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.sheet .contents {
    min-width: 100vw;
    max-height: 100vh;
    pointer-events: all;
    border-radius: 1rem 1rem 0 0;
    overflow-y: hidden;
    background: var(--c-bg-secondary-transparent);
    transition: var(--default-transitions);
    transform: translateY(0);
}

.sheet .contents:not(.not-selectable) {
    transition: var(--default-transitions), height 0.5s;
}

.sheet .contents.fullscreen {
    border-radius: 0;
    /* only allow scrolling when fullscreen */
    overflow-y: auto;
}

.sheet[aria-hidden="true"] .contents {
    transform: translateY(100%);
}

.sheet .controls {
    display: flex;
}

.sheet .draggable-area {
    width: 3rem;
    margin: auto;
    padding: 1rem;
    cursor: grab;
    z-index: 10000;
}

.sheet .draggable-thumb {
    width: inherit;
    height: 0.25rem;
    background: var(--c-bg-secondary);
    border-radius: 0.125rem;
}

.sheet .close-sheet {
    border: none;
    padding: 0.7rem;
    z-index: 1000;
    cursor: pointer;
    display: none;
}

.sheet .body {
    margin-top: -2.5rem;
    min-height: 100%;
    box-sizing: border-box;
}

.toast {
    position: absolute;
    bottom: 0;
    background-color: var(--c-bg-secondary);
    padding: 1rem .5rem;
    width: 100%;
    z-index: 99;
}

.toast .close {
    float: right;
    line-height: 1rem;
    font-size: 1.5rem;
    opacity: .7;
}