/* ============================================================
   QUEST-HUD.CSS — Floating HUD panel + minimized bubble
   ============================================================ */

/* ── Root container ─────────────────────────────────────────── */
#quest-hud-root {
  position: fixed;
  right: 24px;
  bottom: 90px;
  z-index: 8000;
  pointer-events: all;
  user-select: none;
  -webkit-user-select: none;
}

/* ── Panel ──────────────────────────────────────────────────── */
.qhud-panel {
  width: 420px;
  max-width: 90vw;
  max-height: 80vh;
  background: rgba(4, 9, 28, 0.94);
  border: 1px solid rgba(0, 168, 255, 0.35);
  border-radius: 4px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  resize: both;
  min-width: 280px;
  min-height: 140px;
  box-shadow:
    0 0 0 1px rgba(0, 168, 255, 0.08) inset,
    0 2px 2px rgba(0, 168, 255, 0.15) inset,
    0 16px 60px rgba(0, 0, 0, 0.8),
    0 0 40px rgba(0, 168, 255, 0.06);
  pointer-events: all;
  animation: hudPanelIn 250ms cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
  --corner: rgba(0, 168, 255, 0.6);
}

.qhud-panel.qhud-panel-out {
  animation: hudPanelOut 200ms ease-in forwards;
}

/* Corner bracket decorations */
.qhud-panel::before,
.qhud-panel::after {
  content: '';
  position: absolute;
  width: 12px;
  height: 12px;
  pointer-events: none;
  z-index: 10;
}

.qhud-panel::before {
  top: 0;
  left: 0;
  border-top: 2px solid var(--corner);
  border-left: 2px solid var(--corner);
}

.qhud-panel::after {
  bottom: 0;
  right: 0;
  border-bottom: 2px solid var(--corner);
  border-right: 2px solid var(--corner);
}

@keyframes hudFadeIn {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.96);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* ── Scanline texture ───────────────────────────────────────── */
.qhud-scanlines {
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(0deg,
      transparent,
      transparent 2px,
      rgba(0, 0, 0, 0.06) 2px,
      rgba(0, 0, 0, 0.06) 4px);
  pointer-events: none;
  z-index: 0;
}

/* ── Header / Drag Handle ───────────────────────────────────── */
.qhud-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1.1rem;
  background: rgba(0, 168, 255, 0.07);
  border-bottom: 1px solid rgba(0, 168, 255, 0.2);
  cursor: grab;
  user-select: none;
  position: relative;
  z-index: 1;
  flex-shrink: 0;
}

.qhud-header:active {
  cursor: grabbing;
}

.qhud-title {
  font-size: 0.68rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--color-primary, #00a8ff);
  font-family: 'Orbitron', sans-serif;
  text-shadow: 0 0 12px rgba(0, 168, 255, 0.4);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.qhud-header-btns {
  display: flex;
  gap: 0.3rem;
}

.qhud-btn {
  width: 24px;
  height: 24px;
  background: transparent;
  border: 1px solid rgba(51, 65, 85, 0.7);
  border-radius: 3px;
  color: #64748b;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 150ms ease-out;
  padding: 0;
}

.qhud-btn:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-primary, #f1f5f9);
  border-color: rgba(255, 255, 255, 0.25);
}

/* ── Quest Navigator ────────────────────────────────────────── */
.qhud-navigator {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1.1rem;
  border-bottom: 1px solid rgba(51, 65, 85, 0.3);
  background: rgba(15, 23, 42, 0.5);
  position: relative;
  z-index: 1;
  flex-shrink: 0;
}

.qhud-nav-btn {
  width: 28px;
  height: 28px;
  background: transparent;
  border: 1px solid rgba(51, 65, 85, 0.6);
  border-radius: 3px;
  color: #64748b;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 150ms ease-out;
  padding: 0;
}

.qhud-nav-btn:not([disabled]):hover {
  border-color: var(--color-primary, #00a8ff);
  color: var(--color-primary, #00a8ff);
  background: rgba(0, 168, 255, 0.08);
}

.qhud-nav-btn[disabled] {
  opacity: 0.2;
  cursor: not-allowed;
}

.qhud-quest-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.qhud-quest-counter {
  font-size: 0.6rem;
  color: #475569;
  font-family: 'JetBrains Mono', monospace;
  font-feature-settings: 'tnum';
  letter-spacing: 0.5px;
}

.qhud-quest-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-primary, #f1f5f9);
  font-family: 'Orbitron', sans-serif;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  letter-spacing: 0.3px;
}

/* ── Objectives List ────────────────────────────────────────── */
.qhud-objectives {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 0.5rem 0;
  scrollbar-width: thin;
  scrollbar-color: rgba(51, 65, 85, 0.6) transparent;
  position: relative;
  z-index: 1;
}

.qhud-objectives::-webkit-scrollbar {
  width: 3px;
}

.qhud-objectives::-webkit-scrollbar-thumb {
  background: rgba(51, 65, 85, 0.6);
  border-radius: 99px;
}

.qhud-obj-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.45rem 1.1rem;
  transition: background 100ms ease-out;
}

.qhud-obj-row:hover {
  background: rgba(255, 255, 255, 0.025);
}

.qhud-obj-row.done .qhud-obj-text {
  text-decoration: line-through;
  opacity: 0.35;
}

.qhud-checkbox {
  width: 16px;
  height: 16px;
  border: 1.5px solid #334155;
  border-radius: 3px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 150ms ease-out;
}

.qhud-checkbox.checked {
  background: #22c55e;
  border-color: #22c55e;
  box-shadow: 0 0 8px rgba(34, 197, 94, 0.4);
}

.qhud-checkbox.checked::after {
  content: '';
  width: 4px;
  height: 8px;
  border: 1.5px solid #000;
  border-top: none;
  border-left: none;
  transform: rotate(45deg) translateY(-1px);
}

.qhud-checkbox.clickable {
  cursor: pointer;
}

.qhud-checkbox.clickable:hover:not(.checked) {
  border-color: #22c55e;
  background: rgba(34, 197, 94, 0.1);
}

.qhud-parent-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #fbbf24;
  flex-shrink: 0;
  margin: 0 4px;
  opacity: 0.8;
}

.qhud-parent-dot.done {
  background: #10b981;
  opacity: 0.6;
}

.qhud-obj-text {
  flex: 1;
  font-size: 0.8rem;
  color: #cbd5e1;
  font-family: 'JetBrains Mono', monospace;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1.4;
}

.qhud-timer {
  font-size: 0.7rem;
  font-family: 'JetBrains Mono', monospace;
  font-feature-settings: 'tnum';
  color: var(--color-primary, #00a8ff);
  flex-shrink: 0;
  padding: 2px 7px;
  border: 1px solid rgba(0, 168, 255, 0.3);
  border-radius: 3px;
  background: rgba(0, 168, 255, 0.06);
  letter-spacing: 0.5px;
}

.qhud-timer.overdue {
  color: #ef4444;
  border-color: rgba(239, 68, 68, 0.4);
  background: rgba(239, 68, 68, 0.08);
  animation: timerPulse 1.5s ease-in-out infinite;
}

@keyframes timerPulse {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.5;
  }
}

.qhud-empty-obj {
  padding: 0.75rem 0.9rem;
  font-size: 0.75rem;
  color: #475569;
  font-family: 'JetBrains Mono', monospace;
  text-align: center;
}

/* ── Penalty Bar ────────────────────────────────────────────── */
.qhud-penalty-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  width: 100%;
  padding: 0.7rem 1.1rem;
  background: rgba(239, 68, 68, 0.08);
  border: none;
  border-top: 1px solid rgba(239, 68, 68, 0.25);
  color: #f87171;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  cursor: pointer;
  transition: background 150ms ease-out;
  font-family: 'Orbitron', sans-serif;
  position: relative;
  z-index: 1;
  flex-shrink: 0;
  margin-top: auto;
}

.qhud-penalty-bar:hover {
  background: rgba(239, 68, 68, 0.14);
}

/* ── Minimized Bubble ───────────────────────────────────────── */
.qhud-bubble {
  position: relative;
  width: 48px;
  height: 44px;
  cursor: pointer;
  pointer-events: all;
  animation: hudFadeIn 200ms ease-out forwards;
  opacity: 0.35;
  transition: opacity 280ms ease-out, transform 280ms ease-out;
}

/* Border hex — sits behind .qhud-hex, 2px larger on each side */
.qhud-bubble::before {
  content: '';
  position: absolute;
  inset: -2px;
  background: rgba(0, 168, 255, 0.5);
  clip-path: polygon(25% 0%, 75% 0%, 100% 50%, 75% 100%, 25% 100%, 0% 50%);
  pointer-events: none;
  transition: background 280ms ease-out;
}

/* The hex fill — dark background, clipped */
.qhud-hex {
  position: relative;
  width: 100%;
  height: 100%;
  background: rgba(4, 9, 28, 0.95);
  clip-path: polygon(25% 0%, 75% 0%, 100% 50%, 75% 100%, 25% 100%, 0% 50%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #f1f5f9;
  filter: drop-shadow(0 0 10px rgba(0, 168, 255, 0.2)) drop-shadow(0 3px 8px rgba(0, 0, 0, 0.6));
  transition: filter 280ms ease-out;
}

.qhud-hex svg,
.qhud-hex [data-lucide] {
  transition: opacity 280ms ease-out, color 280ms ease-out;
  opacity: 0.6;
  color: #f1f5f9;
}

.qhud-bubble:hover {
  opacity: 1;
  transform: scale(1.1);
}

.qhud-bubble:hover::before {
  background: rgba(0, 168, 255, 0.9);
}

.qhud-bubble:hover .qhud-hex {
  filter: drop-shadow(0 0 16px rgba(0, 168, 255, 0.45)) drop-shadow(0 3px 8px rgba(0, 0, 0, 0.6));
}

.qhud-bubble:hover .qhud-hex svg,
.qhud-bubble:hover .qhud-hex [data-lucide] {
  opacity: 1;
  color: var(--color-primary, #00a8ff);
}

.qhud-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  background: #ef4444;
  color: #fff;
  border-radius: 99px;
  font-size: 0.55rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'JetBrains Mono', monospace;
  border: 2px solid rgba(4, 9, 28, 0.95);
  box-sizing: border-box;
  transform: scale(0);
  opacity: 0;
  transition: transform 280ms cubic-bezier(0.34, 1.56, 0.64, 1), opacity 200ms ease-out;
  transform-origin: center center;
}

.qhud-bubble:hover .qhud-badge {
  transform: scale(1);
  opacity: 1;
}

.qhud-penalty-badge {
  position: absolute;
  bottom: -4px;
  right: -4px;
  min-width: 15px;
  height: 15px;
  padding: 0 3px;
  background: #f97316;
  color: #fff;
  border-radius: 99px;
  font-size: 0.52rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'JetBrains Mono', monospace;
  border: 2px solid rgba(4, 9, 28, 0.95);
  box-sizing: border-box;
  transform: scale(0);
  opacity: 0;
  transition: transform 280ms cubic-bezier(0.34, 1.56, 0.64, 1) 60ms, opacity 200ms ease-out 60ms;
  transform-origin: center center;
}

.qhud-bubble:hover .qhud-penalty-badge {
  transform: scale(1);
  opacity: 1;
}

/* ── Bubble progress ring (aggregate objective completion) ─── */
.qhud-ring {
  position: absolute;
  inset: -7px;
  width: calc(100% + 14px);
  height: calc(100% + 14px);
  pointer-events: none;
  z-index: 1;
}

.qhud-ring-bg {
  fill: none;
  stroke: rgba(0, 168, 255, 0.15);
  stroke-width: 2;
}

.qhud-ring-fill {
  fill: none;
  stroke: #00a8ff;
  stroke-width: 2.5;
  stroke-linecap: round;
  filter: drop-shadow(0 0 4px rgba(0, 168, 255, 0.6));
  transition: stroke-dasharray 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}

/* ── Urgent state: penalties pending or a deadline < 10 min ── */
.qhud-bubble.urgent {
  opacity: 1;
  animation: hudUrgentPulse 1.4s ease-in-out infinite;
}

.qhud-bubble.urgent::before {
  background: rgba(239, 68, 68, 0.85);
}

.qhud-bubble.urgent .qhud-ring-fill {
  stroke: #ef4444;
  filter: drop-shadow(0 0 5px rgba(239, 68, 68, 0.7));
}

.qhud-bubble.urgent .qhud-hex {
  filter: drop-shadow(0 0 14px rgba(239, 68, 68, 0.5)) drop-shadow(0 3px 8px rgba(0, 0, 0, 0.6));
}

.qhud-bubble.urgent .qhud-hex svg,
.qhud-bubble.urgent .qhud-hex [data-lucide] {
  opacity: 1;
  color: #f87171;
}

@keyframes hudUrgentPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.07); }
}

/* ── Nearest-deadline countdown chip under the bubble ──────── */
.qhud-deadline-chip {
  position: absolute;
  top: calc(100% + 9px);
  left: 50%;
  transform: translateX(-50%);
  padding: 2px 7px;
  background: rgba(4, 9, 28, 0.95);
  border: 1px solid rgba(0, 168, 255, 0.35);
  border-radius: 4px;
  font-size: 0.55rem;
  font-weight: 800;
  color: #7dd3fc;
  font-family: 'JetBrains Mono', monospace;
  font-feature-settings: 'tnum';
  white-space: nowrap;
  pointer-events: none;
}

.qhud-deadline-chip.overdue,
.qhud-bubble.urgent .qhud-deadline-chip {
  border-color: rgba(239, 68, 68, 0.5);
  color: #f87171;
}

/* ── Panel In/Out Keyframes ────────────────────────────────── */
@keyframes hudPanelIn {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.96);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes hudPanelOut {
  from {
    opacity: 1;
    transform: translateY(0) scale(1);
  }

  to {
    opacity: 0;
    transform: translateY(12px) scale(0.96);
  }
}

/* ── Resize handle ─────────────────────────────────────────── */
.qhud-panel::-webkit-resizer {
  background: linear-gradient(135deg,
      transparent 50%,
      rgba(0, 168, 255, 0.25) 50%,
      rgba(0, 168, 255, 0.25) 62%,
      transparent 62%,
      transparent 72%,
      rgba(0, 168, 255, 0.35) 72%,
      rgba(0, 168, 255, 0.35) 82%,
      transparent 82%);
}