/*
 * 考试首页响应式微调（v1.44）
 * 只作用于 #view-home：不改题目页、结果页、数据接口和原版交互。
 * 目的：让窄桌面不再硬挤四列，手机保持图片、文字、按键完整可见。
 */

#view-home,
#view-home * { min-width: 0; }

/* 桌面顶栏只保留品牌，版本/状态说明不再挤压原有横向顶栏。 */
@media (min-width: 861px) {
  .header-tag { display: none; }
}

/* 卡片内容使用弹性布局，避免固定高度把底部按键裁掉。 */
#view-home .home-core-grid { align-items: stretch; }
#view-home .home-core-grid .mode-card {
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
  height: auto;
  min-height: 218px;
}
#view-home .home-entry-card > *:not(.home-entry-art) { max-width: 70%; }
#view-home .home-entry-card .mode-head {
  align-items: flex-start;
  min-width: 0;
}
#view-home .home-entry-card .mode-head h2 {
  min-width: 0;
  margin: 0;
  line-height: 1.35;
  word-break: normal;
  overflow-wrap: break-word;
}
#view-home .home-entry-card .mode-desc,
#view-home .home-entry-card .home-card-note {
  line-height: 1.45;
  overflow-wrap: break-word;
}
#view-home .home-entry-card .mode-cta {
  position: relative;
  z-index: 2;
  align-self: flex-start;
  width: min(150px, 100%);
  max-width: none;
  min-height: 34px;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: auto;
  white-space: nowrap;
}
#view-home .home-entry-art { object-fit: cover; object-position: 72% center; }
#view-home [data-exam="zhuli"] .home-entry-art { object-position: 74% 36%; }
#view-home [data-exam="shicheng"] .home-entry-art { object-position: 72% 38%; }
#view-home .selftest-entry .home-entry-art { object-position: 78% center; }
#view-home .compare-entry .home-entry-art { object-position: 76% center; }

/* 目前页面宽度不足以舒服容纳四列时，主入口改为 2×2。 */
@media (min-width: 641px) and (max-width: 1199px) {
  #view-home .home-core-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
  }
  #view-home .home-core-grid .mode-card {
    min-height: 218px;
  }
  #view-home .home-entry-card > *:not(.home-entry-art) { max-width: 68%; }
}

/* 大桌面保留四列，但给内容更合理的整体宽度。 */
@media (min-width: 1200px) {
  body:has(#view-home.active) .app-main { max-width: 1080px; }
  #view-home .home-core-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
  }
  #view-home .home-core-grid .mode-card { min-height: 226px; }
  #view-home .home-entry-card > *:not(.home-entry-art) { max-width: 72%; }
}

/* 首页 Hero：保留每日任务和图片，只压缩空白区域。 */
#view-home .home-hero {
  position: relative;
  overflow: hidden;
}
#view-home .home-hero-art { object-position: 68% center; }
#view-home .home-hero .daily-items {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
#view-home .home-hero .daily-item {
  min-height: 32px;
  box-sizing: border-box;
}
#view-home #active-exam-card:not([hidden]) {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

/* 手机端：两列紧凑入口，图片靠右、文字靠左、按钮落在内容区底部。 */
@media (max-width: 640px) {
  #view-home .home-heading { margin-bottom: 12px; }
  #view-home .home-heading-mark { font-size: 25px; }
  #view-home .home-hero {
    min-height: 0;
    margin-bottom: 14px;
    padding: 11px 12px 10px;
  }
  #view-home .home-hero-art {
    opacity: .38;
    object-position: 70% center;
  }
  #view-home .hero-head { gap: 6px; }
  #view-home .hero-ico { width: 23px; height: 23px; }
  #view-home .hero-tt { font-size: 14px; }
  #view-home .home-hero .daily-items {
    gap: 6px;
    margin-top: 8px;
  }
  #view-home .home-hero .daily-item {
    min-height: 31px;
    padding: 5px 10px;
    font-size: 11.5px;
  }
  #view-home .hero-prog { margin-top: 7px; font-size: 11.5px; }
  #view-home .hero-sub { margin-top: 3px; font-size: 11px; }
  #view-home .hero-divider { margin: 7px 0 3px; }
  #view-home #active-exam-card:not([hidden]) {
    align-items: flex-start;
    flex-direction: column;
    padding: 8px 9px !important;
  }
  #view-home #active-exam-card .subject-info { width: 100%; }
  #view-home #active-exam-card .btn { flex: 1; }

  #view-home .sec-title { margin-top: 13px; margin-bottom: 7px; }
  #view-home .home-core-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }
  #view-home .home-core-grid .mode-card {
    height: 158px;
    min-height: 158px;
    max-height: 158px;
    padding: 11px 9px 10px 12px;
    border-radius: 12px;
  }
  #view-home .home-entry-card > *:not(.home-entry-art) { max-width: 68%; }
  #view-home .home-entry-card .mode-head { gap: 5px; }
  #view-home .home-entry-card .mode-head svg {
    width: 27px;
    height: 27px;
    padding: 5px;
  }
  #view-home .home-entry-card .home-card-glyph {
    width: 27px;
    height: 27px;
    font-size: 10px;
  }
  #view-home .home-entry-card .mode-head h2 {
    font-size: 14px;
    line-height: 1.25;
  }
  #view-home .home-entry-card .mode-desc {
    margin: 5px 0 4px;
    font-size: 10.5px;
    line-height: 1.28;
  }
  #view-home .home-entry-card .home-card-note,
  #view-home .home-entry-card .mode-detail summary {
    font-size: 10px;
    line-height: 1.3;
  }
  #view-home .home-action-card .home-card-note {
    display: block;
    min-height: 0;
    height: 12px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 9px;
    line-height: 1.2;
  }
  #view-home .home-entry-card .mode-cta {
    align-self: stretch;
    width: 100%;
    min-height: 32px;
    padding: 5px 4px;
    font-size: 11px;
  }
  #view-home .home-entry-art { opacity: .76; object-position: 74% center; }
  #view-home .home-entry-card::after {
    background: linear-gradient(90deg,
      rgba(247,241,229,.91) 0%,
      rgba(247,241,229,.73) 48%,
      rgba(247,241,229,.25) 78%,
      rgba(247,241,229,.05) 100%);
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }

  #view-home .home-bottom-grid {
    grid-template-columns: 1fr;
    gap: 13px;
    margin-top: 14px;
  }
  #view-home .home-bottom-grid .quick-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }
  #view-home .quick-card {
    min-height: 102px;
    padding: 10px 34% 9px 12px;
    border-radius: 11px;
  }
  #view-home .quick-card-art { opacity: .70; object-position: 74% center; }
  #view-home .quick-title { font-size: 12.5px; line-height: 1.25; }
  #view-home .quick-sub { font-size: 10.5px; line-height: 1.35; }

  #view-home .library-entry-wrap { padding: 9px 9px 10px; }
  #view-home .library-entry-head { margin-bottom: 6px; }
  #view-home .library-entry-head span { font-size: 13px; }
  #view-home .library-entry-head small { font-size: 9.5px; }
  #view-home .library-entry-grid { gap: 6px; }
  #view-home .library-entry-card {
    min-height: 88px;
    padding: 8px 5px;
    border-radius: 8px;
  }
  #view-home .library-entry-card-art { opacity: .66; }
  #view-home .library-entry-card-text b { font-size: 11px; }
  #view-home .library-entry-card-text small { font-size: 9px; line-height: 1.25; }
  #view-home .library-entry-count { font-size: 9.5px; }
  #view-home .home-bottom-grid .gs-card { margin-top: 7px; }
}

@media (max-width: 360px) {
  #view-home .home-core-grid .mode-card { height: 158px; min-height: 158px; max-height: 158px; }
  #view-home .home-entry-card > *:not(.home-entry-art) { max-width: 72%; }
  #view-home .home-entry-card .mode-head h2 { font-size: 13.5px; }
  #view-home .quick-card { min-height: 98px; padding-right: 31%; }
}

/* 极窄屏只在确实放不下时退回单列，避免文字和按钮互相遮挡。 */

/* 视觉装饰层不参与点击，点击统一交给卡片事件。 */
#view-home .home-entry-card::before,
#view-home .home-entry-card::after,
#view-home .home-entry-card .home-entry-art {
  pointer-events: none;
}

@media (max-width: 330px) {
  #view-home .home-core-grid { grid-template-columns: 1fr; }
  #view-home .home-core-grid .mode-card { min-height: 132px; }
}
