/* ==========================================================================
   科研咨询 · 学生反馈展示页
   极简 / 类 Notion 风格：黑、白、灰为主，仅用一种低饱和度绿色做强调
   ========================================================================== */

/* ---------- 1. 设计变量（想调颜色只改这里） ---------- */
:root {
  --bg: #ffffff;              /* 页面背景 */
  --surface: #fbfbfa;         /* 卡片底色 */
  --border: #e9e7e3;          /* 分割线 / 边框 */
  --border-hover: #d6d3cd;    /* 悬停时的边框 */

  --text: #282623;            /* 主文字（近黑） */
  --text-secondary: #767470;  /* 次要文字（灰） */

  --accent: #3f7a5e;          /* 强调色：低饱和度绿（全站唯一强调色） */
  --accent-soft: #edf3ef;     /* 强调色的浅底 */

  --page-max: 1160px;         /* 内容最大宽度 */
  --radius: 8px;
}

/* ---------- 2. 基础排版 ---------- */
* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
               "Microsoft YaHei", "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

img { max-width: 100%; }

button { font: inherit; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---------- 3. 页面容器 ---------- */
.page {
  max-width: var(--page-max);
  margin: 0 auto;
  padding: 0 24px 96px;
}

/* ---------- 4. 页面顶部 ---------- */
.site-header { padding: 56px 0 20px; }

.site-title {
  margin: 0;
  font-size: 30px;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.3;
}

.site-subtitle {
  margin: 8px 0 0;
  font-size: 15px;
  color: var(--text-secondary);
}

.site-subtitle[hidden] { display: none; }

/* ---------- 5. 横向分类导航 ---------- */
.category-nav {
  position: sticky;          /* 滚动时停靠顶部，方便随时切换分类 */
  top: 0;
  z-index: 20;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.category-nav__inner {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  padding: 8px 0;
}

.category {
  appearance: none;
  -webkit-appearance: none;
  border: 0;
  background: transparent;
  color: var(--text-secondary);
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 15px;
  line-height: 1.4;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 0.12s ease, color 0.12s ease;
}

.category:hover {
  background: var(--surface);
  color: var(--text);
}

/* 选中状态：浅绿底 + 绿字，克制但不含糊 */
.category[aria-selected="true"] {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 500;
}

/* ---------- 6. 截图展示区（n × 3 网格） ---------- */
.content { padding-top: 24px; }

.gallery {
  display: grid;
  /* 按容器宽度自动排：宽屏一行 5 个左右，卡片最小 205px，行数随数量增加 */
  grid-template-columns: repeat(auto-fill, minmax(205px, 1fr));
  gap: 14px;
  align-items: start;
}

.gallery[hidden] { display: none; }   /* grid 会覆盖 hidden，这里显式还原 */

.gallery__item { display: block; min-width: 0; }

/* 整张卡片就是一个按钮：上面图片、下面说明 */
.card {
  display: flex;
  flex-direction: column;
  width: 100%;
  margin: 0;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  overflow: hidden;
  text-align: left;
  color: inherit;
  cursor: zoom-in;
  transition: border-color 0.12s ease;
}

.card:hover { border-color: var(--border-hover); }

/* 画框：正方形，所有卡片等大，像微信朋友圈的相册网格 */
.card__thumb {
  aspect-ratio: 1 / 1;
  background: var(--surface);
  overflow: hidden;
}

/* cover = 图片等比缩放后填满画框，多出的部分裁掉（只在缩略图上裁，原图不受影响）；
   center top = 从图片顶部开始取，聊天记录会显示"对话开头"，不会把气泡拦腰截断 */
.card__thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center top;
}

/* 说明行：统一占两行高度，保证同一行卡片的底边对齐；
   超过两行的文字用省略号截断（完整文字悬停可见，且始终保存在数据文件里） */
.card__caption {
  margin: 0;
  padding: 8px 10px 10px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-secondary);
  border-top: 1px solid var(--border);
  min-height: calc(1.5em * 2);          /* 两行的高度 */
  display: -webkit-box;
  -webkit-line-clamp: 2;                 /* 最多显示 2 行 */
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ---------- 7. 空分类 ---------- */
.empty-state {
  margin: 0;
  padding: 64px 0;
  text-align: center;
  color: var(--text-secondary);
  font-size: 15px;
}

.empty-state[hidden] { display: none; }

/* ---------- 8. 回到顶部 ---------- */
.back-to-top {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 30;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--bg);
  color: var(--text-secondary);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  transition: border-color 0.12s ease, color 0.12s ease;
}

.back-to-top:hover {
  border-color: var(--border-hover);
  color: var(--text);
}

.back-to-top[hidden] { display: none; }

/* ---------- 9. 大图预览 ---------- */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 60px 20px 48px;
  background: rgba(18, 18, 18, 0.94);
  overflow-y: auto;              /* 长截图在这里上下滚动浏览 */
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

.lightbox[hidden] { display: none; }

/* 图片按原始比例显示，宽屏不超过 1000px，长图靠滚动看完整 */
.lightbox__img {
  display: block;
  width: auto;
  height: auto;
  max-width: min(1000px, 100%);
  background: #ffffff;
  border-radius: 4px;
}

.lightbox__close {
  position: fixed;
  top: 12px;
  right: 16px;
  z-index: 101;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.14);
  color: #ffffff;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
}

.lightbox__close:hover { background: rgba(255, 255, 255, 0.26); }

/* 预览打开时锁定背景滚动 */
body.is-locked { overflow: hidden; }

/* ---------- 10. 响应式 ---------- */
/* 平板：一行 2 个，并限制整体宽度，让卡片不会一下变得过大（约 290px 一张） */
@media (max-width: 900px) {
  .gallery {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
    max-width: 600px;
    margin: 0 auto;
  }
}

@media (max-width: 620px) {
  .page { padding: 0 16px 72px; }

  .site-header { padding: 36px 0 14px; }
  .site-title { font-size: 26px; }

  /* 手机端：分类不换行，改为横向滚动，避免挤压内容 */
  .category-nav__inner {
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;               /* Firefox 隐藏滚动条 */
    -webkit-overflow-scrolling: touch;
    padding: 6px 0;
  }
  .category-nav__inner::-webkit-scrollbar { display: none; }

  .category { padding: 6px 10px; font-size: 14px; }

  .gallery { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .card__caption { padding: 8px 10px 10px; font-size: 13px; }

  .back-to-top { right: 16px; bottom: 16px; width: 36px; height: 36px; }

  .lightbox { padding: 52px 12px 32px; }
  .lightbox__img { max-width: 100%; border-radius: 0; }
}
