/*
 * Phone / tablet fixes for the CMS-driven public site.
 *
 * Loaded by _Layout right after the tenant theme (<style id="cms-theme">), so it wins over the brand
 * stylesheet, the theme and the inline styles in CMS page HTML. Every rule is inside a media query or
 * scoped to the theme's mobile navbar (.rd-navbar-fixed), so the desktop layout is untouched.
 */

/* ---------- Header (RD Navbar "fixed" layout = below 1200px) ---------- */

/* The logo is dark text meant for a white background; on the theme's black mobile bar it was
   unreadable, taller than the bar and ran off the right edge. Light bar, logo sized to fit. */
.rd-navbar-fixed .rd-navbar-panel {
  height: 64px;
}
.rd-navbar-fixed .rd-navbar-panel:before {
  background: #fff;
  border-bottom: 3px solid var(--cms-primary, #FFA500);
  box-shadow: 0 2px 6px rgba(0, 0, 0, .12);
}
.rd-navbar-fixed .rd-navbar-toggle span,
.rd-navbar-fixed .rd-navbar-toggle span:before,
.rd-navbar-fixed .rd-navbar-toggle span:after {
  background: #1b1b1b;
}
.rd-navbar-fixed .rd-navbar-toggle {
  margin-top: 4px;
}
/* Local831: the 203x139 logo hung far below the bar over the slider. Fit it between the menu
   button (left) and the "more" button (right). */
.rd-navbar-fixed .rd-navbar-brand {
  top: 8px;
  left: 60px;
  right: 60px;
  height: 48px;
  justify-content: center;
}
.rd-navbar-fixed .rd-navbar-brand .brand-logo,
.rd-navbar-fixed .rd-navbar-brand img {
  max-width: 100%;
}
.rd-navbar-fixed .rd-navbar-brand img {
  max-height: 48px;
  width: auto;
  height: auto;
  object-fit: contain;
}
/* Room for the 64px fixed bar (the theme reserves 56px only while the fixed layout is active). */
html.rd-navbar-fixed-linked .page {
  padding-top: 64px;
}
/* Some page shells nest a second .page inside the layout's: reserve the space only once. */
html.rd-navbar-fixed-linked .page .page {
  padding-top: 0;
}
/* The slide-out menu starts under the (now taller) bar. */
.rd-navbar-fixed .rd-navbar-nav-wrap {
  padding-top: 64px;
}

@media (max-width: 1199px) {
  /* Related Sites / Register / Member Login strip: wrap instead of colliding. */
  #flex-box {
    flex-wrap: wrap;
    gap: 6px 16px;
    padding-top: 8px !important;
  }
  #flex-box > div {
    float: none !important;
  }
  #flex-box + br {
    display: none;
  }
}

/* ---------- Tablets ---------- */

@media (min-width: 768px) and (max-width: 1199px) {
  .carousel-caption {
    left: 10% !important;
    right: 10% !important;
    text-shadow: 0 1px 4px rgba(0, 0, 0, .85);
  }
  .carousel-caption span {
    font-size: 34px !important;
    white-space: normal !important;
  }
  .carousel-caption h3 {
    font-size: 20px !important;
    color: var(--cms-primary, #ffc002) !important;
  }
}

/* ---------- Content: phones ---------- */

@media (max-width: 767px) {
  html, body {
    overflow-x: hidden;
  }

  /* Nothing in page content may be wider than the screen. */
  .cms-page-content img,
  .cms-page-content video,
  .cms-page-content canvas,
  .cms-page-content svg,
  .cms-page-content iframe,
  .cms-page-content embed,
  .cms-page-content object {
    max-width: 100% !important;
  }
  .cms-page-content img,
  .cms-page-content video {
    height: auto !important;
  }
  /* Maps / embedded players: full width, keep a usable height. */
  .cms-page-content iframe {
    width: 100% !important;
  }
  .cms-page-content iframe[src*="youtube"],
  .cms-page-content iframe[src*="vimeo"] {
    height: auto !important;
    aspect-ratio: 16 / 9;
  }

  /* Bootstrap rows placed outside a .container pull 15px past both screen edges. */
  .cms-page-content .row:not(.container .row):not(.container-fluid .row):not(.shell .row):not([class*="col-"] .row),
  .page > .row /* page HTML with extra closing tags ends up outside .cms-page-content */ {
    margin-left: 0;
    margin-right: 0;
  }
  .cms-page-content {
    padding-left: 0;
    padding-right: 0;
  }

  /* Card grids built with minmax(300px+, 1fr) overflow on narrow phones: one full-width column. */
  .cms-page-content [class*="grid"] {
    grid-template-columns: minmax(0, 1fr) !important;
  }
  .cms-page-content [class*="card"] {
    min-width: 0 !important;
    max-width: 100%;
    flex-basis: auto !important;
    box-sizing: border-box;
  }

  /* Long words / URLs / headings wrap instead of being cut off. */
  .cms-page-content,
  .cms-page-content h1, .cms-page-content h2, .cms-page-content h3,
  .cms-page-content h4, .cms-page-content h5, .cms-page-content h6,
  .cms-page-content p, .cms-page-content li, .cms-page-content a,
  .cms-page-content span, .cms-page-content td, .cms-page-content th {
    overflow-wrap: break-word;
    word-break: normal;
  }
  /* Email addresses / URLs have no spaces: let links break anywhere. */
  .cms-page-content a {
    overflow-wrap: anywhere;
    white-space: normal !important;
    max-width: 100%;
  }
  .cms-page-content [style*="nowrap"],
  .cms-page-content .text-bold {
    white-space: normal !important;
  }

  /* Theme sizes (h1 5rem, h2 4rem, h3 3rem) are desktop sizes; also beat inline font-size. */
  .cms-page-content h1, .cms-page-content .h1 { font-size: 30px !important; line-height: 1.2 !important; }
  .cms-page-content h2, .cms-page-content .h2 { font-size: 26px !important; line-height: 1.25 !important; }
  .cms-page-content h3, .cms-page-content .h3 { font-size: 22px !important; line-height: 1.3 !important; }
  .cms-page-content h4, .cms-page-content .h4 { font-size: 19px !important; }
  .cms-page-content [style*="font-size:42px"],
  .cms-page-content [style*="font-size: 42px"],
  .cms-page-content [style*="font-size:36px"],
  .cms-page-content [style*="font-size: 36px"],
  .cms-page-content [style*="font-size:48px"],
  .cms-page-content [style*="font-size: 48px"] {
    font-size: 26px !important;
  }
  body {
    font-size: 16px !important;
  }

  /* Wide tables scroll inside themselves instead of being clipped at the screen edge. */
  .cms-page-content table {
    display: block;
    width: 100% !important;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .cms-page-content table td,
  .cms-page-content table th {
    min-width: 120px;
  }
  /* Related Sites: two narrow columns read better stacked as cards. */
  .cms-page-content table.RelatedSitesTable,
  .cms-page-content table.RelatedSitesTable tbody,
  .cms-page-content table.RelatedSitesTable tr,
  .cms-page-content table.RelatedSitesTable td,
  .cms-page-content table.RelatedSitesTable th {
    display: block;
    width: 100% !important;
    min-width: 0;
  }
  .cms-page-content table.RelatedSitesTable tr {
    border-bottom: 1px solid var(--cms-table, #ddd);
    padding: 6px 0;
  }
  .cms-page-content table.RelatedSitesTable td {
    border: 0 !important;
    padding: 2px 10px !important;
  }

  /* Buttons wrap and never exceed the screen; comfortable tap size. */
  .cms-page-content .btn,
  .cms-page-content button,
  .cms-page-content input[type="submit"] {
    white-space: normal !important;
    max-width: 100%;
    min-height: 44px;
  }

  /* Form fields: 16px stops iOS from zooming when a field is tapped. */
  input, select, textarea {
    font-size: 16px !important;
    max-width: 100%;
  }

  /* Home slider: captions were 42px / nowrap and taller than the (short) mobile image. */
  .carousel-caption {
    left: 8% !important;
    right: 8% !important;
    top: auto !important;
    bottom: 34px !important;
    text-shadow: 0 1px 4px rgba(0, 0, 0, .85);
    padding: 0 !important;
  }
  .carousel-caption > div {
    padding: 0 !important;
  }
  .carousel-caption span,
  .carousel-caption .brand-inline {
    font-size: 20px !important;
    line-height: 1.2 !important;
    white-space: normal !important;
  }
  .carousel-caption h3 {
    font-size: 14px !important;
    line-height: 1.3 !important;
    margin: 2px 0 0 !important;
    /* the theme's heading colour (black) is unreadable over the photo at this size */
    color: var(--cms-primary, #ffc002) !important;
  }
  .carousel-caption p {
    display: none;
  }
  .carousel-control {
    width: 10%;
  }
  .carousel-indicators {
    bottom: 2px;
  }
}

/* Very small phones (iPhone SE 1st gen, older Android). */
@media (max-width: 360px) {
  .carousel-caption h3 {
    display: none;
  }
  .cms-page-content h1, .cms-page-content .h1 { font-size: 26px !important; }
  .cms-page-content h2, .cms-page-content .h2 { font-size: 23px !important; }
}
