/* StatsTube front-end theme. Dark by default, light via [data-theme="light"]. */

:root {
  --accent: #ff0040;
  --accent-2: #ff4d6d;
  --accent-3: #7c5cff;          /* violet — premium secondary glow */
  --gradient: linear-gradient(135deg, #ff0040 0%, #ff4d6d 45%, #7c5cff 100%);
  --bg: #07080f;
  --bg-2: #0d0f1c;
  --surface: rgba(255, 255, 255, 0.045);
  --surface-2: rgba(255, 255, 255, 0.07);
  --surface-solid: #12152a;
  --border: rgba(255, 255, 255, 0.085);
  --border-glow: rgba(124, 92, 255, 0.35);
  --text: #f2f4ff;
  --muted: #98a0c0;
  --ok: #2ee6a0;
  --shadow: 0 24px 64px rgba(0, 0, 0, 0.55);
  --shadow-glow: 0 18px 50px rgba(255, 0, 64, 0.22);
  --radius: 18px;
}

[data-theme="light"] {
  --bg: #eef1fb;
  --bg-2: #ffffff;
  --surface: rgba(255, 255, 255, 0.78);
  --surface-2: rgba(255, 255, 255, 0.92);
  --surface-solid: #ffffff;
  --border: rgba(20, 20, 50, 0.10);
  --border-glow: rgba(124, 92, 255, 0.30);
  --text: #121327;
  --muted: #5a6080;
  --shadow: 0 16px 40px rgba(40, 50, 90, 0.14);
  --shadow-glow: 0 16px 40px rgba(255, 0, 64, 0.14);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, sans-serif;
  color: var(--text);
  background:
    radial-gradient(1200px 600px at 88% -12%, rgba(255, 0, 64, 0.20), transparent 58%),
    radial-gradient(1000px 520px at 5% -5%, rgba(124, 92, 255, 0.20), transparent 55%),
    radial-gradient(800px 800px at 50% 120%, rgba(124, 92, 255, 0.10), transparent 60%),
    var(--bg);
  background-attachment: fixed;
  min-height: 100vh;
  line-height: 1.55;
}

a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }

.container { width: min(1140px, 92vw); margin: 0 auto; }

/* ---------- Glass card ---------- */
.glass {
  background: var(--surface);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  backdrop-filter: blur(14px);
  background: color-mix(in srgb, var(--bg) 80%, transparent);
  border-bottom: 1px solid var(--border);
}
.nav {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 0; gap: 16px;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 1.25rem; }
.brand .dot { color: var(--accent); }
.nav-links { display: flex; align-items: center; gap: 22px; }
.nav-links a { color: var(--muted); font-weight: 500; font-size: .95rem; transition: color .2s; }
.nav-links a:hover, .nav-links a.active { color: var(--text); }
.icon-btn {
  background: var(--surface); border: 1px solid var(--border); color: var(--text);
  width: 40px; height: 40px; border-radius: 12px; cursor: pointer; font-size: 1rem;
  display: inline-flex; align-items: center; justify-content: center;
}
.icon-btn:hover { border-color: var(--accent); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px; justify-content: center;
  padding: 12px 22px; border-radius: 12px; font-weight: 600; cursor: pointer;
  border: 1px solid transparent; font-size: .98rem; transition: transform .12s, filter .2s;
}
.btn:hover { transform: translateY(-1px); }
.btn-primary { background: var(--gradient); background-size: 160% 160%; color: #fff; box-shadow: var(--shadow-glow); }
.btn-primary:hover { filter: brightness(1.08); background-position: 100% 0; }
.btn-ghost { background: var(--surface); border-color: var(--border); color: var(--text); }
.btn-block { width: 100%; }

/* ---------- Hero ---------- */
.hero { padding: 70px 0 40px; text-align: center; }
.hero h1 {
  font-size: clamp(2rem, 5vw, 3.4rem); margin: 0 0 14px; line-height: 1.1; letter-spacing: -0.02em;
  background: linear-gradient(120deg, var(--text) 0%, var(--accent-2) 55%, var(--accent-3) 100%);
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}
.hero p.lead { color: var(--muted); font-size: 1.15rem; max-width: 620px; margin: 0 auto 30px; }

.search-bar {
  display: flex; gap: 10px; max-width: 640px; margin: 0 auto; padding: 10px;
  border-radius: 18px;
}
.search-bar input {
  flex: 1; padding: 14px 18px; border-radius: 12px; border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.2); color: var(--text); font-size: 1rem;
}
[data-theme="light"] .search-bar input { background: rgba(0,0,0,0.04); }
.search-bar input:focus { outline: none; border-color: var(--accent); }

.hero-badges { display: flex; gap: 26px; justify-content: center; margin-top: 26px; flex-wrap: wrap; }
.hero-badges span { color: var(--muted); font-size: .92rem; display: inline-flex; gap: 8px; align-items: center; }

/* ---------- Sections ---------- */
section.block { padding: 46px 0; }
.section-title { font-size: 1.7rem; margin: 0 0 6px; }
.section-sub { color: var(--muted); margin: 0 0 26px; }

/* ---------- Channel cards grid ---------- */
.cards { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); }
.channel-card { padding: 18px; display: flex; flex-direction: column; gap: 10px; align-items: center; text-align: center; transition: transform .15s, border-color .2s; }
.channel-card:hover { transform: translateY(-4px); border-color: var(--accent); }
.channel-card img { width: 72px; height: 72px; border-radius: 50%; object-fit: cover; border: 2px solid var(--border); }
.channel-card .name { font-weight: 700; font-size: 1rem; }
.channel-card .subs { color: var(--accent-2); font-weight: 700; }
.channel-card .meta { color: var(--muted); font-size: .82rem; }
.rank-badge { position: absolute; }

/* ---------- Channel detail page ---------- */
.channel-hero { display: flex; gap: 24px; align-items: center; padding: 26px; flex-wrap: wrap; margin-top: 28px; }
.channel-hero img.avatar { width: 120px; height: 120px; border-radius: 50%; border: 3px solid var(--accent); object-fit: cover; }
.channel-hero h1 { margin: 0 0 6px; font-size: 1.8rem; }
.channel-hero .handle { color: var(--muted); }

.count-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); margin-top: 22px; }
.count-card { padding: 24px; text-align: center; position: relative; overflow: hidden; transition: transform .15s, border-color .2s, box-shadow .2s; }
.count-card:hover { transform: translateY(-3px); border-color: var(--border-glow); box-shadow: var(--shadow-glow); }
.count-card .label { color: var(--muted); text-transform: uppercase; letter-spacing: .08em; font-size: .78rem; }
.count-card .value { font-size: clamp(1.8rem, 4vw, 2.8rem); font-weight: 800; margin-top: 6px; font-variant-numeric: tabular-nums; max-width: 100%; }
.count-card.primary { background: linear-gradient(160deg, rgba(255,0,64,.12), rgba(124,92,255,.10)), var(--surface); }
.count-card.primary::before { content: ""; position: absolute; top: 0; left: 0; right: 0; height: 3px; background: var(--gradient); }
.count-card.primary .value { color: var(--accent-2); text-shadow: 0 0 22px rgba(255, 77, 109, .35); }

/* Clickable metric cards — tap to chart that metric */
.metric-card { cursor: pointer; user-select: none; }
.metric-card .metric-hint { margin-top: 8px; font-size: .66rem; color: var(--muted); opacity: 0; transition: opacity .2s; text-transform: uppercase; letter-spacing: .07em; display: inline-flex; gap: 5px; align-items: center; }
.metric-card:hover .metric-hint { opacity: .75; }
.metric-card.active { border-color: var(--border-glow); box-shadow: var(--shadow-glow); }
.metric-card.active::before { content: ""; position: absolute; top: 0; left: 0; right: 0; height: 3px; background: var(--gradient); }
.metric-card.active .metric-hint { opacity: 1; color: var(--accent-2); }
.chart-head #chartMetricName { color: var(--accent-2); }
.live-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--ok); margin-right: 6px; animation: pulse 1.4s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .25; } }

/* ---------- Rolling number counter (odometer) ---------- */
.odo { display: inline-flex; align-items: flex-end; line-height: 1; font-variant-numeric: tabular-nums; }
.odo-d { display: inline-block; height: 1em; overflow: hidden; }
.odo-strip { display: flex; flex-direction: column; will-change: transform; transition: transform .6s cubic-bezier(.22, 1, .36, 1); }
.odo-n { height: 1em; line-height: 1em; text-align: center; }
.odo-sep { display: inline-block; }
.odo-up { animation: odoFlashUp .7s ease; }
.odo-down { animation: odoFlashDown .7s ease; }
@keyframes odoFlashUp { 0%, 100% { text-shadow: none; } 30% { text-shadow: 0 0 16px rgba(46, 204, 113, .85); } }
@keyframes odoFlashDown { 0%, 100% { text-shadow: none; } 30% { text-shadow: 0 0 16px rgba(255, 85, 102, .85); } }
@media (prefers-reduced-motion: reduce) { .odo-strip { transition: none; } }

/* ---------- Live chart (fixed box — prevents infinite growth) ---------- */
.chart-card { margin-top: 24px; padding: 18px 20px 20px; }
.chart-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.chart-head h3 { margin: 0; font-size: 1.05rem; display: flex; align-items: center; gap: 8px; }
.chart-head h3 i { color: var(--accent-2); }
.chart-live { color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; display: inline-flex; align-items: center; gap: 6px; }
/* The box has a FIXED height so Chart.js (maintainAspectRatio:false) fills it
   instead of growing taller on every resize. */
.chart-box { position: relative; width: 100%; height: 260px; }
.chart-box canvas { position: absolute !important; inset: 0; width: 100% !important; height: 100% !important; }
@media (max-width: 600px) { .chart-box { height: 200px; } }

/* Live auto-refresh countdown indicator */
.live-refresh { text-align: center; color: var(--muted); font-size: .85rem; margin: 16px 0 2px; display: flex; align-items: center; justify-content: center; gap: 6px; }
.live-refresh b { color: var(--accent-2); font-variant-numeric: tabular-nums; min-width: 1ch; display: inline-block; font-weight: 700; }

.stat-row { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); margin-top: 18px; }
.stat-pill { padding: 16px; }
.stat-pill .k { color: var(--muted); font-size: .82rem; }
.stat-pill .v { font-weight: 700; font-size: 1.15rem; }

/* ---------- Video / live page ---------- */
.video-hero { display: grid; grid-template-columns: 1.3fr 1fr; gap: 26px; align-items: center; padding: 22px; margin-top: 28px; }
.video-embed { position: relative; width: 100%; aspect-ratio: 16 / 9; border-radius: 14px; overflow: hidden; background: #000; box-shadow: var(--shadow); }
.video-embed iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.video-meta h1 { margin: 12px 0 8px; font-size: 1.5rem; line-height: 1.25; }
.video-meta .handle { color: var(--muted); font-size: .95rem; }
.video-meta .handle a { color: var(--text); font-weight: 600; }
.video-meta .handle a:hover { color: var(--accent-2); }
.video-badges { display: flex; gap: 8px; flex-wrap: wrap; }
.video-badges span { font-size: .74rem; font-weight: 800; letter-spacing: .06em; padding: 5px 10px; border-radius: 999px; display: inline-flex; align-items: center; gap: 6px; }
.live-badge { background: var(--accent); color: #fff; box-shadow: 0 0 0 0 rgba(255,0,51,.6); animation: livePulse 1.6s infinite; }
.live-badge .lb-dot { width: 8px; height: 8px; border-radius: 50%; background: #fff; animation: pulse 1.2s infinite; }
@keyframes livePulse { 0% { box-shadow: 0 0 0 0 rgba(255,0,51,.55); } 70% { box-shadow: 0 0 0 12px rgba(255,0,51,0); } 100% { box-shadow: 0 0 0 0 rgba(255,0,51,0); } }
.up-badge { background: rgba(255,178,36,.16); color: #ffce6b; border: 1px solid rgba(255,178,36,.4); }
.past-badge, .dur-badge { background: var(--surface); color: var(--muted); border: 1px solid var(--border); }

/* ---------- Share row ---------- */
.share-row { display: flex; align-items: center; gap: 8px; margin-top: 16px; flex-wrap: wrap; }
.share-label { color: var(--muted); font-size: .85rem; font-weight: 600; margin-right: 2px; }
.share-btn { width: 38px; height: 38px; border-radius: 11px; display: inline-flex; align-items: center; justify-content: center; color: #fff; border: 0; cursor: pointer; font-size: 1rem; transition: transform .12s, filter .2s; text-decoration: none; }
.share-btn:hover { transform: translateY(-2px); filter: brightness(1.1); }
.share-btn.wa { background: #25d366; } .share-btn.tw { background: #111; } .share-btn.fb { background: #1877f2; }
.share-btn.tg { background: #29a9eb; } .share-btn.copy { background: var(--surface-solid); color: var(--text); border: 1px solid var(--border); }
.share-btn.copied { background: var(--ok); color: #fff; }

@media (max-width: 760px) {
  .video-hero { grid-template-columns: 1fr; }
}

/* ---------- Promotion slots ---------- */
.promo-slot { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); margin: 20px 0; }
.promo-btn {
  display: flex; align-items: center; gap: 12px; padding: 14px 18px; border-radius: 14px;
  font-weight: 700; box-shadow: var(--shadow); transition: transform .14s, filter .2s;
}
.promo-btn:hover { transform: translateY(-2px); filter: brightness(1.05); }
.promo-btn img { width: 34px; height: 34px; border-radius: 8px; object-fit: cover; }
.promo-btn .pt { display: flex; flex-direction: column; line-height: 1.2; }
.promo-btn .pt small { font-weight: 500; opacity: .85; font-size: .8rem; }
.promo-sidebar .promo-btn { width: 100%; }

/* ---------- Ad container (responsive AdSense) ---------- */
.ad-box { margin: 26px auto; text-align: center; width: 100%; max-width: 100%; overflow: hidden; }
.ad-box .ad-label { color: var(--muted); font-size: .7rem; text-transform: uppercase; letter-spacing: .12em; margin-bottom: 6px; }
/* Force any pasted AdSense unit to behave responsively inside the slot. */
.ad-box ins.adsbygoogle,
.promo-slot ins.adsbygoogle,
.ad-box ins,
.ad-box iframe { display: block !important; width: 100% !important; max-width: 100% !important; height: auto; margin: 0 auto; }

/* ---------- Blog ---------- */
.blog-card { padding: 20px; display: flex; flex-direction: column; gap: 8px; text-align: left; align-items: flex-start; transition: transform .15s, border-color .2s; }
.blog-card:hover { transform: translateY(-4px); border-color: var(--accent); }
.blog-card h2, .blog-card h3 { margin: 4px 0; font-size: 1.15rem; line-height: 1.3; }
.blog-tag { font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: #fff; background: var(--gradient); padding: 3px 10px; border-radius: 999px; }
.blog-meta { color: var(--muted); font-size: .82rem; }

/* ---------- Legal / article typography ---------- */
.legal h2, .article h2 { margin: 22px 0 8px; font-size: 1.2rem; }
.legal a, .article a { color: var(--accent-2); }
.article article h2 { margin: 22px 0 10px; font-size: 1.25rem; }
.article article p { margin: 0 0 14px; line-height: 1.7; }
.article article ul { margin: 0 0 14px; padding-left: 22px; }
.article article li { margin-bottom: 7px; }

/* ---------- Instagram coming-soon badge ---------- */
.ig-badge { display: inline-flex; align-items: center; gap: 8px; padding: 6px 14px; border-radius: 999px; font-weight: 700; font-size: .8rem; margin-bottom: 14px; color: #fff; background: linear-gradient(135deg, #feda75, #d62976, #962fbf, #4f5bd5); }

/* ---------- SEO content ---------- */
.seo-content h2 { font-size: 1.5rem; margin: 0 0 10px; }
.seo-content h3 { font-size: 1.1rem; margin: 20px 0 6px; }
.seo-content p { color: var(--muted); margin: 0 0 12px; }

/* ---------- FAQ ---------- */
.faq details { padding: 16px 20px; margin-bottom: 12px; }
.faq summary { cursor: pointer; font-weight: 600; }
.faq details p { color: var(--muted); margin: 10px 0 0; }

/* ---------- Footer ---------- */
.site-footer { border-top: 1px solid var(--border); margin-top: 50px; padding: 40px 0 24px; }
.footer-grid { display: grid; gap: 28px; grid-template-columns: 2fr 1fr 1fr 1fr; }
.footer-grid h4 { margin: 0 0 12px; font-size: .95rem; }
.footer-grid a { display: block; color: var(--muted); padding: 4px 0; font-size: .9rem; }
.footer-grid a:hover { color: var(--text); }
.footer-bottom { display: flex; justify-content: space-between; align-items: center; margin-top: 26px; padding-top: 18px; border-top: 1px solid var(--border); color: var(--muted); font-size: .86rem; flex-wrap: wrap; gap: 10px; }

/* ---------- Flash ---------- */
.flash { padding: 12px 16px; border-radius: 12px; margin: 14px 0; font-size: .92rem; }
.flash.success { background: rgba(46,204,113,.14); border: 1px solid rgba(46,204,113,.4); color: #8ef0b6; }
.flash.error { background: rgba(255,85,102,.14); border: 1px solid rgba(255,85,102,.4); color: #ffb3bd; }

/* ---------- CTA widgets ---------- */
.announcement-bar { text-align: center; padding: 10px 16px; font-weight: 600; font-size: .92rem; position: relative; }
.announcement-bar .ann-close { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); cursor: pointer; background: none; border: 0; color: inherit; font-size: 1.1rem; opacity: .8; }
.announcement-bar .cd { font-variant-numeric: tabular-nums; opacity: .9; }

.floating-cta {
  position: fixed; right: 20px; bottom: 20px; z-index: 60; max-width: 280px;
  padding: 16px 18px; border-radius: 16px; box-shadow: var(--shadow);
  background: var(--surface-solid); border: 1px solid var(--border);
  animation: floatIn .4s ease;
}
@keyframes floatIn { from { transform: translateY(20px); opacity: 0; } to { transform: none; opacity: 1; } }
.floating-cta p { margin: 0 0 10px; font-weight: 700; }
.floating-cta .fc-close { position: absolute; top: 8px; right: 10px; background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 1rem; }

.sticky-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 16px; background: var(--surface-solid); border-top: 1px solid var(--border);
  box-shadow: 0 -10px 30px rgba(0,0,0,.3);
}
.sticky-bar .sb-text { font-weight: 700; font-size: .95rem; }
.sticky-bar .sb-close { background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 1.2rem; }

.exit-overlay {
  position: fixed; inset: 0; z-index: 80; display: none; align-items: center; justify-content: center;
  background: rgba(0,0,0,.6); backdrop-filter: blur(4px); padding: 20px;
}
.exit-overlay.show { display: flex; }
.exit-modal { max-width: 440px; width: 100%; padding: 30px; text-align: center; background: var(--surface-solid); }
.exit-modal h3 { margin: 0 0 10px; font-size: 1.5rem; }
.exit-modal p { color: var(--muted); margin: 0 0 20px; }
.exit-modal .ex-btns { display: grid; gap: 10px; }
.exit-modal .ex-close { position: absolute; top: 14px; right: 18px; background: none; border: 0; color: var(--muted); font-size: 1.4rem; cursor: pointer; }

/* ---------- Misc ---------- */
.text-muted { color: var(--muted); }
.center { text-align: center; }
.mt-3 { margin-top: 18px; } .mt-4 { margin-top: 26px; }
.spinner { width: 18px; height: 18px; border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 50%; display: inline-block; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Search bar: premium glow + paste button ---------- */
.search-bar { position: relative; transition: box-shadow .25s, border-color .25s; }
.search-bar:focus-within { border-color: var(--border-glow); box-shadow: 0 0 0 3px rgba(124, 92, 255, .18), var(--shadow); }
.btn-paste { padding: 12px 16px; white-space: nowrap; }
.btn-paste i { font-size: 1rem; }

/* ======================================================================
   RESPONSIVE — phones & tablets
   ====================================================================== */
@media (max-width: 900px) {
  .footer-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 760px) {
  /* Keep the nav usable on mobile instead of hiding it. */
  .nav-links { gap: 14px; font-size: .9rem; }
  .nav-links a { font-size: .9rem; }
  .nav { gap: 10px; flex-wrap: wrap; }

  .hero { padding: 46px 0 28px; }
  .hero p.lead { font-size: 1.02rem; }
  .search-bar { flex-direction: column; padding: 12px; }
  .search-bar input { width: 100%; }
  .search-bar .btn { width: 100%; }
  .hero-badges { gap: 14px 18px; }

  .channel-hero { flex-direction: column; text-align: center; padding: 22px 18px; }
  .channel-hero img.avatar { width: 96px; height: 96px; }
  .channel-hero .handle { justify-content: center; }
  .share-row { justify-content: center; }

  .count-grid { grid-template-columns: 1fr 1fr; gap: 12px; }
  .count-card { padding: 18px 12px; }
  .count-card .value { font-size: clamp(1.4rem, 7vw, 2rem); }

  .stat-row { grid-template-columns: 1fr 1fr; }
  .video-meta h1 { font-size: 1.25rem; }
  .section-title { font-size: 1.4rem; }
}

@media (max-width: 460px) {
  .container { width: 92vw; }
  .nav-links { display: none; }            /* brand + theme only on very small screens */
  .count-grid { grid-template-columns: 1fr; }
  .stat-row { grid-template-columns: 1fr; }
  .hero h1 { font-size: 1.7rem; }
  .footer-grid { grid-template-columns: 1fr; }
  .video-badges { gap: 6px; }
}
