/* Blue theme for the Maestro WebUSB page. */
:root {
  --blue-900: #0b2e59;
  --blue-700: #0d4f9c;
  --blue-600: #1263c2;
  --blue-500: #1f78d1;
  --blue-100: #e3effb;
  --blue-50:  #f3f8fe;
  --ink: #1a2433;
  --muted: #5a6b80;
  --line: #c9d9ec;
  --bad: #b3261e;
  --radius: 6px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font: 14px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--blue-50);
}

header {
  background: linear-gradient(90deg, var(--blue-900), var(--blue-700));
  color: #fff;
  padding: 1rem 2rem;
  box-shadow: 0 2px 6px rgb(11 46 89 / 25%);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: .5rem 1rem;
}
header h1 { margin: 0; font-size: 1.4rem; font-weight: 600; letter-spacing: .01em; }
/* Connect and Disconnect at the title bar's right: light buttons on the dark bar. */
header button { background: #fff; border-color: #fff; color: var(--blue-900); font-weight: 600; }
header button:hover:not(:disabled) { background: var(--blue-100); border-color: var(--blue-100); color: var(--blue-900); }
header button:disabled { background: transparent; border-color: rgb(255 255 255 / 35%); color: rgb(255 255 255 / 55%); }
#support { font-size: .85rem; color: rgb(255 255 255 / 75%); }
#support .bad { color: #ffc9c4; }

/* The page uses the window's width, aligned with the header; text keeps its own max-width
   (.note) so lines stay readable. */
main { padding: 1.5rem 2rem 3rem; }

h2 { color: var(--blue-900); margin: 1.75rem 0 .5rem; font-size: 1.25rem; }
h3 {
  color: var(--blue-700);
  margin: 1.75rem 0 .5rem;
  padding-bottom: .25rem;
  border-bottom: 2px solid var(--blue-100);
  font-size: 1.05rem;
}

.note { color: var(--muted); max-width: 52rem; }
.bad { color: var(--bad); font-weight: 600; }
b { color: var(--blue-900); }

button {
  font: inherit;
  padding: .35rem .9rem;
  border: 1px solid var(--blue-600);
  border-radius: var(--radius);
  background: var(--blue-600);
  color: #fff;
  cursor: pointer;
}
button:hover:not(:disabled) { background: var(--blue-700); border-color: var(--blue-700); }
button:disabled { background: #d5dfeb; border-color: #d5dfeb; color: #8193a8; cursor: default; }

input[type=number], input[type=text], select {
  font: inherit;
  padding: .25rem .4rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
}
input[type=number] { width: 5.5rem; }
input:disabled, select:disabled { background: #eef2f7; color: #8193a8; border-color: #dde5ef; }
input:focus, select:focus, button:focus-visible { outline: 2px solid var(--blue-500); outline-offset: 1px; }
input[type=range] { width: min(22rem, 40vw); accent-color: var(--blue-600); }
input[type=checkbox] { accent-color: var(--blue-600); width: 1rem; height: 1rem; }

/* A table wider than the window scrolls sideways in its own box (ui.js table()), so the page
   itself never needs scrolling sideways and nothing is cut off. */
.table-wrap { max-width: 100%; overflow-x: auto; margin: .5rem 0 1.25rem; padding-bottom: 2px; }
table {
  border-collapse: collapse;
  margin: 0;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 1px 2px rgb(11 46 89 / 8%);
}
th, td { padding: .35rem .7rem; text-align: right; border-bottom: 1px solid var(--blue-100); white-space: nowrap; }
th { background: var(--blue-100); color: var(--blue-900); font-weight: 600; }
th:first-child, td:first-child { text-align: left; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--blue-50); }

pre {
  background: var(--blue-900);
  color: #dbe9fb;
  padding: .75rem 1rem;
  border-radius: var(--radius);
  max-height: 16rem;
  overflow: auto;
  font-size: 12px;
}

/* Narrow windows: less padding. */
@media (max-width: 700px) {
  header, main { padding-left: 1rem; padding-right: 1rem; }
}

/* Folding help text, closed by default. */
details.help { margin: .25rem 0 .75rem; }
/* A heading right after a fold (the Settings tab's board name) needs no extra gap above it. */
details.help + h2 { margin-top: 0; }
details.help summary {
  cursor: pointer;
  color: var(--blue-700);
  font-weight: 600;
  width: fit-content;
}
details.help summary:hover { color: var(--blue-500); }
details.help[open] {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: .5rem 1rem .25rem;
}
/* A fold whose content is a callout: the callout is the panel. */
details.help.callout-help[open] { background: none; border: 0; padding: 0; }

/* A number the browser considers out of range or off-step, until it is corrected on change. */
input[type=number]:invalid { border-color: var(--bad); background: #fdf0ef; }

/* The latest result, in a full-width strip just below the title bar (and in the log):
   plain when idle, green for a success, red for an error. It stays at the top while scrolling. */
#status {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: .55rem 2rem;
  background: var(--blue-100);
  border-bottom: 1px solid var(--line);
  color: var(--blue-900);
  font-weight: 600;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: .25rem 1rem;
}
/* Which build is running (build-info.js), small and quiet at the status bar's right. */
#status .build { font-size: .8rem; font-weight: 400; color: var(--muted); }
#status .build a { color: inherit; text-decoration: underline dotted; }
#status .build a:hover { color: var(--blue-700); }
#status.ok { background: #e3f4ea; border-color: #9fd4b4; color: #14532d; }
#status.bad { background: #fbe4e2; border-color: #eba59f; color: var(--bad); }
#status.flash { animation: status-flash .8s ease-out; }
@keyframes status-flash { from { filter: brightness(.85); } to { filter: none; } }
@media (prefers-reduced-motion: reduce) { #status.flash { animation: none; } }
@media (max-width: 700px) { #status { padding-left: 1rem; padding-right: 1rem; } }

/* A channel's name beside its number (channel and sequence tables). */
.channel-name { color: var(--muted); font-size: .85em; }

/* Settings file section. */
.file-pick input[type=file] { font: inherit; margin-left: .4rem; }
.import-preview {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: .5rem 1rem;
  margin-bottom: 1rem;
}
.import-preview ul { margin: .25rem 0 .75rem; }

/* WebUSB support and the Connect / Disconnect buttons, in the title bar. */
.connect-bar { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }

/* Tabs. */
[role=tablist] {
  display: flex;
  gap: .25rem;
  border-bottom: 2px solid var(--line);
  margin-bottom: .5rem;
}
[role=tab] {
  background: transparent;
  color: var(--blue-700);
  border: 1px solid transparent;
  border-bottom: none;
  border-radius: var(--radius) var(--radius) 0 0;
  padding: .5rem 1.2rem;
  margin-bottom: -2px;
  font-weight: 600;
}
[role=tab]:hover:not(:disabled) { background: var(--blue-100); border-color: transparent; color: var(--blue-900); }
[role=tab][aria-selected=true] {
  background: #fff;
  color: var(--blue-900);
  border-color: var(--line);
  border-bottom: 2px solid #fff;
}
[role=tabpanel] > .note:first-child { margin-top: 1rem; }

/* "playing" on the Sequences tab while a sequence plays, so it's seen from the other tabs. */
.tab-badge {
  display: none;
  margin-left: .35rem;
  padding: 0 .45rem;
  border-radius: 999px;
  background: #1e8e4f;
  color: #fff;
  font-size: .75em;
  font-weight: 600;
}
#tab-sequences.is-playing .tab-badge { display: inline-block; }

/* Sequences. */
.callout {
  background: #fff8e1;
  border: 1px solid #f1d27a;
  border-left: 4px solid #d9a400;
  border-radius: var(--radius);
  padding: .6rem 1rem;
  margin: .5rem 0 1rem;
  max-width: 52rem;
}
.seq-bar, .button-row { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; margin: .5rem 0; }
.seq-player { margin-top: 1rem; }
#seq-now { color: #14532d; font-weight: 600; }
#seq-name { width: 12rem; }
#seq-frames input[type=text] { width: 7.2rem; }
/* Number fields in the frames table have no spinner arrows (the arrow keys still step), so
   they can be narrow: room for 1500.25. */
#seq-frames input[type=number] { width: 4.3rem; appearance: textfield; -moz-appearance: textfield; }
#seq-frames input[type=number]::-webkit-inner-spin-button,
#seq-frames input[type=number]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
#seq-frames th { vertical-align: bottom; }
#seq-frames tr.playing td { background: #e3f4ea; }
/* The frames table is a grid of fields, so it's compact: fields as tall as its small buttons. */
#seq-frames td { padding: .2rem .4rem; }
#seq-frames th { padding-left: .4rem; padding-right: .4rem; }
#seq-frames input, #seq-frames select { padding: .1rem .35rem; }
/* Fields in the bars above it as tall as their slim buttons. */
.seq-bar input[type=text], .seq-bar select { padding-top: .2rem; padding-bottom: .2rem; }
button.small { padding: .15rem .5rem; font-size: .9em; }

/* Script tab. */
#script-source {
  display: block;
  width: 100%;
  max-width: 44rem;   /* about 90 columns: room for a script line and its comment */
  min-height: 14rem;
  resize: vertical;
  font: 13px/1.45 ui-monospace, "Cascadia Mono", Consolas, monospace;
  padding: .6rem .75rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
  tab-size: 2;
}
#script-source:focus { outline: 2px solid var(--blue-500); outline-offset: 1px; }
/* Compile result, then board status, under the editor: quiet unless something is wrong. */
.script-result { margin: .25rem 0; }
#script-compile { margin-top: .5rem; }
#script-warnings { margin: .25rem 0; padding-left: 1.25rem; }
li.warn { color: #7a4d00; margin: .2rem 0; }
li.warn button, #script-goto { padding: .05rem .5rem; font-size: .85em; }
#script-state { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 13px; white-space: normal; }
pre.listing { max-height: 24rem; white-space: pre; }
#script-param { width: 6.5rem; }
details.help h4 { color: var(--blue-900); margin: .9rem 0 .25rem; }
details.help table { width: 100%; max-width: 60rem; }
details.help th { text-align: left; }
details.help td { white-space: normal; text-align: left; vertical-align: top; }
details.help td:first-child { width: 13rem; }
details.help td:nth-child(2) { width: 11rem; }
details.help td:first-child, details.help td:nth-child(2) { white-space: nowrap; }
/* The command tables' Gives column (the keyword table has no fourth column). */
details.help td:nth-child(3):not(:last-child) { width: 9rem; white-space: nowrap; }
button.insert {
  font: 12px/1.3 ui-monospace, "Cascadia Mono", Consolas, monospace;
  padding: .1rem .45rem;
  background: var(--blue-50);
  color: var(--blue-900);
  border-color: var(--line);
}
button.insert:hover:not(:disabled) { background: var(--blue-100); border-color: var(--blue-500); color: var(--blue-900); }
/* Text buttons as tall as the icon buttons (the Script tab's Open / Save row). */
button.slim { padding: .2rem .75rem; }
button.icon { display: inline-flex; align-items: center; justify-content: center; padding: .3rem .55rem; line-height: 0; }
.icon-group { display: inline-flex; gap: .35rem; }
.warn-text { color: #7a4d00; font-weight: 600; }
#script-source.drop { outline: 3px dashed var(--blue-500); outline-offset: 2px; background: var(--blue-50); }
#script-upload { margin-right: .75rem; }
