<script setup lang="ts">
import { useHead } from '@unhead/vue';
import { computed } from 'vue';
import { commentaryReplicant } from '../../browser_shared/replicants';
import type { Schemas } from '../../types';

useHead({ title: 'Commentary' });

const defaultCommentary: Schemas.Commentary = {
  leftCommentator: '',
  rightCommentator: '',
};

const commentary = computed<Schemas.Commentary>(() => commentaryReplicant?.data ?? defaultCommentary);

const leftCommentator = computed(() => commentary.value.leftCommentator || 'COMMENTATOR 1');
const rightCommentator = computed(() => commentary.value.rightCommentator || 'COMMENTATOR 2');
</script>

<template>
  <div id="commentary-overlay">
    <div class="bar bar-left">
      <div class="bar-glow" />
      <div class="label">
        COMMENTARY
      </div>
      <div class="name">
        {{ leftCommentator }}
      </div>
    </div>

    <div class="center-divider">
      <div class="divider-core">
        VS
      </div>
    </div>

    <div class="bar bar-right">
      <div class="bar-glow" />
      <div class="label">
        COMMENTARY
      </div>
      <div class="name">
        {{ rightCommentator }}
      </div>
    </div>
  </div>
</template>

<style scoped>
:global(body) {
  margin: 0;
  background: transparent;
  overflow: hidden;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

#commentary-overlay {
  position: fixed;
  left: 50%;
  bottom: 56px;
  transform: translateX(-50%);
  width: min(1480px, calc(100vw - 80px));
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: end;
  gap: 20px;
  pointer-events: none;
}

.bar {
  position: relative;
  height: 82px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 10px 28px;
  border: 2px solid rgba(255, 255, 255, 0.42);
  overflow: hidden;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.32),
    inset 0 -1px 0 rgba(0, 0, 0, 0.45),
    0 8px 24px rgba(0, 0, 0, 0.45);
}

.bar::after {
  content: '';
  position: absolute;
  inset: 0;
  opacity: 0.35;
  background: repeating-linear-gradient(
    135deg,
    transparent 0,
    transparent 12px,
    rgba(255, 255, 255, 0.11) 12px,
    rgba(255, 255, 255, 0.11) 15px
  );
}

.bar-left {
  clip-path: polygon(0 0, 100% 0, calc(100% - 60px) 100%, 0 100%);
  background: linear-gradient(106deg, #20174a 0%, #42246f 45%, #6e3b9b 100%);
}

.bar-right {
  text-align: right;
  clip-path: polygon(60px 0, 100% 0, 100% 100%, 0 100%);
  background: linear-gradient(254deg, #430f33 0%, #7a214f 42%, #b53b58 100%);
}

.bar-glow {
  position: absolute;
  top: -20px;
  left: 0;
  right: 0;
  height: 26px;
  background: radial-gradient(circle at 50% 100%, rgba(255, 255, 255, 0.95), rgba(255, 255, 255, 0));
  opacity: 0.45;
}

.label,
.name {
  position: relative;
  z-index: 1;
  color: #f4f7ff;
  text-shadow:
    0 0 8px rgba(0, 0, 0, 0.65),
    0 1px 0 rgba(0, 0, 0, 0.7);
}

.label {
  font-size: 13px;
  letter-spacing: 0.24em;
  opacity: 0.8;
  font-weight: 700;
  margin-bottom: 4px;
}

.name {
  font-size: 35px;
  line-height: 1;
  font-weight: 900;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
  text-transform: uppercase;
}

.center-divider {
  position: relative;
  width: 84px;
  height: 84px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(circle, rgba(255, 255, 255, 0.22) 0%, rgba(255, 255, 255, 0.06) 55%, rgba(255, 255, 255, 0) 70%),
    conic-gradient(from 20deg, #5bd8ff, #cb6cff, #ff726b, #ffd05f, #5bd8ff);
  box-shadow:
    0 0 26px rgba(150, 120, 255, 0.5),
    0 0 40px rgba(130, 80, 255, 0.3);
}

.divider-core {
  width: 62px;
  height: 62px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #eef3ff;
  font-size: 24px;
  font-weight: 900;
  letter-spacing: 0.12em;
  background: radial-gradient(circle, #1b1e2d 0%, #0f111b 82%);
  border: 1px solid rgba(255, 255, 255, 0.35);
}
</style>
