/* css/kim.css: Kim, the AI chat. Entry points on the home page (symptom cards, the Talk to Kim line, the
   "Is this you?" blocks) and the full-screen chat panel that js/kim.js builds. Palette tokens only. */

/* ---------------------------------------------------------------- entry points
   Without the script none of these do anything, so they stay hidden. */
html:not(.js) .kim-go, html:not(.js) .kim-talk, html:not(.js) .five-hint, html:not(.js) .who-go { display: none; }
.kim-ic { flex: none; width: 1.3em; height: 1.3em; display: block; }

/* Talk to Kim: one line under the two hero buttons, as wide as both together. The wrapper shrinks to the
   buttons' row, the line fills it. */
.hero-cta { width: fit-content; max-width: 100%; margin: 30px 0 30px; }
.hero-cta .hero-actions { margin: 0; }
.kim-talk {
  display: flex; align-items: center; justify-content: center; gap: .6em; width: 100%; margin-top: 20px; padding: .8em 1.2em;
  border: 1.5px solid var(--forest); border-radius: 3px; background: color-mix(in oklab, var(--forest) 8%, var(--bg));
  color: var(--forest); font: 600 1rem/1.2 var(--f-body); letter-spacing: -0.005em; cursor: pointer;
  transition: background-color .18s ease, color .18s ease, translate .25s var(--ease-out), box-shadow .25s var(--ease-out);
}
.kim-talk::after { content: "\2192"; margin-left: .15em; transition: translate .25s var(--ease-out); }
.kim-talk:focus-visible { outline: 2px solid var(--forest); outline-offset: 3px; }
@media (hover: hover) {
  .kim-talk:hover { background: var(--accent); color: var(--accent-ink); translate: 0 -2px; box-shadow: var(--shadow); }
  .kim-talk:hover::after { translate: 4px 0; }
}

/* Symptom cards: the whole card is the target; the chat icon at its bottom right is the button the keyboard and
   screen readers reach. Its ::after stretches over the card. */
.five-card { position: relative; }
.kim-go {
  grid-row: 3; justify-self: end; align-self: end; margin-top: -2px;
  display: grid; place-items: center; width: 40px; height: 40px; padding: 0;
  border: 1.5px solid var(--forest); border-radius: 50%; background: color-mix(in oklab, var(--forest) 8%, var(--bg));
  color: var(--forest); cursor: pointer; transition: background-color .18s ease, color .18s ease, scale .3s var(--ease-spring);
}
.kim-go .kim-ic { width: 22px; height: 22px; }
.kim-go::after { content: ""; position: absolute; inset: 0; border-radius: 4px; }
.kim-go:focus-visible { outline: 2px solid var(--forest); outline-offset: 3px; }
.kim-go:focus-visible::after { outline: 2px solid var(--forest); outline-offset: 2px; }
@media (hover: hover) {
  .five-card:hover .kim-go { background: var(--accent); color: var(--accent-ink); scale: 1.08; }
}
.five-hint {
  margin: 14px min(0px, calc((100% - min(1320px, 100vw - 56px)) / 2)) 0; text-align: right;
  font-size: .8rem; letter-spacing: .02em; color: var(--muted);
}
.five-hint::before { content: "\2191"; margin-right: .5em; color: var(--forest); }
@media (max-width: 640px) {
  .five-card { grid-template-rows: auto auto; }
  .five-card .five-art { grid-row: 1 / span 2; grid-column: 1; }
  .five-card .five-q { grid-column: 2; grid-row: 1; align-self: end; }
  .kim-go { grid-column: 2; grid-row: 2; align-self: start; margin-top: 0; width: 36px; height: 36px; }
  .kim-go .kim-ic { width: 20px; height: 20px; }
}
/* "Chat with me": js/kim.js puts this bubble on one of the five cards, chosen at random on each page load. It springs
   in when its card scrolls into view. On a wide screen it straddles the card's top edge; on a phone the card gets
   room above it, so the bubble never sits on card text. */
.kim-bub {
  position: absolute; right: 14px; bottom: calc(100% - 8px); z-index: 3;
  margin: 0; padding: 8px 14px; border: 0; border-radius: 999px; white-space: nowrap; cursor: pointer;
  font: 600 .84rem/1 var(--f-body); color: #ffffff; background: var(--accent-side);
  box-shadow: 0 6px 18px -8px var(--accent-side);
  opacity: 0; scale: .3; transform-origin: 85% 130%; pointer-events: none;
  transition: opacity .2s ease, scale .5s var(--ease-spring), background-color .18s ease;
}
.kim-bub::before, .kim-bub::after { content: ""; position: absolute; border-radius: 50%; background: var(--accent-side); }
.kim-bub::before { width: 8px; height: 8px; right: 22px; bottom: -7px; }
.kim-bub::after { width: 4px; height: 4px; right: 18px; bottom: -12px; }
.kim-bub.is-in { opacity: 1; scale: 1; pointer-events: auto; animation: kim-bob 3.4s ease-in-out .7s infinite; }
.kim-bub:focus-visible { outline: 2px solid var(--forest); outline-offset: 3px; }
@media (hover: hover) { .kim-bub:hover { background: var(--forest); color: var(--accent-ink); } .kim-bub:hover::before, .kim-bub:hover::after { background: var(--forest); } }
@keyframes kim-bob { 0%, 100% { translate: 0 0; } 50% { translate: 0 -3px; } }
@media (max-width: 640px) {
  .five-card.has-bub { margin-top: 32px; }
  .five-card.has-bub:first-child { margin-top: 0; }
  .kim-bub { bottom: calc(100% + 9px); }
}
@media (max-width: 960px) { .hero-cta { margin-bottom: 0; } }

/* Who we work with: a closed block hides its text from the tab key; an open block ends in the line that sends
   the visitor to the chat. */
.js .who-item:not(.is-open) .who-more { visibility: hidden; transition: visibility 0s .34s; }
.who-go {
  display: block; width: 100%; margin: 0; padding: 11px 14px 13px 16px; border: 0; border-top: 1px dashed var(--line-2);
  background: color-mix(in oklab, var(--forest) 9%, transparent); color: var(--forest);
  font: 600 .88rem/1.35 var(--f-body); text-align: left; cursor: pointer;
}
.who-go::after { content: "\2192"; margin-left: .45em; }
.who-go:focus-visible { outline: 2px solid var(--forest); outline-offset: -3px; }
@media (hover: hover) { .who-go:hover { background: var(--accent); color: var(--accent-ink); } }

/* ---------------------------------------------------------------- the panel */
html.kim-open { overflow: hidden; }
html.kim-open .cursor, html.kim-open .progress { display: none; }
.kim-panel {
  position: fixed; left: 0; right: 0; top: 0; z-index: 10000; height: var(--kim-h, 100vh); height: var(--kim-h, 100dvh);
  display: flex; flex-direction: column; background: var(--bg-2); color: var(--ink);
  font: 400 1rem/1.55 var(--f-body); overscroll-behavior: contain;
  animation: kim-in .24s var(--ease-out) both;
}
@keyframes kim-in { from { opacity: 0; translate: 0 14px; } to { opacity: 1; translate: 0 0; } }
.kim-panel * { box-sizing: border-box; }
.kim-sr { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.kim-col { width: 100%; max-width: 780px; margin: 0 auto; padding-left: 20px; padding-right: 20px; }

.kim-head { flex: none; background: var(--bg); border-bottom: 1px solid var(--line-2); }
.kim-head-in { display: flex; align-items: center; gap: 14px; padding-top: 12px; padding-bottom: 12px; }
.kim-av {
  flex: none; display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%;
  background: var(--accent); color: var(--accent-ink); font: 700 1.1rem/1 var(--f-body);
}
.kim-who { min-width: 0; flex: 1; }
.kim-title { margin: 0; font: 700 1.1rem/1.2 var(--f-body); letter-spacing: -0.005em; }
.kim-sub { margin: 2px 0 0; font-size: .8rem; line-height: 1.3; color: var(--muted); }
.kim-ref { margin: 0; flex: none; text-align: right; font-size: .78rem; line-height: 1.3; color: var(--muted); }
.kim-ref b { display: block; font-size: .95rem; letter-spacing: .06em; color: var(--ink); }
.kim-close {
  flex: none; display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 14px;
  border: 1.5px solid var(--line-2); border-radius: 3px; background: var(--bg); color: var(--ink);
  font: 600 .9rem/1 var(--f-body); cursor: pointer; transition: border-color .15s ease, background-color .15s ease;
}
.kim-close svg { width: 16px; height: 16px; }
.kim-close:hover { border-color: var(--ink); background: var(--bg-2); }
.kim-panel :is(button, a, input, textarea):focus-visible { outline: 2px solid var(--forest); outline-offset: 2px; }

.kim-scroll { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
.kim-scroll:focus { outline: none; }
.kim-log { display: flex; flex-direction: column; gap: 14px; padding-top: 24px; padding-bottom: 28px; }

/* messages */
.kim-msg { display: flex; flex-direction: column; gap: 8px; max-width: 100%; }
.kim-msg--kim { align-items: flex-start; }
.kim-msg--you { align-items: flex-end; }
.kim-b {
  max-width: min(100%, 640px); padding: 11px 15px; border-radius: 16px 16px 16px 4px; overflow-wrap: anywhere;
  background: var(--bg); border: 1px solid var(--line-2);
}
.kim-b p { margin: 0; }
.kim-b p + p { margin-top: .7em; }
.kim-msg--you .kim-b { border-radius: 16px 16px 4px 16px; background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.kim-msg--kim + .kim-msg--kim { margin-top: -6px; }
.kim-lbl { margin: 0 0 -4px 4px; font-size: .75rem; letter-spacing: .04em; color: var(--muted); }
.kim-ctx {
  align-self: center; max-width: min(100%, 560px); margin: 0 0 4px; padding: 8px 14px; border-radius: 12px; text-align: center;
  font-size: .9rem; line-height: 1.4; color: var(--ink); overflow-wrap: anywhere;
  background: color-mix(in oklab, var(--ochre) 13%, var(--bg)); border: 1px solid color-mix(in oklab, var(--ochre) 45%, var(--line-2));
}
.kim-note { align-self: center; max-width: 100%; margin: 0; font-size: .82rem; color: var(--muted); text-align: center; }

.kim-typing .kim-b { display: flex; align-items: center; gap: 5px; padding: 15px 16px; }
.kim-typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); animation: kim-dot 1.1s ease-in-out infinite; }
.kim-typing i:nth-child(2) { animation-delay: .16s; }
.kim-typing i:nth-child(3) { animation-delay: .32s; }
@keyframes kim-dot { 0%, 60%, 100% { opacity: .35; translate: 0 0; } 30% { opacity: 1; translate: 0 -4px; } }

.kim-err { align-self: stretch; max-width: 640px; padding: 12px 15px; border-radius: 6px; background: var(--bg); border: 1.5px solid var(--bark); }
.kim-err p { margin: 0; }
.kim-err p::before { content: "!"; display: inline-grid; place-items: center; width: 1.25em; height: 1.25em; margin-right: .6em; border-radius: 50%; background: var(--bark); color: var(--bg); font: 700 .8em/1 var(--f-body); }
.kim-acts { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; }

/* buttons */
.kim-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5em; min-height: 44px; padding: 0 20px;
  border: 1.5px solid var(--accent); border-radius: 3px; background: var(--accent); color: var(--accent-ink);
  font: 600 .95rem/1.2 var(--f-body); text-decoration: none; cursor: pointer;
  transition: background-color .15s ease, color .15s ease, border-color .15s ease;
}
.kim-btn:hover { background: var(--accent-side); border-color: var(--accent-side); color: var(--accent-ink); }
html[data-theme="dark"] .kim-btn:hover { color: var(--ink); }
.kim-btn--ghost { background: var(--bg); color: var(--forest); }
.kim-btn--ghost:hover { background: color-mix(in oklab, var(--forest) 12%, var(--bg)); border-color: var(--forest); color: var(--forest); }
.kim-btn[disabled] { opacity: .5; cursor: not-allowed; }
html[data-theme="dark"] .kim-btn--ghost:hover { color: var(--forest); }

/* the composer */
.kim-foot { flex: none; background: var(--bg); border-top: 1px solid var(--line-2); padding-bottom: env(safe-area-inset-bottom); }
.kim-foot .kim-col { padding-top: 12px; padding-bottom: 10px; }
.kim-left { margin: 0 0 8px; font-size: .82rem; color: var(--bark); }
.kim-box { border: 1.5px solid var(--line-2); border-radius: 8px; background: var(--bg); transition: border-color .15s ease; }
.kim-box:focus-within { border-color: var(--forest); box-shadow: 0 0 0 3px color-mix(in oklab, var(--forest) 22%, transparent); }
.kim-box.is-over { border-color: var(--bark); }
.kim-text {
  display: block; width: 100%; min-height: 3.1em; max-height: 38vh; padding: 12px 14px 4px; border: 0; border-radius: 8px 8px 0 0; resize: none;
  background: transparent; color: var(--ink); font: 400 1rem/1.5 var(--f-body); /* 16px keeps iOS from zooming */
}
.kim-text:focus, .kim-panel .kim-text:focus-visible { outline: none; }
.kim-text::placeholder { color: var(--muted); opacity: 1; }
.kim-text[disabled] { opacity: .6; }
.kim-tools { display: flex; align-items: center; gap: 10px; padding: 6px 8px 8px 10px; }
.kim-attach {
  display: inline-flex; align-items: center; gap: 7px; min-height: 40px; padding: 0 10px; border: 1px solid var(--line-2); border-radius: 3px;
  background: transparent; color: var(--ink); font: 500 .85rem/1 var(--f-body); cursor: pointer;
}
.kim-attach svg { width: 16px; height: 16px; }
.kim-attach:hover { border-color: var(--ink); }
.kim-attach[disabled] { opacity: .5; cursor: not-allowed; }
.kim-count { margin-left: auto; font-size: .78rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.kim-count.is-near { color: var(--bark); }
.kim-count.is-over { color: var(--bark); font-weight: 700; }
.kim-send { min-width: 84px; }
.kim-fine { margin: 8px 0 0; font-size: .78rem; line-height: 1.4; color: var(--muted); }
.kim-fine a { color: var(--forest); text-underline-offset: 2px; }

/* the "not available yet" and start-up cards */
.kim-solo { align-self: center; width: 100%; max-width: 520px; margin-top: 8vh; padding: 28px 26px; border: 1px solid var(--line-2); border-radius: 8px; background: var(--bg); box-shadow: var(--shadow); }
.kim-solo h3 { margin: 0 0 8px; font: 700 1.35rem/1.2 var(--f-body); }
.kim-solo p { margin: 0; color: var(--muted); }
.kim-solo .kim-acts { margin-top: 18px; }

/* ---------------------------------------------------------------- charts (drawn by js/kim.js from the data) */
.kim-chart {
  width: 100%; max-width: 640px; margin: 0; padding: 14px 14px 10px; border: 1px solid var(--line-2); border-radius: 8px; background: var(--bg);
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
}
.kim-chart figcaption { margin: 0 0 8px; font: 700 .95rem/1.3 var(--f-body); overflow-wrap: anywhere; }
.kim-chart svg { display: block; width: 100%; height: auto; overflow: visible; pointer-events: none; }
.kch-t { fill: var(--ink); font: 600 14px var(--f-body); }
.kch-s { fill: var(--muted); font: 500 12px var(--f-body); }
.kch-v { fill: var(--ink); font: 700 13px var(--f-body); }
.kch-box { fill: var(--bg-2); stroke: var(--line-2); stroke-width: 1.5; }
.kch-box.is-bn { fill: color-mix(in oklab, var(--ochre) 15%, var(--bg)); stroke: var(--ochre); stroke-width: 3.5; }
.kch-link { fill: none; stroke: var(--muted); stroke-width: 1.7; }
.kch-head { fill: var(--muted); }
.kch-tag { fill: var(--bark); }
.kch-tag-t { fill: var(--bg); font: 700 10.5px var(--f-body); letter-spacing: .05em; }
.kch-track { fill: var(--bg-3); }
.kch-bar { fill: var(--forest); }
.kch-bar.is-neg { fill: var(--bark); }
.kch-grid { stroke: var(--line); stroke-width: 1; }
.kch-axis { stroke: var(--line-2); stroke-width: 1.2; }
.kch-ln { fill: none; stroke: var(--forest); stroke-width: 2.6; stroke-linejoin: round; stroke-linecap: round; }
.kch-dot { fill: var(--bg); stroke: var(--forest); stroke-width: 2.4; }
.kch-s0 { fill: var(--forest); stroke: var(--forest); }
.kch-s1 { fill: var(--ochre); stroke: var(--ochre); }
.kch-s2 { fill: var(--ocean); stroke: var(--ocean); }
.kch-s3 { fill: var(--sand); stroke: var(--sand); }
.kch-s4 { fill: var(--moss); stroke: var(--moss); }
.kch-s5 { fill: var(--bark); stroke: var(--bark); }
.kch-ring { fill: none; }
.kch-sw { stroke: none; }

/* ---------------------------------------------------------------- booking and hand-off cards */
.kim-card { width: 100%; max-width: 640px; padding: 16px 16px 18px; border: 1px solid var(--line-2); border-radius: 8px; background: var(--bg); }
.kim-card h3 { margin: 0; font: 700 1.05rem/1.3 var(--f-body); }
.kim-card .kim-small { margin: 4px 0 0; font-size: .82rem; color: var(--muted); }
.kim-seg { display: inline-flex; margin: 14px 0 12px; border: 1.5px solid var(--forest); border-radius: 3px; overflow: hidden; }
.kim-seg label { position: relative; display: block; }
.kim-seg input { position: absolute; inset: 0; opacity: 0; cursor: pointer; margin: 0; }
.kim-seg span { display: block; min-height: 44px; padding: 0 18px; line-height: 44px; font: 600 .9rem/44px var(--f-body); color: var(--forest); background: var(--bg); }
.kim-seg input:checked + span { background: var(--accent); color: var(--accent-ink); }
.kim-seg label:focus-within { outline: 2px solid var(--forest); outline-offset: 2px; }
.kim-day { margin: 0 0 14px; }
.kim-day svg { display: block; width: 100%; height: auto; overflow: visible; }
.kd-bg { fill: var(--bg-3); }
.kd-hour { stroke: var(--line-2); stroke-width: 1; }
.kd-lbl { fill: var(--muted); font: 500 11px var(--f-body); }
.kd-blk { fill: color-mix(in oklab, var(--forest) 55%, var(--bg)); stroke: var(--bg); stroke-width: 1; cursor: pointer; transition: fill .12s ease; }
.kd-blk.is-hi { fill: var(--ochre); }
.kd-blk.is-picked { fill: var(--bark); }
.kim-chips { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 8px; }
.kim-chip {
  min-height: 44px; padding: 0 8px; border: 1.5px solid var(--forest); border-radius: 3px; background: var(--bg); color: var(--forest);
  font: 600 .92rem/1 var(--f-body); font-variant-numeric: tabular-nums; cursor: pointer; transition: background-color .12s ease, color .12s ease;
}
.kim-chip:hover, .kim-chip.is-hi { background: var(--accent); color: var(--accent-ink); }
.kim-chip.is-picked { background: var(--bark); border-color: var(--bark); color: var(--bg); }
.kim-chip[disabled] { cursor: default; }
.kim-chip[disabled]:not(.is-picked) { opacity: .45; }
.kim-empty { margin: 4px 0 0; color: var(--muted); }

.kim-form-card .kim-sum { margin: 10px 0 0; padding: 10px 12px; border-left: 3px solid var(--forest); background: var(--bg-2); border-radius: 0 4px 4px 0; font-size: .95rem; }
.kim-sum p { margin: 0; }
.kim-sum p + p { margin-top: .6em; }
.kim-pickline { margin: 10px 0 0; font-weight: 600; }
.kim-fields { display: grid; gap: 12px; margin: 14px 0 0; }
.kim-field label { display: block; margin: 0 0 4px; font-size: .85rem; font-weight: 600; }
.kim-field label small { font-weight: 400; color: var(--muted); }
.kim-field input { display: block; width: 100%; min-height: 46px; padding: 0 12px; border: 1.5px solid var(--line-2); border-radius: 4px; background: var(--bg); color: var(--ink); font: 400 1rem/1.2 var(--f-body); }
.kim-field input:focus { outline: none; border-color: var(--forest); box-shadow: 0 0 0 3px color-mix(in oklab, var(--forest) 22%, transparent); }
.kim-field input[aria-invalid="true"] { border-color: var(--bark); }
.kim-field .kim-bad { margin: 4px 0 0; font-size: .82rem; color: var(--bark); font-weight: 600; }
.kim-consent { margin: 14px 0 0; font-size: .85rem; color: var(--muted); }
.kim-form-card .kim-btn { margin-top: 14px; width: 100%; }
.kim-done h3::before { content: "\2713"; display: inline-grid; place-items: center; width: 1.4em; height: 1.4em; margin-right: .5em; border-radius: 50%; background: var(--accent); color: var(--accent-ink); font-size: .85em; }
.kim-done p { margin: 8px 0 0; }
.kim-done .kim-ref2 { font-size: .85rem; color: var(--muted); }

/* ---------------------------------------------------------------- phones */
@media (max-width: 640px) {
  .kim-col { padding-left: 14px; padding-right: 14px; }
  .kim-head-in { gap: 10px; padding-top: 10px; padding-bottom: 10px; }
  .kim-av { width: 34px; height: 34px; font-size: .95rem; }
  .kim-title { font-size: 1rem; }
  .kim-sub { display: none; }
  .kim-close span { display: none; }
  .kim-close { width: 44px; padding: 0; justify-content: center; }
  .kim-log { padding-top: 16px; gap: 12px; }
  .kim-attach span { display: none; }
  .kim-attach { width: 44px; padding: 0; justify-content: center; }
  .kim-card { padding: 14px 13px 16px; }
  .kim-chips { grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); }
  .kim-solo { margin-top: 4vh; padding: 22px 18px; }
}

@media (prefers-reduced-motion: reduce) {
  .kim-bub, .kim-bub.is-in { transition: none; animation: none; scale: 1; }
  .kim-panel { animation: none; }
  .kim-typing i { animation: none; opacity: .7; }
  .kim-talk, .kim-talk::after, .kim-go, .kim-chip, .kd-blk { transition: none; }
}
.static .kim-panel { animation: none; }
.static .kim-bub, .static .kim-bub.is-in { transition: none; animation: none; scale: 1; }
.static .kim-typing i { animation: none; opacity: .7; }
.static .kim-talk, .static .kim-talk::after, .static .kim-go, .static .kim-chip, .static .kd-blk { transition: none; }
