/* Let's chat: dither bloom (concept B). See js/chat-bloom.js.
   The nav button turns into a folder tab and the form blooms out of it through
   a 4x4 ordered-dither mask, stepped at 12fps on the 4px grid. On phones (or
   whenever the nav button is not on screen) the panel sits at the bottom of
   the screen with its own tab. Everything is on a 2px grid; colours come from
   the site tokens, so the dark-mode toggle swaps them. */

:root {
  --cb-ink: var(--swatch--neutral-100, #010101);
  --cb-fill: var(--color--background-2, #f5f4f0);
  --cb-field: var(--color--background, #fcfcfa);
  --cb-field-focus: var(--swatch--neutral-10, #fff);
  --cb-text: var(--color--text, #010101);
  --cb-muted: var(--swatch--neutral-70, #5f6b7a);
  --cb-seg: var(--swatch--ecru-40, #e2e0da);
  --cb-focus: var(--swatch--primary-90, #0b3861);
  --cb-caret: var(--swatch--primary-60, #056fce);
  --cb-send: var(--swatch--primary-90, #0b3861);
  --cb-send-press: var(--swatch--primary-110, #031d34);
  --cb-send-text: var(--swatch--neutral-10, #fff);
  --cb-brick: #b4441f;
  --cb-brick-bg: #faeee8;
  --cb-moss: #2f6b3a;
  --cb-shadow-paint: color-mix(in srgb, var(--swatch--neutral-100, #010101) 78%, var(--swatch--ecru-50, #cbc8c1));
  --cb-notch: polygon(0 4px, 2px 4px, 2px 2px, 4px 2px, 4px 0, calc(100% - 4px) 0, calc(100% - 4px) 2px, calc(100% - 2px) 2px, calc(100% - 2px) 4px, 100% 4px, 100% calc(100% - 4px), calc(100% - 2px) calc(100% - 4px), calc(100% - 2px) calc(100% - 2px), calc(100% - 4px) calc(100% - 2px), calc(100% - 4px) 100%, 4px 100%, 4px calc(100% - 2px), 2px calc(100% - 2px), 2px calc(100% - 4px), 0 calc(100% - 4px));
  --cb-notch-top: polygon(0 4px, 2px 4px, 2px 2px, 4px 2px, 4px 0, calc(100% - 4px) 0, calc(100% - 4px) 2px, calc(100% - 2px) 2px, calc(100% - 2px) 4px, 100% 4px, 100% 100%, 0 100%);
  --cb-notch-tr: polygon(0 4px, 2px 4px, 2px 2px, 4px 2px, 4px 0, 100% 0, 100% calc(100% - 4px), calc(100% - 2px) calc(100% - 4px), calc(100% - 2px) calc(100% - 2px), calc(100% - 4px) calc(100% - 2px), calc(100% - 4px) 100%, 4px 100%, 4px calc(100% - 2px), 2px calc(100% - 2px), 2px calc(100% - 4px), 0 calc(100% - 4px));
  --cb-brackets: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='30' height='30' shape-rendering='crispEdges' fill='%230b3861'%3E%3Cpath d='M0 0h10v2H2v8H0z M30 0h-10v2h8v8h2z M0 30h10v-2H2v-8H0z M30 30h-10v-2h8v-8h2z'/%3E%3C/svg%3E");
}
html.dark-mode {
  --cb-ink: var(--swatch--neutral-60, #97a3b5);
  --cb-fill: var(--swatch--neutral-90, #2b3138);
  --cb-field: var(--swatch--neutral-95, #1a1a1d);
  --cb-field-focus: var(--swatch--neutral-100, #010101);
  --cb-muted: var(--swatch--neutral-60, #97a3b5);
  --cb-seg: var(--swatch--neutral-80, #3d4653);
  --cb-focus: var(--swatch--primary-40, #5ba6ea);
  --cb-caret: var(--swatch--primary-40, #5ba6ea);
  --cb-send: var(--swatch--primary-60, #056fce);
  --cb-send-press: var(--swatch--primary-80, #074f8f);
  --cb-brick: #e58a66;
  --cb-brick-bg: #3a221a;
  --cb-moss: #8fc79a;
  --cb-shadow-paint: repeating-conic-gradient(var(--swatch--neutral-60, #97a3b5) 0 25%, transparent 0 50%) 0 0 / 2px 2px;
  --cb-brackets: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='30' height='30' shape-rendering='crispEdges' fill='%235ba6ea'%3E%3Cpath d='M0 0h10v2H2v8H0z M30 0h-10v2h8v8h2z M0 30h10v-2H2v-8H0z M30 30h-10v-2h8v-8h2z'/%3E%3C/svg%3E");
}

.cb-root[hidden], .cb-root [hidden] { display: none !important; }
.cb-root { position: fixed; inset: 0; z-index: 10000; pointer-events: none; }
.cb-root *, .cb-root *::before, .cb-root *::after { box-sizing: border-box; }

/* Panel: notched pixel frame (ink outline, fill, inner corner steps), a hard
   4px shadow that only lands once the bloom has finished. */
.cb-panel {
  position: fixed;
  isolation: isolate;
  margin: 0;
  padding: 20px 22px 18px;
  color: var(--cb-text);
  font-family: var(--site-font, 'Departure Mono', monospace);
  font-size: 16px;
  line-height: 22px;
  font-weight: 400;
  letter-spacing: 0;
  text-align: left;
  pointer-events: auto;
  -webkit-font-smoothing: none;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
}
.cb-panel::before, .cb-panel::after,
.cb-field::before, .cb-field::after,
.cb-send::before, .cb-send::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  clip-path: var(--cb-notch);
}
.cb-panel::before { z-index: -2; background: var(--cb-shadow-paint); translate: 4px 4px; opacity: 0; }
.cb-root.is-settled .cb-panel::before { opacity: 1; }
.cb-panel::after {
  z-index: -1;
  background:
    linear-gradient(var(--cb-ink), var(--cb-ink)) left 2px top 2px / 2px 2px no-repeat,
    linear-gradient(var(--cb-ink), var(--cb-ink)) right 2px top 2px / 2px 2px no-repeat,
    linear-gradient(var(--cb-ink), var(--cb-ink)) left 2px bottom 2px / 2px 2px no-repeat,
    linear-gradient(var(--cb-ink), var(--cb-ink)) right 2px bottom 2px / 2px 2px no-repeat,
    linear-gradient(var(--cb-fill), var(--cb-fill)) 2px 2px / calc(100% - 4px) calc(100% - 4px) no-repeat,
    var(--cb-ink);
}

/* Joined: when the tab sits flush with the panel's right edge, that corner is
   square (no notch, no inner step) so tab and panel read as one shape. */
.cb-root.is-joined-right .cb-panel::before,
.cb-root.is-joined-right .cb-panel::after { clip-path: var(--cb-notch-tr); }
.cb-root.is-joined-right .cb-panel::after {
  background:
    linear-gradient(var(--cb-ink), var(--cb-ink)) left 2px top 2px / 2px 2px no-repeat,
    linear-gradient(var(--cb-ink), var(--cb-ink)) left 2px bottom 2px / 2px 2px no-repeat,
    linear-gradient(var(--cb-ink), var(--cb-ink)) right 2px bottom 2px / 2px 2px no-repeat,
    linear-gradient(var(--cb-fill), var(--cb-fill)) 2px 2px / calc(100% - 4px) calc(100% - 4px) no-repeat,
    var(--cb-ink);
}

/* The tab: drawn over the nav button, notched on top, open at the bottom so it
   runs straight into the panel. In tab mode its label copies the nav button's
   box and sits on its exact rect (see copyLabel in the JS). */
.cb-tab {
  position: fixed;
  z-index: 1;
  isolation: isolate;
  margin: 0;
  padding: 0;
  color: var(--cb-text);
  cursor: pointer;
  pointer-events: auto;
}
.cb-tab::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  clip-path: var(--cb-notch-top);
  background:
    linear-gradient(var(--cb-ink), var(--cb-ink)) left 2px top 2px / 2px 2px no-repeat,
    linear-gradient(var(--cb-ink), var(--cb-ink)) right 2px top 2px / 2px 2px no-repeat,
    linear-gradient(var(--cb-fill), var(--cb-fill)) 2px 2px / calc(100% - 4px) 100% no-repeat,
    var(--cb-ink);
}
.cb-tab-label { display: block; white-space: nowrap; }
.cb-root.is-sheet .cb-tab { padding: 6px 14px; }
.cb-root.is-sheet .cb-tab-label { font-family: var(--site-font-display, 'PP NeueBit', monospace); font-size: 28px; line-height: 28px; font-weight: 500; -webkit-font-smoothing: none; }

.cb-hp { position: absolute !important; left: -10000px; top: auto; width: 1px; height: 1px; margin: 0; overflow: hidden; }

/* Icons: HackerNoon pixel icon library, 24-unit grid, drawn 1:1 (or 2:1). */
.cb-icon { display: block; flex: none; shape-rendering: crispEdges; }

/* Type: three sizes from the site scale.
   28/28 PP NeueBit: the prompt. 16/22 Departure Mono: labels, fields, button.
   14/18 Departure Mono: count, errors, shortcut hint, alternative contact. */
/* Webflow styles label and p (PP NeueBit labels, weight 300 paragraphs):
   reset them so the panel uses only the three sizes below. */
.cb-panel label, .cb-panel p, .cb-panel input, .cb-panel textarea, .cb-panel button { font-family: var(--site-font, 'Departure Mono', monospace); font-weight: 400; letter-spacing: 0; }
.cb-panel .cb-title { font-family: var(--site-font-display, 'PP NeueBit', monospace); font-weight: 500; }

.cb-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 0 0 16px; }
.cb-title { margin: 0; font-family: var(--site-font-display, 'PP NeueBit', monospace); font-size: 28px; line-height: 28px; font-weight: 500; letter-spacing: 0; color: var(--cb-text); }
.cb-x { display: inline-flex; flex: none; width: 32px; height: 32px; margin: -4px -6px -4px 0; padding: 4px; border: 0; background: none; color: var(--cb-muted); cursor: pointer; }
.cb-x:hover { color: var(--cb-text); }
.cb-x:focus { outline: none; }
.cb-x:focus-visible { color: var(--cb-text); border-image: var(--cb-brackets) 10 / 10px / 0; }

.cb-row { margin: 0 0 4px; }
.cb-label { display: flex; justify-content: space-between; align-items: baseline; margin: 0 0 6px; font-size: 16px; line-height: 22px; font-weight: 400; color: var(--cb-text); }
.cb-count { font-size: 14px; line-height: 18px; color: var(--cb-muted); }

.cb-field { position: relative; isolation: isolate; --cb-edge: var(--cb-ink); --cb-bg: var(--cb-field); }
.cb-field::before { z-index: -2; background: var(--cb-seg); translate: 0 0; }
.cb-field::after {
  z-index: -1;
  background:
    linear-gradient(var(--cb-ink), var(--cb-ink)) left 2px top 2px / 2px 2px no-repeat,
    linear-gradient(var(--cb-ink), var(--cb-ink)) right 2px top 2px / 2px 2px no-repeat,
    linear-gradient(var(--cb-ink), var(--cb-ink)) left 2px bottom 2px / 2px 2px no-repeat,
    linear-gradient(var(--cb-ink), var(--cb-ink)) right 2px bottom 2px / 2px 2px no-repeat,
    linear-gradient(var(--cb-bg), var(--cb-bg)) 2px 2px / calc(100% - 4px) calc(100% - 4px) no-repeat,
    var(--cb-edge);
}
.cb-field:focus-within { --cb-edge: var(--cb-focus); --cb-bg: var(--cb-field-focus); }
.cb-field:focus-within::before { translate: 2px 2px; }
.cb-field.is-error { --cb-edge: var(--cb-brick); --cb-bg: var(--cb-brick-bg); }
.cb-field.err-half { --cb-edge: repeating-conic-gradient(var(--cb-brick) 0 25%, var(--cb-ink) 0 50%) 0 0 / 4px 4px; }
.cb-field input, .cb-field textarea {
  display: block;
  width: 100%;
  height: 42px;
  margin: 0;
  padding: 10px 12px;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  color: var(--cb-text);
  font-family: inherit;
  font-size: 16px;
  line-height: 22px;
  font-weight: 400;
  caret-color: var(--cb-caret);
  caret-shape: block;
  outline: none;
  resize: none;
  -webkit-appearance: none;
  appearance: none;
}
.cb-field textarea { height: 108px; }
.cb-field input::placeholder, .cb-field textarea::placeholder { color: var(--cb-muted); opacity: 1; }
.cb-err { min-height: 18px; margin: 4px 0 0; font-size: 14px; line-height: 18px; color: var(--cb-brick); }

/* Length as 2px-gapped segments: focus colour while typing, brick near the cap. */
.cb-bar { display: flex; gap: 2px; height: 4px; margin-top: 6px; }
.cb-bar i { flex: 1; background: var(--cb-seg); }
.cb-bar i.on { background: var(--cb-focus); }
.cb-bar i.warn { background: var(--cb-brick); }

.cb-actions { display: flex; align-items: center; gap: 12px; margin-top: 8px; }
.cb-net { min-height: 0; margin: 8px 0 0; font-size: 14px; line-height: 18px; color: var(--cb-brick); }
.cb-net:empty { display: none; }
.cb-net a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
.cb-alt { margin: 16px 0 0; padding-top: 12px; border-top: 2px solid var(--cb-seg); font-size: 14px; line-height: 18px; color: var(--cb-muted); }
.cb-alt a { color: var(--cb-text); text-decoration: underline; text-underline-offset: 2px; }

/* Send: the navy pixel button (same build as .px-btn--primary), body size. */
.cb-send {
  position: relative;
  isolation: isolate;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  margin: 0;
  padding: 8px 12px 8px 16px;
  border: 0;
  background: transparent;
  color: var(--cb-send-text);
  font-family: inherit;
  font-size: 16px;
  line-height: 22px;
  font-weight: 400;
  cursor: pointer;
  translate: 0 var(--cb-y, 0px);
  --cb-bg: var(--cb-send);
  -webkit-font-smoothing: none;
}
.cb-send::before { z-index: -2; background: var(--cb-shadow-paint); translate: 2px calc(2px - var(--cb-y, 0px)); }
.cb-send::after {
  z-index: -1;
  background:
    linear-gradient(var(--cb-ink), var(--cb-ink)) left 2px top 2px / 2px 2px no-repeat,
    linear-gradient(var(--cb-ink), var(--cb-ink)) right 2px top 2px / 2px 2px no-repeat,
    linear-gradient(var(--cb-ink), var(--cb-ink)) left 2px bottom 2px / 2px 2px no-repeat,
    linear-gradient(var(--cb-ink), var(--cb-ink)) right 2px bottom 2px / 2px 2px no-repeat,
    linear-gradient(var(--cb-bg), var(--cb-bg)) 2px 2px / calc(100% - 4px) calc(100% - 4px) no-repeat,
    var(--cb-ink);
}
.cb-send svg { transition: translate 80ms steps(2, end); }
@media (hover: hover) and (pointer: fine) {
  .cb-send:hover { --cb-y: -2px; }
  .cb-send:hover svg { translate: 2px 0; }
}
.cb-send:active { --cb-y: 2px; --cb-bg: var(--cb-send-press); }
.cb-send:focus { outline: none; }
.cb-send:focus-visible { border-image: var(--cb-brackets) 10 / 10px / 6px; }
.cb-send[disabled] { cursor: progress; }
.cb-dots i { display: inline-block; width: 4px; height: 4px; margin-left: 2px; background: currentColor; vertical-align: 2px; }

/* Hold Cmd / Ctrl: the shortcut hint. */
.cb-sc { display: none; font-size: 14px; line-height: 18px; color: var(--cb-muted); }
.cb-show-sc .cb-sc { display: inline; }
@media (hover: none) { .cb-show-sc .cb-sc { display: none; } }

/* Success: the library check at 2x (48px), a line, then the panel blooms shut. */
.cb-panel { display: flex; flex-direction: column; }
.cb-done { display: flex; flex: 1 0 auto; flex-direction: column; align-items: center; justify-content: center; gap: 12px; padding: 24px 12px; text-align: center; }
.cb-check { color: var(--cb-moss); }
.cb-done-text { margin: 0; font-size: 16px; line-height: 22px; outline: none; }

/* The nav button after a send: library check + "Sent". The check is 24px but
   takes 20px of line, so the nav line box does not grow. */
.cb-tick { display: inline-block; margin: -2px 4px -2px 0; color: var(--cb-moss); vertical-align: middle; }

@media (max-height: 640px) { .cb-field textarea { height: 86px; } }

@media (prefers-reduced-motion: reduce) {
  .cb-send, .cb-send svg { transition: none; }
  .cb-send:hover { --cb-y: 0px; }
}
