/* ============================================================
   84452cup 设计语言层 —— 签名元素
   「赛场转播 MATCHDAY」的三件套：
   ① 球衣斜切角（cut corner）——主操作与徽标的剪裁轮廓
   ② 转播条（broadcast bar）——模块标题上的信号条
   ③ 泛光（floodlight）——卡片与按钮的灯下悬停感
   本文件只叠加签名层，不改动 theme.css 的基础 token。
   ============================================================ */

/* —— ① 球衣斜切角：主按钮的右下斜切 —— */
button.primary,
a.button-link.primary {
  clip-path: polygon(0 0, 100% 0, 100% calc(100% - var(--cut-angle)), calc(100% - var(--cut-angle)) 100%, 0 100%);
}

/* 大号 hero 主按钮：更大的斜切 */
button.primary.is-hero,
a.button-link.primary.is-hero {
  --cut-angle: 14px;
  min-height: 54px;
  padding: 0 26px;
  font-size: 16px;
}

/* 面板与卡片的左上斜切：只给显式声明 cut 的面板 */
.panel[data-cut],
.card[data-cut] {
  clip-path: polygon(var(--cut-angle) 0, 100% 0, 100% 100%, 0 100%, 0 var(--cut-angle));
}

/* 徽标类小元素（直播标签、比分牌）的对角斜切 */
.pill.broadcast-tag {
  border-radius: 0;
  clip-path: polygon(6px 0, 100% 0, 100% calc(100% - 6px), calc(100% - 6px) 100%, 0 100%, 0 6px);
  padding: 4px 12px;
  letter-spacing: .1em;
  text-transform: uppercase;
  font-size: 12px;
  font-weight: 900;
}

/* —— ② 转播条：模块标题左侧的信号条 —— */
.section-heading::before,
.panel-header::before {
  content: "";
  flex: 0 0 auto;
  width: 4px;
  align-self: stretch;
  margin-right: 14px;
  background: linear-gradient(180deg, var(--lime), var(--lime-deep));
  box-shadow: 0 0 10px var(--lime-wash);
}

/* 无文字的纯装饰条：面板顶部信号灯 */
.panel::after,
.card::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, var(--lime-line), transparent 38%, transparent 62%, var(--line-strong));
  opacity: .55;
  pointer-events: none;
}

/* eyebrow 前的信号点 */
.eyebrow::before {
  content: "";
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 9px;
  margin-bottom: 1px;
  background: var(--lime);
  clip-path: polygon(0 0, 100% 0, 100% 70%, 70% 100%, 0 100%);
}

/* —— ③ 泛光：卡片悬停的灯光下移感 —— */
.panel,
.card,
.metric {
  transition: transform .2s var(--ease-out), box-shadow .2s ease, border-color .2s ease;
}
.panel:hover,
.card:hover {
  border-color: var(--line-strong);
  box-shadow: var(--shadow), 0 0 0 1px var(--lime-wash);
}
.metric:hover { border-color: var(--lime-line); }

/* 主按钮泛光呼吸（仅暗色夜场，亮色关闭避免刺眼） */
html:not([data-theme="light"]) button.primary:not(:disabled) {
  animation: softGlow 3.6s ease-in-out infinite;
}
html[data-theme="light"] button.primary:not(:disabled) {
  animation: none;
  box-shadow: 0 5px 16px rgba(90, 156, 16, .26), inset 0 1px 0 rgba(255, 255, 255, .35);
}

/* 行内聚焦泛光：表格行与列表项 */
tbody tr:hover {
  box-shadow: inset 3px 0 0 var(--lime);
}

/* —— 数字：转播计分牌字体节奏 —— */
.metric strong,
.score-digits,
.numeric {
  font-variant-numeric: tabular-nums;
  letter-spacing: -.01em;
}
.metric strong { text-shadow: 0 2px 14px rgba(0, 0, 0, .22); }
html[data-theme="light"] .metric strong { text-shadow: none; }

/* —— 滚动条：转播台导轨 —— */
* { scrollbar-width: thin; }
.table-scroll::-webkit-scrollbar { height: 9px; }
.table-scroll::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: var(--line-strong);
}
.table-scroll::-webkit-scrollbar-thumb:hover { background: var(--lime-line); }

/* —— 主题切换按钮 —— */
/* —— 明暗切换：iOS 分段胶囊开关（滑块 + 太阳/月亮双图标） ——
   几何全部使用偶数像素，保证 Windows 125%/150% 缩放下不糊不偏：
   轨道 62×30（内 60×28），滑块 24，行程 32；
   滑块中心 15/47 = 图标中心 15/47（图标 16px，sun left 7 / moon right 7）。 */
.theme-toggle {
  --tt-knob-travel: 32px;
  position: relative;
  width: 62px;
  height: 30px;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--surface-input);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, .07);
  cursor: pointer;
  transition: border-color .2s ease, background-color .2s ease, box-shadow .2s ease;
}
.theme-toggle:hover {
  border-color: var(--lime-line);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, .07), 0 0 0 3px var(--lime-wash);
}
.theme-toggle:focus-visible {
  outline: 2px solid var(--lime);
  outline-offset: 3px;
}

.theme-toggle .tt-track { position: absolute; inset: 0; }
.theme-toggle .tt-knob {
  position: absolute;
  top: 2px;
  left: 3px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--panel);
  box-shadow: 0 1px 3px rgba(0, 0, 0, .24), 0 3px 10px rgba(0, 0, 0, .1);
  transform: translateX(0) scale(1);
  will-change: transform;
  transition: transform .3s cubic-bezier(.3, 1.4, .4, 1), background-color .2s ease;
}
/* 拨杆语义：滑块停在「当前模式」一侧 —— 浅色 = 太阳侧（左），暗色 = 月亮侧（右），
   当前模式的图标显示在滑块上并高亮。 */
.theme-toggle[data-theme-active="light"] .tt-knob {
  transform: translateX(0) scale(1);
  background: #ffffff;
}
.theme-toggle[data-theme-active="dark"] .tt-knob {
  transform: translateX(var(--tt-knob-travel)) scale(1);
  background: var(--panel-3);
}
/* 按压：滑块轻微压扁（保留位移，不跳位） */
.theme-toggle[data-theme-active="dark"]:active .tt-knob { transform: translateX(var(--tt-knob-travel)) scaleX(.9); }
.theme-toggle[data-theme-active="light"]:active .tt-knob { transform: translateX(0) scaleX(.9); }

.theme-toggle .tt-glyph {
  position: absolute;
  z-index: 2;
  top: 50%;
  width: 16px;
  height: 16px;
  transform: translateY(-50%) scale(.86) rotate(-8deg);
  color: var(--text-3);
  opacity: .5;
  transition: color .22s ease, opacity .22s ease, transform .32s var(--ease-spring);
}
.theme-toggle .tt-sun { left: 7px; }
.theme-toggle .tt-moon { right: 7px; }
.theme-toggle[data-theme-active="light"] .tt-sun {
  color: var(--lime-strong);
  opacity: 1;
  transform: translateY(-50%) scale(1) rotate(0deg);
}
.theme-toggle[data-theme-active="light"] .tt-moon {
  transform: translateY(-50%) scale(.86) rotate(-16deg);
}
.theme-toggle[data-theme-active="dark"] .tt-moon {
  color: var(--lime);
  opacity: 1;
  transform: translateY(-50%) scale(1) rotate(0deg);
}
.theme-toggle[data-theme-active="dark"] .tt-sun {
  transform: translateY(-50%) scale(.86) rotate(16deg);
}

@media (prefers-reduced-motion: reduce) {
  .theme-toggle .tt-knob,
  .theme-toggle .tt-glyph { transition: none; }
}

/* —— 主题过渡：整页换场的灯暗/灯亮 —— */
html.theme-transition,
html.theme-transition body,
html.theme-transition .site-header,
html.theme-transition .panel,
html.theme-transition .card {
  transition: background-color .35s ease, background .35s ease, color .35s ease, border-color .35s ease, box-shadow .35s ease !important;
}
html.theme-transition * {
  transition-delay: 0s !important;
}

/* —— 亮色日场的签名层收敛 —— */
html[data-theme="light"] .panel::after,
html[data-theme="light"] .card::after {
  background: linear-gradient(90deg, var(--lime-line), transparent 34%, transparent 66%, var(--line-strong));
  opacity: .4;
}
html[data-theme="light"] .section-heading::before,
html[data-theme="light"] .panel-header::before {
  box-shadow: none;
}

/* —— 动效偏好：尊重系统减少动态 —— */
@media (prefers-reduced-motion: reduce) {
  html:not([data-theme="light"]) button.primary:not(:disabled) { animation: none; }
  .panel, .card, .metric { transition: none; }
  html.theme-transition,
  html.theme-transition body,
  html.theme-transition * {
    transition: none !important;
  }
}

/* —— 大屏（4K 转播墙）：签名元素同步放大 —— */
@media (min-width: 3000px) {
  :root { --cut-angle: 12px; }
  button.primary.is-hero,
  a.button-link.primary.is-hero {
    --cut-angle: 18px;
    min-height: 64px;
    font-size: 20px;
  }
}

/* ============================================================
   控件与动效层 —— 「转播节奏」
   ④ 按压（press）：按钮按下的物理反馈
   ⑤ 聚焦（focus ring）：键盘导航的信号灯环
   ⑥ 入场（entry）：卡片的开播淡入
   ============================================================ */

/* —— ④ 按压：所有按钮统一下沉 1px + 微缩 —— */
button.primary:active,
a.button-link.primary:active {
  transform: translateY(1px) scale(.985);
  filter: brightness(.96);
}
button.secondary:active,
button.ghost:active,
button.danger:active,
a.button-link.secondary:active {
  transform: translateY(1px);
}
/* 斜切角在按压时同步收小，形成「咬合」感 */
button.primary:active,
a.button-link.primary:active {
  --cut-angle: 6px;
}

/* —— ⑤ 聚焦信号灯环：键盘 Tab 的可见反馈 —— */
button:focus-visible,
a.button-link:focus-visible,
.theme-toggle:focus-visible {
  outline: 2px solid var(--lime);
  outline-offset: 3px;
  box-shadow: 0 0 0 6px var(--lime-wash);
}
/* 日场聚焦环加深一档（亮绿在白底上偏浅） */
html[data-theme="light"] button:focus-visible,
html[data-theme="light"] a.button-link:focus-visible {
  outline-color: var(--lime-deep);
  box-shadow: 0 0 0 6px var(--lime-wash);
}
/* 输入控件聚焦：左侧信号条 + 荧光环 */
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: none;
  border-color: var(--lime-line);
  box-shadow: 0 0 0 3px var(--lime-wash), inset 2px 0 0 var(--lime);
}
html[data-theme="light"] input:focus-visible,
html[data-theme="light"] select:focus-visible,
html[data-theme="light"] textarea:focus-visible {
  box-shadow: 0 0 0 3px var(--lime-wash), inset 2px 0 0 var(--lime-deep);
}

/* —— ⑥ 入场：面板与卡片的开播淡入（0.45s，一次性） —— */
.panel,
.card,
.metric {
  animation: riseIn .45s var(--ease-out) both;
}
/* 指标条错峰入场：转播台逐格点亮的节奏 */
.metric:nth-child(2) { animation-delay: .05s; }
.metric:nth-child(3) { animation-delay: .1s; }
.metric:nth-child(4) { animation-delay: .15s; }

/* 数字跳动：比分/余额更新时由 JS 加 .score-pop 触发 */
.score-digits.score-pop,
strong.score-pop {
  animation: scorePop .34s var(--ease-spring);
}

/* 弹窗与对话框：转播切入的滑入 */
dialog[open] {
  animation: riseIn .32s var(--ease-out);
}
dialog::backdrop {
  animation: fadeInBackdrop .3s ease;
}
@keyframes fadeInBackdrop {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* 下拉菜单与抽屉：从边缘展开 */
.database-nav-menu {
  animation: riseIn .22s var(--ease-out);
  transform-origin: top;
}
.mobile-nav-drawer.is-open {
  animation: drawerIn .24s var(--ease-out);
}
@keyframes drawerIn {
  from { transform: translateX(60%); opacity: .4; }
  to { transform: translateX(0); opacity: 1; }
}

/* 徽标 hover：斜切角小元素的一致反馈 */
.pill {
  transition: border-color .16s ease, color .16s ease, background-color .16s ease, transform .16s var(--ease-out);
}
a.pill:hover,
button.pill:hover {
  transform: translateY(-1px);
  border-color: var(--lime-line);
}

/* 表格行按压反馈 */
tbody tr:active {
  background: var(--surface-hover);
}

/* 链接下划线的信号灯扫过 */
a:not(.button-link):not(.home-route):not(.main-nav a) {
  background-image: linear-gradient(var(--lime-line), var(--lime-line));
  background-size: 0% 1px;
  background-position: 0 100%;
  background-repeat: no-repeat;
  transition: background-size .2s var(--ease-out);
}
a:not(.button-link):not(.home-route):not(.main-nav a):hover {
  background-size: 100% 1px;
}

/* 减少动态时禁用入场与扫线（theme.css 已有全局兜底，这里显式收口） */
@media (prefers-reduced-motion: reduce) {
  .panel,
  .card,
  .metric,
  dialog[open],
  .database-nav-menu,
  .mobile-nav-drawer.is-open {
    animation: none;
  }
  a:not(.button-link):not(.home-route):not(.main-nav a) {
    background-image: none;
    transition: none;
  }
}
