/*
 * 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;
}

/* iPhone Safari did not paint the position:fixed bar at the top of the page; it appeared only
   after scrolling. Make the bar part of the page instead: the header is sticky (stays at the top
   while scrolling) and the bar sits in normal flow, so it renders on first load in every browser.
   overflow-x: clip (not hidden) on html/body/.page is what lets sticky work; browsers without clip
   keep "hidden", and the bar then simply scrolls away with the page, still visible on load. */
html.rd-navbar-fixed-linked,
html.rd-navbar-fixed-linked body,
html.rd-navbar-fixed-linked .page {
  overflow-x: hidden;
  overflow-x: clip;
  overflow-y: visible;
}
html.rd-navbar-fixed-linked .page-head {
  position: -webkit-sticky;
  position: sticky;
  top: 0;
  z-index: 1000;
}
html.rd-navbar-fixed-linked .rd-navbar-fixed .rd-navbar-panel {
  position: relative;
}
/* the navbar script writes an inline height:0 on the wrapper (it expected a fixed bar) */
html.rd-navbar-fixed-linked .rd-navbar-wrap {
  height: auto !important;
}
html.rd-navbar-fixed-linked .page,
html.rd-navbar-fixed-linked .page .page {
  padding-top: 0;
}

@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;
    overflow-x: clip;
  }

  /* 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;
  }
}

/* ---------- Home slider + title band: phones and tablets ---------- */

@media (max-width: 1199px) {
  /* Home slider (Local831): the photos were only ~160px tall on a phone, so the big logo was cropped
     and the white "Health Fund / Pension Plan" boxes overflowed above the slide, cutting their
     headline off. A taller slide, the photo cropped to fill it, and the caption centred inside it. */
  .carousel-inner > .item {
    height: 440px;
  }
  .carousel-inner > .item > img {
    width: 100%;
    height: 100% !important;
    max-width: none;
    object-fit: cover;
    object-position: center;
  }
  .carousel-caption {
    top: 0 !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px 44px 34px !important;
  }
  .carousel-caption > div {
    width: 100%;
    margin: 0 !important;
  }
  /* Slide 1: the Local 831 logo graphic, whole and centred. */
  .carousel-caption img {
    width: auto !important;
    max-width: 100% !important;
    max-height: 300px;
    height: auto !important;
    margin: 0 auto;
    filter: drop-shadow(0 2px 6px rgba(0, 0, 0, .45));
  }
  /* Slides 2 and 3: a compact card. */
  .carousel-caption .range {
    margin: 0 !important;
    justify-content: center;
  }
  .carousel-caption .adBox {
    float: none;
    width: 100%;
    max-width: 330px;
    margin: 0 auto !important;
    left: auto;
    right: auto;
    padding: 16px 18px 18px;
    background: rgba(255, 255, 255, .94);
    border-top: 4px solid var(--cms-primary, #379b9f);
    border-radius: 6px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, .35);
    text-shadow: none;
    text-align: center;
  }
  .carousel-caption .headingAlt {
    font-size: 12px;
    line-height: 1.3;
    font-weight: 700;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: var(--cms-primary, #379b9f);
  }
  .carousel-caption .leadheading {
    font-size: 22px;
    line-height: 1.2;
    margin: 4px 0 6px;
    color: #1b2433;
  }
  .carousel-caption .mainp {
    font-size: 14px;
    line-height: 1.4;
    font-weight: 400;
    color: #3a4250;
  }
  .carousel-caption .rd-navbar-btn-wrap {
    margin: 12px 0 0 !important;
    padding: 0 !important;
  }
  .carousel-caption .adBox > :last-child,
  .carousel-caption .adBox .btn {
    margin-bottom: 0 !important;
  }
  .carousel-caption .adBox .btn {
    min-height: 0;
    padding: 9px 22px;
    font-size: 13px;
    line-height: 1.2;
    letter-spacing: .06em;
    border-radius: 4px;
  }
  .carousel-indicators {
    bottom: 6px;
    margin-bottom: 0;
  }

  /* Dark "Local Union 831 / Employer Health Fund | Employer Pension Plan" band under the slider:
     the title rendered black on navy and the subtitle in a thin oblique face. */
  .noticeTitle {
    padding: 22px 6px;
    margin-bottom: 0;
    background-size: cover;
    background-position: center;
  }
  .noticeTitle h3,
  .noticeTitle h3 * {
    color: #fff !important;
    font-size: 24px !important;
    line-height: 1.2 !important;
    margin: 0 0 4px !important;
  }
  .noticeTitle p {
    color: rgba(255, 255, 255, .88) !important;
    font-size: 15px !important;
    font-weight: 400 !important;
    font-style: normal !important;
    line-height: 1.4 !important;
    margin: 0 !important;
  }
}

@media (max-width: 767px) {
  .carousel-inner > .item {
    height: 320px;
  }
}

/* The band's title is meant to be white (inline style) but a theme rule turned it black on navy;
   this one applies on desktop too. */
.noticeTitle h3,
.noticeTitle h3 b {
  color: #fff !important;
}

/* 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; }
}
