/*
 * Tesla Media Player - Material 3 style theme.
 * Colors are the Sports Live Android TV app palette (kqb-tv-clean app/.../ui/KqbTheme.kt),
 * mapped onto Material 3 roles.  Shared by index.html and live.html.
 */
:root {
  /* KqbColors */
  --md-primary: #6554C0;             /* Primary */
  --md-on-primary: #FFFFFF;
  --md-focus: #6957D4;               /* Focus */
  --md-primary-container: #E3DDF8;   /* focused action background */
  --md-on-primary-container: #22243C;
  --md-background: #F1F0FA;          /* Background */
  --md-surface: #FAFAFF;             /* Surface */
  --md-surface-bright: #FFFFFF;
  --md-surface-container: #E7E3F7;   /* SurfaceRaised */
  --md-surface-container-low: #F4F0FF;
  --md-on-surface: #22243C;          /* TextPrimary */
  --md-on-surface-variant: #64667B;  /* TextSecondary */
  --md-outline: #DCD9EC;             /* Divider */
  --md-error: #AF384D;               /* Danger */
  --md-error-container: #F8DDE2;
  --md-success: #1E7F50;
  --md-success-container: #D5F5E4;
  --md-warning: #8A5A00;
  --md-warning-container: #FCEBC9;
  --md-info-container: #E3DDF8;
  --live: #42D887;                   /* Live */
  --live-badge: #555F8B;             /* LiveBadge */
  /* player (dark) surfaces */
  --player-surface: #28243D;
  --player-text: #F8F7FF;
  --player-text-2: #D5D0E8;
  --player-outline: #69617F;
  --player-accent: #D0C3FF;
  /* geometric card art */
  --art-base: #F0EDFB;
  --art-blue: #CFDDF4;
  --art-purple: #DDD2F0;
  --art-periwinkle: #BFC7EF;

  --md-radius-s: 8px;
  --md-radius-m: 12px;
  --md-radius-l: 16px;
  --md-radius-xl: 28px;
  --md-elev-1: 0 1px 2px rgba(34, 36, 60, .08), 0 1px 3px 1px rgba(34, 36, 60, .06);
  --md-elev-2: 0 1px 2px rgba(34, 36, 60, .10), 0 2px 6px 2px rgba(34, 36, 60, .08);
  --md-elev-3: 0 4px 8px 3px rgba(34, 36, 60, .10), 0 1px 3px rgba(34, 36, 60, .12);
  --md-font: Roboto, "Noto Sans SC", "PingFang SC", "Microsoft YaHei", -apple-system, BlinkMacSystemFont,
             "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  --md-ease: cubic-bezier(.2, 0, 0, 1);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--md-font);
  background: var(--md-background);
  color: var(--md-on-surface);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
a { color: var(--md-primary); }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--md-focus); outline-offset: 2px; }

/* ---------- typography ---------- */
.md-display { font-size: 30px; line-height: 36px; font-weight: 700; color: var(--md-primary); letter-spacing: .5px; margin: 0; }
.md-title-l { font-size: 22px; line-height: 28px; font-weight: 600; margin: 0; }
.md-title-m { font-size: 16px; line-height: 24px; font-weight: 600; margin: 0; }
.md-body { font-size: 15px; line-height: 22px; }
.md-label { font-size: 13px; line-height: 18px; font-weight: 500; letter-spacing: .1px; }
.md-muted { color: var(--md-on-surface-variant); }

/* ---------- icons (inline SVG, 24px Material Symbols paths) ---------- */
.md-icon { width: 24px; height: 24px; flex: 0 0 auto; fill: currentColor; display: inline-block; vertical-align: middle; }
.md-icon.sm { width: 20px; height: 20px; }

/* ---------- top app bar ---------- */
.md-appbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 8px;
  padding: 12px 24px; min-height: 64px;
  background: color-mix(in srgb, var(--md-background) 88%, transparent);
  -webkit-backdrop-filter: saturate(1.4) blur(12px); backdrop-filter: saturate(1.4) blur(12px);
}
@supports not (background: color-mix(in srgb, red, blue)) { .md-appbar { background: var(--md-background); } }
.md-appbar.scrolled { box-shadow: var(--md-elev-1); }
.md-appbar .md-appbar-title { flex: 1 1 auto; min-width: 0; display: flex; align-items: baseline; gap: 12px; }
.md-appbar .md-appbar-title .md-display { white-space: nowrap; }

/* ---------- buttons ---------- */
.md-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 10px 24px; border-radius: 999px; border: 0;
  font-size: 15px; font-weight: 600; letter-spacing: .1px; text-decoration: none; white-space: nowrap;
  transition: background-color .2s var(--md-ease), box-shadow .2s var(--md-ease), transform .1s;
  -webkit-user-select: none; user-select: none;
}
.md-btn:active { transform: scale(.98); }
.md-btn.filled { background: var(--md-primary); color: var(--md-on-primary); box-shadow: var(--md-elev-1); }
.md-btn.filled:hover { box-shadow: var(--md-elev-2); background: #5A49B3; }
.md-btn.tonal { background: var(--md-primary-container); color: var(--md-on-primary-container); }
.md-btn.tonal:hover { background: #D8D0F4; }
.md-btn.outlined { background: transparent; color: var(--md-primary); border: 1px solid var(--md-outline); }
.md-btn.outlined:hover { background: rgba(101, 84, 192, .08); }
.md-btn.text { background: transparent; color: var(--md-primary); padding: 10px 14px; }
.md-btn.text:hover { background: rgba(101, 84, 192, .08); }
.md-btn.block { width: 100%; }
.md-btn[disabled] { opacity: .38; pointer-events: none; }

.md-icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 44px; height: 44px; border-radius: 50%; border: 0; background: transparent; color: var(--md-on-surface-variant);
  text-decoration: none; transition: background-color .2s var(--md-ease);
}
.md-icon-btn:hover { background: rgba(101, 84, 192, .08); color: var(--md-primary); }

/* ---------- chips / pill tabs (Android TvAction) ---------- */
.md-chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding: 4px 24px; }
.md-chips::-webkit-scrollbar { display: none; }
.md-chip {
  flex: 0 0 auto; min-width: 90px; min-height: 44px; padding: 9px 24px; border-radius: 999px;
  border: 1px solid var(--md-outline); background: transparent; color: var(--md-on-surface);
  font-size: 16px; font-weight: 500; white-space: nowrap;
  transition: background-color .2s var(--md-ease), border-color .2s, color .2s;
}
.md-chip:hover { background: var(--md-primary-container); border-color: var(--md-focus); }
.md-chip.selected { background: var(--md-primary); border-color: transparent; color: var(--md-on-primary); }

/* ---------- cards ---------- */
.md-card {
  background: var(--md-surface); border-radius: var(--md-radius-l);
  border: 1px solid var(--md-surface-bright); box-shadow: var(--md-elev-1);
}
.md-card-header { display: flex; align-items: center; gap: 12px; padding: 18px 20px 6px; }
.md-card-body { padding: 8px 20px 20px; }

/* ---------- live status pill (Android StatusPill) ---------- */
.md-pill {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 999px;
  background: rgba(250, 250, 255, .9); color: var(--md-primary); font-size: 12px; font-weight: 600; line-height: 16px;
  white-space: nowrap;
}
.md-pill.live { background: var(--live-badge); color: #fff; }
.md-pill.live::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--live); }

/* ---------- text field (outlined) ---------- */
.md-field { position: relative; display: block; }
.md-field input {
  width: 100%; min-height: 52px; padding: 14px 16px; border-radius: var(--md-radius-m);
  border: 1px solid var(--md-outline); background: var(--md-surface-bright); color: var(--md-on-surface);
  font-size: 16px; transition: border-color .2s, box-shadow .2s;
}
.md-field input::placeholder { color: #9A9BAE; }
.md-field input:focus { outline: none; border-color: var(--md-primary); box-shadow: 0 0 0 1px var(--md-primary); }
.md-field-label { display: block; margin: 0 0 8px 4px; color: var(--md-on-surface-variant); font-size: 13px; font-weight: 500; }

/* ---------- banners / snackbars ---------- */
.md-banner {
  display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-radius: var(--md-radius-m);
  font-size: 15px; font-weight: 500; background: var(--md-info-container); color: var(--md-on-primary-container);
}
.md-banner.success { background: var(--md-success-container); color: var(--md-success); }
.md-banner.error { background: var(--md-error-container); color: var(--md-error); }
.md-banner.warning { background: var(--md-warning-container); color: var(--md-warning); }

/* ---------- linear progress ---------- */
.md-progress { height: 4px; border-radius: 2px; background: var(--md-surface-container); overflow: hidden; }
.md-progress > * { height: 100%; width: 0; background: var(--md-primary); border-radius: 2px; transition: width .3s var(--md-ease); }

/* ---------- spinner ---------- */
.md-spinner {
  width: 36px; height: 36px; border-radius: 50%;
  border: 4px solid var(--md-surface-container); border-top-color: var(--md-primary);
  animation: md-spin 1s linear infinite;
}
@keyframes md-spin { to { transform: rotate(360deg); } }

/* ---------- geometric art (Android MatchGeometry) ---------- */
.md-art { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

/* ---------- player shell (Android LiveScreen look; live viewer + YouTube/Bilibili player) ---------- */
.vbar { flex: 0 0 auto; display: flex; align-items: center; gap: 16px; padding: 14px 24px;
  background: linear-gradient(#000, #0b0a12); color: var(--player-text); }
.vbar .back { min-width: 0; padding: 10px 28px; background: var(--md-surface-container); color: var(--md-on-surface); }
.vbar .back:hover { background: #fff; }
.vbar .vtitle { flex: 1; min-width: 0; }
.vbar .vtitle b { display: block; font-size: 22px; line-height: 28px; font-weight: 700;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vbar .vtitle span { color: var(--player-text-2); font-size: 14px; }
.vbar .md-icon-btn { color: var(--player-text-2); }
.vbar .md-icon-btn:hover { background: rgba(255,255,255,.1); color: #fff; }
.lines { flex: 0 0 auto; display: flex; align-items: center; gap: 12px; padding: 14px 24px 18px; overflow-x: auto;
  background: linear-gradient(#0b0a12, #000); color: var(--player-text); scrollbar-width: none; }
.lines::-webkit-scrollbar { display: none; }
.lines:empty { display: none; }
.lines .label { flex: 0 0 auto; color: var(--player-text); font-size: 16px; margin-right: 4px; }
.chip {                                              /* Android TvAction, dark */
  flex: 0 0 auto; display: inline-flex; flex-direction: column; align-items: center; justify-content: center;
  min-width: 96px; max-width: 280px; min-height: 48px; padding: 6px 24px; border-radius: 999px;
  border: 1px solid var(--player-outline); background: var(--player-surface); color: var(--player-text);
  font-size: 16px; font-weight: 500; white-space: nowrap; transition: background-color .2s, border-color .2s;
}
.chip > span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.chip small { font-size: 11px; line-height: 13px; color: var(--player-text-2); font-weight: 400; }
.chip:hover { border-color: var(--player-accent); }
.chip.active { background: var(--md-primary); border-color: transparent; color: #fff; }
.chip.active small { color: #E3DDF8; }
.chip.failed { opacity: .4; }
.sep { flex: 0 0 1px; align-self: stretch; background: var(--player-outline); margin: 6px 8px; }
.peek { position: absolute; left: 14px; top: 14px; z-index: 4; display: none; width: 44px; height: 44px;
  border: 0; border-radius: 50%; background: rgba(40,36,61,.7); color: #fff; opacity: .7; align-items: center; justify-content: center; }
.peek:hover { opacity: 1; }
.immersive .vbar, .immersive .lines { display: none; }
.immersive .peek { display: inline-flex; }
@media (max-width: 760px) {
  .vbar { padding: 10px 12px; gap: 10px; }
  .vbar .back { padding: 8px 16px; }
  .vbar .vtitle b { font-size: 17px; line-height: 22px; }
  .lines { padding: 10px 12px 14px; }
}

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