
/*
 * 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: theme('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 theme('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: theme('padding.1') theme('padding.2');
    color: theme('colors.white');
    font-size: theme('fontSize.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: theme('padding.3');
}

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

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

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

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

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

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

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

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