/* Kill any masonry leftovers and enable grid */
.resource-grid { position: static !important; height: auto !important; }
.resource-grid .resource{
  position: static !important; top:auto!important; left:auto!important;
  transform:none!important; margin:0!important; width:100%!important;
}

/* Actual grid */
.resource-grid{
  display:grid;
  grid-template-columns:repeat(auto-fill, minmax(220px,1fr));
  gap:24px;
  align-items:stretch;
}
.resource-grid .resource{
  background:#fff; border:1px solid #ececec; box-shadow:0 1px 6px rgba(51,51,51,.18);
  border-radius:6px; display:flex; flex-direction:column; overflow:hidden;
}
.resource-grid .resource__thumbnail{ position:relative; aspect-ratio:2/3; width:100%; background:#f5f5f5; line-height:0; overflow:hidden; }
.resource-grid .resource__thumbnail img{ position:absolute; inset:0; width:100%; height:100%; object-fit:cover; display:block; }
.resource-grid .resource__content{ padding:12px; }
.resource-grid .resource__meta{ padding:0 12px 12px; color:#6b7280; font-size:.85rem; }

@media (min-width:1200px){ .resource-grid{ grid-template-columns:repeat(5,1fr);} }
@media (min-width: 992px){ .resource-grid{ grid-template-columns:repeat(4,1fr);} }
@media (min-width: 768px){ .resource-grid{ grid-template-columns:repeat(3,1fr);} }
@media (max-width: 767px){ .resource-grid{ grid-template-columns:repeat(2,1fr);} }

@supports not (aspect-ratio:1){
  .resource-grid .resource__thumbnail{ height:0; padding-top:150%; }
  .resource-grid .resource__thumbnail img{ position:absolute; top:0; left:0; right:0; bottom:0; }
}

/* Browse grid container */
.resource-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, 200px); /* fixed card width */
  justify-content: center; /* center the row if it doesn't fill */
  gap: 20px;
  list-style: none;
  padding: 0;
  margin: 0;
}
/* === Mobile (≤767px): 2-up, smaller, equal-height cards === */
@media (max-width: 767px){
  /* 2 columns */
  .resource-grid{
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 12px;
    justify-content: stretch;
  }

  /* Uniform card height */
  .resource-grid .resource{
    height: 260px !important;          /* set the total card height */
    display: flex;
    flex-direction: column;
    overflow: hidden;                   /* clip any overflow */
  }

  /* Fixed thumbnail frame (keeps rows equal) */
  .resource-grid .resource__thumbnail{
    height: 160px !important;           /* smaller cover on phones */
    flex: 0 0 auto;
    overflow: hidden;
  }
  .resource-grid .resource__thumbnail img{
    width: 100% !important;
    height: 100% !important;
    object-fit: cover;                  /* uniform; small crop if needed */
    object-position: top;
    display: block;
  }

  /* Content area fills the remainder under the image */
  .resource-grid .resource__content{
    flex: 1 1 auto;
    padding: 8px 10px !important;
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-height: 0;                      /* allow clamping */
    overflow: hidden;
  }

  /* Tighter type on mobile */
  .resource-grid .resource__content .title,
  .resource-grid .resource__content .resource-name{
    font-size: 0.95rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* Clamp description to 2 lines so card heights match */
  .resource-grid .resource__content .description{
    font-size: 0.9rem;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;              /* 2 lines */
    -webkit-box-orient: vertical;
    overflow: hidden;
    white-space: normal;
  }

  /* Optional: smaller meta */
  .resource-grid .resource__meta{
    font-size: 0.8rem;
    padding: 0 10px 10px;
  }
}
/* Each card */
.resource-grid .resource {
  background: #fff;
  border: 1px solid #ececec;
  box-shadow: 0 1px 6px rgba(51,51,51,.15);
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  width: 200px;   /* fixed width */
  height: 380px;  /* << fixed total card height */
  overflow: hidden;
  position: static !important; 
  top: auto !important;
  left: auto !important;
  transform: none !important;
}

/* Thumbnail frame */
.resource-grid .resource__thumbnail {
  width: 100%;
  height: 300px;   /* << fixed image frame height */
  background: #f5f5f5;
  overflow: hidden;
  flex-shrink: 0;
}
.resource-grid .resource__thumbnail img {
  width: 100%;
  height: 100%;
  object-fit: cover;  /* fills frame, crops excess */
  display: block;
}

/* Content section: fills remaining space */
.resource-grid .resource__content {
  flex: 1 1 auto;
  padding: 10px 12px;
  display: flex;
  flex-direction: column; 
  align-items: left;
  gap: .5rem;
  overflow: hidden;      /* prevent wrapping */
}

.resource-grid .resource__content a,
.resource-grid .resource__content .description {
  flex: 1 1 auto;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;  /* ⬅ important for flexbox truncation */
}

/* Meta/info line at bottom */
.resource-grid .resource__meta {
  padding: 0 12px 12px;
  font-size: 0.8rem;
  color: #6b7280;
  margin-top: auto;  /* pushes meta text to bottom */
}
/* Titles (single line, ellipsis at the end) */
.resource-grid .resource__content h3,
.resource-grid .resource__content .resource-name,
.resource-grid .resource__content .title {
  margin: 0 0 6px;
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.3;
  white-space: nowrap;        /* keep everything in one line */
  overflow: hidden;           /* hide the overflow */
  text-overflow: ellipsis;    /* add ... at the end */
}

/* Scope: only the search block */
.block--searchForm form.search-form.form-search{
  max-width: 820px; margin: 0 auto;
}

/* Visually hide the label but keep for a11y */
.block--searchForm .field-meta label{
  position:absolute; width:1px; height:1px; margin:-1px; overflow:hidden;
  clip:rect(0 0 0 0); white-space:nowrap; border:0;
}

/* Input itself (beats UA + theme) */
.block--searchForm .inputs > input[type="search"][name="q"]{
  -webkit-appearance:none !important; appearance:none !important;
  box-sizing:border-box !important; width:100% !important; height:56px !important;
  border:1px solid #d8dee8 !important; border-radius:12px !important; background:#fff !important;
  padding:0 48px 0 48px !important; font-size:1rem !important; line-height:1.3 !important;
  box-shadow:0 1px 2px rgba(0,0,0,.04) !important;
  background-image:url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%238aa0b6' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><circle cx='11' cy='11' r='8'/><line x1='21' y1='21' x2='16.65' y2='16.65'/></svg>") !important;
  background-repeat:no-repeat !important; background-position:16px center !important; background-size:20px 20px !important;
}
.block--searchForm .inputs > input[type="search"][name="q"]::placeholder{ color:#9aa6b2 !important; }
.block--searchForm .inputs > input[type="search"][name="q"]:focus{
  outline:none !important; border-color:var(--primary,#394f68) !important;
  box-shadow:0 0 0 4px rgba(57,79,104,.12) !important;
}

/* Clamp the card title to one line (ellipsis) */
.resource-grid .resource__content .title,
.resource-grid .resource__content .resource-name{
  display:block; overflow:hidden; white-space:nowrap; text-overflow:ellipsis;
}

/* Taller cover image (same width cards you already have) */
.resource-grid .resource__thumbnail{ height: 300px; }   /* was 200 */
.resource-grid .resource__thumbnail img{ width:100%; height:100%; object-fit:cover; }

/* ========== 1) Layout polish ========== */
.faceted-browse-page #container {
  align-items: flex-start;
  gap: 2rem;
}
.faceted-browse-page #section-sidebar {
  background: #fff;
  border: 1px solid #ececec;
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 2px 10px rgba(0,0,0,.05);
  position: sticky;
  top: 90px; /* below main header */
  max-height: calc(100vh - 110px);
  overflow: auto;
}
@media (max-width: 1199px){
  .faceted-browse-page #section-sidebar {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    border-radius: 0;
    padding: 18px 16px 80px;
    background:#fff;
    transform: translateY(-100%);
    transition: transform .25s ease;
    z-index: 1050;
  }
  .faceted-browse-page #section-sidebar.open { transform: translateY(0); }
}

/* ========== 2) Sidebar header & controls ========== */
#section-sidebar .facets-container legend,
#section-sidebar .categories-container legend {
  font: 600 1.05rem/1.2 "Noto Serif", serif;
  margin: 0 0 .75rem;
}
#section-sidebar-modal-toggle {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  padding: .55rem .8rem;
  border: 1px solid var(--primary, #394f68);
  color: var(--primary, #394f68);
  background: #fff;
  border-radius: 999px;
  font-size: .9rem;
}
#section-sidebar.open #section-sidebar-modal-toggle { display:none; }

/* ========== 3) Facet groups (accordion-ish look) ========== */
#facets > .facet-group { /* if your theme doesn’t emit this, you can wrap groups in the view */
  margin-bottom: 1rem;
}
#facets .facet-title, /* optional header element if present */
#facets .accordion__trigger {
  background: #f7f9fc;
  border: 1px solid #e8edf4;
  border-radius: 10px;
  padding: .7rem .9rem;
  font-weight: 600;
  color: #36475a;
  display: flex; align-items: center; justify-content: space-between;
  cursor: pointer;
}
#facets .facet-title + .select-list,
#facets .accordion__panel,
#facets .select-list {
  margin-top: .5rem;
  border-left: 2px solid #eef2f7;
  padding-left: .75rem;
}

/* ========== 4) One facet item (checkbox row) ========== */
.select-list { list-style:none; margin:0; padding:0; }
.select-list-item {
  display:flex; align-items:center; justify-content:space-between;
  gap: .75rem;
  padding: .4rem 0;
  border-bottom: 1px dashed #eef2f7;
}
.select-list-item:last-child { border-bottom: 0; }

/* checkbox + label inline */
.select-list-item label { 
  display:flex; align-items:center; gap:.5rem; 
  cursor:pointer; color:#333; font-weight:500;
}
/* counts lighter */
.select-list-item .count, .select-list-item .facet-count { 
  color:#8c99a8; font-size:.85rem;
}

/* Custom checkbox look (keeps native, just styling) */
.select-list input[type="checkbox"]{
  width: 18px; height: 18px; border-radius: 4px;
  border: 2px solid #c9d3df; background:#fff;
  appearance: none; display:grid; place-content:center;
  margin:0;
}
.select-list input[type="checkbox"]:checked{
  border-color: var(--primary, #394f68); background: var(--primary, #394f68);
}
.select-list input[type="checkbox"]:checked::before{
  content:""; width:10px; height:10px; border-radius:2px; background:#fff;
}

/* Hover state */
.select-list-item:hover label { color:#1f2937; }

/* Active (selected) facet label bolder */
.select-list input[type="checkbox"]:checked + label,
.select-list label[aria-checked="true"] {
  font-weight: 700; 
}

/* Expand/Collapse links subtle */
.select-list-expand, .select-list-collapse {
  display:inline-block; margin:.35rem 0; font-size:.9rem; color: var(--primary, #394f68);
  text-decoration: underline; cursor: pointer;
}

/* ========== 5) Active filters as chips above results ========== */
.search-filters {
  margin: .5rem 0 1.5rem;
  gap: .5rem;
}
.search-filters .filter {
  background: #eef4ff;
  color: #2f4361;
  border: 1px solid #d7e3ff;
  border-radius: 999px;
  padding: .25rem .6rem;
  display:inline-flex; align-items:center; gap:.4rem;
}
.search-filters .filter::after { /* small x glyph via content font */
  content:"✕"; font-size:.85em; opacity:.75;
}

/* ========== 6) Results toolbar (sort/permalink) ========== */
#section-content .browse-controls {
  border: 0;
  background: #f8fafc;
  padding: .75rem 1rem;
  border-radius: 10px;
  box-shadow: inset 0 0 0 1px #eef2f7;
}

/* ========== 7) Mobile bottom actions (apply/clear) ========== */
@media (max-width: 1199px){
  #section-sidebar .facet-actions {
    position: fixed; left:0; right:0; bottom:0;
    background: #fff; border-top: 1px solid #ececec;
    padding: .75rem; display:flex; gap:.75rem; justify-content:space-between;
  }
  #section-sidebar .facet-actions .btn {
    flex:1 1 auto; text-align:center; padding:.7rem .9rem; border-radius:10px; cursor:pointer;
  }
  #section-sidebar .facet-actions .btn-primary {
    background: var(--primary, #394f68); color:#fff; border:0;
  }
  #section-sidebar .facet-actions .btn-secondary {
    background:#fff; color:var(--primary, #394f68); border:1px solid var(--primary, #394f68);
  }
}

.item-lexo { margin-top: 1rem; }
.lexo-button {
  display: inline-block;
  background: #007bff;
  color: #fff !important;
  font-weight: 600;
  padding: .5rem 1rem;
  border-radius: 4px;
  text-decoration: none;
  transition: background-color .2s ease-in-out;
}
.lexo-button:hover,
.lexo-button:focus { background: #0056b3; color: #fff !important; }

.browse-all {
  display: inline-block;
  margin-top: 30px;
margin-right:50px;
  padding: 0.6rem 1.2rem;
  background: var(--primary, #394f68); /* theme color fallback */
  color: #000 !important;
  font-weight: 600;
  border-radius: 6px;
  text-decoration: none;
  transition: background-color 0.2s ease-in-out;
}

.browse-all:hover,
.browse-all:focus {
  background: #2d3b50; /* darker hover */
  color: #fff !important;
}

/* ===== Global browse content rules (grid + list) ===== */

/* Stack content vertically everywhere in browse */
.browse .resources .resource .resource__content,
.browse .resources .resource .resource__meta{
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0; /* allow children to truncate */
}

/* Single-line ellipsis for primary title + description (all browse types) */
.browse .resources .resource .resource__content > a,
.browse .resources .resource .resource__content .description,
.browse .resources .resource .resource__meta > a,
.browse .resources .resource .resource__meta .description,
.browse .resources .resource .resource__content .resource-name,
.browse .resources .resource .resource__content .title{
  display: block;
  width: 100%;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Extra: list view uses media-object; ensure truncation there too */
.browse .resource-list .media-object .resource__meta > a,
.browse .resource-list .media-object .resource__meta .description{
  display: block;
  width: 100%;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Optional: shared padding if not already handled per template */
.browse .resources .resource .resource__content{ padding: 10px 12px; }
.browse .resources .resource .resource__meta{ padding: 0 12px 12px; }

/* (You already set thumbnails globally; included here just for completeness)
   Ensure images crop from the top everywhere */
.browse .resources .resource .resource__thumbnail img{
  object-fit: cover;
  object-position: top;
}

/* Base heading styles */
h1, h2, h3, h4, h5, h6 {
  font-family: inherit;    /* keep theme’s font */
  font-weight: 600;
  line-height: 1.3;
  margin: 0 0 1rem 0;
  color: #222;
}

/* Compact, readable defaults site-wide */
h1 { font-size: 1.5rem;   line-height: 1.25; } /* ~24px */
h2 { font-size: 1.25rem;  line-height: 1.3;  } /* ~20px */
h3 { font-size: 1.125rem; line-height: 1.35; } /* ~18px */
h4 { font-size: 1rem;     line-height: 1.4;  } /* ~16px */
h5 { font-size: 0.95rem;  line-height: 1.45; }
h6 { font-size: 0.875rem; line-height: 1.5;  }

/* Slight step up on larger screens */
@media (min-width: 768px){
  h1 { font-size: 1.75rem; }  /* ~28px */
  h2 { font-size: 1.5rem; }   /* ~24px */
  h3 { font-size: 1.25rem; }  /* ~20px */
}

@media (min-width: 1200px){
  h1 { font-size: 1.875rem; } /* ~30px */
  h2 { font-size: 1.625rem; } /* ~26px */
  h3 { font-size: 1.375rem; } /* ~22px */
}