/*
 * SPDX-License-Identifier: Apache-2.0
 * Copyright 2026 Thomas Steiner
 */

:root {
  color-scheme: light dark;
  --bg: light-dark(#f6f5f2, #111214);
  --card: light-dark(#ffffff, #1b1c1f);
  --text: light-dark(#1d1d1f, #ececee);
  --muted: light-dark(#6b6b70, #9a9aa2);
  --line: light-dark(#e3e1dc, #2c2d31);
  --accent: light-dark(#0a6cff, #4d9bff);
  --still: light-dark(#2e8b57, #4cc38a);
  --moving: light-dark(#d9480f, #ff8a4c);
  --radius: 14px;
  font-family:
    -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  transition:
    background 0.6s,
    color 0.6s;
}

/* The ambient light demo overrides the system scheme. */
:root[data-scheme="light"] {
  color-scheme: light;
}

:root[data-scheme="dark"] {
  color-scheme: dark;
}

body {
  margin: 0 auto;
  max-width: 72rem;
  padding: 2.5rem 1.25rem 3rem;
}

h1 {
  font-size: clamp(1.8rem, 4vw, 2.6rem);
  letter-spacing: -0.02em;
  margin: 0 0 0.5rem;
}

.lede {
  color: var(--muted);
  font-size: 1.1rem;
  line-height: 1.5;
  max-width: 46rem;
  margin: 0;
}

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

main {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(21rem, 1fr));
  gap: 1.25rem;
  margin-top: 2rem;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.25rem 1.25rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  transition: background 0.6s;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

h2 {
  font-size: 1.2rem;
  margin: 0;
}

.connect {
  font: inherit;
  font-weight: 600;
  border: 0;
  border-radius: 999px;
  padding: 0.4rem 1rem;
  background: var(--accent);
  color: white;
  cursor: pointer;
}

.connect:disabled {
  background: var(--line);
  color: var(--muted);
  cursor: default;
}

.hint {
  color: var(--muted);
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.6;
}

/* The device name to pick in the chooser, styled as a chip. */
.hint strong {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 0.95em;
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
  border-radius: 6px;
  padding: 0.05em 0.4em;
}

.notice {
  margin: 0;
  padding: 0.6rem 0.8rem;
  border-radius: 8px;
  background: light-dark(#fff4d6, #3a2f12);
  font-size: 0.9rem;
}

header .notice {
  margin-top: 1rem;
  max-width: 46rem;
}

.readout {
  margin: 0;
  display: flex;
  align-items: baseline;
  gap: 0.35rem;
}

.readout .value {
  font-size: 3.2rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.03em;
}

.readout span {
  color: var(--muted);
  font-size: 1.2rem;
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
  margin: 0;
}

.stats dt {
  color: var(--muted);
  font-size: 0.75rem;
}

.stats dd {
  margin: 0;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.toggle {
  display: flex;
  gap: 0.5rem;
  align-items: flex-start;
  font-size: 0.9rem;
}

details {
  font-size: 0.85rem;
  color: var(--muted);
  border-top: 1px solid var(--line);
  padding-top: 0.6rem;
}

summary {
  cursor: pointer;
}

details p {
  line-height: 1.45;
}

.raw {
  font-size: 0.75rem;
  white-space: pre-wrap;
  word-break: break-all;
  margin: 0;
}

/* Lid angle */

.laptop {
  width: 100%;
  height: auto;
}

.laptop line {
  stroke-linecap: round;
}

.laptop .base {
  stroke: var(--muted);
  stroke-width: 10;
}

.laptop .lid {
  stroke: var(--accent);
  stroke-width: 6;
}

.laptop .hinge {
  fill: var(--text);
}

.laptop .arc {
  fill: color-mix(in srgb, var(--accent) 14%, transparent);
  stroke: none;
}

/* Ambient light */

.meter {
  position: relative;
  height: 0.6rem;
  border-radius: 999px;
  background: linear-gradient(90deg, #1b1f3a, #6b6f8a, #f0e2b6, #fff7d1);
  margin-bottom: 1.2rem;
}

.meter-fill {
  position: absolute;
  top: -0.3rem;
  width: 0.25rem;
  height: 1.2rem;
  border-radius: 2px;
  background: var(--text);
  left: 0;
  transition: left 0.3s;
}

.meter-scale {
  list-style: none;
  margin: 0;
  padding: 0;
  position: absolute;
  inset: 0.9rem 0 auto;
  font-size: 0.7rem;
  color: var(--muted);
}

.meter-scale li {
  position: absolute;
  left: calc(var(--at) * 100%);
  transform: translateX(-50%);
  white-space: nowrap;
}

.spark {
  width: 100%;
  height: 70px;
}

.light-detail {
  display: flex;
  gap: 1rem;
  align-items: center;
  justify-content: space-between;
}

.cct {
  display: flex;
  gap: 0.6rem;
  align-items: center;
}

.swatch {
  width: 2.4rem;
  height: 2.4rem;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--line);
}

.cct-value {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.sub {
  color: var(--muted);
  font-size: 0.75rem;
}

.channels {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  height: 2.6rem;
}

.channels span {
  width: 0.7rem;
  height: 4%;
  border-radius: 3px 3px 0 0;
  background: var(--muted);
  transition: height 0.3s;
}

.channels span:nth-child(1) {
  background: #7d5cff;
}

.channels span:nth-child(2) {
  background: #2f8cff;
}

.channels span:nth-child(3) {
  background: #2fbf71;
}

.channels span:nth-child(4) {
  background: #ffb020;
}

.channels span:nth-child(5) {
  background: #ff5a4f;
}

/* Motion state */

.status {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 2rem;
  font-weight: 700;
  padding: 0.5rem 0;
}

.dot {
  width: 1.1rem;
  height: 1.1rem;
  border-radius: 50%;
  background: var(--muted);
}

.status[data-state="still"] .dot {
  background: var(--still);
}

/* Settling: it moved a moment ago. Same color as moving, without the pulse. */
.status[data-state="settling"] .dot {
  background: var(--moving);
  opacity: 0.6;
}

.status[data-state="moving"] .dot {
  background: var(--moving);
  animation: pulse 0.8s ease-in-out infinite;
}

@keyframes pulse {
  50% {
    transform: scale(1.4);
    opacity: 0.6;
  }
}

@media (prefers-reduced-motion: reduce) {
  .status[data-state="moving"] .dot {
    animation: none;
  }
}

.log {
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 0.85rem;
  max-height: 8.5rem;
  overflow: auto;
}

.log li {
  display: flex;
  justify-content: space-between;
  padding: 0.3rem 0;
  border-bottom: 1px solid var(--line);
}

.log time {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

footer {
  margin-top: 2.5rem;
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.5;
  max-width: 46rem;
}
