/* Mathmiu 谜题中心 —— 访客端 */
:root {
  --brand: #ea6a31;
  --admin: #5b2ca3;
  --page: #ffffff;
  --ink: #2b2b2e;
  --muted: #7a7d85;
  --line: rgba(43, 43, 46, 0.12);
  --card-radius: 22px;
  /* cdn.1top1.app 只提供 .ttf 且不带 CORS 头，跨域永远加载不了，
     引它只会刷控制台报错。装了思源圆体的机器走本地字体，其余走系统字体。 */
  --font: "Resource Han Rounded CN", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei",
    -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0 40px 72px;
  background: var(--page);
  color: var(--ink);
  font: 400 16px/1.6 var(--font);
  -webkit-font-smoothing: antialiased;
  /* 缩放下限：窄到 320px 以下就横向滚动，不再继续压缩版面 */
  min-width: 320px;
}

/* —— 顶栏 —— */
.masthead {
  display: flex;
  align-items: center;
  gap: 28px;
  max-width: 1320px;
  margin: 0 auto;
  padding: 22px 0 26px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  text-decoration: none;
  flex: none;
}

.brand__logo {
  width: auto;
  height: 56px;
}

.brand__name {
  font-size: 26px;
  font-weight: 700;
  color: var(--brand);
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.search {
  position: relative;
  flex: 1;
  max-width: 680px;
  margin: 0 auto;
}

.search__icon {
  position: absolute;
  left: 20px;
  top: 50%;
  transform: translateY(-50%);
  width: 20px;
  height: 20px;
  fill: none;
  stroke: var(--muted);
  stroke-width: 2;
  stroke-linecap: round;
  pointer-events: none;
}

.search__input {
  width: 100%;
  padding: 14px 22px 14px 52px;
  border: 1.5px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 16px;
}

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

.search__input:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 4px rgba(234, 106, 49, 0.12);
}

/* Safari 的搜索框清除按钮 */
.search__input::-webkit-search-cancel-button {
  cursor: pointer;
}

.admin-entry {
  display: grid;
  place-items: center;
  flex: none;
  width: 52px;
  height: 52px;
  border: 1.5px solid var(--admin);
  border-radius: 14px;
  color: var(--admin);
  text-decoration: none;
  transition: background 0.15s ease;
}

.admin-entry svg {
  width: 26px;
  height: 26px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.admin-entry:hover,
.admin-entry:focus-visible {
  background: rgba(91, 44, 163, 0.08);
}

/* —— 领域筛选 —— */
.domains {
  max-width: 1320px;
  margin: 0 auto 30px;
}

.domains__list {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.domain-pill {
  padding: 10px 26px;
  border: 1.5px solid transparent;
  border-radius: 999px;
  background: var(--domain-color, #eee);
  color: var(--ink);
  font: inherit;
  font-size: 15px;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.domain-pill:hover {
  transform: translateY(-1px);
}

.domain-pill[aria-pressed="true"] {
  border-color: rgba(43, 43, 46, 0.55);
  box-shadow: 0 2px 8px rgba(43, 43, 46, 0.12);
  font-weight: 700;
}

/* —— 卡片网格 —— */
#main {
  max-width: 1320px;
  margin: 0 auto;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 24px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.card {
  display: grid;
  grid-template-columns: minmax(0, 44%) minmax(0, 1fr);
  align-items: center;
  gap: 20px;
  min-height: 260px;
  padding: 26px 28px;
  border-radius: var(--card-radius);
  background: var(--domain-color, #eee);
  color: var(--ink);
  text-decoration: none;
  transition: transform 0.16s ease, box-shadow 0.16s ease;
}

.card:hover,
.card:focus-visible {
  transform: translateY(-3px);
  box-shadow: 0 10px 30px rgba(43, 43, 46, 0.14);
}

.card:focus-visible {
  outline: 2.5px solid var(--ink);
  outline-offset: 3px;
}

/* 缩略图直接落在卡片底色上（插画式），所以用 contain 而不是 cover。 */
.card__thumb {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 4 / 3;
  object-fit: contain;
}

.card__thumb--empty {
  display: grid;
  place-items: center;
  aspect-ratio: 4 / 3;
  border: 1.5px dashed rgba(43, 43, 46, 0.22);
  border-radius: 14px;
  color: var(--muted);
  font-size: 13px;
}

.card__body {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}

.card__title {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  line-height: 1.3;
}

.card__description {
  margin: 0;
  font-size: 14px;
  color: #5c5f66;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card__meta {
  margin-top: 2px;
  font-size: 13px;
  color: #6f727a;
}

.state {
  padding: 80px 0;
  text-align: center;
  color: var(--muted);
}

.state[data-tone="error"] {
  color: #b3261e;
}

@media (max-width: 900px) {
  body {
    padding: 0 20px 56px;
  }
  .masthead {
    flex-wrap: wrap;
    gap: 16px;
  }
  .search {
    order: 3;
    flex-basis: 100%;
    max-width: none;
  }
  /* 顶栏换行后，搜索框独占一行，管理入口靠 auto 外边距顶到最右 */
  .admin-entry {
    margin-left: auto;
  }
  .brand__name {
    font-size: 21px;
  }
  .brand__logo {
    height: 46px;
  }
  .grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 400px) {
  /* 到了缩放下限附近，品牌收一号，保证它和管理入口还能并排一行 */
  .brand {
    gap: 10px;
  }
  .brand__name {
    font-size: 17px;
  }
  .brand__logo {
    height: 34px;
  }
  .admin-entry {
    width: 46px;
    height: 46px;
  }
}

@media (max-width: 520px) {
  .card {
    grid-template-columns: 1fr;
    min-height: 0;
  }
  .card__thumb,
  .card__thumb--empty {
    aspect-ratio: 16 / 9;
  }
}

[hidden] {
  display: none !important;
}
