/* The room chart: the energy card of a home with solar panels, on a black page. A dark card, the house cut open
   in the middle: grey walls, a roof with its panels, and every room in the colour of its use; the light is warm. */
:root {
  --page: #000000;          /* the page */
  --card: #121317;          /* the card */
  --edge: #24262d;          /* the card's edge */
  --ink: #f3f2ef;           /* the figures and the chosen month */
  --muted: #92949c;         /* the labels */
  --track: #1c1d22;         /* the months' track */
  --thumb: #2c2e35;         /* the chosen month's pill */
  --wall: #2a2c33;          /* the walls, the floor and the ceiling */
  --roof: #23252c;          /* the roof */
  --panel: #1f2f4c;         /* the solar panels */
  --panel-hi: #34507f;      /* the panels where they catch the sky */
  --snow: #e9edf3;          /* the snow on the roof in January */
  --light: #ffe2ad;         /* the light of a lamp */
  --car: #3987e5;           /* the car, in the garage */
  --heat: #d95926;          /* the heat pump */
  --water: #199e70;         /* the hot water, in the bathroom */
  --kitchen: #c98500;       /* the kitchen */
  --devices: #d55181;       /* the devices, in the study */
}

* {
  box-sizing: border-box;
}

/* quick taps never become a double tap that zooms the page */
html {
  touch-action: manipulation;
}

html,
body {
  margin: 0;
}

body {
  min-height: 100svh;
  background: var(--page);
  color: var(--ink);
  font-family: 'Albert Sans Variable', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.sr {
  position: absolute;
  /* in alto nella scheda: la tabella per i lettori di schermo, alta quanto le sue righe, non allunga la pagina */
  top: 0;
  left: 0;
  width: 1px;
  height: 1px;
  margin: 0;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.stage {
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: 32px 16px;
}

/* ---------------------------------------------------------------- the card */
.home {
  position: relative;
  width: min(440px, 100%);
  padding: 20px 20px 12px;
  border: 1px solid var(--edge);
  border-radius: 28px;
  background: var(--card);
}

.home__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.home__title {
  margin: 0;
  font-size: 15px;
  font-weight: 620;
  letter-spacing: -0.005em;
}

/* the month's total, or the use that is lit */
.home__figure {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin: 12px 0 0;
  line-height: 1;
}

.home__value {
  font-size: 44px;
  font-weight: 720;
  letter-spacing: -0.035em;
  font-variant-numeric: tabular-nums;
}

.home__unit {
  font-size: 17px;
  font-weight: 620;
  color: var(--muted);
}

.home__note {
  height: 20px;
  margin: 6px 0 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  line-height: 20px;
  white-space: nowrap;
  text-overflow: ellipsis;
}

/* ---------------------------------------------------------------- the months */
.months {
  position: relative;
  display: flex;
  flex: none;
  padding: 4px;
  border-radius: 999px;
  background: var(--track);
}

.months__thumb {
  position: absolute;
  top: 4px;
  bottom: 4px;
  left: 0;
  width: 0;
  border-radius: 999px;
  background: var(--thumb);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.months__btn {
  position: relative;
  height: 36px;
  min-width: 48px;
  padding: 0 12px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  font-weight: 640;
  cursor: pointer;
  transition: color 0.25s ease, transform 0.15s ease-out;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.months__btn[aria-selected='true'] {
  color: var(--ink);
}

@media (hover: hover) and (pointer: fine) {
  .months__btn[aria-selected='false']:hover {
    color: color-mix(in srgb, var(--muted), var(--ink) 50%);
  }
}

.months__btn:active {
  transform: scale(0.96);
}

.months__btn:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 1px;
}

/* ---------------------------------------------------------------- the house */
.house {
  position: relative;
  margin-top: 12px;
  touch-action: pan-y;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
}

.house__svg {
  display: block;
  width: 100%;
  height: 164px;
  overflow: visible;
}

/* ---------------------------------------------------------------- the key: a cell for every room, in the house's order */
.key {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 2px;
  margin-top: 8px;
}

.key__item {
  position: relative;
  display: grid;
  justify-items: center;
  gap: 2px;
  min-width: 0;
  min-height: 60px;
  padding: 6px 2px 4px;
  border: 0;
  border-radius: 14px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  text-align: center;
  cursor: pointer;
  transition: background-color 0.2s ease, color 0.2s ease, transform 0.15s ease-out;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.key__icon {
  display: block;
  width: 20px;
  height: 20px;
  fill: none;
  stroke: var(--c);
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.key__name {
  max-width: 100%;
  overflow: hidden;
  font-size: 12px;
  font-weight: 560;
  line-height: 16px;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.key__value {
  color: var(--ink);
  font-size: 15px;
  font-weight: 680;
  line-height: 18px;
  font-variant-numeric: tabular-nums;
}

/* while a room is lit, the other cells step back: their objects fade and their figures turn grey, the words stay
   readable */
.key__icon,
.key__value {
  transition: opacity 0.25s ease, color 0.25s ease;
}

.key.is-lit .key__item .key__icon {
  opacity: 0.32;
}

.key.is-lit .key__item .key__value {
  color: var(--muted);
}

.key.is-lit .key__item.is-on {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.06);
}

.key.is-lit .key__item.is-on .key__icon {
  opacity: 1;
}

.key.is-lit .key__item.is-on .key__value {
  color: var(--ink);
}

@media (hover: hover) and (pointer: fine) {
  .key__item:hover {
    background: rgba(255, 255, 255, 0.05);
  }
}

.key__item:active {
  transform: scale(0.97);
}

.key__item:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: -2px;
}

@media (max-width: 420px) {
  .key {
    gap: 0;
  }

  .key__item {
    padding-right: 0;
    padding-left: 0;
  }

  .key__name {
    font-size: 11.5px;
    letter-spacing: -0.015em;
  }
}

@media (max-width: 380px) {
  .home {
    padding: 18px 16px 10px;
  }

  .months__btn {
    min-width: 44px;
    padding: 0 10px;
  }

  .home__value {
    font-size: 40px;
  }
}

/* una casella bassa (l'anteprima sul telefono, 341 per 410): meno margini e una cifra un po' più piccola, la casa
   resta alta uguale e la scheda sta in altezza senza rimpicciolirsi */
@media (max-height: 520px) {
  .stage {
    padding: 6px 16px;
  }

  .home__figure {
    margin-top: 8px;
  }

  .home__value {
    font-size: 36px;
  }

  .house {
    margin-top: 8px;
  }
}
