/* The enfilade gallery: six photos of a flat in a grid on a white page. Open, the photo fills the gallery's own box
   and you walk from room to room through the doors; the buttons, the name and the floor plan sit on the photo. */
:root {
  --page: #ffffff;          /* the page */
  --ink: #241e19;           /* the names under the photos */
  --muted: #8b8178;         /* the sizes */
  --frame: #efe8de;         /* behind a photo while it is drawn */
  --glass: rgba(26, 19, 14, 0.36);        /* the round buttons and the plan, over the photo */
  --glass-hover: rgba(26, 19, 14, 0.52);
  --on-photo: #fffaf3;      /* words and lines over the photo */
  --windows: #c4e2f2;       /* the windows on the floor plan */
  --sun: #ffd49a;           /* the afternoon sun through the windows */
  --evening: #f1d6b8;       /* the warm air the far rooms melt into */
}

* {
  box-sizing: border-box;
}

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;
}

.stage {
  min-height: 100svh;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  place-items: center;
  padding: 32px 16px;
}

.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.flat {
  position: relative;
  width: min(640px, 100%);
  border-radius: 18px;
}

/* while a photo is open the grid grows past the gallery's edges: they cut it */
.flat.is-touring {
  overflow: hidden;
}

/* ---------------------------------------------------------------- the grid */
.flat__grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px 12px;
  margin: 0;
  padding: 0;
  list-style: none;
  transform-origin: 0 0;
}

.flat__item {
  min-width: 0;
}

/* the square whose photo is open stays empty, ready to take it back */
.flat__item.is-away .thumb {
  visibility: hidden;
}

.thumb {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.thumb__frame {
  position: relative;
  display: block;
  aspect-ratio: 1;
  border-radius: 14px;
  overflow: hidden;
  background: var(--frame);
  transition: transform 0.25s cubic-bezier(0.23, 1, 0.32, 1), box-shadow 0.4s cubic-bezier(0.23, 1, 0.32, 1);
}

.thumb__view {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
}

/* the lens's soft dark corners, over the photo */
.thumb__frame::after,
.tour__lens {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(farthest-corner at 50% 50%, rgba(34, 22, 12, 0) 40%, rgba(34, 22, 12, 0.17));
  pointer-events: none;
}

.thumb:active .thumb__frame {
  transform: scale(0.98);
}

@media (hover: hover) {
  .thumb:hover .thumb__frame {
    box-shadow: 0 16px 30px -20px rgba(64, 38, 20, 0.6);
  }
}

.thumb__cap {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-top: 9px;
}

.thumb__name {
  min-width: 0;
  overflow: hidden;
  font-family: 'Bodoni Moda Variable', Georgia, serif;
  font-size: 17px;
  font-weight: 500;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.thumb__size {
  flex: none;
  color: var(--muted);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.thumb:focus-visible {
  outline: none;
}

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

/* the focus comes back to the photo when it closes: its ring shows only to who uses the keys */
html[data-using='pointer'] .thumb:focus-visible .thumb__frame {
  outline: none;
}

/* ---------------------------------------------------------------- the photo, open */
.tour {
  --chrome: 0;              /* how much the buttons, the name and the plan show: set by the script */
  position: absolute;
  inset: 0;
  z-index: 5;
  outline: none;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  cursor: grab;
}

.tour[hidden] {
  display: none;
}

/* the open photo has the focus: a ring inside its edge, only for the keys */
.tour::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 18px;
  box-shadow: inset 0 0 0 2px var(--on-photo);
  opacity: 0;
  pointer-events: none;
}

html[data-using='keys'] .tour:focus-visible::after {
  opacity: 1;
}

.tour.is-held {
  cursor: grabbing;
}

.tour__view,
.tour__ghost {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
}

.tour__ghost {
  opacity: 0;
  pointer-events: none;
}

.tour__lens {
  border-radius: 18px;
  opacity: var(--chrome);
}

.tour__shade {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 44%;
  border-radius: 0 0 18px 18px;
  background: linear-gradient(rgba(28, 19, 12, 0), rgba(28, 19, 12, 0.22) 45%, rgba(28, 19, 12, 0.55));
  opacity: var(--chrome);
  pointer-events: none;
}

.tour__btn {
  position: absolute;
  display: flex;
  align-items: center;
  height: 44px;
  min-width: 44px;
  padding: 0;
  border: 0;
  border-radius: 22px;
  background: var(--glass);
  -webkit-backdrop-filter: blur(10px) saturate(1.3);
  backdrop-filter: blur(10px) saturate(1.3);
  color: var(--on-photo);
  font: inherit;
  cursor: pointer;
  opacity: var(--chrome);
  pointer-events: none;
  transition: background-color 0.2s, transform 0.16s cubic-bezier(0.23, 1, 0.32, 1);
  -webkit-tap-highlight-color: transparent;
}

.tour.is-ready .tour__btn {
  pointer-events: auto;
}

.tour__btn svg {
  flex: none;
  width: 22px;
  height: 22px;
  margin: 0 11px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.tour__btn:active {
  transform: scale(0.95);
}

.tour__btn:disabled {
  visibility: hidden;
}

@media (hover: hover) {
  .tour__btn:hover {
    background: var(--glass-hover);
  }
}

.tour__btn:focus-visible {
  outline: 2px solid var(--on-photo);
  outline-offset: 2px;
}

.tour__close {
  top: 14px;
  right: 14px;
  width: 40px;
  min-width: 40px;
  height: 40px;
  border-radius: 20px;
}

.tour__close svg {
  margin: 0 9px;
}

.tour__step {
  top: calc(50% - 22px);
}

.tour__step--back {
  left: 14px;
}

.tour__step--on {
  right: 14px;
}

/* the name of the room the arrow leads to, folded away until the pointer or the keys come */
.tour__to {
  max-width: 0;
  overflow: hidden;
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  opacity: 0;
  transition: max-width 0.4s cubic-bezier(0.23, 1, 0.32, 1), padding 0.4s cubic-bezier(0.23, 1, 0.32, 1), opacity 0.2s;
}

@media (hover: hover) {
  .tour__step--on:hover .tour__to {
    max-width: 180px;
    padding-left: 16px;
    opacity: 1;
  }

  .tour__step--back:hover .tour__to {
    max-width: 180px;
    padding-right: 16px;
    opacity: 1;
  }
}

.tour__step--on:focus-visible .tour__to {
  max-width: 180px;
  padding-left: 16px;
  opacity: 1;
}

.tour__step--back:focus-visible .tour__to {
  max-width: 180px;
  padding-right: 16px;
  opacity: 1;
}

.tour__caption {
  position: absolute;
  left: 24px;
  right: 24px;
  bottom: 22px;
  color: var(--on-photo);
  opacity: var(--chrome);
  transform: translateY(calc((1 - var(--chrome)) * 10px));
  pointer-events: none;
}

.tour__name {
  margin: 0;
  font-family: 'Bodoni Moda Variable', Georgia, serif;
  font-size: 30px;
  font-weight: 500;
  line-height: 1.1;
  text-shadow: 0 1px 14px rgba(30, 18, 10, 0.35);
}

.tour__line {
  margin: 6px 0 0;
  max-width: 36ch;
  font-size: 14px;
  line-height: 1.35;
  text-shadow: 0 1px 10px rgba(30, 18, 10, 0.4);
}

.tour__name span,
.tour__line span {
  display: inline-block;
}

/* ---------------------------------------------------------------- the floor plan */
.plan {
  --plan-ratio: 5.6;        /* set by the script from the rooms */
  position: absolute;
  left: 22px;
  top: 22px;
  width: 232px;
  aspect-ratio: var(--plan-ratio);
  opacity: var(--chrome);
  pointer-events: none;
}

.tour.is-ready .plan {
  pointer-events: auto;
}

.plan::before {
  content: '';
  position: absolute;
  inset: -9px -10px;
  border-radius: 12px;
  background: var(--glass);
  -webkit-backdrop-filter: blur(10px) saturate(1.3);
  backdrop-filter: blur(10px) saturate(1.3);
}

.plan__lines {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.plan__walls {
  fill: none;
  stroke: var(--on-photo);
  stroke-width: 0.17;
  stroke-linecap: square;
}

.plan__solid {
  fill: var(--on-photo);
}

.plan__glass {
  fill: none;
  stroke: var(--windows);
  stroke-width: 0.34;
}

.plan__rail {
  fill: none;
  stroke: var(--on-photo);
  stroke-width: 0.12;
  stroke-dasharray: 0.14 0.2;
}

.plan__room {
  fill: var(--on-photo);
  opacity: 0;
  transition: opacity 0.4s;
}

.plan__room.is-here {
  opacity: 0.22;
}

.plan__cone {
  fill: var(--on-photo);
}

.plan__go {
  position: absolute;
  top: -9px;
  bottom: -9px;
  padding: 0;
  border: 0;
  border-radius: 4px;
  background: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.plan__go:focus-visible {
  outline: 2px solid var(--on-photo);
  outline-offset: -2px;
}

/* ---------------------------------------------------------------- the phone */
@media (max-width: 560px) {
  .flat__grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px 10px;
  }

  .thumb__frame {
    aspect-ratio: 11 / 10;
  }

  .thumb__name {
    font-size: 15px;
  }

  .thumb__size {
    font-size: 12px;
  }

  .tour__name {
    font-size: 25px;
  }

  .tour__line {
    font-size: 13px;
  }

  .tour__caption {
    left: 18px;
    right: 18px;
    bottom: 18px;
  }

  .plan {
    left: 18px;
    top: 20px;
    width: 176px;
  }
}
