/**
 * Styles for the Search Results Template
 * Global parts like the search form and popular searches are in the main styles.css
 */

/* -----------------------------
   Layout / ordering
------------------------------ */

.cresset-ms-wrap{
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  gap: 20px;
  width: 100%;
}

.cresset-ms-wrap > p{
  width: 100%;
  text-align: center;
}

.cresset-ms-sort-wrap{
  width: 160px;
  order: 1;
}

.cresset-ms-results-wrap.wrap-a{
  width: 75%;
  flex-grow: 1;
  order: 0;
}

.cresset-ms-results-wrap.wrap-b{
  order: 2;
  width: 100%;
}

.wrap-c{
  order: 99;
  width: 100%;
}

/* Tablet */
@media (max-width: 1024px){
  .cresset-ms-wrap{ flex-direction: column; }
  .cresset-ms-sort-wrap{ order: 0; width: 100%; }
  .cresset-ms-results-wrap.wrap-a{ width: 100%; }
}

/* -----------------------------
   Sections / headings
------------------------------ */

.cresset-ms-section{
  margin-bottom: 3rem;
}

.cresset-ms-section h2{
  margin: 0 0 1rem 0;
  font-size: 1.2rem;
  line-height: calc(1em + 5px);
}

/* -----------------------------
   Grids
------------------------------ */

.cresset-ms-grid.cresset-ms-loop-a{
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  align-content: center;
  justify-content: flex-start;
  align-items: stretch;
}

.cresset-ms-grid.cresset-ms-loop-b,
.cresset-ms-grid.cresset-ms-loop-c{
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 16px;
}

.cresset-ms-grid.cresset-ms-loop-b .e-loop-item,
.cresset-ms-grid.cresset-ms-loop-c .e-loop-item{
  display: flex;
  align-items: stretch;
}

/* -----------------------------
   Pagination
------------------------------ */

.cresset-ms-pagination{
  margin: 2rem 0;
  display: flex;
  justify-content: center;
  gap: .7rem;
  flex-wrap: wrap;
}

.cresset-ms-pagination a,
.cresset-ms-pagination span{
  border-radius: 8px;
  text-decoration: none;
}

.cresset-ms-pagination .current{
  color: #FF9E1B;
}

/* -----------------------------
   Sort UI
------------------------------ */

.cresset-ms-sort--radios{
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  border: none;
  gap: 8px;
}

.cresset-ms-sort--radios legend{
  margin-bottom: 8px;
}

/* Sort By label color */
.cresset-ms-sort legend,
.cresset-ms-sort-label{
  color: var(--e-global-color-accent);
  font-weight: 600;
}

/* Desktop/tablet: keep radios visible */
.cresset-ms-sort-ui{
  display: none;
}

/* Mobile: show faux dropdown trigger, hide radios until opened */
@media (max-width: 767px){
  .cresset-ms-sort.cresset-ms-sort--radios{
    position: relative;
    display: block;
  }

  .cresset-ms-sort-legend{
    display: none;
  }

  .cresset-ms-sort-ui{
    display: block;
  }

  .cresset-ms-sort-trigger{
    width: fit-content;
    display: flex;
    justify-content: flex-start;
    align-items: center;
    padding: 0 !important;
    border-radius: 2px !important;
    border: none;
    background: none !important;
    color: var(--e-global-color-text) !important;
    cursor: pointer;
  }

  .cresset-ms-sort-trigger-caret{
    width: 0;
    height: 0;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-top: 6px solid var(--e-global-color-text);
    margin-left: 12px;
  }

  /* Options panel */
  .cresset-ms-sort-options{
    display: none;
    position: absolute;
    left: 0;
    right: 0;
    top: calc(100% - 1px);
    border: 1px solid grey;
    background: #fff;
    z-index: 50;
    padding: 0;
  }

  .cresset-ms-sort.is-open .cresset-ms-sort-options{
    display: block;
  }

  /* Make labels fill like dropdown options */
  .cresset-ms-sort-options label{
    display: flex;
    gap: 10px;
    align-items: center;
    padding: 20px !important;
    cursor: pointer;
  }

  .cresset-ms-sort-options label:hover{
    background-color: grey;
    color: white;
  }

  /* Hide the radio circle visually but keep it accessible */
  .cresset-ms-sort-options input[type="radio"]{
    position: absolute;
    opacity: 0;
    pointer-events: none;
  }
}

/* -----------------------------
   Landing page link hover
------------------------------ */

.landing-page-link{
  overflow: hidden;
}

.landing-page-link:before{
  content: '';
  height: 102%;
  width: 0%;
  position: absolute;
  left: -2%;
  top: 0;
  z-index: -1;
  border: none;
  background-color: var(--e-global-color-accent);
  transition: width 0.3s;
}

.landing-page-link:hover:before{
  width: 104%;
}

.landing-page-link:hover .landing-page-title{
  text-decoration: none;
}

.landing-page-link:hover .landing-page-title h3{
  color: white !important;
}

/* Very small screens: ellipsis for the title */
@media (max-width: 350px){
  .cresset-ms-grid.cresset-ms-loop-a .e-loop-item .landing-page-title h3{
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: calc(100vw - 90px);
  }
}

/* -----------------------------
   Thumbnails
------------------------------ */

.search-thumbnail img{
  aspect-ratio: 128 / 67;
  width: 100%;
  height: unset !important;
  object-fit: cover;
  object-position: center top;
}

/* Fix images on mobile */
@media (max-width: 767px){
  .search-thumbnail{
    max-width: calc(100vw - 40px) !important;
  }
  .search-thumbnail img{
    aspect-ratio: 128 / 67;
    height: unset !important;
  }
}
/* -----------------------------
   Empty Results
------------------------------ */
.cresset-ms-results-wrap.nothing-found { display:none; }


/* Only the About page result (post-2) this fixes it wrapping to 2 lines on firefox */
.cresset-ms-grid.cresset-ms-loop-a .e-loop-item.post-2 .elementor-heading-title{
  white-space: nowrap;
}