/* SLOP CENTER — talk (dialogue box). Owner: Menus UI.
   A warm-ink box docked to the bottom; the speaker's portrait stands up out of its left
   edge, their accent colour runs along the top. "You" lines turn into a cream reply bubble
   on the right; choices stack above the box as reply chips. The 3D view stays visible. */
.tk-root {
  --tk-ink: #17151c;
  --tk-paper: #f8f2e6;
  --tk-round: ui-rounded, "SF Pro Rounded", "Arial Rounded MT Bold", system-ui, sans-serif;
  --tk-pad-l: 150px;
  position: absolute; inset: 0; pointer-events: none;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
.tk-root[hidden] { display: none; }
/* keeps the bottom-right corner free for the look-down chevron (bottom-left when left-handed) */
.tk-wrap {
  position: absolute; margin: 0 auto; max-width: 900px;
  left: max(14px, env(safe-area-inset-left)); right: max(64px, calc(env(safe-area-inset-right) + 54px));
  bottom: max(12px, env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 10px;
}

.tk-root.lefty .tk-wrap { left: max(64px, calc(env(safe-area-inset-left) + 54px)); right: max(14px, env(safe-area-inset-right)); }

/* ---------- box ---------- */
.tk-box {
  --tk-accent: #94a3b8; --tk-on: #17151c;
  position: relative; pointer-events: auto; cursor: pointer;
  min-height: 112px; max-height: 38vh;
  padding: 22px 46px 16px var(--tk-pad-l);
  border-radius: 20px;
  background:
    linear-gradient(180deg, rgba(255,255,255,.05), rgba(255,255,255,0) 45%),
    #18161d;
  box-shadow:
    inset 0 3px 0 var(--tk-accent),
    inset 0 0 0 1px rgba(255,255,255,.07),
    0 18px 50px -12px rgba(0,0,0,.6), 0 4px 14px rgba(0,0,0,.28);
  color: #f3eee4;
  opacity: 0; transform: translateY(18px);
  transition: opacity .2s cubic-bezier(.22,1,.36,1), transform .34s cubic-bezier(.22,1,.36,1);
  outline: none;
}
.tk-box.on { opacity: 1; transform: none; }
.tk-box.rm { transform: none; transition: opacity .15s linear; }

/* portrait stands out of the box's top-left */
.tk-port {
  position: absolute; left: 14px; bottom: 14px; width: 118px; height: 132px;
  border-radius: 16px; overflow: hidden;
  background:
    radial-gradient(120% 90% at 50% 15%, rgba(255,255,255,.35), rgba(255,255,255,0) 60%),
    var(--tk-accent);
  box-shadow: 0 0 0 3px #17151c, 0 0 0 4.5px rgba(255,255,255,.14), 0 10px 22px rgba(0,0,0,.4);
  transform: rotate(-2deg);
  transition: transform .3s cubic-bezier(.34,1.56,.64,1);
}
.tk-cv { width: 100%; height: 100%; display: block; }

.tk-name {
  position: absolute; z-index: 2; top: -15px; left: calc(var(--tk-pad-l) - 4px);
  display: flex; align-items: baseline; gap: 8px;
  padding: 5px 12px 6px; border-radius: 999px;
  background: var(--tk-accent); color: var(--tk-on);
  font: 700 calc(14px * var(--ts, 1))/1 var(--tk-round); letter-spacing: .01em;
  box-shadow: 0 0 0 3px #17151c;
  white-space: nowrap;
}
.tk-role { font: 600 calc(11px * var(--ts, 1))/1 -apple-system, system-ui, sans-serif; opacity: .72; letter-spacing: .02em; }
.tk-role:empty { display: none; }

.tk-body { position: relative; max-height: calc(38vh - 38px); overflow: auto; overscroll-behavior: contain; touch-action: pan-y; }
.tk-text {
  font-size: calc(18px * var(--ts, 1)); line-height: 1.42; font-weight: 500;
  letter-spacing: -.005em; text-wrap: pretty;
}
.tk-text.swap { animation: tkSwap .18s cubic-bezier(.22,1,.36,1); }
@keyframes tkSwap { from { opacity: .35; } to { opacity: 1; } }
.tk-ghost { color: transparent; }

.tk-more {
  position: absolute; right: 16px; bottom: 12px; width: 26px; height: 26px; border-radius: 50%;
  display: grid; place-items: center; font-size: 15px; line-height: 1; color: var(--tk-on); background: var(--tk-accent);
  opacity: 0; transform: scale(.6); transition: opacity .15s, transform .2s cubic-bezier(.34,1.56,.64,1);
}
.tk-more.on { opacity: 1; transform: none; }
.tk-more.on span { display: block; animation: tkNudge 1.1s ease-in-out infinite; }
@keyframes tkNudge { 0%, 100% { transform: translateX(0); } 50% { transform: translateX(3px); } }

/* ---------- "you" lines: cream reply bubble, right-aligned, no portrait ---------- */
.tk-box.you {
  align-self: flex-end; width: fit-content; min-width: 200px; max-width: min(72%, 640px);
  min-height: 0; padding: 22px 48px 14px 20px; border-radius: 20px 20px 6px 20px;
  background: var(--tk-paper); color: var(--tk-ink);
  box-shadow: inset 0 0 0 1px rgba(31,45,43,.08), 0 16px 40px -14px rgba(0,0,0,.55), 0 3px 10px rgba(0,0,0,.2);
  text-align: right;
}
.tk-box.you .tk-port { display: none; }
.tk-box.you .tk-name {
  left: auto; right: 18px; background: #0e7f78; color: #f8f2e6; box-shadow: 0 0 0 3px var(--tk-paper);
}
.tk-box.you .tk-more { background: #0e7f78; color: #f8f2e6; }

/* ---------- choices: reply chips stacked above the box, right-aligned ---------- */
.tk-choices {
  align-self: flex-end; display: flex; flex-direction: column; align-items: flex-end; gap: 7px;
  max-width: min(68%, 600px);
}
.tk-choices:empty { display: none; }
.tk-choice {
  pointer-events: auto; cursor: pointer; border: 0; margin: 0;
  display: flex; align-items: center; gap: 10px; text-align: left;
  min-height: 46px; padding: 9px 18px 9px 10px;
  border-radius: 16px 16px 5px 16px;
  background: var(--tk-paper); color: var(--tk-ink);
  font: 600 calc(16px * var(--ts, 1))/1.25 -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  box-shadow: inset 0 0 0 1px rgba(31,45,43,.08), 0 2px 0 #d9ccb2, 0 12px 26px -10px rgba(0,0,0,.55);
  opacity: 0; transform: translateY(10px) scale(.97);
  transition: opacity .2s cubic-bezier(.22,1,.36,1), transform .3s cubic-bezier(.34,1.4,.64,1),
              background-color .12s, box-shadow .12s;
}
.tk-choices.on .tk-choice { opacity: 1; transform: none; }
.tk-choice:hover { background: #fffaf0; }
.tk-choice:active { transform: scale(.97); transition-duration: 70ms; transition-delay: 0s !important; }
.tk-choice:focus-visible { outline: 3px solid #f0b23a; outline-offset: 2px; }
.tk-key {
  flex: none; width: 26px; height: 26px; border-radius: 9px; display: grid; place-items: center;
  background: #0e7f78; color: #f8f2e6; font: 700 13px/1 var(--tk-round);
}
.tk-choice.picked { background: #0e7f78; color: #f8f2e6; transform: scale(1.02); transition-delay: 0s !important; }
.tk-choice.picked .tk-key { background: #f8f2e6; color: #0e7f78; }
.tk-choice.dropped { opacity: 0 !important; transform: translateX(14px) !important; transition-delay: 0s !important; }

/* ---------- desktop: more air ---------- */
@media (min-width: 1000px) and (min-height: 620px) {
  .tk-root { --tk-pad-l: 186px; }
  .tk-wrap { bottom: 22px; gap: 12px; }
  .tk-box { min-height: 140px; padding: 28px 54px 22px var(--tk-pad-l); border-radius: 24px; }
  .tk-port { width: 150px; height: 170px; left: 18px; bottom: 18px; border-radius: 20px; }
  .tk-text { font-size: calc(21px * var(--ts, 1)); }
  .tk-name { font-size: calc(16px * var(--ts, 1)); padding: 6px 14px 7px; top: -17px; }
  .tk-choice { font-size: calc(17px * var(--ts, 1)); min-height: 50px; }
}
/* ---------- short phones: tighter box so the 3D stays visible ---------- */
@media (max-height: 430px) {
  .tk-root { --tk-pad-l: 132px; }
  .tk-wrap { bottom: max(8px, env(safe-area-inset-bottom)); gap: 7px; }
  .tk-box { min-height: 98px; padding: 19px 42px 12px var(--tk-pad-l); }
  .tk-port { width: 104px; height: 118px; left: 12px; bottom: 10px; }
  .tk-text { font-size: calc(16.5px * var(--ts, 1)); line-height: 1.38; }
  .tk-choice { min-height: 44px; padding: 7px 16px 7px 9px; font-size: calc(15px * var(--ts, 1)); }
  .tk-choices { gap: 6px; }
}
/* ---------- phone is up: live in the space left of the phone + "Put down" (set from JS) ---------- */
.tk-root.phone .tk-wrap { right: var(--tk-right, 50%); max-width: none; }
.tk-root.phone { --tk-pad-l: 96px; }
.tk-root.phone .tk-box { min-height: 0; padding: 20px 38px 14px var(--tk-pad-l); }
.tk-root.phone .tk-port { width: 72px; height: 82px; left: 12px; bottom: 12px; border-radius: 13px; }
.tk-root.phone .tk-text { font-size: calc(16px * var(--ts, 1)); line-height: 1.36; }
.tk-root.phone .tk-choices { max-width: 100%; }
.tk-root.phone .tk-box.you { max-width: 100%; }
@media (prefers-reduced-motion: reduce) {
  .tk-more.on span { animation: none; }
}
