/* ── Persistent feedback button + modal ─────────────────────────────
   Floats in the bottom-right corner on every page. Click opens a
   simple modal with a message + optional email. Submit posts to
   /api/feedback. Matches the dark/violet aesthetic of the site. */

:root {
  --fb-surface:    #110f1c;
  --fb-border:     rgba(196, 161, 255, 0.22);
  --fb-border-h:   rgba(196, 161, 255, 0.45);
  --fb-text:       #f0ecf7;
  --fb-text-mid:   rgba(230, 220, 245, 0.72);
  --fb-text-dim:   rgba(200, 190, 220, 0.45);
  --fb-accent:     #c4a1ff;
  --fb-accent-bg:  rgba(196, 161, 255, 0.12);
}

/* ── Floating button ─────────────────────────────────────────────── */

#fb-launcher {
  position: fixed;
  bottom: max(clamp(72px, 9vh, 96px), env(safe-area-inset-bottom));
  right: max(clamp(18px, 3vw, 26px), env(safe-area-inset-right));
  width: clamp(48px, 5.2vw, 58px);
  height: clamp(48px, 5.2vw, 58px);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background:
    radial-gradient(circle at 30% 25%, rgba(216, 196, 255, 0.18), transparent 65%),
    rgba(46, 32, 78, 0.88);
  border: 2px solid rgba(196, 161, 255, 0.55);
  color: var(--fb-accent);
  cursor: pointer;
  z-index: 80;
  padding: 0;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow:
    0 6px 18px rgba(0, 0, 0, 0.4),
    0 0 16px rgba(196, 161, 255, 0.22);
  transition: color 0.25s ease, border-color 0.25s ease,
              background 0.25s ease, transform 0.2s ease,
              box-shadow 0.25s ease;
  -webkit-tap-highlight-color: transparent;
}

#fb-launcher svg {
  width: 56%;
  height: 56%;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

#fb-launcher:hover {
  color: #fff;
  border-color: rgba(216, 196, 255, 0.85);
  background:
    radial-gradient(circle at 30% 25%, rgba(216, 196, 255, 0.28), transparent 65%),
    rgba(64, 46, 110, 0.95);
  transform: scale(1.06);
  box-shadow: 0 8px 26px rgba(0, 0, 0, 0.45),
              0 0 24px rgba(196, 161, 255, 0.35);
}

#fb-launcher:active { transform: scale(0.94); }

/* Tooltip on hover (desktop only) */
#fb-launcher::after {
  content: 'Feedback';
  position: absolute;
  right: calc(100% + 10px);
  top: 50%;
  transform: translateY(-50%) translateX(6px);
  padding: 6px 10px;
  background: rgba(20, 17, 32, 0.94);
  color: var(--fb-text);
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 0.78rem;
  border-radius: 6px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease, transform 0.2s ease;
  border: 1px solid var(--fb-border);
}

#fb-launcher:hover::after {
  opacity: 1;
  transform: translateY(-50%) translateX(0);
}

@media (hover: none) {
  #fb-launcher::after { display: none; }
}

/* Mobile: still a touch smaller than desktop, but pronounced enough
   to draw the eye. Tucked into the bottom-right corner. */
@media (max-width: 640px) {
  #fb-launcher {
    width: 44px;
    height: 44px;
    bottom: max(18px, env(safe-area-inset-bottom));
    /* Bottom-LEFT on mobile so we don't fight with right-aligned game UI
       (e.g. the hospital exit door, which sits below the bottom-right cell). */
    left: max(18px, env(safe-area-inset-left));
    right: auto;
    border-width: 2px;
  }
  /* Tooltip flips to the right side since the button is now on the left. */
  #fb-launcher::after {
    right: auto;
    left: calc(100% + 10px);
    transform: translateY(-50%) translateX(-6px);
  }
  #fb-launcher:hover::after {
    transform: translateY(-50%) translateX(0);
  }
}

/* ── Modal overlay + container ───────────────────────────────────── */

.fb-overlay {
  position: fixed;
  inset: 0;
  background: rgba(6, 5, 13, 0.78);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 9998;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  transition: opacity 0.25s ease;
}

.fb-overlay.is-visible {
  display: flex;
  opacity: 1;
}

.fb-modal {
  position: relative;
  width: 100%;
  max-width: 460px;
  background: var(--fb-surface);
  border: 1px solid var(--fb-border);
  border-radius: 16px;
  padding: clamp(22px, 3.6vw, 30px);
  color: var(--fb-text);
  box-shadow:
    0 30px 60px rgba(0, 0, 0, 0.6),
    0 0 0 1px rgba(196, 161, 255, 0.08),
    inset 0 1px 0 rgba(255, 255, 255, 0.04);
  font-family: 'Inter', system-ui, sans-serif;
  transform: scale(0.96) translateY(10px);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.fb-overlay.is-visible .fb-modal {
  transform: scale(1) translateY(0);
}

.fb-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 30px;
  height: 30px;
  background: transparent;
  border: none;
  color: var(--fb-text-dim);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s ease, background 0.2s ease;
}

.fb-close:hover {
  color: var(--fb-text);
  background: rgba(255, 255, 255, 0.06);
}

.fb-title {
  font-family: 'Instrument Serif', Georgia, serif;
  font-size: clamp(1.5rem, 3.6vw, 1.85rem);
  font-weight: 400;
  margin: 0 0 6px;
  line-height: 1.1;
  text-align: center;
}

.fb-body {
  font-size: clamp(0.85rem, 1.6vw, 0.95rem);
  color: var(--fb-text-mid);
  text-align: center;
  margin: 0 0 18px;
  line-height: 1.4;
}

/* ── Form ────────────────────────────────────────────────────────── */

.fb-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.fb-textarea,
.fb-input {
  width: 100%;
  padding: 11px 14px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  color: var(--fb-text);
  font-family: inherit;
  font-size: 0.92rem;
  transition: border-color 0.2s ease, background 0.2s ease;
  resize: none;
}

.fb-textarea {
  min-height: 110px;
  line-height: 1.45;
}

.fb-input::placeholder,
.fb-textarea::placeholder {
  color: var(--fb-text-dim);
}

.fb-textarea:focus,
.fb-input:focus {
  outline: none;
  border-color: var(--fb-border-h);
  background: rgba(255, 255, 255, 0.05);
}

.fb-submit {
  padding: 12px;
  font-family: inherit;
  font-size: 0.92rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: #1a0f33;
  background: linear-gradient(135deg, #d8c4ff 0%, #c4a1ff 100%);
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: filter 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
  margin-top: 4px;
}

.fb-submit:hover {
  filter: brightness(1.06);
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(196, 161, 255, 0.28);
}

.fb-submit:active {
  transform: translateY(0) scale(0.98);
}

.fb-submit:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  filter: grayscale(0.3);
  transform: none;
  box-shadow: none;
}

.fb-error {
  color: #ff8585;
  font-size: 0.82rem;
  text-align: center;
  margin: 4px 0 0;
  min-height: 1.1em;
}

/* ── Success state ───────────────────────────────────────────────── */

.fb-success {
  display: none;
  text-align: center;
  padding: 18px 0 6px;
}

.fb-success.is-visible {
  display: block;
}

.fb-success-icon {
  font-size: 3rem;
  margin-bottom: 12px;
  animation: fb-pop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
  filter: drop-shadow(0 0 18px rgba(196, 161, 255, 0.4));
}

.fb-success-title {
  font-family: 'Inter', system-ui, sans-serif;
  font-size: clamp(1.15rem, 2.6vw, 1.35rem);
  font-weight: 500;
  color: var(--fb-text);
  margin: 0 0 6px;
}

.fb-success-msg {
  font-size: 0.9rem;
  color: var(--fb-text-mid);
  margin: 0;
}

@keyframes fb-pop {
  0%   { transform: scale(0.4); opacity: 0; }
  60%  { transform: scale(1.15); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .fb-overlay,
  .fb-modal,
  .fb-success-icon,
  #fb-launcher,
  #fb-launcher::after {
    transition: none !important;
    animation: none !important;
  }
}
