/* ============================================================
   Xuming.me — YouTube Dark Mode Style
   ============================================================ */

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

:root {
  --bg:          #0f0f0f;
  --bg2:         #181818;
  --bg3:         #272727;
  --border:      #3f3f3f;
  --text:        #f1f1f1;
  --text2:       #aaaaaa;
  --red:         #ff0000;
  --red-hover:   #cc0000;
  --radius:      8px;
  --nav-h:       56px;
}

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Roboto', sans-serif;
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
}

a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }
button { cursor: pointer; border: none; background: none; font-family: inherit; }

/* ── Top Nav ─────────────────────────────────────────────────── */
.topnav {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--nav-h);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 16px;
}

.topnav__logo {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  text-decoration: none;
}

.topnav__logo-icon {
  width: 32px;
  height: 32px;
  background: var(--red);
  color: #fff;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 16px;
}

.topnav__logo-name {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
}

.topnav__search {
  flex: 1;
  max-width: 560px;
  display: flex;
  border: 1px solid var(--border);
  border-radius: 40px;
  overflow: hidden;
  background: var(--bg2);
}

.topnav__search input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  padding: 8px 16px;
  font-size: 14px;
}

.topnav__search-btn {
  padding: 0 16px;
  background: var(--bg3);
  color: var(--text2);
  border-left: 1px solid var(--border);
  transition: color .2s;
}
.topnav__search-btn:hover { color: var(--text); }

.topnav__admin-link {
  margin-left: auto;
  flex-shrink: 0;
  font-size: 13px;
  color: var(--text2);
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 20px;
  transition: color .2s, border-color .2s;
}
.topnav__admin-link:hover { color: var(--text); border-color: var(--text2); }

/* ── Container ───────────────────────────────────────────────── */
.container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 16px 40px;
}

/* ── Channel Banner ──────────────────────────────────────────── */
.channel-banner {
  height: 130px;
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
  border-radius: 0 0 var(--radius) var(--radius);
  margin-bottom: 16px;
}

/* ── Channel Info ────────────────────────────────────────────── */
.channel-info {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 0 8px 20px;
}

.channel-avatar {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: var(--red);
  color: #fff;
  font-size: 36px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border: 3px solid var(--bg);
  margin-top: -30px;
}

.channel-meta { flex: 1; }

.channel-name {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 4px;
}

.channel-sub {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--text2);
  font-size: 13px;
  margin-bottom: 12px;
}
.channel-sub span::after { content: '·'; margin-left: 8px; }
.channel-sub span:last-child::after { content: ''; margin: 0; }

/* ── Channel Bar (handle + subscribe per tab) ────────────────── */
.channel-bar { margin-bottom: 8px; min-height: 32px; }
.channel-bar__item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 0;
}
.channel-bar__handle {
  color: var(--text2);
  font-size: 13px;
}

/* ── Subscribe Button ────────────────────────────────────────── */
.btn-subscribe {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--red);
  color: #fff;
  border-radius: 20px;
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 500;
  transition: background .2s;
}
.btn-subscribe:hover { background: var(--red-hover); }

/* ── Tabs ────────────────────────────────────────────────────── */
.tabs {
  display: flex;
  align-items: center;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 12px;
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }

.tab-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 16px;
  color: var(--text2);
  font-size: 14px;
  font-weight: 500;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  transition: color .2s, border-color .2s;
  flex-shrink: 0;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active {
  color: var(--text);
  border-bottom-color: var(--text);
}

.tab-count {
  background: var(--bg3);
  color: var(--text2);
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 10px;
}
.tab-btn.active .tab-count {
  background: var(--red);
  color: #fff;
}

/* ── Filter Chips ────────────────────────────────────────────── */
.filters {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.filter-chip {
  padding: 6px 14px;
  border-radius: 20px;
  background: var(--bg3);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  transition: background .2s, color .2s;
}
.filter-chip:hover { background: #3f3f3f; }
.filter-chip.active {
  background: var(--text);
  color: var(--bg);
}

/* ── Video Grid ──────────────────────────────────────────────── */
.video-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
}

/* ── Video Card ──────────────────────────────────────────────── */
.video-card {
  cursor: pointer;
  border-radius: var(--radius);
  overflow: hidden;
  transition: transform .2s;
}
.video-card:hover { transform: translateY(-2px); }

.video-card__thumb {
  position: relative;
  aspect-ratio: 16/9;
  background: var(--bg3);
  overflow: hidden;
}
.video-card__thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform .3s;
}
.video-card:hover .video-card__thumb img { transform: scale(1.03); }

.video-card__duration {
  position: absolute;
  bottom: 6px;
  right: 6px;
  background: rgba(0,0,0,.85);
  color: #fff;
  font-size: 12px;
  font-weight: 500;
  padding: 2px 5px;
  border-radius: 3px;
}

.video-card__info {
  padding: 10px 4px 4px;
}
.video-card__title {
  font-size: 14px;
  font-weight: 500;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 4px;
}
.video-card__meta {
  color: var(--text2);
  font-size: 12px;
}

/* ── Empty State ─────────────────────────────────────────────── */
.empty-state {
  grid-column: 1/-1;
  text-align: center;
  padding: 60px 20px;
  color: var(--text2);
}
.empty-state__icon { font-size: 48px; margin-bottom: 12px; }
.empty-state__title { font-size: 18px; font-weight: 500; color: var(--text); margin-bottom: 6px; }
.empty-state__text  { font-size: 14px; }

/* ── Modal ───────────────────────────────────────────────────── */
.modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.85);
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal-backdrop.open { display: flex; }

.modal {
  background: var(--bg2);
  border-radius: var(--radius);
  width: 100%;
  max-width: 900px;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
}

.modal__close {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 10;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(0,0,0,.6);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .2s;
}
.modal__close:hover { background: rgba(0,0,0,.9); }

.modal__video {
  position: relative;
  aspect-ratio: 16/9;
  background: #000;
}
.modal__video iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: none;
}

.modal__info {
  padding: 16px;
}
.modal__title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 6px;
}
.modal__stats {
  color: var(--text2);
  font-size: 13px;
  margin-bottom: 10px;
}
.modal__desc {
  color: var(--text2);
  font-size: 13px;
  line-height: 1.6;
  white-space: pre-wrap;
  max-height: 120px;
  overflow-y: auto;
}

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 640px) {
  .topnav__logo-name { display: none; }
  .channel-avatar { width: 60px; height: 60px; font-size: 26px; }
  .channel-name   { font-size: 18px; }
  .video-grid     { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
}

/* ── Category sub-tabs ──────────────────────────────────────── */
.category-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid #333;
  margin-bottom: 16px;
}
.category-tab {
  background: none;
  border: none;
  color: #aaa;
  font-size: 14px;
  font-weight: 500;
  padding: 10px 20px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color .15s, border-color .15s;
}
.category-tab:hover { color: #fff; }
.category-tab.active { color: #fff; border-bottom-color: #fff; }

/* ── Shorts portrait cards ──────────────────────────────────── */
.video-card--short .video-card__thumb {
  aspect-ratio: 9 / 16;
}
.modal--short { max-width: 400px; width: 95vw; }
.modal--short .modal__video { aspect-ratio: 9 / 16; }
.modal--video { max-width: 900px; width: 95vw; }
.modal--video .modal__video { aspect-ratio: 16 / 9; }
