/*
 * PARKSY BROADCAST - Premium Election Style
 * Award-winning level UI design
 */

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

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  /* Premium Color Palette */
  --primary: #6366f1;
  --primary-dark: #4f46e5;
  --primary-light: #818cf8;
  --secondary: #f59e0b;
  --secondary-dark: #d97706;
  --accent: #22d3ee;
  --accent-glow: rgba(34, 211, 238, 0.5);

  /* Dark Theme */
  --bg-deep: #030712;
  --bg-dark: #0f172a;
  --bg-card: rgba(15, 23, 42, 0.8);
  --bg-glass: rgba(255, 255, 255, 0.03);
  --bg-glass-border: rgba(255, 255, 255, 0.08);

  /* Text */
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  /* Status */
  --live-red: #ef4444;
  --success: #10b981;
  --warning: #f59e0b;

  /* Gradients */
  --gradient-primary: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #d946ef 100%);
  --gradient-accent: linear-gradient(135deg, #22d3ee 0%, #6366f1 100%);
  --gradient-gold: linear-gradient(135deg, #f59e0b 0%, #fbbf24 50%, #f59e0b 100%);
  --gradient-dark: linear-gradient(180deg, #0f172a 0%, #030712 100%);

  /* Effects */
  --shadow-glow: 0 0 40px rgba(99, 102, 241, 0.3);
  --shadow-card: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
  --shadow-text: 0 2px 10px rgba(0, 0, 0, 0.5);

  /* Timing */
  --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in-out: cubic-bezier(0.4, 0, 0.2, 1);
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg-deep);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ========== 16:9 브로드캐스트 스크린 ========== */
#broadcast-screen {
  position: relative;
  width: 100vw;
  height: 56.25vw;
  max-height: 100vh;
  max-width: 177.78vh;
  margin: auto;
  background: var(--gradient-dark);
  overflow: hidden;
  box-shadow: var(--shadow-glow);
}

/* Animated background grid */
#broadcast-screen::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(99, 102, 241, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(99, 102, 241, 0.03) 1px, transparent 1px);
  background-size: 50px 50px;
  animation: gridMove 20s linear infinite;
}

@keyframes gridMove {
  0% { background-position: 0 0; }
  100% { background-position: 50px 50px; }
}

/* ========== L바 상단 - Premium Glass ========== */
#l-bar-top {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 9%;
  background: linear-gradient(180deg,
    rgba(15, 23, 42, 0.95) 0%,
    rgba(15, 23, 42, 0.8) 100%);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2.5%;
  z-index: 100;
  border-bottom: 1px solid var(--bg-glass-border);
  box-shadow: 0 4px 30px rgba(0, 0, 0, 0.3);
}

#l-bar-top::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--gradient-accent);
  opacity: 0.8;
}

.program-title {
  font-size: 2.8vw;
  font-weight: 800;
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: 0.05em;
  text-shadow: var(--shadow-text);
  position: relative;
}

.program-title::after {
  content: '';
  position: absolute;
  bottom: -4px;
  left: 0;
  width: 60%;
  height: 2px;
  background: var(--gradient-gold);
  border-radius: 1px;
}

.live-badge {
  display: flex;
  align-items: center;
  gap: 0.5vw;
  background: linear-gradient(135deg, var(--live-red) 0%, #dc2626 100%);
  color: white;
  padding: 0.6vw 1.8vw;
  border-radius: 6px;
  font-weight: 700;
  font-size: 1.4vw;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  box-shadow:
    0 0 20px rgba(239, 68, 68, 0.5),
    0 4px 15px rgba(239, 68, 68, 0.3);
  animation: livePulse 2s ease-in-out infinite;
}

.live-badge::before {
  content: '';
  width: 0.8vw;
  height: 0.8vw;
  background: white;
  border-radius: 50%;
  animation: liveDot 1s ease-in-out infinite;
}

@keyframes livePulse {
  0%, 100% {
    box-shadow:
      0 0 20px rgba(239, 68, 68, 0.5),
      0 4px 15px rgba(239, 68, 68, 0.3);
  }
  50% {
    box-shadow:
      0 0 30px rgba(239, 68, 68, 0.7),
      0 4px 20px rgba(239, 68, 68, 0.5);
  }
}

@keyframes liveDot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.8); }
}

.clock {
  font-size: 2.2vw;
  font-weight: 600;
  font-family: 'JetBrains Mono', monospace;
  color: var(--accent);
  text-shadow: 0 0 20px var(--accent-glow);
  letter-spacing: 0.05em;
}

/* ========== 메인 콘텐츠 영역 ========== */
#main-content {
  position: absolute;
  top: 9%;
  left: 0;
  right: 0;
  bottom: 18%;
  display: flex;
  gap: 1px;
  background: rgba(99, 102, 241, 0.1);
}

/* 메인 영상 영역 */
#main-video {
  flex: 1;
  position: relative;
  background: var(--bg-deep);
  overflow: hidden;
}

#main-video::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center, transparent 0%, var(--bg-deep) 100%);
  pointer-events: none;
  z-index: 1;
  opacity: 0.3;
}

#main-iframe {
  width: 100%;
  height: 100%;
  border: none;
}

/* 자료화면 오버레이 */
#content-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(135deg,
    rgba(3, 7, 18, 0.97) 0%,
    rgba(15, 23, 42, 0.95) 100%);
  backdrop-filter: blur(10px);
  overflow-y: auto;
  padding: 4%;
  transition: all 0.5s var(--ease-out-expo);
  z-index: 10;
}

#content-overlay.hidden {
  opacity: 0;
  transform: scale(0.98);
  pointer-events: none;
}

#content-overlay::-webkit-scrollbar {
  width: 6px;
}

#content-overlay::-webkit-scrollbar-track {
  background: var(--bg-dark);
}

#content-overlay::-webkit-scrollbar-thumb {
  background: var(--primary);
  border-radius: 3px;
}

#scroll-content {
  max-width: 85%;
  margin: 0 auto;
}

.segment {
  margin-bottom: 5vh;
  padding: 3vh 4vh;
  background: var(--bg-glass);
  border: 1px solid var(--bg-glass-border);
  border-left: 4px solid var(--primary);
  border-radius: 12px;
  transition: all 0.3s var(--ease-in-out);
  position: relative;
  overflow: hidden;
}

.segment::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--gradient-primary);
  opacity: 0;
  transition: opacity 0.3s;
}

.segment:hover {
  border-color: var(--primary-light);
  transform: translateX(8px);
  box-shadow: var(--shadow-card);
}

.segment:hover::before {
  opacity: 0.03;
}

.segment h2 {
  font-size: 2.8vw;
  font-weight: 700;
  background: var(--gradient-accent);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 1.5vh;
  position: relative;
}

.segment-text {
  color: var(--text-secondary);
  font-size: 1.8vw;
  line-height: 1.7;
  font-weight: 400;
}

/* ========== 사이드 패널 - Glass Morphism ========== */
#side-panel {
  width: 26%;
  background: linear-gradient(180deg,
    rgba(15, 23, 42, 0.9) 0%,
    rgba(3, 7, 18, 0.95) 100%);
  backdrop-filter: blur(20px);
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--bg-glass-border);
}

/* PIP 창 */
.pip-window {
  position: relative;
  height: 38%;
  border-bottom: 1px solid var(--bg-glass-border);
  transition: all 0.5s var(--ease-out-expo);
  overflow: hidden;
}

.pip-window.hidden {
  height: 0;
  opacity: 0;
}

.pip-window::after {
  content: '';
  position: absolute;
  inset: 0;
  border: 2px solid transparent;
  border-image: var(--gradient-accent) 1;
  pointer-events: none;
  opacity: 0.5;
}

.pip-label {
  position: absolute;
  top: 8%;
  left: 5%;
  background: var(--gradient-gold);
  color: var(--bg-deep);
  padding: 0.4vw 1vw;
  font-size: 0.9vw;
  font-weight: 700;
  border-radius: 4px;
  z-index: 10;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  box-shadow: 0 4px 15px rgba(245, 158, 11, 0.4);
}

.pip-iframe {
  width: 100%;
  height: 100%;
  border: none;
}

/* 데이터 패널 */
#data-panel {
  flex: 1;
  padding: 4%;
  display: flex;
  flex-direction: column;
}

.data-title {
  font-size: 1.4vw;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 2vh;
  text-align: center;
  padding-bottom: 1.5vh;
  border-bottom: 1px solid var(--bg-glass-border);
  position: relative;
}

.data-title::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 50%;
  transform: translateX(-50%);
  width: 40%;
  height: 2px;
  background: var(--gradient-primary);
}

.data-grid {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1.2vh;
}

.data-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.5vh 1.2vw;
  background: var(--bg-glass);
  border: 1px solid var(--bg-glass-border);
  border-radius: 10px;
  transition: all 0.3s var(--ease-in-out);
}

.data-item:hover {
  background: rgba(99, 102, 241, 0.1);
  border-color: var(--primary);
  transform: scale(1.02);
}

.data-label {
  color: var(--text-muted);
  font-size: 1.1vw;
  font-weight: 500;
}

.data-value {
  font-size: 1.8vw;
  font-weight: 700;
  font-family: 'JetBrains Mono', monospace;
  background: var(--gradient-accent);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.data-value.positive {
  background: linear-gradient(135deg, #10b981, #34d399);
  -webkit-background-clip: text;
  background-clip: text;
}

.data-value.negative {
  background: linear-gradient(135deg, #ef4444, #f87171);
  -webkit-background-clip: text;
  background-clip: text;
}

/* ========== 하단 티커 - Neon Style ========== */
#ticker-bar {
  position: absolute;
  bottom: 10%;
  left: 0;
  right: 0;
  height: 5.5%;
  background: linear-gradient(90deg,
    rgba(15, 23, 42, 0.95) 0%,
    rgba(99, 102, 241, 0.1) 50%,
    rgba(15, 23, 42, 0.95) 100%);
  backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  overflow: hidden;
  border-top: 1px solid var(--primary);
  border-bottom: 1px solid var(--primary);
  box-shadow:
    0 0 20px rgba(99, 102, 241, 0.2),
    inset 0 0 30px rgba(99, 102, 241, 0.05);
}

.ticker-label {
  background: var(--gradient-primary);
  color: white;
  padding: 0 2.5vw;
  height: 100%;
  display: flex;
  align-items: center;
  font-weight: 800;
  font-size: 1.3vw;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  flex-shrink: 0;
  clip-path: polygon(0 0, 90% 0, 100% 50%, 90% 100%, 0 100%);
  padding-right: 3vw;
  box-shadow: 4px 0 20px rgba(99, 102, 241, 0.5);
}

.ticker-content {
  flex: 1;
  overflow: hidden;
  white-space: nowrap;
  mask-image: linear-gradient(90deg, transparent, white 5%, white 95%, transparent);
}

#ticker-text {
  display: inline-block;
  color: var(--text-primary);
  font-size: 1.4vw;
  font-weight: 500;
  animation: tickerScroll 25s linear infinite;
  padding-left: 100%;
}

@keyframes tickerScroll {
  0% { transform: translateX(0); }
  100% { transform: translateX(-100%); }
}

/* ========== 자막 영역 - Premium Style ========== */
#caption-bar {
  position: absolute;
  bottom: 4%;
  left: 2%;
  right: 2%;
  display: flex;
  align-items: center;
  gap: 1.2vw;
  transition: all 0.4s var(--ease-out-expo);
}

#caption-bar.hidden {
  opacity: 0;
  transform: translateY(20px);
}

.speaker-name {
  background: var(--gradient-primary);
  color: white;
  padding: 1vh 2vw;
  font-size: 1.4vw;
  font-weight: 700;
  border-radius: 8px;
  flex-shrink: 0;
  box-shadow:
    0 4px 20px rgba(99, 102, 241, 0.4),
    0 0 0 1px rgba(255, 255, 255, 0.1) inset;
  position: relative;
  overflow: hidden;
}

.speaker-name::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
  animation: shimmer 2s infinite;
}

@keyframes shimmer {
  100% { left: 100%; }
}

.caption-text {
  flex: 1;
  background: linear-gradient(135deg,
    rgba(3, 7, 18, 0.9) 0%,
    rgba(15, 23, 42, 0.85) 100%);
  backdrop-filter: blur(10px);
  color: var(--text-primary);
  padding: 1.2vh 2.5vw;
  font-size: 1.7vw;
  font-weight: 500;
  border-radius: 8px;
  border: 1px solid var(--bg-glass-border);
  border-left: 4px solid var(--accent);
  box-shadow: var(--shadow-card);
}

/* ========== 타임라인 바 - Modern Progress ========== */
#timeline-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 4%;
  background: var(--bg-deep);
  border-top: 1px solid var(--bg-glass-border);
}

.timeline-progress {
  height: 35%;
  background: var(--gradient-accent);
  width: 0%;
  transition: width 0.5s var(--ease-in-out);
  position: relative;
  box-shadow: 0 0 20px var(--accent-glow);
}

.timeline-progress::after {
  content: '';
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 12px;
  height: 12px;
  background: var(--accent);
  border-radius: 50%;
  box-shadow: 0 0 15px var(--accent);
}

.timeline-markers {
  height: 65%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 2%;
}

.timeline-markers span {
  color: var(--text-muted);
  font-size: 0.95vw;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s var(--ease-in-out);
  padding: 0.3vh 0.8vw;
  border-radius: 4px;
}

.timeline-markers span:hover {
  color: var(--accent);
  background: rgba(34, 211, 238, 0.1);
}

.timeline-markers span.active {
  color: var(--accent);
  font-weight: 700;
  text-shadow: 0 0 10px var(--accent-glow);
}

/* ========== 컨트롤 패널 - Floating Glass ========== */
#control-panel {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 8px;
  background: rgba(15, 23, 42, 0.9);
  backdrop-filter: blur(20px);
  padding: 12px 24px;
  border-radius: 16px;
  border: 1px solid var(--bg-glass-border);
  box-shadow: var(--shadow-card);
  z-index: 9999;
}

#control-panel button {
  background: var(--bg-glass);
  color: var(--text-primary);
  border: 1px solid var(--bg-glass-border);
  padding: 10px 20px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s var(--ease-in-out);
  font-family: 'Inter', sans-serif;
}

#control-panel button:hover {
  background: var(--primary);
  border-color: var(--primary);
  transform: translateY(-2px);
  box-shadow: 0 4px 20px rgba(99, 102, 241, 0.4);
}

#control-panel button:active {
  transform: translateY(0);
}

body.record-mode #control-panel {
  display: none;
}

/* ========== 전환 효과 ========== */
.fade-in {
  animation: fadeIn 0.5s var(--ease-out-expo);
}

.slide-in-right {
  animation: slideInRight 0.5s var(--ease-out-expo);
}

.scale-in {
  animation: scaleIn 0.4s var(--ease-out-expo);
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideInRight {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

@keyframes scaleIn {
  from { transform: scale(0.9); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

/* ========== 반응형 ========== */
@media (orientation: portrait) {
  #broadcast-screen {
    width: 100vw;
    height: 56.25vw;
  }
}

@media (orientation: landscape) {
  #broadcast-screen {
    width: 177.78vh;
    height: 100vh;
  }
}

/* ========== 스크롤바 전역 ========== */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg-deep);
}

::-webkit-scrollbar-thumb {
  background: var(--primary);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--primary-light);
}
