/*
 * SPDX-FileCopyrightText: Stichting Badge.Team
 * SPDX-License-Identifier: MIT
 *
 * Styles for the in-browser WebUSB flasher (/flash/). Scoped under
 * .flasher so nothing here leaks into the rest of the site. Colours come
 * from Bootstrap/Docsy custom properties where possible so the widget
 * follows the active theme instead of hard-coding light-mode values.
 */

.flasher {
  margin: 2rem 0;
}

.flasher-step {
  border: 1px solid var(--bs-border-color, #dee2e6);
  border-radius: 0.5rem;
  padding: 1rem 1.25rem;
  margin-bottom: 1rem;
  background: var(--bs-body-bg, transparent);
}

.flasher-step h3 {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-top: 0;
  font-size: 1.15rem;
}

/* Step number bubble. */
.flasher-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 1.7rem;
  height: 1.7rem;
  border-radius: 50%;
  background: var(--bs-primary, #30638e);
  color: #fff;
  font-size: 0.95rem;
  font-weight: 700;
}

.flasher-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  margin: 0.75rem 0;
}

.flasher-row .form-select {
  width: auto;
  min-width: min(100%, 22rem);
}

.flasher-single-badge {
  font-weight: 600;
}

.flasher-docs-link {
  margin-left: auto;
  font-size: 0.9rem;
}

.flasher-sub {
  margin: 1.25rem 0 0.25rem;
  font-size: 1rem;
  font-weight: 600;
}

.flasher-check {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin: 0;
  font-size: 0.9rem;
}

.flasher-hint {
  margin: 0.25rem 0 0;
  font-size: 0.9rem;
  opacity: 0.85;
}

.flasher-hint:empty {
  display: none;
}

.flasher-status {
  font-family: var(--bs-font-monospace, monospace);
  font-size: 0.9rem;
  opacity: 0.75;
}

.flasher-status.connected {
  color: #1a7f37;
  opacity: 1;
  font-weight: 600;
}

/* Device details table. */
.flasher-kv {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.15rem 1rem;
  margin: 0.75rem 0 0;
  font-size: 0.9rem;
}

.flasher-kv dt {
  font-weight: 600;
  opacity: 0.75;
}

.flasher-kv dd {
  margin: 0;
  font-family: var(--bs-font-monospace, monospace);
  overflow-wrap: anywhere;
}

.flasher progress {
  flex: 1 1 12rem;
  height: 1.1rem;
}

.flasher-donot {
  margin-top: 0.75rem;
  margin-bottom: 0;
  font-size: 0.9rem;
}

/* Serial console. Focusable, so give it a visible focus ring — you have to
   click into it before typing reaches the badge.
 *
 * Selector deliberately over-qualified: Docsy styles `.td-content pre` with a
 * light background, which outranks a bare `.repl-term` and left the console
 * grey-on-grey (it sets background-color but not color, so only half of it
 * lost). `.flasher pre.repl-term` outranks it. Same reason for the
 * diagnostics pane below. */
/* The shell wraps the toolbar and terminal and owns the drag-to-resize handle;
   the terminal flexes to fill whatever is left. Resizing the shell keeps the
   corner grip clear of the terminal's own scrollbar, and lets fullscreen
   restyle a single element that already contains the controls. */
.flasher .repl-shell {
  display: flex;
  flex-direction: column;
  margin: 0.75rem 0 0;
  height: 24rem;
  min-height: 10rem;
  /* Vertical only: horizontal scrolling a wrapped terminal gains nothing. */
  resize: vertical;
  overflow: hidden;
}

.flasher .repl-shell .repl-toolbar {
  margin: 0 0 0.5rem;
  flex: 0 0 auto;
}

.flasher pre.repl-term {
  flex: 1 1 auto;
  min-height: 0; /* let the terminal shrink inside the flex column */
  margin: 0;
  overflow: auto;
  padding: 0.75rem;
  border: 0;
  border-radius: 0.375rem;
  background: #1e1e1e;
  color: #d4d4d4;
  font-size: 0.85rem;
  line-height: 1.45;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.flasher pre.repl-term:focus-visible {
  outline: 2px solid var(--bs-primary, #30638e);
  outline-offset: -2px;
}

/* Fullscreen: the shell fills the viewport and stops being resizable (the drag
   handle would fight the screen edge). :fullscreen matches whichever element
   the Fullscreen API promoted — always .repl-shell here. A background is set
   because the promoted element is composited over black, and the toolbar row
   would otherwise sit on it. */
.flasher .repl-shell:fullscreen {
  height: 100%;
  width: 100%;
  resize: none;
  padding: 0.75rem;
  background: var(--bs-body-bg, #fff);
}

.flasher .repl-shell:fullscreen pre.repl-term {
  border-radius: 0.375rem;
  font-size: 0.95rem;
}

.flasher-diag summary {
  cursor: pointer;
  font-weight: 600;
}

.flasher .flasher-diag pre {
  max-height: 18rem;
  overflow: auto;
  padding: 0.75rem;
  border: 0;
  border-radius: 0.375rem;
  background: #1e1e1e;
  color: #d4d4d4;
  font-size: 0.82rem;
  line-height: 1.45;
}

/* Log severity colours — chosen to stay legible on the dark log pane. */
.flasher-diag .ok {
  color: #6ac36a;
}
.flasher-diag .warn {
  color: #e0b341;
}
.flasher-diag .err {
  color: #f07178;
}

/* Utility fallback: Docsy ships Bootstrap, but do not depend on it. */
.flasher .d-none {
  display: none !important;
}
