/* palette.css — R291 (W8-palette / U15) command palette + shortcuts modal styling.
 *
 * Scoped to the canonical openModal({id:'palette'|'shortcuts'}) backdrop
 * built by kit/_palette.js + kit/_shortcuts-modal.js. The .modal-backdrop
 * + .modal class chain comes from kit/modals.js; this file just styles
 * the inner palette/shortcuts content. All colors, radii, and durations
 * pull from frontend/web/src/colors_and_type.css design tokens.
 *
 * Why a separate file?
 *  - kit/index.html already has ~2680 lines of inline <style>, audit
 *    P2-U15 flagged this duplication. New surfaces live in CSS files.
 *  - palette + shortcuts share kbd/row styling — collocate so changes
 *    stay in sync.
 */

/* =====================================================================
   Palette modal — input + listbox
   ===================================================================== */

.modal-backdrop#palette .modal {
  width: min(720px, 100vw - 32px);
  max-height: min(640px, 90vh);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.modal-backdrop#palette .modal-head {
  display: none; /* The palette uses its input row as its own header */
}
.modal-backdrop#palette .modal-body {
  padding: 0;
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}

.palette-body {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
}

.palette-input-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-1);
  background: var(--bg-app);
}
.palette-input-row > i {
  color: var(--fg-3);
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
}
.palette-input-row > i[data-lucide] {
  display: inline-block;
}
.palette-input-row input {
  flex: 1 1 auto;
  border: 0;
  outline: 0;
  background: transparent;
  font-family: inherit;
  font-size: var(--fs-md);
  font-weight: var(--fw-500);
  color: var(--fg-1);
  padding: 4px 0;
}
.palette-input-row input::placeholder {
  color: var(--fg-3);
  font-weight: var(--fw-400);
}

.palette-list {
  list-style: none;
  margin: 0;
  padding: 6px 0;
  flex: 1 1 auto;
  overflow-y: auto;
  background: var(--bg-card, #fff);
  min-height: 200px;
}

.palette-group-label {
  font-size: 11px;
  font-weight: var(--fw-700);
  color: var(--fg-3);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 10px 18px 4px;
}
.palette-group-label:first-child { padding-top: 6px; }

.palette-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 18px;
  cursor: pointer;
  user-select: none;
  border-left: 2px solid transparent;
  transition: background var(--dur-fast, .12s) var(--ease-standard, ease);
}
.palette-row.is-active,
.palette-row:hover {
  background: var(--bg-app, #f5f7fb);
}
.palette-row.is-active {
  border-left-color: var(--dnuv-blue-light, #3CB3FE);
}
.palette-row:focus-visible {
  outline: 2px solid var(--dnuv-blue-light, #3CB3FE);
  outline-offset: -2px;
}

.palette-row-ico {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  color: var(--fg-2);
}
.palette-row-main {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.palette-row-label {
  font-size: var(--fs-sm);
  font-weight: var(--fw-500);
  color: var(--fg-1);
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.palette-row-label mark {
  background: rgba(60, 179, 254, 0.18);
  color: inherit;
  border-radius: 3px;
  padding: 0 1px;
  font-weight: var(--fw-700);
}
.palette-row-hint {
  font-size: 12px;
  color: var(--fg-3);
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.palette-row-kbd {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
}
.palette-row-kbd kbd {
  display: inline-block;
  min-width: 18px;
  padding: 2px 6px;
  font-family: var(--font-sans);
  font-size: 11px;
  line-height: 1.2;
  font-weight: var(--fw-600);
  color: var(--fg-2);
  background: var(--bg-app);
  border: 1px solid var(--border-1);
  border-radius: 4px;
  text-align: center;
}
.palette-row-pin {
  width: 14px;
  height: 14px;
  color: var(--fg-3);
}
.palette-row-pin.pinned {
  color: var(--dnuv-blue-light, #3CB3FE);
}

.palette-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 48px 18px;
  color: var(--fg-3);
  list-style: none;
  cursor: default;
}
.palette-empty i {
  width: 32px;
  height: 32px;
  opacity: 0.6;
}
.palette-empty span {
  font-size: var(--fs-sm);
}

.palette-foot {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 10px 18px;
  border-top: 1px solid var(--border-1);
  background: var(--bg-app);
  font-size: 12px;
  color: var(--fg-3);
  flex: 0 0 auto;
}
.palette-foot kbd {
  display: inline-block;
  min-width: 18px;
  padding: 1px 5px;
  margin: 0 2px;
  font-family: var(--font-sans);
  font-size: 11px;
  line-height: 1.2;
  font-weight: var(--fw-600);
  color: var(--fg-2);
  background: #fff;
  border: 1px solid var(--border-1);
  border-radius: 3px;
}
.palette-foot-right {
  margin-left: auto;
}
.palette-foot-right a {
  color: var(--dnuv-blue-light, #3CB3FE);
  text-decoration: none;
  font-weight: var(--fw-600);
}
.palette-foot-right a:hover { text-decoration: underline; }

/* =====================================================================
   Shortcuts modal
   ===================================================================== */

.modal-backdrop#shortcuts .modal {
  width: min(760px, 100vw - 32px);
  max-height: 80vh;
}
.modal-backdrop#shortcuts .modal-body {
  overflow-y: auto;
}

.shortcuts-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.shortcuts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}
.shortcuts-section {
  background: var(--bg-app);
  border: 1px solid var(--border-1);
  border-radius: 8px;
  padding: 12px 14px;
}
.shortcuts-section-head {
  margin: 0 0 8px;
  font-size: 12px;
  font-weight: var(--fw-700);
  color: var(--fg-2);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.shortcuts-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.shortcuts-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 0;
  border-top: 1px dashed var(--border-1);
}
.shortcuts-row:first-child { border-top: 0; }
.shortcuts-label {
  flex: 1 1 auto;
  font-size: var(--fs-sm);
  color: var(--fg-1);
}
.shortcuts-kbd {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex: 0 0 auto;
}
.shortcuts-kbd kbd {
  display: inline-block;
  min-width: 22px;
  padding: 2px 6px;
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: var(--fw-600);
  color: var(--fg-2);
  background: #fff;
  border: 1px solid var(--border-1);
  border-radius: 4px;
}
.shortcuts-foot {
  margin: 8px 4px 0;
  font-size: 12px;
  color: var(--fg-3);
}
.shortcuts-foot kbd {
  display: inline-block;
  min-width: 18px;
  padding: 1px 5px;
  margin: 0 2px;
  font-size: 11px;
  font-weight: var(--fw-600);
  color: var(--fg-2);
  background: var(--bg-app);
  border: 1px solid var(--border-1);
  border-radius: 3px;
}
.shortcuts-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 32px;
  color: var(--fg-3);
}
.shortcuts-empty i { width: 32px; height: 32px; opacity: 0.6; }

/* =====================================================================
   Dark mode adjustments (data-theme="dark" toggles on <html>).
   ===================================================================== */
html[data-theme="dark"] .palette-list,
html[data-theme="dark"] .modal-backdrop#palette .modal {
  background: var(--bg-card, #11182a);
}
html[data-theme="dark"] .palette-row.is-active,
html[data-theme="dark"] .palette-row:hover {
  background: rgba(60, 179, 254, 0.08);
}
html[data-theme="dark"] .palette-foot kbd,
html[data-theme="dark"] .shortcuts-kbd kbd {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.1);
}
html[data-theme="dark"] .palette-row-label mark {
  background: rgba(60, 179, 254, 0.28);
  color: #fff;
}

/* Respect reduced motion — keep visible focus but skip transitions. */
@media (prefers-reduced-motion: reduce) {
  .palette-row { transition: none; }
}

/* Mobile / narrow viewport tightening. */
@media (max-width: 600px) {
  .modal-backdrop#palette .modal,
  .modal-backdrop#shortcuts .modal {
    width: 100vw;
    max-width: 100vw;
    max-height: 100vh;
    border-radius: 0;
  }
  .palette-foot { flex-wrap: wrap; gap: 10px; }
  .shortcuts-grid { grid-template-columns: 1fr; }
}
