/* The demos' shared interface pieces (app/frontend/components/ui): key caps,
   buttons that show their key, avatars, toasts, the first-visit hint and the
   key list. They read the tokens base.css defines and know nothing about any
   one demo, so a page that uses the components needs only this file. */

.ui-icon { flex: none; }

/* --- Key caps -------------------------------------------------------------- */

.ui-keys { display: inline-flex; align-items: center; gap: 3px; flex: none; }

.ui-keys kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  border-radius: 5px;
  border: 1px solid rgba(10, 10, 10, 0.12);
  background: var(--card);
  box-shadow: 0 1px 0 rgba(10, 10, 10, 0.04);
  font: 500 11px/1 var(--mono);
  color: var(--muted);
}

.ui-keys[data-tone=on-accent] kbd, .ui-keys[data-tone=on-ink] kbd {
  border-color: transparent;
  background: rgba(255, 255, 255, 0.2);
  box-shadow: none;
  color: #fff;
}

/* A control does not show a key where there is no keyboard to press it on. */
@media (pointer: coarse) {
  button .ui-keys { display: none; }
}

/* --- A button that shows its key ------------------------------------------- */

button.ui-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 32px;
  padding: 0 12px;
  border: 0;
  border-radius: 9999px;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
}

button.ui-button[data-quiet=true] { background: rgba(126, 114, 96, 0.08); color: var(--ink); box-shadow: none; }
button.ui-button[data-quiet=true]:hover { background: rgba(126, 114, 96, 0.14); filter: none; }
button.ui-button:disabled { cursor: default; }
button.ui-button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* --- Avatar ---------------------------------------------------------------- */

.ui-avatar {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--hairline-soft);
  color: var(--ink-2);
  font-size: 14px;
  font-weight: 600;
}

.ui-avatar[data-size=small] { width: 24px; height: 24px; font-size: 11px; }

/* --- Toasts ---------------------------------------------------------------- */

.ui-toasts {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 390;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: max-content;
  max-width: calc(100vw - 32px);
  transform: translateX(-50%);
  pointer-events: none;
}

.ui-toast {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 42px;
  padding: 6px 8px 6px 16px;
  border-radius: 9999px;
  background: var(--ink);
  color: var(--paper);
  font-size: 14px;
  box-shadow: 0 12px 28px -12px rgba(48, 43, 38, 0.5);
  pointer-events: auto;
  animation: ui-rise 0.16s ease-out;
}

.ui-toast small { font-size: 13px; opacity: 0.7; }

.ui-toast button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 10px;
  border: 0;
  border-radius: 9999px;
  background: rgba(255, 255, 255, 0.12);
  box-shadow: none;
  color: inherit;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.ui-toast button:hover { background: rgba(255, 255, 255, 0.2); filter: none; }
.ui-toast button:focus-visible { outline: 2px solid #fff; outline-offset: 1px; }
.ui-toast .ui-toast-close { width: 30px; padding: 0; justify-content: center; background: none; }

@keyframes ui-rise {
  from { opacity: 0; transform: translateY(6px); }
}

@media (prefers-reduced-motion: reduce) {
  .ui-toast { animation: none; }
}

/* --- First-visit hint ------------------------------------------------------ */

.ui-hint {
  position: fixed;
  left: 50%;
  bottom: 76px;
  z-index: 380;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 9999px;
  background: var(--ink);
  color: var(--paper);
  font-size: 12px;
  font-weight: 500;
  transform: translateX(-50%);
  pointer-events: none;
}

@media (pointer: coarse) {
  .ui-hint { display: none; }
}

/* --- Key list -------------------------------------------------------------- */

.ui-help {
  position: fixed;
  inset: 0;
  z-index: 400;
  display: grid;
  place-items: center;
  background: rgba(48, 43, 38, 0.28);
}

/* Taller than a short window, so the list scrolls inside the card and the
   title and foot stay put. */
.ui-help-card {
  display: flex;
  flex-direction: column;
  width: min(720px, calc(100vw - 32px));
  max-height: min(85vh, 640px);
  border-radius: 16px;
  background: var(--card);
  box-shadow: var(--ring), 0 24px 48px -20px rgba(48, 43, 38, 0.35);
  outline: none;
  overflow: hidden;
}

.ui-help-card h2 { margin: 0; padding: 20px 26px 8px; font-family: var(--serif); font-size: 24px; font-weight: 400; }
.ui-help-groups { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 4px 32px; padding: 4px 26px 16px; overflow-y: auto; min-height: 0; }
.ui-help-card h3 { margin: 12px 0 4px; font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--faint); }
.ui-help-card dl { margin: 0; }
.ui-help-card dl div { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 4px 0; }
.ui-help-card dd { margin: 0; font-size: 14px; color: var(--ink-2); }
.ui-help-card dt { display: flex; align-items: center; gap: 6px; flex: none; }
.ui-help-card dt span { display: inline-flex; align-items: center; gap: 6px; }
.ui-help-card dt i { font-size: 11px; font-style: normal; color: var(--faint); }
.ui-help-foot { display: flex; align-items: center; justify-content: center; gap: 6px; margin: 0; padding: 10px 26px; border-top: 1px solid var(--hairline-soft); background: var(--paper); font-size: 12px; color: var(--muted); }
