/* The live page's tiles: the iPhone app's home screen on a wider screen (doc/live-page.md). The
   colours are the app's (ios/NGAging/App/Theme.swift), each for light and for dark; the rest of
   the look is style.css, which every page of ours shares. */

:root {
  --s0: #2a78d6; --s1: #eb6834; --s2: #1baf7a; --s3: #eda100; --s4: #e87ba4; --s5: #008300; --s6: #6250d6; --s7: #e34948;
  --pulse: #1a56c4; --good: #3f7d4e; --caution: #b98200; --unfilled: #d8cec4;
  --temperature: #e6ac00; --humidity: #1a56c4; --plan-bad: #d70015;
}
:root[data-theme="dark"] {
  --s0: #3987e5; --s1: #d95926; --s2: #199e70; --s3: #c98500; --s4: #d55181; --s5: #008300; --s6: #9085e9; --s7: #e66767;
  --pulse: #6fa8ff; --good: #8fcb9b; --caution: #f2c94c; --unfilled: #5a4e44;
  --temperature: #f7c531; --humidity: #4a8fea; --plan-bad: #ff453a;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --s0: #3987e5; --s1: #d95926; --s2: #199e70; --s3: #c98500; --s4: #d55181; --s5: #008300; --s6: #9085e9; --s7: #e66767;
    --pulse: #6fa8ff; --good: #8fcb9b; --caution: #f2c94c; --unfilled: #5a4e44;
    --temperature: #f7c531; --humidity: #4a8fea; --plan-bad: #ff453a;
  }
}

/* As wide as the window: the tiles side by side where there is room, one under another where not. */
main { max-width: none; }
#tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 34rem), 1fr)); gap: 1rem; align-items: start; }

.tile { background: var(--card); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); padding: 0.9rem 1rem 1rem; min-width: 0; }
.tile.folded { padding-bottom: 0.9rem; }
.tile-head { display: flex; align-items: center; gap: 0.5rem; }
.tile-head h2 { flex: 1; margin: 0; font: 600 0.82rem/1.3 "Avenir Next", "Segoe UI", system-ui, sans-serif; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.tile-moves { display: inline-flex; gap: 0.25rem; }
.tile-moves button { width: 1.9rem; height: 1.9rem; padding: 0; border-radius: 50%; color: var(--muted); }
.tile-moves button.fold { color: var(--accent); }
button.small { font-size: 0.85rem; padding: 0.15rem 0.7rem; }
.tile h3.day { margin: 0; font: 600 1.15rem/1.3 "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif; display: inline-flex; align-items: center; gap: 0.5rem; }
.muted { color: var(--muted); }

/* the icons are the app's own, drawn in the colour of the text they stand in */
.icon { display: inline-block; flex: none; background: currentColor; -webkit-mask: var(--icon) center / contain no-repeat; mask: var(--icon) center / contain no-repeat; }
.icon.small { width: 1.25rem; height: 1.25rem; }
.icon.big { width: 2.9rem; height: 2.9rem; }
.spinner { width: 0.9rem; height: 0.9rem; border-radius: 50%; border: 2px solid var(--pulse); border-right-color: transparent; animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Latest Activity */
.latest { display: flex; align-items: center; gap: 1rem; margin-top: 0.7rem; }
.latest .disc { flex: none; display: grid; place-items: center; width: 4.5rem; height: 4.5rem; border-radius: 50%; color: var(--accent); background: color-mix(in srgb, var(--accent) 16%, transparent); font-size: 1.8rem; }
.latest.none .disc { color: var(--muted); background: color-mix(in srgb, var(--muted) 16%, transparent); }
.latest p { margin: 0; }
.latest .ago { font: 600 1.75rem/1.2 "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif; }

/* Home Activity */
.plan-note { margin: 0.4rem 0 0; color: var(--plan-bad); font-weight: 700; font-size: 0.92rem; }
.replay-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin: 0.6rem 0 0.2rem; }
.readings { text-align: right; font-variant-numeric: tabular-nums; font-size: 0.92rem; }
.readings p { margin: 0; }
.readings .shown { color: var(--pulse); font-weight: 600; }
svg.fp { display: block; width: 100%; height: auto; max-height: 34rem; }
svg.fp line, svg.fp path { vector-effect: non-scaling-stroke; }
.fp-room { fill: var(--bg); }
.fp-shade { fill: var(--pulse); }
.fp-wall { fill: none; stroke: var(--fg); stroke-width: 3; stroke-linecap: square; }
.fp-name { fill: var(--fg); font-family: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif; font-weight: 600; }
.fp-size { fill: var(--muted); font-variant-numeric: tabular-nums; }
.fp-icon { opacity: 0.45; }
/* a room with a device still to place, as the app's: its floor hatched and drifting, its walls in
   dashes running round, a pixel thicker, and its name and size on black whatever the look */
.fp-hatch { animation: fp-drift 6s linear infinite; }
.fp-hatch path { fill: none; stroke: var(--accent); stroke-opacity: 0.4; stroke-width: 1; }
@keyframes fp-drift { to { transform: translate(var(--drift), var(--drift)); } }
.fp-wall.unplaced { stroke: var(--accent); stroke-opacity: 0.25; stroke-width: 4; }
svg.fp path.fp-dash { fill: none; stroke: var(--accent); stroke-dasharray: 0.5 0.5; stroke-linecap: butt; vector-effect: none; animation: fp-run 2s linear infinite; }
@keyframes fp-run { to { stroke-dashoffset: -1; } }
@media (prefers-reduced-motion: reduce) { .fp-hatch, svg.fp path.fp-dash { animation: none; } }
.fp-ground { fill: #000; }
.fp-name.on-black { fill: #fff; }
.fp-size.on-black { fill: rgba(255, 255, 255, 0.75); }
.fp-icon.on-black, :root[data-theme="dark"] .fp-icon.on-black { filter: invert(1); opacity: 0.75; }
:root[data-theme="dark"] .fp-icon { filter: invert(1); opacity: 0.6; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .fp-icon { filter: invert(1); opacity: 0.6; } }
.fp-gap { stroke: var(--bg); stroke-width: 5; }
.fp-jamb { stroke: var(--fg); stroke-width: 2; }
.fp-door.outside .fp-jamb { stroke: var(--accent); }
.fp-swing { fill: none; stroke: var(--accent); stroke-width: 1.2; stroke-dasharray: 3 3; opacity: 0.8; }
.fp-overhead { stroke: var(--accent); stroke-width: 2.5; }
.fp-pane { fill: var(--bg); stroke: var(--fg); stroke-width: 1; }
.fp-glass { stroke: var(--fg); stroke-width: 1; }
.fp-walk { fill: none; stroke: var(--good); stroke-width: 5; stroke-linecap: round; stroke-linejoin: round; }
.fp-seen { fill: var(--good); stroke: var(--card); stroke-width: 1.5; vector-effect: non-scaling-stroke; }
.fp-device circle, .fp-device rect { fill: var(--c); stroke: #fff; stroke-width: 2; vector-effect: non-scaling-stroke; }
.fp-device image { filter: invert(1); pointer-events: none; }

.replay-controls, .hours-head { display: flex; align-items: center; gap: 0.5rem; margin-top: 0.5rem; }
.hours-head { justify-content: space-between; margin: 0.6rem 0 0.5rem; }
button.day-step { width: 2.2rem; height: 2.2rem; padding: 0; border-radius: 50%; font-size: 1.3rem; line-height: 1; color: var(--pulse); }
svg.scrub { flex: 1; min-width: 0; height: 2.5rem; cursor: pointer; }
/* a press and a drag moves the time, and selects nothing on the way */
svg.scrub, svg.day-chart, svg.hour-grid { touch-action: none; user-select: none; -webkit-user-select: none; }
.scrub line { vector-effect: non-scaling-stroke; stroke-linecap: round; }
.scrub-done { stroke: var(--line); stroke-width: 4; }
.scrub-later { stroke: var(--line); stroke-width: 1.5; stroke-dasharray: 2 3; }
.scrub-tick { stroke: var(--muted); stroke-width: 1; opacity: 0.6; }
.scrub-played { stroke: var(--pulse); stroke-width: 4; }
.scrub-thumb { fill: var(--pulse); stroke: var(--card); stroke-width: 2; vector-effect: non-scaling-stroke; }

button.play { min-width: 3rem; padding: 0.25rem 0.6rem; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--pulse); background: color-mix(in srgb, var(--pulse) 12%, transparent); border-color: transparent; }
button.play.playing { color: var(--card); background: var(--pulse); }
.shuttle-row { display: flex; justify-content: center; margin-top: 0.3rem; }
svg.shuttle { max-width: 100%; height: auto; cursor: grab; touch-action: none; user-select: none; -webkit-user-select: none; }
svg.shuttle.held { cursor: grabbing; }
.shuttle-track { fill: color-mix(in srgb, var(--line) 35%, transparent); }
.shuttle-end { fill: var(--muted); font-size: 9px; letter-spacing: -2px; }
.shuttle-middle { stroke: var(--muted); opacity: 0.5; }
.shuttle-knob { fill: var(--muted); filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.25)); }
.held .shuttle-knob { fill: var(--pulse); }

/* the day's chart */
.scale { display: flex; align-items: center; justify-content: center; gap: 0.7rem; margin-top: 0.4rem; font-variant-numeric: tabular-nums; }
.scale .spacer { width: 3.3rem; }
.detail { min-height: 2.6rem; margin: 0.4rem 0 0; font-size: 0.88rem; }
.scale-titles { display: flex; justify-content: space-between; font-size: 0.75rem; color: var(--muted); }
svg.day-chart { display: block; max-width: 100%; height: auto; cursor: pointer; margin-top: 0.2rem; }
.day-chart .grid { stroke: var(--line); stroke-dasharray: 2 3; }
.day-chart .axis { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.day-chart .base, .day-chart .midnight { stroke: var(--line); }
.day-chart .now-bar { fill: color-mix(in srgb, var(--pulse) 16%, transparent); stroke: color-mix(in srgb, var(--pulse) 60%, transparent); }
.day-chart .bar { fill: var(--c); }
.day-chart .line-under { fill: none; stroke: #000; stroke-width: 6; stroke-linecap: round; stroke-linejoin: round; }
.day-chart circle.line-under { fill: #000; stroke: none; }
.day-chart .line { fill: none; stroke: var(--c); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.day-chart .line-dot { fill: var(--c); }
.dash1 { stroke-dasharray: 6 4; } .dash2 { stroke-dasharray: 2 3; }
.key { display: flex; flex-wrap: wrap; gap: 0.3rem 1.2rem; margin-top: 0.4rem; font-size: 0.8rem; font-variant-numeric: tabular-nums; }
.key .swatch { display: inline-block; width: 1.1rem; height: 0; border-top: 3px solid var(--c); margin-right: 0.35rem; vertical-align: middle; }
.key .swatch.dash1, .key .swatch.dash2 { border-top-style: dashed; }

/* the event table */
.marked { font-size: 0.8rem; margin: 0.6rem 0 0.4rem; }
.stripe { display: inline-block; width: 3px; height: 12px; border-radius: 2px; background: var(--pulse); vertical-align: middle; }
.event-table { max-height: 26rem; overflow: auto; border-radius: 12px; }
.event-table table { box-shadow: none; }
.event-table td.when { white-space: nowrap; font-variant-numeric: tabular-nums; }
.event-table tr.marked td:first-child { box-shadow: inset 3px 0 0 var(--pulse); }
.event-table tr.current td { background: color-mix(in srgb, var(--pulse) 14%, transparent); }
.dot { display: inline-block; width: 0.6rem; height: 0.6rem; border-radius: 50%; background: var(--c); }

/* Movement by Hour */
svg.hour-grid { display: block; max-width: 100%; height: auto; cursor: pointer; }
.hour-grid .label { fill: var(--fg); font-size: 12px; }
.hour-grid .cell { fill: var(--c); }
.hour-grid .cell.empty { fill: var(--line); opacity: 0.55; }
.hour-grid .hour-mark { fill: none; stroke: var(--pulse); stroke-width: 1.5; }
.hour-grid .axis { fill: var(--muted); font-size: 11px; }
.legend { display: flex; align-items: center; gap: 0.3rem; margin-top: 0.4rem; font-size: 0.75rem; color: var(--muted); }
.legend .grow { flex: 1; }
.legend .swatch { display: inline-block; width: 0.65rem; height: 0.65rem; border-radius: 2px; background: var(--fg); }
.legend .s1 { opacity: 0.36; } .legend .s2 { opacity: 0.52; } .legend .s3 { opacity: 0.68; } .legend .s4 { opacity: 0.84; } .legend .s5 { opacity: 1; }

/* Rooms */
ul.rooms { list-style: none; margin: 0.4rem 0 0; padding: 0; }
ul.rooms li { display: flex; align-items: center; gap: 0.5rem; padding: 0.55rem 0.1rem; border-bottom: 1px solid var(--line); cursor: pointer; user-select: none; }
ul.rooms li:last-child { border-bottom: 0; }
ul.rooms li:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; border-radius: 6px; }
ul.rooms li.off { color: var(--muted); }
.tick { flex: none; display: grid; place-items: center; width: 1.25rem; height: 1.25rem; border-radius: 4px; border: 2px solid var(--c); background: var(--c); color: #fff; font-size: 0.8rem; font-weight: 700; }
li.off .tick { background: transparent; opacity: 0.5; }
.icon-space { width: 1.25rem; flex: none; }
.chip, .chip-space { flex: none; display: grid; place-items: center; width: 1.75rem; height: 1.75rem; border-radius: 50%; }
.chip { background: var(--c); border: 2px solid #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25); }
.chip img { width: 1rem; height: 1rem; filter: invert(1); }
.names { flex: 1; min-width: 0; display: grid; overflow-wrap: anywhere; }
.names small { font-size: 0.78rem; }
.condition { display: inline-flex; gap: 0.6rem; font-size: 0.8rem; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.battery, .signal { display: inline-flex; align-items: center; gap: 0.2rem; }
.cell-shape { position: relative; display: inline-block; width: 1.3rem; height: 0.65rem; border: 1.5px solid currentColor; border-radius: 3px; }
.cell-shape b { position: absolute; inset: 1px auto 1px 1px; width: calc(var(--fill) - 2px); border-radius: 1px; background: currentColor; }
.battery.good .cell-shape { color: var(--good); } .battery.low .cell-shape { color: var(--caution); } .battery.critical .cell-shape { color: var(--bad); }
svg.arcs { width: 1.25rem; height: 0.95rem; }
.arcs path { fill: none; stroke-width: 2; stroke-linecap: round; }
.arcs .unlit { stroke: var(--unfilled); }
.arcs.good .lit { stroke: var(--good); fill: none; } .arcs.low .lit { stroke: var(--caution); } .arcs.critical .lit { stroke: var(--bad); }
.arcs circle.lit { stroke: none; } .arcs.good circle.lit { fill: var(--good); } .arcs.low circle.lit { fill: var(--caution); } .arcs.critical circle.lit { fill: var(--bad); }
.rooms .ago { flex: none; width: 2.4rem; text-align: right; font-size: 0.85rem; font-variant-numeric: tabular-nums; }

/* Orders on Their Way: above the tiles, there only while something is coming. */
#orders { margin-bottom: 1rem; }
#orders:empty { display: none; }
.order { padding: 0.7rem 0 0; margin-top: 0.7rem; border-top: 1px solid var(--line); }
.tile-head + .order { border-top: 0; margin-top: 0.2rem; }
.order-head { display: flex; align-items: baseline; gap: 0.75rem; }
.order-head strong { flex: 1; }
.order-number { font-variant-numeric: tabular-nums; font-size: 0.85rem; }
.order-standing { margin-top: 0.15rem; }
.order-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem; margin-top: 0.6rem; }
.order-track { font-weight: 600; }
.order .small { font-size: 0.85rem; }
