/* The homepage room band in two steps. Loaded after
   home.css, whose chips, swatches, total and back button it reuses. */

/* ---------- step one: the choices ---------- */

.choose,
.quote {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.choose {
  gap: 8px;
}

.choose[hidden],
.quote[hidden] {
  display: none;
}

/* One card per piece: what it is and what it's wearing, then its choices. */
.pick {
  pointer-events: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 6px 6px 14px;
  border-radius: var(--radius-card);
  background: var(--card);
  box-shadow:
    0 1px 2px rgb(0 0 0 / 0.06),
    0 6px 16px -8px rgb(0 0 0 / 0.18);
}

/* The card whose piece the room is showing. */
.pick[data-open] {
  box-shadow:
    0 0 0 2px var(--ink),
    0 6px 16px -8px rgb(0 0 0 / 0.18);
}

.pick[data-open] .pick-open {
  stroke: var(--ink);
  rotate: 90deg;
}

/* The heading shows the piece in the room. */
.pick-head {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) auto;
  grid-template-areas:
    "thumb name open"
    "thumb sub open";
  align-items: center;
  column-gap: 12px;
  row-gap: 1px;
  width: 100%;
  padding: 0 8px 0 0;
  border: 0;
  border-radius: 12px;
  background: transparent;
  font: inherit;
  text-align: left;
  color: var(--ink);
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.pick-head:hover {
  background: var(--room);
}

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

.pick-open {
  grid-area: open;
  width: 18px;
  height: 18px;
  fill: none;
  stroke: var(--ink-faint);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition:
    stroke 0.15s ease,
    translate 0.2s var(--ease-out);
}

.pick-head:hover .pick-open {
  stroke: var(--ink);
  translate: 2px 0;
}

.pick-choices {
  padding-inline: 10px;
}

.pick-choices[aria-busy="true"] [aria-pressed="true"] img {
  animation: pulse 1s ease-in-out infinite;
}

.swap-choice:active {
  scale: 0.94;
}

.see-quote {
  pointer-events: auto;
  align-self: stretch;
  height: 52px;
  margin-top: 12px;
  transition: scale 0.1s ease;
}

.see-quote:active {
  scale: 0.98;
}

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

/* ---------- step two: the quote ---------- */

/* The way back sits over the room, where a piece's does. */
.band[data-spot] .room-back,
.band[data-step="quote"] .room-back {
  visibility: visible;
  opacity: 1;
  transition: opacity 0.2s ease;
}

/* Each line takes its pin's number, on the thumbnail's corner. */
.line-no {
  grid-area: thumb;
  align-self: start;
  justify-self: start;
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  translate: -6px -6px;
  border-radius: 50%;
  background: var(--ink);
  box-shadow: 0 0 0 2px var(--card);
  font-size: 0.72rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  color: #fff;
  pointer-events: none;
}

.piece[aria-pressed="true"] .line-no {
  background: #fff;
  box-shadow: 0 0 0 2px var(--ink);
  color: var(--ink);
}

.piece.is-lit {
  translate: 0 -1px;
  box-shadow:
    0 0 0 2px var(--ink),
    0 6px 16px -8px rgb(0 0 0 / 0.18);
}

@media (prefers-reduced-motion: no-preference) {
  .choose {
    animation: step-in 0.3s var(--ease-out);
  }

  /* The lines come in one after another as the drawing wipes across, then
     the total. */
  .quote .pieces li,
  .quote .band-total {
    animation: step-in 0.4s var(--ease-out) backwards;
    animation-delay: calc(120ms + var(--n, 4) * 70ms);
  }

  .quote .pieces li:nth-child(1) {
    --n: 0;
  }

  .quote .pieces li:nth-child(2) {
    --n: 1;
  }

  .quote .pieces li:nth-child(3) {
    --n: 2;
  }

  .quote .pieces li:nth-child(4) {
    --n: 3;
  }
}

@keyframes step-in {
  from {
    opacity: 0;
    translate: 0 8px;
  }
}

/* ---------- under the room ---------- */

@media (max-width: 1180px) {
  /* The column is one block under the room: the two choices side by side,
     and the quote's lines two to a row. Nothing scrolls sideways. */
  .band-side {
    display: block;
  }

  .choose {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
  }

  .see-quote {
    grid-column: 1 / -1;
    justify-self: center;
    width: min(100%, 360px);
    margin-top: 8px;
  }

  .pieces {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin-inline: 0;
    padding: 0;
    overflow: visible;
  }

  .piece {
    min-width: 0;
  }
}

@media (max-width: 720px) {
  .choose,
  .pieces {
    grid-template-columns: minmax(0, 1fr);
  }

  .choose {
    gap: 8px;
  }

  .see-quote {
    width: 100%;
    margin-top: 12px;
  }
}

/* The narrowest phones: five chairs still fit one row. */
@media (max-width: 360px) {
  .pick-choices {
    gap: 6px;
  }
}

/* ---------- a menu over the piece ---------- */

/* The picked piece's choices, hung over it in the room: a small card with a
   nub pointing down at the piece. choose-quote.js sets --x and --y (the
   point over the piece, in the room's box) and --nub (how far the nub sits
   from the card's centre when the card is held inside the room). */
.room-menu {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 2;
  padding: 10px;
  border-radius: 18px;
  background: var(--card);
  box-shadow:
    0 1px 2px rgb(0 0 0 / 0.08),
    0 10px 24px -10px rgb(0 0 0 / 0.28);
  translate: calc(var(--x, 0px) - 50%) calc(var(--y, 0px) - 100% - 14px);
}

.room-menu::after {
  content: "";
  position: absolute;
  bottom: -6px;
  left: calc(50% + var(--nub, 0px));
  width: 14px;
  height: 14px;
  border-radius: 3px;
  background: var(--card);
  translate: -50% 0;
  rotate: 45deg;
}

.room-menu .swap-choices {
  position: relative;
  z-index: 1;
  flex-wrap: nowrap;
}

.room-menu .swap-choices[aria-busy="true"] [aria-pressed="true"] img {
  animation: pulse 1s ease-in-out infinite;
}

@media (prefers-reduced-motion: no-preference) {
  .room-menu {
    animation: room-menu-in 0.2s var(--ease-out);
  }
}

@keyframes room-menu-in {
  from {
    opacity: 0;
    scale: 0.94;
  }
}

@media (max-width: 480px) {
  .room-menu .swap-choice {
    width: 40px;
    height: 40px;
  }

  .room-menu .swap-choices {
    gap: 6px;
  }
}

/* ---------- the prompts ---------- */

/* Two prompts above the room, each a room built ahead of time. The one
   showing reads as a filled-in prompt; the other is there to try. */
.prompts {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  padding-block: 20px 4px;
}

.prompt {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 8px 16px;
  border: 1px solid var(--stroke);
  border-radius: 999px;
  background: transparent;
  color: var(--ink-soft);
  font: inherit;
  font-size: 15px;
  line-height: 1.3;
  text-align: left;
  cursor: pointer;
  transition:
    background-color 160ms ease,
    color 160ms ease,
    border-color 160ms ease,
    scale 120ms ease;
}

.prompt:hover {
  color: var(--ink);
  border-color: var(--ink);
}

.prompt:active {
  scale: 0.98;
}

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

.prompt[aria-pressed="true"] {
  border-color: transparent;
  background: var(--card);
  color: var(--ink);
  box-shadow:
    0 1px 2px rgb(0 0 0 / 6%),
    0 4px 16px rgb(0 0 0 / 6%);
  cursor: default;
}

/* The line being typed carries a caret; the letters still to come hold
   their place unseen. */
.prompt-typed {
  box-shadow: 1.5px 0 0 currentColor;
}

.prompt-rest {
  visibility: hidden;
}

/* The cards sit in the column as they did before they had a wrapper. */
.picks {
  display: contents;
}

/* A choice this room's share doesn't offer has no card. */
.pick[hidden] {
  display: none;
}

/* The column is centred on the room, under the prompts. */
.band-ui {
  top: 68px;
}

/* The column appears once its cards are built and their pictures are in. */
.band-side {
  visibility: hidden;
  opacity: 0;
  transition: opacity 200ms ease;
}

.band-side.is-ready {
  visibility: visible;
  opacity: 1;
}

/* Each room has its own frame, under a still of the same view. The frame
   comes up under its still, and the still lifts once the room has drawn. A
   room that was waiting at its opening view fades in over the one before. */
.band .room-frame {
  opacity: 0;
  pointer-events: none;
  transition: opacity 400ms ease;
}

.band .room-frame.is-on {
  opacity: 1;
  pointer-events: auto;
}

/* Loading under its still: opaque, so the browser keeps drawing it. */
.band .room-frame.is-warm {
  opacity: 1;
  transition: none;
}

.band .room-poster,
.band-room.loaded .room-poster {
  opacity: 1;
  visibility: visible;
  transition: opacity 200ms ease;
}

.band-room.revealed .room-poster {
  opacity: 0;
  visibility: hidden;
  transition:
    opacity 350ms ease,
    visibility 0s linear 350ms;
}

/* Only the room that is showing has its still up. The other's is loaded
   and waiting. */
.band[data-room="office"] .room-poster[data-room="meeting"],
.band[data-room="meeting"] .room-poster[data-room="office"] {
  opacity: 0;
  visibility: hidden;
  transition: none;
}

/* Tablets: the embed frames the room by height, so the still does too. */
@media (min-width: 721px) and (max-width: 1180px) {
  .band .room-poster {
    left: 50%;
    width: auto;
    max-width: none;
    object-fit: fill;
    translate: -50% 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .prompt {
    transition: none;
  }
}
