/* File: airqo_aq/css/aqi-widget.css */

/* ---------- 1. Colours for each air quality band ---------- */
/* --aqiw-tone is the band colour, --aqiw-ink is the icon colour on top of it */
.aqiw                 { --aqiw-tone: #8a857c; --aqiw-ink: #ffffff; }
.aqiw--good           { --aqiw-tone: #3a8f5c; --aqiw-ink: #ffffff; }
.aqiw--moderate       { --aqiw-tone: #e2b33c; --aqiw-ink: #3a2c05; }
.aqiw--usg            { --aqiw-tone: #e07a2e; --aqiw-ink: #ffffff; }
.aqiw--unhealthy      { --aqiw-tone: #c4453c; --aqiw-ink: #ffffff; }
.aqiw--very-unhealthy { --aqiw-tone: #7a4a99; --aqiw-ink: #ffffff; }
.aqiw--hazardous      { --aqiw-tone: #6b2432; --aqiw-ink: #ffffff; }

/* ---------- 2. The whole widget: bottom-left corner ---------- */
.aqiw {
  --aqiw-paper: #fbfaf7;
  --aqiw-line: #dcd7cd;
  --aqiw-text: #24211c;
  --aqiw-muted: #6f695f;

  position: fixed;
  left: 20px;
  bottom: 20px;
  z-index: 9999;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.4;
  color: var(--aqiw-text);
}

.aqiw *,
.aqiw *::before,
.aqiw *::after {
  box-sizing: border-box;
}

.aqiw svg {
  display: block;
}

/* ---------- 3. The square icon tile (used in the button and the card) ---------- */
.aqiw-tile {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 30px;
  height: 30px;
  border-radius: 6px;
  background: var(--aqiw-tone);
  color: var(--aqiw-ink);
}

.aqiw-tile svg {
  width: 20px;
  height: 20px;
}

.aqiw-tile--big {
  width: 48px;
  height: 48px;
  border-radius: 8px;
}

.aqiw-tile--big svg {
  width: 30px;
  height: 30px;
}

/* Icon gently fades while loading */
.aqiw--loading .aqiw-pill .aqiw-tile svg {
  animation: aqiw-pulse 1.2s ease-in-out infinite;
}

@keyframes aqiw-pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.35; }
}

@media (prefers-reduced-motion: reduce) {
  .aqiw--loading .aqiw-pill .aqiw-tile svg {
    animation: none;
  }
}

/* ---------- 4. The button ---------- */
.aqiw-pill {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  padding: 5px 14px 5px 5px;
  border: 1px solid var(--aqiw-line);
  border-radius: 9px;
  background: var(--aqiw-paper);
  color: var(--aqiw-text);
  font: inherit;
  text-align: left;
  text-transform: none;
  letter-spacing: normal;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(36, 33, 28, 0.08);
}

.aqiw-pill:hover {
  border-color: #c3bdb1;
}

.aqiw-pill:focus-visible,
.aqiw-close:focus-visible {
  outline: 2px solid #2f5fb3;
  outline-offset: 2px;
}

.aqiw-label {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.aqiw-label-main {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.aqiw-label-sub {
  font-size: 12px;
  color: var(--aqiw-muted);
}

/* ---------- 5. The card that opens above the button ---------- */
.aqiw-card {
  position: absolute;
  left: 0;
  bottom: calc(100% + 8px);
  width: 296px;
  max-width: calc(100vw - 40px);
  padding: 16px;
  background: var(--aqiw-paper);
  border: 1px solid var(--aqiw-line);
  border-radius: 10px;
  box-shadow: 0 6px 20px rgba(36, 33, 28, 0.12);
}

.aqiw-card[hidden] {
  display: none;
}

.aqiw-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}

.aqiw-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--aqiw-muted);
}

.aqiw-close {
  display: inline-flex;
  margin: -4px -4px -4px 0;
  padding: 4px;
  background: none;
  border: 0;
  border-radius: 4px;
  color: var(--aqiw-muted);
  cursor: pointer;
}

.aqiw-close:hover {
  color: var(--aqiw-text);
  background: #efece5;
}

/* The big number with its icon */
.aqiw-reading {
  display: flex;
  align-items: center;
  gap: 12px;
}

.aqiw-aqi {
  font-size: 34px;
  font-weight: 650;
  line-height: 1;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.aqiw-aqi small {
  margin-left: 4px;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0;
  color: var(--aqiw-muted);
}

.aqiw-cat {
  margin-top: 3px;
  font-size: 14px;
  font-weight: 600;
}

/* The scale under the number: six bands with a marker for this reading */
.aqiw-scale {
  position: relative;
  display: flex;
  gap: 2px;
  margin: 16px 0 4px;
}

.aqiw-scale span {
  flex: 1;
  height: 6px;
  opacity: 0.85;
}

.aqiw-scale span:first-child { border-radius: 3px 0 0 3px; }
.aqiw-scale span:last-child  { border-radius: 0 3px 3px 0; }

.aqiw-marker {
  position: absolute;
  top: -4px;
  width: 4px;
  height: 14px;
  margin-left: -2px;
  border-radius: 2px;
  background: var(--aqiw-text);
  box-shadow: 0 0 0 2px var(--aqiw-paper);
}

.aqiw-scale-ends {
  display: flex;
  justify-content: space-between;
  margin-bottom: 14px;
  font-size: 11px;
  color: var(--aqiw-muted);
}

/* Monitor, PM2.5 and time, as label / value rows */
.aqiw-details {
  margin: 0;
  padding-top: 12px;
  border-top: 1px solid #e8e4dc;
  font-size: 13px;
}

.aqiw-details div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin: 4px 0;
}

.aqiw-details dt {
  color: var(--aqiw-muted);
}

.aqiw-details dd {
  margin: 0;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.aqiw-note {
  margin: 10px 0 0;
  font-size: 12px;
  color: var(--aqiw-muted);
}

.aqiw-msg {
  margin: 0;
  font-size: 14px;
}

.aqiw-source {
  margin-top: 12px;
  font-size: 11px;
  color: var(--aqiw-muted);
}

/* ---------- 6. Small phones ---------- */
@media (max-width: 480px) {
  .aqiw {
    left: 12px;
    bottom: 12px;
  }
}
