/* Color tokens match www-src-rv-server/src/style.css exactly (dark is the default/root, light is
   the override) so the marketing site and my.rvaltctrl.com read as the same product. */
:root {
  --bg: #0f1115;
  --surface: #1a1d24;
  --surface-2: #22262f;
  --line: #2e3340;
  --text: #e8eaf0;
  --muted: #7a8099;
  --accent: #4f8ef7;
}

:root[data-theme="light"] {
  --bg: #f5f6fa;
  --surface: #ffffff;
  --surface-2: #eef0f5;
  --line: #dde1ea;
  --text: #1a1d24;
  --muted: #666d80;
  --accent: #3b6fe0;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  transition: background 0.15s, color 0.15s;
}

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

h1, h2, h3 {
  line-height: 1.3;
}

/* ── Header ───────────────────────────────────────────────────────────────── */

.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 0 24px;
  height: 60px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  text-decoration: none;
  color: var(--text);
  margin-right: auto;
}

.brand-logo {
  height: 38px;
  width: auto;
  display: block;
}

.brand-name {
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.site-nav {
  display: flex;
  gap: 1.25rem;
}

.site-nav a {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.95rem;
  font-weight: 500;
}

.site-nav a:hover {
  color: var(--text);
}

/* Same markup/classes as www-src-rv-server's ThemeToggle.jsx button. */
.theme-toggle-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.theme-toggle-btn:hover {
  border-color: var(--accent);
}

.theme-toggle-icon {
  font-size: 13px;
  line-height: 1;
}

.nav-toggle-btn {
  display: none;
  align-items: center;
  justify-content: center;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--text);
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 8px;
  font-size: 1.1rem;
  cursor: pointer;
}

/* Dropdown panel for narrow screens, hidden entirely on wide screens regardless of .is-open,
   since the header shows the real nav + theme toggle inline there instead. */
.nav-flyout {
  display: none;
  position: sticky;
  top: 60px;
  z-index: 99;
  flex-direction: column;
  gap: 0.5rem;
  padding: 1rem 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.nav-flyout a {
  color: var(--text);
  text-decoration: none;
  font-size: 0.95rem;
  font-weight: 500;
  padding: 0.4rem 0;
}

.nav-flyout .theme-toggle-btn {
  align-self: flex-start;
}

@media (max-width: 767px) {
  .site-nav,
  .theme-toggle-desktop {
    display: none;
  }

  .nav-toggle-btn {
    display: flex;
  }

  .nav-flyout.is-open {
    display: flex;
  }
}

/* ── Page shell ───────────────────────────────────────────────────────────── */

.site-main {
  flex: 1;
  width: 100%;
}

/* Reading-width wrapper for simple prose pages (home, privacy, terms, docs index). Docs pages
   use .docs-layout instead, which needs more width for its two-column ToC split. */
.page-prose {
  max-width: 720px;
  margin: 0 auto;
  padding: 2.5rem 1.5rem;
}

/* ── Footer ───────────────────────────────────────────────────────────────── */

.site-footer {
  background: var(--surface-2);
  border-top: 1px solid var(--line);
}

.footer-inner {
  max-width: 960px;
  margin: 0 auto;
  padding: 2.5rem 1.5rem 1.5rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
}

.footer-brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  text-decoration: none;
  color: var(--text);
  font-weight: 700;
  font-size: 1.05rem;
}

.footer-logo {
  height: 26px;
  width: auto;
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
}

.footer-links a {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.9rem;
}

.footer-links a:hover {
  color: var(--text);
}

.footer-bottom {
  max-width: 960px;
  margin: 0 auto;
  padding: 1.25rem 1.5rem;
  border-top: 1px solid var(--line);
  text-align: center;
}

.footer-bottom p {
  margin: 0;
  color: var(--muted);
  font-size: 0.8rem;
}

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

/* ── Docs index ───────────────────────────────────────────────────────────── */

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

.docs-list li {
  padding: 0.85rem 1rem;
  margin-bottom: 0.5rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.docs-list a {
  text-decoration: none;
  font-weight: 600;
}

/* ── Docs page + table of contents ───────────────────────────────────────── */

.docs-page {
  max-width: 960px;
  margin: 0 auto;
  padding: 2.5rem 1.5rem;
}

.docs-layout {
  display: flex;
  align-items: flex-start;
  gap: 2.5rem;
  margin-top: 1.5rem;
}

.docs-content {
  flex: 1;
  min-width: 0;
}

/* Every h2/h3 in doc/feature body content is a potential #anchor target (ToC links, cross-page
   links like /features/automations/#triggers). Without this, jumping to one lands it right at
   the top edge of the viewport, under the sticky header. */
.docs-content h2,
.docs-content h3 {
  scroll-margin-top: 76px;
  /* A heading should never wrap next to a floated accent image (.accent-img-right) left over
     from a shorter preceding paragraph, it always starts on its own clear line. */
  clear: both;
}

.docs-back a {
  text-decoration: none;
  color: var(--muted);
  font-size: 0.9rem;
}

.theme-shot {
  max-width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  margin: 1.5rem 0;
}

/* Stand-in for a physical LED in inline text (e.g. "the LED blinks 5 times") - a fixed red,
   not a theme token, since the real LEDs are red regardless of light/dark mode. */
.led-dot {
  display: inline-block;
  width: 0.6em;
  height: 0.6em;
  border-radius: 50%;
  background: #e0342f;
  box-shadow: 0 0 4px rgba(224, 52, 47, 0.6);
  margin: 0 0.15em;
  vertical-align: middle;
}

/* A "digit is zero" blip (led_task.c's LED_ZERO_BLIP_*): a quick, small flash rather than a
   full slow blink, so it reads as visually distinct from a real counted blink. */
.led-dot--blip {
  width: 0.3em;
  height: 0.3em;
  opacity: 0.55;
  box-shadow: none;
}

/* The quick "get ready" marker blinks (led_task.c's LED_QUICK_ON_MS/OFF_MS) between digit
   groups: smaller and dimmer than a counted blink so it doesn't look like part of the number. */
.led-dot--quick {
  width: 0.4em;
  height: 0.4em;
  opacity: 0.8;
}

.led-dot-row {
  display: inline-flex;
  align-items: center;
  gap: 0.1em;
}

/* The digit itself is what a reader actually has to count, so its dots get noticeably more
   breathing room than the tightly-packed quick marker blinks. */
.led-dot-row--wide {
  gap: 0.4em;
}

/* One step of the blink-by-blink walkthrough (Status LEDs doc page): a label plus its dots,
   spaced out onto its own line so the "get ready" marker and the digit it introduces read as
   clearly separate beats rather than running together. */
.led-sequence-step {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin: 0.6rem 0;
}

.led-sequence-step--digit {
  margin: 0.9rem 0 1.4rem;
}

.led-step-label {
  color: var(--muted);
  font-size: 0.9rem;
  min-width: 12rem;
}

/* The "put it all together" line at the end of each worked example: every step's dots back to
   back on one line, set apart in its own box so it reads as the payoff, not just another step. */
.led-sequence-full {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
  padding: 0.85rem 1rem;
  margin: 1rem 0 1.75rem;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 8px;
}

/* Small accent photo floated beside a paragraph (e.g. Pet Temperature Alert), text wraps down
   the left side and continues underneath once it clears the image. Unfloats on narrow screens,
   a skinny wrap column reads worse than just stacking the image above the text. */
.accent-img-right {
  float: right;
  width: 260px;
  max-width: 45%;
  height: auto;
  margin: 0.25rem 0 1rem 1.5rem;
  border: 1px solid var(--line);
  border-radius: 8px;
}

/* Forces whatever comes next below a floated accent-img-right instead of wrapping beside it,
   for when a new topic starts and shouldn't visually run alongside the previous one's photo. */
.clear-both {
  clear: both;
}

@media (max-width: 600px) {
  .accent-img-right {
    float: none;
    width: 100%;
    max-width: 100%;
    margin: 0.5rem 0 1rem;
  }
}

/* Modifier for a smaller accent photo, e.g. a compact product shot next to a longer paragraph.
   Scoped to min-width so the mobile full-width stacking above still wins on narrow screens. */
@media (min-width: 601px) {
  .accent-img-sm {
    width: 200px;
    max-width: 40%;
  }
}

/* Wraps a single affiliate product callout (heading + photo + blurb) in its own card, so it reads
   as a distinct item under its section rather than blending into the surrounding prose. Several
   of these can stack under one heading (e.g. multiple Temperature & Humidity sensors). */
.product-entry {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 1.25rem 1.5rem;
  margin: 1.5rem 0;
}

/* Clearfix: without this, the card's border only wraps the in-flow heading/paragraph text, so a
   floated product photo (.accent-img-right) taller than that text spills out past the bottom
   border instead of being contained by the card. */
.product-entry::after {
  content: "";
  display: table;
  clear: both;
}

@media (max-width: 600px) {
  .product-entry {
    padding: 1rem;
  }
}

/* Standalone product shot, e.g. at the bottom of a feature page. No border/background of its
   own since these are transparent-background cutouts, meant to sit directly on the page. */
.accent-img-center {
  display: block;
  width: 100%;
  max-width: 420px;
  height: auto;
  margin: 2rem auto 0;
}

.docs-toc {
  flex: 0 0 220px;
  position: sticky;
  top: 76px;
}

.docs-toc-toggle {
  display: none;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 0.6rem 0.9rem;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
}

.docs-toc-nav {
  font-size: 0.88rem;
}

.docs-toc-nav > ul {
  list-style: none;
  padding: 0;
  margin: 0;
  border-left: 2px solid var(--line);
}

.docs-toc-nav li {
  margin: 0;
}

.docs-toc-nav li.docs-toc-sub a {
  padding-left: 1.5rem;
}

.docs-toc-nav li.docs-toc-subsub a {
  padding-left: 2.25rem;
}

.docs-toc-nav a {
  display: block;
  padding: 0.35rem 0.9rem;
  color: var(--muted);
  text-decoration: none;
}

.docs-toc-nav a:hover {
  color: var(--text);
}

/* All-docs ToC (docs/index.njk only): each doc page is its own group, with that page's own
   h2/h3 outline nested underneath, a full site map, not just one page's sections. */
.toc-group {
  margin-bottom: 0.35rem;
}

.docs-toc-nav a.toc-group-link {
  color: var(--text);
  font-weight: 600;
}

.toc-group ul {
  list-style: none;
  padding: 0;
  margin: 0 0 0 0.9rem;
  border-left: 2px solid var(--line);
}

/* Docs ToC breakpoint is wider than the header's: a two-column layout needs more room than a
   single nav link does. Below it, the ToC collapses behind the Contents button (same
   disclosure mechanism as the header's mobile nav flyout). */
@media (max-width: 900px) {
  .docs-layout {
    flex-direction: column;
    gap: 1rem;
  }

  /* Reordered above the article: a "jump to section" control belongs before the reading starts,
     not after it (which is where it'd land as plain second-flex-child-becomes-second-row). */
  .docs-toc {
    order: -1;
    position: static;
    width: 100%;
    flex-basis: auto;
  }

  .docs-toc-toggle {
    display: flex;
  }

  .docs-toc-nav {
    display: none;
    margin-top: 0.5rem;
  }

  .docs-toc-nav.is-open {
    display: block;
  }
}

/* ── Home hero ────────────────────────────────────────────────────────────── */

.home-hero {
  text-align: center;
}

.home-hero .logo {
  width: 160px;
  height: auto;
  margin-bottom: 0.75rem;
}

/* ── Features ─────────────────────────────────────────────────────────────── */

/* Offsets the jump-to-#features anchor (nav link, callout box link) so the sticky header
   doesn't cover the heading it lands on. */
#features {
  scroll-margin-top: 76px;
}

.features-section {
  max-width: 1100px;
  margin: 3rem auto 0;
  padding: 0 1.5rem 3.5rem;
}

.features-title {
  text-align: center;
  font-size: 2.25rem;
  margin: 0 0 2rem;
}

.feature-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1.5rem;
}

.feature-box {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 1.5rem;
}

.feature-box-icon {
  color: var(--accent);
}

.feature-box h3 {
  margin: 0.25rem 0 0;
  font-size: 1.05rem;
}

.feature-box p {
  flex: 1;
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.feature-box-link {
  margin-top: 0.5rem;
  font-weight: 600;
  font-size: 0.9rem;
  text-decoration: none;
}

/* The Temperature callout, same card, just visually called out since it isn't its own
   top-level feature, it's a specific angle on Wireless Sensors worth a dedicated box. */
.feature-box--highlight {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 8%, var(--surface));
}

/* ── /sensors/ quick-summary grid ────────────────────────────────────────── */

.sensor-category {
  max-width: 900px;
  margin: 0 auto;
  padding: 0 1.5rem 2.5rem;
}

.sensor-category h2 {
  font-size: 1.4rem;
  margin: 0 0 1rem;
}

.sensor-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 1rem;
}

.sensor-tile {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 1rem 0.75rem;
}

.sensor-tile-title {
  margin: 0;
  font-size: 0.88rem;
  font-weight: 600;
}

.sensor-tile-img {
  width: 72px;
  height: 72px;
  object-fit: contain;
  margin: 0.5rem 0;
}

.sensor-tile-links {
  display: flex;
  gap: 0.75rem;
  font-size: 0.82rem;
}
