/* EJCRCI – phone and tablet alignment fixes (header search box + "Stay Up to Date" social links)
   Loaded last from headscripts.php so it applies on every page. Search box: up to 991px. Social links: up to 1199px. Top menu: Menu button on phones, tidy row on tablets and desktop. */

@media (max-width: 991.98px) {

  /* ---------- Top search box ---------- */
  .search_header_top { padding: 12px 16px 14px !important; }
  .search_header_top > .row {
    display: flex !important; flex-direction: column; align-items: center;
    margin: 0 !important; padding: 0 !important; width: 100% !important; max-width: 100% !important; flex: none !important;
  }
  .search_header_top > .row > div { flex: none !important; max-width: 100% !important; width: 100% !important; padding: 0 !important; }
  .search_header_top > .row > .col-md-1 { display: none !important; }
  .search_header_top .col-md-2 { text-align: center; margin-bottom: 12px !important; }
  .search_header_top .col-md-2 img { width: auto !important; max-width: min(320px, 85%) !important; height: auto !important; }
  .search_header_top .col-md-8 > div { width: 100% !important; max-width: 640px !important; margin: 0 auto; }
  .search_header_top .input-group { display: flex !important; flex-wrap: nowrap !important; width: 100%; }
  .search_header_top .input-group .form-control { flex: 1 1 auto; min-width: 0; width: 1% !important; height: 44px !important; font-size: 16px; }
  .search_header_top .input-group .btn { height: 44px !important; white-space: nowrap; display: flex; align-items: center; }
  .search_header_top .input-group .dropdown-menu { max-width: calc(100vw - 32px); white-space: normal; }

}

/* ---------- "Stay Up to Date" social links (phones, tablets, iPad landscape) ---------- */
@media (max-width: 1199.98px) {

  .footerbox > .col-12 {
    display: grid !important; grid-template-columns: 1fr; gap: 12px;
    max-width: 440px; margin: 0 auto; padding: 0 16px; float: none !important;
  }
  .footerbox .twitter {
    width: auto !important; margin: 0 !important; padding: 0 !important;
    display: block !important; float: none !important; border-radius: 8px; overflow: hidden;
  }
  .footerbox .twitter .followtext { display: flex !important; align-items: center; min-height: 64px; margin: 0 !important; }
  .footerbox .twitter .followtext span {
    float: none !important; position: static !important; margin: 0 !important;
    width: auto !important; top: auto !important; left: auto !important;
  }
  .footerbox .twitter .followtext span:first-child { flex: 0 0 64px; align-self: stretch; display: flex !important; }
  .footerbox .twitter .followtext span:first-child a {
    display: flex; align-items: center; justify-content: center;
    width: 100%; min-height: 64px; background: #006B99; border-radius: 0 0 0 12px;
  }
  .footerbox .twitter .followtext span:first-child i {
    padding: 0 !important; background: none !important; border-radius: 0 !important;
    font-size: 28px !important; color: #fff !important; line-height: 1;
  }
  .footerbox .twitter .followtext span:nth-child(2) {
    flex: 1 1 auto; padding: 8px 16px !important; word-break: normal !important; word-wrap: normal !important; text-align: left;
  }
  .footerbox .twitter .followtext span:nth-child(2) a { font-size: 18px !important; line-height: 1.3; }
}

/* iPad landscape / small laptop: five cards in one row */
@media (min-width: 992px) and (max-width: 1199.98px) {
  .footerbox > .col-12 { grid-template-columns: repeat(5, 1fr); max-width: 100%; gap: 14px; padding: 0 15px; }
  .footerbox .twitter .followtext span:first-child { flex-basis: 52px; }
  .footerbox .twitter .followtext span:nth-child(2) { padding: 8px 10px !important; }
  .footerbox .twitter .followtext span:nth-child(2) a { font-size: 15px !important; }
  .footerbox .twitter .followtext span:first-child i { font-size: 24px !important; }
}

/* Tablet: two cards per row, the odd last card centred */
@media (min-width: 576px) and (max-width: 991.98px) {
  .footerbox > .col-12 { grid-template-columns: 1fr 1fr; max-width: 680px; }
  .footerbox .twitter:last-child:nth-child(odd) { grid-column: 1 / -1; justify-self: center; width: calc(50% - 6px) !important; }
}

/* Small phones: keep the search row on one line */
@media (max-width: 400px) {
  .search_header_top .input-group .btn-danger { padding-left: 10px; padding-right: 10px; font-size: 14px; }
}

/* Very small phones: let long emails/links in the footer wrap instead of pushing the page sideways */
@media (max-width: 400px) {
  footer p, footer a { overflow-wrap: anywhere; }
}

/* ---------- Top menu (orange bar) ---------- */
.menu-toggle { display: none; }

/* Tablets and desktop: one tidy, centred row of links, no "|" separators */
@media (min-width: 768px) {
  #ul_top_hypers { display: flex !important; flex-wrap: wrap; justify-content: center; gap: 4px; padding: 0 !important; margin: 0 !important; }
  #div_top_hypers #ul_top_hypers > li.sep { display: none !important; }
  #div_top_hypers #ul_top_hypers > li { display: block !important; float: none !important; padding: 0 !important; font-size: 18px; }
  #ul_top_hypers > li > a { display: block; padding: 8px 16px !important; margin: 0 !important; border-radius: 20px; }
  #ul_top_hypers > li > a:hover, #ul_top_hypers > li > a:focus { background: rgba(255,255,255,.18); }
}

/* Phones: a Menu button that opens the full list, everything expanded */
@media (max-width: 767.98px) {
  .menu-toggle {
    display: inline-flex; align-items: center; gap: 10px; cursor: pointer;
    background: rgba(255,255,255,.15); color: #fff; border: 1px solid rgba(255,255,255,.7); border-radius: 6px;
    padding: 10px 20px; font-size: 18px; font-weight: 600; line-height: 1;
  }
  .menu-toggle:focus { outline: 2px solid #fff; outline-offset: 2px; }
  .menu-toggle-bars, .menu-toggle-bars::before, .menu-toggle-bars::after {
    display: block; width: 20px; height: 2px; background: #fff; border-radius: 2px; position: relative; content: "";
  }
  .menu-toggle-bars::before { position: absolute; top: -6px; }
  .menu-toggle-bars::after { position: absolute; top: 6px; }
  .menu-toggle[aria-expanded="true"] .menu-toggle-bars { background: transparent; }
  .menu-toggle[aria-expanded="true"] .menu-toggle-bars::before { top: 0; transform: rotate(45deg); }
  .menu-toggle[aria-expanded="true"] .menu-toggle-bars::after { top: 0; transform: rotate(-45deg); }

  #div_top_hypers { display: none; margin: 14px auto 0; max-width: 420px; }
  #div_top_hypers.open { display: block; }
  #ul_top_hypers { display: block !important; padding: 0 !important; margin: 0 !important; text-align: left; background: rgba(0,0,0,.14); border-radius: 8px; overflow: hidden; }
  #div_top_hypers #ul_top_hypers > li.sep { display: none !important; }
  #div_top_hypers #ul_top_hypers > li { display: block !important; float: none !important; padding: 0 !important; font-size: 17px; border-bottom: 1px solid rgba(255,255,255,.22); }
  #div_top_hypers #ul_top_hypers > li:last-child { border-bottom: 0; }
  #ul_top_hypers > li > a { display: block !important; padding: 13px 18px !important; margin: 0 !important; }
  #ul_top_hypers > li > a:active { background: rgba(255,255,255,.15); }
  /* Resources: shown open, its links listed underneath */
  #ul_top_hypers .dropdown-toggle { pointer-events: none; }
  #ul_top_hypers .dropdown-toggle::after, #ul_top_hypers .dropdown-toggle .caret { display: none !important; }
  #ul_top_hypers .dropdown-menu {
    display: block !important; position: static !important; float: none !important; transform: none !important;
    background: transparent !important; border: 0 !important; box-shadow: none !important;
    margin: -6px 0 0 !important; padding: 0 0 8px !important; min-width: 0 !important; max-height: none !important;
  }
  #ul_top_hypers .dropdown-menu li { display: block !important; padding: 0 !important; }
  #ul_top_hypers .dropdown-menu a { color: #fff !important; background: transparent !important; padding: 8px 18px 8px 36px !important; font-size: 15px !important; opacity: .95; }
  #ul_top_hypers .dropdown-menu a::before { content: "– "; }
}

/* Tablet portrait: slightly tighter so the whole menu fits on one row */
@media (min-width: 768px) and (max-width: 991.98px) {
  #ul_top_hypers { gap: 0 !important; }
  #div_top_hypers #ul_top_hypers > li { font-size: 16px; }
  #ul_top_hypers > li > a { padding: 8px 9px !important; }
}
@media (min-width: 768px) and (max-width: 819.98px) {
  #div_top_hypers #ul_top_hypers > li { font-size: 15px; }
  #ul_top_hypers > li > a { padding: 8px 7px !important; }
}

/* ---------- Footer "General Links": arrow before each link, wrapped lines aligned under the text ---------- */
footer .bg-black .list-arrow-right { padding-left: 0 !important; margin: 6px 0 10px !important; }
footer .bg-black .list-arrow-right li { position: relative; padding-left: 28px !important; margin-bottom: 9px; line-height: 1.45; }
footer .bg-black .list-arrow-right li::before {
  content: ""; position: absolute; left: 0; top: .42em; width: 18px; height: 9px;
  background-color: #bdbdbd; transition: background-color .2s, transform .2s;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 12'%3E%3Crect x='0' y='5' width='11' height='2'/%3E%3Cpolygon points='8,0 24,6 8,12 10.5,6'/%3E%3C/svg%3E") no-repeat center / contain;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 12'%3E%3Crect x='0' y='5' width='11' height='2'/%3E%3Cpolygon points='8,0 24,6 8,12 10.5,6'/%3E%3C/svg%3E") no-repeat center / contain;
}
footer .bg-black .list-arrow-right li:hover::before { background-color: #FF5733; transform: translateX(3px); }
footer .bg-black .list-arrow-right li a { display: inline; }
