/* Pimsy Rooms prototype — ?rooms=1 on phones (room behind Pimsy) and desktops (room card
   next to the chat); every rule is scoped to .rooms-on / .room-* */

/* ── Scene ───────────────────────────────────────────────────────────────── */
.room-scene {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  background: #e9e3f5;
}

.room-backdrop {
  position: absolute;
  inset: -48px;
  background-size: cover;
  background-position: center;
  filter: blur(28px) saturate(1.1);
  opacity: 0.85;
}

.room-frame,
.room-stage,
.room-stage-overlay {
  position: absolute;
}

.room-frame {
  inset: 0;
  overflow: hidden;
}

/* Desktop: the room is a card next to the chat */
.room-frame.is-card {
  border-radius: 28px;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.22), 0 0 0 1px rgba(255, 255, 255, 0.5);
}

/* Phone: the image ends under the chat glass — fade it so there's no seam */
.room-stage.fade-bottom {
  -webkit-mask-image: linear-gradient(to bottom, #000 calc(100% - 90px), transparent);
  mask-image: linear-gradient(to bottom, #000 calc(100% - 90px), transparent);
}

.room-stage {
  background-size: 100% 100%;
  background-repeat: no-repeat;
}

.room-stage-overlay {
  pointer-events: none;
}

/* ── Tap spots ───────────────────────────────────────────────────────────── */
.room-spot {
  position: absolute;
  padding: 0;
  margin: 0;
  border: 0;
  border-radius: 14px;
  background: transparent;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.room-spot:focus-visible {
  outline: 2px dashed rgba(255, 96, 160, 0.8);
  outline-offset: 2px;
}

.room-spot-crop {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background-repeat: no-repeat;
  opacity: 0;
  pointer-events: none;
}

.room-spot.is-popped .room-spot-crop {
  animation: room-spot-pop 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes room-spot-pop {
  0%   { opacity: 1; transform: scale(1) rotate(0deg); }
  35%  { opacity: 1; transform: scale(1.12) rotate(-3deg); }
  65%  { opacity: 1; transform: scale(0.97) rotate(2deg); }
  95%  { opacity: 1; transform: scale(1) rotate(0deg); }
  100% { opacity: 0; transform: scale(1); }
}

.room-spot.has-hint::after {
  content: '\2728';  /* ✨ as an escape, so the file's encoding can't garble it */
  position: absolute;
  top: 4px;
  right: 4px;
  font-size: 13px;
  line-height: 1;
  opacity: 0;
  pointer-events: none;
  animation: room-hint 3.2s ease-in-out infinite;
  animation-delay: var(--hint-delay, 0s);
}

@keyframes room-hint {
  0%, 60%, 100% { opacity: 0; transform: scale(0.6); }
  75%           { opacity: 1; transform: scale(1.1); }
}

/* ── Night ───────────────────────────────────────────────────────────────── */
.room-night {
  position: absolute;
  inset: 0;
  background: rgba(34, 22, 78, 0.5);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.6s ease;
}

.room-glow {
  position: absolute;
  left: 50%;
  top: 6%;
  width: 80%;
  aspect-ratio: 1;
  transform: translate(-50%, -38%);
  background: radial-gradient(circle, rgba(255, 214, 150, 0.55) 0%, rgba(255, 214, 150, 0.18) 38%, rgba(255, 214, 150, 0) 62%);
  opacity: 0;
  transition: opacity 0.6s ease;
}

.room-scene.is-night .room-night,
.room-scene.is-night .room-glow {
  opacity: 1;
}

.room-backdrop {
  transition: filter 0.6s ease;
}

.room-scene.is-night .room-backdrop {
  filter: blur(28px) saturate(1.1) brightness(0.82);
}

/* ── Pimsy's line bubble ─────────────────────────────────────────────────── */
.room-bubble {
  position: fixed;
  z-index: 130;
  transform: translateY(-100%);
  pointer-events: none;
  display: flex;
  justify-content: center;
}

.room-bubble span {
  position: relative;
  padding: 10px 14px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.16);
  color: #0f172a;
  font-family: 'Outfit', 'Inter', sans-serif;
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.35;
  text-align: center;
  animation: room-bubble-in 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Tail pointing down at Pimsy */
.room-bubble span::before {
  content: '';
  position: absolute;
  bottom: -6px;
  left: 50%;
  width: 14px;
  height: 14px;
  background: inherit;
  border-radius: 3px;
  transform: translateX(-50%) rotate(45deg);
}

@keyframes room-bubble-in {
  from { opacity: 0; transform: translateY(8px) scale(0.9); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ── Room button + picker ────────────────────────────────────────────────── */
.room-button {
  position: fixed;
  top: 64px;
  right: 24px;
  z-index: 110;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1.5px solid rgba(100, 116, 139, 0.18);
  background: rgba(255, 255, 255, 0.88);
  color: #475569;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.12);
}

.room-button:active {
  transform: scale(0.94);
}

.room-sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 999;
  background: rgba(15, 23, 42, 0.28);
}

.room-sheet {
  position: fixed;
  left: 50%;
  bottom: 0;
  z-index: 1000;
  width: min(100%, 440px);
  transform: translateX(-50%);
  padding: 16px 16px max(20px, env(safe-area-inset-bottom));
  border-radius: 24px 24px 0 0;
  background: #ffffff;
  box-shadow: 0 -12px 40px rgba(15, 23, 42, 0.18);
  font-family: 'Outfit', 'Inter', sans-serif;
  animation: room-sheet-in 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes room-sheet-in {
  from { transform: translate(-50%, 40px); opacity: 0; }
  to   { transform: translate(-50%, 0); opacity: 1; }
}

.room-sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  color: #0f172a;
  font-size: 1.05rem;
}

.room-sheet-close {
  border: 0;
  background: transparent;
  color: #64748b;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
}

.room-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.room-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 6px 6px 8px;
  border: 2px solid transparent;
  border-radius: 16px;
  background: #f8fafc;
  cursor: pointer;
  font-family: inherit;
}

.room-card img {
  width: 100%;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  object-position: top;
  border-radius: 12px;
}

.room-card.is-active {
  border-color: #ff60a0;
  background: #fff0f5;
}

.room-card-label {
  color: #0f172a;
  font-size: 0.85rem;
  font-weight: 600;
}

.room-card-note {
  color: #64748b;
  font-size: 0.7rem;
  text-align: center;
  line-height: 1.2;
}

.room-card.is-locked img {
  filter: grayscale(0.6) blur(1.5px);
  opacity: 0.7;
}

.room-card-lock {
  position: absolute;
  top: 38%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 1.6rem;
}

.room-card.is-shaking {
  animation: room-shake 0.45s ease;
}

@keyframes room-shake {
  0%, 100% { transform: translateX(0); }
  20%      { transform: translateX(-5px); }
  40%      { transform: translateX(5px); }
  60%      { transform: translateX(-3px); }
  80%      { transform: translateX(3px); }
}

.room-lights {
  width: 100%;
  margin-top: 12px;
  padding: 10px;
  border: 1.5px solid rgba(100, 116, 139, 0.18);
  border-radius: 14px;
  background: #ffffff;
  color: #475569;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
}

/* ── App on top of the room ──────────────────────────────────────────────── */

/* Empty parts of the layout let taps reach the room; Pimsy's drawn shape stays tappable. */
.app.rooms-on,
.app.rooms-on .app-character,
.app.rooms-on .pimsy-character,
.app.rooms-on .pimsy-lottie-wrap,
.app.rooms-on .lottie-layer-active {
  pointer-events: none;
}

.app.rooms-on .pimsy-lottie-wrap svg * {
  pointer-events: visiblePainted;
}

.app.rooms-on .app-chat,
.app.rooms-on .chat-toggle-pill {
  pointer-events: auto;
}

/* ── Pimsy stands on the floor ───────────────────────────────────────────── */
.app.rooms-on {
  /* Client: bigger, so she doesn't get lost in the room. Height caps it on short phones so
     she stays clear of the buttons along the top. */
  --pimsy-size: clamp(200px, min(66vw, 38svh), 290px);
}

.app.rooms-on .app-character {
  animation: none;
  justify-content: flex-end;
  padding: 0 0 10px;
}

.app.rooms-on .pimsy-character {
  position: relative;
  padding: 0;
}

.app.rooms-on .pimsy-lottie-wrap {
  width: var(--pimsy-size);
  height: var(--pimsy-size);
  animation: room-bob 3.4s ease-in-out infinite;
}

/* Floor shadow under her feet (feet sit at ~91% of her frame) */
.app.rooms-on .pimsy-character::before {
  content: '';
  position: absolute;
  left: 50%;
  bottom: calc(var(--pimsy-size) * 0.035);
  width: calc(var(--pimsy-size) * 0.62);
  height: calc(var(--pimsy-size) * 0.1);
  border-radius: 50%;
  background: radial-gradient(ellipse at center, rgba(40, 20, 60, 0.34) 0%, rgba(40, 20, 60, 0.14) 48%, rgba(40, 20, 60, 0) 72%);
  transform: translateX(-50%);
  animation: room-shadow 3.4s ease-in-out infinite;
  pointer-events: none;
}

@keyframes room-bob {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-6px); }
}

@keyframes room-shadow {
  0%, 100% { transform: translateX(-50%) scale(1);    opacity: 1; }
  50%      { transform: translateX(-50%) scale(0.86); opacity: 0.75; }
}

/* ── Frosted chat ────────────────────────────────────────────────────────── */
.app.rooms-on .app-chat {
  background: rgba(255, 240, 245, 0.55);
  backdrop-filter: blur(14px) saturate(1.2);
  -webkit-backdrop-filter: blur(14px) saturate(1.2);
  border-radius: 24px 24px 0 0;
  box-shadow: 0 -6px 24px rgba(15, 23, 42, 0.06);
}

.app.rooms-on .chat-messages {
  background: transparent;
}

.app.rooms-on .chat-toggle-pill-on {
  background: rgba(255, 255, 255, 0.85);
}

/* Hide Chat: only the input bar stays; the rest of the room opens up */
.app.rooms-on.app-chat-hidden .app-chat {
  background: transparent;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  box-shadow: none;
}

.app.rooms-on.app-chat-hidden .legal-footer {
  background: rgba(255, 240, 245, 0.7) !important;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-radius: 16px 16px 0 0;
}

/* ── Phone: room on top, chat below ──────────────────────────────────────── */
/* Phone look: phones and portrait tablets (keep in step with roomConfig.js) */
@media (max-width: 640px), (max-width: 1100px) and (orientation: portrait) {
  .app.rooms-on .app-character {
    height: 54svh;
  }

  .app.rooms-on .app-chat {
    height: 46svh;
    max-height: 46svh;
  }

  .app.rooms-on.app-chat-hidden .app-character {
    height: auto;
    flex: 1;
  }

  .app.rooms-on.app-chat-hidden .app-chat {
    height: auto;
    max-height: none;
  }
}

/* QuickPrompts row (production only): see-through over the frosted chat, and a narrow chat
   scrolls it from the first button instead of centering it off the left edge */
.app.rooms-on .quick-prompts {
  background: transparent;
}

.app.rooms-on .prompts-grid {
  justify-content: flex-start;
}

.app.rooms-on .prompt-button:first-child {
  margin-left: auto;
}

.app.rooms-on .prompt-button:last-child {
  margin-right: auto;
}

/* ── Portrait tablets: the phone look in a centered column ──────────────────── */
/* Keep the media query in step with TABLET_QUERY in roomConfig.js */
@media (min-width: 641px) and (max-width: 1100px) and (orientation: portrait) {
  .app.rooms-on {
    /* RoomScene reads the room column from this box, so its size only lives here. Narrower on
       shorter tablets so the room's top isn't cut much more than on phones (~25%). */
    max-width: min(100vw, 600px, 52svh);
    --pimsy-size: clamp(240px, min(55vw, 34svh), 360px);
  }

  .room-frame.is-column {
    box-shadow: 0 0 60px rgba(15, 23, 42, 0.16);
  }
}

/* ── Landscape tablets and desktops: room card + chat column ──────────────── */
/* Keep the media query in step with CARD_QUERY / TABLET_QUERY in roomConfig.js */
@media (min-width: 641px) and (min-height: 500px) and (orientation: landscape),
  (min-width: 1101px) and (min-height: 500px) {
  .app.rooms-on {
    /* the card keeps its shape and shrinks before the chat gets under --chat-min;
       72px = 2 x 24px padding + 24px gap */
    --chat-min: 340px;
    --room-app-w: min(1100px, 100vw);
    --room-card-w: min(calc((100dvh - 48px) * 1280 / 2189), calc(var(--room-app-w) - 72px - var(--chat-min)));
    --pimsy-size: clamp(170px, calc(var(--room-card-w) * 0.65), 420px);
    flex-direction: row;
    gap: 24px;
    padding: 24px;
    width: var(--room-app-w);
    max-width: none;
    margin: 0 auto;
  }

  .app.rooms-on .app-character {
    flex: none;
    align-self: center;
    width: var(--room-card-w);
    height: calc(var(--room-card-w) * 2189 / 1280);
    padding: 0 0 16px;
    border-radius: 28px;
  }

  .app.rooms-on .app-chat {
    flex: 1 1 auto;
    min-width: var(--chat-min);
    height: calc(100dvh - 48px);
    max-height: none;
    border-radius: 28px;
  }

  .app.rooms-on .chat-toggle-pill {
    display: none;
  }

  /* a long placeholder wrapped into 5 clipped lines in the 300px chat */
  .app.rooms-on .input-field-wrap textarea::placeholder {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .app.rooms-on .app-chat {
    container-type: inline-size;
  }

  /* narrow chat: less padding around the input so the field itself gets the width */
  @container (max-width: 420px) {
    .input-bar-container {
      padding: 12px 10px 20px;
    }

    .input-bar-main {
      gap: 8px;
      padding: 0;
    }

    .input-actions {
      gap: 8px;
    }

    .input-field-wrap {
      padding: 4px 14px;
    }
  }

  .room-sheet {
    bottom: 24px;
    border-radius: 24px;
  }
}

/* Narrow landscape windows (641-759px): a slightly narrower chat so the card still fits */
@media (min-width: 641px) and (max-width: 759px) and (min-height: 500px) and (orientation: landscape) {
  .app.rooms-on {
    --chat-min: 300px;
  }
}
