/* OBSCURA OS: the Engineering Suite's productivity dialogs, for both
   halves: the undo history (pro-code/cad-history-panel.js), the keyboard
   shortcuts and Foundry's command aliases (pro-code/eng-keys.js,
   pro-code/foundry-ux.js), the templates (pro-code/eng-templates.js and
   foundry-ux.js), the plug-ins (pro-code/cad-plugins.js), and the
   printed shortcut sheet. They sit inside
   cad-files.css's dialogs, on the design system's tokens (theme.css). */

/* The undo history: the steps, oldest first, the one shown marked. */
.cad-hist-dlg { width: min(460px, calc(100vw - 32px)); }
.cad-hist { display: grid; gap: 2px; margin: var(--space-2) 0 0; padding: 0; list-style: none; max-height: min(60vh, 520px); overflow-y: auto; }
.cad-hist-step { display: flex; align-items: center; gap: var(--space-2); width: 100%; min-height: 36px; padding: 6px 10px; border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--ink); font: inherit; font-size: var(--text-sm); text-align: left; cursor: pointer; }
.cad-hist-step:hover, .cad-hist-step:focus-visible { background: var(--paper-inset); outline: none; }
.cad-hist-now { background: var(--accent-soft); color: var(--accent-strong); font-weight: 600; }
.cad-hist-redo { color: var(--ink-faint); }
.cad-hist-redo .cad-hist-label { text-decoration: line-through; text-decoration-color: var(--rule-strong); }
.cad-hist-n { width: 2.4em; flex: none; font: var(--text-2xs) var(--font-mono); color: var(--ink-faint); text-align: right; }
.cad-hist-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cad-hist-tag { flex: none; font-size: var(--text-2xs); font-weight: 500; }
.cad-hist-empty { padding: var(--space-2); font-size: var(--text-sm); color: var(--ink-faint); }

/* Keys and aliases: a table a group, the key in a box. */
.cad-keys { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(420px, 100%), 1fr)); gap: var(--space-2) var(--space-5); }
.cad-keys-group h3 { margin: var(--space-3) 0 var(--space-1); font-size: var(--text-2xs); font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-faint); }
.cad-keys table { width: 100%; border-collapse: collapse; font-size: var(--text-xs); }
.cad-keys th, .cad-keys td { padding: 3px 4px; border-bottom: 1px solid var(--rule); text-align: left; vertical-align: middle; }
.cad-keys th { font-weight: 400; color: var(--ink); }
.cad-keys kbd { display: inline-block; min-width: 2.2em; padding: 1px 6px; border: 1px solid var(--rule-strong); border-radius: var(--radius-sm); background: var(--paper); font: var(--text-2xs) var(--font-mono); text-align: center; white-space: nowrap; }
.cad-keys-acts { white-space: nowrap; text-align: right; }
.cad-keys .cad-in { min-height: 30px; padding: 3px 6px; font-family: var(--font-mono); font-size: var(--text-2xs); }

/* Templates: a heading over each set of cards. */
.eng-tpl-h { margin: var(--space-4) 0 var(--space-2); font-size: var(--text-sm); font-weight: 600; }
.eng-tpl-cards .cad-open { padding: var(--space-3); gap: var(--space-1); }
.eng-tpl-cards .cad-name, .eng-tpl-cards .cad-meta { padding: 0; }
.eng-tpl-cards .cad-meta { font-size: var(--text-2xs); line-height: 1.45; }
.eng-gear[hidden] { display: none; }

/* Plug-ins: the list down the side, the chosen one beside it. */
.cad-plug { display: grid; grid-template-columns: minmax(180px, 230px) minmax(0, 1fr); gap: var(--space-4); align-items: start; }
.cad-plug-side { display: grid; gap: var(--space-3); }
.cad-plug-list { display: grid; gap: 2px; margin: 0; padding: 0; list-style: none; }
.cad-plug-h { margin: var(--space-2) 0 2px; font: 600 var(--text-2xs) var(--font-mono); letter-spacing: .08em; text-transform: uppercase; color: var(--ink-faint); }
.cad-plug-h:first-child { margin-top: 0; }
.cad-plug-none { padding: 4px 10px; font-size: var(--text-xs); color: var(--ink-faint); }
.cad-plug-pick { display: block; width: 100%; min-height: 36px; padding: 6px 10px; border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--ink); font: inherit; font-size: var(--text-sm); text-align: left; cursor: pointer; }
.cad-plug-pick .cad-name { padding: 0; font-weight: 500; }
.cad-plug-pick:hover { background: var(--paper-inset); }
.cad-plug-pick:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.cad-plug-pick[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent-strong); }
.cad-plug-install { justify-self: start; min-height: 40px; }
.cad-plug-main { min-width: 0; padding-left: var(--space-4); border-left: 1px solid var(--rule); min-height: 200px; }
.cad-plug-name { margin: 0 0 var(--space-1); font-size: var(--text-lg); font-weight: 600; }
.cad-plug-form .cad-lead { margin-bottom: var(--space-2); }
.cad-plug-num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.cad-plug-doc { margin-top: var(--space-4); padding-top: var(--space-3); border-top: 1px solid var(--rule); font-size: var(--text-xs); color: var(--ink-soft); }
.cad-plug-doc summary { min-height: 32px; font-size: var(--text-sm); font-weight: 600; color: var(--ink); cursor: pointer; }
.cad-plug-ref p { margin: var(--space-2) 0; line-height: 1.55; }
.cad-plug-ref code { font: var(--text-2xs) var(--font-mono); }
.cad-plug-ref pre { margin: var(--space-2) 0; padding: var(--space-3); overflow-x: auto; border-radius: var(--radius-sm); background: var(--paper-inset); font: var(--text-2xs)/1.5 var(--font-mono); color: var(--ink); }

/* The shortcut sheet: only it, on paper. */
.cad-print-sheet { display: none; }
@media print {
  html.cad-printing body > *:not(.cad-print-sheet) { display: none !important; }
  html.cad-printing .cad-print-sheet { display: block; color: black; font-size: 10pt; }
  .cad-print-sheet h1 { margin: 0 0 4pt; font-size: 16pt; }
  .cad-print-sheet p { margin: 0 0 10pt; }
  .cad-print-sheet table { width: 100%; border-collapse: collapse; columns: 2; }
  .cad-print-sheet th, .cad-print-sheet td { padding: 2pt 6pt 2pt 0; border-bottom: 0.5pt solid gray; text-align: left; vertical-align: top; }
  .cad-print-sheet tbody th { width: 34%; font-family: var(--font-mono); font-weight: 600; }
}

@media (max-width: 720px), (pointer: coarse) {
  .cad-hist-step, .cad-keys .cad-link, .cad-keys .cad-in, .cad-plug-pick, .cad-plug-install { min-height: 44px; }
}
@media (max-width: 720px) {
  .cad-plug { grid-template-columns: minmax(0, 1fr); }
  .cad-plug-main { padding-left: 0; padding-top: var(--space-3); border-left: 0; border-top: 1px solid var(--rule); min-height: 0; }
}
