/* DataLab web flasher. No external fonts, no framework. */

:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --text: #17202a;
  --muted: #5b6875;
  --line: #d9dfe5;
  --accent: #0b6e69;
  --accent-text: #ffffff;
  --accent-soft: #e2f1ef;
  --warn-bg: #fff4d6;
  --warn-line: #e3b341;
  --code-bg: #eef1f4;
  --radius: 12px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", "Segoe UI Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #10161b;
    --surface: #182027;
    --text: #e6ebef;
    --muted: #9aa7b3;
    --line: #2c3842;
    --accent: #4fc4b8;
    --accent-text: #06211f;
    --accent-soft: #17363a;
    --warn-bg: #3a2f10;
    --warn-line: #8a6d1c;
    --code-bg: #212b33;
  }
}

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

[hidden] {
  display: none !important;
}

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 1rem/1.55 var(--font);
}

.wrap {
  width: 100%;
  max-width: 46rem;
  margin: 0 auto;
  padding: 0 1.25rem;
}

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

a:hover {
  text-decoration-thickness: 2px;
}

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

code,
pre {
  font-family: var(--mono);
  font-size: 0.9em;
}

code {
  padding: 0.1em 0.35em;
  border-radius: 5px;
  background: var(--code-bg);
  overflow-wrap: anywhere;
}

pre {
  margin: 0.75rem 0;
  padding: 0.85rem 1rem;
  border-radius: 8px;
  background: var(--code-bg);
  overflow-x: auto;
}

pre code {
  padding: 0;
  background: none;
  overflow-wrap: normal;
}

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

/* Masthead ---------------------------------------------------------------- */

.masthead {
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.masthead .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 3.5rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--accent);
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  text-decoration: none;
}

.brand span {
  color: var(--text);
}

.masthead nav {
  display: flex;
  align-items: center;
  gap: 1.1rem;
  font-size: 0.95rem;
}

/* Language switch */
.lang {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  overflow: hidden;
}

.lang button {
  border: 0;
  padding: 0.25rem 0.6rem;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.lang button + button {
  border-left: 1px solid var(--line);
}

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

/* Intro ------------------------------------------------------------------- */

.intro {
  padding: 2.5rem 0 0.5rem;
}

h1 {
  margin: 0 0 0.75rem;
  font-size: clamp(1.7rem, 5vw, 2.3rem);
  line-height: 1.15;
  letter-spacing: -0.02em;
}

.intro p {
  max-width: 38rem;
  margin: 0 0 0.75rem;
  font-size: 1.08rem;
}

.intro .version {
  color: var(--muted);
  font-size: 0.95rem;
}

/* Steps ------------------------------------------------------------------- */

.step {
  margin: 1.25rem 0;
  padding: 1.4rem 1.5rem 1.5rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

h2 {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  margin: 0 0 1rem;
  font-size: 1.25rem;
  line-height: 1.25;
  letter-spacing: -0.01em;
}

.num {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 1.9rem;
  height: 1.9rem;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-text);
  font-size: 1rem;
  font-weight: 700;
}

.todo {
  margin: 0;
  padding-left: 1.3rem;
}

.todo li {
  margin: 0.35rem 0;
  padding-left: 0.2rem;
}

/* Device picker ----------------------------------------------------------- */

.devices fieldset {
  min-width: 0;
  margin: 0 0 1.1rem;
  padding: 0;
  border: 0;
}

.devices fieldset:last-child {
  margin-bottom: 0;
}

.devices legend {
  margin-bottom: 0.5rem;
  padding: 0;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.chip {
  position: relative;
  display: inline-flex;
}

.chip input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.chip span {
  padding: 0.5rem 0.95rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--bg);
  font-size: 0.97rem;
  line-height: 1.3;
  transition: background-color 0.12s, border-color 0.12s, color 0.12s;
}

.chip input:hover + span {
  border-color: var(--accent);
}

.chip input:checked + span {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-text);
  font-weight: 600;
}

.chip input:focus-visible + span {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

/* Install block ----------------------------------------------------------- */

.install {
  margin: 1.2rem 0;
  padding: 1.1rem 1.2rem;
  border-radius: 10px;
  background: var(--accent-soft);
}

.install p {
  margin: 0 0 0.8rem;
}

.install > p,
.install > div > :last-child {
  margin-bottom: 0;
}

.selected strong {
  display: block;
  font-size: 1.1rem;
}

.selected span {
  color: var(--muted);
  font-size: 0.95rem;
}

esp-web-install-button {
  display: block;
}

/* Until the component is loaded its children would all show at once. */
esp-web-install-button:not(:defined) {
  display: none;
}

.button {
  appearance: none;
  padding: 0.75rem 1.6rem;
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-text);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.button:hover {
  filter: brightness(1.08);
}

.button:active {
  filter: brightness(0.94);
}

/* The dialog ESP Web Tools opens: keep its light theme, use our accent. */
ewt-install-dialog {
  --md-sys-color-primary: #0b6e69;
}

/* Notices ----------------------------------------------------------------- */

.notice {
  margin: 1rem 0 0;
  padding: 0.8rem 1rem;
  border-left: 4px solid var(--line);
  border-radius: 6px;
  background: var(--bg);
  font-size: 0.97rem;
}

.notice.warn {
  border-left-color: var(--warn-line);
  background: var(--warn-bg);
}

main > .notice {
  margin: 1.25rem 0;
}

#browser-warning {
  margin: 0 0 1rem;
}

/* Other ways -------------------------------------------------------------- */

.more {
  margin: 2.25rem 0 1rem;
}

.more h2 {
  margin-bottom: 0.75rem;
}

details {
  border-top: 1px solid var(--line);
}

details:last-of-type {
  border-bottom: 1px solid var(--line);
}

summary {
  padding: 0.85rem 0.25rem;
  font-weight: 600;
  cursor: pointer;
}

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

details .body {
  padding: 0 0.25rem 1rem;
}

details .body > :first-child {
  margin-top: 0;
}

details .body > :last-child {
  margin-bottom: 0;
}

details ul {
  padding-left: 1.2rem;
}

details li {
  margin: 0.5rem 0;
}

.files {
  padding: 0;
  list-style: none;
}

.files li {
  margin: 0.6rem 0;
}

.files a {
  font-family: var(--mono);
  font-size: 0.9em;
  overflow-wrap: anywhere;
}

.files small {
  display: block;
  color: var(--muted);
  font-size: 0.9rem;
}

/* Footer ------------------------------------------------------------------ */

footer {
  padding-top: 1.5rem;
  padding-bottom: 2.5rem;
  color: var(--muted);
  font-size: 0.9rem;
}

footer p {
  margin: 0.3rem 0;
}

footer span {
  margin: 0 0.35rem;
}

@media (max-width: 30rem) {
  .step {
    padding: 1.1rem 1rem 1.2rem;
  }

  .intro {
    padding-top: 1.75rem;
  }

  .masthead nav {
    gap: 0.8rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }
}
