/* search */
.search-bar {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
  max-width: 1435px;
  margin: 0 auto;
  background: #fff;
  border-radius: 30px;
  padding: 11px 20px 11px 47px;
}

.search-icon {
  position: absolute;
  left: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.search-input {
  width: 100%;
  height: 100%;
  background: transparent;
  border: none;
  outline: none;
  font-size: 20px;
  color: #183b59;
  font-family: "Inter", Arial, sans-serif;
  font-weight: 500;
}
.search-input::placeholder {
  color: #183b5933;
  opacity: 20%;
  font-size: 20px;
  opacity: 0.8;
}

.search-hint {
  font-size: 16px;
  color: #183b59;
  margin-top: 4px;
  opacity: 0;
  transition: opacity 0.2s ease;
  margin-top: 10px;
  margin-bottom: 20px;
}

.search-hint.show {
  opacity: 1;
}

/* Hero Section */
.hero {
  background-repeat: no-repeat;
  border-radius: 30px;
  position: relative;
  overflow: hidden;
  max-width: 1435px;
  margin: 0 auto;
  margin-top: 50px;
  height: 390px;
  padding: 47px 50px;
  position: relative;
}

.hero-margins {
  margin: 0 50px;
}

.hero-chemistry {
  background-image: url("/images/chemistry-bg.svg");
}

.hero-title {
  font-family: "Inter";
  font-weight: 900;
  font-size: 76px;
  color: #183b59;
  text-transform: uppercase;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
}

.hero-physics .hero-title {
  color: #fff;
}

@media screen and (max-width: 1440px) {
  .hero {
    padding: 40px;
    margin-top: 40px;
  }

  .hero-margins {
    margin: 0 40px;
  }

  .hero-title {
    font-size: 56px;
  }
}

@media screen and (max-width: 1150px) {
  .hero {
    padding: 30px;
    margin-top: 30px;
  }
}

@media screen and (max-width: 1060px) {
  .hero {
    padding: 25px;
  }
}

@media screen and (max-width: 820px) {
  .hero {
    padding: 20px;
  }

  .hero-margins {
    margin: 0 30px;
  }
}

@media screen and (max-width: 580px) {
  .hero {
    max-height: 540px;
  }

  .hero-title {
    font-size: clamp(30px, 8vw, 46px);
  }
}

/* filter row */
.filter-row {
  display: flex;
  gap: 24px;
  justify-content: space-between;
  align-items: center;
  min-height: 60px; /* Резервируем место для предотвращения CLS */
}

.filter-physics {
  display: flex;
  gap: 24px;
  /* justify-content: space-between; */
  align-items: center;
  min-height: 60px; /* Резервируем место для предотвращения CLS */
}

.filter-btn {
  height: 60px;
  max-width: 250px;
  width: 100%;
  border: none;
  background-color: #f3f8ff;
  border-radius: 15px;
  color: #183b59;
  cursor: pointer;
  transition: background 0.2s;
  font-family: "Inter";
  font-weight: 400;
  font-size: 24px;
  min-height: 60px; /* Резервируем место для предотвращения CLS */
  flex-shrink: 0; /* Предотвращаем сжатие */
}

.filter-btn.active {
  background-color: #0c6ed6;
  color: #fff;
  font-family: "Inter";
  font-weight: 900;
  font-size: 24px;
}

.filter-btn:focus {
  outline: none;
  box-shadow: 0 0 0 2px #0c6ed6;
}

@media (max-width: 1250px) {
  .filter-row,
  .filter-physics {
    gap: 12px;
    overflow-x: auto;
    flex-wrap: nowrap;
    padding: 8px 4px;
  }

  .filter-btn.active {
    font-size: 16px;
  }

  .filter-btn {
    min-width: 140px;
    max-width: 180px;
    height: 44px;
    font-size: 16px;
    border-radius: 12px;
  }

  .search-hint {
    margin-bottom: 10px;
  }
}

/* Video Collection Section */
.video-section {
  margin-top: 50px;
  padding: 40px 40px 100px;
  background-image: url("/images/video-subjects-bg.svg");
}

.video-section-title {
  font-family: "Inter";
  font-weight: 900;
  font-size: clamp(18px, 3vw + 1rem, 36px);
  color: #183b59;
  text-transform: uppercase;
}

.video-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 30px 20px;
  margin-top: 50px;
  align-items: start;
  min-height: 400px; /* Reserve space to prevent layout shift when content loads */
}

.video-card {
  display: block;
  text-decoration: none;
  color: inherit;
}

.card-image {
  position: relative;
  cursor: pointer;
  border-radius: 10px;
  overflow: hidden;
  background-color: #f5f5f5;
  aspect-ratio: 16 / 9;
  /* Фиксируем размер для предотвращения CLS */
  width: 100%;
  min-height: 0;
}

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

.video-card:hover .thumbnail-img {
  transform: scale(1.02);
}

.play-icon {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  transition: all 0.3s ease;
  filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.2));
  opacity: 50%;
  z-index: 2;
}

.video-card:hover .play-icon {
  transform: translate(-50%, -50%) scale(1.1);
  opacity: 100%;
}

.video-text {
  font-family: "Inter";
  font-weight: 500;
  font-size: clamp(13px, 2vw + 1rem, 20px);
  color: #183b59;
  margin-top: 10px;
  line-height: 1.3;
  min-height: 2.6em; /* Резервируем место для 2 строк текста для предотвращения CLS */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.view-all-card .card-image {
  background-color: #b0e881;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: auto;
}

.view-all-content {
  display: flex;
  gap: 20px;
  align-items: center;
  justify-content: center;
  padding: 20px;
  text-align: center;
}

.video-card .card-image {
  transition: all 0.3s ease;
}

.video-card:hover .card-image {
  transform: scale(1.02);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
}

.view-all-content span {
  font-family: "Inter";
  font-weight: 700;
  font-size: clamp(14px, 2vw + 1rem, 24px);
  color: #183b59;
}

@media screen and (max-width: 1440px) {
  .video-section {
    padding: 40px;
    margin-top: 40px;
  }
}

@media (max-width: 1024px) {
  .video-grid {
    margin-top: 30px;
  }

  .video-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 24px;
  }
}

@media screen and (max-width: 950px) {
  .video-section {
    padding: 30px;
    margin-top: 30px;
  }

  .video-grid {
    gap: 20px;
  }
}

@media screen and (max-width: 768px) {
  .video-section {
    padding-left: 20px;
    padding-right: 20px;
  }
}

@media (max-width: 600px) {
  .video-grid {
    grid-template-columns: 1fr;
    gap: 30px;
  }
}

/* physics */
.physics {
  margin-top: 100px;
}

.hero-physics {
  background-image: url("/images/physics-bg.svg");
}

.view-all-card .card-physics {
  background-color: #86bcfc;
}

@media (max-width: 1440px) {
  .physics {
    margin-top: 60px;
  }
}

/* download btn */
.btn-card {
  text-align: center;
}

.show-more {
  background-color: #0c6ed6;
  padding: 23px 92px;
  display: inline-block;
  border-radius: 20px;
  border: none;
  font-family: "Inter";
  font-weight: 900;
  font-size: 32px;
  color: #ffffff;
  margin-top: 50px;
  text-transform: uppercase;
  cursor: pointer;
}

.show-more:hover {
  transform: scale(1.02);
  background-color: #1e81eb;
}

@media (max-width: 540px) {
  .show-more {
    padding: 20px 62px;
    font-size: 25px;
    margin-top: 40px;
  }
}

@media (max-width: 540px) {
  .show-more {
    padding: 18px 42px;
    font-size: 23px;
    margin-top: 30px;
  }
}

/* Skeleton Loader */
.skeleton-card {
  opacity: 0.6;
  display: block;
  text-decoration: none;
  color: inherit;
  /* Обеспечиваем точное соответствие структуре реальной карточки */
  width: 100%;
}

.skeleton-image {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9; /* Такое же соотношение, как у реальных карточек */
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: loading 1.5s ease-in-out infinite;
  border-radius: 10px;
  background-color: #f5f5f5; /* Та же фоновая заливка, что и у .card-image */
}

.skeleton-text {
  height: 2.6em; /* Соответствует min-height реального video-text */
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: loading 1.5s ease-in-out infinite;
  border-radius: 4px;
  margin-top: 10px;
  width: 80%;
}

@keyframes loading {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

/* Loading and Error States */
.loading,
.error,
.no-results {
  grid-column: 1 / -1;
  text-align: center;
  padding: 40px;
  font-family: "Inter";
  font-size: 20px;
  color: #183b59;
  min-height: 400px; /* Резервируем место для предотвращения CLS */
  display: flex;
  align-items: center;
  justify-content: center;
}

.error {
  color: #e74c3c;
}

.no-results {
  color: #666;
}

.video-card .thumbnail-img {
  transition: opacity 0.3s ease;
}

.video-card.loading .thumbnail-img {
  opacity: 0.7;
}

/* Video Popup Styles */
#video-popup {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  justify-content: center;
  align-items: center;
  z-index: 9999;
}

#video-popup .popup-container {
  position: relative;
  width: 90%;
  max-width: 1100px;
  max-height: 95vh;
  background: #000;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

#video-player {
  width: 100%;
  height: auto;
  max-height: calc(95vh - 40px);
  display: block;
}

.popup-close-btn {
  position: absolute;
  top: 15px;
  right: 15px;
  background: rgba(0, 0, 0, 0.7);
  border: none;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 10;
  transition: background 0.3s ease;
}

.popup-close-btn:hover {
  background: rgba(0, 0, 0, 0.9);
  transform: scale(1.1);
}

.popup-close-btn img {
  width: 20px;
  height: 20px;
  filter: brightness(0) invert(1);
}

@media (max-width: 768px) {
  #video-popup .popup-container {
    width: 95%;
    max-height: 90vh;
  }

  #video-player {
    max-height: calc(90vh - 40px);
  }

  .popup-close-btn {
    top: 10px;
    right: 10px;
    width: 35px;
    height: 35px;
  }

  .popup-close-btn img {
    width: 16px;
    height: 16px;
  }
}
