/* -------------------------------------------------------------------------
   Responsive fixes.

   The theme predates any mobile treatment: the header had a fixed 120px
   height with floated columns, so on a phone the donate buttons landed on
   top of the nav links and the logo pushed the page 21px wider than the
   viewport.

   Everything here is inside a max-width query (or is a no-op at desktop
   widths) so the desktop design is unchanged.
   ------------------------------------------------------------------------- */


/* Never let an image push the page wider than the screen. */
#head-nav img,
#main-nav img,
footer img {
    max-width: 100%;
    height: auto;
}


@media (max-width: 767px) {

    /* --- notification bar ------------------------------------------------ */

    #notification {
        padding: 10px 0;
    }

    #notification .container {
        padding-left: 15px;
        padding-right: 15px;
    }


    /* --- logo + donate buttons ------------------------------------------- */

    /* the fixed height is what made the buttons collide with the nav */
    #head-nav {
        height: auto;
        padding: 18px 0 20px;
    }

    #head-nav .row > div {
        float: none;
        width: 100%;
    }

    #head-nav nav a {
        display: block;
        text-align: center;
    }

    #head-nav nav img {
        display: inline-block;
        max-width: 250px;
    }

    .nav-btn {
        margin: 18px 0 0;
        display: flex;
        justify-content: center;
        gap: 10px;
        /* .pull-right in the compiled Bootstrap forces a right float with the
           important flag, so a normal declaration cannot win here */
        float: none !important;
    }

    .nav-btn li {
        float: none;
        margin: 0;
    }

    .nav-btn li a {
        display: flex;
        align-items: center;
    }


    /* --- main nav -------------------------------------------------------- */

    #main-nav ul {
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
    }

    #main-nav ul > li {
        float: none;
    }

    /* comfortable tap targets, and links no longer sit on top of anything */
    #main-nav ul > li > a {
        padding: 12px 14px;
        font-size: 15px;
        line-height: 1.4;
    }

    #main-nav ul > li.pull-left {
        /* .pull-left forces a left float with the important flag, same as
           .pull-right above - specificity alone cannot beat it */
        float: none !important;
    }

    /* matches the specificity of `#main-nav.stuck ul li a.nav-logo` and wins
       on load order, so no !important needed */
    #main-nav.stuck ul li a.nav-logo {
        display: none;
    }

    /* hover-only dropdowns are unreachable on touch, and their targets are all
       linked elsewhere (Karl's Story / Butterfly Story are anchors on
       /foundation, The Hormel Institute is linked from /resources).
       Mirrors the `#main-nav ul>li:hover>ul` selector so it wins on order. */
    #main-nav ul > li:hover > ul {
        display: none;
    }

    /* a fixed bar costs too much of a phone screen; JS also guards this */
    #main-nav.stuck {
        position: static;
        box-shadow: none;
    }


    /* --- story sections --------------------------------------------------- */

    /* background-attachment:fixed is broken on mobile browsers - the image is
       sized against the viewport instead of the element, so these sections
       rendered as solid black. Scroll attachment shows the photo again. */
    #karls-story,
    #butterfly-story {
        background-attachment: scroll;
        background-position: center center;
        padding: 60px 0;
    }

    /* On desktop the copy sits in a column over a dark part of the photo. At
       phone width it spans the full image, so a scrim keeps the white text
       readable. The image URLs are repeated because a gradient has to be
       layered in the same background-image declaration. */
    #karls-story {
        background-image:
            linear-gradient(rgba(0, 0, 0, 0.66), rgba(0, 0, 0, 0.66)),
            url(../img/foundation-karls-story.jpg);
    }

    #butterfly-story {
        background-image:
            linear-gradient(rgba(0, 0, 0, 0.66), rgba(0, 0, 0, 0.66)),
            url(../img/foundation-butterfly-story.jpg);
    }


    /* --- page banners ------------------------------------------------------ */

    header {
        height: 220px;
        padding-top: 30px;
    }

    header.foundation {
        height: 160px;
    }


    /* --- footer ------------------------------------------------------------ */

    footer {
        text-align: center;
    }

    #footer-nav {
        /* .pull-right again - forced right float with the important flag */
        float: none !important;
        padding-left: 0;
        margin-top: 10px;
    }

    #footer-nav li {
        display: inline-block;
        float: none;
    }

    /* footer links were 19px tall - too small to tap reliably */
    footer a {
        display: inline-block;
        padding: 8px 6px;
    }
}


/* Tablet: the header columns still fit, but the logo needs a ceiling. */
@media (min-width: 768px) and (max-width: 991px) {

    #head-nav nav img {
        max-width: 100%;
    }

    #main-nav ul > li > a {
        padding: 10px 15px;
    }
}
