/* Critterscan — single hand-written stylesheet (ADR-0003).
   No external fonts, no CDN, no JS (except the opt-in /flash enhancement).
   Aesthetic: clean and friendly — warm paper neutrals, a teal signal accent with
   a soft blush highlight, rounded surfaces, and monospace kept for real technical
   data (hashes, versions, code). */

/* ---- design tokens ---- */
:root {
  color-scheme: light dark;

  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial,
    "Noto Sans", sans-serif;
  --font-mono: ui-monospace, "SF Mono", "Cascadia Code", "JetBrains Mono", Menlo,
    Consolas, "Liberation Mono", monospace;

  --bg: #f7f5f2;
  --surface: #ffffff;
  --surface-2: #efece7;
  --text: #1b1a17;
  --muted: #615b53;
  --border: #e7e1d8;
  --accent: #c85a17;
  --accent-strong: #a2470d;
  --accent-ink: #ffffff;
  --code-bg: #f0ede8;
  --shadow: 0 1px 2px rgba(40, 30, 20, 0.06), 0 6px 20px rgba(40, 30, 20, 0.05);

  --radius: 14px;
  --radius-sm: 9px;
  --maxw: 66rem;
  --measure: 42rem;
  --step: clamp(1rem, 0.9rem + 0.4vw, 1.125rem);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16151b;
    --surface: #1e1c24;
    --surface-2: #26232d;
    --text: #ece8e2;
    --muted: #a8a29a;
    --border: #322e39;
    --accent: #f0975a;
    --accent-strong: #f6b184;
    --accent-ink: #2a1206;
    --code-bg: #141219;
    --shadow: none;
  }
}

/* ---- reset ---- */
*,
*::before,
*::after {
  box-sizing: border-box;
}
html {
  -webkit-text-size-adjust: 100%;
}
body {
  margin: 0;
  border-top: 3px solid var(--accent);
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: var(--step);
  line-height: 1.65;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}
img {
  max-width: 100%;
  height: auto;
}
h1,
h2,
h3 {
  line-height: 1.15;
  letter-spacing: -0.012em;
  font-weight: 650;
}

/* ---- layout ---- */
.container {
  width: 100%;
  max-width: var(--maxw);
  margin-inline: auto;
  padding-inline: clamp(1rem, 4vw, 2rem);
}
main {
  flex: 1 0 auto;
  padding-block: clamp(2rem, 5vw, 3.5rem);
}

/* ---- header ---- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(8px);
  border-bottom: 1px solid var(--border);
}
.header-inner {
  display: flex;
  align-items: center;
  gap: 0.75rem 1rem;
  flex-wrap: wrap;
  min-height: 3.75rem;
  padding-block: 0.5rem;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 680;
  letter-spacing: -0.01em;
  text-decoration: none;
  color: var(--text);
}
.header-tagline {
  display: none;
  color: var(--accent-strong);
  background: color-mix(in srgb, var(--accent) 9%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 22%, transparent);
  padding: 0.28rem 0.7rem;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
}
.header-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}
.nav {
  display: flex;
  gap: 0.35rem;
  margin-left: auto;
  flex-wrap: wrap;
}
.nav-link {
  padding: 0.4rem 0.65rem;
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--muted);
  font-weight: 500;
}
.nav-link:hover {
  color: var(--text);
  background: var(--surface-2);
}
.nav-link.active {
  color: var(--text);
  box-shadow: inset 0 -2px 0 var(--accent);
  border-radius: 0;
}

/* ---- buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.5rem 0.95rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 550;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease,
    color 0.15s ease;
}
.btn:hover {
  border-color: color-mix(in srgb, var(--accent) 55%, var(--border));
}
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}
.btn-primary:hover {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
}
.btn-outline {
  background: transparent;
  white-space: nowrap;
}
.btn-support {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
  color: var(--accent-strong);
  background: color-mix(in srgb, var(--accent) 8%, var(--surface));
}
.btn-support:hover {
  background: color-mix(in srgb, var(--accent) 15%, var(--surface));
}

/* ---- hero ---- */
.hero {
  margin-bottom: clamp(2.5rem, 6vw, 4rem);
}
.hero-grid {
  display: grid;
  gap: clamp(1.75rem, 4vw, 3rem);
  grid-template-columns: 1fr;
  align-items: center;
}
@media (min-width: 60rem) {
  .hero-grid {
    grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
  }
}
.hero-copy {
  max-width: 40rem;
}
.hero-title {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 0.4em;
  flex-wrap: wrap;
  font-size: clamp(2.6rem, 1.8rem + 3.6vw, 4.5rem);
  letter-spacing: -0.03em;
  font-weight: 720;
  line-height: 1.05;
}
.title-mascot {
  height: 0.92em;
  width: auto;
  filter: drop-shadow(0 3px 8px color-mix(in srgb, var(--accent) 30%, transparent));
}
.hero-lead {
  margin: 0.75rem 0 1rem;
  font-size: clamp(1.2rem, 1.05rem + 0.7vw, 1.5rem);
  color: var(--text);
}
.hero-body {
  margin: 0 0 1.75rem;
  color: var(--muted);
  max-width: 38rem;
}
.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
}

/* ---- hero board panel (ADR-0008) ---- */
.hero-board {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  overflow: hidden;
  min-height: 20rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.board-empty {
  margin: auto;
  padding: 2rem 1.5rem;
  text-align: center;
  color: var(--muted);
  max-width: 26rem;
}
.board-icon {
  color: color-mix(in srgb, var(--accent) 70%, var(--muted));
  margin-bottom: 0.75rem;
}
.board-empty-title {
  margin: 0 0 0.25rem;
  color: var(--text);
  font-weight: 600;
}
.board-gallery {
  width: 100%;
  padding: 0.5rem;
}
/* Radios drive the gallery; visually hidden but still keyboard-focusable. */
.board-radio {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}
.board-shot {
  margin: 0;
}
.board-shot picture {
  display: block;
}
.board-shot img {
  display: block;
  width: 100%;
  height: auto;
}
/* Gallery stage: a fixed 3:2 box holding both views stacked. Its height never
   changes with the selected view or while the lazy back image loads, so switching
   Front/Back can't reflow the panel or the page. */
.board-stage {
  position: relative;
  aspect-ratio: 3 / 2;
}
.board-stage .board-shot {
  position: absolute;
  inset: 0;
  display: none;
}
#board-front:checked ~ .board-stage .shot-front,
#board-back:checked ~ .board-stage .shot-back {
  display: block;
}
.board-stage .board-shot picture,
.board-stage .board-shot img {
  width: 100%;
  height: 100%;
}
.board-stage .board-shot img {
  object-fit: contain;
}
/* Segmented Front/Back control */
.board-tabs {
  display: flex;
  gap: 0.25rem;
  width: fit-content;
  margin: 0.6rem auto 0;
  padding: 0.2rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-2);
}
.board-tab {
  cursor: pointer;
  padding: 0.28rem 0.9rem;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 550;
  color: var(--muted);
  user-select: none;
  transition: color 0.15s ease, background-color 0.15s ease;
}
.board-tab:hover {
  color: var(--text);
}
#board-front:checked ~ .board-tabs [for="board-front"],
#board-back:checked ~ .board-tabs [for="board-back"] {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
}
#board-front:focus-visible ~ .board-tabs [for="board-front"],
#board-back:focus-visible ~ .board-tabs [for="board-back"] {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.board-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.5rem 1rem;
  margin: 0.75rem 0 0.85rem;
}

/* terminal snippet — always reads as a real terminal, in both themes */
.terminal {
  margin: 0;
  background: #0d1117;
  color: #d7dde5;
  border: 1px solid #1e2733;
  border-radius: var(--radius);
  overflow-x: auto;
}
.terminal pre {
  margin: 0;
  padding: 0.9rem 1.1rem;
  font-family: var(--font-mono);
  font-size: 0.9rem;
  line-height: 1.5;
}
.term-prompt {
  color: #f0975a;
  user-select: none;
}

/* ---- home ---- */
.home-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr));
  margin-bottom: clamp(2.5rem, 6vw, 3.5rem);
}
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.4rem;
  box-shadow: var(--shadow);
}
.panel h2 {
  margin: 0 0 0.5rem;
  font-size: 1.15rem;
}
.panel p {
  margin: 0 0 1rem;
  color: var(--muted);
}
.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.5rem;
}
.section-head h2 {
  margin: 0;
  font-size: 1.25rem;
}

/* ---- page heads ---- */
.page-head {
  margin-bottom: 2rem;
}
.page-head h1 {
  margin: 0 0 0.4rem;
  font-size: clamp(1.9rem, 1.5rem + 1.6vw, 2.6rem);
}
.page-intro {
  margin: 0;
  color: var(--muted);
  max-width: var(--measure);
}

/* ---- entry lists (docs & news) ---- */
.entry-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.entry {
  padding: 1.15rem 0;
  border-top: 1px solid var(--border);
}
.entry:first-child {
  border-top: none;
}
.entry-link {
  text-decoration: none;
  color: var(--text);
}
.entry-title {
  margin: 0;
  font-size: 1.2rem;
  transition: color 0.15s ease;
}
.entry-link:hover .entry-title {
  color: var(--accent-strong);
}
.entry-summary {
  margin: 0.35rem 0 0;
  color: var(--muted);
  max-width: var(--measure);
}

/* ---- dates & tags ---- */
.date {
  display: inline-block;
  color: var(--muted);
  font-size: 0.875rem;
  margin-top: 0.35rem;
}
.tags {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0.6rem 0 0;
  padding: 0;
}
.tag {
  font-size: 0.78rem;
  color: var(--muted);
  padding: 0.15rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 999px;
}

/* ---- prose (rendered markdown) ---- */
.prose {
  max-width: var(--measure);
}
.article-head {
  margin-bottom: 1.5rem;
}
.article-head h1 {
  margin: 0 0 0.3rem;
  font-size: clamp(1.9rem, 1.5rem + 1.6vw, 2.6rem);
}
.prose h1,
.prose h2,
.prose h3 {
  margin: 2rem 0 0.75rem;
}
.prose h2 {
  font-size: 1.5rem;
  padding-bottom: 0.3rem;
  border-bottom: 1px solid var(--border);
}
.prose h3 {
  font-size: 1.2rem;
}
.prose p,
.prose ul,
.prose ol {
  margin: 0 0 1.1rem;
}
.prose ul,
.prose ol {
  padding-left: 1.4rem;
}
.prose li {
  margin: 0.3rem 0;
}
.prose a {
  color: var(--accent-strong);
  text-underline-offset: 2px;
}
.prose img {
  border-radius: var(--radius);
  border: 1px solid var(--border);
}
.prose blockquote {
  margin: 1.25rem 0;
  padding: 0.4rem 1rem;
  border-left: 3px solid var(--accent);
  background: color-mix(in srgb, var(--accent) 6%, transparent);
  color: var(--text);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
.prose blockquote p:last-child {
  margin-bottom: 0;
}
.prose hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2rem 0;
}
code,
kbd,
samp {
  font-family: var(--font-mono);
  font-size: 0.9em;
}
.prose :not(pre) > code {
  background: var(--code-bg);
  padding: 0.12em 0.38em;
  border-radius: 4px;
}
.prose pre {
  background: #0d1117;
  color: #d7dde5;
  padding: 1rem 1.1rem;
  border-radius: var(--radius);
  overflow-x: auto;
  border: 1px solid #1e2733;
}
.prose pre code {
  background: none;
  padding: 0;
  color: inherit;
}
.prose table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.25rem 0;
  font-size: 0.95rem;
}
.prose th,
.prose td {
  text-align: left;
  padding: 0.55rem 0.7rem;
  border-bottom: 1px solid var(--border);
}
.prose thead th {
  border-bottom: 2px solid var(--border);
}

/* ---- firmware table ---- */
.release {
  margin-bottom: 2.5rem;
}
.release-version {
  font-family: var(--font-mono);
  font-size: 1.15rem;
  letter-spacing: -0.01em;
  margin: 0 0 0.75rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--border);
}
.table-scroll {
  overflow-x: auto;
}
.fw-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}
.fw-table th,
.fw-table td {
  text-align: left;
  padding: 0.65rem 0.8rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.fw-table thead th {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.82rem;
  border-bottom: 2px solid var(--border);
}
.fw-table .download {
  font-weight: 550;
  color: var(--accent-strong);
  text-decoration: none;
}
.fw-table .download:hover {
  text-decoration: underline;
}
.nowrap {
  white-space: nowrap;
}
.hash {
  font-family: var(--font-mono);
  color: var(--text);
}

/* ---- misc ---- */
.textlink {
  color: var(--accent-strong);
  font-weight: 550;
  text-decoration: none;
  text-underline-offset: 2px;
}
.textlink:hover {
  text-decoration: underline;
}
.textlink.tiny {
  font-size: 0.82rem;
  font-weight: 500;
}
.muted {
  color: var(--muted);
}
.back {
  margin-top: 2.5rem;
}
.narrow {
  max-width: 34rem;
}
.narrow h1 {
  font-size: clamp(1.8rem, 1.5rem + 1.4vw, 2.4rem);
}
.empty {
  padding: 2.5rem 1.5rem;
  text-align: center;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}
.empty-title {
  margin: 0 0 0.35rem;
  font-weight: 600;
}

/* ---- footer ---- */
.site-footer {
  flex-shrink: 0;
  margin-top: 3rem;
  border-top: 1px solid var(--border);
  background: var(--surface);
}
.footer-inner {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 1.5rem;
  padding-block: 2rem;
}
.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
}
.footer-links a {
  color: var(--muted);
  text-decoration: none;
}
.footer-links a:hover {
  color: var(--text);
}
.footer-meta {
  text-align: right;
  max-width: 30rem;
}
.footer-meta .btn-support {
  margin-bottom: 0.75rem;
}
.footer-meta p {
  margin: 0.25rem 0;
  font-size: 0.85rem;
}

/* ---- accessibility ---- */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 3px;
}
.skip-link {
  position: absolute;
  left: -999px;
  top: 0.5rem;
  background: var(--surface);
  color: var(--text);
  padding: 0.5rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  z-index: 100;
}
.skip-link:focus {
  left: 0.5rem;
}

@media (max-width: 40rem) {
  .footer-inner {
    flex-direction: column;
  }
  .footer-meta {
    text-align: left;
  }
}

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

/* ---- brand art (self-hosted neofox) ---- */
img.brand-mark {
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 0;
  background: none;
  box-shadow: none;
}

/* ---- cards & webflasher ---- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
}
.flasher {
  margin: 0 0 2rem;
  max-width: var(--measure);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.75rem;
}
.flasher-fox {
  width: 64px;
  height: 64px;
}
.small {
  font-size: 0.85rem;
}
/* Until esp-web-tools upgrades the element, hide it so its slots don't render as
   loose text; the command-line method below is always available. */
esp-web-install-button:not(:defined) {
  display: none;
}
esp-web-install-button {
  display: block;
}

/* Descriptor pill only where the one-row header has room for it. */
@media (min-width: 66rem) {
  .header-tagline {
    display: inline-block;
  }
}

/* Mobile header: a clean centered stack that scrolls away (not sticky), instead
   of the one-row layout wrapping into a lopsided three-row pile. */
@media (max-width: 52rem) {
  .site-header {
    position: static;
  }
  .header-inner {
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    padding-block: 0.75rem;
  }
  .nav {
    margin-left: 0;
    justify-content: center;
  }
  .header-actions {
    justify-content: center;
  }
}

/* ---- print (docs are meant to be printed) ---- */
@media print {
  body {
    border-top: none;
    background: #fff;
    color: #000;
  }
  .site-header,
  .site-footer,
  .hero-actions,
  .back,
  .skip-link {
    display: none;
  }
  .prose {
    max-width: none;
  }
  a {
    color: #000;
    text-decoration: underline;
  }
}
