/* Kith signature motion for the web: logo draw and Kith Assistant. Requires kith-tokens.css. */

/* ---- Logo draws itself (about 1.4 s). Add class "is-playing" to start; remove and re-add to replay.
   The K is cut by stroking in the ground color, so set --kith-logo-ground to whatever the logo sits on. */
.kith-logo-draw { --kith-logo-ground: var(--kith-oat); height: 120px; width: auto; overflow: visible; display: block; }
.kith-logo-draw .kl-wheel { fill: var(--kith-fern); transform-origin: 256px 214px; transform-box: view-box; }
.kith-logo-draw .kl-cut { fill: none; stroke: var(--kith-logo-ground); stroke-width: 36; stroke-linejoin: miter; stroke-miterlimit: 10; }
.kith-logo-draw .kl-cradle { fill: none; stroke: var(--kith-fern); stroke-width: 36; stroke-linejoin: miter; stroke-miterlimit: 10; }
.kith-logo-draw .kl-s { stroke-dasharray: 1 1; stroke-dashoffset: 1; }
.kith-logo-draw:not(.is-playing):not(.is-static) { opacity: 0; }
.kith-logo-draw.is-static .kl-s { stroke-dashoffset: 0; }
.kith-logo-draw.is-playing .kl-wheel { animation: kl-wheel 340ms cubic-bezier(.34,1.56,.64,1) both; }
.kith-logo-draw.is-playing .kl-s1 { animation: kl-stroke 260ms cubic-bezier(.4,0,.2,1) 310ms forwards; }
.kith-logo-draw.is-playing .kl-s2 { animation: kl-stroke 260ms cubic-bezier(.4,0,.2,1) 570ms forwards; }
.kith-logo-draw.is-playing .kl-s3 { animation: kl-stroke 570ms cubic-bezier(.3,0,.2,1) 830ms forwards; }
.kith-logo-draw.is-playing .kl-all { animation: kl-settle 600ms cubic-bezier(.34,1.8,.64,1) 800ms both; }
@keyframes kl-wheel { from { transform: scale(.6); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes kl-stroke { to { stroke-dashoffset: 0; } }
@keyframes kl-settle { 0% { transform: translateY(0); } 35% { transform: translateY(6px); } 100% { transform: translateY(0); } }
@media (prefers-reduced-motion: reduce) {
  .kith-logo-draw .kl-s { stroke-dashoffset: 0; animation: none !important; }
  .kith-logo-draw.is-playing .kl-wheel, .kith-logo-draw.is-playing .kl-all { animation: kl-fade 160ms ease both !important; }
}
@keyframes kl-fade { from { opacity: 0; } to { opacity: 1; } }

/* ---- Kith Assistant button. States: data-state="idle" | "listening" | "thinking".
   Markup: <button class="kith-assistant" data-state="idle" aria-label="Kith Assistant"><svg class="ka-glyph">…</svg><span class="ka-ring" aria-hidden="true"></span></button> */
.kith-assistant { --size: 60px; position: relative; width: var(--size); height: var(--size); border-radius: 50%; border: 0; padding: 0; cursor: pointer;
  background: var(--kith-assistant); color: var(--kith-on-assistant); display: grid; place-items: center;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.5), 0 8px 22px rgba(80,60,0,.25); transition: transform var(--kith-dur-press) var(--kith-ease-standard); }
.kith-assistant:active { transform: scale(.96); }
.kith-assistant .ka-glyph { position: relative; z-index: 1; width: 54%; height: 54%; fill: currentColor; transform: translate(1.4%, 5%); /* optical centering */ }
.kith-assistant::before { content: ""; position: absolute; inset: -24%; border-radius: 50%; pointer-events: none; opacity: 0;
  background: radial-gradient(circle, color-mix(in srgb, var(--kith-assistant) 90%, transparent) 30%, transparent 70%); transition: opacity 300ms var(--kith-ease-out); }
.kith-assistant[data-state="listening"]::before { opacity: 1; animation: ka-breathe 1600ms ease-in-out infinite; }
.kith-assistant[data-state="thinking"]::before { opacity: 1; animation: ka-breathe 2600ms ease-in-out infinite; }
@keyframes ka-breathe { 0%, 100% { transform: scale(.8); opacity: .2; } 50% { transform: scale(1.14); opacity: 1; } }
/* Circling light: a fading tail with a round head. Ring band is 8.7% of the button size, sitting just outside it. */
.kith-assistant .ka-ring { position: absolute; inset: -13%; border-radius: 50%; opacity: 0; pointer-events: none; transition: opacity 300ms var(--kith-ease-out); }
.kith-assistant .ka-ring::before { content: ""; position: absolute; inset: 0; border-radius: 50%;
  background: conic-gradient(from 0deg, transparent 0 3%, color-mix(in srgb, var(--kith-assistant-ring) 25%, transparent) 14%, var(--kith-assistant-ring) 32%, transparent 32%);
  -webkit-mask: radial-gradient(closest-side, transparent calc(100% - 13.5%), #000 calc(100% - 13%), #000 calc(100% - .8%), transparent 100%);
          mask: radial-gradient(closest-side, transparent calc(100% - 13.5%), #000 calc(100% - 13%), #000 calc(100% - .8%), transparent 100%); }
/* Round head: a dot at the end of the tail (32% of a turn), centered on the band. */
.kith-assistant .ka-ring::after { content: ""; position: absolute; width: 6.5%; height: 6.5%; border-radius: 50%; background: var(--kith-assistant-ring);
  left: calc(50% + 46.5% * 0.9048 - 3.25%); top: calc(50% - 46.5% * -0.4258 - 3.25%); }
.kith-assistant[data-state="thinking"] .ka-ring { opacity: 1; animation: ka-spin 2400ms linear infinite; }
@keyframes ka-spin { to { transform: rotate(1turn); } }
@media (prefers-reduced-motion: reduce) { .kith-assistant::before, .kith-assistant .ka-ring { animation: none !important; } }

/* ---- Press and springs */
.kith-press { transition: transform var(--kith-dur-press) var(--kith-ease-standard); }
.kith-press:active { transform: scale(.96); }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition-duration: 160ms !important; animation-duration: 160ms !important; } }
