/**
 * PRK-3 - Mobile parking plan: pinch zoom + bottom sheet with place detail.
 *
 * Everything here is scoped under .parking-plan-mobile / .parking-sheet. Both classes are added
 * at runtime by assets/js/parkingPlanMobile.js and only on touch devices, so on desktop none of
 * these selectors can ever match.
 *
 * NOTE: this file is linked in head_css_js.tpl right after new22.css, which is BEFORE the
 * jquery-modal stylesheet. Any future rule targeting .modal with specificity (0,1,0) would lose
 * to jquery-modal - keep overrides scoped or raise their specificity.
 *
 * @Author: Sofie <sofie@foxprofi.cz>
 */

/* ------------------------------------------------------------------ plan viewport */

.parking-plan-mobile {
    overflow: visible;
}

/*
 * .jquery-modal .modal .parking_map sets "margin: 50px auto 0 auto" (base.less:2054-2056),
 * which would break the stage coordinate math used for pinch anchoring. !important is needed
 * because that selector has specificity (0,3,0).
 */
.parking-plan-mobile .parking_map {
    margin: 0 !important;
    transform-origin: 0 0;
}

/* .jquery-modal .modal sets text-align: center, which would leak into the frame */
.parking-plan-mobile .parking-plan-frame {
    position: relative;
    text-align: left;
}

/*
 * No -webkit-overflow-scrolling: touch here. It is a no-op on iOS 13+ and combined with a
 * transformed child it is a known source of blank tiles and unreliable scrollLeft writes.
 */
.parking-plan-mobile .parking-plan-viewport {
    position: relative;
    overflow: auto;
    touch-action: pan-x pan-y;
}

.parking-plan-mobile .parking-plan-stage {
    position: relative;
}

/*
 * Mobile browsers emulate :hover on tap, which is how the bubble shows up today.
 * The bottom sheet replaces it. Specificity (0,5,0) beats .parking_map .stani:hover .detail (0,4,0).
 */
.parking-plan-mobile .parking_map .stani:hover .detail {
    display: none;
}

/* ------------------------------------------------------------------ zoom controls */

/*
 * PAR-124: the controls sit in their own strip above the plan, not over it. They stay in
 * .parking-plan-frame and outside .parking-plan-viewport, so they still cannot scroll away.
 * text-align beats the inherited "text-align: left" of .parking-plan-frame (3.8).
 */
.parking-plan-mobile .parking-plan-zoom {
    margin-bottom: 6px;
    text-align: right;
}

/*
 * inline-block, not flex: the row has to hold on the old Android WebViews this project still
 * serves. The buttons are appended without whitespace between them, so the gap is a margin.
 */
.parking-plan-mobile .parking-plan-zoom button {
    display: inline-block;
    vertical-align: top;
    width: 40px;
    height: 40px;
    margin-left: 6px;
    padding: 0;
    border: 1px solid #c4c4c4;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.92);
    color: #0859a9;
    font-size: 17px;
    line-height: 38px;
    text-align: center;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

/*
 * PAR-124: the icon has to take the colour from its button. Without this the minus came out grey,
 * because base.css sets ".fa-minus { color: #777777; }" globally for the data tables - a rule that
 * matches the <i> itself and therefore beats the colour inherited from the button.
 */
.parking-plan-mobile .parking-plan-zoom button .fa {
    color: inherit;
}

.parking-plan-mobile .parking-plan-zoom button[disabled] {
    opacity: 0.4;
}

/* ------------------------------------------------------------------ bottom sheet */

.parking-sheet {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10000;
    pointer-events: none;
}

.parking-sheet.is-open {
    pointer-events: auto;
}

.parking-sheet__panel {
    position: relative;
    /*
     * The vh/svh pair is mandatory: older Android does not know svh and would drop the whole
     * declaration, leaving the sheet without any height limit.
     */
    max-height: 50vh;
    max-height: 50svh;
    /*
     * The panel itself must not scroll. The close button is absolutely positioned against it and
     * would scroll away with the content once a tall card (a shared place in landscape) overflows.
     * Scrolling happens in .parking-sheet__body instead, so the button and the action row stay put.
     */
    display: flex;
    flex-direction: column;
    overflow: visible;
    /*
     * The top padding makes room for the close button and belongs to the panel, not to the
     * scrolled body - inside the body it would scroll away and the blue header would slide
     * underneath the button.
     */
    padding: 40px 12px 14px;
    background: #fff;
    border-radius: 12px 12px 0 0;
    box-shadow: 0 -2px 16px rgba(0, 0, 0, 0.35);
    transform: translateY(100%);
    transition: transform 200ms ease-out;
}

.parking-sheet.is-open .parking-sheet__panel {
    transform: translateY(0);
}

@media (prefers-reduced-motion: reduce) {
    .parking-sheet__panel {
        transition: none;
    }
}

.parking-sheet__close {
    position: absolute;
    top: 4px;
    right: 6px;
    z-index: 2;
    width: 38px;
    height: 38px;
    padding: 0;
    border: 0;
    background: transparent;
    color: #666;
    font-size: 28px;
    line-height: 1;
}

.parking-sheet__body {
    overflow-y: auto;
    min-height: 0; /* required so a flex child may actually shrink and scroll */
}

.parking-sheet__actions {
    margin-top: 12px;
}

.parking-sheet__actions .btn {
    display: block;
    width: 100%;
    margin-bottom: 8px;
}

.parking-sheet__actions .btn:last-child {
    margin-bottom: 0;
}

/* ------------------------------------------------------------------ cloned .detail inside the sheet */

/*
 * The sheet holds a .parking_map > .stani wrapper on purpose: all bubble styles in base.less
 * (1476-1594) are nested under .parking_map .stani .detail, so the clone keeps its original look
 * only inside that selector chain. Rules below just undo the bubble positioning and must keep the
 * same selector depth as the originals, otherwise base.css wins on specificity.
 */

.parking-sheet .parking_map {
    position: static;
    width: auto;
    height: auto;
    margin: 0;
    background: none;
}

.parking-sheet .parking_map .stani {
    position: static;
    display: block;
    cursor: default;
    font-size: 100%;
}

.parking-sheet .parking_map .stani .detail {
    position: relative; /* .type-icon is absolute and must anchor here, not on the panel */
    display: block;
    top: auto;
    left: auto;
    width: 100%;
    height: auto;
    box-shadow: none;
}

/* speech bubble arrow */
.parking-sheet .parking_map .stani .detail:after {
    display: none;
}

.parking-sheet .parking_map .stani .detail.double-bubble {
    width: 100%;
}

.parking-sheet .parking_map .stani .detail .detail-top,
.parking-sheet .parking_map .stani .detail .detail-bottom {
    height: auto;
    overflow: visible;
}

/*
 * Shared places: Bootstrap 3 .col-xs-6 is "float: left; width: 50%" with no media query at all
 * (xs is the lowest breakpoint), so the two halves would never stack on their own and would be
 * squeezed into ~160px each. Force them below each other and separate them visually.
 */
.parking-sheet .parking_map .stani .detail.double-bubble .col-xs-6 {
    float: none;
    width: 100%;
}

.parking-sheet .parking_map .stani .detail.double-bubble .detail-top .right-side {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid rgba(255, 255, 255, 0.35);
}

.parking-sheet .parking_map .stani .detail.double-bubble .detail-bottom .right-side {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid #ddd;
}
