/* Sugarpine site assistant. Two rest states, one markup.
   Desktop: a frosted input bar always sits bottom-center, rests narrow and springs wide on engage; the
   suggested questions ride above it while the bar has focus, and a panel opens above it once a turn is sent.
   Phone: a scroll-up dock (the primary CTA pill plus a round "?") that grows into the bar and a full sheet.
   Tokens only; light and dark follow base.css. Loaded after base.css on every page. */
.spc{position:fixed;left:50%;bottom:18px;z-index:150;font-family:var(--ui);color:var(--paper)}
.spc *{box-sizing:border-box}
.spc-glass{background:color-mix(in srgb,var(--pine-900) 72%,transparent);backdrop-filter:blur(16px) saturate(140%);-webkit-backdrop-filter:blur(16px) saturate(140%);border:1px solid var(--hairline);box-shadow:0 10px 34px rgba(10,11,10,.28)}
html.light .spc-glass{background:color-mix(in srgb,var(--pine-900) 90%,transparent);box-shadow:0 8px 28px rgba(25,27,20,.10)}

/* ---------- shared atoms ---------- */
.spc-bar{position:relative;display:flex;align-items:center;gap:6px;border-radius:999px}
.spc-input{flex:1;min-width:0;background:transparent;border:0;outline:0;color:var(--paper);font:inherit;font-size:15.5px;line-height:1.4;padding:6px 0}
.spc-input::placeholder{color:var(--sage)}
.spc-input:focus-visible{outline:0}
.spc-send{width:44px;height:44px;border-radius:50%;border:1px solid var(--hairline);background:var(--pine-700);color:var(--paper);display:grid;place-items:center;cursor:pointer;flex:0 0 auto}
.spc-send:disabled{opacity:.45;cursor:default}
.spc-send svg{width:18px;height:18px;stroke:currentColor;fill:none;stroke-width:2.2;stroke-linecap:round;stroke-linejoin:round}
.spc-chip{background:color-mix(in srgb,var(--pine-800) 80%,transparent);color:var(--paper);border:1px solid var(--hairline);border-radius:999px;padding:9px 16px;font:inherit;font-size:14px;line-height:1.3;min-height:44px;cursor:pointer;text-align:left}
.spc-chip:hover{border-color:var(--sage)}
.spc-title{flex:1;min-width:0;font-size:15px;font-weight:600;color:var(--paper)}
.spc-x{width:44px;height:44px;margin-right:-8px;border:0;border-radius:50%;background:transparent;color:var(--sage);font-size:22px;line-height:1;cursor:pointer;display:grid;place-items:center;flex:0 0 auto}
.spc-mark img{display:block;width:24px;height:24px;border-radius:6px}
.spc-thread{overflow-y:auto;overscroll-behavior:contain}
.spc-msg{margin:0 0 12px;font-size:15px;line-height:1.55;white-space:pre-wrap;word-wrap:break-word}
.spc-msg.user{color:var(--sage);padding-left:12px;border-left:2px solid var(--hairline)}
.spc-msg.bot{color:var(--paper)}
.spc-msg a{color:var(--paper);font-weight:600}
.spc-msg.wait{color:var(--sage-dim)}
.spc-scrim{display:none}
html.drawer-lock .spc,html.wlm-lock .spc,.exit.open ~ .spc,.wlm.open ~ .spc{display:none}

/* ---------- desktop: the bar is the rest state ---------- */
@media(min-width:721px){
  /* elastic: the bar rests narrow and springs wide the moment the visitor engages */
  .spc{width:min(380px,calc(100% - 24px));transform:translateX(-50%);transition:width .6s cubic-bezier(.34,1.6,.5,1)}
  .spc:focus-within,.spc.open{width:min(680px,calc(100% - 24px))}
  /* no dock furniture here: no launcher pill, no "?" */
  .spc-cta,.spc-q{display:none}
  .spc-dock{display:block}
  .spc-bar{padding:6px 6px 6px 18px}
  .spc-input{padding:8px 0}
  .spc:focus-within .spc-bar{border-color:var(--sage)}
  /* closed: the sheet is a pass-through so the chips can ride above the bar on their own */
  .spc-sheet{display:contents}
  .spc-head,.spc-thread{display:none}
  /* suggested questions only while the visitor is in the bar, so the pill never sits on top of page CTAs */
  .spc-chips{display:flex;flex-direction:column;align-items:flex-start;gap:8px;margin:0 0 10px 6px;opacity:0;visibility:hidden;transform:translateY(6px);transition:opacity .18s ease,transform .18s ease,visibility 0s linear .18s}
  .spc:focus-within .spc-chips{opacity:1;visibility:visible;transform:none;transition-delay:0s}
  .spc-chip{backdrop-filter:blur(12px);-webkit-backdrop-filter:blur(12px);box-shadow:0 6px 24px rgba(10,11,10,.18)}
  html.light .spc-chip{box-shadow:0 8px 28px rgba(25,27,20,.10)}
  /* open: one frosted panel (header, thread) above the bar */
  .spc.open .spc-sheet{display:flex;flex-direction:column;height:min(62vh,620px);background:color-mix(in srgb,var(--pine-900) 74%,transparent);backdrop-filter:blur(18px) saturate(140%);-webkit-backdrop-filter:blur(18px) saturate(140%);border:1px solid var(--hairline);border-radius:22px;padding:12px 16px 14px;margin-bottom:10px;box-shadow:0 18px 50px rgba(10,11,10,.3);overflow:hidden}
  html.light .spc.open .spc-sheet{box-shadow:0 14px 44px rgba(25,27,20,.14)}
  .spc.open .spc-head{display:flex;align-items:center;gap:10px;padding:2px 0 10px;margin-bottom:10px;border-bottom:1px solid var(--hairline-soft)}
  .spc.open .spc-thread{display:block;flex:1;min-height:0}
  .spc.open .spc-chips{display:none}
}

/* ---------- phone: scroll-up dock at rest, full sheet with a backdrop when open ---------- */
@media(max-width:720px){
  .spc{bottom:max(12px,env(safe-area-inset-bottom));width:calc(100% - 32px);max-width:470px;
    transform:translateX(-50%) translateY(calc(100% + 80px));transition:transform .38s cubic-bezier(.2,.75,.2,1)}
  .spc.show,.spc.open{transform:translateX(-50%)}
  .spc-dock{display:flex;align-items:center;justify-content:center}
  .spc-sheet{display:none}
  .spc-mark{display:none}

  /* the site's primary CTA, dressed as .btn-primary but frosted like the bar */
  .spc-cta{display:flex;align-items:center;gap:12px;height:48px;max-width:420px;overflow:hidden;white-space:nowrap;
    margin-right:10px;padding:5px 5px 5px 18px;border-radius:999px;color:var(--paper);text-decoration:none;
    font-weight:600;font-size:14.5px;line-height:1;
    transition:max-width .6s cubic-bezier(.34,1.6,.5,1),padding .6s cubic-bezier(.34,1.6,.5,1),margin .6s cubic-bezier(.34,1.6,.5,1),opacity .22s ease,border-width .3s ease}
  .spc-cta-arrow{flex:0 0 auto;width:38px;height:38px;border-radius:999px;background:var(--chartreuse);color:var(--on-marker);display:grid;place-items:center;font-size:16px;transition:transform .15s ease}
  .spc.open .spc-cta{max-width:0;margin-right:0;padding-left:0;padding-right:0;border-width:0;opacity:0;pointer-events:none}

  /* the "?" circle and the input bar are one object: the circle grows into the bar */
  .spc-bar{width:48px;height:48px;flex:0 0 auto;padding:1px;
    transition:width .6s cubic-bezier(.34,1.6,.5,1),padding .6s cubic-bezier(.34,1.6,.5,1)}
  .spc-q{position:absolute;inset:0;width:100%;border:0;border-radius:999px;background:transparent;color:var(--paper);
    font:inherit;font-size:21px;font-weight:600;line-height:1;cursor:pointer;display:grid;place-items:center;transition:opacity .2s ease}
  .spc-q::after{content:"";position:absolute;top:7px;right:7px;width:9px;height:9px;border-radius:50%;background:var(--chartreuse);opacity:0;transition:opacity .2s ease}
  .spc.has .spc-q::after{opacity:1}
  .spc.open .spc-q{opacity:0;pointer-events:none}
  .spc-input,.spc-send{opacity:0;pointer-events:none;transition:opacity .2s ease}
  .spc.open .spc-input,.spc.open .spc-send{opacity:1;pointer-events:auto;transition-delay:.18s}
  /* the focus ring follows the pill, not the bare input box */
  .spc.open .spc-bar:focus-within{border-color:var(--sage)}
  .spc-bar:has(.spc-input:focus-visible){outline:2px solid var(--paper);outline-offset:2px}

  .spc-chips{display:none;flex-direction:column;align-items:flex-start;gap:8px;margin:0 0 4px}
  .spc.open:not(.has) .spc-chips{display:flex}
  .spc-chip{font-size:13.5px;padding:8px 14px}

  .spc.open{top:max(10px,env(safe-area-inset-top));left:16px;right:16px;width:auto;max-width:none;transform:none;display:flex;flex-direction:column;gap:10px}
  .spc.open .spc-dock{flex:0 0 auto}
  .spc.open .spc-bar{width:100%;padding:1px 1px 1px 20px}
  .spc.open .spc-sheet{display:flex;flex-direction:column;flex:1;min-height:0;border-radius:22px;padding:12px 14px 14px;overflow:hidden;background:color-mix(in srgb,var(--pine-900) 86%,transparent)}
  .spc.open .spc-head{display:flex;align-items:center;gap:10px;padding:2px 0 10px;margin-bottom:10px;border-bottom:1px solid var(--hairline-soft)}
  .spc.open .spc-thread{flex:1;min-height:0}
  .spc.open .spc-scrim{display:block;position:fixed;inset:0;z-index:-1;background:rgba(10,11,10,.55);backdrop-filter:blur(8px) saturate(120%)}
  html.light .spc.open .spc-scrim{background:rgba(25,27,20,.34)}
  html.spc-lock,html.spc-lock body{overflow:hidden}
}
@media(prefers-reduced-motion:reduce){.spc,.spc-cta,.spc-bar,.spc-q,.spc-q::after,.spc-input,.spc-send,.spc-cta-arrow,.spc-chips{transition:none}}
@media(hover:hover){.spc-cta:hover .spc-cta-arrow{transform:translateX(2px)}}
@media(prefers-reduced-motion:no-preference){
  @media(max-width:720px){
    .spc.open .spc-sheet{animation:spc-rise .22s cubic-bezier(.2,.75,.2,1)}
    .spc.open .spc-scrim{animation:spc-fade .22s ease}
    @keyframes spc-rise{from{opacity:0;transform:translateY(12px)}to{opacity:1;transform:none}}
    @keyframes spc-fade{from{opacity:0}to{opacity:1}}
  }
  .spc-msg.wait span{animation:spc-blink 1.2s infinite}
  @keyframes spc-blink{0%,100%{opacity:.3}50%{opacity:1}}
}
