/* v3 chat (play/chat.js): a wide box centred at the bottom, black see-through like the other speech boxes, face badge on
   the left, numbered reply buttons under the line. Sizes follow the stage (1cqw = 1% of its width). */
/* Figma "Story Card" (file CmD5wuS76aqLyzzpSVK2J5, node 2051:1197): every number is a Figma pixel on the 2752-wide frame
   times --u. Black 75% panel, 4.94 white pixel border, hard drop shadow, orange label on top, the line in Inter with the
   round character avatar on the right, World Buttons in the footer on the right. Docked bottom centre so the person
   you talk to stays in view. */
.chat { --u: calc(100cqw / 2752); position: absolute; z-index: 40; left: 50%; bottom: calc(60 * var(--u)); translate: -50% 0; width: calc(1680 * var(--u)); max-width: calc(100cqw - 3cqw);
  display: flex; flex-direction: column; gap: calc(29.647 * var(--u)); padding: calc(49.412 * var(--u)) calc(59.294 * var(--u)) calc(34.588 * var(--u));
  background: rgba(0, 0, 0, .75); border: max(2px, calc(4.941 * var(--u))) solid #fff; border-radius: calc(9.882 * var(--u));
  filter: drop-shadow(0 calc(14.824 * var(--u)) 0 rgba(0, 0, 0, .6)); color: #fff; font-family: Inter, system-ui, sans-serif; animation: rise .3s ease-out both; }
.chat[hidden], .chat-card[hidden] { display: none; }
.chat-name { margin: 0; font: 400 max(11px, calc(29.647 * var(--u))) / 1.3 Inter, system-ui, sans-serif; color: var(--brand-orange, #fcb24f); white-space: nowrap; }
.chat-row { display: flex; gap: calc(148.235 * var(--u)); align-items: flex-start; }
.chat-line { flex: 1 0 0; min-width: 0; margin: 0; font: 400 max(14px, calc(44.471 * var(--u))) / 1.5 Inter, system-ui, sans-serif; }
.chat-line.in { animation: chatIn .35s ease-out; }
.chat-face { flex: none; width: calc(177.882 * var(--u)); aspect-ratio: 1; background: center / contain no-repeat; image-rendering: pixelated; }
.chat.is-avg .chat-face { border-radius: 50%; border: calc(5 * var(--u)) solid #fff; background-color: #6b6f7a; background-size: 190% auto; background-position: 50% 12%; }
.chat.is-avg .chat-name { color: #c9ccd6; }
/* footer: World Buttons, right-aligned. One reply = "Text" variant (like Tap to continue ›); choices = outlined "Secondary" */
.chat-replies { display: flex; flex-wrap: wrap; gap: calc(18 * var(--u)) calc(26 * var(--u)); align-items: center; justify-content: flex-end; }
.chat-btn { display: inline-flex; align-items: center; gap: calc(15.289 * var(--u)); margin: 0; padding: calc(14 * var(--u)) calc(30 * var(--u));
  border: max(2px, calc(3.822 * var(--u))) solid #fff; border-radius: calc(9.882 * var(--u)); background: transparent; color: #fff; text-decoration: none; cursor: pointer;
  font: 600 max(12px, calc(30.578 * var(--u))) / 1.3 Inter, system-ui, sans-serif; letter-spacing: calc(1.2231 * var(--u)); text-align: left;
  filter: drop-shadow(0 calc(7.644 * var(--u)) 0 #000); transition: transform .08s, background-color .15s; }
.chat-btn:hover, .chat-btn:focus-visible { background-color: rgba(255, 255, 255, .12); outline: none; }
.chat-btn:active { transform: translateY(calc(5 * var(--u))); }
.chat-btn kbd { font: inherit; opacity: .55; }
.chat-btn.link { border-style: dashed; filter: none; }
.chat-replies.single .chat-btn { border-color: transparent; filter: none; padding-inline: calc(9.882 * var(--u)); font-size: max(13px, calc(39.529 * var(--u))); letter-spacing: calc(1.5812 * var(--u)); text-transform: uppercase; }
.chat-replies.single .chat-btn kbd { display: none; }
.chat-replies.single .chat-btn:hover, .chat-replies.single .chat-btn:focus-visible { background: none; text-decoration: underline; text-underline-offset: .25em; }
.chat-replies.single .chat-btn::after { content: ' ›'; }
@keyframes chatIn { from { opacity: 0; translate: 0 .4cqw; } to { opacity: 1; translate: 0 0; } }

/* while chatting: the face bar, speech toast, controls hint and talk button step aside */
body.in-chat .sb-bar, body.in-chat .sb-speech, body.in-chat .w3d-keys, body.in-chat .talk { opacity: 0 !important; pointer-events: none; }
/* the spoken-line captions only step aside while the chat box is up (Mr Average's laugh between lines keeps its caption) */
body.in-chat:has(.chat:not([hidden])) .captions { opacity: 0 !important; }

/* the trading card at the end */
.chat-card { position: absolute; inset: 0; z-index: 45; display: grid; place-items: center; background: rgba(0, 0, 0, .45); }
.chat-card-in { width: 24cqw; padding: 1.6cqw; text-align: center; color: #fff; background: rgba(0, 0, 0, .85); border: 2px solid #fff; border-radius: 8px;
  font-family: Inter, system-ui, sans-serif; animation: cardIn .5s cubic-bezier(.3, 1.4, .5, 1) both; }
.cc-photo { width: 9cqw; aspect-ratio: 1; margin: 0 auto 1cqw; border-radius: 50%; border: 3px solid #fff; background: #2b2f3a center / cover no-repeat; image-rendering: pixelated; box-shadow: 0 0 2cqw rgba(255, 255, 255, .25); }
.cc-eyebrow { margin: 0; font-size: clamp(11px, .9cqw, 26px); letter-spacing: .12em; text-transform: uppercase; opacity: .7; }
.chat-card h2 { margin: .2cqw 0 0; font: 300 clamp(20px, 2.2cqw, 64px) / 1.1 'ivyora-display', Georgia, serif; }
.cc-role { margin: .3cqw 0 1cqw; font-size: clamp(12px, 1cqw, 30px); opacity: .75; }
.chat-card h3 { margin: 0 0 .5cqw; font-size: clamp(11px, .9cqw, 26px); font-weight: 600; letter-spacing: .1em; text-transform: uppercase; opacity: .8; }
.chat-card ol { list-style: none; margin: 0 0 1cqw; padding: 0; display: grid; gap: .35cqw; }
.chat-card li { padding: .35cqw .6cqw; border-radius: 4px; border: 2px solid var(--c); background: color-mix(in srgb, var(--c) 18%, transparent); font-size: clamp(13px, 1.1cqw, 32px); font-weight: 600; }
.cc-met { margin: 0 0 1cqw; font-size: clamp(12px, 1cqw, 30px); opacity: .85; }
@keyframes cardIn { from { opacity: 0; scale: .85; } to { opacity: 1; scale: 1; } }

/* v3: the card for a floating object (no buttons to press except a link or the quiz; it goes when you walk away) */
.chat.obj-card { width: calc(1180 * var(--u)); animation: rise .25s ease-out both; }
.obj-card .chat-row { gap: calc(40 * var(--u)); align-items: center; }
.obj-icon { flex: none; font-size: calc(120 * var(--u)); line-height: 1; }
.obj-words { flex: 1; min-width: 0; }
.obj-title { margin: 0 0 calc(8 * var(--u)); font: 300 max(15px, calc(48 * var(--u))) / 1.15 'ivyora-display', Georgia, serif; }
body.in-chat .obj-card { display: none; }

/* v3: a close (×) button on every dialogue box */
.chat, .chat-card-in { position: absolute; }
.chat-card-in { position: relative; }
.chat-x { position: absolute; top: calc(14 * var(--u, .0363cqw)); right: calc(18 * var(--u, .0363cqw)); width: max(28px, calc(64 * var(--u, .0363cqw))); aspect-ratio: 1; display: grid; place-items: center;
  padding: 0; border: 0; border-radius: 50%; background: transparent; color: #fff; font: 300 max(22px, calc(56 * var(--u, .0363cqw))) / 1 Inter, system-ui, sans-serif; cursor: pointer; opacity: .75; }
.chat-x:hover, .chat-x:focus-visible { opacity: 1; background: rgba(255, 255, 255, .14); outline: none; }
body:has(.obj-card:not([hidden])) .sb-bar { opacity: 0 !important; }   /* the face bar steps aside under an object card */
/* object cards: heading to paragraph about 1.6 : 1 (heading 48, text 30 Figma px), so the title leads and the text reads as body copy */
.obj-card .obj-title { margin-bottom: calc(14 * var(--u)); }
.obj-card .chat-line { font-size: max(13px, calc(30 * var(--u))); line-height: 1.55; color: rgba(255, 255, 255, .88); }
.obj-card .obj-icon { font-size: calc(100 * var(--u)); }

/* one box at a time: an open object card hides the speech box under it until the card is closed */
#s-planet:has(.obj-card:not([hidden])) .sb-speech { visibility: hidden; }

/* quiz: the round, top right beside the close button (set in chat.js) */
body.in-chat .chat[data-round]::before { content: attr(data-round); position: absolute; top: calc(20 * var(--u)); right: calc(110 * var(--u)); font: 500 max(11px, calc(26 * var(--u))) / 1 Inter, system-ui, sans-serif; letter-spacing: .08em; text-transform: uppercase; color: rgba(255, 255, 255, .8); }

/* 3 Dec: chat and object cards share the speech box's look (same black box, 2px white border, 4px corners, no drop
   shadow), and the object card drops the owner's name line above the title (it only took up height) */
.chat { border-width: 2px; border-radius: 4px; filter: none; }
@media not ((orientation: landscape) and (max-height: 500px)) { .obj-card > .chat-name { display: none; } }
/* the card icon is the voxel object's pixel art (chat.js voxIcon), scaled up with hard pixel edges */
.obj-card .obj-icon { display: grid; place-items: center; }
.obj-vox { width: calc(110 * var(--u)); height: calc(110 * var(--u)); min-width: 44px; min-height: 44px; image-rendering: pixelated; }
/* 3 Dec: the card's buttons (Play the quiz, Visit their site) in the game's pixel capitals at the Sound / Next size */
.obj-card .chat-btn, .chat-replies.single .chat-btn { font: 400 clamp(12px, 1cqw, 30px) / 1.1 var(--font-pixel); letter-spacing: .05em; text-transform: uppercase; padding: .8em 1.2em; }
@media (orientation: landscape) and (max-height: 500px) { .chat.obj-card .chat-btn, body.in-chat .chat .chat-replies.single .chat-btn { font: 400 12px / 1.1 var(--font-pixel); letter-spacing: .05em; } }
/* BugHerd 24: the eyebrow over the card's title (Cause, Highlight, Fun fact; Quiz in orange with a play arrow), the same
   words as the label floating over the object (world/world3d.css .w3d-olbl) */
.obj-eyebrow { margin: 0 0 calc(14 * var(--u)); font: 400 clamp(10px, .8cqw, 24px) / 1 var(--font-pixel); font-variant-ligatures: none; letter-spacing: .08em; text-transform: uppercase; color: rgba(255, 255, 255, .72); }
.obj-eyebrow.is-quiz { display: flex; align-items: center; gap: .4em; color: var(--brand-orange, #fcb24f); }
.obj-eyebrow.is-quiz::after { content: ''; width: .5em; height: .62em; background: currentColor; clip-path: polygon(0 0, 100% 50%, 0 100%); }
@media (orientation: landscape) and (max-height: 500px) { .obj-card .obj-eyebrow { margin-bottom: 6px; font-size: 10px; } }

/* 3 Dec: the quiz (desktop and tablets) looks like the talk box (strengths.css body.talk-demo .sb-speech): same size and
   place at the bottom middle, same near-black box, round face with the green ring on the LEFT, name in IvyOra, the round in
   orange pixel capitals where the job title goes, the question in Inter, answers left-aligned with no shadow on the text.
   Phones keep their side panel (phone.css). */
@media not ((orientation: landscape) and (max-height: 500px)) {
  body.in-chat .chat:not(.obj-card) {
    bottom: 1.6cqw; width: min(94vw, max(46cqw, 540px)); max-width: none; box-sizing: border-box;
    display: grid; grid-template-columns: auto 1fr; column-gap: clamp(10px, 1.2cqw, 36px); row-gap: 0; align-items: start;
    padding: clamp(10px, 1cqw, 30px) clamp(14px, 1.5cqw, 44px); background: rgba(8, 8, 10, .94); border: 2px solid #fff; border-radius: 4px; filter: none; }
  body.in-chat .chat:not(.obj-card) .chat-row { display: contents; }
  body.in-chat .chat:not(.obj-card) .chat-face { grid-column: 1; grid-row: 1 / span 4; width: clamp(48px, 5.4cqw, 160px); border-radius: 50%;
    border: 3px solid #00bd8c; box-sizing: border-box; background-color: #2b2f3a; background-size: cover; }
  body.in-chat .chat:not(.obj-card) .chat-name { grid-column: 2; grid-row: 1; padding-right: 48px; color: #fff; font: 300 clamp(18px, 2cqw, 60px) / 1.05 'ivyora-display', Georgia, serif; }
  body.in-chat .chat[data-round]:not(.obj-card)::before { position: static; grid-column: 2; grid-row: 2; margin: .15em 0 .5em; color: #fcb24f;
    font: 400 clamp(12px, 1cqw, 30px) / 1.1 var(--font-pixel); letter-spacing: .05em; text-transform: uppercase; }
  body.in-chat .chat:not(.obj-card) .chat-line { grid-column: 2; grid-row: 3; margin-bottom: .8em; font: 400 clamp(13px, 1.2cqw, 34px) / 1.4 Inter, system-ui, sans-serif; }
  body.in-chat .chat:not(.obj-card) .chat-replies { grid-column: 2; grid-row: 4; display: grid; gap: clamp(6px, .5cqw, 16px); justify-content: stretch; }
  body.in-chat .chat:not(.obj-card) .chat-btn { width: 100%; box-sizing: border-box; justify-content: flex-start; padding: .55em .8em; border: 2px solid rgba(255, 255, 255, .85); border-radius: 4px;
    background: rgba(255, 255, 255, .04); font: 500 clamp(12px, 1.05cqw, 30px) / 1.3 Inter, system-ui, sans-serif; letter-spacing: 0; filter: none; text-shadow: none; }
  body.in-chat .chat:not(.obj-card) .chat-btn:hover, body.in-chat .chat:not(.obj-card) .chat-btn:focus-visible { background: rgba(255, 255, 255, .14); border-color: #fff; }
  body.in-chat .chat:not(.obj-card) .chat-btn kbd { opacity: .7; }
  /* one reply (Next, Done): a small button, left-aligned under the text, not a full-width answer */
  body.in-chat .chat:not(.obj-card) .chat-replies.single { justify-content: start; }
  body.in-chat .chat:not(.obj-card) .chat-replies.single .chat-btn:is(:hover, :focus-visible) { text-decoration: none; }
  body.in-chat .chat:not(.obj-card) .chat-replies.single .chat-btn { width: auto; padding: .7em 1.1em; font: 400 clamp(12px, 1cqw, 30px) / 1.1 var(--font-pixel); letter-spacing: .05em; }
  body.in-chat .chat:not(.obj-card) .chat-x { top: clamp(8px, .8cqw, 24px); right: clamp(8px, .8cqw, 24px); }
}
