/* The playground in the new look (Bloom ticket 13, boards Playground and
   Play-*). On top of /bloom/style.css and /bloom/public.css. The chat's
   messages are drawn by the classic page's script (draw.mjs), with its
   class names (entry, message, bubble, status…), so every rule for them
   is scoped to .play-chat: public.css's .message (the setup page's box)
   and Home's page-wide rules stay out. A business's Try your agent draws
   the same chat in its dashboard's shell (.app.fit), on top of
   /bloom/style.css only.

   1. Picking a business
   2. The chat: its card, head and log
   3. Messages
   4. Notices, Replying to, and the box
   5. Loading a chat the browser kept
   6. Try your agent, in the dashboard
   7. Phone */

/* 1. Picking a business -------------------------------------------------- */

.play-list .rows li[hidden], .play-none[hidden] { display: none; }
.play-list .rows li:first-child { border-top: 0; }
.play-list .rows .tile { width: 40px; height: 40px; border-radius: 12px; font-size: 16px; }
.play-list .rows .d { overflow-wrap: anywhere; }
.play-list .rows .btn { pointer-events: none; }
.play-list .rows a:hover .btn { border-color: var(--ink); }
.play-none { display: flex; flex-direction: column; align-items: center; gap: 12px; width: 100%; padding: 40px 0; text-align: center; }
.play-none .glyph { background: var(--soft); color: var(--accent); }
.play-none p { max-width: 440px; font-size: 15px; }

/* 2. The chat ------------------------------------------------------------ */

main.pub.play-w { max-width: 808px; }
.card.play-chat { align-items: stretch; gap: 16px; }
.play-head { display: flex; align-items: center; gap: 12px; padding-bottom: 16px; border-bottom: 1px solid var(--line); }
.tile.play-tile { width: 44px; height: 44px; border-radius: 12px; font-size: 18px; }
.play-who { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.play-chat .play-who :is(h1, h2) { font-size: 20px; line-height: 1.25; font-weight: 700; letter-spacing: -0.02em; overflow-wrap: anywhere; }
.play-who p { font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.play-log { display: flex; flex-direction: column; margin: 0 -6px; padding: 0 6px 6px; min-height: 320px; max-height: min(60vh, 640px); overflow-y: auto;
            overscroll-behavior: contain; }
.play-intro { max-width: 440px; margin: 8px auto 4px; color: var(--muted); font-size: 13px; text-align: center; }
.play-pill { align-self: center; display: inline-flex; align-items: center; min-height: 36px; margin: 12px 0; padding: 0 14px;
             border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--ink);
             font: 500 14px/1 var(--font); cursor: pointer; }
.play-pill:hover { border-color: var(--ink); }
.play-pill[hidden] { display: none; }
#suggest.play-pill { margin-top: 24px; }
.play-foot { font-size: 14px; color: var(--muted); }

/* The chat fills the window (.site.fit): the header, the chat and the
   footer fit in it, the box to write in shows at the chat's foot, and
   only the messages scroll, inside the chat. The messages are sized by
   the room left (contain: size), never by how many there are; a window
   too short even for their least height scrolls the whole page. */
.site.fit, .app.fit { height: 100vh; height: 100dvh; min-height: 0; }
.site.fit main.pub { flex: 1 1 auto; padding-top: 28px; padding-bottom: 28px; gap: 20px; }
.site.fit .card.play-chat, .app.fit .card.play-chat { flex: 1 1 auto; }
.site.fit .play-log, .app.fit .play-log { flex: 1 1 auto; min-height: 140px; max-height: none; contain: size; }

/* 3. Messages ------------------------------------------------------------ */

.play-msgs { display: flex; flex-direction: column; margin: 0; padding: 0; list-style: none; }
.play-chat .entry { position: relative; display: flex; flex-direction: column; }
.play-chat .entry.mine { align-items: flex-end; }
.play-chat .entry.theirs { align-items: flex-start; }
.play-chat .message { display: flex; align-items: center; gap: 6px; width: auto; max-width: 78%; margin: 16px 0 0; padding: 0;
                      border: 0; border-radius: 0; background: none; color: inherit; font: inherit; resize: none; }
.play-chat .message.more { margin-top: 4px; }
.play-chat .entry.mine .message { flex-direction: row-reverse; }
.play-chat .bubble { min-width: 0; padding: 12px 16px; border-radius: 16px; background: var(--soft); color: var(--ink);
                     font-size: 15px; line-height: 1.5; text-align: left; white-space: pre-wrap; overflow-wrap: anywhere; cursor: pointer; }
.play-chat .mine .bubble { background: var(--accent); color: var(--on-accent); border-bottom-right-radius: 6px; }
.play-chat .theirs .bubble { border-bottom-left-radius: 6px; }
.play-chat .mine .bubble a { color: inherit; }
.play-chat .bubble.chosen { outline: 2px solid var(--ask); outline-offset: 2px; }
.play-chat .outgoing .bubble { opacity: .6; cursor: default; }
.play-chat .flash .bubble { animation: play-flash 1.6s ease-out; }
@keyframes play-flash { 0%, 30% { box-shadow: 0 0 0 4px var(--soft); } 100% { box-shadow: 0 0 0 4px transparent; } }
.play-chat .reply { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%);
                    white-space: nowrap; border: 0; }
.play-chat .reply:focus-visible { position: static; width: auto; height: auto; flex: none; clip-path: none; padding: 4px 10px;
                                  border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--ink);
                                  font: 500 12px/1.4 var(--font); cursor: pointer; }
.play-chat .time { align-self: center; margin: 20px 0 0; color: var(--muted); font-size: 12px; }
.play-chat .re { max-width: 78%; margin: 14px 6px -10px; padding: 0; border: 0; background: none; color: var(--muted);
                 font: 12px/1.5 var(--font); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; }
.play-chat .re:hover, .play-chat .re:focus-visible { color: var(--ink); }
.play-chat .status { max-width: 100%; margin: 6px 6px 0; color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.play-chat .entry.mine .status { text-align: right; }
.play-chat .status.failed { font-weight: 600; color: var(--warn); }
/* A business's message that waits for you: Waiting for your answer, or
   Asks you to sign in. */
.play-chat .entry.theirs .status { font-weight: 700; color: var(--ask); }
.play-chat .typing { display: flex; align-items: center; gap: 5px; padding: 16px; cursor: default; }
.play-chat .typing span { width: 7px; height: 7px; border-radius: 999px; background: var(--muted);
                          animation: play-blink 1.2s infinite ease-in-out; }
.play-chat .typing span:nth-child(2) { animation-delay: .2s; }
.play-chat .typing span:nth-child(3) { animation-delay: .4s; }
@keyframes play-blink { 0%, 60%, 100% { opacity: .3; } 30% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  .play-chat .typing span, .play-chat .flash .bubble { animation: none; }
  .play-chat .typing span { opacity: .6; }
}

/* 4. Notices, Replying to, and the box ----------------------------------- */

.play-notice { padding: 14px 16px; border-radius: 12px; background: var(--warn-soft); color: var(--ink); font-size: 14px; }
.play-notice[hidden], .play-replying[hidden] { display: none; }
.play-log .play-notice { margin: 12px 0; }
.play-replying { display: flex; align-items: center; gap: 8px; padding: 6px 6px 6px 14px; border-radius: 12px;
                 background: var(--ask-soft); color: var(--ink); font-size: 13px; }
.play-replying p { flex: 1; min-width: 0; overflow: hidden; color: var(--ink); font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.play-replying button { display: inline-flex; align-items: center; justify-content: center; flex: none; width: 32px; height: 32px;
                        padding: 0; border: 0; border-radius: 999px; background: none; color: var(--muted); cursor: pointer; }
.play-compose { display: flex; align-items: flex-end; gap: 8px; padding-top: 16px; border-top: 1px solid var(--line); }
.play-compose textarea { flex: 1; min-width: 0; min-height: 46px; max-height: 160px; padding: 12px 18px; border: 1px solid var(--line);
                         border-radius: 23px; background: var(--surface); color: var(--ink); font: 400 15px/1.4 var(--font); resize: none; }
.play-compose textarea::placeholder { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.play-compose textarea:focus { outline: none; border-color: var(--accent); }
.play-compose .btn { min-height: 46px; }
.play-compose .btn:disabled { opacity: .5; cursor: default; }

/* 5. Loading a chat the browser kept ------------------------------------ */

/* The messages' room is the chat's from the first paint (above), so what
   comes in never moves the page. While the chat is read (.loading, set by
   app.mjs), its messages stay hidden; if that takes more than a moment,
   skeleton messages fade in, so a quick read never flashes them. Then the
   messages fade and rise into place, the newest few one after another
   (--i), landing on the newest. With reduced motion nothing moves:
   the messages show at once. */
.play-loading { display: none; }
.play-chat.loading .play-msgs, .play-chat.loading .play-pill { display: none; }
.play-chat.loading .play-loading { display: flex; flex-direction: column; gap: 4px; animation: play-appear .2s ease-out .15s both; }
.play-loading .sk { display: block; width: 44%; height: 46px; margin-top: 12px; border-radius: 16px;
                    background: linear-gradient(100deg, var(--soft) 40%, var(--surface) 50%, var(--soft) 60%) 0 0 / 300% 100% var(--soft);
                    animation: play-shimmer 1.6s linear infinite; }
.play-loading .theirs { align-self: flex-start; border-bottom-left-radius: 6px; }
.play-loading .mine { align-self: flex-end; width: 30%; border-bottom-right-radius: 6px; opacity: .7; }
.play-loading .long { width: 62%; height: 70px; }
.play-chat .rise { animation: play-rise .42s cubic-bezier(.2, .8, .3, 1) both; animation-delay: calc(var(--i, 0) * 60ms); }
@keyframes play-appear { from { opacity: 0; } }
@keyframes play-shimmer { from { background-position: 100% 0; } to { background-position: 0 0; } }
@keyframes play-rise { from { opacity: 0; transform: translateY(6px); } }
@media (prefers-reduced-motion: reduce) {
  .play-chat .rise, .play-loading .sk { animation: none; }
}

/* 6. Try your agent, in the dashboard ----------------------------------- */

/* The menu beside it, the heading over it, and the chat filling the rest
   of the window (.app.fit, above). Open chat, beneath the menu, is shown
   as the page you're on. */
.app.fit .pane { min-height: 0; padding-bottom: 28px; }
.app.fit .foot { padding-top: 0; }
.tryit a[aria-current] { border-color: var(--accent); color: var(--accent); }

/* 7. Phone --------------------------------------------------------------- */

@media (max-width: 720px) {
  .site.fit main.pub { padding-top: 16px; padding-bottom: 16px; gap: 12px; }
  .app.fit .pane { padding-bottom: 76px; }
  .card.play-chat { padding: 16px; }
  .play-head { flex-wrap: wrap; }
  .play-head .chip { display: none; }
  .play-log { min-height: 280px; max-height: 55vh; max-height: 55dvh; }
  .play-chat .message, .play-chat .re { max-width: 88%; }
  .play-compose textarea { padding: 12px 14px; font-size: 16px; }
  .play-compose .btn { padding: 0 16px; }
}
