/* ============================================================
   适老智家 · 页面讲解模式（tour.css）
   —— 「像有人在旁边讲一遍」

   页面引入 js/tour.js 后会自动长出一个入口按钮；
   点进去＝进入放映态：
     · 音频按 时间轴 播放（tools/build-tour.py 预合成的 mp3）
     · 当前讲到的那一块自动滚到视口中间，其余内容退到背景里
     · 讲到的卡片描边亮起、光晕扫一下；成组的卡片依次点亮
     · 底部一条控制条 + 字幕，可以暂停、跳段、退出

   颜色 / 圆角 / 阴影一律沿用 styles.css 的 token，这里只放讲解自己的件。
   前缀 .tour-* / .tb-*
   ============================================================ */

/* ============================================================
   1) 入口：页头里的「听讲解」胶囊
   ============================================================ */
.tour-invite {
  display: flex;
  align-items: center;
  gap: 16px;
  width: 100%;
  /* 与页头配图同宽（.ph-fig 是 880px 居中）—— 入口和配图左右对齐，
     才不会像一条跑偏的横幅 */
  max-width: 880px;
  margin: 28px auto 0;
  padding: 16px 22px;
  text-align: left;
  cursor: pointer;
  border: 1px solid var(--dark-line);
  border-radius: var(--r);
  background: var(--night);
  color: var(--dark-ink);
  box-shadow: var(--shadow-lift);
  transition: transform .24s var(--ease), box-shadow .24s var(--ease);
}
.tour-invite:hover { transform: translateY(-2px); }
.tour-invite:focus-visible { outline: 3px solid var(--dark-brand); outline-offset: 3px; }

.ti-play {
  position: relative;
  flex: none;
  width: min(3.1rem, 62px);
  height: min(3.1rem, 62px);
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--dark-brand);
  color: var(--night);
}
.ti-play svg { width: min(1.35rem, 27px); height: min(1.35rem, 27px); }
/* 呼吸环：慢、轻，只用来把视线牵过来，不闪 */
.ti-play::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid var(--dark-brand);
  animation: ti-pulse 3.2s var(--ease) infinite;
  pointer-events: none;
}
@keyframes ti-pulse {
  0%   { transform: scale(1);    opacity: .55; }
  70%  { transform: scale(1.42); opacity: 0; }
  100% { transform: scale(1.42); opacity: 0; }
}

.ti-txt { min-width: 0; flex: 1 1 auto; }
.ti-txt b {
  display: block;
  font-size: 1.16rem;
  font-weight: 750;
  letter-spacing: .02em;
  color: #fff;
}
.ti-txt span {
  display: block;
  margin-top: 3px;
  font-size: .94rem;
  font-weight: 600;
  line-height: 1.45;
  color: var(--dark-ink-2);
}
.ti-dur {
  flex: none;
  padding: .3rem .72rem;
  border-radius: 999px;
  border: 1px solid var(--dark-line);
  background: rgba(255, 255, 255, .06);
  color: var(--dark-brand);
  font-size: .82rem;
  font-weight: 750;
}

@media (max-width: 560px) {
  .tour-invite { gap: 12px; padding: 14px 16px; margin-top: 22px; }  .ti-txt b { font-size: 1.06rem; }
  .ti-txt span { font-size: .88rem; }
  .ti-dur { display: none; }     /* 手机上文案优先，时长让位 */
}

/* ============================================================
   2) 放映态：其余内容退到背景，讲到的这一块站到台前
   ============================================================ */
html[data-tour="on"] { scroll-padding-top: 96px; scroll-padding-bottom: 210px; }

html[data-tour="on"] main > section {
  opacity: .24;
  transition: opacity .55s var(--ease);
}
html[data-tour="on"] main > section.is-hot { opacity: 1; }

/* 同一块里，没被点到的兄弟再淡一档 —— 一张卡讲一半，其余卡片退开 */
html[data-tour="on"] .tour-dim {
  opacity: .34;
  transition: opacity .45s var(--ease);
}

/* 讲到的目标：描边亮起 + 光晕扫一次（outline 不占位置，不会把版面顶动） */
.tour-hit {
  position: relative;
  z-index: 3;
  outline: 3px solid var(--brand);
  outline-offset: 5px;
  border-radius: var(--r-sm);
  animation: tour-pop 1s var(--ease);
}
@keyframes tour-pop {
  0%   { box-shadow: 0 0 0 0 rgba(29, 78, 216, .40); }
  65%  { box-shadow: 0 0 0 18px rgba(29, 78, 216, 0); }
  100% { box-shadow: 0 0 0 0 rgba(29, 78, 216, 0); }
}
/* 深色区块（底部收尾 / 深色面板）上把描边换成青色，不然蓝压蓝看不见 */
html[data-tour="on"] .cta-box.tour-hit,
html[data-tour="on"] .ai-sec.tour-hit,
html[data-tour="on"] .gallery.tour-hit { outline-color: var(--dark-brand); }

/* 成组依次点亮：用伪元素描边，避免和卡片自己的 box-shadow 打架 */
.tour-pick { position: relative; }
.tour-pick::after {
  content: "";
  position: absolute;
  inset: -5px;
  border-radius: calc(var(--r-sm) + 4px);
  border: 2px solid var(--brand);
  opacity: 0;
  pointer-events: none;
  animation: tour-pick-in .78s var(--ease) both;
  animation-delay: calc(var(--i, 0) * .17s);
}
@keyframes tour-pick-in {
  0%   { opacity: 0;    transform: scale(.985); }
  38%  { opacity: 1;    transform: scale(1); }
  100% { opacity: .34;  transform: scale(1); }
}

/* 讲解时把悬浮拨号条让开，免得更底部控制条撞在一起 */
html[data-tour="on"] .callbar { display: none !important; }

/* 已经在放映里了，入口按钮就收起来，别再占一屏位置 */
html[data-tour="on"] [data-tour-invite] { display: none; }

/* ============================================================
   3) 底部控制条（含字幕）
   ============================================================ */
.tour-bar {
  position: fixed;
  left: 50%;
  bottom: 0;
  z-index: 90;
  width: min(760px, calc(100vw - 32px));
  transform: translateX(-50%) translateY(120%);
  padding: 14px 18px 16px;
  border: 1px solid var(--dark-line);
  border-bottom: 0;
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  background: var(--night);
  box-shadow: 0 -18px 46px -20px rgba(11, 18, 32, .55);
  color: var(--dark-ink);
  transition: transform .34s var(--ease);
}
html[data-tour="on"] .tour-bar { transform: translateX(-50%) translateY(0); }

/* 语音没加载出来时的告知条（靠画面也能看完，但要说清楚） */
.tb-warn {
  margin: 0 0 10px;
  padding: 8px 13px;
  border-radius: var(--r-sm);
  background: rgba(56, 189, 248, .13);
  border: 1px solid rgba(56, 189, 248, .32);
  color: var(--dark-brand);
  font-size: .88rem;
  font-weight: 700;
  line-height: 1.45;
}
.tb-warn[hidden] { display: none; }

/* 字幕：讲到哪句，这里就显示哪句 */
.tb-sub {
  margin: 0 0 12px;
  min-height: 2.9em;
  font-size: 1.02rem;
  font-weight: 650;
  line-height: 1.5;
  color: var(--dark-ink);
}
.tb-sub b { color: var(--dark-brand); font-weight: 750; }

/* 音频在缓冲：字幕尾巴上点一个呼吸的省略号，别让人以为卡死了 */
.tour-bar.is-busy .tb-sub::after {
  content: " …";
  color: var(--dark-brand);
  animation: tb-blink 1.3s steps(2, end) infinite;
}
@keyframes tb-blink { 50% { opacity: .22; } }

.tb-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.tb-btn {
  flex: none;
  display: inline-grid;
  place-items: center;
  width: min(2.5rem, 48px);
  height: min(2.5rem, 48px);
  padding: 0;
  border: 1px solid var(--dark-line);
  border-radius: 50%;
  background: rgba(255, 255, 255, .07);
  color: var(--dark-ink);
  cursor: pointer;
  transition: background .2s var(--ease), transform .2s var(--ease);
}
.tb-btn svg { width: min(1.15rem, 22px); height: min(1.15rem, 22px); }
.tb-btn:hover { background: rgba(255, 255, 255, .16); }
.tb-btn:focus-visible { outline: 3px solid var(--dark-brand); outline-offset: 2px; }

.tb-main {
  width: min(3rem, 58px);
  height: min(3rem, 58px);
  background: var(--dark-brand);
  color: var(--night);
  border-color: transparent;
}
.tb-main:hover { background: #6ad0fb; }
.tb-main svg { width: min(1.4rem, 27px); height: min(1.4rem, 27px); }
/* 播放钮里「播放/暂停」两个图标，按状态切 */
.tb-main .ic-pause { display: none; }
.tour-bar.is-playing .tb-main .ic-play  { display: none; }
.tour-bar.is-playing .tb-main .ic-pause { display: block; }

/* 进度条 */
.tb-track {
  position: relative;
  flex: 1 1 auto;
  min-width: 60px;
  height: 26px;
  display: flex;
  align-items: center;
  cursor: pointer;
}
.tb-track::before {
  content: "";
  position: absolute;
  left: 0; right: 0;
  height: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .16);
}
.tb-fill {
  position: absolute;
  left: 0;
  height: 6px;
  width: 0;
  border-radius: 999px;
  background: var(--dark-brand);
}
.tb-knob {
  position: absolute;
  left: 0;
  width: 13px;
  height: 13px;
  margin-left: -6.5px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(56, 189, 248, .35);
  opacity: 0;
  transition: opacity .2s var(--ease);
}
.tb-track:hover .tb-knob,
.tb-track:focus-visible .tb-knob { opacity: 1; }
.tb-track:focus-visible { outline: 3px solid var(--dark-brand); outline-offset: 2px; border-radius: 999px; }

/* 章节刻度：进度条上按讲解章节打点 */
.tb-chap {
  position: absolute;
  top: 50%;
  width: 2px;
  height: 12px;
  margin-top: -6px;
  border-radius: 1px;
  background: rgba(255, 255, 255, .34);
}

.tb-time {
  flex: none;
  font-size: .84rem;
  font-weight: 700;
  color: var(--dark-ink-2);
  letter-spacing: .02em;
}

.tb-exit {
  width: auto;
  height: min(2.5rem, 48px);
  padding: 0 .9rem;
  gap: .4rem;
  border-radius: 999px;
  font-size: .92rem;
  font-weight: 750;
  color: var(--dark-ink);
  display: inline-flex;
  align-items: center;
}

/* ---- 手机：控制条占满宽度，字幕压到两行，时间让位 ---- */
@media (max-width: 659px) {
  .tour-bar {
    width: 100%;
    padding: 12px 14px calc(12px + env(safe-area-inset-bottom, 0px));
    border-left: 0;
    border-right: 0;
    border-radius: 0;
  }
  .tb-sub {
    font-size: .96rem;
    min-height: 0;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }
  .tb-row { gap: 9px; }
  .tb-time { display: none; }
  .tb-btn { width: min(2.35rem, 44px); height: min(2.35rem, 44px); }
  .tb-main { width: min(2.75rem, 52px); height: min(2.75rem, 52px); }
  .tb-exit { padding: 0 .7rem; font-size: .88rem; }
  .tb-exit span { display: none; }   /* 只留叉号 */
}

/* ============================================================
   4) 长辈模式：字大、对比强，聚光也留一档余地
   ============================================================ */
html[data-mode="elder"][data-tour="on"] { scroll-padding-bottom: 260px; }
/* ⚠️ 必须写成 :not(.is-hot) —— 这条比上面的 .is-hot 规则特异性高，
   直接写 main > section 会把「正在讲的这一块」也一起淡掉（实测：标题有描边却是灰的）。 */
html[data-mode="elder"][data-tour="on"] main > section:not(.is-hot) { opacity: .34; }
html[data-mode="elder"] .tb-sub { font-size: min(1.06rem, 24px); }
html[data-mode="elder"] .tb-time { font-size: min(.86rem, 21px); }
html[data-mode="elder"] .tb-exit { font-size: min(.95rem, 22px); }
html[data-mode="elder"] .ti-txt b { font-size: min(1.2rem, 28px); }
html[data-mode="elder"] .ti-txt span { font-size: min(.97rem, 23px); }
html[data-mode="elder"] .ti-dur { font-size: min(.85rem, 20px); }

/* ============================================================
   5) 关掉动画偏好：只留滚动与描边，不做呼吸和扫光
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  .ti-play::after { animation: none; opacity: 0; }
  .tour-hit { animation: none; }
  .tour-pick::after { animation: none; opacity: .34; transform: none; }
  .tour-invite, .tour-bar { transition: none; }
}
