/*
 * Every rule in this file belongs to the demo, not to the package.
 * `@avlon/shortcut-recorder` ships no CSS and no class names: this is what
 * "headless" costs you, and what it buys you.
 */

:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --ink: #111827;
  --muted: #6b7280;
  --line: #e5e7eb;
  --accent: #2563eb;
  --danger: #b42318;
  --danger-bg: #fef3f2;
  --warn: #92400e;
  --warn-bg: #fffaeb;
  --cap-bg: #ffffff;
  --cap-line: #d1d5db;
  --cap-shadow: 0 1px 0 #d1d5db;
  --code-bg: #f3f4f6;
  --ok: #15803d;
  --radius: 10px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b0f17;
    --panel: #121826;
    --ink: #e6e8ec;
    --muted: #9aa3b2;
    --line: #232b3b;
    --accent: #6ea8fe;
    --danger: #ff9c94;
    --danger-bg: #2a1614;
    --warn: #f3cf8a;
    --warn-bg: #2a2113;
    --cap-bg: #1a2230;
    --cap-line: #38415a;
    --cap-shadow: 0 1px 0 #0a0d14;
    --code-bg: #1a2230;
    --ok: #6ee7a8;
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.6 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.page {
  max-width: 860px;
  margin: 0 auto;
  padding: 48px 20px 96px;
}

/* ---- header ---------------------------------------------------------- */

header h1 {
  margin: 0 0 6px;
  font-size: 30px;
  letter-spacing: -0.02em;
}

header p.lede {
  margin: 0 0 20px;
  color: var(--muted);
  font-size: 17px;
  max-width: 62ch;
}

.links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 36px;
}

.links a {
  display: inline-block;
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  color: var(--ink);
  text-decoration: none;
  font-size: 13px;
}

.links a:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* ---- panels ---------------------------------------------------------- */

section {
  margin-bottom: 32px;
}

h2 {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin: 0 0 10px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.panel > * + * {
  border-top: 1px solid var(--line);
}

/* ---- platform switch -------------------------------------------------- */

.switch {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  flex-wrap: wrap;
}

.switch .label {
  color: var(--muted);
  font-size: 13px;
}

.seg {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.seg button {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  padding: 6px 14px;
  cursor: pointer;
}

.seg button[aria-pressed="true"] {
  background: var(--accent);
  color: #fff;
}

.seg button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

/* ---- binding rows ----------------------------------------------------- */

.row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 16px;
  align-items: center;
  padding: 14px 16px;
}

.row .name {
  font-weight: 550;
}

.row .note {
  grid-column: 1 / -1;
  font-size: 13px;
  border-radius: 8px;
  padding: 6px 10px;
  margin-top: 4px;
}

.note.conflict {
  color: var(--danger);
  background: var(--danger-bg);
}

.note.reserved {
  color: var(--warn);
  background: var(--warn-bg);
}

.row .portable {
  grid-column: 1;
  font-size: 12px;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

/* ---- the recorder control -------------------------------------------- */

.recorder {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-width: 190px;
  min-height: 38px;
  justify-content: center;
  padding: 5px 12px;
  border: 1px solid var(--cap-line);
  border-radius: 8px;
  background: var(--panel);
  cursor: pointer;
  font: inherit;
  color: var(--ink);
}

.recorder:hover {
  border-color: var(--accent);
}

.recorder:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.recorder[aria-pressed="true"] {
  border-color: var(--accent);
  border-style: dashed;
  background: transparent;
}

.recorder[aria-invalid="true"] {
  border-color: var(--danger);
}

.recorder .hint {
  color: var(--muted);
  font-size: 13px;
}

kbd {
  display: inline-block;
  min-width: 26px;
  padding: 2px 7px;
  border: 1px solid var(--cap-line);
  border-bottom-width: 2px;
  border-radius: 6px;
  background: var(--cap-bg);
  box-shadow: var(--cap-shadow);
  font: 12px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  text-align: center;
}

.clear {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  font-size: 18px;
  line-height: 1;
  padding: 4px 6px;
  border-radius: 6px;
}

.clear:hover {
  color: var(--danger);
}

.control {
  display: flex;
  align-items: center;
  gap: 4px;
}

/* ---- code ------------------------------------------------------------- */

pre {
  margin: 0;
  padding: 16px;
  overflow-x: auto;
  background: var(--code-bg);
  font: 13px/1.65 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.92em;
}

p.caption {
  color: var(--muted);
  font-size: 13px;
  margin: 8px 2px 0;
}

/* ---- live region ------------------------------------------------------ */

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

footer {
  margin-top: 44px;
  color: var(--muted);
  font-size: 13px;
}

footer a {
  color: var(--accent);
}

/* ---- the settled-recording note --------------------------------------- */

.note-flash.ok {
  color: var(--ok);
}

.note-flash.muted {
  color: var(--muted);
}

.muted {
  color: var(--muted);
}

/* ---- the pretend application ------------------------------------------ */

.app {
  display: flex;
  min-height: 260px;
}

.app-sidebar {
  width: 168px;
  flex: none;
  border-right: 1px solid var(--line);
  padding: 12px 10px;
}

.app-heading {
  margin: 2px 6px 8px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
}

.app-sidebar ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.doc {
  appearance: none;
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  padding: 5px 8px;
  border-radius: 6px;
  cursor: pointer;
}

.doc:hover {
  background: var(--code-bg);
}

.doc.current {
  background: var(--accent);
  color: #fff;
}

.app-main {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.app-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}

.state {
  font-size: 12px;
}

.state.saved {
  color: var(--ok);
}

.state.dirty {
  color: var(--warn);
}

.app-editor {
  flex: 1;
  min-height: 150px;
  resize: vertical;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--ink);
  font: 14px/1.6 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding: 14px;
}

.app-comments {
  list-style: none;
  margin: 0;
  padding: 10px 14px;
  border-top: 1px solid var(--line);
  font-size: 13px;
  color: var(--muted);
}

.app-comments li + li {
  margin-top: 4px;
}

/* ---- palette / search overlay ----------------------------------------- */

.overlay {
  position: absolute;
  inset: 12px 12px auto;
  background: var(--panel);
  border: 1px solid var(--cap-line);
  border-radius: 10px;
  box-shadow: 0 12px 32px rgb(0 0 0 / 22%);
  overflow: hidden;
}

.overlay-input {
  width: 100%;
  border: 0;
  border-bottom: 1px solid var(--line);
  outline: none;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  padding: 11px 14px;
}

.overlay-list {
  list-style: none;
  margin: 0;
  padding: 6px;
  max-height: 168px;
  overflow-y: auto;
}

.overlay-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 8px;
  font-size: 13px;
  border-radius: 6px;
}

.overlay-keys {
  display: inline-flex;
  gap: 4px;
  flex: none;
}

.overlay-pick {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  padding: 0;
  cursor: pointer;
  text-align: left;
  width: 100%;
}

.overlay-pick:hover {
  color: var(--accent);
}

.overlay-foot {
  margin: 0;
  padding: 8px 14px;
  border-top: 1px solid var(--line);
  font-size: 12px;
  color: var(--muted);
}
