/* The "talk to me" overlay: the hero portrait on the left, the conversation on the right.
   Paper / ink / amber tokens come from styles.css. All classes are prefixed tk- to stay clear of the page. */
html:has(.tk[open]) { overflow: hidden; }

.tk {
  padding: 0; margin: auto;
  width: min(1040px, calc(100vw - 32px));
  height: min(680px, calc(100dvh - 32px));
  border: 0; background: transparent; color: var(--ink);
  box-shadow: none;
  overflow: hidden;
}
.tk[open] { display: grid; grid-template-columns: 5fr 7fr; animation: tk-in .28s ease-out; }
.tk::backdrop { background: color-mix(in srgb, var(--paper, #F3EEE4) 8%, transparent); -webkit-backdrop-filter: blur(18px) saturate(1.1); backdrop-filter: blur(18px) saturate(1.1); animation: tk-fade .28s ease-out; }
@keyframes tk-in { from { opacity: 0; transform: translateY(14px) scale(.985); } }
@keyframes tk-fade { from { opacity: 0; } }
.tk [hidden] { display: none !important; }
.tk .visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---- stage: the portrait ---- */
.tk-stage { position: relative; overflow: hidden; display: flex; align-items: flex-end; justify-content: center; }
.tk-portrait { position: relative; height: 100%; max-width: 100%; object-fit: contain; object-position: center bottom; }
.tk-halo {
  position: absolute; left: 50%; top: 46%; width: 78%; aspect-ratio: 1; translate: -50% -50%;
  border-radius: 50%; background: radial-gradient(circle, color-mix(in srgb, var(--amber, #D9952E) 55%, transparent), transparent 68%);
  opacity: 0; transition: opacity .4s;
}
.tk[data-state="thinking"] .tk-halo { opacity: .45; animation: tk-breathe 1.6s ease-in-out infinite; }
.tk[data-state="speaking"] .tk-halo { opacity: .9; animation: tk-breathe 1.1s ease-in-out infinite; }
.tk[data-state="listening"] .tk-halo { opacity: .7; animation: tk-breathe 0.8s ease-in-out infinite; }
@keyframes tk-breathe { 50% { scale: 1.1; } }
.tk-caption { position: absolute; left: 16px; bottom: 14px; display: flex; flex-direction: column; gap: 2px; }
.tk-name { font: 22px/1 var(--serif); }
.tk-state { font: 12px var(--mono); color: var(--muted); }
.tk[data-state="speaking"] .tk-state::before, .tk[data-state="thinking"] .tk-state::before, .tk[data-state="listening"] .tk-state::before {
  content: ""; display: inline-block; width: 7px; height: 7px; margin-right: 6px; border-radius: 50%; background: var(--amber); animation: tk-blink 1s ease-in-out infinite;
}
@keyframes tk-blink { 50% { opacity: .25; } }

/* ---- panel: the conversation ---- */
.tk-panel { display: flex; flex-direction: column; min-height: 0; padding: 14px 20px 16px; gap: 12px; }
.tk-bar { display: flex; align-items: center; justify-content: space-between; }
.tk-kicker { font: 13px var(--mono); color: var(--muted); }
.tk-tools { display: flex; align-items: center; gap: 4px; margin-left: auto; }
.tk-icon { display: grid; place-items: center; width: 34px; height: 34px; padding: 0; border: 0; border-radius: 50%; background: none; color: var(--ink); cursor: pointer; }
.tk-icon:hover { background: var(--tint); }
.tk-icon svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.tk-icon svg .tk-spk { fill: currentColor; stroke-width: 1; }
.tk-icon[aria-pressed="true"] .tk-mute, .tk-icon[aria-pressed="false"] .tk-wave { display: none; }

/* the info icon is deliberately faint; its note shows on hover or keyboard focus (and on tap) */
.tk-info { position: relative; }
.tk-i { color: var(--muted); opacity: .5; transition: opacity .2s; }
.tk-i:hover, .tk-i:focus-visible, .tk-info:focus-within .tk-i { opacity: 1; }
.tk-tip {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 5; width: min(320px, 78vw);
  padding: 12px 14px; background: var(--ink); color: var(--paper); border-radius: 8px;
  font: 13px/1.55 system-ui, sans-serif; text-align: left;
  opacity: 0; visibility: hidden; transform: translateY(-4px); transition: opacity .18s, transform .18s, visibility .18s;
}
.tk-tip b { display: block; margin-bottom: 4px; font: 500 12px var(--mono); color: var(--amber); }
.tk-info:hover .tk-tip, .tk-info:focus-within .tk-tip { opacity: 1; visibility: visible; transform: none; }

.tk-log { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 16px; padding: 4px 4px 4px 0; scrollbar-width: thin; scrollbar-color: var(--rule) transparent; }
.tk-msg { margin: 0; line-height: 1.55; overflow-wrap: anywhere; }
.tk-ai { max-width: 94%; padding-left: 14px; border-left: 2px solid var(--amber); font: 18px/1.55 system-ui, sans-serif; }
.tk-user { align-self: flex-end; max-width: 82%; padding: 8px 12px; background: var(--tint); border-radius: 12px 12px 2px 12px; font: 14px/1.5 var(--mono); }
.tk-pending { color: var(--muted); }
.tk-pending::after { content: ""; display: inline-block; width: 1.4em; height: .3em; margin-left: 4px; background: radial-gradient(circle, currentColor 45%, transparent 50%) 0 50% / .5em 100% repeat-x; animation: tk-blink 1s ease-in-out infinite; }
.tk-sources { display: block; margin-top: 8px; font: 12px var(--mono); color: var(--muted); }

.tk-suggest { display: flex; flex-wrap: wrap; gap: 8px; }
.tk-chip { font: 13px var(--mono); padding: 7px 12px; border: 1px solid var(--ink); border-radius: 999px; background: transparent; color: inherit; cursor: pointer; }
.tk-chip:hover, .tk-chip:focus-visible { background: var(--amber); }

.tk-ask { display: flex; align-items: flex-end; gap: 8px; padding: 6px 6px 6px 14px; border: 1px solid var(--ink); border-radius: 26px; background: color-mix(in srgb, var(--tint, #EAE3D6) 60%, transparent); }
.tk-ask:focus-within { outline: 2px solid var(--amber); outline-offset: 2px; }
.tk-ask textarea { flex: 1; min-width: 0; max-height: 96px; padding: 9px 0; border: 0; outline: 0; resize: none; background: transparent; color: inherit; font: 16px/1.4 system-ui, sans-serif; }
.tk-round { display: grid; place-items: center; flex: none; width: 40px; height: 40px; padding: 0; border: 1px solid var(--ink); border-radius: 50%; background: transparent; color: var(--ink); cursor: pointer; }
.tk-round svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tk-send { background: var(--ink); color: var(--paper); }
.tk-send:hover { background: var(--amber); color: var(--ink); }
.tk-round[disabled] { opacity: .4; cursor: default; }
.tk-mic[aria-pressed="true"] { background: var(--amber); animation: tk-ring 1.2s ease-out infinite; }
@keyframes tk-ring { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--amber, #D9952E) 55%, transparent); } 100% { box-shadow: 0 0 0 12px transparent; } }
.tk-note { min-height: 1.2em; margin: -4px 0 0; font: 12px var(--mono); color: var(--muted); }

.tk button:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }

/* ---- phones: full screen, portrait as a short strip on top ---- */
@media (max-width: 760px) {
  .tk { width: 100vw; height: 100dvh; max-width: none; max-height: none; border: 0; box-shadow: none; }
  .tk[open] { grid-template-columns: 1fr; grid-template-rows: minmax(0, 26dvh) minmax(0, 1fr); }
  .tk-stage { justify-content: flex-start; padding-left: 8%; }
  .tk-portrait { height: 100%; }
  .tk-halo { left: 22%; top: 50%; width: 60%; }
  .tk-caption { left: auto; right: 16px; bottom: auto; top: 50%; translate: 0 -50%; text-align: right; align-items: flex-end; }
  .tk-panel { padding: 10px 14px 14px; }
  .tk-ai { font-size: 17px; }
}
@media (prefers-reduced-motion: reduce) {
  .tk[open], .tk::backdrop, .tk-halo, .tk-mic { animation: none !important; }
  .tk-tip { transition: none; }
}
