/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 * Copyright © 2026 Marcel Rymenhout and IniqDash contributors */
.iq-dev { container: iq-dev / size; position: relative; isolation: isolate; overflow: hidden; height: 100%; box-sizing: border-box; padding: 14px 16px 16px;
  display: flex; flex-direction: column; justify-content: space-between; border-radius: var(--radius-device, 22px); color: var(--text-primary); background: var(--surface-tertiary, #2a2c34); transition: background .25s; }
.iq-dev[data-on="true"] { background: linear-gradient(150deg, var(--dev-a), var(--dev-b)); color: #ffffff; box-shadow: 0 10px 30px color-mix(in srgb, var(--dev-b) 35%, transparent); }
.iq-dev__pic { position: absolute; right: -8%; bottom: -6%; width: 70%; height: 70%; z-index: -1; background: center / contain no-repeat; opacity: .28; filter: grayscale(.4); }
.iq-dev[data-on="true"] .iq-dev__pic { opacity: .5; filter: none; mix-blend-mode: multiply; }
.iq-dev__top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.iq-dev__word { font-size: 11px; font-weight: 600; letter-spacing: .06em; color: var(--text-muted); }
.iq-dev[data-on="true"] .iq-dev__word { color: rgba(255, 255, 255, .85); }
.iq-dev__sw { all: unset; box-sizing: border-box; position: relative; width: 40px; height: 22px; border-radius: 11px; cursor: pointer; flex: none; background: rgba(255, 255, 255, .12); transition: background .2s; }
.iq-dev__knob { position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #5b5e69; transition: left .2s, background .2s; }
.iq-dev[data-on="true"] .iq-dev__sw { background: rgba(255, 255, 255, .55); }
.iq-dev[data-on="true"] .iq-dev__knob { left: 21px; background: #ffffff; }
.iq-dev__sw:focus-visible { outline: 2px solid #ffffff; outline-offset: 2px; }
.iq-dev__sw:disabled { cursor: not-allowed; opacity: .5; }
.iq-dev__body { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 2px; }
.iq-dev__ic { display: grid; place-items: center; width: 38px; height: 38px; margin-bottom: 4px; border-radius: 50%; color: var(--accent); background: rgba(255, 255, 255, .06); }
.iq-dev__ic svg { width: 22px; height: 22px; }
.iq-dev[data-on="true"] .iq-dev__ic { color: #ffffff; background: rgba(255, 255, 255, .22); }
.iq-dev__name { font-size: 15px; font-weight: 700; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.iq-dev__since { font-size: 11.5px; color: var(--text-muted); }
.iq-dev[data-on="true"] .iq-dev__since { color: rgba(255, 255, 255, .8); }
@container iq-dev (max-height: 130px) { .iq-dev__ic { display: none; } }
@media (prefers-reduced-motion: reduce) { .iq-dev, .iq-dev__knob, .iq-dev__sw { transition: none; } }

/* ================================================================ ROW (variant 'row') — an icon tile in the tone of the state, its words,
   then its switch (or a lock). A sensor: state · name · since. A switch: name · "Off · read-only". */
.iq-devr { --sc: #3ce06a; position: relative; box-sizing: border-box; height: 100%; min-width: 0; display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 12px;
  padding: 12px 14px; color: #fff; font-family: var(--mai-font, var(--font)); border-radius: 18px; border: 1px solid rgba(255, 255, 255, .06);
  background: linear-gradient(180deg, #22252e 0%, #1f222a 100%); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .04), 0 6px 16px rgba(0, 0, 0, .25); transition: background .3s, border-color .3s; }
.iq-devr[data-kind="sensor"] { grid-template-columns: auto minmax(0, 1fr); padding: 13px 14px; }
.iq-devr[data-kind="sensor"][data-tone="on"] { --sc: #ffb347; }
.iq-devr[data-kind="sensor"][data-tone="alert"] { --sc: #ff5a5a; }
.iq-devr[data-tone="na"] { --sc: #5c616e; }
.iq-devr[data-kind="switch"] { --sc: #8b909c; }
.iq-devr[data-kind="switch"][data-tone="on"] { --sc: #ff9d3f; }
.iq-devr__ic { width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center; font-size: 20px; color: var(--sc); background: color-mix(in srgb, var(--sc) 12%, #1a1c23); flex: none; }
.iq-devr__ic .bi { font-size: inherit; line-height: 1; }
.iq-devr[data-kind="sensor"]:is([data-tone="on"], [data-tone="alert"]) .iq-devr__ic { box-shadow: 0 0 16px color-mix(in srgb, var(--sc) 35%, transparent); }
.iq-devr[data-kind="switch"] .iq-devr__ic { font-size: 21px; background: color-mix(in srgb, var(--sc) 15%, #1a1c23); border: 1px solid color-mix(in srgb, var(--sc) 30%, transparent); box-sizing: border-box; }
.iq-devr[data-kind="switch"][data-tone="on"] .iq-devr__ic { box-shadow: 0 0 18px rgba(255, 138, 43, .25); }
.iq-devr__t { min-width: 0; }
.iq-devr__t b, .iq-devr__t small, .iq-devr__t span { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.iq-devr[data-kind="sensor"] .iq-devr__t b { font-size: 13.5px; font-weight: 600; line-height: 18px; }
.iq-devr[data-kind="sensor"][data-tone="na"] .iq-devr__t b { color: #f38b8b; }
.iq-devr[data-kind="sensor"] .iq-devr__t small { font-size: 10px; line-height: 14px; color: #c9ccd4; }
.iq-devr[data-kind="sensor"] .iq-devr__t span { font-size: 8.5px; line-height: 11px; color: #8b909c; }
.iq-devr[data-kind="switch"] .iq-devr__t b { font-size: 12.5px; font-weight: 600; line-height: 1.25; }
.iq-devr[data-kind="switch"] .iq-devr__t small { font-size: 9.5px; line-height: 13px; color: #8b909c; margin-top: 1.5px; }
.iq-devr__ro { color: #858a97; font-size: 14px; padding: 0 4px; }
.iq-devr__sw { position: relative; width: 46px; height: 26px; padding: 0; border: 0; border-radius: 99px; background: #3a3d48; cursor: pointer; transition: background .2s; flex: none; }
.iq-devr__sw::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: transform .2s; box-shadow: 0 1px 3px rgba(0, 0, 0, .35); }
.iq-devr__sw[aria-checked="true"] { background: linear-gradient(160deg, #ffa244 0%, #ff8a2b 50%, #f5751f 100%); }
.iq-devr__sw[aria-checked="true"]::after { transform: translateX(20px); }
.iq-devr__sw:disabled { opacity: .45; cursor: not-allowed; }

/* ================================================================ ORB (variant 'orb') — a ring that fills with how long the device has been on */
.iq-orb { box-sizing: border-box; height: 100%; display: flex; flex-wrap: wrap; align-items: center; align-content: center; gap: 10px; padding: 10px; border-radius: 12px; border: 1px solid rgba(120, 200, 255, .12); background: rgba(255, 255, 255, .02);
  color: #eef2fa; font-family: var(--mai-font, var(--font)); --orb-c: #ffd23f; }
.iq-orb[data-on="true"] { border-color: color-mix(in srgb, var(--orb-c) 45%, transparent); background: color-mix(in srgb, var(--orb-c) 7%, transparent); }
.iq-orb__r { position: relative; width: 48px; height: 48px; flex: none; padding: 0; border: 0; border-radius: 50%; cursor: pointer; display: grid; place-items: center;
  background: conic-gradient(var(--orb-c) var(--orb-p, 0%), rgba(255, 255, 255, .07) 0); }
.iq-orb__r::before { content: ""; position: absolute; inset: 4px; border-radius: 50%; background: #10141f; }
.iq-orb__r:disabled { cursor: not-allowed; opacity: .55; }
.iq-orb__ic { position: relative; display: grid; place-items: center; color: #5f6679; }
.iq-orb__ic svg { width: 18px; height: 18px; }
.iq-orb__ic .bi { font-size: 17px; line-height: 1; }
.iq-orb[data-on="true"] .iq-orb__r { box-shadow: 0 0 18px -4px var(--orb-c); }
.iq-orb[data-on="true"] .iq-orb__ic { color: var(--orb-c); filter: drop-shadow(0 0 6px var(--orb-c)); }
.iq-orb__tx { flex: 1 1 72px; min-width: 0; display: flex; flex-direction: column; }  /* too narrow beside the ring: the name goes under it */
.iq-orb__tx b { font-weight: 700; font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.iq-orb__tx small { color: #5f6679; font-size: 9.5px; font-weight: 600; white-space: nowrap; }
.iq-orb[data-on="true"] .iq-orb__tx small { color: var(--orb-c); }
