/* ==========================================================================
 * eCredit home
 * ========================================================================== */

.catalog-layout-shell {
  --home-sidebar-top: 112px;
  --home-sidebar-width: clamp(240px, 24vw, 272px);
  --home-shell-padding-inline: clamp(1rem, 2.4vw, 2rem);
  --home-shell-gap: clamp(1.25rem, 2vw, 2rem);
  position: relative;
  width: 100%;
}

.catalog-layout-shell::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: var(--home-sidebar-width);
  background: var(--white);
  border-right: 1px solid var(--border-color);
  box-shadow: 20px 0 32px rgba(15, 23, 42, 0.06);
  pointer-events: none;
}

.mobile-filter-bar {
  display: none;
}

.container {
  display: flex;
  align-items: stretch;
  gap: var(--home-shell-gap);
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 0 var(--home-shell-padding-inline) 0 0;
  position: relative;
  z-index: 1;
}

.sidebar {
  flex: 0 0 var(--home-sidebar-width);
  width: var(--home-sidebar-width);
  position: sticky;
  top: var(--home-sidebar-top);
  min-height: calc(100vh - var(--home-sidebar-top));
  max-height: calc(100vh - var(--home-sidebar-top));
  overflow-y: auto;
  background-color: transparent;
  padding: clamp(1.25rem, 1.8vw, 1.75rem) 1.5rem 2rem;
  border: none;
  box-shadow: none;
}

.filter-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid #f0f0f0;
  font-weight: 700;
}

.btn-clear-filter {
  border: none;
  background: none;
  color: var(--primary-green);
  cursor: pointer;
  font-size: 0.75rem;
  text-decoration: underline;
}

.filter-group {
  margin-bottom: 1.5rem;
}

.filter-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  position: relative;
  margin-bottom: 0.5rem;
  color: var(--text-main);
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 600;
}

.filter-header:hover {
  color: var(--primary-green);
}

.filter-header-badge {
  display: none;
  width: 8px;
  height: 8px;
  margin-left: 6px;
  border-radius: 50%;
  background-color: var(--primary-green);
  vertical-align: middle;
}

.filter-header.active .filter-header-badge {
  display: inline-block;
}

.filter-content {
  display: none;
  flex-direction: column;
  gap: 0.6rem;
  padding-left: 0.5rem;
}

.filter-content.open {
  display: flex;
}

.filter-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text-sub);
  cursor: pointer;
  font-size: 0.9rem;
}

.filter-item input {
  accent-color: var(--primary-green);
  cursor: pointer;
}

.main-content {
  flex: 1;
  min-width: 0;
  max-width: min(
    1120px,
    calc(
      100vw - var(--home-sidebar-width) - var(--home-shell-padding-inline) -
        var(--home-shell-gap)
    )
  );
  padding: clamp(1.25rem, 2vw, 2rem) 0 2.5rem;
}

.results-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.results-count {
  font-size: 1.1rem;
  font-weight: 700;
}

.course-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: clamp(1rem, 2vw, 1.5rem);
}

.course-card {
  display: block;
  position: relative;
  overflow: hidden;
  min-width: 0;
  padding: 1rem 1.2rem;
  border: 2px solid var(--theme-color, var(--accent-color));
  border-radius: 8px;
  background: var(--white);
  cursor: pointer;
  transition:
    transform 0.2s ease,
    box-shadow 0.2s ease;
}

.course-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.08);
}

.card-ribbon {
  position: absolute;
  top: 0;
  right: 1.2rem;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  width: 45px;
  height: 70px;
  padding-top: 14px;
  clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 85%, 0 100%);
  background-color: var(--theme-color, var(--accent-color));
  color: #fff;
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.2));
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-orientation: upright;
  writing-mode: vertical-rl;
}

.card-ribbon-type {
  position: absolute;
  top: 0;
  right: calc(1.2rem + 45px + 5px);
  z-index: 9;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  width: 45px;
  height: 70px;
  padding-top: 14px;
  clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 85%, 0 100%);
  background-color: var(--type-theme-color, #777);
  color: #fff;
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.2));
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-orientation: upright;
  writing-mode: vertical-rl;
}

.course-card .card-header {
  margin-bottom: 0.3rem;
  padding-right: 125px;
  color: var(--text-sub);
  font-size: 0.75rem;
}

.card-title {
  margin: 0 0 0.5rem;
  padding-right: 125px;
  color: #222;
  font-size: clamp(1.1rem, 1vw + 0.85rem, 1.2rem);
  font-weight: 500;
  letter-spacing: 0.02em;
  line-height: 1.3;
}

.course-card .card-info {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  color: var(--text-sub);
  font-size: 0.9rem;
}

.card-bottom-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-top: 0.4rem;
  padding-top: 0;
  border-top: none;
}

.info-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.info-row i {
  width: 16px;
  color: #555;
  font-size: 0.85rem;
  text-align: center;
}

.info-group {
  display: flex;
  flex-wrap: wrap;
  gap: 1.2rem;
}

.compare-button-slot {
  display: flex;
  justify-content: flex-end;
}

.pagination-container {
  position: relative;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0 var(--home-shell-padding-inline) 2rem
    calc(var(--home-sidebar-width) + var(--home-shell-padding-inline));
}

.pagination-container:empty {
  padding-bottom: 0;
}

.pagination-btn {
  margin: 0;
  padding: 8px 16px;
  border: 1px solid var(--pagination-theme-color, var(--primary-green));
  border-radius: 12px;
  background-color: transparent;
  color: var(--pagination-theme-color, var(--primary-green));
  cursor: pointer;
  transition:
    background-color 0.3s,
    color 0.3s,
    border-color 0.3s;
}

.pagination-btn:hover {
  background-color: #f0f0f0;
}

.pagination-btn.active {
  border-color: var(--pagination-theme-color, var(--primary-green));
  background-color: var(--pagination-theme-color, var(--primary-green));
  color: #fff;
  font-weight: 700;
}

.pagination-btn:disabled {
  color: #aaa;
  cursor: not-allowed;
}

.pagination-ellipsis {
  padding: 8px 4px;
  color: #888;
}

@keyframes homeFilterExpand {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 1120px) {
  .catalog-layout-shell {
    --home-sidebar-width: clamp(220px, 26vw, 252px);
    --home-shell-gap: 1.25rem;
  }

  .container {
    padding-right: 1rem;
  }

  .main-content {
    max-width: none;
  }
}

@media (max-width: 860px) {
  .catalog-layout-shell::before {
    display: none;
  }

  .mobile-filter-bar {
    display: block;
    padding: 0.8rem 1rem 0;
  }

  .mobile-filter-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    width: 100%;
    padding: 0.95rem 1rem;
    border: 1px solid rgba(31, 122, 88, 0.14);
    border-radius: 16px;
    background:
      linear-gradient(135deg, rgba(255, 255, 255, 0.98), rgba(241, 248, 245, 0.98));
    box-shadow: 0 14px 28px rgba(15, 23, 42, 0.08);
    color: var(--text-main);
  }

  .mobile-filter-copy {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    min-width: 0;
    text-align: left;
  }

  .mobile-filter-label {
    font-size: 0.95rem;
    font-weight: 700;
  }

  .mobile-filter-meta {
    max-width: 100%;
    color: var(--text-sub);
    font-size: 0.8rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .mobile-filter-icons {
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--primary-green);
    font-size: 0.95rem;
  }

  #mobileFilterChevron {
    transition: transform 0.2s ease;
  }

  .catalog-layout-shell.mobile-filter-open #mobileFilterChevron {
    transform: rotate(180deg);
  }

  .container {
    display: block;
    padding: 0.75rem 1rem 1rem;
  }

  .sidebar {
    display: none;
    width: 100%;
    max-height: none;
    min-height: 0;
    margin-bottom: 1rem;
    padding: 1rem;
    position: static;
    overflow: visible;
    border: 1px solid rgba(31, 122, 88, 0.14);
    border-radius: 18px;
    background-color: var(--white);
    box-shadow: 0 18px 36px rgba(15, 23, 42, 0.1);
  }

  .catalog-layout-shell.mobile-filter-open .sidebar {
    display: block;
    animation: homeFilterExpand 0.22s ease;
  }

  .main-content {
    max-width: none;
    padding: 0 0 1.5rem;
  }

  .results-header {
    margin-bottom: 1rem;
    align-items: flex-start;
    flex-direction: column;
  }

  .course-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .pagination-container {
    padding: 0 1rem 1.5rem;
  }
}

@media (max-width: 560px) {
  .course-card {
    padding: 1rem;
  }

  .course-card .card-header,
  .card-title {
    padding-right: 94px;
  }

  .card-title {
    font-size: 1.08rem;
  }

  .card-ribbon,
  .card-ribbon-type {
    width: 36px;
    height: 54px;
    padding-top: 10px;
    font-size: 0.9rem;
  }

  .card-ribbon-type {
    right: calc(1rem + 36px + 4px);
  }

  .card-bottom-row {
    align-items: stretch;
    flex-direction: column;
  }

  .info-group {
    justify-content: space-between;
    gap: 0.75rem;
    font-size: 0.82rem;
  }

  .compare-button-slot,
  .compare-button-slot .btn-compare {
    width: 100%;
  }

  .compare-button-slot .btn-compare {
    justify-content: center;
  }
}

.ecredit-filter-block {
  margin-bottom: 1.5rem;
}

.ecredit-year-select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #cfd8dc;
  border-radius: 8px;
  background-color: #fff;
  color: #37474f;
  cursor: pointer;
  font-size: 0.95rem;
}

.ecredit-faculty-select {
  line-height: 1.4;
}

.sidebar .search-box {
  gap: 0.5rem;
}

.sidebar .search-box input {
  min-width: 0;
  padding-right: 4.8rem;
}

.sidebar .clear-search-btn {
  right: 4.2rem;
}

.ecredit-search-button {
  align-self: stretch;
  flex: 0 0 auto;
  padding: 0 0.85rem;
  border: none;
  border-radius: 6px;
  background: var(--primary-green);
  color: #ffffff;
  font-weight: 800;
  cursor: pointer;
}

.ecredit-search-button:hover {
  filter: brightness(0.96);
}

.ecredit-filter-icon {
  font-size: 0.8rem;
}

.ecredit-no-results-message {
  margin-top: 3rem;
  color: #666;
  text-align: center;
}
