
@import url('https://fonts.googleapis.com/css2?family=Share+Tech+Mono&family=Orbitron:wght@400;700;900&family=Rajdhani:wght@300;400;600;700&display=swap');

:root {
  --bg-deep:       #020b18;
  --bg-dark:       #040f1f;
  --bg-panel:      #071428;
  --bg-card:       #091830;
  --cyan:          #00f5ff;
  --cyan-dim:      #0099aa;
  --cyan-glow:     rgba(0, 245, 255, 0.15);
  --green:         #39ff14;
  --green-dim:     #1a7a08;
  --green-glow:    rgba(57, 255, 20, 0.12);
  --magenta:       #ff0090;
  --magenta-glow:  rgba(255, 0, 144, 0.15);
  --orange:        #ff6b00;
  --orange-glow:   rgba(255, 107, 0, 0.15);
  --yellow:        #ffe600;
  --text-bright:   #e8f4fd;
  --text-mid:      #7ab3cc;
  --text-dim:      #3a6070;
  --border:        rgba(0, 245, 255, 0.15);
  --border-bright: rgba(0, 245, 255, 0.5);
  --font-display:  'Orbitron', monospace;
  --font-ui:       'Rajdhani', sans-serif;
  --font-mono:     'Share Tech Mono', monospace;
}

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

html, body {
  width: 100%;
  min-height: 100vh;
  background: var(--bg-deep);
  color: var(--text-bright);
  font-family: var(--font-ui);
  overflow-x: hidden;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    radial-gradient(ellipse 80% 40% at 20% 10%, rgba(0,245,255,0.05) 0%, transparent 60%),
    radial-gradient(ellipse 60% 50% at 80% 90%, rgba(255,0,144,0.04) 0%, transparent 60%),
    linear-gradient(rgba(0,245,255,0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0,245,255,0.03) 1px, transparent 1px);
  background-size: 100% 100%, 100% 100%, 40px 40px, 40px 40px;
  pointer-events: none;
  z-index: 0;
}

#network-canvas {
  position: fixed;
  inset: 0;
  z-index: 0;
  opacity: 0.35;
  pointer-events: none;
}

#app-header {
  position: relative;
  z-index: 10;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(0,245,255,0.06) 0%, transparent 100%);
  flex-wrap: wrap;
  gap: 10px;
}

#app-header::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--cyan), var(--magenta), transparent);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.header-logo {
  width: 42px;
  height: 42px;
  flex-shrink: 0;
}

.header-title h1 {
  font-family: var(--font-display);
  font-size: 1.1em;
  font-weight: 900;
  letter-spacing: 0.08em;
  color: var(--cyan);
  text-shadow: 0 0 20px var(--cyan), 0 0 40px rgba(0,245,255,0.4);
  line-height: 1.1;
}

.header-title p {
  font-family: var(--font-mono);
  font-size: 0.68em;
  color: var(--text-dim);
  letter-spacing: 0.15em;
  margin-top: 2px;
}

.header-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 0.72em;
  color: var(--green);
  letter-spacing: 0.1em;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 8px var(--green), 0 0 16px var(--green);
  animation: pulse-dot 2s ease-in-out infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.85); }
}

#blockly-container {
  position: relative;
  z-index: 5;
}

#blocklyDiv {
  width: 100%;
  height: 420px;
  border-bottom: 1px solid var(--border);
}

#toolbar {
  position: relative;
  z-index: 10;
  background: var(--bg-panel);
  padding: 10px 20px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  border-bottom: 1px solid var(--border);
}


.btn-uiverse-cyan {
  --c-color-1: rgba(0, 245, 255, 0.7);
  --c-color-2: #0044ff;
  --c-color-3: #00aaff;
  --c-color-4: rgba(0, 200, 255, 0.8);
  --c-shadow: rgba(0, 245, 255, 0.4);
  --c-shadow-inset-top: rgba(0, 245, 255, 0.8);
  --c-shadow-inset-bottom: rgba(180, 255, 255, 0.6);
  --c-radial-inner: #00c8e8;
  --c-radial-outer: #004466;
  --c-color: #ffffff;
  --duration: 7s;
  --easing: linear;
  -webkit-tap-highlight-color: transparent;
  -webkit-appearance: none;
  outline: none;
  position: relative;
  cursor: pointer;
  border: none;
  display: table;
  border-radius: 24px;
  padding: 0;
  margin: 0;
  text-align: center;
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.06em;
  line-height: 1.5;
  color: var(--c-color);
  background: radial-gradient(circle, var(--c-radial-inner), var(--c-radial-outer) 80%);
  box-shadow: 0 0 14px var(--c-shadow);
  font-family: var(--font-display);
}


.btn-uiverse-magenta {
  --c-color-1: rgba(255, 0, 144, 0.7);
  --c-color-2: #6600ff;
  --c-color-3: #ff00cc;
  --c-color-4: rgba(255, 100, 200, 0.8);
  --c-shadow: rgba(255, 0, 144, 0.4);
  --c-shadow-inset-top: rgba(255, 0, 144, 0.8);
  --c-shadow-inset-bottom: rgba(255, 180, 230, 0.6);
  --c-radial-inner: #cc0077;
  --c-radial-outer: #330033;
  --c-color: #ffffff;
  --duration: 7s;
  --easing: linear;
  -webkit-tap-highlight-color: transparent;
  -webkit-appearance: none;
  outline: none;
  position: relative;
  cursor: pointer;
  border: none;
  display: table;
  border-radius: 24px;
  padding: 0;
  margin: 0;
  text-align: center;
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.06em;
  line-height: 1.5;
  color: var(--c-color);
  background: radial-gradient(circle, var(--c-radial-inner), var(--c-radial-outer) 80%);
  box-shadow: 0 0 14px var(--c-shadow);
  font-family: var(--font-display);
}


.btn-uiverse-red {
  --c-color-1: rgba(255, 60, 0, 0.7);
  --c-color-2: #aa0000;
  --c-color-3: #ff2200;
  --c-color-4: rgba(255, 120, 60, 0.8);
  --c-shadow: rgba(255, 50, 0, 0.4);
  --c-shadow-inset-top: rgba(255, 80, 0, 0.8);
  --c-shadow-inset-bottom: rgba(255, 180, 140, 0.6);
  --c-radial-inner: #cc2200;
  --c-radial-outer: #330a00;
  --c-color: #ffffff;
  --duration: 7s;
  --easing: linear;
  -webkit-tap-highlight-color: transparent;
  -webkit-appearance: none;
  outline: none;
  position: relative;
  cursor: pointer;
  border: none;
  display: table;
  border-radius: 24px;
  padding: 0;
  margin: 0;
  text-align: center;
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.06em;
  line-height: 1.5;
  color: var(--c-color);
  background: radial-gradient(circle, var(--c-radial-inner), var(--c-radial-outer) 80%);
  box-shadow: 0 0 14px var(--c-shadow);
  font-family: var(--font-display);
}


.btn-uiverse-cyan::before,
.btn-uiverse-magenta::before,
.btn-uiverse-red::before {
  content: "";
  pointer-events: none;
  position: absolute;
  z-index: 3;
  left: 0; top: 0; right: 0; bottom: 0;
  border-radius: 24px;
  box-shadow:
    inset 0 3px 12px var(--c-shadow-inset-top),
    inset 0 -3px 4px var(--c-shadow-inset-bottom);
}

.btn-uiverse-cyan .wrapper,
.btn-uiverse-magenta .wrapper,
.btn-uiverse-red .wrapper {
  -webkit-mask-image: -webkit-radial-gradient(white, black);
  overflow: hidden;
  border-radius: 24px;
  min-width: 120px;
  padding: 10px 0;
}

.btn-uiverse-cyan .wrapper span,
.btn-uiverse-magenta .wrapper span,
.btn-uiverse-red .wrapper span {
  display: inline-block;
  position: relative;
  z-index: 1;
}

.btn-uiverse-cyan:hover,
.btn-uiverse-magenta:hover,
.btn-uiverse-red:hover {
  --duration: 1400ms;
}


.btn-uiverse-cyan .circle,
.btn-uiverse-magenta .circle,
.btn-uiverse-red .circle {
  position: absolute;
  left: 0; top: 0;
  width: 40px; height: 40px;
  border-radius: 50%;
  filter: blur(var(--blur, 8px));
  background: var(--background, transparent);
  transform: translate(var(--x, 0), var(--y, 0)) translateZ(0);
  animation: var(--animation, none) var(--duration) var(--easing) infinite;
}

.circle.circle-1, .circle.circle-9, .circle.circle-10 { --background: var(--c-color-4); }
.circle.circle-3, .circle.circle-4 { --background: var(--c-color-2); --blur: 14px; }
.circle.circle-5, .circle.circle-6 { --background: var(--c-color-3); --blur: 16px; }
.circle.circle-2, .circle.circle-7, .circle.circle-8, .circle.circle-11, .circle.circle-12 { --background: var(--c-color-1); --blur: 12px; }

.circle.circle-1  { --x: 0;    --y: -40px; --animation: circle-1; }
.circle.circle-2  { --x: 92px; --y: 8px;   --animation: circle-2; }
.circle.circle-3  { --x: -12px;--y: -12px; --animation: circle-3; }
.circle.circle-4  { --x: 80px; --y: -12px; --animation: circle-4; }
.circle.circle-5  { --x: 12px; --y: -4px;  --animation: circle-5; }
.circle.circle-6  { --x: 56px; --y: 16px;  --animation: circle-6; }
.circle.circle-7  { --x: 8px;  --y: 28px;  --animation: circle-7; }
.circle.circle-8  { --x: 28px; --y: -4px;  --animation: circle-8; }
.circle.circle-9  { --x: 20px; --y: -12px; --animation: circle-9; }
.circle.circle-10 { --x: 64px; --y: 16px;  --animation: circle-10; }
.circle.circle-11 { --x: 4px;  --y: 4px;   --animation: circle-11; }
.circle.circle-12 { --blur: 14px; --x: 52px; --y: 4px; --animation: circle-12; }

@keyframes circle-1  { 33% { transform: translate(0px,16px) translateZ(0); }   66% { transform: translate(12px,64px) translateZ(0); } }
@keyframes circle-2  { 33% { transform: translate(80px,-10px) translateZ(0); } 66% { transform: translate(72px,-48px) translateZ(0); } }
@keyframes circle-3  { 33% { transform: translate(20px,12px) translateZ(0); }  66% { transform: translate(12px,4px) translateZ(0); } }
@keyframes circle-4  { 33% { transform: translate(76px,-12px) translateZ(0); } 66% { transform: translate(112px,-8px) translateZ(0); } }
@keyframes circle-5  { 33% { transform: translate(84px,28px) translateZ(0); }  66% { transform: translate(40px,-32px) translateZ(0); } }
@keyframes circle-6  { 33% { transform: translate(28px,-16px) translateZ(0); } 66% { transform: translate(76px,-56px) translateZ(0); } }
@keyframes circle-7  { 33% { transform: translate(8px,28px) translateZ(0); }   66% { transform: translate(20px,-60px) translateZ(0); } }
@keyframes circle-8  { 33% { transform: translate(32px,-4px) translateZ(0); }  66% { transform: translate(56px,-20px) translateZ(0); } }
@keyframes circle-9  { 33% { transform: translate(20px,-12px) translateZ(0); } 66% { transform: translate(80px,-8px) translateZ(0); } }
@keyframes circle-10 { 33% { transform: translate(68px,20px) translateZ(0); }  66% { transform: translate(100px,28px) translateZ(0); } }
@keyframes circle-11 { 33% { transform: translate(4px,4px) translateZ(0); }    66% { transform: translate(68px,20px) translateZ(0); } }
@keyframes circle-12 { 33% { transform: translate(56px,0px) translateZ(0); }   66% { transform: translate(60px,-32px) translateZ(0); } }


#templates-bar {
  position: relative;
  z-index: 10;
  background: rgba(4, 15, 31, 0.9);
  padding: 8px 20px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  border-bottom: 1px solid var(--border);
  font-size: 0.8em;
}

#templates-bar .label {
  font-family: var(--font-mono);
  color: var(--text-dim);
  letter-spacing: 0.12em;
  font-size: 0.85em;
  margin-right: 4px;
}

.tpl-btn {
  padding: 4px 12px;
  border: 1px solid var(--cyan-dim);
  border-radius: 3px;
  background: transparent;
  color: var(--cyan);
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 0.78em;
  letter-spacing: 0.06em;
  transition: all 0.15s;
  position: relative;
  overflow: hidden;
}

.tpl-btn::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--cyan);
  opacity: 0;
  transition: opacity 0.15s;
}

.tpl-btn:hover {
  border-color: var(--cyan);
  color: var(--bg-deep);
  box-shadow: 0 0 10px var(--cyan-glow);
}

.tpl-btn:hover::before { opacity: 1; }
.tpl-btn span { position: relative; z-index: 1; }


#code-section {
  position: relative;
  z-index: 10;
}

#code-header {
  background: var(--bg-panel);
  padding: 7px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border);
}

.code-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-mono);
  font-size: 0.75em;
  color: var(--text-dim);
  letter-spacing: 0.1em;
}

.code-title {
  color: var(--text-mid);
}

.live-badge {
  background: var(--green);
  color: var(--bg-deep);
  padding: 2px 8px;
  border-radius: 2px;
  font-family: var(--font-display);
  font-size: 0.7em;
  font-weight: 700;
  letter-spacing: 0.1em;
  box-shadow: 0 0 8px var(--green), 0 0 16px rgba(57,255,20,0.3);
  animation: badge-pulse 3s ease-in-out infinite;
}

@keyframes badge-pulse {
  0%, 100% { box-shadow: 0 0 8px var(--green), 0 0 16px rgba(57,255,20,0.3); }
  50% { box-shadow: 0 0 14px var(--green), 0 0 28px rgba(57,255,20,0.5); }
}

.packet-counter {
  font-family: var(--font-mono);
  font-size: 0.7em;
  color: var(--cyan-dim);
  letter-spacing: 0.08em;
}

#validations {
  display: none;
  background: linear-gradient(90deg, rgba(57,255,20,0.1), transparent);
  border-left: 3px solid var(--green);
  color: var(--green);
  padding: 6px 16px;
  font-family: var(--font-mono);
  font-size: 0.78em;
  letter-spacing: 0.06em;
}

#erreurs {
  display: none;
  background: linear-gradient(90deg, rgba(255,50,0,0.1), transparent);
  border-left: 3px solid #ff3200;
  color: #ff6640;
  padding: 8px 16px;
  font-family: var(--font-mono);
  font-size: 0.78em;
  line-height: 1.8;
  letter-spacing: 0.04em;
}

#codeOutput {
  background: var(--bg-deep);
  color: var(--green);
  padding: 16px 12px;
  font-family: var(--font-mono);
  font-size: 0.82em;
  min-height: 180px;
  max-height: 340px;
  overflow-y: auto;
  line-height: 1.7;
  border-bottom: 1px solid var(--border);
  position: relative;
}

#codeOutput::-webkit-scrollbar { width: 6px; }
#codeOutput::-webkit-scrollbar-track { background: var(--bg-dark); }
#codeOutput::-webkit-scrollbar-thumb { background: var(--cyan-dim); border-radius: 3px; }

.code-line { display: flex; align-items: baseline; }
.line-num {
  color: var(--text-dim);
  min-width: 32px;
  user-select: none;
  margin-right: 12px;
  text-align: right;
  font-size: 0.85em;
  opacity: 0.5;
}
.code-line:hover { background: rgba(0,245,255,0.03); }

.code-line span:last-child { color: var(--green); }


#codeOutput::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--cyan), transparent);
  opacity: 0.4;
  animation: scanline 4s linear infinite;
  pointer-events: none;
}

@keyframes scanline {
  0% { top: 0; }
  100% { top: 100%; }
}


.packet {
  position: fixed;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--cyan);
  box-shadow: 0 0 6px var(--cyan), 0 0 12px var(--cyan);
  pointer-events: none;
  z-index: 1;
  opacity: 0;
  animation: packet-fly var(--duration, 4s) var(--delay, 0s) linear infinite;
}

@keyframes packet-fly {
  0%   { opacity: 0; transform: translate(0, 0); }
  5%   { opacity: 1; }
  95%  { opacity: 1; }
  100% { opacity: 0; transform: translate(var(--tx, 200px), var(--ty, -100px)); }
}


@media (max-width: 700px) {
  #blocklyDiv { height: 300px; }
  #app-header { padding: 10px 14px; }
  .header-title h1 { font-size: 0.9em; }
  #toolbar { padding: 8px 12px; gap: 6px; }
  .btn-uiverse-cyan .wrapper,
  .btn-uiverse-magenta .wrapper,
  .btn-uiverse-red .wrapper { min-width: 90px; padding: 8px 0; font-size: 11px; }
}
