/* 《从七公里出发》播放器
 * 设计系统沿用《两路》蓝图：暖黑底、米白字、暗金点缀，直角，无发光无粒子。
 */

:root{
  --bg:        #14110F;
  --bg-2:      #1C1815;
  --ink:       #EDE6DA;
  --ink-dim:   #9A9086;
  --gold:      #C9A961;
  --line:      #2E2823;

  --font-serif: 'Noto Serif SC', 'Source Han Serif SC', 'Songti SC', 'STSong', 'SimSun', serif;
  --font-sans:  'Noto Sans SC', 'Source Han Sans SC', 'PingFang SC', 'Microsoft YaHei', sans-serif;

  --t-fast: 200ms;
  --t-base: 480ms;
  --ease: cubic-bezier(.22,.61,.36,1);
}

*, *::before, *::after{ box-sizing: border-box; }

html, body{
  margin: 0;
  padding: 0;
  background: var(--bg);
  overflow-x: hidden;
}

body{
  color: var(--ink);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

/* ---------------- 背景照片 ----------------
   原图是横构图（1672×940），竖屏 cover 会裁掉两侧。
   所以先把整张压暗，再用上下渐变压出层次：中间留住照片，两端压黑保证文字能读。 */

.bg{
  position: fixed;
  inset: 0;
  z-index: 0;
  background: url('img/bg.jpg') center 38% / cover no-repeat;
  filter: brightness(.72) saturate(.95);
  pointer-events: none;
  /* 极慢推近，让静态照片有呼吸感。幅度刻意压得很小，
     免得连同上层的渐变压暗一起位移被看出来。 */
  animation: qgl-kenburns 46s ease-in-out infinite alternate;
  will-change: transform;
}
/* 背景呼吸：46 秒一个来回，只推近 6% */
@keyframes qgl-kenburns{
  from{ transform: scale(1.03) translate3d(0, 0, 0); }
  to  { transform: scale(1.09) translate3d(0, -1.1%, 0); }
}
.bg::after{
  content: '';
  position: absolute;
  inset: 0;
  /* 中间那一段是歌词压着照片的地方，遮罩要比两端轻、但得够厚，
     否则字落在人物身上会读不清。 */
  background: linear-gradient(to bottom,
      rgba(20,17,15,.86) 0%,
      rgba(20,17,15,.20) 18%,
      rgba(20,17,15,.40) 46%,
      rgba(20,17,15,.46) 62%,
      rgba(20,17,15,.80) 80%,
      rgba(20,17,15,.94) 100%);
}

/* ---------------- 版面 ---------------- */

.stage{
  position: relative;
  z-index: 1;
  /* 必须是确定高度，不能只用 min-height：
     歌词有 58 行、两千多像素高，min-height 会让 flex 子项拿内容高度当基准，
     把整页撑到视口外，底部按钮就点不到了。 */
  height: 100vh;                /* 老内核不认 svh 时的兜底 */
  height: 100svh;
  min-height: 460px;
  max-width: 520px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top, 0px) + 26px) 18px calc(env(safe-area-inset-bottom, 0px) + 20px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.head{
  flex: 0 0 auto;
  text-align: center;
}
.title{
  margin: 0;
  font-family: var(--font-serif);
  font-size: 28px;
  font-weight: 500;
  line-height: 1.4;
  letter-spacing: .04em;
  text-shadow: 0 1px 12px rgba(20,17,15,.95);
}
.sub{
  margin: 9px 0 0;
  font-size: 14px;
  line-height: 1.7;
  color: var(--ink-dim);
  text-shadow: 0 1px 10px rgba(20,17,15,.95);
}

/* ---------------- 进入动效 ----------------
   打开页面时标题、歌词区、控制条依次浮现，第一眼更有仪式感。
   歌词区只淡入不改 transform —— .lyrics 的位移是 JS 在控制的，不能抢。 */

@keyframes qgl-rise{
  from{ opacity: 0; transform: translateY(12px); }
  to  { opacity: 1; transform: none; }
}
@keyframes qgl-fade{
  from{ opacity: 0; }
  to  { opacity: 1; }
}
.head{ animation: qgl-rise 820ms var(--ease) both; }
.lyrics-view{ animation: qgl-fade 900ms var(--ease) 140ms both; }
.ctrl{ animation: qgl-rise 820ms var(--ease) 260ms both; }

/* ---------------- 歌词 ---------------- */

.lyrics-view{
  flex: 1 1 auto;
  min-height: 0;
  margin: 18px 0;
  overflow: hidden;
  position: relative;
  /* 上下边缘淡出，不要硬切 */
  -webkit-mask-image: linear-gradient(to bottom, transparent 0%, #000 16%, #000 84%, transparent 100%);
          mask-image: linear-gradient(to bottom, transparent 0%, #000 16%, #000 84%, transparent 100%);
}

.lyrics{
  position: relative;
  padding: 42% 0;               /* 让首尾行也能滚到正中 */
  transition: transform 620ms var(--ease);
  will-change: transform;
}

.ly{
  margin: 0;
  padding: 11px 2px;
  font-size: 17px;
  line-height: 1.62;
  letter-spacing: .015em;
  text-align: center;
  color: var(--ink);
  text-shadow:
    0 1px 3px rgba(20,17,15,.95),
    0 2px 14px rgba(20,17,15,.95),
    0 0 32px rgba(20,17,15,.85);
  cursor: pointer;
  /* 具体透明度由 JS 按"离当前行的距离"写 inline style，这里只给个初值 */
  opacity: .5;
  /* 长句放不下就两行均分，别出现末尾孤零零一个字 */
  text-wrap: balance;
  transition: opacity 420ms var(--ease), font-size 420ms var(--ease), color 420ms var(--ease);
}
.ly:hover{ opacity: .95; }

.ly.is-current{
  font-family: var(--font-serif);
  font-size: 22px;
  font-weight: 500;
  line-height: 1.5;
  color: #FFF8EC;
  opacity: 1;
}
/* 段落第一行：多一点上方留白，让段落之间有呼吸 */
.ly.is-section-start{ padding-top: 26px; }

/* ---------------- 底部控制 ---------------- */

.ctrl{
  flex: 0 0 auto;
}

.seek-row{
  display: flex;
  align-items: center;
  gap: 12px;
}
.range-seek{
  flex: 1 1 auto;
  min-width: 0;
  height: 30px;
}
.time{
  flex: 0 0 auto;
  min-width: 42px;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  letter-spacing: .06em;
  color: var(--ink-dim);
}
.time:last-child{ text-align: right; }

.btn-row{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-top: 6px;
}

.play{
  flex: 0 0 auto;
  width: 62px;
  height: 62px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1.5px solid rgba(237,230,218,.5);
  border-radius: 50%;
  background: rgba(20,17,15,.5);
  color: var(--ink);
  cursor: pointer;
  backdrop-filter: blur(3px);
  transition: border-color var(--t-fast) var(--ease), color var(--t-fast) var(--ease),
              background-color var(--t-fast) var(--ease), transform var(--t-fast) var(--ease);
}
.play:hover{
  border-color: var(--gold);
  color: var(--gold);
  background: rgba(20,17,15,.68);
}
.play:active{ transform: scale(.94); }
.play:focus-visible{ outline: 1px solid var(--gold); outline-offset: 3px; }
body.is-playing .play{ border-color: var(--gold); color: var(--gold); }

.ico{ width: 46%; height: 46%; display: block; }
.ico-play path, .ico-pause path{ fill: currentColor; }
.ico-pause{ display: none; }
body.is-playing .ico-play{ display: none; }
body.is-playing .ico-pause{ display: block; }

.vol{
  flex: 0 1 auto;
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.mute{
  flex: 0 0 auto;
  width: 24px; height: 24px;
  padding: 0; border: 0; background: none;
  color: var(--ink-dim);
  cursor: pointer;
  transition: color var(--t-fast) var(--ease);
}
.mute:hover{ color: var(--ink); }
.mute:focus-visible{ outline: 1px solid var(--gold); outline-offset: 3px; }
.mute .ico{ width: 100%; height: 100%; }
.mute .ico path{ fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linejoin: round; }
.mute .ico path:first-child{ fill: currentColor; stroke: none; }
.mute .slash{ opacity: 0; }
body.is-muted .mute .slash{ opacity: 1; }
body.is-muted .mute .wave{ opacity: 0; }

/* ---------------- range：细线 + 竖条手柄，无圆角 ---------------- */

.range{
  --p: 0%;
  margin: 0;
  padding: 0;
  background: transparent;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}
.range:disabled{ cursor: default; }
.range:focus{ outline: none; }

.range::-webkit-slider-runnable-track{
  height: 2px;
  background: linear-gradient(to right, var(--gold) 0 var(--p), rgba(237,230,218,.24) var(--p) 100%);
}
.range::-webkit-slider-thumb{
  -webkit-appearance: none;
  appearance: none;
  width: 2px; height: 16px;
  margin-top: -7px;
  border: 0; border-radius: 0;
  background: var(--gold);
}
.range::-moz-range-track{ height: 2px; background: rgba(237,230,218,.24); }
.range::-moz-range-progress{ height: 2px; background: var(--gold); }
.range::-moz-range-thumb{ width: 2px; height: 16px; border: 0; border-radius: 0; background: var(--gold); }

/* 进度条比音量条粗一档，主次一眼分得清 */
.range-seek::-webkit-slider-runnable-track{ height: 3px; }
.range-seek::-webkit-slider-thumb{ width: 3px; height: 20px; margin-top: -8.5px; }
.range-seek::-moz-range-track{ height: 3px; }
.range-seek::-moz-range-progress{ height: 3px; }
.range-seek::-moz-range-thumb{ width: 3px; height: 20px; }

.range-vol{
  flex: 1 1 auto;
  max-width: 120px;
  height: 24px;
}

/* 触屏设备：音量本来就用物理键，滑条收起来省地方；
   手柄从 2–3px 加宽到 14px，手指才拖得住（桌面端保持细线设计） */
.is-touch .range-vol{ display: none; }
.is-touch .range::-webkit-slider-thumb{ width: 14px; height: 24px; margin-top: -11px; }
.is-touch .range::-moz-range-thumb{ width: 14px; height: 24px; }
.is-touch .range-seek::-webkit-slider-thumb{ width: 14px; height: 28px; margin-top: -12.5px; }
.is-touch .range-seek::-moz-range-thumb{ width: 14px; height: 28px; }

/* ---------------- 提示与状态 ---------------- */

/* iOS 的物理静音开关会静音 <audio>，而且没有任何 API 能读到它的状态。
   只能给触屏用户一句提示，桌面端不显示。
   判据用 JS 检测后加的 .is-touch，不用 @media (pointer:coarse)——
   后者在无头环境里没法验证。 */
.hint{
  display: none;
  margin: 14px 0 0;
  font-size: 13px;
  line-height: 1.6;
  text-align: center;
  color: var(--ink-dim);
  opacity: .78;
}
.is-touch .hint{ display: block; }

.status{
  min-height: 18px;
  margin: 8px 0 0;
  font-size: 13px;
  line-height: 1.6;
  text-align: center;
  color: var(--ink-dim);
}

.calib-open{ display: none; }

/* ---------------- 歌词调校面板 ---------------- */

.tune{
  position: fixed;
  inset: 0;
  z-index: 10;
  overflow-y: auto;
  padding: 18px;
  /* 用实色，不要半透明：半透明时底下的大标题会透出来跟当前行重影 */
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
}
.tune[hidden]{ display: none; }

.tune-box{
  width: 100%;
  max-width: 520px;
  text-align: center;
}

.tune-head{
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}
.tune-count{
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  letter-spacing: .08em;
  color: var(--ink-dim);
}
.tune-sec{
  font-size: 12px;
  letter-spacing: .1em;
  color: var(--gold);
  opacity: .85;
}

.tune-lines{
  margin: 18px 0 14px;
  min-height: 118px;
}
.tune-side{
  margin: 0;
  min-height: 22px;
  font-size: 14px;
  line-height: 1.55;
  color: var(--ink-dim);
  opacity: .55;
}
.tune-cur{
  margin: 8px 0;
  min-height: 34px;
  font-family: var(--font-serif);
  font-size: 21px;
  line-height: 1.5;
  color: #FFF8EC;
  text-wrap: balance;
}

.tune-howto{
  margin: 0 0 14px;
  font-size: 13px;
  line-height: 1.7;
  color: var(--ink-dim);
}
.tune-howto b{ color: var(--gold); font-weight: 500; }

.tune-timebox{
  display: flex;
  justify-content: center;
  align-items: baseline;
  gap: 14px;
  margin-bottom: 14px;
}
.tune-time{
  font-size: 19px;
  font-variant-numeric: tabular-nums;
  letter-spacing: .04em;
  color: var(--gold);
}
.tune-live{
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  color: var(--ink-dim);
}

.tune-row{
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}
.tune-row button{
  min-width: 62px;
  padding: 9px 13px;
  border: 1px solid var(--line);
  border-radius: 0;
  background: none;
  font-family: inherit;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  cursor: pointer;
  transition: border-color var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.tune-row button:hover{ border-color: var(--gold); color: var(--gold); }
.tune-row button:focus-visible{ outline: 1px solid var(--gold); outline-offset: 2px; }
.tune-row button.is-key{ border-color: rgba(201,169,97,.55); color: var(--gold); }

.tune-shift{ margin-top: 4px; }
.tune-label{
  font-size: 12px;
  color: var(--ink-dim);
  letter-spacing: .06em;
}

.tune-loop{
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 12px 0;
  font-size: 13px;
  color: var(--ink-dim);
  cursor: pointer;
}
.tune-loop input{ accent-color: var(--gold); width: 15px; height: 15px; }

.tune-keys{
  margin: 14px 0;
  font-size: 12px;
  line-height: 1.9;
  color: var(--ink-dim);
  opacity: .8;
}
.tune-keys b{ color: var(--ink); font-weight: 500; }

.tune-out{
  display: block;
  width: 100%;
  height: 150px;
  margin: 0 0 12px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 0;
  background: var(--bg-2);
  color: var(--ink);
  font-family: ui-monospace, Consolas, monospace;
  font-size: 11px;
  line-height: 1.55;
  resize: vertical;
  text-align: left;
}
.tune-out[hidden]{ display: none; }

.tune-msg{
  min-height: 18px;
  margin: 4px 0 0;
  font-size: 12px;
  line-height: 1.6;
  color: var(--gold);
  opacity: .9;
}

/* 浏览器里存着旧调校结果时，在页面上明说一句，别让人以为是文件里的时间码 */
.tune-notice{
  position: relative;
  z-index: 2;
  margin: 10px 0 0;
  font-size: 12px;
  line-height: 1.7;
  text-align: center;
  color: var(--gold);
  opacity: .85;
}
.tune-notice[hidden]{ display: none; }
.tune-notice button{
  margin-left: 6px;
  padding: 2px 6px;
  border: 1px solid rgba(201,169,97,.5);
  border-radius: 0;
  background: none;
  font-family: inherit;
  font-size: 12px;
  color: var(--gold);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.tune-notice button:hover{ border-color: var(--gold); }

/* ---------------- 低动效 ---------------- */

@media (prefers-reduced-motion: reduce){
  .lyrics{ transition: none; }
  *{ transition-duration: 1ms !important; animation: none !important; }
}

/* ---------------- 宽屏：歌词区收窄，背景照片露出更多 ---------------- */

@media (min-width: 760px){
  .stage{ max-width: 600px; }
  .title{ font-size: 32px; }
  .ly{ font-size: 19px; }
  .ly.is-current{ font-size: 26px; }
  .play{ width: 60px; height: 60px; }
  .bg{ filter: brightness(.78) saturate(1); }
}
