/* MQTT Thing EX: project site. Quiet paper with the plugin's MQTT purple (branding/icon.svg); a teal accent marks
   messages coming back from a device, so the two directions of MQTT traffic read apart at a glance. */
:root {
  color-scheme: light dark;
  --paper: #f8f5f9;
  --sheet: #ffffff;
  --ink: #1f1122;
  --muted: #6a5870;
  --rule: #e6dbe9;
  --wash: #f1e9f3;
  --brand: #660066;
  --accent: #8e2b8e;
  --link: #7d1f7d;
  --back: #0c7b6c;
  --lamp: #f4b73d;
  --on-color: #ffffff;
  --stage: #efe6f1;
  --stage-lit: #fbf0da;
  --code: #1d1320;
  --code-ink: #efe5f1;
  --code-key: #e7a8e7;
  --code-str: #9fe0d2;
  --shadow: 0 22px 50px -20px rgba(31, 17, 34, .30), 0 2px 6px rgba(31, 17, 34, .06);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", "PingFang TC", "Hiragino Sans", "Hiragino Kaku Gothic ProN",
    "Noto Sans TC", "Noto Sans JP", "Microsoft JhengHei UI", "Yu Gothic UI", "Meiryo", sans-serif;
  --display: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", "PingFang TC", "Hiragino Sans", "Noto Sans TC", "Noto Sans JP", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #150d17;
    --sheet: #1f1522;
    --ink: #f2eaf4;
    --muted: #b4a3b9;
    --rule: #37293b;
    --wash: #2a1d2e;
    --brand: #d98ad9;
    --accent: #d98ad9;
    --link: #e8a8e8;
    --back: #52d1bd;
    --lamp: #f6c35a;
    --on-color: #150d17;
    --stage: #1b111d;
    --stage-lit: #2c2114;
    --code: #0f0911;
    --shadow: 0 22px 50px -20px rgba(0, 0, 0, .65), 0 2px 6px rgba(0, 0, 0, .3);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 17px/1.65 var(--font);
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; height: auto; }
a { color: var(--link); text-underline-offset: 3px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
[hidden] { display: none !important; }
h1, h2, h3 { font-family: var(--display); line-height: 1.15; letter-spacing: -0.02em; margin: 0; }
h2 { font-size: clamp(28px, 3.6vw, 40px); font-weight: 720; text-wrap: balance; }
h3 { font-size: 18px; font-weight: 680; letter-spacing: -0.01em; }
p { margin: 0; }
code { overflow-wrap: anywhere; font-family: var(--mono); font-size: .86em; padding: .1em .35em; border-radius: 5px; background: var(--wash); }
:lang(zh-Hant-TW) h1, :lang(zh-Hant-TW) h2, :lang(ja) h1, :lang(ja) h2 { letter-spacing: 0; line-height: 1.3; }
/* Japanese has no spaces: break at phrase boundaries, not in the middle of a word (Chrome 119+; others ignore it) */
:lang(ja) :is(h1, h2, h3, p, dt, dd, small, span) { word-break: auto-phrase; }

.wrap { width: min(1120px, 100% - 32px); margin-inline: auto; }

/* ---------- Header ---------- */
.masthead { display: flex; align-items: center; gap: 12px 16px; padding-block: 18px; }
.wordmark { display: flex; white-space: nowrap; align-items: center; gap: 10px; margin-right: auto; color: inherit; text-decoration: none; font-family: var(--display); font-weight: 700; font-size: 17px; }
.wordmark img { width: 30px; height: 30px; }
.masthead > a:not(.wordmark, .tip) { color: var(--muted); text-decoration: none; font-size: 15px; }
.masthead > a:not(.wordmark, .tip):hover { color: var(--ink); }

.lang { position: relative; font-size: 15px; }
.lang summary {
  display: flex; align-items: center; gap: 6px; cursor: pointer; list-style: none; white-space: nowrap;
  padding: 4px 10px; border: 1px solid var(--rule); border-radius: 8px; background: var(--sheet); color: var(--ink);
}
.lang summary::-webkit-details-marker { display: none; }
.lang summary svg { flex: none; }
.lang ul {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 10; min-width: 150px;
  margin: 0; padding: 6px; list-style: none;
  background: var(--sheet); border: 1px solid var(--rule); border-radius: 10px; box-shadow: var(--shadow);
}
.lang li a { display: block; padding: 6px 10px; border-radius: 6px; color: var(--ink); text-decoration: none; }
.lang li a:hover { background: var(--wash); }
.lang li a[aria-current] { font-weight: 700; }

/* ---------- Hero: copy on the left, a Home tile and the MQTT traffic it causes on the right ---------- */
.hero { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 500px); gap: 56px; align-items: center; padding-top: 40px; }
.hero-copy h1 { font-size: clamp(42px, 6vw, 68px); font-weight: 760; letter-spacing: -0.035em; line-height: 1.04; text-wrap: balance; }
:lang(zh-Hant-TW) .hero-copy h1, :lang(ja) .hero-copy h1 { font-size: clamp(32px, 4.4vw, 50px); letter-spacing: 0; line-height: 1.25; }
.hero-copy .lede { margin-top: 22px; font-size: 20px; color: var(--muted); max-width: 30em; }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 22px; margin-top: 32px; }
.btn {
  display: inline-flex; align-items: center; gap: 10px; min-height: 48px; padding: 10px 22px;
  border-radius: 12px; background: var(--ink); color: var(--paper);
  font-weight: 650; text-decoration: none;
}
.btn:hover { opacity: .9; }
.btn img { width: 22px; height: 22px; border-radius: 5px; }
.fine { margin-top: 18px; font-size: 14.5px; color: var(--muted); }

.stage {
  position: relative; isolation: isolate; overflow: hidden;
  display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; padding: 30px 28px 22px; border-radius: 28px; background: var(--stage);
}
/* the lamp's light: warms the stage with the brightness while it is on */
.stage::before {
  content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none;
  background: radial-gradient(120% 80% at 20% 0%, var(--stage-lit), transparent 70%);
  opacity: calc(var(--glow, .7) * 1); transition: opacity .4s ease;
}
.stage[data-off]::before { opacity: 0; }

.tile { padding: 18px 18px 16px; border-radius: 22px; background: var(--sheet); box-shadow: var(--shadow); }
.tile-head { display: flex; align-items: center; gap: 12px; }
.tile-icon {
  display: grid; place-items: center; flex: none; width: 40px; height: 40px; border-radius: 50%;
  background: var(--lamp); color: #3b2600; transition: background .3s, color .3s;
}
.stage[data-off] .tile-icon { background: var(--wash); color: var(--muted); }
.tile-name { flex: 1; min-width: 0; line-height: 1.3; }
.tile-name strong { display: block; font-weight: 650; }
.tile-name span { display: block; font-size: 14px; color: var(--muted); font-variant-numeric: tabular-nums; }

.power {
  position: relative; flex: none; width: 51px; height: 31px; padding: 0; border: 0; border-radius: 999px;
  background: #34c759; cursor: pointer; transition: background .2s;
}
.power span { position: absolute; top: 2px; left: 22px; width: 27px; height: 27px; border-radius: 50%; background: #fff; box-shadow: 0 2px 4px rgba(0, 0, 0, .2); transition: left .2s; }
.power[aria-checked="false"] { background: var(--rule); }
.power[aria-checked="false"] span { left: 2px; }

.bright { display: grid; gap: 6px; margin-top: 14px; }
.bright-label { font-size: 13px; color: var(--muted); }
.bright input { width: 100%; margin: 0; accent-color: var(--lamp); }
.stage[data-off] .bright input { opacity: .45; }

.wire-log { padding: 14px 16px 12px; border-radius: 18px; background: var(--code); color: var(--code-ink); font: 13px/1.5 var(--mono); }
.log-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 12px; font: 600 13px/1.4 var(--font); opacity: .9; }
.queue { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-weight: 400; }
.queue input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.queue code { padding: 0; background: none; color: inherit; font-size: 12px; opacity: .85; }
.mini-switch { position: relative; flex: none; width: 30px; height: 18px; border-radius: 999px; background: rgba(255, 255, 255, .22); transition: background .2s; }
.mini-switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: #fff; transition: left .2s; }
.queue input:checked + .mini-switch { background: var(--code-key); }
.queue input:checked + .mini-switch::after { left: 14px; }
.queue input:focus-visible + .mini-switch { outline: 2px solid var(--code-key); outline-offset: 2px; }

.log { display: grid; align-content: end; gap: 1px; height: calc(7 * 1.5em + 6px); margin: 10px 0 0; padding: 0; list-style: none; overflow: hidden; }
.log li { display: grid; grid-template-columns: 1.2em minmax(0, 1fr) auto; gap: 8px; animation: arrive .25s ease-out; }
.log .dir { color: var(--code-key); }
.log .in .dir { color: var(--code-str); }
.log .topic { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; opacity: .9; }
.log .in .topic { opacity: .7; }
.log .payload { font-weight: 700; font-variant-numeric: tabular-nums; }
@keyframes arrive { from { opacity: 0; transform: translateY(6px); } }
.tally { margin-top: 8px; padding-top: 8px; border-top: 1px solid rgba(255, 255, 255, .12); font: 12.5px/1.45 var(--font); opacity: .8; min-height: 1.45em; }
.hint { font-size: 14px; color: var(--muted); text-align: center; }

/* ---------- Sections ---------- */
section.band { padding-top: 112px; }
.intro { max-width: 40em; }
.intro p { margin-top: 16px; font-size: 19px; color: var(--muted); }
.intro p + p { margin-top: 12px; }
.split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 56px; align-items: start; }

/* Switching over: a real sequence, so numbered */
.moves { display: grid; gap: 18px; margin: 32px 0 0; padding: 0; list-style: none; counter-reset: move; }
.moves li { counter-increment: move; position: relative; padding-left: 44px; }
.moves li::before {
  content: counter(move); position: absolute; left: 0; top: -2px;
  display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%;
  background: var(--brand); color: var(--on-color); font: 700 15px/1 var(--display);
}
.moves h3 { font-size: 16.5px; }
.moves p { margin-top: 4px; color: var(--muted); font-size: 15.5px; }
.back { margin-top: 24px; padding-top: 16px; border-top: 1px solid var(--rule); font-size: 15.5px; }

.code { margin: 0; border-radius: 18px; background: var(--code); color: var(--code-ink); overflow: hidden; box-shadow: var(--shadow); }
.code figcaption { padding: 10px 18px; font: 600 13px/1.4 var(--mono); border-bottom: 1px solid rgba(255, 255, 255, .1); opacity: .75; }
.code pre { margin: 0; padding: 18px; overflow-x: auto; font: 13.5px/1.65 var(--mono); }
.code pre code { padding: 0; background: none; color: inherit; font-size: inherit; }
.code .k { color: var(--code-key); }
.code .s { color: var(--code-str); }

/* Platform mode: the same twelve devices, wired two ways */
.modes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; margin-top: 44px; }
.mode { margin: 0; padding: 26px 28px 20px; background: var(--sheet); border: 1px solid var(--rule); border-radius: 18px; }
.mode figcaption { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 16px; }
.mode .count { color: var(--muted); font-size: 15px; font-variant-numeric: tabular-nums; }
.mode.is-platform .count { color: var(--link); font-weight: 650; }
.conns { display: block; width: 100%; max-width: 400px; height: auto; margin: 16px auto 0; }
.conns .dev { fill: var(--wash); stroke: var(--muted); stroke-width: 1.2; }
.conns .wire { fill: none; stroke: var(--muted); stroke-width: 1.2; opacity: .45; }
.conns .conn { fill: none; stroke: var(--accent); stroke-width: 2; opacity: .7; }
.is-platform .conns .conn { stroke-width: 5; opacity: 1; stroke-linecap: round; }
.conns .hub { fill: var(--sheet); stroke: var(--accent); stroke-width: 2.5; }
.conns .broker { fill: var(--brand); }
.conns text { fill: var(--on-color); font: 700 11px var(--font); letter-spacing: .02em; }

/* Features: plain pairs under a rule, no boxes */
.feats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 36px 40px; margin: 44px 0 0; padding: 0; list-style: none; }
.feats li { padding-top: 16px; border-top: 1px solid var(--rule); }
.feats p { margin-top: 6px; color: var(--muted); font-size: 16px; }
.feats.compact { margin-top: 36px; }

/* Accessory types */
.types { display: grid; grid-template-columns: minmax(0, 1fr); margin: 40px 0 0; background: var(--sheet); border: 1px solid var(--rule); border-radius: 18px; overflow: hidden; }
.types div { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 8px 24px; padding: 18px 26px; }
.types div + div { border-top: 1px solid var(--rule); }
.types dt { font-weight: 680; }
.types dd { display: flex; flex-wrap: wrap; gap: 6px 8px; margin: 0; }
.types dd span { padding: 1px 10px; border-radius: 999px; background: var(--wash); font-size: 15px; }
.types + .fine { margin-top: 20px; }

/* Getting started */
.steps { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 32px; margin: 40px 0 0; padding: 0; list-style: none; counter-reset: step; }
.steps li { counter-increment: step; }
.steps li::before {
  content: counter(step); display: grid; place-items: center; width: 40px; height: 40px; margin-bottom: 14px;
  border-radius: 50%; border: 2px solid var(--ink); font: 700 18px/1 var(--display);
}
.steps p { margin-top: 6px; color: var(--muted); }
.steps + .fine { margin-top: 32px; }

/* ---------- Support ---------- */
.tip {
  display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 6px 16px;
  border: 1px solid var(--rule); border-radius: 10px; background: var(--sheet);
  color: var(--ink); font-weight: 600; text-decoration: none;
}
.tip:hover { border-color: var(--muted); }
.tip img { flex: none; width: 24px; height: 24px; margin-left: -4px; border-radius: 6px; }
.head-tip { min-height: 34px; padding: 4px 12px; font-size: 15px; }
.tipjar {
  display: grid; grid-template-columns: 120px minmax(0, 1fr); gap: 36px; align-items: center;
  padding: 40px 44px; background: var(--sheet); border: 1px solid var(--rule); border-radius: 18px;
}
.tipjar > img { width: 120px; height: 120px; border-radius: 30px; }
.tipjar p { max-width: 38em; margin-top: 12px; color: var(--muted); font-size: 18px; }
.tipjar .actions { margin-top: 24px; }
.tipjar .fine { margin-top: 12px; font-size: 14.5px; }

/* ---------- Footer ---------- */
footer { margin-top: 120px; padding-block: 40px 56px; border-top: 1px solid var(--rule); font-size: 15px; color: var(--muted); }
.foot { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 32px; }
.foot ul { display: flex; flex-wrap: wrap; gap: 8px 20px; margin: 12px 0 0; padding: 0; list-style: none; }
.foot .langs { justify-content: flex-end; }
.foot .langs a { color: var(--muted); text-decoration: none; }
.foot .langs a:hover, .foot .langs a[aria-current] { color: var(--ink); }
.tm { margin-top: 28px; font-size: 13.5px; }

/* ---------- Small screens ---------- */
@media (max-width: 900px) {
  .hero { grid-template-columns: minmax(0, 1fr); gap: 40px; padding-top: 16px; }
  .stage { padding: 24px 18px 18px; }
  .split, .foot, .modes { grid-template-columns: minmax(0, 1fr); }
  .feats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .steps { grid-template-columns: minmax(0, 1fr); }
  .tipjar { grid-template-columns: minmax(0, 1fr); gap: 20px; padding: 28px 24px; }
  .tipjar > img { width: 88px; height: 88px; border-radius: 22px; }
  .foot .langs { justify-content: flex-start; }
  section.band { padding-top: 84px; }
  .types div { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 640px) {
  body { font-size: 16px; }
  .feats { grid-template-columns: minmax(0, 1fr); }
  .mode { padding: 22px 20px 16px; }
  .types div { padding: 16px 18px; }
  .masthead > a:not(.wordmark, .head-tip) { display: none; }
  .wordmark { font-size: 15px; }
  .head-tip span { display: none; }
  .head-tip { padding: 4px 8px; }
  .head-tip img { margin: 0; }
  .wire-log { font-size: 12px; }
}
@media (max-width: 400px) {
  .lang summary span { display: none; }
  .lang summary { padding: 6px 8px; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
