/* PackMate Phase 1 — floating guide (no AI) */

.packmate-root {
  --pm-cyan: #00f5d4;
  --pm-cyan-dim: rgba(0, 245, 212, 0.18);
  --pm-bg: rgba(12, 10, 22, 0.96);
  --pm-border: rgba(0, 245, 212, 0.35);
  --pm-text: #e8e6f2;
  --pm-muted: rgba(232, 230, 242, 0.72);
  --pm-z: 12050; /* always above guide orb (≤9000) — full launcher is clickable */
  font-family: inherit;
  color: var(--pm-text);
  position: relative;
  z-index: 12050;
}

.packmate-launcher {
  position: fixed;
  right: max(1rem, env(safe-area-inset-right, 0px));
  bottom: max(1rem, env(safe-area-inset-bottom, 0px));
  z-index: var(--pm-z);
  pointer-events: auto;
  isolation: isolate;
  width: 4.25rem;
  height: 4.25rem;
  padding: 0;
  border: 2px solid rgba(0, 180, 255, 0.45);
  border-radius: 1.15rem;
  background: rgba(5, 8, 16, 0.95);
  box-shadow:
    0 0 0 1px rgba(0, 180, 255, 0.15),
    0 10px 28px rgba(0, 0, 0, 0.45),
    0 0 24px rgba(0, 180, 255, 0.2);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.packmate-launcher:hover,
.packmate-launcher:focus-visible {
  transform: translateY(-2px) scale(1.03);
  box-shadow:
    0 0 0 1px rgba(0, 245, 212, 0.35),
    0 12px 32px rgba(0, 0, 0, 0.5),
    0 0 28px rgba(0, 245, 212, 0.28);
  outline: none;
}

.packmate-launcher[hidden],
.packmate-root.is-launcher-hidden .packmate-launcher {
  display: none !important;
}

/* Panel can still open from homepage Ask PackMate when float is hidden */
.packmate-root.is-launcher-hidden .packmate-panel:not([hidden]) {
  display: flex !important;
}

.packmate-launcher-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 0.95rem;
  display: block;
  pointer-events: none;
  background: #050810;
}

.packmate-panel {
  position: fixed !important;
  right: max(1rem, env(safe-area-inset-right, 0px));
  bottom: max(4.75rem, calc(env(safe-area-inset-bottom, 0px) + 4.5rem));
  left: auto;
  top: auto;
  z-index: 12050 !important;
  width: min(22.5rem, calc(100vw - 1.5rem));
  max-height: min(32rem, calc(100vh - 6.5rem));
  display: flex;
  flex-direction: column;
  background: var(--pm-bg);
  border: 1px solid var(--pm-border);
  border-radius: 1rem;
  box-shadow:
    0 0 0 1px rgba(0, 245, 212, 0.08),
    0 18px 48px rgba(0, 0, 0, 0.55);
  overflow: hidden;
  backdrop-filter: blur(12px);
}

.packmate-panel[hidden] {
  display: none !important;
}

/* When open, force visible (homepage hero open path) */
.packmate-panel.is-open,
body.packmate-panel-open .packmate-panel:not([hidden]) {
  display: flex !important;
  visibility: visible !important;
  opacity: 1 !important;
  z-index: 12050 !important;
}

/* Homepage Ask PackMate: open in the center so topics are obvious */
.packmate-panel.packmate-panel-center {
  right: 50% !important;
  left: auto !important;
  top: 50% !important;
  bottom: auto !important;
  transform: translate(50%, -50%) !important;
  width: min(24rem, calc(100vw - 1.5rem)) !important;
  max-height: min(70vh, 32rem) !important;
  box-shadow:
    0 0 0 1px rgba(0, 180, 255, 0.25),
    0 24px 64px rgba(0, 0, 0, 0.65),
    0 0 40px rgba(0, 180, 255, 0.15) !important;
}

/* Dim page slightly when centered so panel is obvious */
body.packmate-panel-open::after {
  content: "";
  position: fixed;
  inset: 0;
  background: rgba(5, 4, 12, 0.45);
  z-index: 12040;
  pointer-events: none;
}



.packmate-header {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  padding: 0.85rem 0.85rem 0.7rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background: linear-gradient(180deg, rgba(0, 245, 212, 0.08), transparent);
}

/* Full PackMate art in panel header — not a tiny cropped wolf */
.packmate-badge {
  width: 4.25rem;
  height: 4.25rem;
  object-fit: contain;
  border-radius: 0.75rem;
  flex-shrink: 0;
  background: #050810;
  border: 1px solid rgba(0, 180, 255, 0.35);
}

.packmate-header-text {
  flex: 1;
  min-width: 0;
}

.packmate-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--pm-cyan);
}

.packmate-sub {
  margin: 0.15rem 0 0;
  font-size: 0.8rem;
  color: var(--pm-muted);
}

.packmate-header-actions {
  display: flex;
  gap: 0.25rem;
  flex-shrink: 0;
}

.packmate-icon-btn {
  width: 2rem;
  height: 2rem;
  border-radius: 0.45rem;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.04);
  color: var(--pm-text);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.packmate-icon-btn:hover,
.packmate-icon-btn:focus-visible {
  border-color: var(--pm-border);
  color: var(--pm-cyan);
  outline: none;
}

.packmate-body {
  padding: 0.75rem 0.85rem 0.9rem;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}

.packmate-welcome {
  margin: 0 0 0.65rem;
  font-size: 0.85rem;
  color: var(--pm-muted);
  line-height: 1.4;
}

.packmate-topics {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.packmate-topic-btn {
  width: 100%;
  text-align: left;
  padding: 0.55rem 0.7rem;
  border-radius: 0.55rem;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.03);
  color: var(--pm-text);
  font-size: 0.88rem;
  cursor: pointer;
  transition: border-color 0.12s ease, background 0.12s ease;
}

.packmate-topic-btn:hover,
.packmate-topic-btn:focus-visible {
  border-color: var(--pm-border);
  background: var(--pm-cyan-dim);
  outline: none;
  color: #fff;
}

.packmate-answer {
  margin: 0;
}

.packmate-answer-title {
  margin: 0 0 0.45rem;
  font-size: 0.95rem;
  color: var(--pm-cyan);
}

.packmate-answer-body {
  margin: 0 0 0.75rem;
  font-size: 0.88rem;
  line-height: 1.45;
  color: var(--pm-text);
  white-space: pre-wrap;
}

.packmate-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 0.65rem;
}

.packmate-action {
  display: inline-flex;
  align-items: center;
  padding: 0.4rem 0.7rem;
  border-radius: 999px;
  border: 1px solid var(--pm-border);
  background: rgba(0, 245, 212, 0.1);
  color: var(--pm-cyan);
  font-size: 0.8rem;
  text-decoration: none;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  line-height: 1.3;
}

button.packmate-action {
  appearance: none;
  -webkit-appearance: none;
}

.packmate-action:hover,
.packmate-action:focus-visible {
  background: rgba(0, 245, 212, 0.2);
  outline: none;
}

.packmate-back {
  margin-top: 0.25rem;
}

.packmate-footer {
  padding: 0.55rem 0.85rem 0.75rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.packmate-search-row {
  display: flex;
  gap: 0.4rem;
}

.packmate-search {
  flex: 1;
  min-width: 0;
  padding: 0.45rem 0.6rem;
  border-radius: 0.5rem;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(0, 0, 0, 0.35);
  color: var(--pm-text);
  font-size: 0.85rem;
}

.packmate-search:focus {
  outline: none;
  border-color: var(--pm-border);
}

.packmate-search-btn {
  flex-shrink: 0;
  padding: 0.45rem 0.7rem;
  border-radius: 0.5rem;
  border: 1px solid var(--pm-border);
  background: rgba(0, 245, 212, 0.12);
  color: var(--pm-cyan);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
}

.packmate-search-btn:hover,
.packmate-search-btn:focus-visible {
  background: rgba(0, 245, 212, 0.22);
  outline: none;
}

.packmate-hide-link {
  display: block;
  margin-top: 0.45rem;
  width: 100%;
  background: none;
  border: none;
  color: var(--pm-muted);
  font-size: 0.72rem;
  text-align: center;
  cursor: pointer;
  text-decoration: underline;
  padding: 0.2rem;
}

.packmate-hide-link:hover,
.packmate-hide-link:focus-visible {
  color: var(--pm-cyan);
  outline: none;
}

.packmate-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

/* Avoid covering create-pack Turnstile / sticky footers on small screens */
@media (max-width: 480px) {
  .packmate-launcher {
    right: 0.75rem;
    bottom: 0.75rem;
    width: 3.25rem;
    height: 3.25rem;
  }

  .packmate-panel {
    right: 0.5rem;
    left: 0.5rem;
    width: auto;
    bottom: max(4.5rem, calc(env(safe-area-inset-bottom, 0px) + 4.25rem));
    max-height: min(70vh, 28rem);
  }
}

/* When panel open, keep launcher for reopen after close only — still clickable */
body.packmate-panel-open {
  /* no scroll lock — avoid fighting forms */
}
