/* 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 */
/* Robot Widget V1 — widget-specific CSS only (tokens from assets/css/tokens.css). Namespace: iq-robot. */
.iq-robot {
  position: relative;
  container: iq-robot / size;
  min-width: 0;
  min-height: 56px;
  overflow: hidden;
  border-radius: var(--radius-device);
  color: var(--text-primary);
  font-family: var(--font);
  background: linear-gradient(165deg, var(--surface-primary-top), var(--surface-primary) 55%, var(--surface-secondary));
  box-shadow: var(--shadow-primary), inset 0 0 0 1px var(--border-subtle);
  /* the device artwork's colours (the ring tells the state: accent = working, red = error, grey = docked / idle) */
  --iq-robot-shell: #26262b; --iq-robot-plate: #1b1b1f; --iq-robot-lens: #0c0c0e; --iq-robot-tyre: #0e0e10; --iq-robot-ring: var(--neutral);
}
.iq-robot[data-phase="active"], .iq-robot[data-phase="returning"] { --iq-robot-ring: var(--accent); }
.iq-robot[data-phase="error"] { --iq-robot-ring: var(--danger); }
.iq-robot[data-phase="docked"] { --iq-robot-ring: var(--success); }
.iq-robot__art { display: block; flex: none; aspect-ratio: 1 / 1; height: 40px; min-width: 0; }
.iq-robot__icon { display: none; }                       /* the drawing replaces the round glyph at every size (it stays in the DOM for assistive text parity) */
.iq-robot__art svg { width: 100%; height: 100%; display: block; overflow: visible; }
.iq-robot__body, .iq-robot__brush, .iq-robot__wheel { transform-box: fill-box; transform-origin: center; }
.iq-robot[data-kind="mower"] .iq-robot__art { aspect-ratio: 8 / 5; }
.iq-robot[data-variant="compact"] .iq-robot__art { height: 38px; }
.iq-robot[data-variant="status"] .iq-robot__art { height: 34px; }
.iq-robot[data-phase="na"] .iq-robot__art { filter: grayscale(1); opacity: var(--unavailable-opacity); }
/* big enough: the artwork replaces the round icon (the Standard variant only; Compact / Status keep the icon) */
@container iq-robot (min-height: 130px) and (min-width: 200px) { .iq-robot[data-variant="standard"] .iq-robot__art { height: 64px; } }
@container iq-robot (min-height: 170px) and (min-width: 250px) {
  .iq-robot[data-variant="standard"] .iq-robot__art { height: min(150px, 48cqh); }
  .iq-robot[data-variant="standard"] .iq-robot__main { gap: 16px; }
  .iq-robot[data-variant="standard"] .iq-robot__state { font-size: 22px; font-weight: var(--iq-fw-status); }
}
.iq-robot__in { height: 100%; box-sizing: border-box; padding: 11px 14px 10px; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.iq-robot__head { min-width: 0; }
.iq-robot__name { margin: 0; font-size: 13px; font-weight: var(--iq-fw-title); color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.iq-robot__sub { margin: 0; font-size: 11.5px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.iq-robot [hidden] { display: none !important; }
.iq-robot__main { display: flex; align-items: center; gap: 12px; min-width: 0; flex: 1 1 auto; min-height: 0; }
.iq-robot__icon { flex: none; width: 44px; height: 44px; display: none; place-items: center; border-radius: 50%; color: var(--text-secondary); box-shadow: inset 0 0 0 1px var(--border-subtle); }
.iq-robot__icon svg { width: 26px; height: 26px; }
.iq-robot[data-phase="active"] .iq-robot__icon { color: var(--accent); box-shadow: inset 0 0 0 2px var(--accent); }
.iq-robot[data-phase="returning"] .iq-robot__icon { color: var(--accent); }
.iq-robot[data-phase="error"] .iq-robot__icon { color: var(--danger, var(--warning)); box-shadow: inset 0 0 0 2px var(--danger, var(--warning)); }
.iq-robot[data-phase="na"] { opacity: .7; }
.iq-robot__st { display: flex; flex-direction: column; min-width: 0; flex: 1 1 auto; }
.iq-robot__state { font-size: 18px; font-weight: var(--iq-fw-status); line-height: 1.15; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.iq-robot__note { font-size: 11.5px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.iq-robot__note:empty { display: none; }
.iq-robot__bat { flex: none; display: flex; flex-direction: column; align-items: flex-end; gap: 3px; font-size: 12px; color: var(--text-secondary); }
.iq-robot__bar { width: 44px; height: 6px; border-radius: 3px; background: var(--border-subtle); overflow: hidden; }
.iq-robot__bar i { display: block; height: 100%; background: var(--success); border-radius: 3px; }
.iq-robot__bat[data-level="low"] .iq-robot__bar i { background: var(--warning); }
.iq-robot__pct { font-weight: var(--iq-fw-display); font-variant-numeric: tabular-nums; }
.iq-robot__ctl { display: flex; flex-wrap: nowrap; gap: 6px; overflow: hidden; min-width: 0; flex: none; }
.iq-robot__btn { flex: 0 0 auto; display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 12px; border: 0; border-radius: 17px; cursor: pointer; font: inherit; font-size: 12.5px; font-weight: var(--iq-fw-control);
  color: var(--text-primary); background: var(--surface-secondary); box-shadow: inset 0 0 0 1px var(--border-subtle); }
.iq-robot__btn:first-child { background: var(--accent); color: var(--on-accent, #fff); box-shadow: none; }
.iq-robot__btn:disabled { cursor: default; opacity: .6; }
.iq-robot__btn[data-pending="true"] { opacity: 1; outline: 2px solid var(--accent); outline-offset: -2px; }
.iq-robot__btn:focus-visible, .iq-robot__fan-sel:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.iq-robot__btn--cut { display: none; }
.iq-robot__bi { width: 18px; height: 18px; display: grid; }
.iq-robot__bi svg { width: 18px; height: 18px; }
.iq-robot--icons .iq-robot__bl { display: none; }
.iq-robot--icons .iq-robot__btn { padding: 0; width: 34px; justify-content: center; }
.iq-robot__fan { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-muted); flex: none; }
.iq-robot__fan-sel { flex: 1 1 auto; min-width: 0; height: 30px; border-radius: 8px; border: 1px solid var(--border-subtle); background: var(--surface-secondary); color: var(--text-primary); font: inherit; font-size: 12.5px; padding: 0 8px; }
.iq-robot__info { margin: 0; font-size: 11px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: none; }

/* arrangements follow the widget's OWN box (container queries on .iq-robot, not the screen) */
@container iq-robot (max-height: 150px) { .iq-robot__fan, .iq-robot__info { display: none; } .iq-robot__in { padding-top: 8px; gap: 6px; } }
@container iq-robot (max-height: 110px) { .iq-robot__head { display: none; } .iq-robot__icon { width: 36px; height: 36px; } .iq-robot__state { font-size: 15px; } }
@container iq-robot (max-height: 80px) { .iq-robot:not([data-variant="compact"]) .iq-robot__ctl { display: none; } .iq-robot__bar { display: none; } }
@container iq-robot (max-width: 200px) { .iq-robot__bar { display: none; } .iq-robot__icon { width: 36px; height: 36px; } }
@container iq-robot (max-width: 150px) { .iq-robot__icon { display: none; } .iq-robot__state { font-size: 15px; } }
/* Compact: one row — icon, state (with the name under it), battery, the one main control */
.iq-robot[data-variant="compact"] .iq-robot__in { flex-direction: row; align-items: center; gap: 10px; padding: 8px 12px; }
.iq-robot[data-variant="compact"] .iq-robot__head, .iq-robot[data-variant="compact"] .iq-robot__fan, .iq-robot[data-variant="compact"] .iq-robot__info { display: none; }
.iq-robot[data-variant="compact"] .iq-robot__main { flex: 1 1 auto; }
.iq-robot[data-variant="compact"] .iq-robot__state { font-size: 15px; }
.iq-robot[data-variant="compact"] .iq-robot__btn:not(:first-child) { display: none; }
.iq-robot[data-variant="compact"] .iq-robot__btn { padding: 0; width: 34px; justify-content: center; }
.iq-robot[data-variant="compact"] .iq-robot__bl { display: none; }
.iq-robot[data-variant="status"] .iq-robot__ctl, .iq-robot[data-variant="status"] .iq-robot__fan { display: none; }

/* fine-tune 2 — size ladder for the drawing + text: the drawing never pushes controls out, MICRO keeps silhouette + state + battery % */
@container iq-robot (min-height: 130px) and (max-height: 149px) { .iq-robot[data-variant="standard"] .iq-robot__art { height: 44px; } }
@container iq-robot (max-height: 149px) { .iq-robot__sub { display: none; } .iq-robot__in { padding: 8px 12px; gap: 4px; } }
@container iq-robot (min-height: 150px) and (max-height: 169px) { .iq-robot[data-variant="standard"] .iq-robot__art { height: 54px; } }
@container iq-robot (max-width: 150px) {
  .iq-robot__in { justify-content: center; }
  .iq-robot__ctl, .iq-robot__head { display: none; }
  .iq-robot__main { flex: 0 0 auto; display: grid; grid-template-columns: auto minmax(0, 1fr); grid-template-areas: "art bat" "st st"; row-gap: 3px; align-items: center; }
  .iq-robot__art { grid-area: art; height: 32px; }
  .iq-robot__st { grid-area: st; }
  .iq-robot__bat { grid-area: bat; justify-self: end; flex-direction: row; }
  .iq-robot__state { font-size: 14px; }
  .iq-robot__pct { font-size: 11.5px; }
}

/* ================================================================ pass 2 — STAGE composition (Standard, normal and large)
   The machine is the hero: it takes the free middle of the card on a soft floor light; state and battery sit under it, then the keys. */
.iq-robot[data-variant="standard"] .iq-robot__main::before { content: ""; position: absolute; inset: auto 8% 38% 8%; height: 40%; border-radius: 50%; background: radial-gradient(closest-side, color-mix(in srgb, var(--text-primary) 7%, transparent), transparent); pointer-events: none; display: none; }
@container iq-robot (min-height: 160px) and (min-width: 170px) and (max-aspect-ratio: 3 / 2) {
  .iq-robot[data-variant="standard"] .iq-robot__main { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-rows: minmax(0, 1fr) auto; grid-template-areas: "art art" "st bat"; align-items: end; row-gap: 6px; column-gap: 10px; }
  .iq-robot[data-variant="standard"] .iq-robot__main::before { display: block; }
  .iq-robot[data-variant="standard"] .iq-robot__art { grid-area: art; position: relative; justify-self: center; align-self: center; height: 100%; max-height: 190px; width: auto; }
  .iq-robot[data-variant="standard"] .iq-robot__art svg { filter: drop-shadow(0 10px 10px rgba(0, 0, 0, .45)); }
  .iq-robot[data-variant="standard"] .iq-robot__st { grid-area: st; }
  .iq-robot[data-variant="standard"] .iq-robot__bat { grid-area: bat; align-items: flex-end; }
  .iq-robot[data-variant="standard"] .iq-robot__state { font-size: clamp(18px, 8.5cqw, 26px); }
  .iq-robot[data-variant="standard"] .iq-robot__pct { font-size: clamp(14px, 5cqw, 20px); color: var(--text-primary); }
  .iq-robot[data-variant="standard"] .iq-robot__bar { width: 52px; }
  .iq-robot[data-variant="standard"] .iq-robot__head { text-align: left; }
}
/* wide and short: the machine at the left at the full height, text beside it */
@container iq-robot (min-aspect-ratio: 3 / 2) and (min-height: 130px) {
  .iq-robot[data-variant="standard"] .iq-robot__art { height: min(100%, 150px); }
}

/* ================================================================ conformance — controls as a row of tiles (the approved kit), battery as a bar under the state */
@container iq-robot (min-height: 160px) and (min-width: 170px) {
  .iq-robot[data-variant="standard"] .iq-robot__ctl { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 8px; overflow: visible; }
  .iq-robot[data-variant="standard"] .iq-robot__btn { height: 40px; width: auto; padding: 0 10px; border-radius: var(--radius-md); justify-content: center; background: var(--surface-tertiary); box-shadow: inset 0 0 0 1px var(--border-subtle), inset 0 1px 0 var(--edge-highlight); }
  .iq-robot[data-variant="standard"] .iq-robot__btn:first-child { background: linear-gradient(180deg, var(--accent-hot), var(--accent)); color: var(--accent-on); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .25); }
  .iq-robot[data-variant="standard"] .iq-robot__bar { height: 5px; width: 64px; }
}
