/*
 * Coaching for Health fixes to the Sanabel theme, loaded on every page after
 * the theme's own stylesheets (see functions.php).
 */

/* Partner logos (home page): fill the column on small screens.
 *
 * Below 769px the theme stacks the three-column rows (responsive.css), but the
 * logos keep their 273px width and leave a gap beside them. Here they stretch
 * to the column, up to 420px, and sit centred. The images are only about
 * 275px wide, so the cap stops them being blown up and blurred on tablets.
 *
 * Most logos carry the img-partner class (which adds their border and
 * padding). CPPE (wp-image-635) and Barts (wp-image-636) were added later
 * without it; their border is part of the image, so they are matched by
 * their Media Library IDs instead. A new logo needs img-partner, or its ID
 * adding here, to resize too. */
@media (max-width: 768px) {
    .img-partner,
    img.wp-image-635,
    img.wp-image-636 {
        display: block;
        width: 100%;
        max-width: 420px;
        height: auto;
        margin: 0 auto;
    }
}

/* Mobile header: hamburger on the logo's line, at the right, as tall as the logo.
 *
 * From 501px to 992px the theme already floats the button right of the logo,
 * but under 501px it centres the logo and drops the button onto a line of its
 * own. Here it is pinned to the right of the logo's line at every mobile
 * width, and the logo is left-aligned on phones to match.
 *
 * Height: the theme shows a 36px-tall logo on standard screens and a 26px
 * retina logo on high-resolution ones (every phone), switching on the same
 * media query used below. Its lettering fills 81% of the image height, from
 * 11% down. The bars glyph draws at 79% of the font size, so 37px and 27px
 * give 29px and 21px bars; top: 16px lines their top up with the top of the
 * lettering in both cases (the logo box starts at 15px). The padding and
 * matching negative margin give a large tap area without moving the icon.
 *
 * On phones the logo is kept 52px clear of the right edge so a narrow screen
 * never puts it under the button; object-fit scales it down there instead of
 * squashing it (the theme fixes its height). */
@media (max-width: 992px) {
    .site_header .logo {
        text-align: left;
    }

    .site_header .mobile_menu {
        position: absolute;
        top: 16px;
        right: 0;
        float: none;
        margin: 0;
        line-height: 1;
    }

    .site_header .mobile_menu_button,
    .site_header .mobile_menu_target {
        display: block;
        line-height: 1;
    }

    .site_header .mobile_menu_target {
        padding: 10px;
        margin: -10px;
    }

    .site_header .mobile_menu_target i {
        display: block;
        font-size: 37px; /* 36px logo */
        line-height: 1;
    }
}

/* Under 501px the logo has the full row (above that the theme floats it, so
   a percentage here would shrink it), so keep it clear of the button. */
@media (max-width: 500px) {
    .site_header .logo img {
        max-width: calc(100% - 52px);
        object-fit: contain;
        object-position: left center;
    }
}

/* Same query the theme uses to swap in the 26px retina logo (responsive.css). */
@media only screen and (max-width: 992px) and (-webkit-min-device-pixel-ratio: 2),
       only screen and (max-width: 992px) and (min-device-pixel-ratio: 2) {
    .site_header .mobile_menu_target i {
        font-size: 27px; /* 26px logo */
    }
}

/*
 * Mobile menu: slide out over the page instead of pushing it aside.
 *
 * The theme's jQuery mmenu (js/asalah.js) opens the menu by adding
 * html.mm-opening, which pluginstyle.css uses to slide the whole page
 * (.mm-page) and the click-catching #mm-blocker to the right, revealing the
 * menu fixed underneath. Here the page and blocker stay where they are, and
 * the menu itself slides in from the left on top of them. mmenu's own
 * open/close behaviour, timing and tap-outside-to-close are unchanged.
 */

/* Keep the page and the blocker still. */
html.mm-opening .mm-page.mm-slideout,
html.mm-opening #mm-blocker.mm-slideout {
    -webkit-transform: none;
    transform: none;
}

html.mm-opened .mm-page {
    box-shadow: none;
}

/* Slide the menu in over them. #mm-blocker sits at z-index 999999, so the
   menu goes one above it or the blocker would swallow taps on the links. */
#slide_menu_list.mm-offcanvas {
    z-index: 1000000;
    -webkit-transform: translateX(-100%);
    transform: translateX(-100%);
    -webkit-transition: -webkit-transform 0.4s ease;
    transition: transform 0.4s ease;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
}

html.mm-opening #slide_menu_list.mm-offcanvas {
    -webkit-transform: translateX(0);
    transform: translateX(0);
}

/* Dim the page behind the open menu; tapping it still closes the menu. */
#mm-blocker {
    -webkit-transition: background-color 0.4s ease;
    transition: background-color 0.4s ease;
}

html.mm-opening #mm-blocker {
    background-color: rgba(0, 0, 0, 0.35);
}

@media (prefers-reduced-motion: reduce) {
    #slide_menu_list.mm-offcanvas,
    #mm-blocker {
        -webkit-transition: none;
        transition: none;
    }
}
