/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ mobile overrides
   Loaded after style.css/special.css/listings.css. Only active under 768px,
   so the desktop layout (fixed-width, pixel-positioned) is untouched.
   Converts the absolutely-positioned header/footer and the fixed sidebar
   layout into a stacked, fluid flow for phones/tablets. */

/* hidden outside the media query so the hamburger never shows on desktop */
#mobile-nav-toggle{ display:none; }

@media (max-width: 768px) {

  body{ overflow-x:hidden; }

  #page{ width:100%; max-width:100%; }

  img{ max-width:100%; height:auto; }

  /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ header */

  #header, #header.main{
    height:auto;
    position:static;
    background-image:none;
    background-color:#046f5a; /* bg_header.gif is dark here; #header-nav text is white and needs contrast */
    padding-top:14px; /* padding (not the row's margin) creates real space above the logo, since margin-top would collapse through to the viewport edge */
    padding-bottom:10px;
  }
  #header .ads-top,
  #header .holiday,
  #top-nav,
  #search-box,
  #main-search-form{
    position:static !important;
    left:auto !important;
    top:auto !important;
    width:auto !important;
    display:block;
    margin:8px 10px;
  }

  /* logo + hamburger sit on one row: logo left, button right */
  .mobile-header-row{
    display:flex;
    justify-content:space-between;
    align-items:center;
    margin:8px 10px;
  }
  #header .logo{
    position:static !important;
    left:auto !important;
    top:auto !important;
    width:auto !important;
    margin:0;
  }

  /* hamburger menu: #header-nav starts collapsed, toggled by the button added in header.inc.php */
  #mobile-nav-toggle{
    display:block;
    margin:0;
    flex-shrink:0;
    padding:8px 14px;
    background-color:rgba(255,255,255,0.15);
    color:#fff;
    border:1px solid rgba(255,255,255,0.4);
    border-radius:4px;
    font-size:16px;
    line-height:1;
  }
  #mobile-nav-toggle span{ font-size:13px; font-weight:bold; vertical-align:middle; }
  #header-nav{
    position:static !important;
    left:auto !important;
    top:auto !important;
    width:auto !important;
    display:none;
    margin:8px 10px;
    padding:8px 0px;
    border-top:1px solid rgba(255,255,255,0.3);
    font-size:0; /* collapses the "|" separator text nodes between links, sits between generated <a> tags */
  }
  #header-nav.mobile-nav-open{ display:block; }
  #header-nav a{
    display:block;
    font-size:15px;
    padding:12px 4px;
    border-bottom:1px solid rgba(255,255,255,0.15);
  }
  #header-nav a:last-child{ border-bottom:none; }
  .header-right-region{
    position:static !important;
    left:auto !important;
    top:auto !important;
    text-align:center;
    margin:8px 10px;
  }
  #food-login-info{
    position:static !important;
    left:auto !important;
    top:auto !important;
    width:auto !important;
    height:auto !important;
    text-align:left !important;
    padding:0px 10px 8px 10px;
    box-sizing:border-box;
    word-wrap:break-word;
    overflow-wrap:break-word;
  }

  /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ content / sidebar */

  #content, #content.large{ width:100% !important; float:none; box-sizing:border-box; }
  #content .content-wrapper, #content.large .content-wrapper{ padding:15px 15px 30px 15px; }
  #middle .main-left, #middle .main-right{ width:100% !important; float:none; }

  #right{ width:100% !important; float:none; }
  #right .right-wrapper{ padding:15px; }

  /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ footer */

  #page-footer{
    height:auto;
    padding:15px 0px;
    background-color:#046f5a; /* nav/copy text below is white; stacked height outgrows bg_footer.gif's gradient */
  }
  #page-footer .copy{ position:static; padding:10px 15px 0px 15px; }

  .nav1, .nav2, .nav3, .nav4, .nav5{
    position:static;
    display:block;
    width:auto;
    padding:2px 15px;
  }

  /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ tables used by forms */

  #contact-form table, #contact-form table tr, #contact-form table tr td,
  #main-search-form table, #main-search-form table tr, #main-search-form table tr td{
    display:block;
    width:auto !important;
  }
  #contact-form table tr td input,
  #contact-form table tr td select,
  #contact-form table tr td textarea,
  #main-search-form table tr td input{
    width:100% !important;
    box-sizing:border-box;
  }

  /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ homepage widgets (food search box, BMI calculator) */

  #nutrition-facts-home{
    width:100% !important;
    height:auto;
    background-image:none;
    position:static;
  }
  #nutrition-facts-home .nutrition-facts-form,
  #nutrition-facts-home .groups-holder{
    position:static !important;
    left:auto !important;
    top:auto !important;
    padding:10px;
    clear:both;
  }
  #nutrition-facts-home .input{ width:100% !important; float:none !important; margin-bottom:8px; }
  #nutrition-facts-home .input select, #nutrition-facts-home .input input[type="text"]{
    width:100% !important;
    box-sizing:border-box;
  }
  #nutrition-facts-home .button{ float:none !important; }
  #nutrition-facts-home > div[style*="position:absolute"]{ display:none; }

  /* ad slots: CMS-managed HTML with inline fixed px widths (728px / 300px) — prevent them
     from overflowing the viewport; sizing them properly for mobile is the next planned step */
  .ads-top div[style*="width:728px"],
  .header-right-region div[style*="width:300px"],
  .ads-top ins.adsbygoogle,
  .header-right-region ins.adsbygoogle{
    max-width:100% !important;
  }

  #frm-bmi{
    width:100% !important;
    height:auto;
    background-image:none;
    box-sizing:border-box;
  }
  #frm-bmi .frm-bmi-wrapper{ padding:15px; }
  #frm-bmi table, #frm-bmi table tr, #frm-bmi table tr td{
    display:block;
    width:auto !important;
    text-align:left !important;
  }
  #frm-bmi table tr td input{ width:100% !important; box-sizing:border-box; }

  #middle .box-calculate{
    width:100% !important;
    height:auto;
    background-image:none;
  }
  #middle .bmi-form-holder{
    position:static !important;
    left:auto !important;
    top:auto !important;
    width:auto !important;
    padding:10px;
  }

  /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ nutrition/obesity snippet cards */

  #snippets{ width:100% !important; }
  #snippets .snippet{ width:100% !important; float:none !important; }
  #snippets .snippet-wrapper{ padding:0px 0px 20px 0px; }
  #snippets h3, #snippets h3.second{ width:auto; }
  #snippets p{ width:auto !important; }

  /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ find-a-nutritionist state directory */

  h3.states{ width:100% !important; box-sizing:border-box; }
  #states{ width:100% !important; }
  #states .state-column{ width:50% !important; box-sizing:border-box; }
  #letter-box{ width:100% !important; box-sizing:border-box; }
  #listing, #company-info{ width:100% !important; box-sizing:border-box; }
  .title-listing{ width:100% !important; background-image:none; }

  /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ads: never let a fixed-width unit force page-wide horizontal scroll */

  .adsbygoogle{ max-width:100%; }
}
