/* DerolexTV Status — 无构建、无依赖的静态页面 */

:root {
  --bg: #edeeea;
  --bg-glow: #f7f8f2;
  --surface: #f5f6f1;
  --ink: #1c2023;
  --ink-2: #4b5257;
  --muted: #6d747a;
  --outline: #a5a69d;
  --red: #cf2b2b;
  --green: #14ad49;
  --divider: rgba(20, 24, 27, 0.1);
  --shadow: 0 1px 2px rgba(20, 24, 27, 0.06);
  color-scheme: light;
}

[data-theme="dark"] {
  --bg: #14171a;
  --bg-glow: #1f252a;
  --surface: #1d2226;
  --ink: #eae8e0;
  --ink-2: #b7bcc1;
  --muted: #868d94;
  --outline: #6b7176;
  --red: #ff6f61;
  --green: #35d07a;
  --divider: rgba(255, 255, 255, 0.11);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
  color-scheme: dark;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background-color: var(--bg);
  background-image: radial-gradient(120% 65% at 8% -12%, var(--bg-glow), transparent 72%);
  background-repeat: no-repeat;
  background-attachment: fixed;
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.35s ease, color 0.35s ease;
}

.page {
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
  padding: clamp(22px, 6vw, 48px) clamp(18px, 5vw, 32px) 36px;
}

/* ---------- 标题行 ---------- */

.head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: clamp(24px, 7vw, 40px);
}

.title {
  margin: 0;
  flex: 1 1 auto;
  min-width: 0;
  font-size: clamp(1.35rem, 6.8vw, 2.45rem);
  line-height: 1.15;
  letter-spacing: 0.01em;
  font-weight: 700;
}

.wordmark {
  font-family: "Arial Black", "Arial Bold", Arial, "Segoe UI", sans-serif;
  font-weight: 800;
  letter-spacing: 0.005em;
  white-space: nowrap;
  margin-right: 0.16em;
  color: transparent;
  -webkit-text-stroke: 2px var(--outline);
  transition: -webkit-text-stroke-color 0.35s ease;
}

@supports not ((-webkit-text-stroke: 1px #000) or (text-stroke: 1px #000)) {
  .wordmark { color: var(--outline); }
}

.title-solid { font-weight: 600; white-space: nowrap; }

.theme-toggle {
  flex: none;
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid var(--divider);
  border-radius: 50%;
  background: var(--surface);
  color: #e5a13c;
  box-shadow: var(--shadow);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.25s ease, background-color 0.35s ease,
    border-color 0.35s ease, color 0.35s ease;
}

.theme-toggle:hover { transform: rotate(18deg); }
.theme-toggle:active { transform: scale(0.94); }
.theme-toggle:focus-visible { outline: 2px solid var(--red); outline-offset: 3px; }

.theme-toggle .icon { width: 24px; height: 24px; display: block; }

[data-theme="light"] .icon-moon { display: none; }
[data-theme="dark"] .icon-sun { display: none; }
[data-theme="dark"] .theme-toggle { color: #cdd6dd; }

/* ---------- 状态区 ---------- */

.status {
  display: flex;
  align-items: center;
  gap: clamp(12px, 3.4vw, 20px);
  margin-bottom: clamp(22px, 6vw, 32px);
}

.badge {
  flex: none;
  display: flex;
  align-items: center;
  gap: 1px;
  user-select: none;
}

.badge-dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: #e01b1b;
  box-shadow: 0 0 0 3px rgba(224, 27, 27, 0.12);
}

.badge-num {
  font-family: "Arial Black", "Arial Bold", Arial, "Segoe UI", sans-serif;
  font-size: clamp(2.1rem, 9vw, 2.8rem);
  font-weight: 800;
  line-height: 1;
  color: transparent;
  -webkit-text-stroke: 2.5px var(--outline);
  transition: -webkit-text-stroke-color 0.35s ease;
}

@supports not ((-webkit-text-stroke: 1px #000) or (text-stroke: 1px #000)) {
  .badge-num { color: var(--outline); }
}

.status-line {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: clamp(1.12rem, 4.5vw, 1.35rem);
  font-weight: 600;
  line-height: 1.35;
}

.live-dot {
  flex: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--green) 16%, transparent);
}

.live-dot.is-off,
.live-dot.is-unknown {
  background: var(--muted);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--muted) 14%, transparent);
}

.live-dot.is-live { animation: breathe 2.6s ease-in-out infinite; }

@keyframes breathe {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.62; }
}

.channel {
  margin: 3px 0 0;
  font-size: clamp(0.92rem, 3.6vw, 1rem);
  color: var(--ink-2);
}

/* ---------- 节目信息 ---------- */

.programs {
  margin: 0;
  padding: 0;
}

.row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  margin: 0;
  font-size: clamp(1.12rem, 4.6vw, 1.45rem);
  line-height: 1.55;
}

.row + .row { margin-top: 8px; }

.row dt {
  flex: none;
  font-weight: 500;
  color: var(--ink);
}

.row dd {
  margin: 0;
  min-width: 0;
  overflow-wrap: anywhere;
}

.row.now dd {
  font-weight: 700;
  color: var(--red);
}

.row.next dd {
  font-weight: 500;
  color: var(--ink-2);
}

/* 占位 / 降级文案 */
dd.is-empty {
  font-weight: 500 !important;
  color: var(--muted) !important;
}

/* ---------- 时间与提示 ---------- */

.clock {
  margin: clamp(16px, 4.4vw, 22px) 0 0;
  font-size: clamp(0.98rem, 3.9vw, 1.08rem);
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
}

.notice {
  margin: 8px 0 0;
  font-size: 0.82rem;
  color: var(--muted);
}

.notice[hidden] { display: none; }

/* ---------- 历史播出按钮 ---------- */

.history-trigger {
  margin-top: clamp(16px, 4.4vw, 20px);
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 16px;
  border: 1px solid var(--divider);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink-2);
  font: inherit;
  font-size: clamp(0.84rem, 3.3vw, 0.9rem);
  line-height: 1.2;
  cursor: pointer;
  box-shadow: var(--shadow);
  -webkit-tap-highlight-color: transparent;
  transition: color 0.2s ease, border-color 0.2s ease,
    background-color 0.35s ease, transform 0.15s ease;
}

.history-trigger .icon { width: 17px; height: 17px; }

.history-trigger:hover { color: var(--ink); border-color: var(--muted); }
.history-trigger:active { transform: scale(0.97); }
.history-trigger:focus-visible { outline: 2px solid var(--red); outline-offset: 3px; }

/* ---------- 历史播出弹窗 ---------- */

.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal[hidden] { display: none; }

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(14, 17, 20, 0.48);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
}

.modal-card {
  position: relative;
  display: flex;
  flex-direction: column;
  width: min(560px, 100%);
  max-height: min(78dvh, 640px);
  background: var(--surface);
  border: 1px solid var(--divider);
  border-radius: 16px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.32);
  overflow: hidden;
  animation: modal-in 0.22s ease-out;
}

@keyframes modal-in {
  from { opacity: 0; transform: translateY(10px) scale(0.985); }
  to { opacity: 1; transform: none; }
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 15px 12px 15px 20px;
  border-bottom: 1px solid var(--divider);
}

.modal-title {
  margin: 0;
  font-size: 1.02rem;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.modal-close {
  flex: none;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.modal-close .icon { width: 19px; height: 19px; }
.modal-close:hover { background: var(--divider); color: var(--ink); }
.modal-close:focus-visible { outline: 2px solid var(--red); outline-offset: 2px; }

.modal-body {
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 4px 0 6px;
}

.hist-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.hist-row {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: 11px 20px;
}

.hist-row + .hist-row { border-top: 1px solid var(--divider); }

.hist-time {
  flex: none;
  width: 84px;
  font-size: 0.78rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.hist-title {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 0.95rem;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hist-title.is-empty { color: var(--muted); }

.hist-tag {
  flex: none;
  padding: 2px 8px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--muted) 15%, transparent);
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.6;
}

.hist-state {
  margin: 0;
  padding: 34px 20px;
  text-align: center;
  font-size: 0.9rem;
  color: var(--muted);
}

.hist-state .link-btn {
  display: block;
  margin: 12px auto 0;
  padding: 6px 14px;
  border: 1px solid var(--divider);
  border-radius: 999px;
  background: transparent;
  color: var(--ink-2);
  font: inherit;
  font-size: 0.84rem;
  cursor: pointer;
}

.hist-state .link-btn:hover { color: var(--ink); border-color: var(--muted); }

body.modal-open { overflow: hidden; }

/* ---------- 页脚 ---------- */

.foot {
  margin-top: clamp(20px, 5.5vw, 30px);
  font-size: clamp(0.76rem, 3vw, 0.82rem);
  line-height: 1.85;
  color: var(--muted);
}

.foot p { margin: 0; }

/* ---------- 窄屏微调 ---------- */

@media (max-width: 380px) {
  .page { padding-left: 16px; padding-right: 16px; }
  .badge-dot { width: 9px; height: 9px; }
  .status-line { gap: 7px; }
  .live-dot { width: 17px; height: 17px; }
  .theme-toggle { width: 42px; height: 42px; }
}

/* ---------- 无障碍：减少动效 ---------- */

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
