/**
 * @file
 * Styles for Resource Listing Page (resources_main view with Facets)
 *
 * Mirrors the product-listing.css pattern: filters sidebar (left) + card grid (right).
 * Resource cards are white cards with document icon, title, related product, and download link.
 */

/* ==========================================================================
   Resource Listing Container
   ========================================================================== */

.resource-listing {
  padding: 2rem 0;
  margin-bottom: 3rem;
}

.resource-listing-view {
  position: relative;
}

/* ==========================================================================
   Filters Sidebar
   ========================================================================== */

.resource-listing__filters {
  padding-right: 2rem;
  margin-bottom: 2rem;
}

.resource-listing__filters-wrapper {
  background: transparent;
  border: none;
  padding: 1.5rem;
  border-radius: 8px;
  position: sticky;
  top: 2rem;
}

/* ==========================================================================
   Collapsible FILTERS Toggle Button
   ========================================================================== */

.resource-listing__filters-toggle {
  display: flex;
  align-items: center;
  width: 100%;
  padding: 0.875rem 1.25rem;
  background-color: var(--color-brand-secondary-blue);
  color: var(--color-brand-white);
  border: none;
  border-radius: 4px;
  font-weight: var(--font-weight-bold);
  font-size: var(--font-size-base);
  text-transform: uppercase;
  letter-spacing: var(--letter-spacing-wide);
  cursor: pointer;
  transition: background-color 0.3s ease;
  margin-bottom: 0;
}

.resource-listing__filters-toggle:hover {
  background-color: var(--color-brand-blue);
}

.resource-listing__filters-toggle:focus {
  outline: 2px solid var(--color-brand-blue);
  outline-offset: 2px;
}

.resource-listing__filters-toggle-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.25rem;
  height: 1.25rem;
  margin-right: 0.75rem;
  font-size: 1.25rem;
  font-weight: bold;
  line-height: 1;
}

.resource-listing__filters-toggle-text {
  flex-grow: 1;
  text-align: left;
}

/* Filters Content - Collapsible */
.resource-listing__filters-content {
  display: none;
  flex-direction: column;
  padding-top: 1.5rem;
  overflow: hidden;
  transition: max-height 0.3s ease-out;
}

.resource-listing__filters-content--expanded {
  display: flex;
}

/* Override core exposed filters floating */
.resource-listing__filters-content .exposed-filters,
.resource-listing__filters-content .filters {
  float: none !important;
  width: 100%;
  margin: 0;
}

/* Filter Form Items - Stack vertically */
.resource-listing__filters-content .form-item,
.resource-listing__filters-content .form-type-select,
.resource-listing__filters-content .form-type-checkboxes,
.resource-listing__filters-content .form-type-radios,
.resource-listing__filters-content .bef-wrapper {
  margin-bottom: 2.5rem;
  width: 100%;
  float: none !important;
  clear: both;
}

/* Base label styles */
.resource-listing__filters-content label {
  font-size: var(--font-size-base);
  color: var(--color-brand-secondary-blue);
  cursor: pointer;
}

/* Filter Group Heading Labels */
.resource-listing__filters-content > .form-item > label,
.resource-listing__filters-content > .bef-wrapper > label,
.resource-listing__filters-content .form-type-select > label,
.resource-listing__filters-content .form-type-checkboxes > label,
.resource-listing__filters-content .form-type-radios > label,
.resource-listing__filters-content .bef-label,
.resource-listing__filters-content fieldset > legend,
.resource-listing__filters-content .fieldset-legend {
  font-weight: var(--font-weight-bold);
  font-size: var(--text-filter-label);
  margin-bottom: 1rem;
  display: block;
  color: var(--color-brand-secondary-blue);
  text-transform: uppercase;
  letter-spacing: var(--letter-spacing-wide);
}

/* Fieldset wrapper */
.resource-listing__filters-content fieldset {
  border: none;
  padding: 0;
  margin: 0 0 2.5rem 0;
}

.resource-listing__filters-content fieldset > legend {
  border: none;
  padding: 0;
}

/* Select Dropdowns */
.resource-listing__filters-content select {
  width: 100%;
  padding: 0.75rem 2.5rem 0.75rem 0.75rem;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: var(--font-size-base);
  background-color: #fff;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2301426A' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  cursor: pointer;
}

.resource-listing__filters-content select:focus {
  outline: none;
  border-color: var(--color-brand-secondary-blue);
  box-shadow: 0 0 0 2px rgba(var(--color-brand-blue-rgb), 0.2);
}

/* Checkboxes Widget */
.resource-listing__filters-content .form-checkboxes {
  list-style: none;
  padding: 0;
  margin: 0.5rem 0 0 0;
}

.resource-listing__filters-content .form-checkboxes .form-item {
  margin-bottom: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.resource-listing__filters-content .form-checkboxes input[type="checkbox"] {
  margin-right: 0.5rem;
  margin-top: 0.25rem;
  vertical-align: middle;
}

.resource-listing__filters-content .form-checkboxes label {
  font-weight: normal;
  margin-bottom: 0;
  cursor: pointer;
  text-transform: none;
  letter-spacing: normal;
  font-size: var(--font-size-base);
  color: var(--color-text);
}

/* Radio Buttons Widget */
.resource-listing__filters-content .form-radios {
  list-style: none;
  padding: 0;
  margin: 0.5rem 0 0 0;
}

.resource-listing__filters-content .form-radios .form-item {
  margin-bottom: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.resource-listing__filters-content .form-radios input[type="radio"] {
  margin-right: 0.5rem;
  margin-top: 0.25rem;
  vertical-align: middle;
}

.resource-listing__filters-content .form-radios label {
  font-weight: normal;
  margin-bottom: 0;
  cursor: pointer;
  text-transform: none;
  letter-spacing: normal;
  font-size: var(--font-size-base);
}

/* Apply / Reset Buttons */
.resource-listing__filters-content .form-actions {
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid #ddd;
  text-align: center;
  width: 100%;
  float: none !important;
  clear: both;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.resource-listing__filters-content .form-actions .form-submit,
.resource-listing__filters-content .form-actions input[type="submit"],
.resource-listing__filters-content .form-actions button[type="submit"],
.resource-listing__filters-content .form-actions .button {
  width: 100%;
  padding: 0.875rem 1.5rem;
  background-color: var(--color-brand-secondary-blue);
  color: var(--color-brand-white);
  border: none;
  border-radius: 4px;
  font-weight: bold;
  font-size: var(--font-size-base);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  cursor: pointer;
  transition: background-color 0.3s ease;
  display: block;
}

.resource-listing__filters-content .form-actions .form-submit:hover,
.resource-listing__filters-content .form-actions input[type="submit"]:hover,
.resource-listing__filters-content .form-actions button[type="submit"]:hover,
.resource-listing__filters-content .form-actions .button:hover {
  background-color: var(--color-brand-blue);
}

.resource-listing__filters-content .form-actions input[type="reset"],
.resource-listing__filters-content .form-actions input[value="Reset"] {
  background-color: var(--color-brand-red);
  color: var(--color-brand-white);
  margin-left: 0 !important;
}

.resource-listing__filters-content .form-actions input[type="reset"]:hover,
.resource-listing__filters-content .form-actions input[value="Reset"]:hover {
  background-color: var(--color-brand-secondary-blue);
  color: var(--color-brand-white);
}

/* Ensure exposed form wrapper doesn't float */
.resource-listing__filters-content form.views-exposed-form {
  display: flex;
  flex-direction: column;
  width: 100%;
}

.resource-listing__filters-content form.views-exposed-form > * {
  float: none !important;
  width: 100%;
}

/* Facet blocks inside the filters sidebar */
.resource-listing__filters-content .block-facets,
.resource-listing__filters-content .block-facet {
  margin-bottom: 2rem;
}

.resource-listing__filters-content .block-facets h2,
.resource-listing__filters-content .block-facet h2 {
  font-weight: var(--font-weight-bold);
  font-size: var(--text-filter-label);
  margin-bottom: 1rem;
  color: var(--color-brand-secondary-blue);
  text-transform: uppercase;
  letter-spacing: var(--letter-spacing-wide);
}

.resource-listing__filters-content .facets-widget-checkbox ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.resource-listing__filters-content .facets-widget-checkbox li {
  margin-bottom: 0.5rem;
}

.resource-listing__filters-content .facets-widget-checkbox label {
  font-weight: normal;
  font-size: var(--font-size-base);
  color: var(--color-text);
  cursor: pointer;
}

/* ==========================================================================
   Main Content Area
   ========================================================================== */

.resource-listing__content {
  padding-left: 1rem;
}

.resource-listing__header {
  margin-bottom: 1.5rem;
}

.resource-listing__header .view-header {
  font-size: var(--font-size-base);
  color: #666;
  margin-bottom: 1rem;
}

/* ==========================================================================
   Resource Grid
   The unformatted template outputs <div class="resource-grid"> which is the
   single grid wrapper. Target it directly — no outer grid wrapper exists.
   ========================================================================== */

.resource-grid,
.views-view-unformatted.resource-grid {
  display: grid !important;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
  width: 100%;
}

/* Force 3 columns on wider screens for a tighter card look */
@media (min-width: 992px) {
  .resource-grid,
  .views-view-unformatted.resource-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* 2 columns on tablet */
@media (max-width: 991px) and (min-width: 576px) {
  .resource-grid,
  .views-view-unformatted.resource-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 1.25rem;
  }
}

/* Single column on mobile */
@media (max-width: 575px) {
  .resource-grid,
  .views-view-unformatted.resource-grid {
    grid-template-columns: 1fr;
    gap: 1.25rem;
  }
}

/* Grid Item */
.resource-grid__item {
  width: 100%;
  min-width: 0;
  display: block;
}

/* Ensure card fills its grid cell */
.resource-grid__item .resource-card {
  height: 100%;
}

/* ==========================================================================
   Resource Card
   ========================================================================== */

.resource-card {
  position: relative;
  background: #ffffff;
  border: 1px solid #e8e8e8;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  transition: all 0.25s ease;
  height: 100%;
  display: flex;
  flex-direction: column;
}

.resource-card:hover {
  border-color: var(--color-brand-blue);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.1);
  transform: translateY(-3px);
}

.resource-card__container {
  display: flex;
  flex-direction: column;
  height: 100%;
}

/* ==========================================================================
   Resource Card - Media / Thumbnail Area
   
   Every card gets a media region. A CSS ::before pseudo-element draws a
   large document/PDF icon as the default background. For videos and images
   the actual media covers it; for PDFs the raw file-link text is hidden
   so only the icon shows.
   ========================================================================== */

.resource-card__media {
  width: 100%;
  height: 160px;
  overflow: hidden;
  background: #eef2f7;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

/* ---------- Shared icon base (::before) ---------- */
.resource-card__media::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 56px;
  height: 64px;
  z-index: 1;
  opacity: 1;
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  pointer-events: none;
}

/* ---------- Document / PDF icon (default & explicit) ---------- */
.resource-card--document .resource-card__media::before,
.resource-card__media::before {
  /* PDF / document icon – red page with folded corner and "PDF" text */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 56 64' fill='none'%3E%3Cpath d='M4 0h32l16 16v44a4 4 0 0 1-4 4H4a4 4 0 0 1-4-4V4a4 4 0 0 1 4-4z' fill='%23dc3545'/%3E%3Cpath d='M36 0l16 16H40a4 4 0 0 1-4-4V0z' fill='%23b02a37'/%3E%3Ctext x='28' y='44' text-anchor='middle' font-family='Arial,sans-serif' font-weight='bold' font-size='14' fill='white'%3EPDF%3C/text%3E%3C/svg%3E");
}

/* ---------- Video icon ----------
   Blue play-button circle – shown when the card has .resource-card--video */
.resource-card--video .resource-card__media {
  background: #e8f0fe;
}

.resource-card--video .resource-card__media::before {
  width: 64px;
  height: 64px;
  /* Blue circle with white play triangle */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 64' fill='none'%3E%3Ccircle cx='32' cy='32' r='32' fill='%230d6efd'/%3E%3Cpolygon points='26,18 26,46 48,32' fill='white'/%3E%3C/svg%3E");
}

/* ---------- Video / Image content ----------
   When a <video> or <img> is present it covers the icon. */
.resource-card__media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  position: relative;
  z-index: 2;
}

.resource-card__media video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  position: relative;
  z-index: 2;
}

/* Media entity wrapper – ensure it fills the area */
.resource-card__media .media,
.resource-card__media .contextual-region,
.resource-card__media .field-content,
.resource-card__media .field {
  position: relative;
  z-index: 2;
  width: 100%;
  height: 100%;
}

/* ---------- Hide raw file-link text for documents ----------
   PDFs render as <span class="file"><a href="...">filename.pdf</a></span>.
   Hide that text so the icon shows cleanly. The actual download link is
   in the card footer area instead. */
.resource-card__media .file,
.resource-card__media a[href$=".pdf"],
.resource-card__media a[href$=".doc"],
.resource-card__media a[href$=".docx"],
.resource-card__media a[href$=".xls"],
.resource-card__media a[href$=".xlsx"],
.resource-card__media a[href$=".ppt"],
.resource-card__media a[href$=".pptx"],
.resource-card__media a[href$=".txt"] {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Also hide any generic file field wrapper text that isn't a video */
.resource-card__media .file--general,
.resource-card__media .file--application-pdf,
.resource-card__media .file--x-office-document,
.resource-card__media .file--x-office-spreadsheet,
.resource-card__media .file--x-office-presentation {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* When a video IS present, hide the icon since the video covers it */
.resource-card__media:has(video)::before,
.resource-card__media:has(img)::before {
  display: none;
}

/* ==========================================================================
   Resource Card - Content
   ========================================================================== */

.resource-card__content {
  padding: 1.25rem 1.5rem;
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

/* Document Type Badge */
.resource-card__type {
  font-size: 0.7rem;
  font-weight: var(--font-weight-bold);
  text-transform: uppercase;
  letter-spacing: var(--letter-spacing-wide);
  color: #ffffff;
  background-color: var(--color-brand-secondary-blue);
  padding: 0.2rem 0.6rem;
  border-radius: 3px;
  display: inline-block;
  margin-bottom: 0.75rem;
}

/* Title */
.resource-card__title {
  margin: 0 0 0.75rem 0;
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-bold);
  color: var(--color-brand-secondary-blue);
  line-height: var(--line-height-snug);
  text-align: center;
}

.resource-card__title a {
  color: inherit;
  text-decoration: none;
}

.resource-card__title a:hover {
  color: var(--color-brand-blue);
  text-decoration: underline;
}

/* Related Product */
.resource-card__product {
  font-size: var(--font-size-sm);
  color: #666;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.resource-card__product-label {
  font-weight: var(--font-weight-semibold);
  color: var(--color-brand-secondary-blue);
}

.resource-card__product-value {
  color: #555;
}

.resource-card__product-value a {
  color: var(--color-brand-blue);
  text-decoration: none;
}

.resource-card__product-value a:hover {
  text-decoration: underline;
}

/* Download / Open Link */
.resource-card__link {
  margin-top: auto;
  padding-top: 0.75rem;
  text-align: center;
}

.resource-card__link a {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 1.25rem;
  background-color: var(--color-brand-green);
  color: var(--color-brand-white);
  text-decoration: none;
  border-radius: 30px;
  font-weight: var(--font-weight-bold);
  font-size: var(--font-size-sm);
  text-align: center;
  transition: background-color 0.3s ease;
}

.resource-card__link a:hover {
  background-color: var(--color-brand-blue);
  color: var(--color-brand-white);
}

/* Download icon before link text */
.resource-card__link a::before {
  content: '';
  display: inline-block;
  width: 16px;
  height: 16px;
  background-color: currentColor;
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2.5'%3E%3Cpath d='M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4'/%3E%3Cpolyline points='7 10 12 15 17 10'/%3E%3Cline x1='12' y1='15' x2='12' y2='3'/%3E%3C/svg%3E");
  mask-size: contain;
  mask-repeat: no-repeat;
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2.5'%3E%3Cpath d='M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4'/%3E%3Cpolyline points='7 10 12 15 17 10'/%3E%3Cline x1='12' y1='15' x2='12' y2='3'/%3E%3C/svg%3E");
  -webkit-mask-size: contain;
  -webkit-mask-repeat: no-repeat;
}

/* ==========================================================================
   Document Type Badge Color Variations
   (matches the icon colors from existing view-resources)
   ========================================================================== */

.resource-card--fields.tech-specs .resource-card__type {
  background-color: #0891b2;
}

.resource-card--fields.installation-guide .resource-card__type {
  background-color: #059669;
}

.resource-card--fields.warranty .resource-card__type {
  background-color: #d97706;
}

.resource-card--fields.plan-view .resource-card__type {
  background-color: #4f46e5;
}

.resource-card--fields.comparison-chart .resource-card__type {
  background-color: #7c3aed;
}

.resource-card--fields.maintenance-checklist .resource-card__type {
  background-color: #0d9488;
}

.resource-card--fields.brochure .resource-card__type {
  background-color: #ea580c;
}

/* ==========================================================================
   Empty State
   ========================================================================== */

.resource-listing__empty {
  padding: 3rem 2rem;
  text-align: center;
  background: #f9f9f9;
  border-radius: 8px;
  color: #666;
}

.resource-listing__empty h3 {
  margin-bottom: 1rem;
  color: var(--color-brand-secondary-blue);
}

/* ==========================================================================
   Pager / Load More
   ========================================================================== */

.resource-listing__pager {
  margin-top: 2rem;
  text-align: center;
}

.resource-listing__pager .pager {
  margin: 0;
  padding: 0;
  list-style: none;
}

.resource-listing__pager .pager__item {
  display: inline-block;
  margin: 0 0.25rem;
}

.resource-listing__pager .pager__item a {
  display: inline-block;
  padding: 0.75rem 1.5rem;
  background: var(--color-brand-green);
  color: var(--color-brand-white);
  text-decoration: none;
  border-radius: 30px;
  font-weight: bold;
  transition: background-color 0.3s ease;
}

.resource-listing__pager .pager__item a:hover,
.resource-listing__pager .pager__item a:focus {
  background: var(--color-brand-blue);
  color: var(--color-brand-white);
}

.resource-listing__pager .pager__item.is-active a {
  background: var(--color-brand-secondary-blue);
  color: var(--color-brand-white);
}

/* Load More Button */
.resource-listing__more {
  margin-top: 2rem;
  text-align: center;
}

.resource-listing__more .more-link {
  display: inline-block;
  padding: 0.75rem 2rem;
  background: var(--color-brand-green);
  color: var(--color-brand-white);
  text-decoration: none;
  border-radius: 30px;
  font-weight: bold;
  font-size: var(--font-size-base);
  transition: background-color 0.3s ease;
}

.resource-listing__more .more-link:hover,
.resource-listing__more .more-link:focus {
  background: var(--color-brand-blue);
  color: var(--color-brand-white);
}

/* ==========================================================================
   Responsive: Mobile Filters
   ========================================================================== */

@media (max-width: 991px) {
  .resource-listing__filters {
    padding-right: 0;
    margin-bottom: 2rem;
  }

  .resource-listing__filters-wrapper {
    position: relative;
    top: 0;
  }

  .resource-listing__content {
    padding-left: 0;
  }
}

/* ==========================================================================
   AJAX Loading State
   ========================================================================== */

.resource-listing-view.ajax-progress {
  position: relative;
  min-height: 200px;
}

.resource-listing-view.ajax-progress::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 40px;
  height: 40px;
  border: 4px solid #f3f3f3;
  border-top: 4px solid var(--color-brand-blue);
  border-radius: 50%;
  animation: resource-spin 1s linear infinite;
}

@keyframes resource-spin {
  0% { transform: translate(-50%, -50%) rotate(0deg); }
  100% { transform: translate(-50%, -50%) rotate(360deg); }
}

/* ==========================================================================
   Footer
   ========================================================================== */

.resource-listing__footer {
  margin-top: 3rem;
  padding-top: 2rem;
  border-top: 1px solid #ddd;
}
