#037 style light mobile: high Tactile Analog & Pixel-Craft

Solar Dithered Zine

1-bit dithered editorial print aesthetic with a live solar-battery level meter and ultra-lightweight analog craft.

Inspired by Low-Tech Magazine Solar ↗

Download .html
Fullscreen ↗

WHY THIS AESTHETIC IS UNIQUE

Makes web energy footprint visible right in the layout via an interactive solar battery gauge, 1-bit stippled illustrations, and radically legible low-bandwidth typography.

BEST FOR

Independent essays & zinesClimate & sustainability journalsLow-bandwidth documentationEditorial research archives

TAGS

COLOR PALETTE (CLICK TO COPY HEX)

TYPOGRAPHY

Display
Libre Baskerville
Body
Libre Baskerville
Mono
IBM Plex Mono
Scale
Classic bookish serif body (17px, 1.65 line-height) paired with crisp monospace energy telemetry, byte counts, and numbered marginal footnotes.

Google Fonts Stylesheet ↗

ARCHITECTURE & MOBILE NOTES

LAYOUT

Single-column editorial measure with a full-bleed solar battery fill indicator, dithered Canvas/SVG technical diagrams, and interactive inline footnote callouts.

INTERACTION

Interactive Solar Charge simulator (100% Sunny, 55% Overcast, 18% Low-Power Night) that dynamically shifts the battery fill level, page telemetry, and low-energy contrast mode, plus clickable footnotes.

MOBILE

Natively single-column and ultra-fast on 390px viewports with >=44px solar-mode toggles and tap-to-reveal inline footnotes.

AI AGENT GUARDRAILS

DO

  • Render illustrations as 1-bit dithered or stippled monochrome graphics to honor low-bandwidth craft.
  • Expose honest technical telemetry (page weight in KB, solar battery state, server weather).
  • Keep typography book-like, calm, and optimized for long-form reading.

DON'T

  • Never bloat the layout with heavy hero carousels, autoplay video, or superfluous UI chrome.
  • Avoid glossy modern SaaS buttons; keep controls flat, bordered, and utilitarian.
STANDALONE SOURCE · demos/solar-dithered-zine.html (29.1 KB)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>HELIOS MONOGRAPH — Solar-Powered Dithered Journal</title>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;600&family=Newsreader:ital,opsz,wght@0,6..72,400;0,6..72,600;1,6..72,400&display=swap" rel="stylesheet">
<style>
  :root {
    --paper: #F4EFE4;
    --paper-alt: #E7E0D0;
    --ink: #171614;
    --ink-soft: #4F4A42;
    --accent: #B84A27;
    --charge-tint: rgba(217, 178, 76, 0.16);
    --charge-height: 100%;
    --border: #171614;
    --dither-fg: #171614;
    --dither-bg: #F4EFE4;
  }

  [data-solar="overcast"] {
    --paper: #E9E4D8;
    --paper-alt: #DCD5C6;
    --ink: #22211E;
    --ink-soft: #545047;
    --accent: #8B4E2F;
    --charge-tint: rgba(145, 134, 108, 0.22);
    --charge-height: 55%;
    --border: #2A2824;
    --dither-fg: #22211E;
    --dither-bg: #E9E4D8;
  }

  [data-solar="night"] {
    --paper: #161513;
    --paper-alt: #22201C;
    --ink: #E2DACB;
    --ink-soft: #A79E8D;
    --accent: #E29B4B;
    --charge-tint: rgba(226, 155, 75, 0.14);
    --charge-height: 18%;
    --border: #9E9484;
    --dither-fg: #E2DACB;
    --dither-bg: #161513;
  }

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

  html, body {
    margin: 0;
    padding: 0;
    max-width: 100%;
    overflow-x: hidden;
    background: var(--paper);
    color: var(--ink);
    font-family: 'Newsreader', Georgia, 'Times New Roman', serif;
    font-size: 19px;
    line-height: 1.62;
    transition: background-color 0.25s ease, color 0.25s ease;
  }

  /* Live Solar Battery Backdrop Meter (inspired by Low-Tech Magazine Solar) */
  .battery-backdrop {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
  }
  .battery-fill {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: var(--charge-height);
    background: var(--charge-tint);
    border-top: 2px dashed var(--accent);
    transition: height 0.45s cubic-bezier(0.22, 1, 0.36, 1), background-color 0.25s ease;
  }
  .battery-level-tag {
    position: absolute;
    right: 12px;
    top: 6px;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 11px;
    letter-spacing: 0.06em;
    color: var(--accent);
    text-transform: uppercase;
  }

  .page-wrap {
    position: relative;
    z-index: 1;
    max-width: 820px;
    margin: 0 auto;
    padding: 0 16px 64px;
  }

  /* Solar Telemetry Control Banner */
  .solar-banner {
    margin: 14px 0 24px;
    border: 2px solid var(--border);
    background: var(--paper);
    font-family: 'IBM Plex Mono', monospace;
    font-size: 12px;
  }

  .solar-top {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    background: var(--paper-alt);
  }

  .solar-status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
  }
  .status-dot {
    width: 10px;
    height: 10px;
    border: 1px solid var(--border);
    background: var(--accent);
    display: inline-block;
  }

  .solar-controls {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    border-bottom: 1px solid var(--border);
  }
  @media (max-width: 520px) {
    .solar-controls { grid-template-columns: 1fr; }
  }

  .solar-btn {
    appearance: none;
    border: 0;
    border-right: 1px solid var(--border);
    background: transparent;
    color: var(--ink);
    font-family: 'IBM Plex Mono', monospace;
    font-size: 12px;
    padding: 10px 12px;
    min-height: 44px;
    cursor: pointer;
    text-align: left;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
  }
  .solar-btn:last-child { border-right: 0; }
  @media (max-width: 520px) {
    .solar-btn { border-right: 0; border-bottom: 1px solid var(--border); }
    .solar-btn:last-child { border-bottom: 0; }
  }
  .solar-btn[aria-pressed="true"] {
    background: var(--ink);
    color: var(--paper);
    font-weight: 600;
  }
  .solar-btn:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: -2px;
  }

  .telemetry-strip {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px 16px;
    padding: 10px 12px;
  }
  @media (min-width: 640px) {
    .telemetry-strip { grid-template-columns: repeat(4, 1fr); }
  }
  .telem-item span {
    display: block;
    font-size: 10px;
    color: var(--ink-soft);
    text-transform: uppercase;
  }
  .telem-item strong {
    font-size: 13px;
  }

  /* Masthead */
  .masthead {
    border-top: 4px double var(--border);
    border-bottom: 2px solid var(--border);
    padding: 18px 0;
    margin-bottom: 26px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
  }
  .masthead-id {
    display: flex;
    align-items: center;
    gap: 14px;
  }
  .masthead h1 {
    margin: 0;
    font-family: 'IBM Plex Mono', monospace;
    font-size: clamp(20px, 4vw, 28px);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    line-height: 1.1;
  }
  .masthead-sub {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 12px;
    color: var(--ink-soft);
    margin-top: 4px;
  }
  .issue-meta {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 12px;
    text-align: right;
  }
  @media (max-width: 560px) {
    .issue-meta { text-align: left; }
  }

  /* Article Typography */
  .article-kicker {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--accent);
    margin: 0 0 8px;
  }
  .article-title {
    font-size: clamp(28px, 5vw, 42px);
    line-height: 1.14;
    margin: 0 0 12px;
    font-weight: 600;
    letter-spacing: -0.01em;
  }
  .article-dek {
    font-size: 20px;
    font-style: italic;
    color: var(--ink-soft);
    margin: 0 0 22px;
    border-left: 3px solid var(--accent);
    padding-left: 14px;
  }

  .byline {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 12px;
    color: var(--ink-soft);
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    padding: 8px 0;
    margin-bottom: 24px;
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 8px;
  }

  .prose p { margin: 0 0 18px; }
  .prose h2 {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 16px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin: 30px 0 12px;
    padding-bottom: 4px;
    border-bottom: 1px solid var(--border);
  }

  /* Dithered Illustration Figures */
  .dither-figure {
    margin: 26px 0;
    border: 1px solid var(--border);
    background: var(--paper-alt);
    padding: 12px;
  }
  .dither-toolbar {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 11px;
  }
  .dither-toggle {
    appearance: none;
    border: 1px solid var(--border);
    background: var(--paper);
    color: var(--ink);
    font-family: 'IBM Plex Mono', monospace;
    font-size: 11px;
    padding: 6px 10px;
    min-height: 44px;
    cursor: pointer;
  }
  .dither-toggle:hover { background: var(--ink); color: var(--paper); }

  .dither-canvas {
    width: 100%;
    height: auto;
    display: block;
    border: 1px solid var(--border);
    image-rendering: pixelated;
  }

  .dither-figure figcaption {
    margin-top: 10px;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 12px;
    line-height: 1.45;
    color: var(--ink-soft);
  }

  /* Interactive Footnote Triggers & Popover */
  .fn-ref {
    appearance: none;
    border: 1px solid var(--border);
    background: var(--paper-alt);
    color: var(--ink);
    font-family: 'IBM Plex Mono', monospace;
    font-size: 12px;
    font-weight: 600;
    padding: 2px 6px;
    min-width: 30px;
    min-height: 30px;
    margin: 0 2px;
    cursor: pointer;
    vertical-align: baseline;
    line-height: 1;
  }
  .fn-ref:hover, .fn-ref[aria-expanded="true"] {
    background: var(--accent);
    color: #FFF;
    border-color: var(--accent);
  }

  .fn-popover {
    margin: 12px 0 18px;
    padding: 12px 14px;
    border: 2px solid var(--accent);
    background: var(--paper-alt);
    font-family: 'IBM Plex Mono', monospace;
    font-size: 13px;
    line-height: 1.5;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
  }
  .fn-popover[hidden] { display: none; }
  .fn-close {
    appearance: none;
    border: 1px solid var(--border);
    background: var(--paper);
    color: var(--ink);
    font-family: 'IBM Plex Mono', monospace;
    font-size: 12px;
    min-width: 44px;
    min-height: 44px;
    cursor: pointer;
    flex-shrink: 0;
  }

  /* Budget Comparison Table */
  .table-wrap {
    overflow-x: auto;
    border: 1px solid var(--border);
    margin: 20px 0;
  }
  table {
    width: 100%;
    border-collapse: collapse;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 13px;
    background: var(--paper);
  }
  th, td {
    text-align: left;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
  }
  th {
    background: var(--paper-alt);
    text-transform: uppercase;
    font-size: 11px;
  }

  /* Footnotes Footer */
  .footnotes {
    margin-top: 34px;
    padding-top: 16px;
    border-top: 2px solid var(--border);
    font-family: 'IBM Plex Mono', monospace;
    font-size: 13px;
  }
  .footnotes ol {
    padding-left: 20px;
    margin: 10px 0 0;
  }
  .footnotes li { margin-bottom: 10px; }

  .colophon {
    margin-top: 32px;
    padding: 14px;
    border: 1px dashed var(--border);
    font-family: 'IBM Plex Mono', monospace;
    font-size: 12px;
    color: var(--ink-soft);
  }
</style>
</head>
<body data-solar="sunny">

<!-- Live Solar Battery Backdrop -->
<div class="battery-backdrop" aria-hidden="true">
  <div class="battery-fill" id="batteryFill">
    <span class="battery-level-tag" id="batteryTag">RESERVE 100%</span>
  </div>
</div>

<div class="page-wrap">

  <!-- Solar Charge Simulator & Telemetry -->
  <section class="solar-banner" aria-label="Solar server battery simulator">
    <div class="solar-top">
      <div class="solar-status">
        <span class="status-dot" aria-hidden="true"></span>
        <span id="solarHeadline">SOLAR SERVER: SUNNY PEAK (100% CHARGE)</span>
      </div>
      <span id="solarNote">14.2W PV IN &middot; BARCELONA NODE</span>
    </div>

    <div class="solar-controls" role="group" aria-label="Simulate solar weather">
      <button type="button" class="solar-btn" data-mode="sunny" aria-pressed="true">
        <span>100% Sunny</span><span>14.2W</span>
      </button>
      <button type="button" class="solar-btn" data-mode="overcast" aria-pressed="false">
        <span>55% Overcast</span><span>4.8W</span>
      </button>
      <button type="button" class="solar-btn" data-mode="night" aria-pressed="false">
        <span>18% Low-Power Night</span><span>0.0W</span>
      </button>
    </div>

    <div class="telemetry-strip">
      <div class="telem-item"><span>Battery Reserve</span><strong id="tReserve">38.4 hrs</strong></div>
      <div class="telem-item"><span>Page Transfer</span><strong id="tWeight">14.6 KB</strong></div>
      <div class="telem-item"><span>Est. CO₂ / View</span><strong id="tCo2">0.018 g</strong></div>
      <div class="telem-item"><span>Render Mode</span><strong id="tMode">Full 1-Bit</strong></div>
    </div>
  </section>

  <!-- Editorial Masthead -->
  <header class="masthead">
    <div class="masthead-id">
      <!-- 1-Bit Halftone Sun SVG Emblem -->
      <svg width="48" height="48" viewBox="0 0 48 48" fill="none" aria-hidden="true">
        <circle cx="24" cy="24" r="12" stroke="currentColor" stroke-width="2"/>
        <circle cx="24" cy="24" r="6" fill="currentColor"/>
        <g stroke="currentColor" stroke-width="2" stroke-dasharray="2 2">
          <line x1="24" y1="2" x2="24" y2="9"/>
          <line x1="24" y1="39" x2="24" y2="46"/>
          <line x1="2" y1="24" x2="9" y2="24"/>
          <line x1="39" y1="24" x2="46" y2="24"/>
          <line x1="8" y1="8" x2="14" y2="14"/>
          <line x1="34" y1="34" x2="40" y2="40"/>
          <line x1="40" y1="8" x2="34" y2="14"/>
          <line x1="14" y1="34" x2="8" y2="40"/>
        </g>
      </svg>
      <div>
        <h1>HELIOS MONOGRAPH</h1>
        <div class="masthead-sub">A 1-Bit Solar-Hosted Journal of Resilient Engineering</div>
      </div>
    </div>
    <div class="issue-meta">
      ISSUE NO. 14 &middot; AUTUMN<br>
      LAT 41.38&deg;N &middot; OFF-GRID
    </div>
  </header>

  <main>
    <p class="article-kicker">Essay &middot; Intermittent Infrastructure</p>
    <h2 class="article-title">Designing Websites That Sleep With the Sun</h2>
    <p class="article-dek">
      When a web server runs on a 50-watt balcony panel and a single LiFePO₄ cell, every kilobyte is measured in watt-hours—and 1-bit dithering becomes an architectural discipline.
    </p>

    <div class="byline">
      <span>By M. Soler &amp; K. Lindqvist</span>
      <span>Reading time: 4 min &middot; Zero trackers</span>
    </div>

    <article class="prose">
      <p>
        Modern web pages routinely ship three megabytes of uncompressed photography, web fonts, and telemetry scripts to display a few paragraphs of text.<button type="button" class="fn-ref" data-fn="1" aria-expanded="false" aria-controls="fnPopover">[1]</button> On grid-connected cloud clusters, that excess is invisible; on a rooftop solar server during three consecutive days of November rain, it is the difference between staying online and browning out at dusk.
      </p>

      <div class="fn-popover" id="fnPopover" role="region" aria-label="Footnote detail" hidden>
        <div id="fnPopoverText"></div>
        <button type="button" class="fn-close" id="fnClose" aria-label="Close footnote">&times;</button>
      </div>

      <p>
        Rather than hiding the physical weather behind redundant diesel generators, a solar-hosted publication exposes its energy state directly in the interface. The rising tint behind this page represents the real-time state of charge of our charge controller.<button type="button" class="fn-ref" data-fn="2" aria-expanded="false" aria-controls="fnPopover">[2]</button> Use the weather simulator above to see how typography, contrast, and dithering adapt as cloud cover thickens.
      </p>

      <!-- Live 1-Bit Dithered Canvas Figure 1 -->
      <figure class="dither-figure">
        <div class="dither-toolbar">
          <span>FIG 01. BALCONY PV + MPPT CHARGE CONTROLLER</span>
          <button type="button" class="dither-toggle" id="btnDitherAlgo">Algo: Bayer 4&times;4</button>
        </div>
        <canvas class="dither-canvas" id="ditherSolar" width="480" height="220" aria-label="1-bit dithered technical diagram of a solar panel, battery bank, and low-power single-board server"></canvas>
        <figcaption>
          Rendered live in 1-bit monochrome ink. Switching from 24-bit color photographs to ordered Bayer or Atkinson dithered plates cuts image transfer weight by up to 92% while preserving crisp mechanical legibility.
        </figcaption>
      </figure>

      <h2>1. The Economics of Ordered 1-Bit Dithering</h2>
      <p>
        In 1984, Bill Atkinson designed a halftoning kernel for the original Macintosh that discarded a quarter of quantization error to preserve high-contrast edges in technical line art.<button type="button" class="fn-ref" data-fn="3" aria-expanded="false" aria-controls="fnPopover">[3]</button> Paired with static HTML and system-first typography, 1-bit dithering allows rich diagrams to travel over 2G rural links and e-ink readers without layout shift.
      </p>

      <!-- Live 1-Bit Dithered Canvas Figure 2 -->
      <figure class="dither-figure">
        <div class="dither-toolbar">
          <span>FIG 02. PASSIVE WIND-PUMPED CISTERN LOOP</span>
          <span id="ditherDensity">DENSITY: 100%</span>
        </div>
        <canvas class="dither-canvas" id="ditherPump" width="480" height="200" aria-label="1-bit dithered technical illustration of a wind turbine pumping water to an elevated cistern"></canvas>
        <figcaption>
          Gravity storage mirrors battery storage: excess afternoon wind or sunlight is banked into potential energy for calm, overcast mornings.
        </figcaption>
      </figure>

      <h2>2. Static Page Weight Budget</h2>
      <p>
        Below is the measured energy budget comparing a conventional editorial CMS against our static solar monograph.<button type="button" class="fn-ref" data-fn="4" aria-expanded="false" aria-controls="fnPopover">[4]</button>
      </p>

      <div class="table-wrap">
        <table>
          <thead>
            <tr>
              <th>Component</th>
              <th>Typical News Site</th>
              <th>Helios Monograph</th>
              <th>Savings</th>
            </tr>
          </thead>
          <tbody>
            <tr>
              <td>HTML + Inline CSS</td>
              <td>420 KB</td>
              <td>14.6 KB</td>
              <td>-96.5%</td>
            </tr>
            <tr>
              <td>Illustrations (2 plates)</td>
              <td>1,840 KB</td>
              <td>1-Bit Procedural</td>
              <td>-99.2%</td>
            </tr>
            <tr>
              <td>Client Scripts</td>
              <td>910 KB</td>
              <td>3.8 KB</td>
              <td>-99.6%</td>
            </tr>
            <tr>
              <td>Server Idle Draw</td>
              <td>180 W (rack share)</td>
              <td>1.9 W (ARM SBC)</td>
              <td>-98.9%</td>
            </tr>
          </tbody>
        </table>
      </div>
    </article>

    <section class="footnotes" aria-label="References">
      <strong>REFERENCES &amp; TECHNICAL NOTES</strong>
      <ol>
        <li id="fn-1">HTTP Archive Web Almanac (2024): Median desktop page weight exceeds 2,500 KB, dominated by unoptimized hero images and third-party scripts.</li>
        <li id="fn-2">Our rooftop testbed pairs a 50W monocrystalline panel, a 10A MPPT controller, and a 12V 24Ah LiFePO₄ battery powering a passively cooled 1.9W ARM board.</li>
        <li id="fn-3">Atkinson dithering distributes 6/8 of quantization error to neighboring pixels (instead of 16/16 in Floyd-Steinberg), creating airy highlights ideal for newsprint aesthetics.</li>
        <li id="fn-4">Measurements recorded across 10,000 cold-cache page loads using an inline INA219 DC current sensor on the 5V server rail.</li>
      </ol>
    </section>

    <footer class="colophon">
      COLOPHON: Served statically with zero external image requests. Switch solar modes above to test OLED low-power night contrast and battery-level telemetry.
    </footer>
  </main>
</div>

<script>
(() => {
  const MODES = {
    sunny: {
      headline: 'SOLAR SERVER: SUNNY PEAK (100% CHARGE)',
      note: '14.2W PV IN · BARCELONA NODE',
      tag: 'RESERVE 100%',
      reserve: '38.4 hrs',
      weight: '14.6 KB',
      co2: '0.018 g',
      mode: 'Full 1-Bit',
      density: 'DENSITY: 100%',
      fg: '#171614',
      bg: '#F4EFE4',
      bias: 0
    },
    overcast: {
      headline: 'SOLAR SERVER: OVERCAST THROTTLE (55% CHARGE)',
      note: '4.8W PV IN · CLOUD COVER 78%',
      tag: 'RESERVE 55%',
      reserve: '19.1 hrs',
      weight: '14.6 KB',
      co2: '0.019 g',
      mode: 'Eco Halftone',
      density: 'DENSITY: 82%',
      fg: '#22211E',
      bg: '#E9E4D8',
      bias: 12
    },
    night: {
      headline: 'SOLAR SERVER: LOW-POWER NIGHT (18% RESERVE)',
      note: '0.0W PV IN · OLED DARK INK ACTIVE',
      tag: 'RESERVE 18%',
      reserve: '6.2 hrs',
      weight: '11.2 KB',
      co2: '0.012 g',
      mode: 'OLED Sparse',
      density: 'DENSITY: 64%',
      fg: '#E2DACB',
      bg: '#161513',
      bias: 20
    }
  };

  const FOOTNOTES = {
    1: '[1] HTTP Archive Web Almanac: Median desktop page weight exceeds 2,500 KB, dominated by hero images and third-party scripts.',
    2: '[2] Rooftop testbed: 50W monocrystalline panel + 10A MPPT controller + 12V 24Ah LiFePO₄ cell powering a 1.9W passively cooled ARM board.',
    3: '[3] Bill Atkinson’s 1984 dither distributes 6/8 of quantization error, keeping technical schematics crisp and high-contrast.',
    4: '[4] Measured across 10,000 cold-cache loads using an inline INA219 DC current sensor on the 5V rail.'
  };

  let currentMode = 'sunny';
  let useAtkinson = false;

  const BAYER4 = [
    [0, 8, 2, 10],
    [12, 4, 14, 6],
    [3, 11, 1, 9],
    [15, 7, 13, 5]
  ];

  function hexToRgb(hex) {
    const n = parseInt(hex.slice(1), 16);
    return [(n >> 16) & 255, (n >> 8) & 255, n & 255];
  }

  // Draw grayscale scene 1: Solar Panel + Sun + Battery + Server
  function paintSolarScene(ctx, w, h) {
    const sky = ctx.createLinearGradient(0, 0, 0, h);
    sky.addColorStop(0, '#D8D8D8');
    sky.addColorStop(0.65, '#F5F5F5');
    sky.addColorStop(0.66, '#A8A8A8');
    sky.addColorStop(1, '#707070');
    ctx.fillStyle = sky;
    ctx.fillRect(0, 0, w, h);

    // Sun with radial glow
    const sunGrad = ctx.createRadialGradient(86, 52, 8, 86, 52, 54);
    sunGrad.addColorStop(0, '#FFFFFF');
    sunGrad.addColorStop(0.45, '#E4E4E4');
    sunGrad.addColorStop(1, 'rgba(220,220,220,0)');
    ctx.fillStyle = sunGrad;
    ctx.beginPath();
    ctx.arc(86, 52, 54, 0, Math.PI * 2);
    ctx.fill();
    ctx.strokeStyle = '#222';
    ctx.lineWidth = 2;
    ctx.beginPath();
    ctx.arc(86, 52, 18, 0, Math.PI * 2);
    ctx.stroke();

    // Solar Panel tilted array
    ctx.save();
    ctx.fillStyle = '#3A3A3A';
    ctx.beginPath();
    ctx.moveTo(140, 128);
    ctx.lineTo(245, 74);
    ctx.lineTo(295, 102);
    ctx.lineTo(190, 156);
    ctx.closePath();
    ctx.fill();
    ctx.strokeStyle = '#111';
    ctx.lineWidth = 2;
    ctx.stroke();
    // Panel grid lines
    ctx.strokeStyle = '#E0E0E0';
    ctx.lineWidth = 1;
    for (let i = 1; i < 4; i++) {
      const t = i / 4;
      ctx.beginPath();
      ctx.moveTo(140 + (245 - 140) * t, 128 + (74 - 128) * t);
      ctx.lineTo(190 + (295 - 190) * t, 156 + (102 - 156) * t);
      ctx.stroke();
    }
    ctx.restore();

    // Stand legs
    ctx.strokeStyle = '#181818';
    ctx.lineWidth = 4;
    ctx.beginPath();
    ctx.moveTo(185, 145); ctx.lineTo(175, 185);
    ctx.moveTo(255, 118); ctx.lineTo(265, 185);
    ctx.stroke();

    // Conduit cable to Battery Box
    ctx.strokeStyle = '#111';
    ctx.lineWidth = 2;
    ctx.beginPath();
    ctx.moveTo(260, 152);
    ctx.quadraticCurveTo(300, 182, 336, 152);
    ctx.stroke();

    // LiFePO4 Battery + SBC enclosure
    ctx.fillStyle = '#555555';
    ctx.fillRect(336, 104, 106, 78);
    ctx.strokeStyle = '#111';
    ctx.lineWidth = 2;
    ctx.strokeRect(336, 104, 106, 78);
    ctx.fillStyle = '#EAEAEA';
    ctx.fillRect(348, 118, 42, 48);
    ctx.fillStyle = '#222';
    ctx.fillRect(354, 134, 30, 26);
    // Vent slots on server side
    for (let y = 122; y <= 162; y += 8) {
      ctx.fillStyle = '#111';
      ctx.fillRect(402, y, 28, 3);
    }
  }

  // Draw grayscale scene 2: Windmill + Cistern
  function paintPumpScene(ctx, w, h) {
    const bg = ctx.createLinearGradient(0, 0, 0, h);
    bg.addColorStop(0, '#E2E2E2');
    bg.addColorStop(0.72, '#F7F7F7');
    bg.addColorStop(0.73, '#989898');
    bg.addColorStop(1, '#585858');
    ctx.fillStyle = bg;
    ctx.fillRect(0, 0, w, h);

    // Lattice tower
    ctx.strokeStyle = '#141414';
    ctx.lineWidth = 2;
    ctx.beginPath();
    ctx.moveTo(118, 56); ctx.lineTo(94, 166);
    ctx.moveTo(132, 56); ctx.lineTo(156, 166);
    ctx.moveTo(106, 110); ctx.lineTo(144, 110);
    ctx.moveTo(100, 140); ctx.lineTo(150, 140);
    ctx.stroke();

    // Rotor blades
    const cx = 125, cy = 54;
    for (let a = 0; a < 6; a++) {
      const rad = (a * Math.PI) / 3;
      ctx.fillStyle = a % 2 === 0 ? '#303030' : '#707070';
      ctx.beginPath();
      ctx.moveTo(cx, cy);
      ctx.lineTo(cx + Math.cos(rad) * 44, cy + Math.sin(rad) * 44);
      ctx.lineTo(cx + Math.cos(rad + 0.28) * 38, cy + Math.sin(rad + 0.28) * 38);
      ctx.closePath();
      ctx.fill();
    }

    // Pipe to elevated cistern
    ctx.strokeStyle = '#111';
    ctx.lineWidth = 4;
    ctx.beginPath();
    ctx.moveTo(125, 166);
    ctx.lineTo(125, 180);
    ctx.lineTo(310, 180);
    ctx.lineTo(310, 74);
    ctx.lineTo(340, 74);
    ctx.stroke();

    // Cistern drum with cylindrical shading
    const tankGrad = ctx.createLinearGradient(334, 0, 426, 0);
    tankGrad.addColorStop(0, '#333');
    tankGrad.addColorStop(0.4, '#C8C8C8');
    tankGrad.addColorStop(1, '#262626');
    ctx.fillStyle = tankGrad;
    ctx.fillRect(334, 62, 92, 82);
    ctx.strokeStyle = '#111';
    ctx.lineWidth = 2;
    ctx.strokeRect(334, 62, 92, 82);
    // Support stilts
    ctx.fillStyle = '#222';
    ctx.fillRect(344, 144, 8, 32);
    ctx.fillRect(408, 144, 8, 32);
  }

  function applyDither(canvas, paintFn) {
    const ctx = canvas.getContext('2d');
    const w = canvas.width;
    const h = canvas.height;
    paintFn(ctx, w, h);

    const img = ctx.getImageData(0, 0, w, h);
    const data = img.data;
    const lum = new Float32Array(w * h);
    const cfg = MODES[currentMode];

    for (let i = 0; i < w * h; i++) {
      const r = data[i * 4];
      const g = data[i * 4 + 1];
      const b = data[i * 4 + 2];
      lum[i] = 0.299 * r + 0.587 * g + 0.114 * b + cfg.bias;
    }

    const fg = hexToRgb(cfg.fg);
    const bg = hexToRgb(cfg.bg);

    if (!useAtkinson) {
      // Ordered Bayer 4x4 1-bit dither
      for (let y = 0; y < h; y++) {
        for (let x = 0; x < w; x++) {
          const threshold = ((BAYER4[y & 3][x & 3] + 0.5) / 16) * 255;
          const isLight = lum[y * w + x] >= threshold;
          const col = isLight ? bg : fg;
          const idx = (y * w + x) * 4;
          data[idx] = col[0];
          data[idx + 1] = col[1];
          data[idx + 2] = col[2];
          data[idx + 3] = 255;
        }
      }
    } else {
      // Bill Atkinson 1-bit error diffusion
      for (let y = 0; y < h; y++) {
        for (let x = 0; x < w; x++) {
          const p = y * w + x;
          const oldVal = lum[p];
          const newVal = oldVal >= 128 ? 255 : 0;
          const err = (oldVal - newVal) / 8;
          const col = newVal === 255 ? bg : fg;
          const idx = p * 4;
          data[idx] = col[0];
          data[idx + 1] = col[1];
          data[idx + 2] = col[2];
          data[idx + 3] = 255;

          if (x + 1 < w) lum[p + 1] += err;
          if (x + 2 < w) lum[p + 2] += err;
          if (y + 1 < h) {
            if (x > 0) lum[p + w - 1] += err;
            lum[p + w] += err;
            if (x + 1 < w) lum[p + w + 1] += err;
          }
          if (y + 2 < h) lum[p + w * 2] += err;
        }
      }
    }
    ctx.putImageData(img, 0, 0);
  }

  function renderAllDithers() {
    applyDither(document.getElementById('ditherSolar'), paintSolarScene);
    applyDither(document.getElementById('ditherPump'), paintPumpScene);
  }

  function setSolarMode(mode) {
    currentMode = mode;
    const cfg = MODES[mode];
    document.body.setAttribute('data-solar', mode);
    document.getElementById('solarHeadline').textContent = cfg.headline;
    document.getElementById('solarNote').textContent = cfg.note;
    document.getElementById('batteryTag').textContent = cfg.tag;
    document.getElementById('tReserve').textContent = cfg.reserve;
    document.getElementById('tWeight').textContent = cfg.weight;
    document.getElementById('tCo2').textContent = cfg.co2;
    document.getElementById('tMode').textContent = cfg.mode;
    document.getElementById('ditherDensity').textContent = cfg.density;

    document.querySelectorAll('.solar-btn').forEach(btn => {
      btn.setAttribute('aria-pressed', String(btn.dataset.mode === mode));
    });
    renderAllDithers();
  }

  document.querySelectorAll('.solar-btn').forEach(btn => {
    btn.addEventListener('click', () => setSolarMode(btn.dataset.mode));
  });

  const btnDitherAlgo = document.getElementById('btnDitherAlgo');
  btnDitherAlgo.addEventListener('click', () => {
    useAtkinson = !useAtkinson;
    btnDitherAlgo.textContent = `Algo: ${useAtkinson ? 'Atkinson' : 'Bayer 4×4'}`;
    renderAllDithers();
  });

  // Interactive Footnote Popover
  const fnPopover = document.getElementById('fnPopover');
  const fnPopoverText = document.getElementById('fnPopoverText');
  let openFn = null;

  document.querySelectorAll('.fn-ref').forEach(btn => {
    btn.addEventListener('click', () => {
      const id = btn.dataset.fn;
      if (openFn === id && !fnPopover.hidden) {
        fnPopover.hidden = true;
        btn.setAttribute('aria-expanded', 'false');
        openFn = null;
        return;
      }
      document.querySelectorAll('.fn-ref').forEach(b => b.setAttribute('aria-expanded', 'false'));
      btn.setAttribute('aria-expanded', 'true');
      fnPopoverText.textContent = FOOTNOTES[id];
      fnPopover.hidden = false;
      openFn = id;
      btn.closest('p').insertAdjacentElement('afterend', fnPopover);
    });
  });

  document.getElementById('fnClose').addEventListener('click', () => {
    fnPopover.hidden = true;
    document.querySelectorAll('.fn-ref').forEach(b => b.setAttribute('aria-expanded', 'false'));
    openFn = null;
  });

  renderAllDithers();
})();
</script>
</body>
</html>