/* -------------------------
   YouTube Channel Gallery Style
   Author: ChatGPT for King
   Version: 1.0.3
-------------------------- */

/* Wrapper base */
.ytcg-wrapper {
  --gap: 16px;
  --radius: 14px;
  --bg: #fff;
  --fg: #111;
  padding: 24px;
  background: var(--bg);
  color: var(--fg);
  border-radius: var(--radius);
  box-shadow: 0 2px 24px rgba(0,0,0,0.06);
  position: relative;
  overflow: hidden;
}

/* Header row */
.ytcg-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  border-bottom: 1px solid #e5e7eb;
  flex-wrap: wrap;
  gap: 12px;
}

/* Tabs */
.ytcg-tabs { display: flex; gap: 8px; }
.ytcg-tab {
  background: #f3f4f6;
  border: 1px solid #e5e7eb;
  padding: 10px 14px;
  border-radius: 10px 10px 0 0;
  font-weight: 600;
  color: #374151;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}
.ytcg-tab.ytcg-active { background: #fff; border-bottom-color: #fff; color: #000; }
.ytcg-tab:hover { background: #fff; }

/* Subscribe button */
.ytcg-subscribe {
  display: inline-block;
  padding: 10px 16px;
  border-radius: 999px;
  background: #ff0000;
  color: #fff !important;
  text-decoration: none;
  font-weight: 700;
  box-shadow: 0 6px 14px rgba(255, 0, 0, 0.25);
  transition: all 0.2s ease;
  margin-left: auto;
  white-space: nowrap;
}
.ytcg-subscribe:hover { filter: brightness(0.95); transform: translateY(-1px); }

/* Main gallery grid — max 3 per row */
.ytcg-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: var(--gap);
  max-width: 1080px;
  margin: 0 auto;
}

/* Video cards (used by both gallery and latest) */
.ytcg-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  text-decoration: none;
  color: inherit;
  border: 1px solid #e5e7eb;
  border-radius: var(--radius);
  overflow: hidden;
  background: #fff;
  transition: transform 0.15s ease, box-shadow 0.2s ease;
  position: relative;
}
.ytcg-card:hover { transform: translateY(-2px); box-shadow: 0 10px 24px rgba(0, 0, 0, 0.08); }

/* Thumbnail */
.ytcg-thumb {
  display: block;
  width: 100%;
  padding-top: 56.25%;
  background-size: cover;
  background-position: center;
  position: relative;
}
.ytcg-play {
  position: absolute;
  bottom: 10px; right: 10px;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  font-weight: 700;
  padding: 6px 8px;
  border-radius: 8px;
  font-size: 14px;
}

/* Title */
.ytcg-title { padding: 0 12px 12px 12px; font-weight: 600; line-height: 1.3; }

/* Playlist badge */
.ytcg-badge {
  position: absolute;
  margin: 10px;
  background: #111;
  color: #fff;
  font-weight: 700;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
}

/* Load more */
.ytcg-actions { display: flex; justify-content: center; margin-top: 18px; }
.ytcg-load {
  padding: 10px 18px;
  border-radius: 999px;
  border: 1px solid #111;
  background: #111;
  color: #fff;
  cursor: pointer;
  font-weight: 700;
  transition: all 0.2s ease;
}
.ytcg-load:hover { background: #000; transform: translateY(-1px); }

/* Notice / error */
.ytcg-notice { padding: 12px; background: #fffbea; border: 1px solid #fde68a; border-radius: 10px; }
#ytcg-error { color: #b91c1c; font-weight: 600; margin-top: 10px; }

/* Popup overlay (video & playlist) */
.ytcg-popup-overlay {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.85);
  z-index: 99999;
  display: flex; justify-content: center; align-items: center;
  padding: 20px;
}
.ytcg-popup-content {
  position: relative;
  max-width: 960px; width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
}
.ytcg-popup-content iframe { width: 100%; height: 100%; }
.ytcg-close {
  position: absolute; top: -10px; right: -10px;
  background: #fff; color: #111; border: none;
  font-size: 22px; line-height: 22px;
  border-radius: 50%; width: 34px; height: 34px;
  cursor: pointer; font-weight: bold;
  box-shadow: 0 3px 10px rgba(0,0,0,0.25);
}
body.ytcg-noscroll { overflow: hidden; }

/* ---------- Latest shortcode (3 across) ---------- */
.ytcg-latest-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--gap);
  max-width: 1080px;
  margin: 0 auto;
}
.ytcg-latest-card .ytcg-thumb { border-bottom: none; }
.ytcg-divider {
  margin: 8px 12px;
  border: 0;
  border-top: 1px solid #e5e7eb;
}

/* Responsive */
@media (max-width: 1024px) {
  .ytcg-latest-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 640px) {
  .ytcg-latest-grid { grid-template-columns: 1fr; }
  .ytcg-grid { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
  .ytcg-header { flex-direction: column; align-items: flex-start; }
  .ytcg-subscribe { align-self: flex-end; }
}
