/* =========================================================
   PluggLAB — Terminal Easter Egg
   Retro CRT-style overlay, sandboxed client-side only.
   ========================================================= */

#pglab-terminal-trigger {
  width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--border); border-radius: 8px;
  color: var(--text-soft);
  transition: all 0.2s;
}
#pglab-terminal-trigger:hover { border-color: var(--border-bright); color: var(--soul); background: var(--panel-mid); }
#pglab-terminal-trigger svg { width: 15px; height: 15px; }

#pglab-terminal-overlay {
  position: fixed;
  inset: 0;
  z-index: 10200;
  background: rgba(2, 0, 4, 0.82);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 5vh 1.25rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease;
}
#pglab-terminal-overlay.is-open { opacity: 1; pointer-events: auto; }

.pglab-terminal {
  width: 100%;
  max-width: 760px;
  height: min(72vh, 640px);
  display: flex;
  flex-direction: column;
  background: #04010a;
  border: 1px solid rgba(45, 255, 138, 0.28);
  border-radius: 10px;
  box-shadow: 0 0 0 1px rgba(139, 43, 226, 0.15), 0 30px 80px rgba(0, 0, 0, 0.65), 0 0 60px rgba(45, 255, 138, 0.06);
  overflow: hidden;
  position: relative;
  transform: translateY(-8px) scale(0.99);
  transition: transform 0.2s var(--ease-spring);
}
#pglab-terminal-overlay.is-open .pglab-terminal { transform: translateY(0) scale(1); }

/* CRT scanline + flicker overlay */
.pglab-terminal::before {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 5;
  background-image: repeating-linear-gradient(
    0deg,
    rgba(0, 0, 0, 0.18) 0px,
    rgba(0, 0, 0, 0.18) 1px,
    transparent 1px,
    transparent 3px
  );
  mix-blend-mode: multiply;
  opacity: 0.55;
}
.pglab-terminal::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 6;
  background: radial-gradient(ellipse at center, transparent 60%, rgba(0, 0, 0, 0.45) 100%);
}

.pglab-term-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 1rem;
  border-bottom: 1px solid rgba(45, 255, 138, 0.18);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--soul);
  background: rgba(45, 255, 138, 0.04);
  position: relative;
  z-index: 7;
}
.pglab-term-head .dots { display: flex; gap: 0.4rem; }
.pglab-term-head .dots span { width: 8px; height: 8px; border-radius: 50%; background: rgba(45, 255, 138, 0.35); }
.pglab-term-close {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  padding: 0.2rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 4px;
}
.pglab-term-close:hover { color: var(--soul); border-color: rgba(45, 255, 138, 0.4); }

.pglab-term-body {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 1.1rem;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  line-height: 1.65;
  color: #b9ffcf;
  text-shadow: 0 0 6px rgba(45, 255, 138, 0.25);
  position: relative;
  z-index: 7;
}
.pglab-term-body::-webkit-scrollbar { width: 8px; }
.pglab-term-body::-webkit-scrollbar-thumb { background: rgba(45, 255, 138, 0.2); border-radius: 8px; }

.pglab-line { white-space: pre-wrap; word-break: break-word; margin-bottom: 0.15rem; }
.pglab-line.pglab-echo { color: #d9c3ff; text-shadow: 0 0 6px rgba(139, 43, 226, 0.3); }
.pglab-line.pglab-echo::before { content: '❯ '; color: rgba(217, 195, 255, 0.6); }
.pglab-line.pglab-error { color: #ff8a8a; text-shadow: 0 0 6px rgba(255, 90, 90, 0.25); }
.pglab-line.pglab-dim { color: rgba(185, 255, 207, 0.55); }
.pglab-line.pglab-heading { color: #f6c143; text-shadow: 0 0 6px rgba(246, 193, 67, 0.3); font-weight: 700; }
.pglab-line a { color: #7de3ff; text-decoration: underline; }
.pglab-line.pglab-glitch { animation: pglab-glitch 220ms steps(2, end) 2; }
@keyframes pglab-glitch {
  0% { transform: translateX(0); }
  25% { transform: translateX(-2px); }
  50% { transform: translateX(2px); }
  75% { transform: translateX(-1px); }
  100% { transform: translateX(0); }
}

.pglab-term-inputrow {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.7rem 1.1rem;
  border-top: 1px solid rgba(45, 255, 138, 0.18);
  background: rgba(45, 255, 138, 0.03);
  position: relative;
  z-index: 7;
}
.pglab-term-prompt {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--soul);
  white-space: nowrap;
  text-shadow: 0 0 6px rgba(45, 255, 138, 0.3);
}
#pglab-term-input {
  flex: 1;
  background: none;
  border: none;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: #eaffef;
  caret-color: #2dff8a;
  text-shadow: 0 0 6px rgba(45, 255, 138, 0.25);
}
#pglab-term-input:focus { outline: none; }

@media (max-width: 620px) {
  .pglab-terminal { height: 82vh; }
  .pglab-term-body { font-size: 0.78rem; }
}

@media (prefers-reduced-motion: reduce) {
  .pglab-line.pglab-glitch { animation: none; }
}
