/* The installer page: plain CSS, system fonts, light and dark from the system setting. */
:root {
  color-scheme: light dark;
  --bg: #f7f7f8;
  --surface: #ffffff;
  --text: #1b1d21;
  --muted: #4a5059;
  --border: #d9dce1;
  --accent: #1d4ed8;
  --accent-hover: #1e40af;
  --on-accent: #ffffff;
  --notice-bg: #fff7e6;
  --notice-border: #e3a008;
  --code-bg: #eef0f3;
  --logo: #1d4ed8;
  --logo-eye: #ffffff;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111317;
    --surface: #1a1d22;
    --text: #e8eaed;
    --muted: #b3b9c2;
    --border: #343a42;
    --accent: #8ab4ff;
    --accent-hover: #a8c7ff;
    --on-accent: #0b1a33;
    --notice-bg: #2b2414;
    --notice-border: #c88a12;
    --code-bg: #262a31;
    --logo: #8ab4ff;
    --logo-eye: #111317;
  }

  /* ESP Web Tools' dialogs set their colours on their own element: follow the dark theme there too. */
  ewt-install-dialog,
  ewt-no-port-picked-dialog {
    --text-color: rgba(232, 234, 237, 0.78);
    --md-sys-color-surface: #1f2329;
    --md-sys-color-surface-container: #1f2329;
    --md-sys-color-surface-container-high: #1f2329;
    --md-sys-color-surface-container-highest: #2b3038;
    --md-sys-color-secondary-container: #343a42;
    --md-sys-color-on-surface: #e8eaed;
    --md-sys-color-on-surface-variant: #b3b9c2;
    --md-sys-color-outline: #6b7380;
  }
}

/* ESP Web Tools' dialogs: the page's accent, which reads better than their light blue. */
ewt-install-dialog,
ewt-no-port-picked-dialog {
  --md-sys-color-primary: var(--accent);
  --md-sys-color-on-primary: var(--on-accent);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 1rem;
  line-height: 1.55;
}

.top,
main,
footer {
  max-width: 44rem;
  margin: 0 auto;
  padding-left: 16px;
  padding-right: 16px;
}

.top {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding-top: 1.5rem;
}

.logo {
  width: 2rem;
  height: 2rem;
  flex: none;
}

.logo-body {
  fill: var(--logo);
}

.logo-eye {
  fill: var(--logo-eye);
}

.name {
  font-weight: 650;
  font-size: 1.1rem;
}

h1 {
  font-size: clamp(1.6rem, 5vw, 2.2rem);
  line-height: 1.2;
  margin: 1.5rem 0 0.75rem;
}

h2 {
  font-size: 1.2rem;
  margin: 2rem 0 0.5rem;
}

.lead {
  color: var(--muted);
  font-size: 1.1rem;
  margin-top: 0;
}

ul,
ol {
  padding-left: 1.4rem;
}

li + li {
  margin-top: 0.4rem;
}

a {
  color: var(--accent);
  text-underline-offset: 0.15em;
}

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

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.92em;
  background: var(--code-bg);
  padding: 0.1em 0.35em;
  border-radius: 0.3em;
  overflow-wrap: anywhere;
}

.install {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0.9rem;
  padding: 0.25rem 1.25rem 1.5rem;
  margin-top: 1.5rem;
}

.install h2 {
  margin-top: 1rem;
}

.button {
  font: inherit;
  font-weight: 600;
  font-size: 1.05rem;
  color: var(--on-accent);
  background: var(--accent);
  border: none;
  border-radius: 999px;
  padding: 0.75rem 1.6rem;
  min-height: 48px;
  cursor: pointer;
}

.button:hover {
  background: var(--accent-hover);
}

.button:focus-visible,
a:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}

.notice {
  background: var(--notice-bg);
  border: 1px solid var(--notice-border);
  border-left-width: 5px;
  border-radius: 0.6rem;
  padding: 0.25rem 1rem;
}

/*
 * Install is offered only where it works. ESP Web Tools checks for Web Serial on a secure page and
 * then shows one of its parts: the button, or its message for this browser (install-unsupported).
 * Until it has loaded, "Checking…" shows instead (an element without a slot, which it hides from then
 * on), and the steps keep their place without showing, so nothing moves when the button appears.
 */
esp-web-install-button {
  display: block;
}

esp-web-install-button:not(:defined) > [slot] {
  display: none;
}

.install:has(esp-web-install-button:not(:defined)) .steps {
  visibility: hidden;
}

.install:has(esp-web-install-button[install-unsupported]) .steps {
  display: none;
}

.checking {
  color: var(--muted);
  margin: 0;
  min-height: 50px;
  display: flex;
  align-items: center;
}

/*
 * One card per board, each with its own Install button (its own manifest): USB can't tell the boards
 * apart, so the person picks theirs. The browser check above says once if this browser can't install;
 * the boards' buttons then show nothing.
 */
.boards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.board {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  padding: 1rem;
}

.board h3 {
  font-size: 1.05rem;
  margin: 0.6rem 0 0.25rem;
  overflow-wrap: anywhere;
}

.board p {
  color: var(--muted);
  margin: 0 0 1rem;
}

/* The Install buttons sit at the bottom of their cards, level with each other. */
.board esp-web-install-button {
  margin-top: auto;
}

/* Each board's "buy it" link, with the affiliate disclosure: small, under the description. */
.board .buy {
  font-size: 0.875rem;
  line-height: 1.45;
}

.buy small {
  display: block;
  font-size: 0.8125rem;
  margin-top: 0.15rem;
}

/* Each board's photo: the same height on both cards (the width follows from its own proportions), so
   the names, descriptions and buttons below line up. */
.board-photo {
  display: block;
  height: 11rem;
  width: auto;
  max-width: 100%;
  object-fit: contain;
  border-radius: 0.6rem;
}

.trouble dt {
  font-weight: 600;
  margin-top: 0.9rem;
}

.trouble dd {
  margin: 0.2rem 0 0;
  color: var(--muted);
}

footer {
  color: var(--muted);
  font-size: 0.92rem;
  border-top: 1px solid var(--border);
  margin-top: 2.5rem;
  padding-top: 0.75rem;
  padding-bottom: 2rem;
}
