/*
 * Colours of the catalogue that no semantic token matches. The mid-grey outline
 * of the pagination and the header rule (#ababab) sits between --color-border
 * and the navy --color-border-strong of the light theme, and the red "reset
 * filters" button is a pale pink box that would glare on the dark page.
 */
.programs-header,
.programs-content {
  --programs-line: var(--color-grey-200);
  --programs-reset-color: #dc2626;
  --programs-reset-bg: #fef2f2;
  --programs-reset-bg-hover: #fee2e2;
  --programs-reset-border: #fca5a5;
  --programs-reset-border-hover: #f87171;
}

html[data-theme="dark"] .programs-header,
html[data-theme="dark"] .programs-content {
  --programs-line: var(--color-border-strong);
  --programs-reset-color: #f87171;
  --programs-reset-bg: rgba(248, 113, 113, 0.12);
  --programs-reset-bg-hover: rgba(248, 113, 113, 0.2);
  --programs-reset-border: rgba(248, 113, 113, 0.4);
  --programs-reset-border-hover: #f87171;
}

.programs-header {
  padding: 0 var(--wrap);
}

.programs-content {
  padding: 0 var(--wrap);
  margin-top: 2rem;
  padding-bottom: 5rem;
  margin: 0;
}

.programs-page__header {
  border-bottom: 1px solid var(--programs-line);
  padding-bottom: 0.5rem;
}

._inner-header__title__container {
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  align-items: flex-end;
  gap: 20px;
}

._inner-header__title {
  margin: 0;
  color: var(--color-text-heading);
}

.programs-page-filter-row {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  gap: 1.2rem;
  margin-top: 1rem;
  background: var(--color-bg-primary);
}


.programs-page-search__input {
  flex: 1;
  border: none;
  outline: none;
  padding: 10px 16px;
  font-size: 0.95rem;
  background: transparent;
  color: var(--color-text-primary);
  font-family: inherit;
}

.programs-page-search__input::placeholder {
  color: var(--color-text-muted);
}

.programs-mobile-filter-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--color-surface-card);
  border: 1px solid var(--programs-line);
  color: var(--color-text-secondary);
  padding: 0 16px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  min-height: 44px;
  border-radius: 0 !important;
  -webkit-border-radius: 0 !important;
  appearance: none;
  -webkit-appearance: none;
}

.programs-mobile-filter-toggle.is-open {
  background: var(--color-blue-200, #16295b);
  border-color: var(--color-blue-200, #16295b);
  color: var(--color-white, #ffffff);
}
@media (hover: hover) {
  .programs-mobile-filter-toggle:hover {
    background: var(--color-blue-200, #16295b);
    border-color: var(--color-blue-200, #16295b);
    color: var(--color-white, #ffffff);
  }
}

.programs-page-filters-collapsible {
  display: contents;
}

.custom-dropdown {
  position: relative;
  width: 100%;
  user-select: none;
}

.custom-dropdown__selected {
  min-height: 44px;
  cursor: pointer;
  font-weight: 500;
}

@media (hover: hover) {
  .custom-dropdown__selected:hover {
    box-shadow: 0 0 0 3px rgba(var(--color-blue-200--rgb), 0.05);
  }
}
.custom-dropdown.open .custom-dropdown__selected {
  box-shadow: 0 0 0 3px rgba(var(--color-blue-200--rgb), 0.05);
}

.custom-dropdown__placeholder {
  line-height: 1.4;
  flex: 1;
}

.custom-dropdown__arrow {
  transition: transform 0.3s ease;
  font-size: 0.8rem;
  margin-left: 10px;
  color: var(--color-text-secondary);
  flex-shrink: 0;
}

.custom-dropdown.open .custom-dropdown__arrow {
  transform: rotate(180deg);
  color: var(--color-text-heading);
}

.custom-dropdown__list {
  position: absolute;
  left: 0;
  right: 0;
  background: var(--color-surface-card);
  padding: 0;
  margin: 0;
  list-style: none;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-5px);
  transition: all 0.2s ease;
  z-index: 50;
  box-shadow: 0 10px 25px rgba(var(--color-blue-200--rgb), 0.08);
  max-height: 300px;
  overflow-y: auto;
}

.custom-dropdown__list::-webkit-scrollbar {
  width: 6px;
}

.custom-dropdown__list::-webkit-scrollbar-thumb {
  background-color: var(--color-border);
}

.custom-dropdown.open .custom-dropdown__list {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.custom-dropdown__item {
  padding: 10px 16px;
  font-size: 0.9rem;
  color: var(--color-text-primary);
  cursor: pointer;
  transition: background-color 0.2s ease, color 0.2s ease;
  line-height: 1.4;
  border-bottom: 1px solid var(--color-bg-secondary);
}

.custom-dropdown__item:last-child {
  border-bottom: none;
}

@media (hover: hover) {
  .custom-dropdown__item:hover {
    background-color: var(--color-bg-secondary);
    color: var(--color-text-heading);
  }
}

.programs-filter-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  margin-top: 1.25rem;
  margin-bottom: 0.5rem;
  padding-top: 0;
}

.programs-page-filter__results-count {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--color-text-secondary);
  margin: 0;
}

.programs-content__list {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 1.5rem;
}
.programs-content__item {
  display: flex;
  flex-direction: column;
  background: var(--color-surface-card);
  border: 1px solid var(--color-border);
  text-decoration: none;
  overflow: hidden;
  transition: transform 0.4s cubic-bezier(0.165, 0.84, 0.44, 1), border-color 0.4s ease;
  position: relative;
  min-width: 0;
  /* Оптимізація: браузер не рендерить картки за межами viewport */
  content-visibility: auto;
  contain-intrinsic-size: auto 420px;
}

@media (hover: hover) {
  .programs-content__item:hover {
    transform: translateY(-6px);
    border-color: var(--color-border-strong);
    box-shadow: 0 12px 24px -8px rgba(15, 23, 42, 0.15);
  }
}

.programs-content__item-image {
  display: block;
  width: 100%;
  aspect-ratio: 3 / 2; /* Превентивно задаємо співвідношення, щоб не було layout shift */
  background: var(--color-bg-tertiary); /* Skeleton background color */
  overflow: hidden;
  position: relative;
  border-bottom: 1px solid var(--color-border);
}

.programs-content__item-image::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 50%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(var(--color-bg-primary--rgb), 0.6), transparent);
  animation: programs-shine 1.5s infinite;
  z-index: 1;
}

/* Зупиняємо shimmer коли картинка завантажена - економить GPU */
.programs-content__item-image.img-loaded::before {
  animation: none;
  display: none;
}

.programs-content__item-image picture {
  display: block;
  width: 100%;
  height: 100%;
}

.programs-content__item-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: opacity 0.4s ease;
  position: relative;
  z-index: 2;
  opacity: 0;
}

.programs-content__item-image img[loading="eager"],
.programs-content__item-image.img-loaded img {
  opacity: 1;
}

.programs-content__item-image:has(img[loading="eager"])::before {
  display: none;
  animation: none;
}

@media (hover: hover) {
  .programs-content__item:hover .programs-content__item-image img {
    opacity: 0.95;
  }
}

.programs-content__item-placeholder {
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, var(--color-bg-secondary) 0%, var(--color-bg-secondary) 100%);
}

.programs-content__item-bottom {
  padding: 1rem;
  display: flex;
  background: var(--color-surface-card);
  border-top: none;
  flex-grow: 1;
}

.programs-content__item-info {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  /* Without it the longest unbreakable line of the card's text set this
     block's width, it overflowed the card and the card cut it off. */
  min-width: 0;
}

.programs-content__item-title {
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--color-text-primary);
  margin: 0;
  line-height: 1.25;
  transition: color 0.3s ease;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 2.875rem; /* 2 lines * 1.15rem * 1.25 */
}

@media (hover: hover) {
  .programs-content__item:hover .programs-content__item-title {
    color: var(--color-text-heading);
  }
}

.programs-pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin-top: 4rem;
}
.programs-pagination.top-pagination {
  margin-top: 0 !important;
}

.programs-pagination a,
.programs-pagination span {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 40px;
  height: 40px;
  padding: 0 12px;
  font-size: 0.95rem;
  font-weight: 600;
  border: 1px solid var(--programs-line);
  color: var(--color-text-secondary);
  text-decoration: none;
  transition: all 0.2s ease;
  background: var(--color-surface-card);
}

@media (hover: hover) {
  .programs-pagination a:hover {
    border-color: var(--color-border-strong);
    color: var(--color-text-heading);
    background: var(--color-bg-secondary);
  }
}

.programs-pagination span.current {
  background: var(--color-blue-200, #16295b);
  border-color: var(--color-blue-200, #16295b);
  color: var(--color-white, #ffffff);
}

.programs-pagination .first,
.programs-pagination .last,
.programs-pagination .next,
.programs-pagination .prev {
  border: none;
  background: transparent;
  color: var(--color-text-heading);
  min-width: 36px;
  padding: 0 10px;
  margin: 0 4px;
}

@media (hover: hover) {
  .programs-pagination .first:hover,
  .programs-pagination .last:hover,
  .programs-pagination .next:hover,
  .programs-pagination .prev:hover {
    background: transparent;
    color: var(--color-link);
    transform: translateX(2px);
  }
  .programs-pagination .first:hover,
  .programs-pagination .prev:hover {
    transform: translateX(-2px);
  }
}

@media (max-width: 1400px) {
  .programs-content__list {
    grid-template-columns: repeat(4, 1fr);
  }
}

@media (max-width: 992px) {
  .programs-content__list {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 1240px) {
  ._inner-header__title__container {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }
  .programs-page-filter-row {
    gap: 1rem;
    margin-top: 10px;
  }
  .programs-mobile-filter-toggle {
    display: flex;
    flex: 0 0 auto;
  }
  .programs-page-filters-collapsible {
    display: flex;
    flex: 1 1 100%;
    width: 100%;
    flex-wrap: wrap;
    gap: 1rem;
    margin-top: 0;
    max-height: 0;
    opacity: 0;
    visibility: hidden;
    overflow: hidden;
    transform: translateY(-10px);
    transition: all 0.3s ease;
  }
  .programs-page-filters-collapsible.is-open {
    max-height: 1000px;
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    overflow: visible !important;
    margin-top: 0.5rem;
  }
  .programs-page-filter__reset-text {
    font-size: 0.95rem;
    font-weight: 600;
  }
}

@media (max-width: 768px) {
  .programs-content__list {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 576px) {
  .programs-page-search__input {
    padding: 8px 14px;
    font-size: 0.9rem;
  }
  .programs-mobile-filter-toggle {
    min-height: 40px;
    width: 44px;
    padding: 0;
    gap: 0;
    flex: 0 0 44px;
  }
  .programs-mobile-filter-toggle span {
    display: none;
  }
  .programs-page-filters-collapsible {
    flex-direction: column;
    flex-wrap: nowrap;
  }
  .programs-view-toggle {
    width: 100%;
  }
  .programs-filter-bottom {
    flex-wrap: nowrap;
    gap: 0.5rem;
  }
  .programs-page-filter__results-count {
    font-size: 0.8rem;
    white-space: nowrap;
  }
  /*
   * The pages were 26 x 28 boxes 2px apart, arrows 20px wide: a thumb took the
   * neighbour as often as the page it meant. Now 32px squares 3px apart, each
   * reaching 44px tall for the finger. «First» and «last» go: the first and the
   * last page are numbers in the row already, and without them the longest row
   * (‹ 1 … 3 4 5 … 8 ›) still fits a 360px screen.
   */
  .programs-pagination {
    gap: 3px;
  }
  .programs-pagination a,
  .programs-pagination span {
    position: relative;
    min-width: 32px;
    height: 32px;
    padding: 0 4px;
    font-size: 0.875rem;
  }
  .programs-pagination a::after {
    content: "";
    position: absolute;
    top: -6px;
    bottom: -6px;
    left: -1px;
    right: -2px;
  }
  .programs-pagination .first,
  .programs-pagination .last {
    display: none;
  }
  .programs-pagination .next,
  .programs-pagination .prev {
    min-width: 28px;
    padding: 0;
    margin: 0;
    font-size: 1.25rem;
  }
}

.programs-view-toggle {
  flex-shrink: 0;
}
.view-toggle-btn {
  width: 44px;
  font-size: 0;
  line-height: 0;
}
.view-toggle-btn svg {
  display: block;
  margin: 0;
  transform: translateX(-1.5px); 
}

.programs-list-header {
  display: none;
}

.programs-content.is-list-view .programs-list-header {
  display: grid;
  grid-template-columns: 1fr 1.5fr 1fr 1fr 1fr 1fr 0.8fr;
  gap: 1rem;
  padding: 1rem 4rem 1rem 1.5rem;
  background: var(--color-blue-200, #16295b);
  color: var(--color-white, #ffffff);
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 0;
}

.programs-content.is-list-view .programs-content__list {
  display: flex;
  flex-direction: column;
  gap: 0;
  border: 1px solid var(--color-border);
}

.programs-content.is-list-view .programs-content__item {
  display: grid;
  grid-template-columns: 1fr 1.5fr 1fr 1fr 1fr 1fr 0.8fr;
  gap: 1rem;
  padding: 1rem 4rem 1rem 1.5rem;
  border: none;
  border-bottom: 1px solid var(--color-border);
  align-items: center;
  border-radius: 0;
  position: relative;
}

@media (hover: hover) {
  .programs-content.is-list-view .programs-content__item:hover {
    transform: none;
    box-shadow: none;
    background-color: var(--color-bg-secondary);
    border-color: var(--color-border);
  }
}

.programs-content.is-list-view .programs-content__item:last-child {
  border-bottom: none;
}

.programs-content.is-list-view .programs-content__item-image,
.programs-content.is-list-view .programs-content__item-bottom {
  display: none;
}

.programs-content.is-list-view .programs-content__item-list-data {
  display: contents;
}

.programs-content.is-list-view .list-col {
  font-size: 0.9rem;
  color: var(--color-text-primary);
  line-height: 1.4;
}

.programs-content.is-list-view .programs-list-header .list-col,
.programs-content.is-list-view .programs-list-header .list-col.col-title {
  font-weight: 600;
  color: var(--color-white, #ffffff);
}

.programs-content.is-list-view .list-col.col-title {
  font-weight: 600;
  color: var(--color-text-heading);
}

@media (hover: hover) {
  .programs-content.is-list-view .programs-content__item:hover .list-col.col-title {
    color: var(--color-link);
  }
}

.list-col-label {
  display: none;
  font-weight: 600;
  margin-right: 5px;
  color: var(--color-text-secondary);
  font-size: 0.85rem;
}

.programs-content.is-list-view:has(.programs-no-results) .programs-list-header {
  display: none;
}

@media (max-width: 1024px) {
  .programs-content.is-list-view .programs-list-header {
    display: none;
  }
  .programs-content.is-list-view .programs-content__item {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    align-items: flex-start;
    padding: 1.5rem;
  }
  .programs-content.is-list-view .programs-content__item-list-data {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    width: 100%;
  }
  .list-col-label {
    display: inline;
  }
}

.programs-list-header .sortable {
  cursor: pointer;
  position: relative;
  padding-right: 20px;
  transition: background-color 0.2s ease;
  -webkit-user-select: none;
  -moz-user-select: none;
  user-select: none;
}

.programs-list-header .sortable::after {
  content: '';
  position: absolute;
  right: 8px;
  top: 50%;
  border: 5px solid transparent;
  border-bottom-color: var(--color-white);
  margin-top: -7px;
  opacity: 0.5;
}

.programs-list-header .sortable.active.asc::after {
  border-top-color: transparent;
  border-bottom-color: var(--color-white);
  margin-top: -7px;
  opacity: 1;
}

.programs-list-header .sortable.active.desc::after {
  border-bottom-color: transparent;
  border-top-color: var(--color-white);
  margin-top: -3px;
  opacity: 1;
}

.programs-no-results {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 4rem 1.5rem;
    margin: 2rem 0;
}
.programs-no-results__icon {
    color: var(--color-grey-100);
    margin-bottom: 1rem;
}
.programs-no-results__title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--color-text-heading);
    margin: 0 0 0.5rem 0;
}
.programs-no-results__sub {
    font-size: 1rem;
    color: var(--color-text-secondary);
    margin: 0;
    max-width: 400px;
}

.programs-content__item-list-data { display: none; }

.programs-content__item-image img.program-crest-watermark {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.9);
  width: 140px;
  height: auto;
  opacity: 0;
  z-index: 3;
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s ease;
  object-fit: contain;
  filter: grayscale(100%); /* Завжди ч/б, щоб не було кольорового спалаху при знятті ховера */
}

@media (hover: hover) {
  .programs-content__item:hover .programs-content__item-image img.program-crest-watermark {
    opacity: 0.15;
    transform: translate(-50%, -50%) scale(1);
  }
}

.program-badge {
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--color-text-secondary);
  background-color: transparent;
  border: 1px solid var(--programs-line);
  text-transform: uppercase;
  padding: 0.15rem 0.4rem;
  white-space: nowrap;
  letter-spacing: 0.3px;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}

.program-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.programs-content__item-title {
  flex: 1;
  min-width: 0;
  overflow-wrap: break-word;
}

.program-specs-grid {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  gap: 0.5rem 0.75rem;
  margin-bottom: 0.75rem;
}

.program-spec-item {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.8rem;
  color: var(--color-text-secondary);
}

.program-spec-item svg {
  width: 16px;
  height: 16px;
  color: var(--color-text-heading);
}

.program-bottom-desc {
  margin-top: auto;
  border-top: 1px solid var(--color-border);
  padding-top: 0.75rem;
}

.program-short-desc {
  overflow-wrap: anywhere;
  font-size: 0.85rem;
  color: var(--color-text-secondary);
  line-height: 1.35;
  margin: 0 0 0.75rem 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  hyphens: auto;
  -webkit-hyphens: auto;
}

.program-badges-bottom {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin-bottom: 0.6rem;
}

.program-badges-bottom .program-badge {
  border: none;
  border-radius: 2px;
  padding: 0.15rem 0.45rem;
  font-size: 0.65rem;
  font-weight: 600;
  background: var(--color-bg-tertiary);
  color: var(--color-text-secondary);
}

/* The degree pills keep their own dark ink in both themes, so they sit on an
   opaque light fill rather than a wash that would turn dark under that ink. */
.program-badges-bottom .program-badge--bachelor {
  background: #ebecef;
  color: #051338;
}

.program-badges-bottom .program-badge--master {
  background: #edebf2;
  color: #23035c;
}

.program-badges-bottom .program-badge--phd {
  background: #efede7;
  color: #544312;
}

.program-finance {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.5rem;
  margin-bottom: 0.75rem;
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
}

.program-finance__label {
  display: flex;
  flex-direction: column;
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.2;
  color: var(--color-text-secondary);
}

.program-finance__label small {
  margin-top: 0.2rem;
  font-size: 0.65rem;
  font-weight: 500;
}

.program-price-list {
  display: grid;
  grid-template-columns: auto auto;
  gap: 0.2rem 0.4rem;
  justify-content: flex-end;
  align-items: baseline;
}

.program-price-list__label {
  font-size: 0.7rem;
  font-weight: 400;
  color: var(--color-text-secondary);
}

.program-price-list__value {
  font-size: 0.85rem;
  font-weight: 700;
  text-align: right;
  white-space: nowrap;
  color: var(--color-text-primary);
}

/* Badges and price labels sat at 10-11px; on a phone nothing goes under the scale's caption step. */
@media (max-width: 899px) {
  .program-badge,
  .program-badges-bottom .program-badge,
  .program-finance__label small,
  .program-price-list__label {
    font-size: var(--fs-caption);
  }
}

.program-price-inline {
  font-size: 0.85rem;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
  color: var(--color-text-heading);
}

.program-price-inline__sep {
  margin: 0 2px;
  font-weight: 400;
  color: var(--color-border);
}

.programs-list-header .col-prices {
  font-size: 0.8rem;
  line-height: 1.2;
}

.programs-header-actions {
  position: relative;
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

.programs-custom-search-container {
  display: flex;
  gap: 0.75rem;
  align-items: stretch;
}

.programs-custom-search-bar {
  flex: 1;
}

.programs-favorites-wrapper {
  position: relative;
  display: inline-block;
}

/* A dark tooltip in both themes, like the one it replaced. */
.programs-favorites-tooltip {
  position: absolute;
  bottom: 100%;
  right: 0;
  margin-bottom: 8px;
  padding: 0.4rem 0.6rem;
  font-size: 0.7rem;
  white-space: nowrap;
  color: var(--color-white);
  background: #1e293b;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: all 0.2s ease;
  z-index: 50;
}

.programs-favorites-tooltip::after {
  content: '';
  position: absolute;
  top: 100%;
  right: 20px;
  border-width: 5px;
  border-style: solid;
  border-color: #1e293b transparent transparent transparent;
}

.programs-favorites-wrapper:hover .programs-favorites-tooltip {
  opacity: 1;
  visibility: visible;
  margin-bottom: 12px;
}

@keyframes tooltipFadeInOut {
  0% { opacity: 0; visibility: hidden; margin-bottom: 8px; }
  10% { opacity: 1; visibility: visible; margin-bottom: 12px; }
  80% { opacity: 1; visibility: visible; margin-bottom: 12px; }
  100% { opacity: 0; visibility: hidden; margin-bottom: 8px; }
}

@media (max-width: 1240px) {
  .programs-favorites-wrapper { flex: 1; }
  .programs-favorites-toggle { width: 100%; }
  .programs-favorites-toggle.is-active + .programs-favorites-tooltip {
    animation: tooltipFadeInOut 3.5s forwards;
  }
}




            .programs-custom-search-container,
            .programs-custom-filter-row {
                width: 100%;
                box-sizing: border-box;
                margin-left: 0;
                margin-right: 0;
            }
            .programs-custom-search-container {
                margin-bottom: 0.5rem;
            }
            .programs-custom-search-bar {
                display: flex;
                align-items: center;
                border: 1px solid var(--color-border) !important;
                transition: border-color 0.2s;
                background: var(--color-surface-card);
                overflow: hidden;
            }
            .programs-custom-search-bar:focus-within {
                border-color: #94a3b8 !important;
            }
            @media (hover: hover) {
              .programs-custom-search-bar:hover {
                  border-color: #94a3b8 !important;
              }
            }
            .programs-search-decorative-icon {
                margin-left: 1rem;
                color: var(--color-text-muted);
                display: flex;
                align-items: center;
                justify-content: center;
                width: 22px;
                opacity: 1;
                transform: translateX(0);
                transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
            }
            .programs-custom-search-bar:has(input:focus) .programs-search-decorative-icon,
            .programs-custom-search-bar:has(input:not(:placeholder-shown)) .programs-search-decorative-icon {
                width: 0;
                margin-left: 0;
                opacity: 0;
                transform: translateX(-150%);
            }
            .programs-custom-search-bar input {
                flex: 1;
                border: none !important;
                padding: 0.75rem 1rem;
                padding-left: 0.75rem;
                font-size: 0.95rem;
                color: var(--color-text-primary);
                background: transparent !important;
                outline: none !important;
                box-shadow: none !important;
                border-radius: 0 !important;
                -webkit-border-radius: 0 !important;
                appearance: none;
                -webkit-appearance: none;
                font-family: inherit;
                transition: padding 0.35s cubic-bezier(0.4, 0, 0.2, 1);
            }
            .programs-custom-search-bar:has(input:focus) input,
            .programs-custom-search-bar:has(input:not(:placeholder-shown)) input {
                padding-left: 1.25rem;
            }
            .programs-custom-search-bar input::placeholder {
                color: var(--color-text-muted);
            }
            .programs-custom-filter-row {
                display: flex;
                gap: 0.75rem;
                align-items: center;
                flex-wrap: wrap;
                margin-bottom: 0.5rem;
                position: relative;
                z-index: 100;
            }
            .programs-custom-filters {
                display: flex;
                gap: 0.75rem;
                flex: 1;
                align-items: center; 
                flex-wrap: wrap;
            }
            
            .programs-custom-filter-row .custom-dropdown__selected {
                border: 1px solid var(--color-border) !important;
                border-radius: 0 !important;
                -webkit-border-radius: 0 !important;
                appearance: none;
                -webkit-appearance: none;
                background: var(--color-surface-card) !important;
                padding: 0 0.85rem !important; 
                font-size: 0.85rem !important;
                color: var(--color-text-primary) !important;
                display: flex;
                justify-content: space-between;
                align-items: center;
                height: 40px !important; 
                font-family: inherit;
                box-sizing: border-box;
                transition: border-color 0.2s;
                overflow: hidden;
            }
            .programs-custom-filter-row .custom-dropdown__placeholder {
                white-space: nowrap;
                overflow: hidden;
                text-overflow: ellipsis;
                max-width: calc(100% - 15px);
            }
            @media (hover: hover) {
              .programs-custom-filter-row .custom-dropdown__selected:hover {
                  border-color: #94a3b8 !important;
              }
            }
            .programs-custom-filter-row .custom-dropdown__list {
                border: 1px solid var(--color-border) !important;
                border-top: none !important;
                border-radius: 0 !important;
                top: 100% !important;
                margin-top: 0 !important;
                box-sizing: border-box;
                font-size: 0.85rem !important;
            }
            .programs-custom-filter-row .programs-page-filter__dropdown {
                flex: 1;
                min-width: 140px; 
                margin: 0;
                box-sizing: border-box;
            }
            .programs-custom-filter-row .programs-page-filter__reset-icon {
                margin: 0;
                display: inline-flex !important;
                align-items: center !important;
                justify-content: center !important;
                gap: 0.4rem;
                color: var(--programs-reset-color);
                background: var(--programs-reset-bg);
                border-color: var(--programs-reset-border);
                border-style: solid;
                font-weight: 600;
                font-size: 0.85rem;
                cursor: pointer;
                transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
                white-space: nowrap;
                box-sizing: border-box;
                height: 40px !important; 
                line-height: 1 !important;
                width: auto !important; 
                flex: none !important;
                
                
                max-width: 0;
                padding: 0 !important;
                border-width: 0;
                opacity: 0;
                overflow: hidden;
                display: none !important;
            }
            .programs-custom-filter-row .programs-page-filter__reset-icon.is-visible {
                max-width: 250px; 
                padding: 0 0.85rem !important;
                border-width: 1px;
                opacity: 1;
                display: inline-flex !important;
            }
            @media (hover: hover) {
              .programs-custom-filter-row .programs-page-filter__reset-icon:hover {
                  background: var(--programs-reset-bg-hover);
                  border-color: var(--programs-reset-border-hover);
              }
            }
            
            .programs-view-toggle {
                display: inline-flex !important;
                align-items: center !important;
                box-sizing: border-box;
                border: 1px solid var(--color-border) !important;
                position: relative;
                z-index: 1;
                background: var(--color-surface-card);
                overflow: hidden;
                height: 40px !important;
                border-radius: 0 !important;
            }
            .programs-view-toggle::before {
                content: "";
                position: absolute;
                top: 0;
                left: 0;
                width: 50%;
                height: 100%;
                background: var(--color-blue-200); 
                transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
                z-index: -1;
            }
            .programs-view-toggle:has(#btn-view-list.active)::before {
                transform: translateX(100%);
            }
            .programs-view-toggle .view-toggle-btn {
                background: transparent !important;
                border: none !important;
                color: var(--color-text-muted) !important;
                padding: 0 0.75rem !important;
                cursor: pointer;
                transition: color 0.3s ease;
                display: inline-flex !important;
                align-items: center !important;
                justify-content: center !important;
                box-sizing: border-box;
                height: 100% !important;
                flex: 1;
            }
            .programs-view-toggle .view-toggle-btn.active {
                background: transparent !important;
                color: var(--color-white) !important;
                border: none !important;
            }
            @media (hover: hover) {
              .programs-view-toggle .view-toggle-btn:hover:not(.active) {
                  color: var(--color-text-primary) !important;
                  background: transparent !important;
              }
            }
            .programs-page-filter__reset-text {
                display: block !important;
                line-height: 1 !important;
                margin: 0 !important;
                padding: 0 !important;
                position: static !important; 
            }
        


@media (max-width: 1240px) {
    .programs-custom-filters {
        flex: 1 1 100% !important;
        width: 100% !important;
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 0.5rem !important;
    }
    .programs-custom-filter-row .programs-page-filter__dropdown {
        flex: none !important;
        width: 100% !important;
        min-width: 100% !important;
    }
.programs-custom-filter-row .programs-page-filter__reset-icon.is-visible {
        max-width: none !important;
        width: 100% !important;
        margin-top: 0.25rem;
    }
    .programs-custom-filter-row .custom-dropdown__selected {
        min-height: 40px !important;
        height: auto !important;
        padding-top: 0.5rem !important;
        padding-bottom: 0.5rem !important;
    }
    .programs-custom-filter-row .custom-dropdown__placeholder {
        white-space: normal !important;
        overflow: visible !important;
        word-break: break-word;
    }
}



.programs-content__item.skeleton { display: flex; flex-direction: column; background: var(--color-surface-card); border: 1px solid var(--color-border); border-radius: 0; position: relative; overflow: hidden; height: 100%; min-height: 380px; }
.skeleton-image { width: 100%; height: 180px; background: var(--color-bg-tertiary); }
.skeleton-content { padding: 1.5rem; flex: 1; display: flex; flex-direction: column; gap: 1rem; }
.skeleton-line { height: 16px; background: var(--color-bg-tertiary); border-radius: 0; width: 100%; }
.skeleton-line.title { height: 24px; width: 80%; margin-bottom: 0.5rem; }
.skeleton-line.short { width: 60%; }
.programs-content__item.skeleton::after { content: ''; position: absolute; top: 0; left: 0; width: 50%; height: 100%; background: linear-gradient(90deg, transparent, rgba(var(--color-bg-primary--rgb), 0.6), transparent); animation: programs-shine 1.5s infinite; }
/* The shine moves by transform, not left, so it runs on the compositor instead of re-laying out every card each frame; ±200% of its own width is the old ±100% of the card. */
@keyframes programs-shine { from { transform: translateX(-200%); } to { transform: translateX(200%); } }
.is-list-view .programs-content__item.skeleton { flex-direction: row; height: auto; min-height: 120px; border-bottom: 1px solid var(--color-border); }
.is-list-view .skeleton-image { width: 120px; height: 120px; }
.is-list-view .skeleton-content { flex-direction: row; align-items: center; justify-content: space-between; }

/* Favorites Button */
.program-favorite-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 36px;
  height: 36px;
  border-radius: 0;
  background: transparent;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 10;
  transition: all 0.2s ease;
  color: rgba(255, 255, 255, 0.9);
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.6));
  box-shadow: none;
}

@media (hover: hover) {
  .program-favorite-btn:hover {
    background: transparent;
    transform: scale(1.1);
    color: #ffffff;
    filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.8));
  }
}

.program-favorite-btn.is-active {
  background: transparent;
  color: #eab308;
  filter: drop-shadow(0 0 4px rgba(0, 0, 0, 0.6));
}

.program-favorite-btn.is-active svg {
  fill: #eab308;
  stroke: #eab308;
}

.program-favorite-btn:focus {
  outline: none;
}

.program-favorite-btn.animate-pop svg {
  animation: favoritePop 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

@keyframes favoritePop {
  0% {
    transform: translateY(0) scale(1);
  }
  50% {
    transform: translateY(-4px) scale(1.1);
    fill: #fde047;
  }
  100% {
    transform: translateY(0) scale(1);
  }
}

.programs-content.is-list-view .programs-content__item-list-data > .program-favorite-btn {
  position: absolute;
  right: 15px;
  top: 50%;
  transform: translateY(-50%);
  width: 36px;
  height: 36px;
  filter: none;
  color: var(--color-text-secondary);
  margin: 0;
  display: flex;
}

.programs-content.is-list-view .programs-content__item-list-data > .program-favorite-btn:hover {
  transform: translateY(-50%) scale(1.1);
  color: #eab308;
  filter: none;
}

.programs-content.is-list-view .programs-content__item-list-data > .program-favorite-btn.is-active {
  color: #eab308;
  filter: none;
}

/* Favorites Filter Button */
.programs-favorites-toggle {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 0.5rem;
  padding: 0 16px !important;
  border: 1px solid var(--color-border) !important;
  background: var(--color-surface-card) !important;
  border-radius: 0 !important;
  font-size: 0.85rem !important;
  font-weight: 500 !important;
  color: var(--color-text-primary) !important;
  cursor: pointer;
  transition: all 0.3s ease;
  height: 40px !important;
  min-height: 40px !important;
  box-sizing: border-box !important;
  outline: none !important;
  appearance: none !important;
  -webkit-appearance: none !important;
  flex-shrink: 0 !important;
  margin: 0 !important;
}

.programs-favorites-toggle svg {
  color: var(--color-text-secondary);
  transition: color 0.3s ease;
}

@media (hover: hover) {
  .programs-favorites-toggle:hover {
    border-color: var(--color-border-strong) !important;
    box-shadow: 0 0 0 3px rgba(var(--color-blue-200--rgb), 0.05);
  }
}

.programs-favorites-toggle.is-active {
  background: var(--color-surface-card) !important;
  border-color: var(--color-border-strong) !important;
  color: var(--color-text-heading) !important;
}

.programs-favorites-toggle.is-active svg {
  color: #eab308;
  fill: #eab308;
  stroke: #eab308;
}

@media (max-width: 1240px) {
    .programs-header-actions {
        width: 100%;
        margin-top: 5px;
    }
    .programs-header-actions .programs-view-toggle {
        flex: 1;
        height: 36px !important;
    }
    .programs-header-actions .programs-favorites-toggle {
        flex: 1 !important;
        height: 36px !important;
        min-height: 36px !important;
        font-size: 0.8rem !important;
        padding: 0 0.5rem !important;
    }
    .programs-view-toggle .view-toggle-btn svg {
        width: 18px;
        height: 18px;
    }
    .programs-favorites-toggle svg {
        width: 18px;
        height: 18px;
    }
}

/*
 * Phones, card view: a list, not a stack of boxes. A card was a full-width
 * poster, the name again under it, two lines of description and the prices,
 * about 560px, so a page of twenty took eleven screens; boxed, with a grey
 * price panel, even the short version read heavy and left white gaps. Here
 * each programme is a row between hairlines: the poster (it already carries
 * the name, code and degree) as a thumbnail, the degree as a small line over
 * the name, the length and credits in one grey line without icons, and the
 * day and part-time prices as two short lines under them. The description gives way;
 * the programme's page has it. The blocks between the card and its contents
 * step aside (display: contents) so they all sit on the row's grid.
 */
@media (max-width: 576px) {
  .programs-content:not(.is-list-view) .programs-content__list {
    gap: 0;
  }

  .programs-content:not(.is-list-view) .programs-content__item {
    display: grid;
    grid-template-columns: 96px minmax(0, 1fr);
    grid-template-areas:
      "img badges"
      "img title"
      "img specs"
      "img price";
    grid-template-rows: auto auto auto 1fr;
    column-gap: 14px;
    padding: 14px 0;
    background: none;
    border: 0;
    border-bottom: 1px solid var(--color-border);
    contain-intrinsic-size: auto 120px;
  }

  .programs-content:not(.is-list-view) .programs-content__item-bottom,
  .programs-content:not(.is-list-view) .programs-content__item-info,
  .programs-content:not(.is-list-view) .program-bottom-desc {
    display: contents;
  }

  .programs-content:not(.is-list-view) .programs-content__item-image {
    grid-area: img;
    align-self: start;
    width: 96px;
    border: 0;
  }

  /* The star stays on the thumbnail; its 44px target reaches past the corner. */
  .programs-content:not(.is-list-view) .programs-content__item-image .program-favorite-btn {
    top: 2px;
    right: 2px;
    transform: scale(0.7);
    transform-origin: top right;
  }

  .programs-content:not(.is-list-view) .program-badges-bottom {
    grid-area: badges;
    margin: 0 0 3px;
    gap: 0 8px;
  }

  /* The degree as a small line of text, not a pill. */
  .programs-content:not(.is-list-view) .program-badges-bottom .program-badge {
    padding: 0;
    background: none;
    font-size: var(--fs-caption);
    font-weight: 600;
    letter-spacing: 0.04em;
    color: var(--color-text-secondary);
  }

  .programs-content:not(.is-list-view) .program-title-row {
    grid-area: title;
    margin-bottom: 4px;
  }

  .programs-content:not(.is-list-view) .programs-content__item-title {
    font-size: 1rem;
    line-height: 1.3;
    min-height: 0;
    -webkit-line-clamp: 2;
  }

  .programs-content:not(.is-list-view) .program-specs-grid {
    grid-area: specs;
    gap: 0;
    margin-bottom: 6px;
  }

  .programs-content:not(.is-list-view) .program-spec-item {
    font-size: var(--fs-secondary);
  }

  .programs-content:not(.is-list-view) .program-spec-item svg {
    display: none;
  }

  .programs-content:not(.is-list-view) .program-spec-item + .program-spec-item::before {
    content: "·";
    margin: 0 6px;
  }

  .programs-content:not(.is-list-view) .program-short-desc {
    display: none;
  }

  /* The day and part-time prices as two short lines, no panel. */
  .programs-content:not(.is-list-view) .program-finance {
    grid-area: price;
    align-self: start;
    display: block;
    margin: 0;
    padding: 0;
    background: none;
    border: 0;
  }

  .programs-content:not(.is-list-view) .program-finance__label {
    display: none;
  }

  .programs-content:not(.is-list-view) .program-price-list {
    grid-template-columns: auto auto;
    justify-content: start;
    gap: 2px 8px;
  }

  .programs-content:not(.is-list-view) .program-price-list__label {
    font-size: var(--fs-secondary);
  }

  .programs-content:not(.is-list-view) .program-price-list__value {
    font-size: var(--fs-secondary);
    font-weight: 600;
    text-align: left;
  }
}
