/* ==========================================================================
   css/trial.css —— 寻迹试炼（入口板块 + 全屏闯关弹层）
   说明：板块用 .panel 打底，弹层复用 detail.css 的 .modal 骨架。
        印记用「壹 贰 叁 肆」代替字母，正印以朱砂印章盖下。
   ========================================================================== */

/* -------------------------------------------------------------- 入口板块 */
.trial-shell {
  padding: clamp(24px, 4vw, 40px);
}

.trial-board {
  display: flex;
  align-items: center;
  gap: clamp(18px, 3vw, 34px);
  flex-wrap: wrap;
}

.trial-seal {
  flex: none;
  width: 104px;
  height: 104px;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: .92;
  transform: rotate(0deg);
}

.seal-trial {
  width: 100%;
  height: 100%;
}

.trial-board-main {
  flex: 1 1 260px;
  min-width: 0;
}

.tb-title {
  font-family: var(--font-kai);
  font-size: clamp(19px, 2.4vw, 24px);
  letter-spacing: .16em;
  color: var(--ink);
  margin: 0 0 10px;
}

.tb-best {
  font-size: 14px;
  color: var(--ink-soft);
  margin: 0 0 6px;
  letter-spacing: .04em;
}

.tb-best b {
  font-family: var(--font-num);
  font-size: 19px;
  color: var(--red);
  margin-left: 4px;
}

.tb-note {
  font-size: 13.5px;
  line-height: 1.8;
  color: var(--ink-soft);
  margin: 0 0 16px;
}

.trial-acts {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

/* 板块下方的三条说明 */
.trial-rules {
  list-style: none;
  margin: 26px 0 0;
  padding: 20px 0 0;
  border-top: var(--line);
  display: grid;
  gap: 9px;
}

.trial-rules li {
  position: relative;
  padding-left: 20px;
  font-size: 13.5px;
  line-height: 1.85;
  color: var(--ink-soft);
}

.trial-rules li::before {
  content: "";
  position: absolute;
  left: 2px;
  top: 9px;
  width: 7px;
  height: 7px;
  border-radius: 2px;
  background: var(--red);
  opacity: .78;
  transform: rotate(45deg);
}

.trial-rules b {
  color: var(--red);
  font-family: var(--font-num);
  font-size: 15px;
}

/* ---------------------------------------------------------- 闯关弹层骨架 */
.trial-panel {
  width: min(760px, 100%);
  max-height: min(88vh, 860px);
}

.trial-stage {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  /* 顶部留白让开右上角的收起按钮 */
  padding: 48px clamp(22px, 4vw, 34px) clamp(22px, 4vw, 34px);
}

/* 关卡头：关数与落印数 + 墨线进度 */
.tv-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  font-size: 13.5px;
  color: var(--ink-soft);
  letter-spacing: .06em;
}

.tv-head b {
  font-family: var(--font-num);
  font-size: 21px;
  color: var(--red);
  margin: 0 4px;
}

.tv-bar {
  height: 6px;
  margin: 12px 0 24px;
  border-radius: 99px;
  background: rgba(31, 28, 26, .1);
  box-shadow: var(--inner);
  overflow: hidden;
}

.tv-bar i {
  display: block;
  height: 100%;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--red-deep), var(--red) 55%, var(--gold));
  transition: width .45s var(--ease-out);
}

/* 谜面 */
.tv-ask {
  display: flex;
  gap: 12px;
  font-family: var(--font-kai);
  font-size: clamp(17px, 2.3vw, 20.5px);
  line-height: 1.85;
  color: var(--ink);
  margin: 0 0 24px;
  animation: tv-in .5s var(--ease-out) both;
}

.tv-ask::before {
  content: "谜";
  flex: none;
  width: 30px;
  height: 30px;
  margin-top: 4px;
  border-radius: 5px;
  background: var(--red);
  color: #fdf6ea;
  font-family: var(--font-kai);
  font-size: 19px;
  line-height: 30px;
  text-align: center;
  box-shadow: inset 0 0 0 2px rgba(253, 246, 234, .5);
}

/* 四枚印记 */
.tv-marks {
  display: grid;
  gap: 12px;
}

.tv-mark {
  position: relative;
  display: flex;
  align-items: center;
  gap: 13px;
  width: 100%;
  padding: 14px 76px 14px 16px;
  border: var(--line);
  border-radius: var(--radius-sm);
  background: linear-gradient(180deg, var(--paper-warm), rgba(239, 230, 212, .72));
  box-shadow: var(--shadow-sm), var(--inner);
  font-family: var(--font-kai);
  font-size: 15.5px;
  line-height: 1.65;
  color: var(--ink-2);
  text-align: left;
  cursor: pointer;
  overflow: hidden;
  transition: transform .22s var(--ease), border-color .22s var(--ease), box-shadow .22s var(--ease);
  animation: tv-in .45s var(--ease-out) both;
}

.tv-mark:nth-child(2) { animation-delay: .05s; }
.tv-mark:nth-child(3) { animation-delay: .1s; }
.tv-mark:nth-child(4) { animation-delay: .15s; }

.tv-num {
  flex: none;
  width: 30px;
  height: 30px;
  border: var(--line-red);
  border-radius: 50%;
  background: var(--red-soft);
  color: var(--red);
  font-size: 14px;
  line-height: 28px;
  text-align: center;
  transition: background .22s var(--ease), color .22s var(--ease);
}

.tv-text {
  min-width: 0;
}

/* 正印小章：答对时从大盖成原尺寸 */
.tv-flag {
  position: absolute;
  right: 14px;
  top: 50%;
  width: 42px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border-radius: 50%;
  background: var(--red);
  color: #fdf6ea;
  font-family: var(--font-kai);
  font-size: 12.5px;
  letter-spacing: .16em;
  text-indent: .16em;
  box-shadow: inset 0 0 0 2px rgba(253, 246, 234, .55);
  opacity: 0;
  transform: translateY(-50%) rotate(0deg) scale(2.4);
  transition: opacity .3s var(--ease-out), transform .38s var(--spring);
}

@media (hover: hover) {
  .tv-mark:hover {
    transform: translateY(-2px);
    border-color: rgba(201, 162, 39, .7);
    box-shadow: var(--shadow), var(--inner);
  }
  .tv-mark:hover .tv-num {
    background: rgba(201, 162, 39, .22);
    color: var(--ink);
  }
}

.tv-mark.is-picked {
  animation: none;
}

.tv-mark.is-right {
  border-color: rgba(178, 58, 43, .55);
  background: linear-gradient(180deg, rgba(178, 58, 43, .07), rgba(251, 247, 238, .92));
}

.tv-mark.is-right .tv-num {
  background: var(--red);
  border-color: var(--red);
  color: #fdf6ea;
}

.tv-mark.is-right .tv-flag {
  opacity: 1;
  transform: translateY(-50%) rotate(0deg) scale(1);
}

.tv-mark.is-wrong {
  border-style: dashed;
  border-color: rgba(31, 28, 26, .3);
  background: rgba(239, 230, 212, .45);
  opacity: .62;
  animation: tv-shake .4s var(--ease);
}

.tv-mark.is-wrong .tv-num {
  border-color: rgba(31, 28, 26, .25);
  background: transparent;
  color: var(--ink-soft);
}

/* 解语 */
.tv-lore {
  margin-top: 20px;
  padding: 16px 18px;
  border-radius: var(--radius-sm);
  border-left: 4px solid var(--ink-soft);
  background: linear-gradient(180deg, rgba(255, 255, 255, .58), rgba(239, 230, 212, .5));
  box-shadow: var(--inner);
  animation: tv-in .45s var(--ease-out) both;
}

.tv-lore.ok {
  border-left-color: var(--red);
}

.tv-lore.no {
  border-left-color: rgba(31, 28, 26, .38);
}

.tv-verdict {
  margin: 0 0 8px;
  font-family: var(--font-kai);
  font-size: 15px;
  letter-spacing: .08em;
  color: var(--ink-soft);
}

.tv-lore.ok .tv-verdict {
  color: var(--red);
}

.tv-lore-text {
  margin: 0;
  font-size: 14.5px;
  line-height: 1.9;
  color: var(--ink-2);
}

.tv-lore-text b {
  font-family: var(--font-kai);
  font-weight: 400;
  color: var(--red);
}

.tv-lore .tv-acts,
.tv-done .tv-acts {
  margin-top: 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

/* 结果 */
.tv-done {
  text-align: center;
  padding: 6px 0 4px;
  animation: tv-in .5s var(--ease-out) both;
}

.tv-done-seal {
  width: clamp(112px, 26vw, 148px);
  height: clamp(112px, 26vw, 148px);
  margin: 0 auto 18px;
  transform-origin: 50% 42%;
  animation: tv-seal-drop .7s var(--spring) both;
}

.tv-done-title {
  font-family: var(--font-kai);
  font-size: 20px;
  letter-spacing: .3em;
  text-indent: .3em;
  color: var(--ink);
  margin: 0 0 12px;
}

.tv-done-score {
  font-size: 15px;
  color: var(--ink-soft);
  margin: 0 0 10px;
}

.tv-done-score b {
  font-family: var(--font-num);
  font-size: 34px;
  color: var(--red);
  margin: 0 4px;
}

.tv-done-line {
  font-size: 14.5px;
  line-height: 1.9;
  color: var(--ink-2);
  margin: 0 0 8px;
}

.tv-done-line.dim {
  color: var(--ink-soft);
  font-size: 13.5px;
}

.tv-done-new {
  display: inline-block;
  margin: 4px 0 8px;
  padding: 5px 14px;
  border: var(--line-gold);
  border-radius: 99px;
  background: rgba(201, 162, 39, .12);
  color: #8d6f18;
  font-size: 13px;
  letter-spacing: .1em;
}

.tv-done .tv-acts {
  justify-content: center;
}

/* ------------------------------------------------------------------ 动效 */
@keyframes tv-in {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes tv-shake {
  0%, 100% { transform: translateX(0); }
  22% { transform: translateX(-5px); }
  46% { transform: translateX(4px); }
  70% { transform: translateX(-2px); }
}

@keyframes tv-seal-drop {
  0% { opacity: 0; transform: translateY(-28px) scale(1.5) rotate(-12deg); }
  62% { opacity: 1; transform: translateY(3px) scale(.97) rotate(-2deg); }
  100% { opacity: .95; transform: translateY(0) scale(1) rotate(-4deg); }
}

/* ------------------------------------------------------------ 断点适配 */
@media (min-width: 620px) {
  .tv-marks {
    grid-template-columns: 1fr 1fr;
  }
  .tv-flag {
    right: 10px;
  }
}

@media (max-width: 600px) {
  .trial-shell {
    padding: 22px 16px;
  }
  .trial-seal {
    width: 78px;
    height: 78px;
  }
  .trial-board {
    gap: 16px;
  }
  .trial-rules {
    margin-top: 20px;
  }
  .tv-mark {
    padding: 13px 16px 32px;
    /* 正印小章移到右下角，避免小屏挤掉正文 */
  }
  .tv-flag {
    right: 10px;
    top: auto;
    bottom: 8px;
    transform: translateY(0) rotate(-22deg) scale(2.4);
  }
  .tv-mark.is-right .tv-flag {
    transform: translateY(0) rotate(-9deg) scale(1);
  }
}

@media (prefers-reduced-motion: reduce) {
  .tv-ask,
  .tv-mark,
  .tv-lore,
  .tv-done,
  .tv-done-seal {
    animation: none;
  }
}