/* ==========================================================================
   YouTube Live Stream Overlay — Debraj Gamerz
   Optimized for YouTube Shorts Live (9:16 Vertical — 1080x1920)
   Safe from YouTube UI Buttons (Close, Subscribe, Chat, Action Bar)
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@500;600;700;800;900&family=JetBrains+Mono:wght@600;700;800&family=Roboto:wght@400;500;700;900&display=swap');

:root {
  --yt-red: #FF0033;
  --gold-primary: #FFD166;
  --emerald-green: #06D6A0;
  
  --card-bg: rgba(11, 15, 25, 0.88);
  --card-border: rgba(255, 255, 255, 0.12);
  --card-blur: blur(18px);
  
  --text-primary: #FFFFFF;
  --text-secondary: #94A3B8;
  
  --font-main: 'Outfit', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  --font-yt: 'Roboto', 'Outfit', sans-serif;
}

/* Strict Zero-Background for OBS Browser Source */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  width: 100vw;
  height: 100vh;
  margin: 0;
  padding: 0;
  background: transparent !important;
  background-color: rgba(0, 0, 0, 0) !important;
  overflow: hidden;
  font-family: var(--font-main);
  color: var(--text-primary);
  user-select: none;
  -webkit-font-smoothing: antialiased;
}

.overlay-viewport {
  position: relative;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
}

/* Fullscreen Particle Canvas */
#confetti-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 9999;
}

/* ==========================================================================
   Top Header Bar (Safe Zone below YouTube Shorts top controls)
   ========================================================================== */
.stream-top-bar {
  position: absolute;
  top: 140px; /* Safe distance below YouTube Shorts top close/share/menu */
  left: 0;
  width: 100%;
  padding: 0 36px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  pointer-events: none;
  z-index: 500;
}

/* 1. Live YouTube Subscriber Count Widget */
.sub-count-widget {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 24px 12px 14px;
  background: var(--card-bg);
  backdrop-filter: var(--card-blur);
  -webkit-backdrop-filter: var(--card-blur);
  border: 1px solid var(--card-border);
  border-radius: 40px;
  box-shadow: 0 12px 35px rgba(0, 0, 0, 0.45);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), border-color 0.3s ease;
  transform-origin: center left;
}

.sub-count-widget.sub-pulse {
  animation: widgetPulse 0.8s cubic-bezier(0.16, 1, 0.3, 1);
  border-color: var(--yt-red);
}

.yt-icon-box {
  position: relative;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--yt-red);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 14px rgba(255, 0, 51, 0.4);
  flex-shrink: 0;
}

.yt-icon-box svg {
  width: 24px;
  height: 24px;
  fill: #FFFFFF;
}

.yt-pulse-ring {
  position: absolute;
  top: -3px;
  left: -3px;
  right: -3px;
  bottom: -3px;
  border-radius: 50%;
  border: 1.5px solid var(--yt-red);
  opacity: 0.6;
  animation: liveRingPulse 2.2s cubic-bezier(0.25, 0.1, 0.25, 1) infinite;
}

.sub-info {
  display: flex;
  flex-direction: column;
}

.sub-label-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.sub-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--text-secondary);
}

.sub-live-dot {
  width: 6px;
  height: 6px;
  background-color: var(--yt-red);
  border-radius: 50%;
  box-shadow: 0 0 6px var(--yt-red);
  animation: dotBlink 1.5s infinite;
}

.sub-number-wrap {
  position: relative;
  display: flex;
  align-items: baseline;
}

.sub-number {
  font-family: var(--font-main);
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: #FFFFFF;
  line-height: 1.1;
}

.sub-delta-badge {
  position: absolute;
  right: -38px;
  top: -6px;
  background: var(--emerald-green);
  color: #032B20;
  font-size: 12px;
  font-weight: 800;
  padding: 2px 7px;
  border-radius: 8px;
  opacity: 0;
  transform: translateY(8px) scale(0.7);
  pointer-events: none;
}

.sub-delta-badge.show {
  animation: deltaFloat 2.2s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* 2. Today's Top Donation Tracker Widget */
.top-donation-widget {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 24px 12px 14px;
  background: var(--card-bg);
  backdrop-filter: var(--card-blur);
  -webkit-backdrop-filter: var(--card-blur);
  border: 1px solid var(--card-border);
  border-radius: 40px;
  box-shadow: 0 12px 35px rgba(0, 0, 0, 0.45);
  transition: all 0.3s ease;
  transform-origin: center right;
}

.top-donation-widget.record-broken {
  animation: widgetPulse 1s cubic-bezier(0.16, 1, 0.3, 1);
  border-color: var(--gold-primary);
}

.crown-icon-box {
  position: relative;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, #FFD166, #FF9E00);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 14px rgba(255, 179, 0, 0.4);
  flex-shrink: 0;
}

.crown-icon-box svg {
  width: 24px;
  height: 24px;
  fill: #4D2D00;
}

.top-donation-info {
  display: flex;
  flex-direction: column;
}

.top-donation-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--gold-primary);
}

.top-donor-details {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.top-donor-name {
  font-size: 18px;
  font-weight: 700;
  color: #FFFFFF;
  max-width: 140px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.top-donor-amount {
  font-family: var(--font-mono);
  font-size: 20px;
  font-weight: 700;
  color: var(--gold-primary);
}

/* ==========================================================================
   3. Authentic YouTube Super Chat Alert Card (Upper-Middle Safe Zone)
   ========================================================================== */
.alert-container {
  position: absolute;
  top: 310px; /* Safe between top widgets and YouTube live chat comments */
  left: 50%;
  transform: translateX(-50%);
  width: 860px;
  max-width: 86vw;
  display: flex;
  flex-direction: column;
  align-items: center;
  z-index: 1000;
  pointer-events: none;
}

/* YouTube Superchat Card Container */
.yt-superchat-card {
  position: relative;
  width: 100%;
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.8), 0 2px 10px rgba(0, 0, 0, 0.5);
  font-family: var(--font-yt);
  
  /* Initial hidden state */
  opacity: 0;
  transform: translateY(-30px) scale(0.95);
  transition: none;
}

/* Entrance and Exit Animations */
.yt-superchat-card.alert-enter {
  animation: superChatPopIn 0.55s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.yt-superchat-card.alert-exit {
  animation: superChatPopOut 0.45s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

/* Superchat Header */
.sc-header {
  padding: 18px 24px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.sc-avatar {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  font-weight: 800;
  color: #FFF;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.sc-header-details {
  display: flex;
  flex-direction: column;
  flex-grow: 1;
}

.sc-donor-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.sc-donor-name {
  font-size: 20px;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.95);
  max-width: 500px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sc-superchat-tag {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.85);
  background: rgba(0, 0, 0, 0.2);
  padding: 3px 10px;
  border-radius: 12px;
}

.sc-amount-val {
  font-size: 24px;
  font-weight: 800;
  color: #FFFFFF;
  margin-top: 2px;
}

/* Superchat Body */
.sc-body {
  padding: 18px 24px;
  font-size: 20px;
  font-weight: 500;
  line-height: 1.45;
  color: #FFFFFF;
  word-break: break-word;
}

/* Super Chat Color Tiers */
.sc-tier-blue .sc-header { background-color: #1565C0; }
.sc-tier-blue .sc-body { background-color: #1E88E5; }

.sc-tier-cyan .sc-header { background-color: #00838F; }
.sc-tier-cyan .sc-body { background-color: #00ACC1; }

.sc-tier-green .sc-header { background-color: #00695C; }
.sc-tier-green .sc-body { background-color: #00897B; }

.sc-tier-yellow .sc-header { background-color: #E65100; color: #FFF; }
.sc-tier-yellow .sc-body { background-color: #FFB300; color: #1E1E1E; font-weight: 600; }

.sc-tier-orange .sc-header { background-color: #C2185B; }
.sc-tier-orange .sc-body { background-color: #E91E63; }

.sc-tier-red .sc-header { background-color: #B71C1C; }
.sc-tier-red .sc-body { background-color: #D32F2F; }

.sc-tier-sub .sc-header { background-color: #CC0000; }
.sc-tier-sub .sc-body { background-color: #1E1E1E; color: #FFF; border-top: 1px solid rgba(255, 255, 255, 0.1); }

/* Progress Bar */
.alert-progress-bar-wrap {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 4px;
  background: rgba(0, 0, 0, 0.3);
}

.alert-progress-bar {
  width: 100%;
  height: 100%;
  background: #FFFFFF;
  opacity: 0.85;
  transform-origin: left center;
  transform: scaleX(1);
}

/* ==========================================================================
   Responsive Scaling for 9:16 Vertical Screen (1080x1920)
   ========================================================================== */
@media (max-aspect-ratio: 1/1), (max-width: 1080px) and (orientation: portrait) {
  .stream-top-bar {
    top: 150px;
    padding: 0 40px;
  }

  .sub-count-widget, .top-donation-widget {
    padding: 14px 26px 14px 16px;
    border-radius: 50px;
    border-width: 1.5px;
  }

  .yt-icon-box, .crown-icon-box {
    width: 52px;
    height: 52px;
  }

  .yt-icon-box svg, .crown-icon-box svg {
    width: 28px;
    height: 28px;
  }

  .sub-label, .top-donation-label {
    font-size: 13px;
  }

  .sub-number {
    font-size: 36px;
  }

  .top-donor-name {
    font-size: 22px;
    max-width: 160px;
  }

  .top-donor-amount {
    font-size: 26px;
  }

  .alert-container {
    top: 320px;
    width: 900px;
    max-width: 88vw;
  }

  .sc-donor-name {
    font-size: 24px;
  }

  .sc-amount-val {
    font-size: 28px;
  }

  .sc-body {
    font-size: 22px;
  }
}

/* Landscape Mode (16:9) Fallback */
body.aspect-landscape .stream-top-bar {
  top: 36px;
  padding: 0 48px;
}

body.aspect-landscape .alert-container {
  top: 140px;
  width: 580px;
  max-width: 90vw;
}

/* ==========================================================================
   Animations
   ========================================================================== */
@keyframes superChatPopIn {
  0% {
    opacity: 0;
    transform: translateY(-40px) scale(0.92);
  }
  70% {
    opacity: 1;
    transform: translateY(6px) scale(1.02);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes superChatPopOut {
  0% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
  100% {
    opacity: 0;
    transform: translateY(-30px) scale(0.95);
  }
}

@keyframes widgetPulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.05); }
  100% { transform: scale(1); }
}

@keyframes liveRingPulse {
  0% {
    transform: scale(1);
    opacity: 0.7;
  }
  60% {
    transform: scale(1.3);
    opacity: 0;
  }
  100% {
    transform: scale(1);
    opacity: 0;
  }
}

@keyframes deltaFloat {
  0% {
    opacity: 0;
    transform: translateY(8px) scale(0.7);
  }
  20% {
    opacity: 1;
    transform: translateY(-2px) scale(1.05);
  }
  75% {
    opacity: 1;
    transform: translateY(-12px) scale(1);
  }
  100% {
    opacity: 0;
    transform: translateY(-22px) scale(0.85);
  }
}

@keyframes dotBlink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}
