/*
  Cyberpunk 2077 Style Stream Overlay + Chat for Owncast
  Apply as Custom CSS in OBS Browser Source

  URL: [Your_Owncast_URL]/embed/chat/readonly
  Size: 2048x576

  Inspired by CD Projekt Red's Cyberpunk 2077 UI
  Colors: #fcee0a (Kiroshi Yellow), #00f0ff (NetWatch Cyan), #fc0a54 (Trauma Red)
*/

/* Import Rajdhani - closest to CP2077's Blender Pro */
@import url('https://fonts.googleapis.com/css2?family=Rajdhani:wght@500;600;700&family=Orbitron:wght@700&display=swap');

/* Cyberway Riders - jagged cyberpunk font for spoiler warning */
@font-face {
  font-family: 'Cyberway Riders';
  src: url('https://get.fontspace.co/webfont/lg97d/OGNhMDVjZTA2M2VmNDZhNTk4Y2IzZTBiZGUxOTdlZDkub3Rm/cyberway-riders.otf') format('opentype');
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

/* Ticker scroll animation for spoiler warning */
@keyframes ticker-scroll {
  0% {
    top: 110%;
  }
  100% {
    top: -300%;
  }
}

/* ============================================
   BASE SETUP
   ============================================ */

html, body {
  width: 2048px !important;
  height: 576px !important;
  background: rgba(0,0,0,0) !important;
  background-color: rgba(0,0,0,0) !important;
  background-image: none !important;
  margin: 0 !important;
  padding: 0 !important;
  overflow: hidden !important;
  font-family: 'Rajdhani', 'Share Tech Mono', 'Consolas', monospace !important;
}

/* Kill any gradients or backgrounds from homepage CSS - but not our pseudo-elements */
html {
  background-image: none !important;
}

/* Force transparency on ALL Owncast containers */
#__next,
#root,
[class*="App"],
[class*="app"],
[class*="Layout"],
[class*="layout"],
[class*="Wrapper"],
[class*="wrapper"],
[class*="Container"]:not(#chat-container),
[class*="container"]:not(#chat-container),
[class*="Page"],
[class*="page"],
[class*="ChatContainer"],
[class*="ReadOnly"],
[class*="readonly"],
[class*="Embed"],
[class*="embed"],
main,
.ant-layout,
.ant-layout-content,
div[style*="background"] {
  background: transparent !important;
  background-color: transparent !important;
}

/* Nuclear option - catch any missed backgrounds */
*:not([class*="ChatUserMessage"]) {
  background-color: rgba(0,0,0,0) !important;
}

/* Override Owncast/Ant Design theme variables */
:root {
  --theme-color-background: transparent !important;
  --theme-color-background-main: transparent !important;
  --theme-color-palette-0: transparent !important;
  --theme-color-palette-1: transparent !important;
  --theme-color-palette-2: transparent !important;
  --theme-color-palette-3: transparent !important;
  --ant-theme-color-background: transparent !important;
  --ant-theme-color-components-chat-background: transparent !important;
}

/* Only these elements should have backgrounds */
[class*="ChatUserMessage_root"],
[class*="ChatUserMessage_ownMessage"] {
  background: rgba(0, 0, 0, 0.5) !important;
}

/* ============================================
   BORDER FRAME - Angular cuts like CP2077 UI
   ============================================ */

body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9998;
  /* Main frame with cut corners */
  clip-path: polygon(
    /* Top-left cut */ 0 20px, 20px 0,
    /* Top edge */ calc(100% - 20px) 0,
    /* Top-right cut */ 100% 20px,
    /* Right edge */ 100% calc(100% - 20px),
    /* Bottom-right cut */ calc(100% - 20px) 100%,
    /* Bottom edge */ 20px 100%,
    /* Bottom-left cut */ 0 calc(100% - 20px)
  );
  border: 2px solid;
  border-image: linear-gradient(
    135deg,
    #fcee0a 0%,
    #00f0ff 30%,
    #00f0ff 70%,
    #fc0a54 100%
  ) 1;
  box-shadow:
    inset 0 0 50px rgba(252, 238, 10, 0.03),
    0 0 20px rgba(0, 240, 255, 0.15);
}

/* Spoiler ticker - scrolling vertically on left edge */
body::after {
  content: '◆ WARNING: SPOILERS ◆ WARNING: SPOILERS ◆ WARNING: SPOILERS ◆ WARNING: SPOILERS ◆ WARNING: SPOILERS ◆';
  position: fixed;
  left: 6px;
  top: 0;
  font-family: 'Orbitron', 'Rajdhani', monospace;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 3px;
  color: #fc0a54;
  text-shadow: 0 0 10px rgba(252, 10, 84, 0.6);
  white-space: nowrap;
  z-index: 9999;
  pointer-events: none;
  /* Rotate to run vertically along left edge */
  writing-mode: vertical-rl;
  text-orientation: mixed;
  transform: rotate(180deg);
  /* Animate scrolling - slow crawl */
  animation: ticker-scroll 50s linear infinite;
}

/* ============================================
   CHAT CONTAINER - Flat, wide, angular
   ============================================ */

#chat-container {
  position: fixed !important;
  bottom: 6px !important;
  right: 6px !important;
  width: 480px !important;
  height: 130px !important;
  background: transparent !important;
  background-color: transparent !important;
  border: none !important;
  border-left: 3px solid #fcee0a !important;
  border-top: 1px solid rgba(0, 240, 255, 0.3) !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;
  /* Angular cut on top-left corner */
  clip-path: polygon(
    20px 0,
    100% 0,
    100% 100%,
    0 100%,
    0 20px
  ) !important;
  /* Chromatic aberration edge glow - CP2077 style */
  box-shadow:
    -4px 0 15px rgba(252, 238, 10, 0.15),
    -2px 0 0 rgba(255, 0, 80, 0.2),
    2px 0 0 rgba(0, 240, 255, 0.15) !important;
}

/* Angular cut accent line */
#chat-container::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 28px;
  height: 28px;
  border-top: 1px solid #fcee0a;
  border-left: 1px solid #fcee0a;
  transform: rotate(45deg) translate(-10px, 10px);
  z-index: 100;
  pointer-events: none;
}

/* Status bar above chat - styled like CP2077 objective tracker */
#chat-container::after {
  content: '◈ LIVE.FEED" //STREAM.ACTIVE';
  position: absolute;
  top: -14px;
  left: 25px;
  font-size: 8px;
  letter-spacing: 2px;
  color: #fcee0a;
  text-transform: uppercase;
  z-index: 100;
  text-shadow: 0 0 10px rgba(252, 238, 10, 0.5);
  font-weight: 600;
  font-family: 'Rajdhani', monospace;
}

/* ============================================
   DECORATIVE ELEMENTS
   ============================================ */

/* Red warning accent - top right */
html::before {
  content: '';
  position: fixed;
  top: 6px;
  right: 100px;
  width: 60px;
  height: 3px;
  background: #fc0a54;
  box-shadow: 0 0 15px #fc0a54;
  pointer-events: none;
  z-index: 9999;
  clip-path: polygon(3px 0, 100% 0, calc(100% - 3px) 100%, 0 100%);
}

/* Status block - top right - styled like CP2077 HUD */
html::after {
  content: '◆ REC';
  position: fixed;
  top: 4px;
  right: 25px;
  font-size: 10px;
  letter-spacing: 3px;
  color: #fc0a54;
  font-weight: 700;
  z-index: 9999;
  pointer-events: none;
  text-shadow: 0 0 15px #fc0a54;
  animation: live-pulse 1.5s ease-in-out infinite;
  font-family: 'Orbitron', 'Rajdhani', monospace;
}

/* ============================================
   CORNER BRACKETS - CP2077 targeting UI style
   ============================================ */

/* Top-left corner bracket */
body {
  position: relative;
}

/* Top-left version tag like CP2077 - moved to #virtuoso::after */
#virtuoso::after {
  content: 'v2.13.77';
  position: fixed;
  top: 8px;
  left: 12px;
  font-size: 8px;
  letter-spacing: 1px;
  color: rgba(252, 238, 10, 0.5);
  font-family: 'Orbitron', monospace;
  z-index: 9999;
  pointer-events: none;
}

/* Bottom-left data readout - moved to chat container label area */
/* (Removed to avoid pseudo-element conflicts - spoiler warning takes priority) */

@keyframes live-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* ============================================
   SCANLINE OVERLAY - Applied to chat background
   (Using background-image instead of ::before to avoid conflict)
   ============================================ */

#chat-container {
  background-image:
    repeating-linear-gradient(
      0deg,
      transparent 0px,
      transparent 3px,
      rgba(0, 0, 0, 0.08) 3px,
      rgba(0, 0, 0, 0.08) 6px
    ),
    linear-gradient(
      180deg,
      rgba(8, 8, 12, 0.92) 0%,
      rgba(5, 5, 8, 0.88) 100%
    ) !important;
}

/* ============================================
   GLITCH FLICKER - Relic malfunction style
   ============================================ */

@keyframes relic-glitch {
  0%, 100% {
    clip-path: inset(0 0 0 0);
    transform: translate(0);
  }
  92% {
    clip-path: inset(0 0 0 0);
    transform: translate(0);
  }
  93% {
    clip-path: inset(40% 0 20% 0);
    transform: translate(-2px, 1px);
    filter: hue-rotate(90deg);
  }
  94% {
    clip-path: inset(10% 0 60% 0);
    transform: translate(2px, -1px);
  }
  95% {
    clip-path: inset(0 0 0 0);
    transform: translate(0);
    filter: hue-rotate(0deg);
  }
  97% {
    clip-path: inset(80% 0 5% 0);
    transform: translate(-1px, 0);
  }
  98% {
    clip-path: inset(0 0 0 0);
    transform: translate(0);
  }
}

/* ============================================
   DATA CORRUPTION BARS - Random interference
   ============================================ */

@keyframes data-stream {
  0%, 100% { transform: translateX(-100%); opacity: 0; }
  10% { opacity: 0.6; }
  50% { transform: translateX(100%); opacity: 0.6; }
  60% { opacity: 0; }
}

/* Glitch disabled - too distracting
body::before {
  animation: relic-glitch 8s ease-in-out infinite !important;
}
*/

/* ============================================
   SCROLLBAR - Minimal, angular
   ============================================ */

#chat-container::-webkit-scrollbar {
  width: 2px !important;
}

#chat-container::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.3) !important;
}

#chat-container::-webkit-scrollbar-thumb {
  background: #fcee0a !important;
}

/* ============================================
   MESSAGE ANIMATIONS - Glitchy entrance
   ============================================ */

@keyframes glitch-in {
  0% {
    opacity: 0;
    transform: translateX(20px) skewX(-2deg);
    filter: hue-rotate(90deg);
  }
  3% {
    opacity: 0.8;
    transform: translateX(-3px) skewX(1deg);
  }
  6% {
    opacity: 1;
    transform: translateX(0) skewX(0);
    filter: hue-rotate(0deg);
  }
  80% {
    opacity: 1;
  }
  100% {
    opacity: 0;
  }
}

/* Random glitch flicker */
@keyframes data-flicker {
  0%, 97%, 100% { opacity: 1; }
  97.5% { opacity: 0.8; transform: translateX(-1px); }
  98% { opacity: 1; }
  98.5% { opacity: 0.6; }
  99% { opacity: 1; }
}

/* ============================================
   CHAT MESSAGES - Targeting Owncast CSS modules
   Classes compile to: ChatUserMessage_root__xxxxx
   ============================================ */

/* Message wrapper - the padding container */
[class*="ChatUserMessage_messagePadding"],
[class*="messagePadding"] {
  padding: 0 !important;
  margin: 0 !important;
}

/* Message root container */
[class*="ChatUserMessage_root"],
[class*="ChatUserMessage_ownMessage"] {
  background: rgba(0, 0, 0, 0.5) !important;
  border: none !important;
  border-left: 2px solid #fcee0a !important;
  border-radius: 0 !important;
  margin: 2px 8px 2px 12px !important;
  padding: 4px 8px !important;
  /* Animation disabled for debugging */
  opacity: 1 !important;
  position: relative;
}

/* Simpler fade animation */
@keyframes simple-fade {
  0% { opacity: 0; }
  5% { opacity: 1; }
  85% { opacity: 1; }
  100% { opacity: 0; }
}

/* Alternating accent colors */
[class*="ChatUserMessage_root"]:nth-child(3n) {
  border-left-color: #00f0ff !important;
}

[class*="ChatUserMessage_root"]:nth-child(3n+2) {
  border-left-color: #fc0a54 !important;
}

/* Hide the colored background div Owncast adds */
[class*="ChatUserMessage_background"] {
  display: none !important;
}

/* ============================================
   USERNAME - Yellow CP2077 style
   ============================================ */

[class*="ChatUserMessage_user"],
[class*="ChatUserMessage_userName"],
[class*="userName"] {
  color: #fcee0a !important;
  text-shadow: 0 0 6px rgba(252, 238, 10, 0.3) !important;
  font-weight: 700 !important;
  font-size: 10px !important;
  letter-spacing: 1px !important;
  text-transform: uppercase !important;
  font-family: 'Rajdhani', 'Share Tech Mono', 'Consolas', monospace !important;
}

/* Repeated user (same person, consecutive) - dim it */
[class*="ChatUserMessage_repeatUser"] {
  opacity: 0.5 !important;
}

/* User badges */
[class*="ChatUserMessage_userBadges"] {
  filter: hue-rotate(20deg) saturate(1.5) !important;
}

/* ============================================
   MESSAGE TEXT - Clean, readable
   ============================================ */

[class*="ChatUserMessage_message"] {
  color: rgba(255, 255, 255, 0.95) !important;
  font-size: 11px !important;
  line-height: 1.3 !important;
  font-weight: 500 !important;
  font-family: 'Rajdhani', 'Share Tech Mono', 'Consolas', monospace !important;
}

/* Links in messages - cyan */
[class*="ChatUserMessage_message"] a {
  color: #00f0ff !important;
  text-decoration: none !important;
  font-weight: 600 !important;
}

[class*="ChatUserMessage_message"] a:hover {
  text-shadow: 0 0 8px #00f0ff !important;
}

/* ============================================
   SYSTEM MESSAGES / ACTIONS
   ============================================ */

[class*="ChatAction"],
[class*="ChatSystemMessage"],
[class*="ChatNotification"] {
  color: #fc0a54 !important;
  font-size: 9px !important;
  text-transform: uppercase !important;
  letter-spacing: 1px !important;
  border-left: 2px solid #fc0a54 !important;
  background: rgba(252, 10, 84, 0.1) !important;
  padding: 3px 8px !important;
  margin: 2px 8px !important;
}

/* ============================================
   EMOTES & IMAGES
   ============================================ */

[class*="ChatUserMessage"] img {
  filter: saturate(1.2) drop-shadow(0 0 2px rgba(0, 240, 255, 0.3)) !important;
}
