/**
 * Sirona Core – Resource Center Archive Styles
 * Loaded on is_post_type_archive('resource') only.
 * Covers: filter nav, resource grid, cards, loading/error states.
 */

/* ----------------------------------------
   Filter Navigation — vertical left rail
   ---------------------------------------- */
.sirona-resource-nav {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-xs, 6px);
}

.sirona-resource-nav .menu-item {
  display: block;
  text-decoration: none;
  color: var(--color-primary, #1a4a6e);
  font-weight: var(--weight-semibold, 600);
  font-size: var(--size-body, 1rem);
  padding: var(--spacing-xs, 6px) var(--spacing-md, 16px);
  border-left: 3px solid transparent;
  background: transparent;
  cursor: pointer;
  transition: color 0.2s ease, background-color 0.2s ease, border-color 0.2s ease;
  white-space: nowrap;
}

.sirona-resource-nav .menu-item:hover {
  color: var(--color-secondary, #058abe);
  background-color: var(--color-gray-100, #f3f4f6);
  border-left-color: var(--color-gray-400, #9ca3af);
}

.sirona-resource-nav .menu-item.active {
  color: var(--color-secondary, #058abe);
  background-color: var(--color-secondary-light, #e0f2fb);
  border-left-color: var(--color-secondary, #058abe);
  font-weight: var(--weight-bold, 700);
}

/* ----------------------------------------
   Layout containment — three-layer fix
   Problem: BB renders the nav + grid inside a flex-direction:row outer box.
   The grid's BB box module and html module both default to flex-basis:auto /
   min-width:auto, allowing the CSS grid's intrinsic width to balloon and
   overflow left over the nav column.
   Fix at every level of the chain:
     1. The BB box module wrapping the grid  → overflow:hidden + flex fill
     2. The fl-module-html inside it         → same
     3. The .resource-grid itself            → width:100% + min-width:0
   ---------------------------------------- */

/* Level 1: the fl-module-box that directly contains the grid html module */
.fl-module-box:has(.resource-grid) {
  min-width: 0;
  flex: 1 1 0%;
  overflow: hidden;
}

/* Level 2: the fl-module-html whose direct content is the grid */
.fl-module-html:has(.resource-grid) {
  flex: 1 1 0%;
  min-width: 0;
  overflow: hidden;
  width: 100%;
}

/* Level 3: our own wrapper — no :has() needed, no BB node ID needed */
.sirona-grid-area {
  flex: 1 1 0%;
  min-width: 0;
  overflow: hidden;
  width: 100%;
}

/* ----------------------------------------
   Resource Grid
   ---------------------------------------- */
.resource-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: var(--spacing-2xl, 48px);
  min-height: 300px;
  width: 100%;
  min-width: 0;
}

/* ----------------------------------------
   Resource Card
   ---------------------------------------- */
.resource-card {
  background: var(--bg-primary, #fff);
  border: 1px solid var(--color-gray-300, #d1d5db);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.resource-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
}

.resource-card .card-link {
  text-decoration: none;
  color: inherit;
  display: flex;
  flex-direction: column;
  height: 100%;
}

.resource-card .card-image {
  height: 200px;
  overflow: hidden;
  background: var(--color-gray-100, #f3f4f6);
}

.resource-card .card-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}

.resource-card:hover .card-image img {
  transform: scale(1.04);
}

.resource-card .card-content {
  padding: var(--spacing-lg, 24px);
  flex-grow: 1;
  display: flex;
  flex-direction: column;
}

.resource-card .card-content h3 {
  font-size: var(--size-h5, 1.125rem);
  font-weight: var(--weight-semibold, 600);
  color: var(--color-primary, #1a4a6e);
  margin: 0 0 var(--spacing-sm, 8px) 0;
  line-height: 1.4;
}

.resource-card .card-content p {
  font-size: var(--size-body-sm, 0.9rem);
  color: var(--color-gray-700, #374151);
  flex-grow: 1;
  margin-bottom: var(--spacing-md, 16px);
  line-height: 1.6;
}

.resource-card .card-cta {
  font-weight: var(--weight-bold, 700);
  color: var(--color-secondary, #058abe);
  font-size: var(--size-body-sm, 0.9rem);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  transition: color 0.2s ease;
}

.resource-card:hover .card-cta {
  color: var(--color-secondary-dark, #047aaa);
}

/* ----------------------------------------
   Loading / Error / Empty states
   ---------------------------------------- */
.resource-grid .loading,
.resource-grid .error,
.resource-grid .no-content {
  grid-column: 1 / -1;
  text-align: center;
  padding: var(--spacing-3xl, 64px) var(--spacing-lg, 24px);
  font-size: var(--size-body-lg, 1.125rem);
  color: var(--color-gray-600, #4b5563);
}

/* ----------------------------------------
   Responsive
   ---------------------------------------- */
@media (max-width: 768px) {
  /* On mobile: nav goes horizontal across the top */
  .sirona-resource-nav {
    flex-direction: row;
    flex-wrap: wrap;
    gap: var(--spacing-xs, 6px);
    margin-bottom: var(--spacing-lg, 24px);
    padding-bottom: var(--spacing-md, 16px);
    border-bottom: 1px solid var(--color-gray-300, #d1d5db);
    border-left: none;
  }

  .sirona-resource-nav .menu-item {
    border-left: none;
    border-bottom: 2px solid transparent;
    padding: 6px 12px;
    font-size: var(--size-body-sm, 0.9rem);
  }

  .sirona-resource-nav .menu-item.active {
    border-bottom-color: var(--color-secondary, #058abe);
    background-color: var(--color-secondary-light, #e0f2fb);
  }

  .resource-grid {
    grid-template-columns: 1fr;
    gap: var(--spacing-xl, 32px);
  }
}

@media (min-width: 769px) and (max-width: 1024px) {
  .resource-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}
