/* ══════════════════════════════════════════════════════════
   Bug Report — floating button + modal overlay
   Matches the game palette (shared/css/colors.css):
     --bg-surface, --bg-raised, --gold, --text-primary, --border
══════════════════════════════════════════════════════════ */

/* ─── Floating circular action buttons (top-right, just below chrome) ───
   Shared base for the bug button (🐛) and feedback button (💬). Each
   button only differs in vertical offset and click target — see the
   per-button rules below the base. */

.bug-report-button,
.feedback-button {
  position: fixed;
  right: 16px;
  /* Sits in the overlay tier — above the board, below modals (options
     menu, scenario dialogue, decision prompts) so an open menu visually
     covers the floating action chips. The bug-report MODAL itself
     (.bug-report-overlay, below) stays at 10000 so triggering it from
     beneath an open menu still surfaces above everything. */
  z-index: var(--z-overlay, 50);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--bg-surface, #0f1520);
  border: 1px solid var(--border, #1a2535);
  color: var(--text-sec, #8090a0);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.45);
  transition: transform 120ms ease, color 120ms ease, border-color 120ms ease, background 120ms ease;
  -webkit-user-select: none;
  user-select: none;
  padding: 0;
}

.bug-report-button:hover,
.feedback-button:hover {
  color: var(--gold, #c9a352);
  border-color: var(--gold, #c9a352);
  background: var(--bg-raised, #162030);
  transform: translateY(-1px);
}

.bug-report-button:active,
.feedback-button:active { transform: translateY(0); }

.bug-report-button:focus-visible,
.feedback-button:focus-visible {
  outline: 2px solid var(--gold, #c9a352);
  outline-offset: 2px;
}

.bug-report-button.hidden,
.feedback-button.hidden { display: none; }

/* On the scenario-end screen the dedicated SHARE FEEDBACK CTA covers
   both surfaces — the floating chrome would just be visual noise next
   to the medal + ledger. */
body.scenario-end-visible .bug-report-button,
body.scenario-end-visible .feedback-button { display: none; }

/* Top-left of the battlefield viewport. Anchored 8px below the 48px
   VP bar and 12px right of the 220px left roster, then arranged as a
   horizontal pair so the chrome footprint is 44px tall (not 96px) —
   the canvas is taller than wide so vertical real estate matters more. */
.bug-report-button,
.feedback-button { top: 56px; right: auto; }
.bug-report-button { left: 232px; } /* roster (220) + 12 gap */
.feedback-button   { left: 284px; } /* bug button left + 44 button + 8 gap */

/* One-shot pulse on first scenario start (added by JS, removed after one cycle) */
.bug-report-button.pulse {
  animation: bug-report-pulse 2s ease-in-out 2;
}

@keyframes bug-report-pulse {
  0%, 100% { box-shadow: 0 4px 12px rgba(0, 0, 0, 0.45), 0 0 0 0 rgba(201, 163, 82, 0.55); }
  50%      { box-shadow: 0 4px 12px rgba(0, 0, 0, 0.45), 0 0 0 10px rgba(201, 163, 82, 0); }
}

/* ─── Modal overlay (backdrop + panel) ─── */

.bug-report-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(8, 12, 16, 0.78);
  backdrop-filter: blur(2px);
  padding: 24px;
}

/* .open is added by JS for parity / future hooks; no styles attached. */

.bug-report-panel {
  background: var(--bg-surface, #0f1520);
  border: 1px solid var(--border, #1a2535);
  border-radius: 6px;
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
  color: var(--text-primary, #e0e8f0);
  font-family: inherit;
  display: flex;
  flex-direction: column;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.6);
}

.bug-report-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  /* Material 24dp around dialog title — slight extra top breathing room
     so the title sits more like a heading than a body line. */
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border, #1a2535);
}

.bug-report-title {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary, #e0e8f0);
  letter-spacing: 0.5px;
}

.bug-report-close {
  background: none;
  border: none;
  color: var(--text-sec, #8090a0);
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  padding: 0 4px;
  margin: -4px -4px 0 0;
}

.bug-report-close:hover {
  color: var(--gold, #c9a352);
}

/* ─── Preview ─── */

.bug-report-preview {
  margin: 16px 20px 0;
  background: #000;
  border: 1px solid var(--border, #1a2535);
  border-radius: 4px;
  min-height: 140px;
  max-height: 220px;
  overflow: hidden;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.bug-report-preview-img {
  width: 100%;
  height: auto;
  max-height: 220px;
  object-fit: contain;
  display: block;
}

.bug-report-preview-label {
  color: var(--text-muted, #4a6080);
  font-size: 13px;
  margin-top: 8px;
}

.bug-report-preview-fallback {
  color: var(--text-muted, #4a6080);
  font-size: 13px;
  padding: 24px;
  text-align: center;
}

.bug-report-spinner {
  width: 22px;
  height: 22px;
  border: 2px solid var(--border, #1a2535);
  border-top-color: var(--gold, #c9a352);
  border-radius: 50%;
  animation: bug-report-spin 720ms linear infinite;
}

.bug-report-spinner ~ .bug-report-preview-label {
  position: absolute;
  bottom: 8px;
}

@keyframes bug-report-spin {
  to { transform: rotate(360deg); }
}

/* ─── Textarea ─── */

.bug-report-text {
  margin: 16px 20px 0;
  padding: 10px 12px;
  background: var(--bg-primary, #080c10);
  border: 1px solid var(--border, #1a2535);
  border-radius: 4px;
  color: var(--text-primary, #e0e8f0);
  font: 14px/1.5 inherit;
  resize: none;
  min-height: 90px;
}

.bug-report-text:focus {
  outline: none;
  border-color: var(--gold, #c9a352);
}

.bug-report-text::placeholder {
  color: var(--text-muted, #4a6080);
}

/* ─── Details disclosure ─── */

.bug-report-details-toggle {
  align-self: flex-start;
  margin: 10px 20px 0;
  background: none;
  border: none;
  color: var(--text-sec, #8090a0);
  font-size: 12px;
  cursor: pointer;
  padding: 4px 0;
  text-transform: uppercase;
  letter-spacing: 0.6px;
}

.bug-report-details-toggle:hover {
  color: var(--gold, #c9a352);
}

.bug-report-details-panel {
  margin: 0 20px;
  max-height: 0;
  overflow: hidden;
  transition: max-height 200ms ease;
}

.bug-report-details-panel.open {
  max-height: 280px;
  overflow: auto;
  margin-top: 6px;
}

.bug-report-details-note {
  margin: 0 0 8px;
  font-size: 12px;
  color: var(--text-muted, #4a6080);
  line-height: 1.5;
}

.bug-report-details-json {
  background: var(--bg-primary, #080c10);
  border: 1px solid var(--border, #1a2535);
  border-radius: 4px;
  padding: 8px 10px;
  font: 11px/1.4 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color: var(--text-sec, #8090a0);
  margin: 0;
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 200px;
  overflow: auto;
}

/* ─── Status line + footer ─── */

.bug-report-status {
  margin: 10px 20px 0;
  font-size: 13px;
  min-height: 18px;
  color: var(--text-sec, #8090a0);
}

.bug-report-status-ok    { color: #5fc56f; }
.bug-report-status-warn  { color: #d6a85f; }
.bug-report-status-error { color: var(--bs, #cc2020); }

.bug-report-footer {
  display: flex;
  gap: 10px;
  padding: 16px 20px 20px;
  margin-top: 0;
}
.bug-report-footer .bug-report-btn { flex: 1 1 auto; }

.bug-report-submit-spinner {
  display: inline-block;
  vertical-align: middle;
  width: 14px;
  height: 14px;
  margin-right: 8px;
  border: 2px solid rgba(255, 255, 255, 0.08);
  border-top-color: var(--gold, #c9a352);
  border-radius: 50%;
  animation: bug-report-submit-spin 0.85s linear infinite;
}

@keyframes bug-report-submit-spin {
  to { transform: rotate(360deg); }
}

.bug-report-btn {
  padding: 8px 18px;
  border-radius: 4px;
  font: 13px inherit;
  font-weight: 600;
  letter-spacing: 0.5px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 100ms, color 100ms, border-color 100ms, opacity 100ms;
}

.bug-report-btn-primary {
  background: var(--gold, #c9a352);
  color: #1a1208;
  border-color: var(--gold, #c9a352);
}

.bug-report-btn-primary:hover:not(:disabled) {
  background: #d8b56a;
  border-color: #d8b56a;
}

.bug-report-btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.bug-report-btn-secondary {
  background: transparent;
  color: var(--text-sec, #8090a0);
  border-color: var(--border, #1a2535);
}

.bug-report-btn-secondary:hover {
  color: var(--text-primary, #e0e8f0);
  border-color: var(--text-sec, #8090a0);
}

/* ─── Field row (group two fields side-by-side) ─── */

.bug-report-field-row {
  display: flex;
  gap: 16px;
  margin: 16px 20px 0;
  flex-wrap: wrap;
}
/* When a rating field lives inside a row group, drop its own outer
   margin (the row container already provides the gutter). */
.bug-report-field-row > .bug-report-rating { margin: 0; flex: 1 1 200px; min-width: 0; }

/* ─── Rating field (1-5 stars, end-screen feedback only) ─── */

.bug-report-rating {
  margin: 16px 20px 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.bug-report-rating-label {
  font-size: 13px;
  color: var(--text-primary, #e0e8f0);
}

.bug-report-rating-stars {
  display: flex;
  /* Distribute the 5 squares edge-to-edge in their column so anchors
     line up with the leftmost / rightmost star. */
  justify-content: space-between;
  gap: 8px;
}

.bug-report-rating-star {
  background: transparent;
  border: 1px solid var(--border, #1a2535);
  color: var(--text-muted, #4a6080);
  font-size: 26px; /* glyph ~55% of cell, matching Material rating proportions */
  line-height: 1;
  /* Square 48×48 — Material 48dp rating cell, exceeds Apple 44pt min
     touch target. Aspect ratio fixed (no stretch). */
  width: 48px;
  height: 48px;
  flex: 0 0 48px;
  border-radius: 4px;
  cursor: pointer;
  transition: color 100ms ease, border-color 100ms ease, background 100ms ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.bug-report-rating-star.filled {
  color: var(--gold, #c9a352);
  border-color: var(--gold, #c9a352);
  background: color-mix(in srgb, var(--gold, #c9a352) 12%, transparent);
}

.bug-report-rating-star:focus-visible {
  outline: 2px solid var(--gold, #c9a352);
  outline-offset: 2px;
}

.bug-report-rating-anchors {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  /* WCAG AA: bumped from #4a6080 (≈2.5:1 on bg) to #8395ad (≈4.6:1).
     Important here because anchors are the only label tying a star
     count to its meaning. */
  color: #8395ad;
}

/* ─── Reason radio (exit-intent only) ─── */

.bug-report-reasons {
  margin: 16px 20px 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.bug-report-reason-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  background: var(--bg-primary, #080c10);
  border: 1px solid var(--border, #1a2535);
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-primary, #e0e8f0);
  transition: border-color 120ms ease, background 120ms ease;
}

.bug-report-reason-item:hover {
  border-color: var(--gold, #c9a352);
}

.bug-report-reason-radio {
  accent-color: var(--gold, #c9a352);
  margin: 0;
}

/* ─── Toast variant (exit-intent slide-in, top-left under feedback buttons) ─── */

.bug-report-overlay.bug-report-variant-toast {
  background: transparent;
  backdrop-filter: none;
  align-items: flex-start;
  justify-content: flex-start;
  /* Feedback buttons sit at top:56px, height 44px → bottom edge 100px.
     8px gap = 108px top. Left aligned with the bug button (~232px). */
  padding: 108px 16px 16px 232px;
  pointer-events: none; /* let canvas/UI keep working under the toast */
}

.bug-report-overlay.bug-report-variant-toast .bug-report-panel {
  pointer-events: auto;
  max-width: 380px;
  animation: bug-report-toast-in 220ms ease-out;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.55);
  border-color: var(--gold, #c9a352);
}

@keyframes bug-report-toast-in {
  from { transform: translateX(-40px); opacity: 0; }
  to   { transform: translateX(0);     opacity: 1; }
}

/* Narrow viewports */
@media (max-width: 600px) {
  .bug-report-overlay { padding: 12px; }
  .bug-report-overlay.bug-report-variant-toast { padding: 108px 8px 8px 232px; }
  .bug-report-panel { max-height: 96vh; }
  .bug-report-header,
  .bug-report-preview,
  .bug-report-text,
  .bug-report-reasons,
  .bug-report-details-toggle,
  .bug-report-details-panel,
  .bug-report-status,
  .bug-report-footer { margin-left: 14px; margin-right: 14px; }
  /* Buttons keep their top-left battlefield anchor on narrow viewports;
     mobile isn't a supported target and overriding here would just drift
     the absolute pixel offsets out of sync with the desktop rule. */
}
