/*
  Tools: feedback button, search palette, info dialog and the debug panel.
*/

/* ---------------------------------------------------------------- floating feedback button
   A round icon at rest. Hovering (or reaching it with the keyboard) unfolds its label quietly: small
   type, a short way, no jump; on touch screens it stays an icon (its name is in aria-label). */
.feedback-fab {
  /* one gap on both sides: as far from the right edge as from what is under it – the window's lower
     edge, or the footer's last bar once that scrolls in (--fab-footer-offset, ui/components/feedback.js) */
  --fab-gap: var(--s-5);
  --fab-inset: var(--fab-gap);
  position: fixed; right: var(--fab-gap); bottom: max(var(--fab-inset), calc(var(--fab-footer-offset, 0px) + var(--fab-gap))); z-index: var(--z-fab);
  --unfold: calc(380ms * var(--motion-scale));
  display: inline-flex; align-items: center; height: 42px; padding: 0 11px;
  border: 0; border-radius: var(--r-pill); background: var(--raised); color: var(--ink);
  box-shadow: var(--shadow-md), inset 0 0 0 1px var(--line); font-size: 13px; font-weight: 600; white-space: nowrap;
  transition: padding var(--unfold) var(--ease-io), transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
  animation: rise-in calc(400ms * var(--motion-scale)) var(--ease-enter) calc(900ms * var(--motion-scale)) both;
}
/* the icon itself stays still: only the label unfolds */
.feedback-fab .icon { width: 20px; height: 20px; flex: none; }
/* The label unfolds over exactly its own width (a grid track from 0fr to 1fr), evenly over the whole
   duration. (A max-width far beyond the text let the visible part finish in the first few milliseconds.) */
.feedback-fab__text {
  display: inline-grid; grid-template-columns: 0fr; margin-left: 0; opacity: 0;
  transition: grid-template-columns var(--unfold) var(--ease-io), margin-left var(--unfold) var(--ease-io), opacity var(--dur-panel) var(--ease);
}
.feedback-fab__text > span { min-width: 0; overflow: hidden; }
.feedback-fab:is(:hover, :focus-visible) { padding-right: 14px; box-shadow: var(--shadow-md), inset 0 0 0 1px var(--line-strong); }
.feedback-fab:is(:hover, :focus-visible) .feedback-fab__text { grid-template-columns: 1fr; margin-left: 6px; opacity: 1; }
.feedback-fab:active { transform: scale(.98); }
@media (hover: none) { .feedback-fab:hover { padding-right: 11px; } .feedback-fab:hover .feedback-fab__text { grid-template-columns: 0fr; margin-left: 0; opacity: 0; } }
@media (max-width: 1023px) {
  body.has-sticky-bar .feedback-fab { --fab-inset: calc(var(--fab-gap) + 72px + env(safe-area-inset-bottom)); }
}
@media (max-width: 639px) { .feedback-fab { --fab-gap: var(--s-4); } }
@media print { .feedback-fab { display: none; } }

/* ---------------------------------------------------------------- search dialog */
/* The header's search in a dialog (components/search.js openSearch) where the header shows only its icon:
   the field on top with an X to close, the results in the dialog's own flow – no dropdown in a dialog. */
.search-dialog { margin-top: min(12vh, 120px); }
.search-dialog .dialog__header { display: none; }
.search-dialog .dialog__body { padding: 0; display: flex; flex-direction: column; min-height: 0; }
.header-search--dialog { position: static; display: flex; flex-direction: column; min-height: 0; max-width: none; margin: 0; }
.header-search__bar { display: flex; align-items: center; gap: var(--s-2); padding: var(--s-3) var(--s-3) var(--s-3) var(--s-5); border-bottom: 1px solid var(--line); }
.header-search__bar .pill-field { flex: 1; height: 44px; }
/* one X only: the one that closes (Escape empties the field on a keyboard) */
.header-search__bar .pill-field__clear { display: none; }
.header-search--dialog .header-search__panel {
  position: static; min-width: 0; max-height: min(64vh, 560px); padding: var(--s-2) 0 var(--s-3);
  background: none; box-shadow: none; animation: none;
}
.header-search--dialog :is(.header-search__group, .search-option, .header-search__all) { padding-inline: var(--s-5); }
.header-search--dialog .header-search__chips { padding-inline: var(--s-5); }
/* the highlighted row follows the arrow keys; a finger has none – it only sees the row it presses */
@media (hover: none) and (pointer: coarse) {
  .header-search__panel .is-active { background: none; box-shadow: none; }
  .header-search__panel :is(.search-option, .header-search__all):active { background: var(--highlight); }
}
[data-surface="mobile"] .header-search__panel .is-active { background: none; box-shadow: none; }
[data-surface="mobile"] .header-search__panel :is(.search-option, .header-search__all):active { background: var(--highlight); }
/* phones: the search takes the whole screen from the top, where the thumb meets the keyboard below */
@media (max-width: 639px) {
  .search-dialog.dialog--center { margin: 0; width: 100vw; max-width: 100vw; height: 100dvh; max-height: 100dvh; }
  .search-dialog .dialog__panel { height: 100%; border-radius: 0; padding-top: env(safe-area-inset-top); }
  .search-dialog.dialog--center[open] { animation: fade-in var(--dur-panel) var(--ease-enter); }
  .search-dialog.dialog--center.is-closing { animation: fade-out var(--dur) var(--ease) forwards; }
  .header-search--dialog { flex: 1; }
  .header-search--dialog .header-search__panel { flex: 1; max-height: none; overflow-y: auto; }
}

/* ---------------------------------------------------------------- info dialog */
/* no close button in the footer (the ✕, Escape or a click outside close it): its two links sit left */
#info-dialog .dialog__footer { justify-content: flex-start; }
.info { display: grid; gap: var(--s-4); }
/* the about block: the mark on its own (no tile, so it reads larger), name and line beside it,
   then the facts across the full width, starting on the dialog's left edge */
.info__about { display: grid; gap: var(--s-5); }
.info__intro { display: flex; gap: var(--s-5); align-items: center; }
.info__intro > div { display: grid; gap: var(--s-2); flex: 1; }
.info__mark { display: block; flex: none; }
.info__mark { --logo-h: 53px; }
.info__name { font-size: var(--t-h3); letter-spacing: var(--tracking-display); }
.info__lede { color: var(--muted); }
.info__section { display: grid; gap: var(--s-3); }
/* every part of the dialog is set off from the one above by a semi-transparent hairline */
.info > * + * { padding-top: var(--s-4); border-top: 1px solid var(--line); }
.info__facts > div:last-child { border-bottom: 0; }
.info__heading { display: flex; align-items: center; gap: var(--s-2); font-size: var(--t-body); font-weight: 600; letter-spacing: 0; }
.info__heading .icon { width: 18px; height: 18px; }
.info__changes { display: grid; gap: var(--s-2); }
.info__changes li { position: relative; padding-left: var(--s-5); font-size: var(--t-small); }
.info__changes li::before { content: ""; position: absolute; left: 4px; top: .55em; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 1px var(--line-strong); }
/* shortcuts in the manner of Discord's list: one block per group under its own heading, groups parted
   by a hairline, every shortcut a small card with its name on top and the keys under it */
.shortcut-groups { display: grid; }
.shortcut-group { display: grid; gap: var(--s-3); padding-block: var(--s-4); }
.shortcut-group:first-child { padding-top: var(--s-1); }
.shortcut-group + .shortcut-group { border-top: 1px solid var(--line); }
.shortcut-group__title { font-size: var(--t-body); font-weight: 600; letter-spacing: 0; }
.shortcut-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: var(--s-2); }
.shortcut-card { display: grid; gap: var(--s-2); align-content: start; padding: var(--s-3); border-radius: var(--r-md); background: var(--highlight); font-size: var(--t-small); }
.shortcut-card .kbd-group { justify-self: start; }
@media (max-width: 639px) { .info__intro { flex-direction: column; align-items: flex-start; gap: var(--s-3); } .info__mark { --logo-h: 38px; } }

/* ---------------------------------------------------------------- debug panel (non-modal, docked) */
.debug {
  position: fixed; inset: auto auto var(--s-4) var(--s-4); z-index: 400; margin: 0; padding: 0; border: 0;
  width: min(420px, calc(100vw - 32px)); max-height: min(70dvh, 620px);
  background: none; color: var(--ink); overflow: visible;
}
.debug[open] { display: block; animation: dialog-in var(--dur-panel) var(--ease-enter); }
.debug.is-closing { animation: dialog-out var(--dur) var(--ease) forwards; }
.debug__panel { display: flex; flex-direction: column; max-height: inherit; overflow: hidden; border-radius: var(--r-lg); background: var(--raised); box-shadow: var(--shadow-lg), inset 0 0 0 1px var(--line-strong); }
.debug__header { display: flex; align-items: center; gap: var(--s-2); padding: var(--s-2) var(--s-2) var(--s-2) var(--s-4); border-bottom: 1px solid var(--line); background: var(--highlight); box-shadow: inset 0 -2px 0 var(--accent); }
.debug__title { display: flex; align-items: center; gap: 6px; font-size: var(--t-small); font-weight: 700; margin-right: auto; }
.debug__title .icon { width: 16px; height: 16px; }
.debug__body { padding: var(--s-3) var(--s-4) var(--s-4); overflow-y: auto; overscroll-behavior: contain; display: grid; gap: var(--s-3); align-content: start; }
.debug-log__bar { display: flex; gap: var(--s-2); }
.debug-log { display: grid; font: 12px/1.5 var(--font-mono); }
.debug-log__entry { display: grid; grid-template-columns: auto auto 1fr; gap: var(--s-2); padding: 4px 0; border-bottom: 1px solid var(--line); animation: fade-in var(--dur) var(--ease); }
.debug-log__entry time { color: var(--muted); }
.debug-log__scope { color: var(--info); }
.debug-log__entry.is-warn .debug-log__msg { color: var(--warn); }
.debug-log__entry.is-error .debug-log__msg { color: var(--danger); font-weight: 600; }
.debug-log__msg { overflow-wrap: anywhere; }
.debug-list { display: grid; gap: 2px; font-size: 12px; }
.debug-tools { display: grid; gap: var(--s-2); }
.debug-tools .toggle { border-bottom: 1px solid var(--line); }
.debug-tools__actions { display: flex; flex-wrap: wrap; gap: var(--s-2); margin-top: var(--s-2); }
@media (max-width: 639px) { .debug { inset: auto var(--s-2) var(--s-2) var(--s-2); width: auto; } }
