
/*
 * Info window
 *
 * Structure (to be refactored after new design is ready):
 *  .tb-map-info-window-wrapper
 *      .tb-map-info-window
 *          .tb-map-info-window__close-button
 *              svg.c-icon (#icon-close)
 *          .tb-map-info-window__image-wrapper
 *          .tb-map-info-window__text
 *              h2.tb-map-info-window__title
 *              p.tb-map-info-window__opening-times
 *          .tb-map-info-window__footer
 *              div.tb-map-info-window__attribute
 *              a.tb-map-info-window__button
 */

$tb-map-info-window-image-height: 145px !default;

// Hide marker content so there is no flash of info window content before map is rendered
[data-toubiz-map-location-content] {
    display: none;
}

/* Prevent info window from exceeding map size and set z-index higher */
.tb-map-info-window-wrapper {
    /*
     * NOTE: this is currently set in stone because it is also used in
     * JS to position the info window relative to the marker
     */
    width: 266px;
    padding: 0;
    margin: 0;
    // stylelint-disable-next-line declaration-no-important
    overflow: visible !important;
    background-color: config('colors.white');

    /**
     * Caution: magic numbers ahead.
     * Use `shadows.lg`?
     */
    box-shadow: 0 0 20px rgba(0, 0, 0, .2);
}

// info window triangle (pointing towards the marker)
.tb-map-info-window-wrapper::after {
    /**
     * Caution: magic numbers ahead.
     * These values are independent of project context.
     */
    content: '';
    position: absolute;
    bottom: -34px;
    left: 0;
    right: 0;
    margin: auto;
    width: 20px;
    height: 20px;
    border: 18px solid transparent;
    border-top: 18px solid config('colors.white');
}

// hide triangle if we are in leaflet map (has its own)
.leaflet-popup-content-wrapper .tb-map-info-window-wrapper::after {
    display: none;
}

.tb-map-info-window {
    overflow: hidden;
    position: relative;
}

.tb-map-info-window__close-button {
    display: block;
    position: absolute;
    z-index: 1;
    top: 0;
    right: 0;
    padding: config('padding.1') config('padding.2');
    color: config('colors.white');
    font-size: config('textSizes.xl');
    background-color: rgba(0, 0, 0, .4);

    svg {
        pointer-events: none;
    }
}

.tb-map-info-window__image-wrapper {
    display: block;
    width: 100%;
    height: $tb-map-info-window-image-height;
    position: relative;
}

.tb-map-info-window__image-wrapper img {
    font-family: inherit; // Makes sure that postcss-object-fit-images keeps the family
    height: 100%;
    width: 100%;
    object-fit: cover;
}

.tb-map-info-window__text {
    display: block;
    padding: config('padding.3');
}

.tb-map-info-window__title {
    margin: 0;
    font-size: config('textSizes.lg');
}

.tb-map-info-window__opening-times {
    margin: 0;
    padding: 0;
}

.tb-map-info-window__attribute {
    font-size: config('textSizes.sm');
    margin-top: config('margin.2');

    .tb-badge {
        display: inline-block;
    }
}

.tb-map-info-window__button-wrapper {
    padding: 0 config('padding.3') config('padding.3');
}

.tb-map-info-window__button {
    display: inline-block;
    padding: config('padding.2') config('padding.3');
    background-color: config('colors.secondary');
    font-weight: config('fontWeights.bold');
    text-decoration: none;
    font-size: config('textSizes.sm');

    &:hover {
        text-decoration: none;
    }
}

// Increased specifity for overriding leaflet
.tb-map-info-window__button-wrapper a.tb-map-info-window__button {
    color: config('colors.white');
}
