/* Dotnapps chat widget — uses the site's theme tokens (see site.css :root) so it
   follows the light/dark toggle automatically. */

.dn-launch, .dn-panel, .dn-panel * { box-sizing: border-box; }
.dn-panel[hidden], .dn-launch[hidden], .dn-chips[hidden] { display: none; }

.dn-vh {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0;
}

/* ---- launcher ---- */
.dn-launch {
  position: fixed; z-index: 40;
  right: max(16px, env(safe-area-inset-right));
  bottom: max(16px, env(safe-area-inset-bottom));
  width: 60px; height: 60px; padding: 0;
  display: grid; place-items: center;
  border: 0; border-radius: 20px; cursor: pointer; /* squircle, like BLOOP's app icon */
  background: var(--ink); color: var(--frame);
  box-shadow: var(--shadow-card);
  transition: transform .18s ease, opacity .18s ease;
}
.dn-launch:hover { transform: scale(1.06); }
.dn-launch:active { transform: scale(.97); }
.dn-launch:focus-visible, .dn-panel button:focus-visible, .dn-panel textarea:focus-visible, .dn-panel a:focus-visible {
  outline: 2px solid var(--focus); outline-offset: 2px;
}

/* ---- panel ---- */
.dn-panel {
  position: fixed; z-index: 60; /* above the site's fixed header (z-index 50), which otherwise covers the top of the sheet on phones */
  right: max(16px, env(safe-area-inset-right));
  bottom: max(16px, env(safe-area-inset-bottom));
  width: min(380px, calc(100vw - 32px));
  height: min(600px, calc(100dvh - 32px));
  display: flex; flex-direction: column;
  background: var(--raise); color: var(--text);
  border: 1px solid var(--border); border-radius: 20px;
  box-shadow: var(--shadow-card);
  overflow: hidden;
  font-family: inherit; font-size: .94rem; line-height: 1.45;
}
.dn-panel:not([hidden]) { animation: dn-in .2s ease-out; }
@keyframes dn-in { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: none; } }

.dn-head {
  display: flex; align-items: center; gap: .6rem;
  padding: .85rem .9rem .85rem 1.1rem;
  border-bottom: 1px solid var(--hairline);
}
.dn-title { margin: 0; flex: 1; min-width: 0; font-size: 1rem; font-weight: 600; color: var(--ink); letter-spacing: -.01em; }
.dn-sub { display: block; font-size: .76rem; font-weight: 400; color: var(--muted); letter-spacing: 0; }
.dn-close {
  flex: none; width: 34px; height: 34px; padding: 0; display: grid; place-items: center;
  border: 0; border-radius: 50%; background: transparent; color: var(--muted); cursor: pointer;
}
.dn-close:hover { background: var(--hairline); color: var(--ink); }
.dn-close svg { width: 16px; height: 16px; }

/* ---- messages ---- */
.dn-log {
  flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain;
  padding: 1rem; display: flex; flex-direction: column; gap: .55rem;
}
.dn-msg {
  max-width: 86%; padding: .55rem .8rem; border-radius: 16px;
  overflow-wrap: anywhere; -webkit-user-select: text; user-select: text;
}
.dn-msg p { margin: 0; }
.dn-msg p + p { margin-top: .45rem; }
.dn-msg a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
.dn-bot { align-self: flex-start; border-bottom-left-radius: 5px; background: color-mix(in srgb, var(--ink) 7%, transparent); }
.dn-me { align-self: flex-end; border-bottom-right-radius: 5px; background: var(--ink); color: var(--frame); }
.dn-err { color: var(--muted); }

.dn-typing { display: inline-flex; gap: 4px; align-items: center; padding: .25rem 0; }
.dn-typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); animation: dn-bounce 1s infinite ease-in-out; }
.dn-typing i:nth-child(2) { animation-delay: .15s; }
.dn-typing i:nth-child(3) { animation-delay: .3s; }
@keyframes dn-bounce { 0%, 80%, 100% { opacity: .35; transform: none; } 40% { opacity: 1; transform: translateY(-3px); } }

.dn-chips { display: flex; flex-wrap: wrap; gap: .4rem; padding: 0 1rem .75rem; }
.dn-chip {
  padding: .38rem .75rem; border: 1px solid var(--border); border-radius: 999px;
  background: transparent; color: var(--text); font: inherit; font-size: .84rem; cursor: pointer;
}
.dn-chip:hover { border-color: var(--ink); color: var(--ink); }

/* ---- composer ---- */
.dn-form { display: flex; align-items: flex-end; gap: .5rem; padding: .7rem .8rem .5rem; border-top: 1px solid var(--hairline); }
.dn-input {
  flex: 1; min-width: 0; resize: none; max-height: 110px;
  padding: .6rem .8rem; border: 1px solid var(--border); border-radius: 14px;
  background: transparent; color: var(--text);
  font: inherit; font-size: 1rem; /* 16px+ stops iOS zooming on focus */
  line-height: 1.35; -webkit-user-select: text; user-select: text;
}
.dn-input::placeholder { color: var(--faint); }
.dn-input:focus { border-color: var(--focus); outline: none; }
.dn-input:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
.dn-send {
  flex: none; width: 40px; height: 40px; padding: 0; display: grid; place-items: center;
  border: 0; border-radius: 50%; background: var(--ink); color: var(--frame); cursor: pointer;
}
.dn-send:disabled { opacity: .35; cursor: default; }
.dn-send svg { width: 18px; height: 18px; }

.dn-foot { display: flex; flex-wrap: wrap; gap: .25rem .9rem; align-items: center; justify-content: space-between; padding: 0 1rem .8rem; font-size: .74rem; color: var(--muted); }
.dn-foot a { color: var(--text); text-decoration: underline; text-underline-offset: 2px; }

/* ---- phones: near full-screen sheet; launcher hides while it is open ---- */
@media (max-width: 520px) {
  .dn-panel {
    inset: max(8px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
    width: auto; height: auto; border-radius: 18px;
  }
  .dn-launch[aria-expanded="true"] { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .dn-panel:not([hidden]) { animation: none; }
  .dn-launch { transition: none; }
  .dn-typing i { animation: none; opacity: .6; }
}

/* ---- live human chat ---- */
.dn-link {
  padding: 0; border: 0; background: none; cursor: pointer;
  font: inherit; color: var(--text); text-decoration: underline; text-underline-offset: 2px;
}
.dn-agent { background: color-mix(in srgb, var(--focus) 13%, transparent); }
.dn-who { display: block; margin-bottom: .1rem; font-size: .72rem; font-weight: 600; color: var(--muted); letter-spacing: .01em; }
.dn-note { align-self: center; max-width: 94%; padding: .15rem .5rem; text-align: center; font-size: .8rem; color: var(--muted); background: none; }
.dn-failed { opacity: .5; }

.dn-hand { width: 92%; max-width: 92%; }
.dn-lab { display: block; margin: .55rem 0 .2rem; font-size: .78rem; color: var(--muted); }
.dn-field {
  width: 100%; padding: .5rem .65rem; border: 1px solid var(--border); border-radius: 10px;
  background: var(--raise); color: var(--text); font: inherit; font-size: 1rem;
  -webkit-user-select: text; user-select: text;
}
.dn-field:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
.dn-ferr { margin: .4rem 0 0; font-size: .82rem; color: var(--muted); }
.dn-ferr:empty { display: none; }
.dn-hrow { display: flex; gap: .5rem; margin-top: .65rem; }
.dn-hbtn {
  padding: .45rem .9rem; border: 1px solid transparent; border-radius: 999px; cursor: pointer;
  background: var(--ink); color: var(--frame); font: inherit; font-size: .88rem;
}
.dn-hbtn:disabled { opacity: .5; cursor: default; }
.dn-hbtn.dn-ghost { background: transparent; color: var(--text); border-color: var(--border); }

.dn-launch[data-unread]::after {
  content: ""; position: absolute; top: 2px; right: 2px; width: 14px; height: 14px;
  border-radius: 50%; background: #FF3B30; border: 2px solid var(--frame);
}

/* ---- BLOOP, the bot's face: ring, two eyes and a speech-bubble mouth (bloop.svg) ---- */
.dn-face { display: block; overflow: visible; flex: none; }
.dn-face .dn-ring { fill: none; stroke: var(--face-fill); stroke-width: 7.9; stroke-linecap: round; }
.dn-face .dn-mouth, .dn-face .dn-fe { fill: var(--face-fill); }
.dn-face .dn-fd { fill: var(--face-eye); }   /* dots cut out of the mouth: the colour of whatever the face sits on */
.dn-face .dn-arc { fill: none; stroke: var(--face-fill); stroke-width: 4.6; stroke-linecap: round; stroke-linejoin: round; }
.dn-face .g { display: none; }
.dn-face[data-state="idle"] .g-eyes,
.dn-face[data-state="thinking"] .g-eyes,
.dn-face[data-state="help"] .g-eyes,
.dn-face[data-state="success"] .g-eyes,
.dn-face[data-state="error"] .g-eyes,
.dn-face[data-state="alert"] .g-eyes,
.dn-face[data-state="online"] .g-eyes { display: inline; }
.dn-face[data-state="typing"] .g-typing,
.dn-face[data-state="happy"] .g-happy,
.dn-face[data-state="excited"] .g-excited,
.dn-face[data-state="wink"] .g-wink,
.dn-face[data-state="love"] .g-love,
.dn-face[data-state="cool"] .g-cool,
.dn-face[data-state="thinking"] .g-thinking,
.dn-face[data-state="help"] .g-help,
.dn-face[data-state="success"] .g-success,
.dn-face[data-state="error"] .g-error,
.dn-face[data-state="alert"] .g-alert,
.dn-face[data-state="offline"] .g-offline,
.dn-face[data-state="processing"] .g-processing,
.dn-face[data-state="online"] .g-online { display: inline; }
.dn-face .g-eyes { transform-box: fill-box; transform-origin: center; animation: dn-blink 5.5s infinite; }
/* sparks and zzz sit outside the ring; speech-bubble badges are inverted with an outline */
.dn-face .dn-spark { fill: none; stroke: var(--face-fill); stroke-width: 3.5; stroke-linecap: round; stroke-linejoin: round; }
.dn-face .dn-bt { fill: var(--face-eye); stroke: var(--face-fill); stroke-width: 3.5; stroke-linejoin: round; }
.dn-face .dn-bg { fill: none; stroke: var(--face-fill); stroke-width: 3.5; stroke-linecap: round; stroke-linejoin: round; }
.dn-face .dn-bg-f { fill: var(--face-fill); }
.dn-face .dn-spin { transform-box: fill-box; transform-origin: center; animation: dn-spin 1.1s linear infinite; }
@keyframes dn-spin { to { transform: rotate(360deg); } }
.dn-face[data-state="excited"] .g-excited .dn-spark { animation: dn-spark .7s ease-in-out infinite alternate; }
@keyframes dn-spark { from { opacity: .35; } to { opacity: 1; } }
@keyframes dn-blink { 0%, 91%, 100% { transform: scaleY(1); } 94% { transform: scaleY(.1); } }
.dn-face .dn-td { animation: dn-td 1s infinite ease-in-out; }
.dn-face .dn-td1 { animation-delay: .17s; }
.dn-face .dn-td2 { animation-delay: .34s; }
@keyframes dn-td { 0%, 100% { opacity: .25; } 40% { opacity: 1; } }

.dn-lface { width: 34px; height: 34px; --face-fill: var(--frame); --face-eye: var(--ink); }
.dn-hface { width: 26px; height: 26px; --face-fill: var(--ink); --face-eye: var(--raise); }
.dn-mini { width: 24px; height: 24px; --face-fill: var(--ink); --face-eye: var(--raise); }
.dn-sp { flex: none; width: 24px; }

.dn-dot { position: absolute; right: 5px; bottom: 5px; width: 8px; height: 8px; border-radius: 50%; background: var(--frame); } /* "online" */

.dn-avatar {
  position: relative; flex: none; width: 42px; height: 42px;
  display: grid; place-items: center; border-radius: 14px;
  background: color-mix(in srgb, var(--ink) 7%, transparent);
}
.dn-avatar::after {
  content: ""; position: absolute; right: -2px; bottom: -2px; width: 11px; height: 11px;
  border-radius: 50%; background: var(--ink); border: 2px solid var(--raise);
}
.dn-team { width: 24px; height: 24px; display: block; }
.dn-team path { fill: var(--ink); }

.dn-row { display: flex; align-items: flex-end; gap: 8px; align-self: flex-start; max-width: 94%; }
.dn-row .dn-msg { max-width: calc(100% - 32px); }

@media (prefers-reduced-motion: reduce) {
  .dn-face .g-eyes, .dn-face .dn-td, .dn-face .dn-spin, .dn-face .g-excited .dn-spark { animation: none !important; }
  .dn-face .dn-td { opacity: .7; }
}

/* =====================================================================
   Look: the chat box wears the website's own colours (white on the light site,
   black on the dark site), with hairline edges, small mono labels and black pill
   buttons. BLOOP is drawn in the opposite colour (black on light, white on dark),
   and the message area has a faint dot grid, like the dotted graphics on the site.
   ===================================================================== */
:root { --dn-tray: var(--frame); --dn-card: var(--sunken); --dn-edge: rgba(0, 0, 0, .09); --dn-dot: rgba(0, 0, 0, .1); }
:root[data-theme="dark"] { --dn-edge: rgba(255, 255, 255, .12); --dn-dot: rgba(255, 255, 255, .14); }

/* label bits, shown by the look below */
.dn-eyebrow, .dn-meta { display: none; }
.dn-titles { flex: 1; min-width: 0; }
.dn-who { display: none; }
.dn-eyebrow, .dn-meta {
  font-family: "Space Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  text-transform: uppercase; letter-spacing: .14em; font-size: .62rem; font-weight: 400; color: var(--muted);
}

/* ---------- the chat box ---------- */
.dn-panel.dn-s-a {
  width: min(400px, calc(100vw - 32px)); border-radius: 14px;
  background: var(--dn-tray); border: 1px solid var(--border); box-shadow: var(--shadow-frame);
}
.dn-s-a .dn-head { background: var(--dn-tray); border-bottom: 1px solid var(--dn-edge); padding: .7rem .9rem .7rem 1rem; }
.dn-s-a .dn-eyebrow { display: flex; align-items: center; gap: .45rem; margin-bottom: .1rem; }
.dn-s-a .dn-eyebrow::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--ink); }
.dn-s-a .dn-title { font-size: 1.02rem; }
.dn-s-a .dn-avatar { background: var(--ink); border-radius: 50%; width: 40px; height: 40px; }
.dn-s-a .dn-avatar::after { display: none; }
.dn-s-a .dn-hface { --face-fill: var(--frame); --face-eye: var(--ink); width: 26px; height: 26px; }
.dn-s-a .dn-team { width: 22px; height: 22px; }
.dn-s-a .dn-team path { fill: var(--frame); }
.dn-s-a .dn-log {
  padding: 14px; gap: 10px; background-color: var(--dn-tray);
  background-image: radial-gradient(circle at 1px 1px, var(--dn-dot) 1px, transparent 1.5px); background-size: 20px 20px;
}
.dn-s-a .dn-mini, .dn-s-a .dn-sp { display: none; }
.dn-s-a .dn-row { max-width: 92%; }
.dn-s-a .dn-row .dn-msg { max-width: 100%; }
.dn-s-a .dn-msg { border-radius: 12px; padding: .6rem .8rem; max-width: 90%; }
.dn-s-a .dn-bot { background: var(--dn-card); border: 1px solid var(--dn-edge); border-bottom-left-radius: 12px; }
.dn-s-a .dn-me { background: var(--ink); color: var(--frame); border-bottom-right-radius: 12px; }
.dn-s-a .dn-agent { background: var(--dn-card); border-left: 3px solid var(--focus); }
.dn-s-a .dn-meta { display: block; margin-bottom: .2rem; }
.dn-s-a .dn-me .dn-meta { color: color-mix(in srgb, var(--frame) 60%, transparent); }
.dn-s-a .dn-note { background: none; border: 0; box-shadow: none; }
.dn-s-a .dn-hand { background: var(--dn-card); border: 1px solid var(--dn-edge); }
.dn-s-a .dn-chips { background: var(--dn-tray); padding: 0 14px 12px; }
.dn-s-a .dn-chip { background: var(--dn-tray); border-color: var(--border); display: inline-flex; align-items: center; gap: .4rem; font-weight: 500; }
.dn-s-a .dn-chip:hover { background: var(--dn-card); }
.dn-s-a .dn-chip::after { content: "→"; color: var(--muted); }
.dn-s-a .dn-chip:hover::after { color: var(--ink); }
.dn-s-a .dn-form { background: var(--dn-tray); border-top: 1px solid var(--dn-edge); padding: .7rem .8rem .4rem; }
.dn-s-a .dn-input { background: var(--dn-card); border-radius: 12px; border-color: var(--border); }
.dn-s-a .dn-send { border-radius: 999px; }
.dn-s-a .dn-foot { background: var(--dn-tray); }
.dn-s-a .dn-foot, .dn-s-a .dn-foot .dn-link { font-family: "Space Mono", ui-monospace, "SF Mono", Menlo, monospace; text-transform: uppercase; letter-spacing: .08em; font-size: .6rem; }

/* header buttons */
.dn-expand {
  display: none; flex: none; width: 34px; height: 34px; padding: 0; place-items: center;
  border: 0; border-radius: 50%; background: transparent; color: var(--muted); cursor: pointer;
}
.dn-expand:hover { background: var(--hairline); color: var(--ink); }
.dn-expand svg { width: 16px; height: 16px; }

/* ---------- the launcher: built like the round menu button at the top of the site ----------
   an outlined circle in the page colour, a solid disc inside it, and BLOOP drawn on the disc in
   the opposite colour (white on black on the light site, black on white on the dark site) */
.dn-launch.dn-s-a {
  position: fixed; width: 62px; height: 62px; padding: 0; display: grid; place-items: center;
  border: 1px solid var(--border); border-radius: 50%; background: var(--frame); color: var(--frame);
  box-shadow: var(--shadow-nav);
}
.dn-launch.dn-s-a::before { content: ""; position: absolute; inset: 7px; border-radius: 50%; background: var(--ink); }
.dn-s-a .dn-lface { position: relative; --face-fill: var(--frame); --face-eye: var(--ink); width: 32px; height: 32px; }
.dn-launch.dn-s-a .dn-dot { display: none; }

/* the launcher steps aside while the chat is open */
.dn-launch[aria-expanded="true"] { display: none; }

/* ---------- greeting pop-up ---------- */
.dn-greet {
  position: fixed; z-index: 41;
  right: max(16px, env(safe-area-inset-right)); bottom: calc(max(16px, env(safe-area-inset-bottom)) + 72px);
  width: min(290px, calc(100vw - 32px));
  background: var(--dn-tray); color: var(--text); border: 1px solid var(--border); border-radius: 14px;
  box-shadow: var(--shadow-frame); animation: dn-pop .28s cubic-bezier(.2, .9, .3, 1.15);
  transform-origin: bottom right;
}
.dn-greet[hidden] { display: none; }
.dn-greet::after {
  content: ""; position: absolute; bottom: -7px; right: 28px; width: 12px; height: 12px;
  background: var(--dn-tray); border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); transform: rotate(45deg);
}
@keyframes dn-pop { from { opacity: 0; transform: translateY(8px) scale(.96); } to { opacity: 1; transform: none; } }
.dn-greet-open {
  display: block; width: 100%; text-align: left; padding: .85rem 2.6rem .9rem 1rem; border: 0; background: none;
  color: inherit; font: inherit; line-height: 1.45; cursor: pointer; border-radius: 14px;
}
.dn-greet-eye {
  display: flex; align-items: center; gap: .45rem; margin-bottom: .25rem;
  font: 400 .62rem "Space Mono", ui-monospace, "SF Mono", Menlo, monospace; letter-spacing: .14em; text-transform: uppercase; color: var(--muted);
}
.dn-greet-eye::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--ink); }
.dn-greet-t { display: block; font-size: 1.02rem; font-weight: 600; color: var(--ink); letter-spacing: -.01em; }
.dn-greet-p { display: block; margin-top: .15rem; font-size: .9rem; color: var(--muted); }
.dn-greet-act {
  display: inline-flex; align-items: center; gap: .4rem; margin: 0 1rem .9rem; padding: .4rem .85rem;
  border: 1px solid var(--border); border-radius: 999px; background: var(--dn-tray); color: var(--text);
  font: inherit; font-size: .84rem; font-weight: 500; cursor: pointer;
}
.dn-greet-act[hidden] { display: none; }
.dn-greet-act::after { content: "\2192"; color: var(--muted); }
.dn-greet-act:hover { background: var(--dn-card); }
.dn-greet-x {
  position: absolute; top: .4rem; right: .4rem; width: 30px; height: 30px; padding: 0; display: grid; place-items: center;
  border: 0; border-radius: 50%; background: transparent; color: var(--muted); cursor: pointer;
}
.dn-greet-x:hover { background: var(--hairline); color: var(--ink); }
.dn-greet-x svg { width: 14px; height: 14px; }
.dn-greet button:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* ---------- phones: a compact card by default, full screen only on request ---------- */
@media (max-width: 520px) {
  .dn-panel.dn-s-a {
    inset: auto 12px calc(var(--dn-kb, 0px) + max(12px, env(safe-area-inset-bottom))) 12px;
    width: auto; border-radius: 16px;
    height: min(68dvh, 540px, calc(100dvh - var(--dn-kb, 0px) - 24px));
  }
  .dn-panel.dn-s-a.dn-full {
    inset: max(8px, env(safe-area-inset-top)) 8px calc(var(--dn-kb, 0px) + max(8px, env(safe-area-inset-bottom))) 8px;
    height: auto;
  }
  .dn-expand { display: grid; }
  .dn-s-a .dn-sub { display: none; }
  .dn-panel.dn-s-a.dn-kbd .dn-chips, .dn-panel.dn-s-a.dn-kbd .dn-foot, .dn-panel.dn-s-a.dn-kbd .dn-eyebrow { display: none; }
  .dn-greet { right: 12px; bottom: calc(max(12px, env(safe-area-inset-bottom)) + 64px); }
  .dn-launch.dn-s-a { width: 56px; height: 56px; right: 12px; bottom: max(12px, env(safe-area-inset-bottom)); }
  .dn-launch.dn-s-a::before { inset: 6px; }
  .dn-s-a .dn-lface { width: 29px; height: 29px; }
}

/* a small wobble on the BLOOP button when a message pops up (a visual cue for when the browser keeps the sound off) */
.dn-launch.dn-nudge { animation: dn-wobble 1.4s ease-in-out; }
@keyframes dn-wobble {
  0%, 100% { transform: none; }
  12% { transform: translateY(-6px) rotate(-8deg); } 24% { transform: translateY(0) rotate(7deg); }
  36% { transform: translateY(-4px) rotate(-5deg); } 48% { transform: translateY(0) rotate(4deg); }
  60% { transform: translateY(-2px) rotate(-2deg); } 72% { transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  .dn-greet { animation: none; }
  .dn-launch.dn-nudge { animation: none; }
}
