/* Loading state for AJAX updates */
.anj-subject-filtered-lessons {
  position: relative;
}

.anj-subject-filtered-lessons.is-loading {
  opacity: 0.6;
  pointer-events: none;
}

.anj-loading-overlay {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: rgba(255, 255, 255, 0.7);
  border-radius: 12px;
}

.anj-loading-overlay.is-hidden {
  display: none;
}

.anj-loading-spinner {
  width: 18px;
  height: 18px;
  border-radius: 999px;
  border: 2px solid rgba(17, 24, 39, 0.25);
  border-top-color: rgba(17, 24, 39, 0.75);
  animation: anjResourcesSpin 0.8s linear infinite;
}

.anj-loading-text {
  font-size: 14px;
  font-weight: 700;
  color: rgba(17, 24, 39, 0.85);
}

@keyframes anjResourcesSpin {
  to {
    transform: rotate(360deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  .anj-loading-spinner {
    animation: none;
  }
}

/* ==========================
   SELECT-BASED FILTERS
   ========================== */

/* Unify placeholder colors across selects + search input */
#anj-subject-filter {
  --anj-filter-text-color: #111827;
  --anj-filter-placeholder-color: rgba(17, 24, 39, 0.55);
}

#anj-subject-filter .anj-filter-form-selects {
  border: 1px solid #e4e7eb;
  border-radius: 16px;
  padding: 16px;
  background: #fff;
  margin-bottom: 0;
}

#anj-subject-filter .anj-filter-selects {
  margin: 0;
}

#anj-subject-filter .anj-filter-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
}

#anj-subject-filter .anj-filter-select {
  min-width: 0;
}

#anj-subject-filter .anj-filter-select--search {
  grid-column: 1 / -1;
}

#anj-subject-filter .anj-filter-label {
  display: block;
  font-weight: 600;
  font-size: 1rem;
  margin: 0 0 12px;
  min-width: 0;
}

#anj-subject-filter .anj-filter-control {
  width: 100%;
  padding: 10px 16px;
  border: 1px solid #e4e7eb;
  border-radius: 12px;
  background: #fff;
  font-size: 14px;
  line-height: 1.2;
  color: var(--anj-filter-text-color);
}

/* Search input placeholder */
#anj-subject-filter .anj-filter-control::placeholder {
  color: var(--anj-filter-placeholder-color);
  opacity: 1;
}

/* Select "placeholder" (first empty option) is styled via JS class */
#anj-subject-filter select.anj-filter-control.anj-is-placeholder {
  color: var(--anj-filter-placeholder-color);
}

/* Selected values should match the Filter Summary styling */
#anj-subject-filter #anj-filter-grade.anj-filter-control:not(.anj-is-placeholder) {
  color: #529D00;
  font-weight: 700;
}

#anj-subject-filter #anj-filter-theme.anj-filter-control:not(.anj-is-placeholder) {
  color: #ba6f00;
  font-weight: 700;
}

#anj-subject-filter #anj-filter-search.anj-filter-control:not(:placeholder-shown) {
  color: #6b7280;
  font-weight: 700;
}

#anj-subject-filter .anj-filter-control:disabled {
  cursor: not-allowed;
  opacity: 1;
  background: #f9fafb;
  border-color: #e5e7eb;
  color: var(--anj-filter-text-color);
}

/* Disabled selects that are still on the empty option should keep placeholder color */
#anj-subject-filter select.anj-filter-control.anj-is-placeholder:disabled {
  color: var(--anj-filter-placeholder-color);
}

/* Keep selected value colors even while controls are temporarily disabled (e.g., during loading) */
#anj-subject-filter #anj-filter-grade.anj-filter-control:not(.anj-is-placeholder):disabled {
  color: #529D00;
  font-weight: 700;
}

#anj-subject-filter #anj-filter-theme.anj-filter-control:not(.anj-is-placeholder):disabled {
  color: #ba6f00;
  font-weight: 700;
}

#anj-subject-filter #anj-filter-search.anj-filter-control:not(:placeholder-shown):disabled {
  color: #6b7280;
  font-weight: 700;
}

#anj-subject-filter .anj-filter-footer {
  margin-top: 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}

#anj-subject-filter .anj-filter-select--checkbox {
  display: flex;
  align-items: center;
  flex: 1 1 auto;
}

#anj-subject-filter .anj-filter-checkbox {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  font-size: 16px;
  font-weight: 600;
  color: #111827;
  cursor: pointer;
  user-select: none;
}

#anj-subject-filter .anj-filter-checkbox input[type="checkbox"] {
  width: 18px;
  height: 18px;
  border-radius: 4px;
}

#anj-subject-filter .anj-filter-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex: 0 0 auto;
}

#anj-subject-filter .anj-filter-reset {
  border: none !important;
  background: #ce0000 !important;
  color: #ffffff !important;
  padding: 10px 14px !important;
  border-radius: 30px !important;
  cursor: pointer !important;
  font-size: 13px !important;
  line-height: 1 !important;
  transition:
    background 0.15s ease,
    color 0.15s ease,
    box-shadow 0.15s ease,
    transform 0.1s ease;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
}

#anj-subject-filter .anj-filter-reset:hover {
  transform: scale(1.05) !important;
}

#anj-subject-filter .anj-filter-apply {
  border: none !important;
  background: var(--e-global-color-secondary) !important;
  color: #fff !important;
  padding: 10px 14px !important;
  border-radius: 30px !important;
  cursor: pointer !important;
  font-size: 13px !important;
  line-height: 1 !important;
}

@media (max-width: 640px) {
  #anj-subject-filter .anj-filter-grid {
    grid-template-columns: 1fr;
  }

  #anj-subject-filter .anj-filter-select--search {
    grid-column: auto;
  }
}

/* FILTER LAYOUT */
.anj-subject-filter-buttons {
  margin-bottom: 0;
}

.anj-filter-row {
  margin-bottom: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.anj-filter-label {
  font-weight: 600;
  font-size: 0.95rem;
  min-width: 70px;
}

.anj-filter-buttons-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.anj-filter-themes-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.anj-filter-button {
  border: none !important;
  background: var(--e-global-color-accent) !important;
  color: var(--e-global-color-secondary) !important;
  padding: 8px 15px !important;
  border-radius: 30px !important;
  cursor: pointer !important;
  font-size: 13px !important;
  line-height: 1 !important;
  transition:
    background 0.15s ease,
    color 0.15s ease,
    border-color 0.15s ease,
    box-shadow 0.15s ease,
    transform 0.1s ease;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
}

.anj-filter-button:hover {
  transform: scale(1.1) !important;
}

.anj-filter-button.is-active {
  background: var(--e-global-color-secondary) !important;
  color: #fff !important;
  font-weight: 800;
}

.anj-filter-button.anj-filter-button-theme {
  background: #FFECB3 !important;
  color: #ba6f00 !important;
}

.anj-filter-button.anj-filter-button-theme.is-active {
  background: #ff9902 !important;
  color: #fff !important;
  font-weight: 800;
}

/* LESSONS LIST: single column, wide cards (image left, text right) */
.anj-subject-filtered-lessons {
  margin-top: 1.5rem;
}

/* Single column */
.anj-subject-filtered-lessons ul.anj-lessons-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: block !important;
}

/* Card */
.anj-subject-filtered-lessons .anj-lessons-list .anj-lesson-item {
  width: 100%;
  box-sizing: border-box;
  border-radius: 12px;
  overflow: hidden;
  background: #ffffff;
  border: 1px solid #e4e7eb;
  box-shadow: none;
  /* Keep interactions calm (no lift/hover animation on material previews). */
  transition: none;
  margin-bottom: 1rem;
}

.anj-subject-filtered-lessons .anj-lessons-list .anj-lesson-item:last-child {
  margin-bottom: 0;
}


/* Remove any hover shadow/transform on lesson items (also guards against theme styles). */
.anj-subject-filtered-lessons .anj-lessons-list .anj-lesson-item:hover,
.anj-subject-filtered-lessons .anj-lessons-list .anj-lesson-item:focus-within {
  box-shadow: none !important;
  transform: none !important;
}




.anj-subject-filtered-lessons .anj-lesson-link {
  display: block;
  color: inherit;
  text-decoration: none;
  height: 100%;
}

/* Avoid theme-level hover decorations on the material title link. */
.anj-subject-filtered-lessons .anj-lesson-link:hover,
.anj-subject-filtered-lessons .anj-lesson-link:focus {
  color: inherit;
  text-decoration: none;
}

/* Horizontal layout */
.anj-subject-filtered-lessons .anj-lesson-preview {
  display: flex;
  flex-direction: row;
  /* Prevent image area from stretching with variable text height. */
  align-items: flex-start;
}

/* Thumb left */
.anj-subject-filtered-lessons .anj-lesson-thumb {
  flex: 0 0 220px;
  max-width: 220px;
  /* Consistent thumbnail size across all materials. */
  height: 124px;
  aspect-ratio: 16 / 9;
  background: #f3f4f6;
  position: relative;
  overflow: hidden;
}

.anj-subject-filtered-lessons .anj-lesson-thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.anj-subject-filtered-lessons .anj-lesson-thumb-img--placeholder {
  /* Make placeholders look intentional (slightly muted). */
  opacity: 0.9;
}

/* Text right */
.anj-subject-filtered-lessons .anj-lesson-text {
  padding: 0.85rem 1rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  flex: 1;
  min-width: 0;
}

.anj-subject-filtered-lessons .anj-lesson-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  color: #111827;
}

/* Tags (Grade / Theme) */
.anj-subject-filtered-lessons .anj-lesson-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.1rem;
}

button.anj-tag {
  display: inline-flex;
  align-items: center;
  padding: 0.12rem 0.65rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 500;
  line-height: 1.2;
  background: #eef2ff;
  color: #3730a3;
  border: 0;
  cursor: pointer;
  text-decoration: none;
  font-family: inherit;
  -webkit-appearance: none;
  appearance: none;
}

button.anj-tag:focus-visible {
  outline: 2px solid #4f46e5;
  outline-offset: 2px;
}

button.anj-tag.anj-tag-grade {
  border: none !important;
  background: var(--e-global-color-accent) !important;
  color: var(--e-global-color-secondary) !important;
  padding: 8px 15px !important;
  border-radius: 30px !important;
  cursor: pointer !important;
  font-size: 13px !important;
  line-height: 1 !important;
}

button.anj-tag.anj-tag-theme {
  background: #FFECB3 !important;
  color: #ba6f00 !important;
  border: none !important;
  padding: 8px 15px !important;
  border-radius: 30px !important;
  cursor: pointer !important;
  font-size: 13px !important;
  line-height: 1 !important;
}

/* Style tags (non-clickable spans, e.g. Constructivism) */
span.anj-tag {
  display: inline-flex;
  align-items: center;
  padding: 0.12rem 0.65rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 500;
  line-height: 1.2;
  background: #eef2ff;
  color: #3730a3;
  border: 0;
  text-decoration: none;
  font-family: inherit;
}

span.anj-tag.anj-tag-style {
  background: #e0f2fe;
  color: #0369a1;
  cursor: pointer;
}

/* Excerpt */
.anj-subject-filtered-lessons .anj-lesson-excerpt {
  font-size: 0.9rem;
  color: #4b5563;
  margin-top: 0.1rem;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Call-to-action affordance */
.anj-subject-filtered-lessons .anj-lesson-text::after {
  content: "View lesson →";
  font-size: 0.8rem;
  color: #0073aa;
  margin-top: auto;
  opacity: 0.85;
}

/* Empty state */
.anj-subject-filtered-lessons .anj-no-lessons {
  padding: 1rem 1.25rem;
  border-radius: 10px;
  background: #f9fafb;
  border: 1px dashed #d1d5db;
  color: #4b5563;
  font-size: 0.92rem;
}

/* Responsive */
@media (max-width: 640px) {

  /* Keep the same left-image / right-content layout on mobile. */
  .anj-subject-filtered-lessons .anj-lesson-preview {
    flex-direction: row;
    align-items: flex-start;
  }

  .anj-subject-filtered-lessons .anj-lesson-thumb {
    flex: 0 0 120px;
    max-width: 120px;
    height: 68px;
  }

  .anj-subject-filtered-lessons .anj-lesson-text {
    padding: 0.75rem 0.85rem 0.85rem;
  }

  .anj-subject-filtered-lessons .anj-lesson-title {
    font-size: 0.95rem;
  }

  .anj-subject-filtered-lessons .anj-lesson-excerpt {
    -webkit-line-clamp: 2;
  }
}

/* ==========================
   CURRICULUM MAP
   ========================== */

.anj-curriculum-map {
  margin-top: 2.5rem;
  border-top: 1px solid #e5e7eb;
  padding-top: 1.5rem;
  font-size: 0.95rem;
  color: #111827;
}

.anj-curriculum-subject {
  margin-bottom: 2rem;
  padding: 1.2rem 1.4rem;
  border-radius: 12px;
  background: #f9fafb;
  border: 1px solid #e5e7eb;
}

.anj-curriculum-subject-header {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.75rem;
}

.anj-curriculum-subject-title {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 600;
}

/* Chips for Subject / Grade / Theme labels */
.anj-curriculum-chip {
  display: inline-flex;
  align-items: center;
  padding: 0.12rem 0.6rem;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.anj-curriculum-chip-subject {
  background: #e0f2fe;
  color: #0369a1;
}

.anj-curriculum-chip-grade {
  background: #ede9fe;
  color: #5b21b6;
}

.anj-curriculum-chip-theme {
  background: #fef3c7;
  color: #92400e;
}

/* Grade list */
.anj-curriculum-grade-list {
  list-style: none;
  margin: 0.5rem 0 0;
  padding-left: 0;
  border-left: 2px solid #e5e7eb;
}

.anj-curriculum-grade-item {
  margin: 0;
  padding: 0.6rem 0 0.6rem 1.1rem;
  position: relative;
}

.anj-curriculum-grade-item::before {
  content: "";
  position: absolute;
  left: -2px;
  top: 1.05rem;
  width: 10px;
  height: 2px;
  background: #e5e7eb;
}

.anj-curriculum-grade-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
}

.anj-curriculum-grade-name {
  font-weight: 500;
}

/* Theme list */
.anj-curriculum-theme-list {
  list-style: none;
  margin: 0.25rem 0 0;
  padding-left: 0.9rem;
  border-left: 1px dashed #e5e7eb;
}

.anj-curriculum-theme-item {
  margin: 0;
  padding: 0.45rem 0 0.45rem 0.7rem;
  position: relative;
}

.anj-curriculum-theme-item::before {
  content: "";
  position: absolute;
  left: -1px;
  top: 0.95rem;
  width: 8px;
  height: 1px;
  background: #e5e7eb;
}

.anj-curriculum-theme-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.25rem;
}

.anj-curriculum-theme-name {
  font-weight: 500;
}

/* Resources under theme */
.anj-curriculum-resource-list {
  list-style: none;
  margin: 0.15rem 0 0.1rem;
  padding-left: 0;
}

.anj-curriculum-resource-item {
  margin: 0;
  padding: 0.15rem 0;
}

.anj-curriculum-resource-link {
  text-decoration: none;
  color: #2563eb;
  font-size: 0.9rem;
}

.anj-curriculum-resource-link:hover {
  text-decoration: underline;
}

/* Empty states */
.anj-curriculum-grade-empty,
.anj-curriculum-theme-empty,
.anj-curriculum-resource-empty {
  margin-top: 0.2rem;
  font-size: 0.85rem;
  color: #6b7280;
}

/* Map message */
.anj-curriculum-map-message {
  margin-top: 1rem;
  font-size: 0.95rem;
  color: #6b7280;
}

/* ==========================
   FILTER SUMMARY
   ========================== */

.anj-filter-summary {
  margin-top: 0.6rem;
  font-size: 0.92rem;
  color: #6b7280;
}

.anj-filter-summary.is-hidden {
  display: none;
}

.anj-filter-summary-grade {
  color: #529D00;
  font-weight: 700;
}

.anj-filter-summary-theme {
  color: #ba6f00;
  font-weight: 700;
}

.anj-filter-summary-style {
  color: #0369a1;
  font-weight: 700;
}

.anj-filter-summary-query {
  font-weight: 700;
}

/* Reset button disabled state */
#anj-subject-filter .anj-filter-reset:disabled,
#anj-subject-filter .anj-filter-reset.is-disabled {
  background: #e5e7eb !important;
  color: #ffffff !important;
  opacity: 1;
  cursor: not-allowed !important;
  transform: none !important;
  box-shadow: none !important;
}

#anj-subject-filter .anj-filter-reset:disabled:hover,
#anj-subject-filter .anj-filter-reset.is-disabled:hover {
  transform: none !important;
}

/* ==========================
   MATERIALS PAGINATION
   ========================== */

.anj-materials-pagination {
  margin-top: 1.25rem;
  display: flex;
  justify-content: center;
}

.anj-materials-pagination-wrap--top .anj-materials-pagination {
  margin-top: 0;
  margin-bottom: 1.25rem;
}

.anj-materials-pagination-wrap--bottom .anj-materials-pagination {
  margin-top: 1.25rem;
  margin-bottom: 0;
}


/* Pagination toolbar (per-page selector) */
.anj-pagination-toolbar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 0.75rem;
}

.anj-per-page-form {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.anj-per-page-label {
  font-size: 0.9rem;
  font-weight: 600;
  color: #111827;
  white-space: nowrap;
}

.anj-per-page-control {
  padding: 8px 10px;
  border: 1px solid #e4e7eb;
  border-radius: 12px;
  background: #ffffff;
  font-size: 14px;
  line-height: 1.2;
  color: #111827;
}

.anj-per-page-control:disabled {
  cursor: not-allowed;
  background: #f9fafb;
  border-color: #e5e7eb;
  opacity: 1;
}

@media (max-width: 640px) {
  .anj-pagination-toolbar {
    justify-content: center;
  }
}


.anj-pagination {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  justify-content: center;
}

.anj-pagination .anj-page {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 38px;
  height: 38px;
  padding: 0 0.85rem;
  border-radius: 999px;
  border: 1px solid #e5e7eb;
  background: #ffffff;
  color: #111827;
  font-size: 0.9rem;
  text-decoration: none;
  cursor: pointer;
  user-select: none;
}

.anj-pagination .anj-page:hover {
  transform: translateY(-1px);
}

.anj-pagination .anj-page.is-current {
  background: #111827;
  color: #ffffff;
  border-color: #111827;
  cursor: default;
}

.anj-pagination .anj-page.is-disabled {
  background: #e5e7eb;
  color: #ffffff;
  border-color: #e5e7eb;
  cursor: not-allowed;
}

.anj-pagination .anj-ellipsis {
  display: inline-flex;
  padding: 0 0.35rem;
  color: #6b7280;
}