/*
Theme Name: TubeGrid
Description: Simple YouTube-style video grid theme. Homepage shows video thumbnails in a grid; clicking one opens a YouTube-style player right on the page. Add videos via Dashboard → Videos (upload MP4 or paste a YouTube link).
Version: 1.0.5
Author: USAXNews
Text Domain: tubegrid
*/

/* ---------- Base ---------- */
* { box-sizing: border-box; }
body { margin: 0; font-family: -apple-system, "Segoe UI", Roboto, Arial, sans-serif; background: #f9f9f9; color: #0f0f0f; }
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
.tg-container { max-width: 1280px; margin: 0 auto; padding: 0 16px; }

/* ---------- Header ---------- */
.tg-header { background: #fff; border-bottom: 1px solid #e5e5e5; position: sticky; top: 0; z-index: 50; }
.tg-header-inner { max-width: 1280px; margin: 0 auto; padding: 10px 16px; display: flex; align-items: center; gap: 16px; }
.tg-logo { font-size: 22px; font-weight: 800; color: #f00; letter-spacing: -0.5px; white-space: nowrap; }
.tg-logo span { color: #0f0f0f; }
.tg-search { margin-left: auto; display: flex; }
.tg-search input[type="search"] { padding: 8px 12px; border: 1px solid #ccc; border-radius: 20px 0 0 20px; width: 220px; outline: none; }
.tg-search button { padding: 8px 16px; border: 1px solid #ccc; border-left: 0; border-radius: 0 20px 20px 0; background: #f0f0f0; cursor: pointer; }

/* ---------- Grid ---------- */
.tg-page-title { font-size: 22px; margin: 22px 0 14px; }
.tg-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 20px 14px; padding-bottom: 40px; }
.tg-card { display: block; }
.tg-thumb { position: relative; aspect-ratio: 16/9; background: #000; border-radius: 12px; overflow: hidden; }
.tg-thumb img { width: 100%; height: 100%; object-fit: cover; }
.tg-thumb-ph { width: 100%; height: 100%; background: linear-gradient(135deg, #333, #111); }
.tg-play { position: absolute; inset: 0; margin: auto; width: 58px; height: 58px; border-radius: 50%; background: rgba(255,0,0,.92); color: #fff; font-size: 22px; display: flex; align-items: center; justify-content: center; pointer-events: none; }
.tg-card:hover .tg-play { transform: scale(1.08); }
.tg-dur { position: absolute; right: 8px; bottom: 8px; background: rgba(0,0,0,.8); color: #fff; font-size: 12px; padding: 2px 6px; border-radius: 4px; }
.tg-card-title { font-size: 15px; font-weight: 600; margin: 10px 4px 0; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* ---------- Lightbox player ---------- */
.tg-lightbox { position: fixed; inset: 0; background: rgba(0,0,0,.85); display: none; align-items: center; justify-content: center; z-index: 999; padding: 16px; }
.tg-lightbox.open { display: flex; }
.tg-lb-box { position: relative; width: 100%; max-width: 960px; background: #000; border-radius: 12px; overflow: hidden; }
.tg-lb-title { color: #fff; font-size: 16px; margin: 0; padding: 14px 48px 10px 16px; }
.tg-lb-close { position: absolute; top: 8px; right: 8px; width: 34px; height: 34px; border: 0; border-radius: 50%; background: rgba(255,255,255,.15); color: #fff; font-size: 16px; cursor: pointer; z-index: 2; }
.tg-player { aspect-ratio: 16/9; background: #000; }
.tg-player iframe, .tg-player video { width: 100%; height: 100%; border: 0; display: block; }

/* ---------- Watch page ---------- */
.tg-watch { padding-top: 20px; padding-bottom: 40px; }
.tg-player-big { aspect-ratio: 16/9; background: #000; border-radius: 12px; overflow: hidden; }
.tg-player-big iframe, .tg-player-big video { width: 100%; height: 100%; border: 0; display: block; }
.tg-watch h1 { font-size: 22px; margin: 16px 0 8px; }
.tg-desc { color: #333; line-height: 1.6; margin-bottom: 30px; }
.tg-section-title { font-size: 18px; margin: 0 0 14px; }

/* ---------- Footer ---------- */
.tg-footer { background: #fff; border-top: 1px solid #e5e5e5; padding: 22px 0; color: #666; font-size: 14px; text-align: center; }

/* ---------- Ad slots ---------- */
.ad-label { text-align: center; font-size: 11px; letter-spacing: 2px; color: #999; text-transform: uppercase; margin: 14px 0 6px; }
.tg-adbox { display: flex; justify-content: center; margin-bottom: 18px; }
.tg-adbox .tg-adwidget { width: 100%; display: flex; justify-content: center; }
.tg-adbox ins, .tg-adbox iframe { max-width: 100%; }

/* ---------- Smartlink interstitial (fullscreen) ---------- */
.tg-interstitial { position: fixed; inset: 0; z-index: 1000; background: #000; display: flex; }
.tg-interstitial[hidden] { display: none; }
.tg-int-box { width: 100%; height: 100%; display: flex; flex-direction: column; padding: 8px; }
.tg-int-top { display: flex; justify-content: space-between; align-items: center; padding: 2px 8px 8px; }
.tg-int-top .ad-label { margin: 0; }
.tg-int-box iframe { flex: 1; width: 100%; border: 0; background: #fff; min-height: 0; }
.tg-int-timer { color: #fff; font-size: 14px; white-space: nowrap; }
.tg-int-timer span { font-weight: 700; color: #ffd60a; }

/* ---------- Mobile ---------- */
@media (max-width: 640px) {
  .tg-grid { grid-template-columns: repeat(2, 1fr); gap: 14px 10px; }
  .tg-card-title { font-size: 13px; }
  .tg-search input[type="search"] { width: 130px; }
  .tg-play { width: 44px; height: 44px; font-size: 17px; }
}
