/* K2AI One Cloud: the Feedback button and popover, dialect C (spec 8.2 [ADDITION 2026-10-09]).
   Linked by templates/onboarding/_feedback.html on the landing, pricing, sign-in,
   sign-up, status, account and billing pages. Colours come from tokens.css; every
   rule is scoped under .fb so the landing page's global h2/p/a rules cannot leak in.
   The button sits bottom-right with a 44 px target; --k2-dock-height lifts it above
   a bottom dock on pages that have one (none of the gateway pages do today), and the
   in-flow .fb-spacer keeps the last content of a page scrollable above it at 390 px. */
@import url("tokens.css");

.fb { --fb-gap: 16px; --fb-lift: calc(var(--k2-dock-height, 0px) + env(safe-area-inset-bottom, 0px)); }
.fb [hidden] { display: none !important; }
.fb, .fb * { box-sizing: border-box; }

.fb-tab {
  position: fixed; right: var(--fb-gap); bottom: calc(var(--fb-gap) + var(--fb-lift)); z-index: 40;
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
  min-width: 44px; min-height: 44px; padding: 0 1rem;
  background: var(--surface-2); color: var(--text); border: 1px solid var(--border-strong);
  border-radius: var(--radius-pill); box-shadow: var(--shadow);
  font: 600 0.875rem/1 Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  cursor: pointer;
}
.fb-tab:hover { border-color: var(--teal); }
.fb-tab:focus-visible, .fb-btn:focus-visible, .fb-input:focus-visible, .fb-cat input:focus-visible + span,
.fb-check input:focus-visible, .fb-title:focus-visible, .fb a:focus-visible {
  outline: 2px solid var(--teal); outline-offset: 2px;
}
.fb-tab[aria-expanded="true"] { border-color: var(--teal); }

/* The panel: the native popover (top layer) or, where the browser lacks it, the
   script's .is-open class. Two rules, because an unknown pseudo-class would void a list. */
.fb-panel {
  display: none; position: fixed; inset: auto var(--fb-gap) calc(var(--fb-gap) + 44px + 8px + var(--fb-lift)) auto;
  z-index: 41; margin: 0; padding: 1.25rem; width: min(24rem, calc(100vw - 2 * var(--fb-gap)));
  max-height: calc(100vh - 44px - 3 * var(--fb-gap)); max-height: calc(100dvh - 44px - 3 * var(--fb-gap) - var(--fb-lift));
  overflow-y: auto; color: var(--text); background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: var(--radius-panel, 0.75rem); box-shadow: var(--shadow);
  font: 400 0.875rem/1.5 Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
.fb-panel:popover-open { display: block; }
.fb-panel.is-open { display: block; }
.fb-panel::backdrop { background: transparent; }

.fb .fb-title { margin: 0 0 0.75rem; text-align: left; font-size: 1rem; line-height: 1.3; font-weight: 600; color: var(--text); }
.fb .fb-title:focus { outline: none; }
.fb p { margin: 0; color: var(--text-soft); }
.fb a { color: var(--teal); text-decoration: underline; }

.fb-cats { margin: 0 0 0.9rem; padding: 0; border: 0; min-width: 0; }
.fb-legend { padding: 0; margin-bottom: 0.4rem; color: var(--text-soft); font-weight: 500; }
.fb-cat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.4rem; }
.fb-cat { position: relative; display: block; }
.fb-cat input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.fb-cat span {
  display: flex; align-items: center; min-height: 44px; padding: 0.4rem 0.7rem;
  border: 1px solid var(--border-strong); border-radius: var(--radius); color: var(--text-soft); cursor: pointer;
}
.fb-cat input:checked + span { border-color: var(--teal); background: var(--teal-soft); color: var(--text); }
.fb-cat input[aria-invalid="true"] + span { border-color: var(--red); }

.fb-field { display: flex; flex-direction: column; gap: 0.3rem; margin-bottom: 0.9rem; }
.fb-field label { color: var(--text-soft); font-weight: 500; }
.fb-optional { color: var(--text-muted); font-weight: 400; }
.fb-input {
  width: 100%; min-height: 44px; padding: 0.55rem 0.7rem; color: var(--text); background: var(--bg);
  border: 1px solid var(--border-strong); border-radius: var(--radius); font: inherit;
}
.fb-textarea { min-height: 7rem; resize: vertical; }
.fb-input[readonly] { background: var(--surface-2); color: var(--text-soft); }
.fb-input[aria-invalid="true"] { border-color: var(--red); }
.fb-count { align-self: flex-end; font-size: 0.75rem; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.fb-count[data-over] { color: var(--red); }

.fb-check { display: flex; align-items: center; gap: 0.5rem; min-height: 44px; color: var(--text-soft); cursor: pointer; }
.fb-check input { width: 1.1rem; height: 1.1rem; margin: 0; accent-color: var(--blue); }

.fb-hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
.fb-error { margin-top: 0.5rem; color: var(--red); }

.fb-actions { display: flex; justify-content: flex-end; gap: 0.5rem; margin-top: 1rem; }
.fb-btn {
  display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 0 1.1rem;
  border-radius: var(--radius); border: 1px solid transparent; font-family: inherit; font-size: 0.875rem;
  font-weight: 600; line-height: 1; cursor: pointer;
}
.fb-btn-primary { background: var(--blue); color: #fff; }
.fb-btn-primary:hover { background: var(--blue-hover); }
.fb-btn-primary:disabled { opacity: 0.6; cursor: progress; }
.fb-btn-secondary { background: transparent; color: var(--text-soft); border-color: var(--border-strong); }
.fb-btn-secondary:hover { border-color: var(--teal); color: var(--text); }
.fb-support { margin-top: 0.25rem; overflow-wrap: anywhere; }

/* The no-script result: the form post comes back to #feedback-sent or #feedback-failed. */
.fb-note { display: none; }
.fb-note:target {
  display: block; position: fixed; right: var(--fb-gap); bottom: calc(var(--fb-gap) + 44px + 8px + var(--fb-lift));
  z-index: 40; max-width: min(24rem, calc(100vw - 2 * var(--fb-gap))); padding: 0.75rem 1rem;
  background: var(--surface); color: var(--text); border: 1px solid var(--border-strong);
  border-radius: var(--radius-panel, 0.75rem); box-shadow: var(--shadow); font: 400 0.875rem/1.5 Inter, system-ui, sans-serif;
}
.fb-spacer { height: calc(44px + 2 * var(--fb-gap)); }

@media (max-width: 599px) {
  .fb-panel { right: var(--fb-gap); left: var(--fb-gap); width: auto; }
  .fb-cat-grid { grid-template-columns: 1fr; }
}
@media print { .fb { display: none; } }
