/* ============================================================
   FIGHTERSTATUS — on-page feedback widget (templates/feedback/widget.html,
   static/js/feedback.js; docs/feedback-feature-spec.md §5.3).
   Site tokens only (fighterstatus.css). Layers: the badges (35) and the
   hover box (36) are pinned to page blocks, so they stay under the sticky
   nav — a stacking context at 50, which every nav popover and the drawer
   live inside — and under the mobile nav scrim (40). The tab (85) and the
   panel (86) are fixed chrome above the nav; the toasts (90) stay on top.
   ============================================================ */

/* ---- The tab: right edge, vertically centred ---- */
.fb-tab {
  position: fixed; right: 0; top: 50%; z-index: 85;
  transform: translateY(-50%) rotate(180deg);
  writing-mode: vertical-rl;
  display: inline-flex; align-items: center; gap: 8px;
  padding: 14px 9px; margin: 0;
  background: var(--bg-800); color: var(--fg-2);
  /* Rotated half a turn so the label reads bottom-to-top: the box's left
     edge is the one against the screen edge, its right corners face the page. */
  border: 1px solid var(--line-strong); border-left: none;
  border-radius: 0 10px 10px 0;
  box-shadow: var(--shadow-pop);
  font-family: var(--font-label); font-weight: 700; font-size: 11.5px;
  letter-spacing: 0.12em; text-transform: uppercase;
  cursor: pointer; transition: color .18s, background .18s, right .22s;
}
.fb-tab svg { transform: rotate(180deg); color: var(--crimson-bright) !important; }
.fb-tab:hover, .fb-tab[aria-expanded="true"] { color: var(--fg); background: var(--bg-750); }
.fb-tab:focus-visible { outline: 2px solid var(--crimson-bright); outline-offset: 2px; }
html.fb-open .fb-tab { right: 360px; }

/* ---- The panel: a 360px drawer on the right ---- */
.fb-panel {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 86;
  width: 360px; max-width: 100vw;
  display: flex; flex-direction: column;
  background: var(--bg-800); color: var(--fg);
  border-left: 1px solid var(--line-strong);
  box-shadow: var(--shadow-pop);
  font-family: var(--font-body);
}
.fb-panel[hidden] { display: none; }
@media (prefers-reduced-motion: no-preference) {
  .fb-panel { animation: fbSlide .22s cubic-bezier(.2,.7,.2,1); }
}
@keyframes fbSlide { from { transform: translateX(24px); opacity: 0; } to { transform: none; opacity: 1; } }

.fb-panel-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; border-bottom: 1px solid var(--line);
}
.fb-kicker {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: var(--font-label); font-weight: 700; font-size: 12px;
  letter-spacing: 0.12em; text-transform: uppercase; color: var(--fg-2);
}
.fb-kicker svg { color: var(--crimson-bright) !important; }
.fb-admin-tag {
  padding: 2px 7px; border-radius: 5px; font-size: 10px; letter-spacing: 0.1em;
  background: var(--crimson-tint); color: var(--crimson-bright);
}
.fb-x {
  background: none; border: none; color: var(--fg-3); cursor: pointer;
  font-size: 24px; line-height: 1; padding: 2px 6px; border-radius: 6px;
}
.fb-x:hover { color: var(--fg); background: var(--bg-750); }

.fb-panel-body { flex: 1; overflow-y: auto; padding: 18px 18px 24px; overscroll-behavior: contain; }
.fb-screen[hidden], .fb-panel [hidden] { display: none !important; }

.fb-h {
  margin: 0 0 10px; font-family: var(--font-display); font-weight: 700;
  font-size: 22px; line-height: 1.15; text-transform: uppercase; letter-spacing: 0.01em;
}
.fb-h:focus { outline: none; }
.fb-h:focus-visible { outline: 2px solid var(--crimson-bright); outline-offset: 3px; }
.fb-h3 {
  margin: 22px 0 8px; font-family: var(--font-label); font-weight: 700; font-size: 11.5px;
  letter-spacing: 0.12em; text-transform: uppercase; color: var(--fg-3);
}
.fb-p { margin: 0 0 12px; font-size: 13.5px; line-height: 1.6; color: var(--fg-2); }
.fb-note { margin: 12px 0 0; font-size: 12.5px; line-height: 1.55; color: var(--fg-3); }
.fb-steps { margin: 0 0 16px; padding-left: 20px; font-size: 13.5px; line-height: 1.55; color: var(--fg-2); }
.fb-steps li { margin-bottom: 6px; }
.fb-steps li::marker { color: var(--crimson-bright); font-weight: 700; }
.fb-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 14px; }
.fb-linkbtn {
  background: none; border: none; padding: 4px 2px; cursor: pointer;
  color: var(--fg-3); font: inherit; font-size: 12.5px; font-weight: 600;
  text-decoration: underline; text-underline-offset: 3px;
}
.fb-linkbtn:hover { color: var(--crimson-bright); }
.fb-linkbtn:disabled { opacity: .55; cursor: default; }
.fb-linkbtn:disabled:hover { color: var(--fg-3); }
.fb-seg input:disabled { cursor: default; }

/* ---- The selected block ---- */
.fb-target { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.fb-chip {
  min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  padding: 5px 10px; border-radius: 7px; font-size: 12.5px; font-weight: 700;
  background: var(--crimson-tint); color: var(--fg); border: 1px solid color-mix(in srgb, var(--crimson) 45%, transparent);
}
.fb-snippet {
  margin: 0 0 14px; font-size: 12.5px; line-height: 1.5; color: var(--fg-3);
  display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}

/* ---- The form ---- */
.fb-form { display: flex; flex-direction: column; gap: 12px; }
.fb-field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.fb-field label { font-size: 12px; font-weight: 600; color: var(--fg-2); line-height: 1.4; }
.fb-field input, .fb-field select, .fb-field textarea {
  width: 100%; padding: 9px 10px; border-radius: 8px;
  background: var(--bg-750); color: var(--fg); border: 1px solid var(--line-strong);
  font: inherit; font-size: 13.5px; line-height: 1.45;
}
.fb-field textarea { resize: vertical; min-height: 96px; }
.fb-field input:focus-visible, .fb-field select:focus-visible, .fb-field textarea:focus-visible {
  outline: 2px solid var(--crimson-bright); outline-offset: 1px; border-color: transparent;
}
.fb-row { display: grid; grid-template-columns: 1.4fr 1fr 1fr; gap: 8px; }

.fb-seg { display: flex; margin: 0; padding: 3px; border: 1px solid var(--line-strong); border-radius: 9px; background: var(--bg-750); }
.fb-seg label { flex: 1; position: relative; }
.fb-seg input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.fb-seg span {
  display: block; text-align: center; padding: 7px 6px; border-radius: 7px;
  font-family: var(--font-label); font-weight: 700; font-size: 11.5px;
  letter-spacing: 0.1em; text-transform: uppercase; color: var(--fg-3);
  transition: background .15s, color .15s;
}
.fb-seg input:checked + span { background: var(--crimson); color: #fff; }
.fb-seg input:focus-visible + span { outline: 2px solid var(--crimson-bright); outline-offset: 1px; }

.fb-stored { font-size: 12px; color: var(--fg-3); }
.fb-stored summary { cursor: pointer; font-weight: 600; }
.fb-stored p { margin: 6px 0 0; white-space: pre-line; line-height: 1.5; }

.fb-error, .fb-warn {
  margin: 0; padding: 9px 11px; border-radius: 8px; font-size: 12.5px; line-height: 1.5;
  color: var(--fg); background: var(--crimson-tint);
  border: 1px solid color-mix(in srgb, var(--crimson) 45%, transparent);
}
.fb-status { font-size: 12px; color: var(--fg-3); }
.fb-ident { font-family: var(--font-label); font-weight: 700; letter-spacing: 0.05em; color: var(--crimson-bright); }
.fb-panel a { color: var(--crimson-bright); }
.fb-panel a.cta-btn.primary { color: #fff; }
.fb-panel a.cta-btn.secondary { color: var(--fg); }

/* ---- Item rows ---- */
.fb-items { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.fb-item {
  padding: 10px 11px; border-radius: 10px; background: var(--bg-750);
  border: 1px solid var(--line); display: flex; flex-direction: column; gap: 5px;
}
.fb-item--hl { border-color: var(--crimson-bright); box-shadow: 0 0 0 1px var(--crimson-bright) inset; }
.fb-item-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 11px; color: var(--fg-3); }
.fb-st, .fb-kind {
  padding: 2px 7px; border-radius: 5px; font-family: var(--font-label); font-weight: 700;
  font-size: 10.5px; letter-spacing: 0.08em; text-transform: uppercase;
  background: var(--bg-700); color: var(--fg-2);
}
.fb-kind { background: transparent; border: 1px solid var(--line-strong); }
.fb-st-open, .fb-st-unsynced { background: var(--crimson-tint); color: var(--fg); }
.fb-st-sending { background: var(--bg-700); color: var(--fg-2); }
.fb-st-filed, .fb-st-working, .fb-st-review, .fb-st-approval { background: color-mix(in srgb, var(--tier-good) 18%, transparent); color: var(--fg); }
.fb-st-done, .fb-st-resolved { background: color-mix(in srgb, var(--tier-great) 16%, transparent); color: var(--fg); }
.fb-st-dismissed, .fb-st-canceled, .fb-st-promoted { color: var(--fg-3); }
.fb-who { font-weight: 600; }
.fb-item-label {
  align-self: flex-start; max-width: 100%; padding: 0; background: none; border: none;
  font: inherit; font-size: 13px; font-weight: 700; color: var(--fg); text-align: left;
}
button.fb-item-label { cursor: pointer; text-decoration: underline; text-decoration-color: var(--line-strong); text-underline-offset: 3px; }
button.fb-item-label:hover { color: var(--crimson-bright); }
.fb-item-body { margin: 0; font-size: 12.5px; line-height: 1.5; color: var(--fg-2); overflow-wrap: anywhere; }
.fb-item-dash { align-self: flex-start; font-size: 11.5px; font-weight: 600; }

/* ---- Selecting: crosshair, the hover box, the chosen block ---- */
body.fb-selecting [data-fb], body.fb-selecting [data-fb] * { cursor: crosshair !important; }
/* iOS treats the anchors as clickable while selecting (feedback.js gives each
   a click listener) and would flash its grey tap highlight over whole blocks. */
body.fb-selecting [data-fb] { -webkit-tap-highlight-color: transparent; }
/* Keyboard selecting: an anchor reached with Tab shows the same outline. */
body.fb-selecting [data-fb-kb]:focus-visible { outline: 2px solid var(--crimson-bright); outline-offset: 2px; }
.fb-hover {
  position: absolute; z-index: 36; pointer-events: none;
  outline: 2px solid var(--crimson-bright); outline-offset: 2px; border-radius: 4px;
  background: color-mix(in srgb, var(--crimson) 6%, transparent);
}
.fb-hover[hidden] { display: none; }
.fb-hover-label {
  position: absolute; left: -4px; bottom: calc(100% + 4px);
  max-width: min(420px, 90vw); overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  padding: 3px 8px; border-radius: 5px;
  background: var(--crimson); color: #fff;
  font-family: var(--font-label); font-weight: 700; font-size: 11px; letter-spacing: 0.06em;
}
.fb-hover--inside .fb-hover-label { bottom: auto; top: 4px; left: 4px; }
@media (prefers-reduced-motion: no-preference) {
  .fb-hover { transition: top .08s, left .08s, width .08s, height .08s; }
}
.fb-selected { outline: 2px solid var(--crimson-bright) !important; outline-offset: 3px; }

/* ---- Staff badges: open items per block ---- */
.fb-badge {
  position: absolute; z-index: 35; min-width: 22px; height: 22px; padding: 0 6px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 99px; background: var(--crimson); color: #fff;
  font-family: var(--font-label); font-weight: 700; font-size: 11px; line-height: 1;
  box-shadow: 0 0 0 2px var(--bg-900); cursor: pointer;
}
.fb-badge[hidden] { display: none; }
.fb-badge:hover { box-shadow: 0 0 0 2px var(--bg-900), 0 0 0 4px var(--crimson-bright); }

/* ---- Phones: a round button bottom-right, the panel a bottom sheet ---- */
@media (max-width: 640px) {
  .fb-tab {
    top: auto; bottom: 16px; right: 16px; transform: none; writing-mode: horizontal-tb;
    width: 48px; height: 48px; padding: 0; justify-content: center;
    border: 1px solid var(--line-strong); border-radius: 50%;
  }
  .fb-tab span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .fb-tab svg { transform: none; width: 20px; height: 20px; }
  html.fb-open .fb-tab { display: none; }
  .fb-panel {
    top: auto; left: 0; width: 100%; max-height: 70vh;
    border-left: none; border-top: 1px solid var(--line-strong);
    border-radius: 16px 16px 0 0;
    padding-bottom: env(safe-area-inset-bottom, 0);
  }
  @media (prefers-reduced-motion: no-preference) {
    .fb-panel { animation-name: fbRise; }
  }
  .fb-row { grid-template-columns: 1fr 1fr; }
  .fb-row .fb-field:first-child { grid-column: 1 / -1; }
}
@keyframes fbRise { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }

@media print {
  .fb-tab, .fb-panel, .fb-hover, .fb-badge { display: none !important; }
}
