/* contests.css */

.page-contests {
  background-color: #F8F9FA;
  height: 100vh;
  overflow: hidden;
  overflow-x: hidden;
}

.contests-page-container {
  padding-top: 0;
  height: 100vh;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

/* 顶部 Banner */
.page-header-banner {
  background: linear-gradient(135deg, #4A3E96, #6b5cd6);
  color: #fff;
  padding: calc(var(--header-offset, 80px) + 60px) 20px 60px;
  text-align: center;
}

.page-header-banner h1 {
  font-size: 40px;
  margin-bottom: 15px;
  letter-spacing: 2px;
}

.page-header-banner p {
  font-size: 18px;
  opacity: 0.9;
}

/* 核心内容区 */
.contests-content {
  max-width: 1200px;
  margin: -30px auto 50px;
  padding: 0 20px;
  position: relative;
  z-index: 10;
  overflow: visible;
}

/* 筛选栏 */
.filter-bar {
  background: #fff;
  border-radius: 14px;
  padding: 18px 24px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr)) auto;
  align-items: center;
  column-gap: 16px;
  row-gap: 0;
  box-shadow: 0 14px 34px rgba(51, 45, 108, 0.08);
  margin-bottom: 40px;
  position: relative;
  z-index: 30;
  overflow: visible;
  isolation: isolate;
}

.filter-group {
  display: flex;
  align-items: center;
  gap: 10px;
  background: linear-gradient(180deg, #faf9ff 0%, #f1effc 100%);
  border: 1px solid rgba(74, 62, 150, 0.12);
  padding: 10px 14px;
  border-radius: 10px;
  width: 100%;
  min-width: 0;
}

.filter-group > i {
  font-size: 18px;
  color: #4A3E96;
}

.filter-group-select {
  position: relative;
  min-width: 0;
  max-width: none;
  z-index: 2;
}

.filter-trigger {
  min-width: 0;
  width: 100%;
  flex: 1;
  border: none;
  background: transparent;
  color: #2f2c3f;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  cursor: pointer;
}

.filter-trigger-text {
  flex: 1;
  min-width: 0;
  font-size: 16px;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.filter-trigger .ph-caret-down {
  font-size: 14px;
  margin-left: auto;
  transition: transform 0.2s ease;
}

.filter-group-select.is-open .ph-caret-down {
  transform: rotate(180deg);
}

.filter-group-select.is-open {
  z-index: 420;
}

.filter-reset {
  display: flex;
  align-items: center;
  justify-self: end;
  margin-left: 12px;
}

.filter-reset-btn {
  height: 44px;
  padding: 0 22px;
  border: 1px solid rgba(74, 62, 150, 0.22);
  border-radius: 10px;
  background: #fff;
  color: #4A3E96;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.filter-reset-btn:hover {
  background: #4A3E96;
  border-color: #4A3E96;
  color: #fff;
}

.filter-native {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.filter-menu {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  z-index: 460;
  border-radius: 10px;
  border: 1px solid rgba(74, 62, 150, 0.2);
  background: #fff;
  box-shadow: 0 14px 26px rgba(37, 30, 94, 0.16);
  padding: 6px;
  display: none;
  max-height: 300px;
  overflow-y: auto;
}

.filter-group-select.is-open .filter-menu {
  display: block;
}

.filter-option {
  width: 100%;
  border: none;
  background: transparent;
  color: #2f2c3f;
  border-radius: 8px;
  text-align: left;
  font-size: 16px;
  line-height: 1.2;
  padding: 9px 10px;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.filter-option:hover {
  background: rgba(74, 62, 150, 0.08);
}

.filter-option.is-selected {
  background: #4A3E96;
  color: #fff;
}

@media (max-width: 1200px) {
  .filter-bar {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    row-gap: 12px;
  }

  .filter-reset {
    grid-column: 3;
    justify-self: end;
    margin-left: 0;
  }

}

@media (max-width: 992px) {
  .contests-content {
    padding: 0 16px;
  }

  .filter-bar {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    row-gap: 12px;
  }

  .filter-reset {
    grid-column: 1 / -1;
    justify-self: end;
  }

}

@media (max-width: 768px) {
  .page-header-banner {
    padding: calc(var(--header-offset, 80px) + 24px) 16px 46px;
  }

  .page-header-banner h1 {
    font-size: 32px;
    letter-spacing: 1px;
  }

  .page-header-banner p {
    font-size: 15px;
  }

  .filter-bar {
    grid-template-columns: 1fr;
    padding: 14px;
    row-gap: 10px;
    column-gap: 0;
  }

  .filter-group-select {
    min-width: 0;
  }

  .filter-trigger {
    min-width: 0;
    width: 100%;
  }

  .filter-reset {
    grid-column: auto;
    margin-left: 0;
    width: 100%;
    justify-self: stretch;
  }

  .filter-reset-btn {
    width: 100%;
  }

  .filter-trigger-text,
  .filter-option {
    font-size: 15px;
  }

}

/* ?????? */
.contests-grid-full {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
  gap: 30px;
  position: relative;
  z-index: 0;
}

.contest-card {
  background: #fff;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 4px 15px rgba(0,0,0,0.05);
  transition: all 0.3s ease;
  display: flex;
  flex-direction: column;
  text-decoration: none;
}

.contest-card:hover {
  transform: translateY(-8px);
  box-shadow: 0 15px 35px rgba(74, 62, 150, 0.1);
}

.contest-card-cover {
  width: 100%;
  height: 200px;
  object-fit: cover;
  background: #eee;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #999;
}

.contest-card-body {
  padding: 25px;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.contest-card-tags {
  display: flex;
  gap: 10px;
  margin-bottom: 15px;
}

.tag {
  background: rgba(74, 62, 150, 0.1);
  color: #4A3E96;
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: bold;
}

.contest-card h3 {
  font-size: 18px;
  color: #333;
  margin-bottom: 10px;
  line-height: 1.4;
}

.contest-card p {
  font-size: 14px;
  color: #666;
  line-height: 1.6;
  flex: 1;
}

.contest-card-footer {
  margin-top: 20px;
  padding-top: 15px;
  border-top: 1px solid #eee;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: #999;
  font-size: 13px;
}

@media (max-width: 1200px) {
  .contests-grid-full {
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  }
}

@media (max-width: 992px) {
  .contests-grid-full {
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 20px;
  }
}

@media (max-width: 768px) {
  .contests-grid-full {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .contest-card-body {
    padding: 18px;
  }
}

@media (max-width: 480px) {
  .page-header-banner {
    padding: calc(var(--header-offset, 80px) + 18px) 12px 40px;
  }

  .page-header-banner h1 {
    font-size: 28px;
  }
}

/* Mobile-only contests filter layout:
   keep 5 controls in one row, reset button half width and same height */
body.page-contests.is-mobile-device .contests-content {
  padding: 0 2px;
}

body.page-contests.is-mobile-device .filter-bar {
  grid-template-columns: repeat(4, minmax(0, 1fr)) minmax(48px, 0.5fr);
  align-items: center;
  column-gap: 8px;
  row-gap: 0;
  padding: 14px 12px;
}

body.page-contests.is-mobile-device .filter-group {
  min-height: 42px;
  height: 42px;
  padding: 0 8px;
  gap: 0;
  border-radius: 10px;
}

body.page-contests.is-mobile-device .filter-group > i {
  display: none;
}

body.page-contests.is-mobile-device .filter-trigger {
  height: 100%;
  gap: 2px;
}

body.page-contests.is-mobile-device .filter-trigger-text {
  font-size: 12px;
  line-height: 1;
}

body.page-contests.is-mobile-device .filter-trigger .ph-caret-down {
  display: none;
}

body.page-contests.is-mobile-device .filter-group-select .filter-menu {
  min-width: 100%;
  left: 0;
  right: auto;
}

body.page-contests.is-mobile-device .filter-menu {
  scrollbar-width: none;
  -ms-overflow-style: none;
}

body.page-contests.is-mobile-device .filter-menu::-webkit-scrollbar {
  width: 0;
  height: 0;
  display: none;
}

body.page-contests.is-mobile-device .filter-option {
  font-size: 12px;
  line-height: 1.2;
}

body.page-contests.is-mobile-device .filter-reset {
  grid-column: auto;
  width: 100%;
  margin-left: 0;
  justify-self: stretch;
}

body.page-contests.is-mobile-device .filter-reset-btn {
  width: 100%;
  min-height: 42px;
  height: 42px;
  padding: 0;
  font-size: 15px;
  border-radius: 10px;
}
