/* ==========================================================================
   css/gallery.css —— 非遗卡片墙 + 声音墙
   说明：每张卡片展示照片、标签与简介；点卡片打开全屏详情弹层（见 detail.css）。
   ========================================================================== */

/* ---------------------------------------------------------------- 卡片墙 */
.card-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--gap);
}

.card {
  position: relative;
  height: 428px;
  cursor: pointer;
  transition: transform .38s var(--ease), filter .38s var(--ease);
}

.card:hover { transform: translateY(-10px); }
.card:focus-visible { outline: none; }
.card:focus-visible .card-inner { box-shadow: 0 0 0 3px rgba(178, 58, 43, .45); border-radius: var(--radius); }

.card-inner {
  position: relative;
  width: 100%;
  height: 100%;
}

/* 卡片面板：宣纸底 + 纸纹 + 毛边 + 内阴影 + 描边 */
.face {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  padding: 24px 22px 20px;
  overflow: hidden;
  border: var(--line);
  border-radius: var(--radius);
  background:
    url('../assets/svg/paper-noise.svg') 0 0 / 240px 240px,
    linear-gradient(178deg, rgba(255, 253, 246, .97), rgba(245, 238, 224, .98));
  box-shadow: var(--shadow), var(--inner);
}

/* 内层虚线：剪纸似的框 */
.face::before {
  content: "";
  position: absolute;
  inset: 9px;
  border: 1px dashed rgba(178, 58, 43, .34);
  border-radius: var(--radius-sm);
  pointer-events: none;
}

/* 毛边 */
.face::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  background: url('../assets/svg/rough-edge.svg') center / 100% 100% no-repeat;
  opacity: .3;
}

/* 顶部一道朱砂色带 */
.face.front .card-bar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 5px;
  background: repeating-linear-gradient(90deg,
    rgba(178, 58, 43, .8) 0 14px, rgba(201, 162, 39, .75) 14px 28px);
}

/* ------------------------------------------------------------- 卡片正面 */
.card-icon {
  position: relative;
  z-index: 1;
  width: 92px;
  height: 92px;
  margin: 4px auto 12px;
  padding: 6px;
  color: var(--ink);
  transition: transform .4s var(--ease);
}

.card:hover .card-icon { transform: translateY(-3px) scale(1.04); }

/* ---------------------------------------------- 卡面照片（替代线描图标） */
.card-photo {
  position: relative;
  z-index: 1;
  height: 175px;
  margin-bottom: 12px;
  border: 1px solid rgba(31, 28, 26, .16);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: rgba(246, 240, 228, .9);
  box-shadow: var(--shadow-sm);
}

/* 模糊背景层：用同一张照片铺满，填充横/竖屏留白，避免出现空白窄条 */
.card-photo-bg {
  position: absolute;
  inset: -12px;
  z-index: 0;
  width: calc(100% + 24px);
  height: calc(100% + 24px);
  object-fit: cover;
  object-position: center;
  filter: blur(20px) brightness(.78) saturate(1.08);
  transform: scale(1.04);
  pointer-events: none;
}

.card-photo img:not(.card-photo-bg) {
  position: relative;
  z-index: 1;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: var(--pos, 50% 40%);
  filter: saturate(.94) contrast(1.03);
  transition: transform .6s var(--ease);
}

.card:hover .card-photo img { transform: scale(1.045); }

/* 压一层毛边，让照片也像贴在宣纸上 */
.card-photo::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  background: url('../assets/svg/rough-edge.svg') center / 100% 100% no-repeat;
  opacity: .26;
}

/* 角上的小印：把原来的线描图标缩下来，身份不丢 */
.card-photo-icon {
  position: absolute;
  z-index: 2;
  right: 8px;
  bottom: 8px;
  width: 32px;
  height: 32px;
  padding: 4px;
  border: 1px solid rgba(201, 162, 39, .62);
  border-radius: 50%;
  color: var(--ink);
  background: rgba(251, 247, 238, .92);
  box-shadow: var(--shadow-sm);
}

.card-head { position: relative; z-index: 1; text-align: center; }

.card-name {
  font-size: 1.24rem;
  font-weight: 700;
  letter-spacing: .1em;
  line-height: 1.4;
}

.card-region {
  margin-top: 4px;
  font-family: var(--font-kai);
  font-size: .8rem;
  letter-spacing: .1em;
  color: var(--ink-soft);
}

.card-tagline {
  position: relative;
  z-index: 1;
  margin-top: 12px;
  padding: 0 4px;
  font-family: var(--font-kai);
  font-size: .92rem;
  line-height: 1.8;
  letter-spacing: .04em;
  text-align: center;
  color: var(--red-deep);
}

/* 底部：等级 + 听一声 + 序号角标 */
.card-foot {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: auto;
  padding-top: 12px;
}

.card-foot-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* 右下角序号角标：按卡片顺序排列 1、2、3、4… */
.level-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 30px;
  height: 30px;
  padding: 0 9px;
  border: 1px solid rgba(178, 58, 43, .5);
  border-radius: 8px;
  font-family: var(--font-kai);
  font-size: 1rem;
  font-weight: 700;
  line-height: 1;
  color: var(--red);
  background: rgba(178, 58, 43, .06);
  box-shadow: var(--shadow-sm);
}

.card-sound {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 6px 10px;
  border: 1px solid rgba(201, 162, 39, .55);
  border-radius: 999px;
  background: rgba(255, 253, 246, .7);
  transition: background .22s var(--ease), border-color .22s var(--ease), transform .22s var(--ease);
}

.card-sound:hover {
  transform: translateY(-2px);
  border-color: var(--gold);
  background: rgba(201, 162, 39, .14);
}

.card-sound .wave {
  display: block;
  width: 3px;
  height: 10px;
  border-radius: 2px;
  background: var(--gold);
}

.card-sound .wave:nth-child(2) { height: 16px; }
.card-sound .wave:nth-child(3) { height: 7px; }

.card-sound.playing .wave,
.chip-sound.playing .wave {
  animation: jc-wave .62s ease-in-out infinite alternate;
}

.card-sound.playing .wave:nth-child(2) { animation-delay: .12s; }
.card-sound.playing .wave:nth-child(3) { animation-delay: .24s; }

@keyframes jc-wave {
  from { transform: scaleY(.5); opacity: .6; }
  to   { transform: scaleY(1.5); opacity: 1; }
}

/* “看详情”按钮 */
.card-more {
  position: relative;
  z-index: 2;
  display: block;
  width: 100%;
  margin-top: 10px;
  padding: .5em 0;
  border: 1px solid rgba(178, 58, 43, .55);
  border-radius: var(--radius-sm);
  font-family: var(--font-kai);
  font-size: .84rem;
  letter-spacing: .16em;
  text-indent: .16em;
  color: var(--red);
  background: rgba(178, 58, 43, .06);
  transition: background .22s var(--ease), color .22s var(--ease), box-shadow .22s var(--ease);
}

.card-more:hover {
  background: var(--red);
  color: #fdf8ee;
  box-shadow: 0 8px 18px rgba(178, 58, 43, .26);
}

/* --------------------------------------------------------------- 声音墙 */
.sound-wall {
  margin-top: 34px;
  padding: 26px 22px 24px;
}

.sound-wall-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 18px;
}

.sound-wall-head h3 {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: .14em;
}

.sound-wall-head .warn {
  margin-top: 6px;
  font-family: var(--font-kai);
  font-size: .8rem;
  letter-spacing: .06em;
  color: var(--ink-soft);
}

/* 总开关 */
.sound-mute {
  display: inline-flex;
  align-items: center;
  gap: .5em;
  padding: .45em 1.05em;
  border: 1px solid rgba(201, 162, 39, .6);
  border-radius: 999px;
  font-family: var(--font-kai);
  font-size: .82rem;
  letter-spacing: .1em;
  color: var(--ink-2);
  background: rgba(255, 253, 246, .75);
  transition: background .22s var(--ease), border-color .22s var(--ease), color .22s var(--ease);
}

.sound-mute::before {
  content: "";
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 0 3px rgba(201, 162, 39, .2);
}

.sound-mute:hover { border-color: var(--gold); background: rgba(201, 162, 39, .14); }

.sound-mute.off {
  color: var(--ink-soft);
  border-color: rgba(31, 28, 26, .25);
}

.sound-mute.off::before { background: rgba(31, 28, 26, .3); box-shadow: none; }

.sound-chips {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 12px;
}

.chip-sound {
  display: grid;
  grid-template-columns: 34px 1fr;
  grid-template-rows: auto auto;
  gap: 0 10px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  text-align: left;
}

.chip-sound .chip-icon {
  grid-row: span 2;
  width: 34px;
  height: 34px;
  align-self: center;
  color: var(--ink);
}

.chip-sound .chip-name {
  font-size: .92rem;
  font-weight: 700;
  letter-spacing: .06em;
  color: var(--ink);
}

.chip-sound .chip-note {
  font-size: .74rem;
  letter-spacing: .04em;
  color: var(--ink-soft);
}

.chip-sound.playing {
  border-color: var(--red);
  background: rgba(178, 58, 43, .1);
  box-shadow: 0 8px 20px rgba(178, 58, 43, .16);
}

/* 卡片 / 标签在播放时的轻微脉动 */
.card.playing .card-icon { animation: jc-beat .6s ease-in-out 2; }

@keyframes jc-beat {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.07); }
}