:root {
  --carta: #f6f2ec;
  --inchiostro: #1d1b18;
  --grigio: #8a847b;
  --linea: rgba(29, 27, 24, 0.1);
  --accento: #c8553d;
  --bianco: #ffffff;
  --ombra: 0 1px 2px rgba(29, 27, 24, 0.06), 0 12px 32px -14px rgba(29, 27, 24, 0.28);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; }
body {
  background: var(--carta);
  color: var(--inchiostro);
  font-family: "Mona Sans Variable", "Mona Sans", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.stage {
  position: relative;
  width: 100%;
  height: 100vh;
  max-height: 100vh;
  overflow: hidden;
  display: grid;
  place-items: center;
}

.wrap { display: flex; flex-direction: column; gap: 12px; }

.head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.brand {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 14px;
  font-weight: 640;
  font-stretch: 104%;
  letter-spacing: -0.01em;
}
.brand__mark { width: 18px; height: 18px; fill: none; stroke: var(--accento); stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.head__note { font-size: 12px; color: var(--grigio); font-stretch: 96%; white-space: nowrap; }

/* the mosaic is laid out by the script: every cell gets its own left, top, width and height on every frame */
.mosaic { position: relative; }

.cell {
  position: absolute;
  overflow: hidden;
  border-radius: 14px;
  background: #e8e1d6;
  box-shadow: 0 1px 1px rgba(29, 27, 24, 0.05);
  will-change: left, top, width, height;
}
.cell.is-open { z-index: 5; box-shadow: var(--ombra); }

.cell__hit {
  position: absolute;
  inset: 0;
  z-index: 3;
  border: 0;
  background: transparent;
  cursor: pointer;
  border-radius: inherit;
}
.cell__hit:focus-visible { outline: 2px solid var(--accento); outline-offset: -4px; }
.is-open .cell__hit { pointer-events: none; }

/* the picture is as large as the whole mosaic (and a little more, for the drift): the cell only shows its middle,
   so widening the cell uncovers more of the room instead of stretching it */
.cell__photo { position: absolute; left: 0; top: 0; }
.cell__photo canvas { display: block; width: 100%; height: 100%; }

/* grain over the photo */
.cell::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image: var(--grana);
  background-size: 160px 160px;
  opacity: 0.16;
  mix-blend-mode: overlay;
  z-index: 2;
}

.cell__shade {
  position: absolute;
  inset: auto 0 0 0;
  height: 64%;
  background: linear-gradient(to top, rgba(20, 16, 12, 0.62), rgba(20, 16, 12, 0));
  opacity: 0.55;
  pointer-events: none;
  z-index: 1;
}

.cap {
  position: absolute;
  left: 12px;
  bottom: 11px;
  right: 12px;
  z-index: 2;
  display: flex;
  flex-direction: column;
  gap: 2px;
  color: var(--bianco);
  pointer-events: none;
}
.cap__name {
  font-size: 13px;
  font-weight: 620;
  font-stretch: 100%;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.25);
}
.cap__price {
  font-size: 11.5px;
  color: rgba(255, 255, 255, 0.86);
  font-stretch: 96%;
  white-space: nowrap;
}

.more {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 2;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
  pointer-events: none;
}
.more svg { width: 14px; height: 14px; fill: none; stroke: var(--inchiostro); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* the details card, only when the room fills the mosaic */
.detail {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 12px;
  z-index: 4;
  max-width: 330px;
  padding: 13px 14px 12px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--ombra);
  visibility: hidden;
  opacity: 0;
}
.detail__top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.detail__kind { font-size: 10.5px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--accento); font-weight: 600; }
.detail__name { font-size: 17px; font-weight: 660; letter-spacing: -0.02em; font-stretch: 102%; margin-top: 2px; line-height: 1.15; }
.detail__price { font-size: 11.5px; color: var(--grigio); white-space: nowrap; text-align: right; }
.detail__price strong { display: block; font-size: 17px; color: var(--inchiostro); font-weight: 660; letter-spacing: -0.02em; }
.detail__meta { font-size: 12px; color: #5d574f; margin-top: 7px; line-height: 1.4; }
.detail__foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 11px; }
.detail__free { font-size: 11.5px; color: #3e7a57; font-weight: 560; }
.detail__book {
  display: inline-flex;
  align-items: center;
  height: 32px;
  padding: 0 15px;
  border-radius: 999px;
  background: var(--inchiostro);
  color: var(--bianco);
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
}

.close {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 4;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.95);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.16);
  display: grid;
  place-items: center;
  cursor: pointer;
  visibility: hidden;
  opacity: 0;
}
.close svg { width: 15px; height: 15px; fill: none; stroke: var(--inchiostro); stroke-width: 1.9; stroke-linecap: round; }
.close:focus-visible { outline: 2px solid var(--accento); outline-offset: 2px; }

.pointer {
  position: absolute;
  left: 0;
  top: 0;
  width: 22px;
  height: 22px;
  z-index: 20;
  pointer-events: none;
  opacity: 0;
  fill: var(--inchiostro);
  stroke: var(--bianco);
  stroke-width: 1.3;
  stroke-linejoin: round;
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.25));
}

@media (hover: hover) {
  .close:hover { background: var(--bianco); }
}
