/* ==========================================================================
   LIFX Home Control — shared styles
   "Instrument grey": soft appliance greys, a dark top panel, and one
   signal green that means "on".
   ========================================================================== */

@font-face {
  font-family: "Archivo";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("fonts/archivo-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Archivo";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("fonts/archivo-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  color-scheme: light;
  --bg: #e6e6e4;
  --surface: #f6f6f4;
  --surface-2: #ececea;
  --line: #d4d4d1;
  --line-strong: #b4b4b0;
  --text: #1c1c1c;
  --muted: #555552;
  --faint: #64645f;
  --accent: #2f7d36;
  --accent-soft: #dbeadb;
  --accent-ink: #ffffff;
  --danger: #c23128;
  --danger-soft: #f8e0de;
  --led: #4fc95a;
  --plate: #efefed;
  --paddle-hi: #fbfbfa;
  --paddle-lo: #d2d2ce;
  /* Top panel */
  --bar-bg: #2a2a2a;
  --bar-line: #2a2a2a;
  --bar-text: #f2f2f0;
  --bar-muted: #b4b4b0;
  --bar-hover: rgba(255, 255, 255, .08);
  --bar-on: rgba(255, 255, 255, .16);
  --shadow: 0 1px 0 rgba(255, 255, 255, .6) inset, 0 2px 6px rgba(0, 0, 0, .08);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, .22);
  --radius: 14px;
  --radius-sm: 8px;
  --font: "Archivo", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #1b1b1b;
  --surface: #252525;
  --surface-2: #2d2d2d;
  --line: #373737;
  --line-strong: #4c4c4c;
  --text: #ededeb;
  --muted: #a9a9a5;
  --faint: #92928d;
  --accent: #6ccf74;
  --accent-soft: #21361f;
  --accent-ink: #0b210d;
  --danger: #ff8076;
  --danger-soft: #3a1d1a;
  --led: #6ccf74;
  --plate: #303030;
  --paddle-hi: #4a4a4a;
  --paddle-lo: #2b2b2b;
  --bar-bg: #111111;
  --bar-line: #373737;
  --bar-text: #ededeb;
  --bar-muted: #a9a9a5;
  --bar-hover: rgba(255, 255, 255, .06);
  --bar-on: rgba(255, 255, 255, .14);
  --shadow: 0 1px 0 rgba(255, 255, 255, .04) inset, 0 2px 6px rgba(0, 0, 0, .35);
  --shadow-lg: 0 16px 48px rgba(0, 0, 0, .6);
}

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

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

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }
button, input { font: inherit; color: inherit; }
h1, h2, h3, p, ul, ol { margin: 0; }
[hidden] { display: none !important; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
::selection { background: var(--accent-soft); color: var(--text); }
html { accent-color: var(--accent); caret-color: var(--accent); scrollbar-color: var(--line-strong) transparent; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.wrap { width: 100%; max-width: 1120px; margin: 0 auto; padding: 0 16px; }
main { flex: 1; }

/* ---------- Top bar ---------- */

.topbar {
  position: sticky; top: 0; z-index: 10;
  background: var(--bar-bg);
  color: var(--bar-text);
  border-bottom: 1px solid var(--bar-line);
}
.topbar .btn-ghost { color: var(--bar-muted); }
.topbar .btn-ghost:hover { color: var(--bar-text); background: var(--bar-hover); }
.topbar .btn:not(.btn-ghost) { background: transparent; color: var(--bar-text); border-color: rgba(255, 255, 255, .22); }
.topbar .btn:not(.btn-ghost):hover { background: var(--bar-hover); }
.topbar .segmented { background: var(--bar-hover); border-color: rgba(255, 255, 255, .1); }
.topbar .segmented button { color: var(--bar-muted); }
.topbar .segmented button:hover { color: var(--bar-text); }
.topbar .segmented button[aria-pressed="true"] { background: var(--bar-on); color: var(--bar-text); box-shadow: none; }
.topbar :focus-visible { outline-color: var(--led); }
.topbar .wrap { display: flex; align-items: center; gap: 12px; height: 56px; }

.brand {
  display: inline-flex; align-items: center; gap: 10px;
  font-weight: 650; letter-spacing: -.01em; text-decoration: none; white-space: nowrap;
}
.brand-mark {
  width: 22px; height: 22px; border-radius: 50%;
  background: radial-gradient(circle at 50% 50%, var(--led) 0 28%, #3a3a3a 30% 100%);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, .18) inset, 0 0 8px rgba(79, 201, 90, .35);
  flex: none;
}
.topbar .spacer { flex: 1; }

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 36px; padding: 0 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  font-size: 14px; font-weight: 550;
  text-decoration: none; cursor: pointer; white-space: nowrap;
  transition: background-color .15s, border-color .15s;
}
.btn:hover { background: var(--surface-2); border-color: var(--line-strong); }
.btn:disabled { opacity: .5; cursor: default; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: color-mix(in srgb, var(--accent) 88%, var(--text)); border-color: transparent; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--surface-2); border-color: transparent; color: var(--text); }
.btn-icon { width: 36px; padding: 0; }
.btn svg { width: 18px; height: 18px; flex: none; }

/* Segmented control (theme picker, view tabs) */
.segmented {
  display: inline-flex; padding: 3px; gap: 2px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 10px;
}
.segmented button {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 28px; min-width: 30px; padding: 0 10px;
  border: 0; border-radius: 7px; background: transparent;
  color: var(--muted); font-size: 13px; font-weight: 550; cursor: pointer;
}
.segmented button svg { width: 16px; height: 16px; }
.segmented button:hover { color: var(--text); }
.segmented button[aria-pressed="true"],
.segmented button[aria-selected="true"] {
  background: var(--surface); color: var(--text); box-shadow: var(--shadow);
}
.segmented.icons button { padding: 0 6px; }

/* ---------- Wall-switch (rocker) ---------- */

.rocker {
  --w: 30px; --h: 44px;
  position: relative; flex: none;
  width: var(--w); height: var(--h);
  padding: 3px;
  border-radius: 6px;
  border: 1px solid var(--line-strong);
  background: var(--plate);
  box-shadow: var(--shadow);
  cursor: pointer;
}
.rocker.lg { --w: 34px; --h: 50px; }
.rocker .paddle {
  display: block; width: 100%; height: 100%;
  border-radius: 5px;
  border: 1px solid var(--line);
  transition: background .18s ease, box-shadow .18s ease;
  /* Off: bottom half pressed in, top half proud */
  background: linear-gradient(to bottom, var(--paddle-hi) 0%, var(--paddle-hi) 46%, var(--paddle-lo) 54%, var(--paddle-lo) 100%);
  box-shadow: 0 -2px 0 rgba(0,0,0,.04) inset, 0 1px 1px rgba(0,0,0,.08);
}
.rocker[aria-checked="true"] .paddle {
  /* On: top half pressed in, bottom half proud */
  background: linear-gradient(to bottom, var(--paddle-lo) 0%, var(--paddle-lo) 46%, var(--paddle-hi) 54%, var(--paddle-hi) 100%);
  box-shadow: 0 2px 0 rgba(0,0,0,.04) inset, 0 -1px 1px rgba(0,0,0,.08);
}
/* Pilot light */
.rocker::after {
  content: ""; position: absolute; left: 50%; top: 9px;
  width: 4px; height: 4px; margin-left: -2px; border-radius: 50%;
  background: var(--line-strong);
  transition: background .18s, box-shadow .18s;
}
.rocker[aria-checked="true"]::after {
  background: var(--led);
  box-shadow: 0 0 6px 1px var(--led);
}
.rocker:disabled { cursor: not-allowed; opacity: .45; }

/* ---------- Brightness slider ---------- */

.range {
  --pct: 50%;
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 22px; margin: 0;
  background: transparent; cursor: pointer;
}
.range::-webkit-slider-runnable-track {
  height: 6px; border-radius: 3px;
  background: linear-gradient(to right, var(--accent) var(--pct), var(--line) var(--pct));
}
.range::-moz-range-track { height: 6px; border-radius: 3px; background: var(--line); }
.range::-moz-range-progress { height: 6px; border-radius: 3px; background: var(--accent); }
.range::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 18px; height: 18px; margin-top: -6px; border-radius: 50%;
  background: var(--surface); border: 1px solid var(--line-strong);
  box-shadow: 0 1px 3px rgba(0,0,0,.25);
}
.range::-moz-range-thumb {
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--surface); border: 1px solid var(--line-strong);
  box-shadow: 0 1px 3px rgba(0,0,0,.25);
}
.range:disabled { cursor: default; opacity: .4; }
.range:disabled::-webkit-slider-runnable-track { background: var(--line); }
.range:disabled::-moz-range-progress { background: transparent; }

/* ---------- Colour swatch ---------- */

.swatch {
  flex: none; width: 26px; height: 26px; padding: 0;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  box-shadow: 0 0 0 2px var(--surface) inset;
  background: var(--surface-2);
  cursor: pointer;
}
.swatch:disabled { cursor: default; opacity: .5; }
.swatch:not(:disabled):hover { border-color: var(--text); }

/* ---------- Dashboard ---------- */

.toolbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  flex-wrap: wrap;
  padding: 16px 0 12px;
}
.status-line { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; }
.status-line .btn { height: 30px; width: 30px; }

.banner {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 10px 12px; margin-bottom: 12px;
  border-radius: var(--radius-sm);
  background: var(--danger-soft); color: var(--danger);
  font-size: 14px;
}
.banner svg { width: 18px; height: 18px; flex: none; }
.banner .btn { margin-left: auto; height: 30px; }

.rooms {
  /* Masonry-style columns so short rooms don't leave gaps */
  columns: 2 420px; column-gap: 12px;
  padding-bottom: 12px;
}
.rooms > .card { break-inside: avoid; margin-bottom: 12px; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.row {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 12px;
  min-height: 56px;
}
.row + .row { border-top: 1px solid var(--line); }

.row .label { flex: 1 1 auto; min-width: 0; }
.row .name {
  display: block; font-weight: 550;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.row .meta { display: block; font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .controls { flex: 0 0 auto; display: flex; align-items: center; gap: 10px; }
.row .controls .range { width: 120px; }
.row .meta, .status-line { font-variant-numeric: tabular-nums; }
.row .pct { width: 3.2em; text-align: right; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }

.room-head { background: var(--surface-2); min-height: 64px; }
.room-head .name { font-size: 16px; font-weight: 650; letter-spacing: -.01em; }

.err { color: var(--danger); font-weight: 550; }
.err svg { width: 13px; height: 13px; vertical-align: -2px; margin-right: 2px; }

.light.is-offline .name { color: var(--muted); }

.all-lights { padding-bottom: 24px; }
.all-lights .card {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 420px), 1fr));
}
/* Draw dividers in a multi-column list */
.all-lights .card .row { border-top: 1px solid var(--line); margin-top: -1px; }
.all-lights .card .row:nth-child(odd) { border-right: 1px solid var(--line); margin-right: -1px; }

.empty {
  padding: 40px 16px; text-align: center; color: var(--muted);
}

.skeleton .row .name, .skeleton .row .meta {
  background: var(--surface-2); color: transparent; border-radius: 4px; width: 50%;
}
.skeleton .row .meta { width: 30%; margin-top: 4px; }

/* ---------- Home (signed out) ---------- */

.hero {
  display: grid; gap: 32px; align-items: center;
  grid-template-columns: 1.1fr 1fr;
  padding: 56px 0 40px;
}
.hero h1 { font-size: clamp(30px, 5vw, 44px); line-height: 1.1; letter-spacing: -.025em; font-weight: 700; }
.hero .lede { margin-top: 14px; font-size: 17px; color: var(--muted); max-width: 34em; }

.signin { padding: 20px; }
.signin h2 { font-size: 17px; font-weight: 650; }
.signin p { color: var(--muted); font-size: 14px; margin-top: 4px; }
.field { display: flex; gap: 8px; margin-top: 14px; }
.input-wrap { position: relative; flex: 1; }
.input {
  width: 100%; height: 40px; padding: 0 40px 0 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  background: var(--bg);
}
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input-wrap .btn { position: absolute; right: 2px; top: 2px; height: 36px; width: 36px; }
.field .btn-primary { height: 40px; }
.form-msg { margin-top: 10px; font-size: 13px; min-height: 1.2em; }
.signin .fine { margin-top: 12px; font-size: 12px; color: var(--faint); }

.preview { margin-top: 16px; pointer-events: none; user-select: none; }

.section { padding: 32px 0; border-top: 1px solid var(--line); }
.section > h2 { font-size: 22px; letter-spacing: -.015em; font-weight: 650; }
.section > .sub { color: var(--muted); margin-top: 4px; }

.values { display: grid; gap: 20px 40px; margin-top: 24px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.value { display: grid; grid-template-columns: 22px 1fr; gap: 2px 12px; align-content: start; }
.value svg { width: 20px; height: 20px; color: var(--accent); grid-row: span 2; margin-top: 2px; }
.value h3 { font-size: 15px; font-weight: 650; }
.value p { color: var(--muted); font-size: 14px; max-width: 36ch; }

.steps { list-style: none; padding: 0; margin-top: 20px; display: grid; gap: 10px; counter-reset: step; }
.steps li {
  counter-increment: step;
  display: grid; grid-template-columns: 28px 1fr; gap: 12px; align-items: start;
}
.steps li::before {
  content: counter(step);
  width: 28px; height: 28px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent);
  font-size: 13px; font-weight: 700;
}
.steps strong { display: block; font-weight: 600; }
.steps span { color: var(--muted); font-size: 14px; }

/* ---------- Help page ---------- */

.doc { display: grid; grid-template-columns: 200px 1fr; gap: 40px; padding-top: 32px; padding-bottom: 48px; }
.toc { position: sticky; top: 76px; align-self: start; font-size: 14px; }
.toc p { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--faint); margin-bottom: 8px; }
.toc ul { list-style: none; padding: 0; display: grid; gap: 2px; }
.toc a { display: block; padding: 4px 8px; margin-left: -8px; border-radius: 6px; text-decoration: none; color: var(--muted); }
.toc a:hover { background: var(--surface-2); color: var(--text); }

.prose { max-width: 680px; }
.prose h1 { font-size: 32px; letter-spacing: -.02em; font-weight: 700; line-height: 1.15; }
.prose .lede { color: var(--muted); font-size: 17px; margin-top: 8px; }
.prose h2 { font-size: 20px; font-weight: 650; letter-spacing: -.01em; margin-top: 40px; padding-top: 8px; scroll-margin-top: 72px; }
.prose h3 { font-size: 15px; font-weight: 650; margin-top: 20px; }
.prose p, .prose ul, .prose ol { margin-top: 10px; }
.prose ul, .prose ol { padding-left: 20px; }
.prose li + li { margin-top: 6px; }
.prose a { color: var(--accent); text-underline-offset: 2px; }
.prose code { font-size: 13px; padding: 1px 5px; border-radius: 4px; background: var(--surface-2); border: 1px solid var(--line); }
.callout { margin-top: 14px; padding: 12px 14px; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--line); font-size: 14px; }
.demo-row { display: flex; gap: 16px; align-items: center; margin-top: 12px; flex-wrap: wrap; font-size: 13px; color: var(--muted); }
.demo-row > span { display: inline-flex; align-items: center; gap: 8px; }

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

.footer { border-top: 1px solid var(--line); color: var(--muted); font-size: 13px; }
.footer .wrap { display: flex; gap: 8px 20px; align-items: center; flex-wrap: wrap; padding-top: 16px; padding-bottom: 20px; }
.footer nav { display: flex; gap: 4px 16px; flex-wrap: wrap; }
.footer a { text-decoration: none; }
.footer a:hover { color: var(--text); text-decoration: underline; text-underline-offset: 2px; }
.footer .note { margin-left: auto; color: var(--faint); }

/* ---------- Colour dialog ---------- */

dialog.sheet {
  width: min(400px, calc(100vw - 24px));
  padding: 0; border: 1px solid var(--line); border-radius: 16px;
  background: var(--surface); color: var(--text);
  box-shadow: var(--shadow-lg);
}
dialog.sheet::backdrop { background: rgba(10, 10, 9, .45); }
.sheet-head { display: flex; align-items: center; gap: 10px; padding: 14px 16px 4px; }
.sheet-head h2 { font-size: 16px; font-weight: 650; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sheet-body { padding: 8px 16px 16px; }
.wheel-wrap { display: grid; place-items: center; padding: 8px 0 4px; }
#color-wheel { width: min(260px, 70vw); aspect-ratio: 1; border-radius: 50%; touch-action: none; cursor: crosshair; }
.sheet-label { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--faint); margin: 14px 0 8px; }
.whites { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 30px; padding: 0 10px 0 6px;
  border-radius: 999px; border: 1px solid var(--line);
  background: var(--surface); font-size: 13px; cursor: pointer;
}
.chip i { width: 16px; height: 16px; border-radius: 50%; border: 1px solid var(--line-strong); }
.chip:hover { border-color: var(--line-strong); }
.chip[aria-pressed="true"] { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.sheet-foot { display: flex; align-items: center; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--line); }
.sheet-foot .preview-dot { width: 28px; height: 28px; border-radius: 50%; border: 1px solid var(--line-strong); }
.sheet-foot .spacer { flex: 1; }

/* ---------- Toasts ---------- */

.toasts {
  position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%);
  z-index: 50; display: grid; gap: 8px; width: min(440px, calc(100vw - 32px));
}
.toast {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 12px 14px; border-radius: 10px;
  background: var(--text); color: var(--bg);
  box-shadow: var(--shadow-lg); font-size: 14px;
  animation: toast-in .18s ease-out;
}
.toast.error { background: var(--danger); color: #fff; }
.toast svg { width: 18px; height: 18px; flex: none; margin-top: 1px; }
.toast strong { display: block; font-weight: 650; }
@keyframes toast-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------- Responsive ---------- */

@media (max-width: 860px) {
  .hero { grid-template-columns: 1fr; padding-top: 32px; gap: 24px; }
  .doc { grid-template-columns: 1fr; gap: 16px; padding-top: 20px; }
  .toc { position: static; }
  .toc ul { display: flex; flex-wrap: wrap; gap: 4px 12px; }
  .toc a { margin-left: 0; padding: 2px 0; }
}

@media (max-width: 520px) {
  .hide-sm { display: none !important; }
  .topbar .wrap { gap: 8px; }
  .row { gap: 10px; padding: 8px 10px; }
  .row .controls { gap: 8px; }
  .row .controls .range { width: 84px; }
  .row .meta, .status-line { font-variant-numeric: tabular-nums; }
.row .pct { display: none; }
  .field { flex-direction: column; }
  .footer .note { margin-left: 0; }
  .all-lights .card .row:nth-child(odd) { border-right: 0; margin-right: 0; }
}

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