Skip to content

Your home as a live 3D model in the Mac menu bar and on iPhone — lights and ACs via Smart Life, Home Assistant, Philips Hue and Apple Home.

12.3 KB
Raw Blame
/* The island lives in a transparent window pinned to the top of the screen; only the
   black shape is drawn. Its top edge is the screen's edge, so it reads as part of the notch. */

html.mode-island, html.mode-island body { background: transparent; }
html.mode-island #app { display: block; padding: 0; height: 100%; }

.isle {
  --notch-w: 190px;
  --notch-h: 34px;
  --ear: 64px;
  --mood: #17274f;
  --w: calc(var(--notch-w) + var(--ear) * 2);
  --h: var(--notch-h);
  --r: 13px;
  /* Springs sampled from a damped oscillator, the way SwiftUI animates: opening is
     response 0.5 s with damping 0.74 (overshoots 3 %), closing response 0.34 s, no bounce. */
  --open: cubic-bezier(0.3, 1.32, 0.5, 1);
  --close: cubic-bezier(0.32, 0.72, 0.2, 1);
  --open-ms: 820ms;
  --close-ms: 460ms;
  position: absolute;
  inset: 0 0 auto 0;
  display: flex;
  justify-content: center;
  pointer-events: none;
  font-size: 12px;
}
@supports (transition-timing-function: linear(0, 1)) {
  .isle { --open: linear(0, 0.0217, 0.0776, 0.156, 0.2473, 0.3442, 0.4412, 0.5342, 0.6205, 0.6985, 0.7672, 0.8264, 0.8762, 0.9174, 0.9504, 0.9764, 0.9961, 1.0105, 1.0204, 1.0268, 1.0302, 1.0315, 1.0311, 1.0296, 1.0272, 1.0244, 1.0214, 1.0183, 1.0153, 1.0126, 1.01, 1.0078, 1.0059, 1.0042, 1.0029, 1.0018, 1.0009, 1.0002, 0.9998, 0.9994, 0.9992, 0.9991, 0.999, 0.999, 0.9991, 0.9991, 0.9992, 1); --close: linear(0, 0.0145, 0.0518, 0.1043, 0.1659, 0.2324, 0.3005, 0.3679, 0.4329, 0.4944, 0.5518, 0.6047, 0.6529, 0.6966, 0.7358, 0.7707, 0.8018, 0.8291, 0.8532, 0.8742, 0.8926, 0.9085, 0.9222, 0.9341, 0.9443, 0.9531, 0.9605, 0.9669, 0.9723, 0.9769, 0.9808, 0.984, 0.9868, 0.9891, 0.991, 0.9926, 0.994, 0.9951, 0.996, 0.9968, 0.9974, 0.9979, 0.9983, 0.9987, 0.999, 0.9992, 0.9994, 1); }
}
.isle.quiet { --ear: 0px; }
.isle[data-state='peek'] { --ear: 132px; --r: 16px; }
.isle[data-state='expanded'] { --w: 664px; --h: calc(var(--notch-h) + 292px); --r: 34px; }

/* Only the size of one plain black box changes while the island moves; everything heavy
   (the glow, the model) keeps its size and fades, so no frame has to repaint much. */
.isle-shape {
  position: relative;
  width: var(--w);
  height: var(--h);
  background: #000;
  border-radius: 0 0 var(--r) var(--r);
  overflow: hidden;
  pointer-events: auto;
  transition:
    width var(--close-ms) var(--close),
    height var(--close-ms) var(--close),
    border-radius var(--close-ms) var(--close);
}
.isle[data-state='expanded'] .isle-shape,
.isle[data-state='peek'] .isle-shape {
  transition:
    width var(--open-ms) var(--open),
    height var(--open-ms) var(--open),
    border-radius var(--open-ms) var(--open);
}

/* The light that spills out under the open island, tinted by what is on at home. */
.isle-glow {
  position: absolute;
  top: 0;
  left: 50%;
  width: 664px;
  height: calc(var(--notch-h) + 292px);
  margin-left: -332px;
  border-radius: 0 0 34px 34px;
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.06),
    0 26px 60px -12px rgba(0, 0, 0, 0.75),
    0 40px 110px -30px color-mix(in srgb, var(--mood) 85%, transparent);
  opacity: 0;
  transform: scale(0.94);
  transform-origin: 50% 0;
  transition: opacity 140ms ease, transform 0s 140ms;
}
.isle[data-state='expanded'] .isle-glow {
  opacity: 1;
  transform: none;
  transition: opacity 520ms ease 120ms, transform var(--open-ms) var(--open);
}

/* ---------- at rest and while peeking ---------- */

.ear {
  position: absolute;
  top: 0;
  height: var(--notch-h);
  width: var(--ear);
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 10px 0 12px;
  white-space: nowrap;
  overflow: hidden;
  color: #f3f5fa;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  transition: opacity 220ms ease, width var(--open-ms) var(--open);
}
.ear.left { left: 0; }
.ear.right { right: 0; justify-content: flex-end; padding: 0 12px 0 10px; }
.isle[data-state='expanded'] .ear { opacity: 0; transition: opacity 90ms ease; }
.isle[data-state='collapsed'] .ear { transition: opacity 260ms ease 200ms, width var(--close-ms) var(--close); }
.ear-icon { color: var(--c); filter: drop-shadow(0 0 5px color-mix(in srgb, var(--c) 70%, transparent)); flex: none; }
.ear-text { overflow: hidden; text-overflow: ellipsis; }
.ear-text.strong { color: color-mix(in srgb, var(--mood) 35%, #fff); }
.ear > * { animation: ear-in 360ms cubic-bezier(0.22, 1, 0.36, 1) both; }
@keyframes ear-in { from { opacity: 0; transform: scale(0.6); filter: blur(4px); } }

/* ---------- open ---------- */

.isle-body {
  position: absolute;
  top: 0;
  left: 50%;
  width: 664px;
  height: calc(var(--notch-h) + 292px);
  margin-left: -332px;
  display: flex;
  flex-direction: column;
  pointer-events: none;
}
.isle[data-state='expanded'] .isle-body { pointer-events: auto; }

.isle-head {
  flex: none;
  height: var(--notch-h);
  display: grid;
  grid-template-columns: 1fr var(--notch-w) 1fr;
  align-items: center;
  padding: 0 14px 0 16px;
  color: var(--muted);
}
.isle-title { display: flex; align-items: center; gap: 8px; min-width: 0; font-size: 12.5px; }
.isle-title b { color: var(--text); font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.isle-badge { color: color-mix(in srgb, var(--mood) 40%, #fff); display: grid; }
.isle-right { display: flex; align-items: center; justify-content: flex-end; gap: 10px; min-width: 0; }
.isle-status { display: flex; align-items: center; gap: 5px; white-space: nowrap; font-size: 12px; }
.isle-status b { color: var(--text); font-weight: 600; }
.isle-status .dot { width: 6px; height: 6px; border-radius: 50%; background: #4ade80; box-shadow: 0 0 8px #4ade80; margin-right: 2px; }
.isle-power {
  width: 24px; height: 24px; border-radius: 50%;
  display: grid; place-items: center;
  background: rgba(255, 255, 255, 0.1);
  color: var(--muted);
  transition: background 200ms, color 200ms, transform 260ms var(--spring), box-shadow 300ms;
}
.isle-power:active { transform: scale(0.88); }
.isle-power.on { background: linear-gradient(180deg, #5aa2ff, #2f7bf2); color: #fff; box-shadow: 0 4px 14px -3px rgba(61, 139, 255, 0.8); }

.isle-main { flex: 1; min-height: 0; display: grid; grid-template-columns: 286px 1fr; gap: 6px; padding: 2px 14px 14px 8px; }

.isle-stage { position: relative; min-height: 0; }
.isle-stage canvas {
  width: 100%; height: 100%; display: block; outline: none;
  /* The model floats in the black of the island: no edge of the canvas may show. */
  -webkit-mask-image: radial-gradient(closest-side, #000 66%, transparent 100%);
  mask-image: radial-gradient(closest-side, #000 66%, transparent 100%);
}

.isle-side { min-width: 0; min-height: 0; display: flex; flex-direction: column; gap: 9px; }

.isle-scenes { flex: none; display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 6px; }
.isle-scene {
  height: 50px; border-radius: 15px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  font-size: 10.5px; font-weight: 600; color: var(--muted);
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.06);
  --own: transform 300ms var(--spring), background 220ms, color 220ms, border-color 220ms, box-shadow 300ms;
  transition: var(--own);
}
.isle-scene span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 0 4px; }
@media (hover: hover) { .isle-scene:hover { background: rgba(255, 255, 255, 0.12); color: var(--text); } }
.isle-scene:active { transform: scale(0.93); }
.isle-scene.active {
  color: #fff;
  background: linear-gradient(180deg, rgba(88, 150, 255, 0.4), rgba(61, 139, 255, 0.16));
  border-color: rgba(120, 175, 255, 0.55);
  box-shadow: 0 8px 20px -10px rgba(61, 139, 255, 0.9);
}
.isle-scene.active .icon { color: #a9cbff; }

.isle-list {
  flex: 1; min-height: 0;
  display: grid; grid-template-columns: 1fr 1fr; grid-auto-rows: 44px; gap: 6px;
  overflow-y: auto; scrollbar-width: none;
  margin-bottom: -14px; padding-bottom: 14px;
  -webkit-mask-image: linear-gradient(180deg, #000 calc(100% - 26px), transparent 100%);
  mask-image: linear-gradient(180deg, #000 calc(100% - 26px), transparent 100%);
}
.isle-list::-webkit-scrollbar { display: none; }

.chip {
  --c: var(--warm);
  position: relative;
  min-width: 0;
  border-radius: 14px;
  padding: 0 9px;
  display: flex; align-items: center; gap: 8px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.06);
  --own: transform 300ms var(--spring), background 240ms, border-color 240ms, box-shadow 320ms;
  transition: var(--own);
}
.chip.ac { grid-column: 1 / -1; gap: 6px; }
@media (hover: hover) { .chip.light:hover { background: rgba(255, 255, 255, 0.12); } }
.chip.pressed { transform: scale(0.96); }
.chip.dimmable { cursor: ew-resize; }
.chip.on {
  background: linear-gradient(135deg, color-mix(in srgb, var(--c) 30%, transparent), color-mix(in srgb, var(--c) 9%, transparent));
  border-color: color-mix(in srgb, var(--c) 44%, transparent);
  box-shadow: 0 10px 22px -16px var(--c);
}
.chip-bubble {
  flex: none; width: 28px; height: 28px; border-radius: 10px;
  display: grid; place-items: center;
  color: var(--muted); background: rgba(255, 255, 255, 0.08);
  transition: background 240ms, color 240ms, box-shadow 320ms;
}
.chip.on .chip-bubble { color: #241503; background: var(--c); box-shadow: 0 0 16px -3px var(--c); }
.chip.ac.on .chip-bubble { color: #06162c; }
.chip-text { flex: 1; min-width: 0; }
.chip-name { font-size: 12px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chip-sub { margin-top: 1px; font-size: 10.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-variant-numeric: tabular-nums; }
.chip.on .chip-sub { color: color-mix(in srgb, var(--c) 55%, #fff); }
.chip-level {
  position: absolute; left: 0; bottom: 0; height: 2.5px; width: 100%;
  transform-origin: left; transform: scaleX(var(--level, 0));
  background: var(--c); opacity: 0;
  transition: transform 240ms var(--ease), opacity 240ms;
}
.chip.on.dimmable .chip-level { opacity: 0.9; }
.chip-step, .chip-power {
  flex: none; width: 24px; height: 24px; border-radius: 8px;
  display: grid; place-items: center; color: var(--muted);
  transition: background 180ms, color 180ms, transform 240ms var(--spring), box-shadow 300ms;
}
@media (hover: hover) { .chip-step:hover { background: rgba(255, 255, 255, 0.14); color: var(--text); } }
.chip-step:active, .chip-power:active { transform: scale(0.86); }
.chip-value { min-width: 30px; text-align: center; font-size: 14px; font-weight: 650; color: var(--text); font-variant-numeric: tabular-nums; }
.chip.ac:not(.on) .chip-value { color: var(--faint); }
.chip-power { border-radius: 50%; margin-left: 2px; background: rgba(255, 255, 255, 0.1); }
.chip.ac.on .chip-power { background: var(--c); color: #06162c; box-shadow: 0 0 14px -4px var(--c); }
/* On but not running: outlined in the mode's colour instead of lit with it. */
.chip.ac.on.idle { background: rgba(255, 255, 255, 0.07); border-color: rgba(255, 255, 255, 0.06); box-shadow: none; }
.chip.ac.on.idle .chip-bubble, .chip.ac.on.idle .chip-power { background: transparent; color: var(--c); box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--c) 70%, transparent); }

/* ---------- arriving ---------- */

/* Every part of the open island arrives on its own, top to bottom (--d is set per part),
   and they all leave together. `translate` and `scale` leave `transform` to the parts'
   own press effects; --own keeps their own transitions running. */
.reveal {
  opacity: 0;
  translate: 0 -10px;
  transition: opacity 110ms ease, translate 0s 120ms, scale 0s 120ms, var(--own, opacity 110ms ease);
}
.isle-stage.reveal { translate: none; scale: 0.84; transform-origin: 50% 35%; }
.isle-scene.reveal { translate: 0 -12px; scale: 0.9; }
.isle[data-state='expanded'] .reveal {
  opacity: 1;
  translate: none;
  scale: none;
  transition:
    opacity 320ms ease var(--d, 0ms),
    translate var(--open-ms) var(--open) var(--d, 0ms),
    scale var(--open-ms) var(--open) var(--d, 0ms),
    var(--own, opacity 320ms ease var(--d, 0ms));
}

/* With Reduce Motion on, as Apple does it: the island still grows out of the notch, but
   without the bounce, and its parts fade in where they belong instead of flying in. */
@media (prefers-reduced-motion: reduce) {
  .isle { --open: var(--close); --open-ms: 360ms; --close-ms: 280ms; }
  .reveal, .isle-stage.reveal, .isle-scene.reveal { translate: none; scale: none; }
  .isle-glow { transform: none; }
}