/* ==========================================================================
   移动端 / 微信内置浏览器适配层
   在 style.css 之后加载，只做「手机上的修正」，不改桌面观感
   ========================================================================== */

/* ---------- 1. 全局手感：微信 WebView 的几个老毛病 ---------- */

html {
  /* 微信 X5 内核会自作主张放大字号，必须关掉 */
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  /* 防止横向被撑出滚动条 */
  overflow-x: hidden;
}

body {
  /* 点链接时那层灰色高亮，微信里特别明显 */
  -webkit-tap-highlight-color: transparent;
  /* 干掉双击缩放带来的 300ms 延迟 */
  touch-action: manipulation;
  /* 微信下拉会露出「网页由 xxx 提供」，顶到边看着更整 */
  overscroll-behavior-y: none;
  /* 兜底：任何子元素意外撑宽都不让它变成整页横向滚动 */
  max-width: 100%;
  overflow-x: hidden;
}

/* 长文案（接口提示、错误信息、URL）强制断行，别把容器顶宽 */
.hero-sub,
.hero-hint,
.player-status,
.empty,
.songlist .artist,
.card-title,
.footer,
footer {
  overflow-wrap: anywhere;
  word-break: break-word;
}

/* 输入框在 iOS 上小于 16px 会触发自动放大 */
input,
textarea,
select {
  font-size: 16px;
}

/* 手机上没有 hover，别让 :hover 样式卡住 */
@media (hover: none) {
  .btn:hover,
  .tab:hover,
  a:hover {
    text-decoration: none;
  }
}

/* ---------- 2. 热门搜索：桌面短标签 / 手机横滑一行 ---------- */

.hot-row {
  justify-content: center;
  margin-top: 20px;
}

.hot-row .hot-label {
  font-size: 13px;
  color: var(--muted);
  align-self: center;
  flex: 0 0 auto;
}

.hot-list {
  display: inline-flex;
  gap: 8px;
  flex-wrap: wrap;
}

@media (max-width: 768px) {
  /* 手机上别换行——14 个词换行要占掉一屏。
     改成单行横向滑动，右边露出一截提示还能滑。 */
  .hot-row {
    margin-top: 14px;
    flex-wrap: nowrap;
    justify-content: flex-start;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    /* 右侧留白，让最后一个词不贴边 */
    padding: 2px 16px 6px 0;
    /* 手指划动时不要顺带触发页面滚动 */
    touch-action: pan-x;
  }
  .hot-row::-webkit-scrollbar {
    display: none;
  }
  .hot-row .hot-label {
    position: sticky;
    left: 0;
    z-index: 2;
    padding-right: 10px;
    background: linear-gradient(90deg, var(--bg) 72%, transparent);
  }
  .hot-list {
    flex-wrap: nowrap;
    flex: 0 0 auto;
  }
  .hot-list .hot-word {
    flex: 0 0 auto !important;
    height: 34px !important;
    padding: 0 15px !important;
    font-size: 13.5px !important;
    border-radius: 17px;
    white-space: nowrap;
    /* 词很多时不吃字 */
    overflow: visible;
  }
}

/* ---------- 3. 顶部导航 / 标签：单行横滑 ---------- */

@media (max-width: 768px) {
  .nav {
    padding: 10px 14px 0;
    /* 刘海屏 */
    padding-top: calc(10px + env(safe-area-inset-top));
  }
  .nav-links {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-x;
    /* 关键：必须能收缩。之前用负 margin 外扩到屏幕边，flex 子项因此把
       文档撑宽（body 宽度 > 视口），整页就出现横向滚动，hero 文案看着像被截断。 */
    min-width: 0;
    max-width: 100%;
  }
  .nav-links::-webkit-scrollbar {
    display: none;
  }
  .tab {
    flex: 0 0 auto;
    white-space: nowrap;
  }
}

/* ---------- 4. 搜索区：拇指够得到，按钮给足高度 ---------- */

@media (max-width: 768px) {
  .hero {
    padding: 26px 16px 24px;
  }
  .hero h1 {
    font-size: 25px;
  }
  .hero-sub {
    font-size: 14px;
  }
  .hero-search input {
    height: 48px;
  }
  .hero-search .btn {
    height: 48px;
  }
}

/* ---------- 5. 触控目标：可点的东西不能太小 ---------- */

/* 手机宽度下就该加大，不依赖 pointer:coarse——
   有些安卓机的 UA/指针判定不准，只靠媒体特性会漏掉 */
@media (max-width: 768px) {
  .tab {
    min-height: 40px;
    display: inline-flex;
    align-items: center;
  }
  .nav-link,
  .nav-brand {
    min-height: 40px;
    display: inline-flex;
    align-items: center;
  }
  .section-more,
  .card-title .more {
    min-height: 34px;
    min-width: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
  .btn.sm {
    min-height: 38px;
  }
  /* 滑块在手机上太细捏不住 */
  input[type='range'] {
    height: 32px;
  }
  input[type='range']::-webkit-slider-thumb {
    width: 22px;
    height: 22px;
  }
  /* 剧集按钮加大，手指点得准 */
  .ep-grid button,
  .eps button {
    min-height: 44px;
  }
  /* 歌曲行也要够高 */
  .songlist .song {
    min-height: 54px;
  }
}

/* ---------- 6. 播放器：手机上占满宽度，控制条够大 ---------- */

@media (max-width: 768px) {
  .player-wrap,
  .player-frame {
    border-radius: 12px;
  }
  video {
    /* 竖屏时别让视频把整屏顶走 */
    max-height: 46vh;
    background: #000;
  }
  .controls {
    flex-wrap: wrap;
    row-gap: 8px;
  }
  .controls .btn {
    min-height: 42px;
  }
  /* 进度条单独一行，够宽才好拖 */
  #seek {
    flex: 1 1 100%;
    order: -1;
  }
}

/* ---------- 7. 底部固定条（音乐播放）避开 iPhone 底部横条 ---------- */

@media (max-width: 768px) {
  .now-bar,
  .mini-player {
    padding-bottom: env(safe-area-inset-bottom);
  }
  body {
    /* 内容别被底部条盖住 */
    padding-bottom: env(safe-area-inset-bottom);
  }
}

/* ---------- 8. 微信环境专属提示 ---------- */

/* 微信里下载会被拦，mobile.js 会给 .wx-* 打标 */
.wx-block-hint {
  display: none;
}

html.is-wechat .wx-block-hint {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(178, 80, 0, 0.08);
  border: 1px solid rgba(178, 80, 0, 0.25);
  color: var(--orange);
  font-size: 13px;
  line-height: 1.6;
}

.wx-block-hint .ico {
  flex: 0 0 auto;
  font-size: 15px;
}

/* 微信里点下载按钮时给的引导层 */
.wx-guide {
  position: fixed;
  inset: 0;
  z-index: 999;
  background: rgba(0, 0, 0, 0.78);
  display: none;
  align-items: flex-start;
  justify-content: flex-end;
  padding: 16px 22px;
  backdrop-filter: blur(2px);
}

.wx-guide.open {
  display: flex;
}

.wx-guide .box {
  max-width: 320px;
  color: #fff;
  font-size: 15px;
  line-height: 1.9;
  text-align: right;
}

.wx-guide .box .arrow {
  font-size: 30px;
  line-height: 1;
  margin-bottom: 6px;
}

.wx-guide .box .close {
  margin-top: 18px;
  display: inline-block;
  padding: 9px 22px;
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.4);
  color: #fff;
  background: transparent;
  font-size: 14px;
}

/* ---------- 9. 竖屏 / 横屏 ---------- */

@media (max-width: 900px) and (orientation: landscape) {
  video {
    max-height: 76vh;
  }
  .hero {
    padding: 18px 20px;
  }
}

/* ---------- 10. 小屏再收一档 ---------- */

@media (max-width: 380px) {
  .hero h1 {
    font-size: 22px;
  }
  .tab {
    font-size: 13px;
    padding: 6px 10px;
  }
  .grid {
    grid-template-columns: repeat(auto-fill, minmax(94px, 1fr));
    gap: 14px 10px;
  }
}
