/* RiverThames.co.uk mobile rescue stylesheet
   Purpose: make legacy fixed-width River Thames pages usable on phones without redesigning desktop.
   Load after existing site CSS. */

html { -webkit-text-size-adjust: 100%; }
body { max-width: 100%; overflow-x: hidden; }

img, video, canvas, svg, iframe, object, embed {
  max-width: 100% !important;
  height: auto !important;
}

iframe[src*="google"], iframe[src*="youtube"], iframe[src*="vimeo"] {
  width: 100% !important;
}

/* Bootstrap-era pages */
.container, .container-fluid, .row,
[class^="col-"], [class*=" col-"] {
  box-sizing: border-box;
}
.navbar-brand { max-width: 82%; white-space: normal; height: auto; line-height: 1.2; }
.navbar-brand img { max-height: 48px; width: auto !important; }
.navbar-toggle .icon-bar { display: block; width: 22px; height: 2px; border-radius: 1px; background: #888; margin: 4px 0; }

/* Legacy fixed-width wrappers used across older templates */
.body, #masthead, #masthead_mobile, #masthead_mobile_other, #masthead_img,
#articlebg, .articlebg, #main, #content, .content, .main, .wrapper, .page,
#page, #container, .container_12, .mobile-container {
  max-width: 100% !important;
  box-sizing: border-box;
}

/* Tables are the main overflow source. Preserve desktop; loosen on mobile below. */
table { max-width: 100% !important; }
td, th { box-sizing: border-box; }

/* Old nav systems */
nav.main_sections, nav#main_sections,
nav.main_sections ul, nav#main_sections ul,
.nav-justified, .navbar-nav, .dropdown-menu {
  max-width: 100% !important;
  box-sizing: border-box;
}

/* FrontPage / inline legacy alignment */
[align="center"] { max-width: 100%; }

@media (max-width: 767px) {
  body {
    min-width: 0 !important;
    width: 100% !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
  }

  .body, #masthead, #masthead_mobile, #masthead_mobile_other, #masthead_img,
  #articlebg, .articlebg, #main, #content, .content, .main, .wrapper, .page,
  #page, #container, .container_12, .mobile-container,
  .container, .container-fluid, .jumbotron, .jumbotronblue {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    margin-left: auto !important;
    margin-right: auto !important;
    padding-left: 10px !important;
    padding-right: 10px !important;
    box-sizing: border-box !important;
  }

  #masthead, #masthead_mobile, #masthead_mobile_other {
    height: auto !important;
    min-height: 0 !important;
  }

  #masthead_img { height: auto !important; }

  table, thead, tbody, tfoot, tr, td, th {
    max-width: 100% !important;
  }

  table[width], td[width], th[width],
  table[style*="width"], td[style*="width"], th[style*="width"] {
    width: auto !important;
  }

  table {
    width: 100% !important;
    border-collapse: collapse;
  }

  td, th {
    word-break: normal;
    overflow-wrap: anywhere;
  }

  /* Nested layout tables used for article pages */
  table table, table table table {
    width: 100% !important;
  }

  img[width], img[height], img[style*="width"], img[style*="height"] {
    width: auto !important;
    max-width: 100% !important;
    height: auto !important;
  }

  /* Two side-by-side inline images should wrap instead of causing overflow. */
  p img + img, td img + img, div img + img {
    margin-top: 8px;
  }

  nav .nav-justified,
  nav .nav-justified > li,
  .nav-justified > li,
  .navbar-nav,
  .navbar-nav > li,
  nav.main_sections,
  nav#main_sections,
  nav.main_sections ul,
  nav#main_sections ul,
  nav.main_sections li,
  nav#main_sections li {
    display: block !important;
    width: 100% !important;
    height: auto !important;
    float: none !important;
    text-align: center !important;
  }

  nav .nav-justified a,
  nav.main_sections a,
  nav#main_sections a,
  .navbar-nav > li > a {
    display: block !important;
    padding: 10px 8px !important;
    white-space: normal !important;
  }

  .dropdown-menu {
    position: static !important;
    float: none !important;
    width: 100% !important;
    box-shadow: none !important;
  }

  .rightlogo, .leftlogo, .floatleft, .floatright,
  [style*="float: left"], [style*="float:left"],
  [style*="float: right"], [style*="float:right"] {
    float: none !important;
  }

  h1 { font-size: 26px !important; line-height: 1.2 !important; }
  h2 { font-size: 22px !important; line-height: 1.25 !important; }
  h3 { font-size: 19px !important; line-height: 1.3 !important; }
  p, li, td, th { line-height: 1.45; }

  input, select, textarea, button {
    max-width: 100% !important;
    box-sizing: border-box !important;
  }
}
