/*
 * 设计令牌 + 重置 + 公共组件。页面样式只允许引用这里的变量与类，
 * 不再各自定义颜色和间距——否则十个页面会长出十套灰色。
 *
 * 配色取自小程序原有素材：主色与金色是从 tabbar 图标与 SVG 里解出来的实际值，
 * 四个平台色取自各自的品牌图标，保证两端视觉一致。
 */
:root {
  --brand: #667eea;
  --brand-2: #764ba2;
  --brand-soft: #eef0fe;
  --gold: #f4a621;
  /* 涨跌取小程序端的同一对值：绿涨、橙红跌。
     另立 --danger 供报错与危险操作使用——之前这两处借用 --up 当红色，
     一旦涨跌配色调整，报错文字就会跟着变颜色 */
  --up: #2dce89;
  --down: #fb6340;
  --danger: #f5365c;
  /* 名次金银铜，与小程序一致 */
  --rank-1: #f5b301;
  --rank-2: #a8b0bd;
  --rank-3: #cd7f32;

  --text: #1a1a1a;
  --text-2: #5a5a5a;
  --text-3: #999999;
  --bg: #f5f6f8;
  --card: #ffffff;
  --line: #ececf0;

  --tencent: #00a6ff;
  --iqiyi: #04b53c;
  --youku: #1a9eff;
  --mgtv: #fc5f02;

  /* 图表里「对照期」（前一天）那条线的颜色。刻意取低饱和的石板灰：
     主线用的是平台品牌色，四个平台各不相同，对照线只有把彩度压到接近零，
     才能保证跟任何一个平台色都不会看混。这个值是对四个平台色逐一验过的——
     红绿色盲模拟下最小色差 ΔE 14.7，正常视觉 18.5，都在安全区。 */
  --chart-compare: #75798a;

  --r-sm: 8px;
  --r: 12px;
  --r-lg: 16px;
  --shadow: 0 2px 12px rgba(20, 22, 40, .06);
  --wrap: 1200px;
  --tabbar-h: 56px;

  --font: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
          "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.6 var(--font);
  /* 底部标签栏在手机端浮起，正文要留出等高的空位 */
  padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
}

img { max-width: 100%; border: 0; vertical-align: middle; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }

/*
 * 去掉移动端点击时的蓝色方块。它是系统给可点元素的默认反馈，形状是元素的外接矩形，
 * 遇到圆角胶囊和图标就会露出方角，很难看。去掉之后必须自己补一个按下反馈，
 * 否则点下去毫无动静，会被当成没点上——下面统一给所有可点元素一个轻微的按压效果。
 */
a, button, label, input, select, textarea, [role="button"], [tabindex] {
  -webkit-tap-highlight-color: transparent;
}
a:active, button:active, [role="button"]:active { opacity: .62; }
@media (hover: hover) {
  a:active, button:active, [role="button"]:active { opacity: 1; }
}

/*
 * 焦点圈只在键盘操作时出现。:focus 一律去掉是无障碍倒退——用键盘的人会完全看不到
 * 自己停在哪；:focus-visible 由浏览器判断来源，鼠标点击不显示、Tab 切换才显示。
 */
:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
  border-radius: 4px;
}
input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, h4, p, ul, ol { margin: 0; }
ul, ol { padding: 0; list-style: none; }
table { border-collapse: collapse; width: 100%; }

/* 属性选择器特指度只有 0,1,0，不加 !important 压不住页面样式里的 display */
[v-cloak], [hidden] { display: none !important; }

.wrap { width: 100%; max-width: var(--wrap); margin: 0 auto; padding: 0 16px; }

/* ── 顶部栏 ─────────────────────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #fff;
}
.topbar__inner { display: flex; align-items: center; gap: 16px; height: 52px; }
.brand { display: flex; align-items: center; gap: 8px; font-size: 17px; font-weight: 600; }
/* 站点标识保留本色：它是彩色矢量，压成白色剪影就只剩一团看不出是什么的形状。
   紫色顶栏上橙红火焰本就是互补色，不用再借滤镜提对比 */
.brand__mark { flex: none; }
.topnav { display: none; flex: 1; gap: 4px; }
.topnav__item {
  padding: 6px 14px; border-radius: 999px; font-size: 14px;
  color: rgba(255, 255, 255, .82); transition: background .15s, color .15s;
}
.topnav__item:hover { color: #fff; background: rgba(255, 255, 255, .14); }
.topnav__item.is-active { color: #fff; background: rgba(255, 255, 255, .22); font-weight: 500; }
.topbar__search { margin-left: auto; display: flex; padding: 6px; border-radius: 8px; }
.topbar__search img { filter: brightness(0) invert(1); opacity: .9; }

/* ── 底部标签栏（手机端）────────────────────────────── */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: flex; height: var(--tabbar-h);
  padding-bottom: env(safe-area-inset-bottom);
  background: rgba(255, 255, 255, .94);
  backdrop-filter: saturate(180%) blur(12px);
  border-top: 1px solid var(--line);
}
.tabbar__item {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; font-size: 11px; color: var(--text-3);
}
.tabbar__item.is-active { color: var(--brand); }
.tabbar__item img { width: 22px; height: 22px; }

/* ── 页面骨架 ───────────────────────────────────────── */
.page { width: 100%; max-width: var(--wrap); margin: 0 auto; padding: 16px 16px 32px; }

.section { margin-bottom: 20px; }
.section__head {
  display: flex; align-items: center; gap: 4px; margin-bottom: 12px;
}
.section__head img { flex: none; width: 22px; height: 22px; }
.section__title { font-size: 17px; font-weight: 600; }
.section__more { margin-left: auto; font-size: 13px; color: var(--text-3); }

.card {
  background: var(--card); border-radius: var(--r);
  box-shadow: var(--shadow); overflow: hidden;
}
.card--pad { padding: 16px; }

/* ── 分段切换（剧集/综艺、7日/30日）─────────────────── */
.segment {
  display: inline-flex; padding: 3px; gap: 2px;
  background: #eceef3; border-radius: 999px;
}
.segment__item {
  padding: 6px 18px; border-radius: 999px; font-size: 14px;
  color: var(--text-2); transition: background .15s, color .15s;
}
.segment__item.is-active {
  background: var(--card); color: var(--brand);
  font-weight: 500; box-shadow: 0 1px 4px rgba(20, 22, 40, .1);
}

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  /* 不许收缩。排成单行（.chips 被改成 nowrap）时若不锁死，flex 会去压每个胶囊的
     宽度，「08-17」这种本来一行放得下的短标签会被压断成两行，圆角胶囊也就撑成了圆饼 */
  flex: none; white-space: nowrap;
  padding: 5px 14px; border-radius: 999px; font-size: 13px;
  background: var(--card); color: var(--text-2); border: 1px solid var(--line);
}
.chip.is-active { background: var(--brand-soft); color: var(--brand); border-color: transparent; font-weight: 500; }
/* 单选组等分铺满，不留折行后右边那截空当 */
.chips--pick { display: grid; grid-template-columns: repeat(2, 1fr); }
.chips--pick .chip { padding-left: 6px; padding-right: 6px; text-align: center; }
@media (min-width: 480px) {
  .chips--pick { grid-template-columns: repeat(4, 1fr); }
}

/* ── 榜单行 ─────────────────────────────────────────── */
.rank { display: flex; flex-direction: column; }
.rank__item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; border-bottom: 1px solid var(--line);
}
.rank__item:last-child { border-bottom: 0; }
.rank__no {
  flex: none; width: 26px; text-align: center;
  font: 600 15px/1 var(--mono); color: var(--text-3);
}
/* 前三名按名次上色。用显式类而不是 nth-child：搜索结果也复用这套行结构，
   那里的序号只是行号，不该被染成榜单名次的颜色 */
.rank__no--1 { color: var(--rank-1); }
.rank__no--2 { color: var(--rank-2); }
.rank__no--3 { color: var(--rank-3); }
.rank__poster {
  flex: none; width: 46px; height: 62px; border-radius: var(--r-sm);
  object-fit: cover; background: #eceef3;
}
/* 缺图占位：跟随主题，不用固定亮色的占位图 */
.poster--none { display: inline-flex; align-items: center; justify-content: center; background: var(--line); }
.poster--none::after {
  content: ''; width: 0; height: 0; opacity: .45;
  border: 7px solid transparent; border-left: 11px solid var(--text-3); margin-left: 4px;
}
.rank__main { flex: 1; min-width: 0; }
.rank__title {
  font-size: 15px; font-weight: 500;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.rank__sub {
  margin-top: 3px; font-size: 12px; color: var(--text-3);
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
}
/* 平台图标、播出状态、更新进度：一行放不下时按此顺序折行 */
.rank__pf { width: 16px; height: 16px; border-radius: 3px; }
.rank__status { color: var(--text-2); }
.rank__status--airing { color: var(--up); }
.rank__ep { color: var(--text-3); }

/* 分项得分：窄屏一行放不下，桌面端顶上标题与主数值之间的空当 */
.rank__parts { display: none; flex: none; gap: 28px; margin: 0; }
.rank__parts div { min-width: 66px; text-align: right; }
.rank__parts dt { font-size: 11px; color: var(--text-3); }
.rank__parts dd { margin: 3px 0 0; font: 500 15px/1.2 var(--mono); color: var(--text-2); }

.rank__value {
  flex: none; display: flex; flex-direction: column; align-items: flex-end; gap: 3px;
  min-width: 76px;
}
.rank__num { display: flex; align-items: baseline; gap: 5px; font: 700 18px/1.15 var(--mono); }
.rank__lab { font: 400 11px/1 var(--font); color: var(--text-3); }
.rank__delta { font-size: 12px; }
.rank__delta.new { color: var(--brand); font-weight: 600; }
.up { color: var(--up); }
.down { color: var(--down); }
.flat { color: var(--text-3); }

/* ── 平台标记 ───────────────────────────────────────── */
.plat { display: inline-flex; align-items: center; gap: 4px; }
.plat img { width: 14px; height: 14px; border-radius: 3px; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot--tencent { background: var(--tencent); }
.dot--iqiyi   { background: var(--iqiyi); }
.dot--youku   { background: var(--youku); }
.dot--mgtv    { background: var(--mgtv); }

/* ── 徽章 ───────────────────────────────────────────── */
.badge {
  display: inline-block; padding: 1px 7px; border-radius: 4px;
  font-size: 11px; line-height: 18px; background: var(--brand-soft); color: var(--brand);
}
.badge--gray { background: #f0f0f3; color: var(--text-3); }
.badge--live { background: #e6f8ef; color: #1b9c62; }

.grade {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 34px; height: 22px; padding: 0 6px; border-radius: 5px;
  font: 700 13px/1 var(--mono); color: #fff; background: var(--text-3);
}
/* 七档各自的颜色，取值与小程序端 getGradeColor 一致 */
.grade--sp { background: #ffb300; }
.grade--s  { background: #ff8f00; }
.grade--ap { background: #7c4dff; }
.grade--a  { background: #9575cd; }
.grade--bp { background: #5c6bc0; }
.grade--b  { background: #7986cb; }
.grade--c  { background: #9e9e9e; }

/* ── 按钮 ───────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 20px; border-radius: var(--r-sm);
  font-size: 15px; background: var(--card); color: var(--text);
  border: 1px solid var(--line); transition: opacity .15s, background .15s;
}
.btn:active { opacity: .8; }
.btn--primary { background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff; border-color: transparent; }
.btn--block { display: flex; width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ── 表单 ───────────────────────────────────────────── */
.field { margin-bottom: 14px; }
.field__label { display: block; margin-bottom: 6px; font-size: 13px; color: var(--text-2); }
.input {
  width: 100%; padding: 11px 12px; border-radius: var(--r-sm);
  background: var(--card); border: 1px solid var(--line); outline: none;
  transition: border-color .15s;
}
.input:focus { border-color: var(--brand); }
textarea.input { min-height: 110px; resize: vertical; }

.tip { font-size: 13px; line-height: 1.7; color: var(--text-3); }
.tip--error { color: var(--danger); }
.tip--ok { color: var(--up); }

/* ── 状态占位 ───────────────────────────────────────── */
.empty { padding: 48px 16px; text-align: center; color: var(--text-3); }
.empty img { width: 72px; opacity: .55; margin-bottom: 12px; }
.empty__text { font-size: 14px; color: var(--text-2); }
.empty__hint { margin-top: 6px; font-size: 12.5px; }

.skeleton {
  background: linear-gradient(90deg, #eceef3 25%, #f4f5f8 37%, #eceef3 63%);
  background-size: 400% 100%; border-radius: var(--r-sm);
  animation: shimmer 1.3s ease infinite;
}
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: 0 0; } }

/* ── 页脚 ───────────────────────────────────────────── */
/* 只放免责与版权。导航在顶部栏（宽屏）和「我的」里都有，页脚再列一遍既占地方
   又让人分不清哪个才是主入口——小程序干脆没有页脚 */
.sitefoot {
  margin-top: 32px; padding: 20px 0 22px; text-align: center;
  border-top: 1px solid var(--line); background: var(--card);
}
.sitefoot__legal { font-size: 12px; line-height: 1.95; color: var(--text-3); }
.sitefoot__legal a { color: var(--text-3); }
.sitefoot__legal a:hover { color: var(--brand); }
.sitefoot__sep { margin: 0 5px; opacity: .55; }

/* ── 图表容器：高度写死，避免 Canvas 首绘前页面跳动 ── */
.chart { position: relative; width: 100%; height: 220px; }
.chart canvas { width: 100%; height: 100%; display: block; }

/* ── 桌面端 ─────────────────────────────────────────── */
@media (min-width: 768px) {
  body { padding-bottom: 0; }
  .tabbar { display: none; }
  .topnav { display: flex; }
  .page { padding: 24px 16px 48px; }
  .chart { height: 280px; }
  .rank__item { padding: 14px 20px; transition: background .15s; }
  .rank__item:hover { background: #fafbfd; }
  .rank__poster { width: 54px; height: 72px; }
  /* 标题列不设上限，让它把富余宽度吃掉。封顶会让多出来的空间堆在行尾，
     分数列于是停在卡片中间，右边空出一大条 */
  .rank__parts { display: flex; }
  .rank__value { min-width: 96px; }
  .sitefoot { padding: 24px 0 28px; }
}

/* 内容变宽后，榜单行两端的呼吸感也要跟上，否则封面贴边、分数贴右框 */
@media (min-width: 1024px) {
  .wrap, .page { padding-left: 24px; padding-right: 24px; }
  .rank__item { padding: 15px 24px; }
  .rank__parts { gap: 36px; }
}

/* ── 深色模式：跟随系统，与小程序 theme==='dark' 对齐 ── */
@media (prefers-color-scheme: dark) {
  :root {
    --text: #ececf1;
    --text-2: #a9a9b4;
    --text-3: #77777f;
    --bg: #16161a;
    --card: #1f1f25;
    --line: #2c2c34;
    --brand-soft: #262a44;
    --shadow: 0 2px 12px rgba(0, 0, 0, .4);
    /* 深色底上要重新选一档更亮的，不是把浅色那档直接翻过来：
       #75798a 在 #1f1f25 上对比度不足 3:1，线会糊进背景 */
    --chart-compare: #8b90a3;
  }
  .segment { background: #2a2a32; }
  .rank__poster { background: #2a2a32; }
  .tabbar { background: rgba(31, 31, 37, .94); }
  .badge--gray { background: #2c2c34; }
  .badge--live { background: #16302a; color: #4ad991; }
  .skeleton { background-image: linear-gradient(90deg, #24242b 25%, #2c2c34 37%, #24242b 63%); }
}
