/* ============================================================
   Deback "Micro" components — staging-only experiment (2026-09-21)
   Vanilla HTML/CSS/JS reimplementations of six components from the
   React Bits library (https://github.com/DavidHDev/react-bits),
   Copyright (c) 2026 David Haz, licensed MIT + Commons Clause v1.0.
   Used here as part of the Deback website, per the license terms.
   No dependencies. All motion honors prefers-reduced-motion.
   ============================================================ */

/* ---------- shared ---------- */
.db-sr {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  border: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}
/* hard-hide helper for JS-swapped originals (beats author display rules) */
.db-gone { display: none !important; }

/* ============================================================
   1. Lattice Loader — animated lattice "thinking" indicator
   ============================================================ */
.db-lattice {
  --dbll-n: 3;
  --dbll-cell: 7px;
  --dbll-gap: 2.5px;
  --dbll-color: var(--accent, #5B74FF);
  --dbll-mark: var(--success, #34d399);
  --dbll-idle: 0.16;
  --dbll-peak: 1;
  --dbll-cycle: 960ms;
  --dbll-ease: cubic-bezier(0.77, 0, 0.175, 1);
  position: relative;
  display: none;
  align-items: center;
  flex: none;
  line-height: 1;
  /* sit centered against the status text (all three hosts are <p> lines);
     without this the dot grid rides on the text baseline and the words
     look sunk next to it */
  vertical-align: middle;
  margin-right: 8px;
}
.db-lattice[data-on] { display: inline-flex; }
.db-lattice__grid { display: grid; flex: none; }
.db-lattice__layer {
  grid-area: 1 / 1;
  display: grid;
  grid-template-columns: repeat(var(--dbll-n), var(--dbll-cell));
  gap: var(--dbll-gap);
}
.db-lattice__cell {
  width: var(--dbll-cell);
  height: var(--dbll-cell);
  border-radius: 50%;
  background: var(--dbll-color);
  opacity: var(--dbll-idle);
}
.db-lattice__run { transition: opacity 200ms ease; }
.db-lattice__run .db-lattice__cell { animation: dbll-on var(--dbll-cycle) var(--dbll-ease) infinite; }
.db-lattice__run .db-lattice__cell[data-hole] { animation: none; opacity: calc(var(--dbll-idle) * 0.5); }
.db-lattice__mark {
  opacity: 0; transform: scale(0.9); transform-origin: center;
  transition: opacity 160ms ease, transform 160ms ease;
}
.db-lattice__mark .db-lattice__cell[data-on] { background: var(--dbll-mark); opacity: var(--dbll-peak); }
.db-lattice[data-status="done"] .db-lattice__run,
.db-lattice[data-status="error"] .db-lattice__run { opacity: 0; }
.db-lattice[data-status="done"] .db-lattice__run .db-lattice__cell,
.db-lattice[data-status="error"] .db-lattice__run .db-lattice__cell { animation-play-state: paused; }
.db-lattice[data-status="done"] .db-lattice__mark[data-mark="done"],
.db-lattice[data-status="error"] .db-lattice__mark[data-mark="error"] { opacity: 1; transform: none; }
.db-lattice[data-status="error"] .db-lattice__mark .db-lattice__cell[data-on] { background: var(--danger, #f87171); }
@keyframes dbll-on {
  0%, 100% { opacity: var(--dbll-idle); }
  18%, 42% { opacity: var(--dbll-peak); }
  62% { opacity: var(--dbll-idle); }
}
@media (prefers-reduced-motion: reduce) {
  .db-lattice__run .db-lattice__cell { animation-delay: 0ms !important; animation-duration: 1400ms !important; }
  .db-lattice__mark { transform: none; }
}
/* hide the stock pulsing dot while the lattice is showing */
.status-line.db-lattice-on .dot { display: none; }

/* ============================================================
   2. Hold Button — press-and-hold to confirm
   ============================================================ */
.db-hold {
  --hb-radius: 12px;
  --hb-bg: var(--bg-card-2, #1a2230);
  --hb-fill: var(--accent, #5B74FF);
  --hb-text: var(--text, #eef2f8);
  --hb-fill-text: #ffffff;
  --hb-hold: 1200ms;
  --hb-release: 220ms;
  --hb-press: 0.97;
  --hb-wave: 6px;
  --hb-w: 0px;
  --hb-h: 0px;
  --hb-cycles: 1.1;
  --hb-p: 0;
  --hb-ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  position: relative;
  display: inline-grid;
  place-items: center;
  isolation: isolate;
  margin: 0;
  border: 1px solid var(--border, #232c3d);
  border-radius: var(--hb-radius);
  background: var(--hb-bg);
  color: var(--hb-text);
  font-family: inherit;
  font-weight: 700;
  font-size: 1rem;
  line-height: 1;
  padding: 14px 28px;
  box-shadow: 0 8px 24px rgba(91, 116, 255, 0.18);
  cursor: pointer;
  outline: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: transform 160ms var(--hb-ease-out), box-shadow var(--hb-release) var(--hb-ease-out);
}
.db-hold[data-phase="holding"][data-input="pointer"] { transform: scale(var(--hb-press)); }
.db-hold[data-phase="holding"] {
  box-shadow: 0 8px 24px rgba(91, 116, 255, 0.18), 0 10px 32px -6px rgba(91, 116, 255, 0.7);
  transition: transform 160ms var(--hb-ease-out), box-shadow var(--hb-hold) linear;
}
.db-hold:focus-visible { outline: 2px solid var(--hb-fill); outline-offset: 3px; }
.db-hold:disabled { opacity: 0.55; cursor: not-allowed; box-shadow: none; }
.db-hold__label { position: relative; z-index: 2; display: grid; place-items: center; }
.db-hold__label > span {
  grid-area: 1 / 1;
  display: inline-flex; align-items: center; gap: 8px; white-space: nowrap;
  transition: opacity 200ms ease, filter 200ms ease;
}
.db-hold__done { opacity: 0; filter: blur(2px); }
.db-hold[data-phase="done"] .db-hold__idle { opacity: 0; filter: blur(2px); }
.db-hold[data-phase="done"] .db-hold__done { opacity: 1; filter: blur(0); }
.db-hold__clip {
  position: absolute; inset: 0; z-index: 3;
  clip-path: inset(0 round var(--hb-radius));
  pointer-events: none;
}
.db-hold__fill {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  background: var(--hb-fill); color: var(--hb-fill-text);
  clip-path: inset(0 calc((1 - var(--hb-p)) * (100% + 0.75 * var(--hb-wave)) - var(--hb-p) * 0.25 * var(--hb-wave)) 0 0);
}
.db-hold__crest {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  background: var(--hb-fill); color: var(--hb-fill-text);
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='200' viewBox='0 0 20 200' preserveAspectRatio='none'%3E%3Cpath d='M0 0H10C18 8 18 25.3 10 33.3S2 58.7 10 66.7S18 92 10 100S2 125.3 10 133.3S18 158.7 10 166.7S2 192 10 200H0Z'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='200' viewBox='0 0 20 200' preserveAspectRatio='none'%3E%3Cpath d='M0 0H10C18 8 18 25.3 10 33.3S2 58.7 10 66.7S18 92 10 100S2 125.3 10 133.3S18 158.7 10 166.7S2 192 10 200H0Z'/%3E%3C/svg%3E");
  -webkit-mask-repeat: repeat-y; mask-repeat: repeat-y;
  -webkit-mask-size: var(--hb-wave) calc(var(--hb-h) * 2);
  mask-size: var(--hb-wave) calc(var(--hb-h) * 2);
  -webkit-mask-position-x: calc(-1 * var(--hb-wave) + var(--hb-p) * (var(--hb-w) + var(--hb-wave)));
  mask-position-x: calc(-1 * var(--hb-wave) + var(--hb-p) * (var(--hb-w) + var(--hb-wave)));
  -webkit-mask-position-y: calc(-1 * var(--hb-p) * var(--hb-cycles) * var(--hb-h));
  mask-position-y: calc(-1 * var(--hb-p) * var(--hb-cycles) * var(--hb-h));
}
.db-hold__pulse { position: absolute; inset: 0; z-index: 0; border-radius: var(--hb-radius); pointer-events: none; opacity: 0; }
.db-hold[data-phase="done"] .db-hold__pulse { animation: dbhb-pulse 600ms var(--hb-ease-out) forwards; }
@keyframes dbhb-pulse {
  from { opacity: 1; box-shadow: 0 0 0 0 rgba(91, 116, 255, 0.55); }
  to { opacity: 0; box-shadow: 0 0 0 14px rgba(91, 116, 255, 0); }
}
@media (prefers-reduced-motion: reduce) {
  .db-hold { transform: none !important; }
  .db-hold__fill { clip-path: inset(0); opacity: 0; transition: opacity var(--hb-release) ease; }
  .db-hold__crest { display: none; }
  .db-hold[data-phase="holding"] .db-hold__fill,
  .db-hold[data-phase="done"] .db-hold__fill { opacity: 1; transition: opacity var(--hb-hold) linear; }
  .db-hold__pulse { animation: none !important; }
  .db-hold__label > span { filter: none !important; }
}

/* ============================================================
   3. Glide Select — segmented control with gliding indicator
   ============================================================ */
.db-glide { position: relative; }
.db-glide__pill {
  position: absolute; top: 0; left: 0; z-index: 0;
  border: 1px solid var(--accent, #5B74FF);
  background: rgba(91, 116, 255, 0.1);
  border-radius: 9px;
  pointer-events: none;
  transition: transform 300ms cubic-bezier(0.22, 1, 0.36, 1),
              width 300ms cubic-bezier(0.22, 1, 0.36, 1),
              height 300ms cubic-bezier(0.22, 1, 0.36, 1),
              opacity 200ms ease;
}
.db-glide .opt-btn {
  position: relative; z-index: 1;
  background: transparent !important;
  border-color: transparent !important;
  color: var(--text-dim, #a7b2c5);
  transition: color 200ms ease, background-color 200ms ease;
}
.db-glide .opt-btn.is-active {
  background: transparent !important;
  border-color: transparent !important;
  color: var(--accent, #5B74FF);
}
.db-glide .opt-btn:hover { background: rgba(91, 116, 255, 0.05) !important; }
@media (prefers-reduced-motion: reduce) {
  .db-glide__pill { transition: none; }
}

/* ============================================================
   4. Jelly Radio — jelly-physics radio chips
   ============================================================ */
.db-jelly {
  --jr-chip: var(--bg-card-2, #1a2230);
  --jr-active: var(--accent, #5B74FF);
  --jr-text: var(--text-dim, #a7b2c5);
  --jr-active-text: #ffffff;
  --jr-gap: 8px;
  --jr-radius: 10px;
  --jr-h: 34px;
  --jr-font: 0.9rem;
  --jr-px: 16px;
  /* tight container: no horizontal padding — the first chip's left
     edge must sit flush with the rows below (brush toolbar, product
     size). Gap between chips comes from .opt-btns, not the container. */
  --jr-pad-x: 0px;
  --jr-pad-y: 2px;
  --jr-ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  display: inline-flex; align-items: center; gap: var(--jr-gap);
  padding: var(--jr-pad-y) var(--jr-pad-x);
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
.db-jelly__chip {
  position: relative; margin: 0; padding: 0; border: 0; background: none;
  color: inherit; font: inherit; cursor: pointer; outline: none;
  transform-origin: 50% 50%;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  will-change: transform;
}
.db-jelly__chip:focus-visible { outline: 2px solid var(--jr-active); outline-offset: 3px; border-radius: var(--jr-radius); }
.db-jelly__skin {
  position: relative;
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4em;
  height: var(--jr-h); padding: 0 var(--jr-px);
  border: 1px solid var(--border, #232c3d);
  border-radius: var(--jr-radius);
  overflow: hidden;
  background: var(--jr-chip); color: var(--jr-text);
  font-size: var(--jr-font); font-weight: 600; line-height: 1; white-space: nowrap;
  transition: background-color 200ms ease, color 200ms ease, border-color 200ms ease;
}
@media (hover: hover) and (pointer: fine) {
  .db-jelly__chip[data-on="false"]:hover .db-jelly__skin { border-color: var(--accent, #5B74FF); color: var(--text, #eef2f8); }
}
.db-jelly__chip[data-on="true"] .db-jelly__skin {
  background: var(--jr-active); border-color: var(--jr-active); color: var(--jr-active-text);
  box-shadow: 0 6px 18px rgba(91, 116, 255, 0.35);
}

/* ============================================================
   5. Peek Rating — "how was your result?" star widget
   ============================================================ */
.db-rate-card {
  margin: 18px 0 0; padding: 16px 18px;
  border: 1px solid var(--border-soft, #1b2331); border-radius: var(--radius, 14px);
  background: var(--bg-soft, #11151d);
}
.db-rate-card[hidden] { display: none; }
.db-rate-title { margin: 0 0 4px; font-size: 0.95rem; font-weight: 700; color: var(--text, #eef2f8); }
.db-rate-sub { margin: 0 0 10px; font-size: 0.82rem; color: var(--text-dim, #a7b2c5); }
.db-rate-thanks { margin: 6px 0 0; font-size: 0.88rem; color: var(--success, #34d399); font-weight: 600; }
.db-rate-thanks[hidden] { display: none; }
.db-rate {
  --pr-active: #f5b400;
  --pr-idle: #3a4358;
  --pr-tip: var(--bg-card-2, #1a2230);
  --pr-tip-text: var(--text, #eef2f8);
  --pr-size: 30px;
  --pr-gap: 6px;
  --pr-room: 34px;
  --pr-rise: 320ms;
  --pr-ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  display: inline-flex;
  font-family: inherit; color: inherit;
}
.db-rate__row {
  position: relative;
  display: inline-flex; align-items: flex-end;
  padding-top: var(--pr-room);
  touch-action: pan-y;
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}
.db-rate__star {
  display: grid; place-items: center;
  width: calc(var(--pr-size) + var(--pr-gap)); height: calc(var(--pr-size) + 8px);
  margin: 0; padding: 0; border: 0; background: none; color: inherit; font: inherit;
  outline: none; touch-action: manipulation; cursor: pointer;
}
.db-rate__star:focus-visible { outline: 2px solid var(--pr-active); outline-offset: 2px; border-radius: 6px; }
@media (pointer: coarse) { .db-rate__star { min-width: 44px; min-height: 44px; } }
.db-rate__lift { display: block; transform: translateY(0) scale(1); transform-origin: 50% 100%; transition: transform var(--pr-rise) var(--pr-ease-out); }
.db-rate__glyph { display: block; width: var(--pr-size); height: var(--pr-size); color: var(--pr-idle); transition: color 160ms ease; }
.db-rate__glyph > svg { display: block; width: 100%; height: 100%; }
.db-rate__glyph[data-lit="true"] { color: var(--pr-active); }
.db-rate__tip {
  position: absolute; top: 0; left: 0;
  display: inline-flex; align-items: center;
  height: calc(var(--pr-size) * 0.62); padding: 0 calc(var(--pr-size) * 0.32);
  border-radius: 999px; background: var(--pr-tip); color: var(--pr-tip-text);
  font-size: calc(var(--pr-size) * 0.38); font-weight: 600; line-height: 1; white-space: nowrap;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.25);
  opacity: 0; pointer-events: none;
  transition: transform var(--pr-rise) var(--pr-ease-out), opacity 180ms ease;
}
.db-rate__tip[data-show="true"] { opacity: 1; }
@media (prefers-reduced-motion: reduce) {
  .db-rate__lift { transition: none; }
  .db-rate__tip { transition: opacity 180ms ease; }
}

/* ============================================================
   6. Bell Toggle — the single "notify me" submit control on
      waitlist cards (2026-09-21: replaces the old submit button;
      the bell below the email field IS the submit button)
   ============================================================ */
.db-bellrow { display: flex; align-items: center; gap: 10px; margin: 10px 0 0; }
.db-bellrow__label { font-size: 0.85rem; color: var(--text-dim, #a7b2c5); }
.db-bell {
  --bt-color: var(--text-dim, #a7b2c5);
  --bt-bg: var(--bg-card-2, #1a2230);
  --bt-on-color: #ffffff;
  --bt-on-bg: var(--accent, #5B74FF);
  --bt-radius: 22px;
  --bt-fade: 200ms;
  --bt-pivot: 16%;
  --bt-h: 40px;
  --bt-fs: 0.85rem;
  --bt-icon: 16px;
  --bt-px: 16px;
  --bt-gap: 9px;
  --bt-press: 0.97;
  --bt-ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  position: relative; display: inline-grid; grid-template-columns: max-content;
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  transition: transform 160ms var(--bt-ease-out);
}
.db-bell[data-pressed] { transform: scale(var(--bt-press)); }
.db-bell__button {
  grid-area: 1 / 1;
  display: inline-flex; align-items: center; gap: var(--bt-gap);
  height: var(--bt-h); margin: 0; padding: 0 var(--bt-px);
  border: 1px solid var(--border, #232c3d); border-radius: var(--bt-radius);
  background: var(--bt-bg); color: var(--bt-color);
  font: inherit; font-size: var(--bt-fs); font-weight: 600; line-height: 1; white-space: nowrap;
  cursor: pointer; outline: none;
  touch-action: manipulation; -webkit-tap-highlight-color: transparent;
  transition: background-color var(--bt-fade) ease, color var(--bt-fade) ease, border-color var(--bt-fade) ease;
}
.db-bell__button:focus-visible { outline: 2px solid var(--bt-on-bg); outline-offset: 3px; }
.db-bell[data-on="true"] .db-bell__button { background: var(--bt-on-bg); border-color: var(--bt-on-bg); color: var(--bt-on-color); }
.db-bell[data-busy=""] { opacity: .55; }
.db-bell[data-busy=""] .db-bell__button { cursor: wait; }
@media (hover: hover) and (pointer: fine) {
  .db-bell__button:hover { border-color: var(--accent, #5B74FF); }
}
.db-bell__bell { position: relative; display: inline-grid; flex: none; width: var(--bt-icon); height: var(--bt-icon); }
.db-bell__glyph {
  display: inline-grid; place-items: center; grid-area: 1 / 1;
  width: var(--bt-icon); height: var(--bt-icon);
  transform-origin: 50% var(--bt-pivot);
}
.db-bell__glyph svg { width: 100%; height: 100%; }
.db-bell__wave {
  position: absolute; top: -3px; width: 14px; height: 14px;
  fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round;
  opacity: 0; pointer-events: none;
}
.db-bell__wave--left { right: calc(100% - 2px); transform-origin: 100% 100%; }
.db-bell__wave--right { left: calc(100% - 2px); transform-origin: 0% 100%; }
.db-bell__say { display: inline-grid; grid-template-columns: max-content; height: 18px; line-height: 18px; }
.db-bell__face { grid-area: 1 / 1; justify-self: start; opacity: 0; filter: blur(2px); transition: opacity var(--bt-fade) ease, filter var(--bt-fade) ease; }
.db-bell[data-on="false"] .db-bell__face--off,
.db-bell[data-on="true"] .db-bell__face--on { opacity: 1; filter: blur(0); }
@media (prefers-reduced-motion: reduce) {
  .db-bell[data-pressed] { transform: none; }
  .db-bell__face { filter: none !important; transition: opacity var(--bt-fade) ease; }
}
/* dim the waitlist form while notifications are toggled off */
form.waitlist.db-bell-off input,
form.waitlist.db-bell-off button[type="submit"] { opacity: 0.4; }
form.waitlist.db-bell-off input:disabled,
form.waitlist.db-bell-off button[type="submit"]:disabled { cursor: not-allowed; }

/* WS7 (2026-10-18): problem-report dialog */
.pr-overlay {
  position: fixed; inset: 0; z-index: 9999;
  background: rgba(4, 7, 16, .78);
  display: flex; align-items: center; justify-content: center;
  padding: 20px; box-sizing: border-box;
}
.pr-sheet {
  width: min(94vw, 520px); max-height: 90vh; overflow: auto;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 16px; padding: 22px; box-sizing: border-box;
  box-shadow: 0 24px 80px rgba(0, 0, 0, .5);
}
.pr-sheet h3 { margin: 0 0 6px; font-size: 1.15rem; }
.pr-sub { margin: 0 0 14px; color: var(--text-dim); font-size: .9rem; }
.pr-label { display: block; font-weight: 700; font-size: .88rem; margin: 12px 0 6px; }
.pr-desc {
  width: 100%; box-sizing: border-box; min-height: 88px; resize: vertical;
  font: inherit; font-size: .92rem; color: var(--text);
  background: var(--bg-soft); border: 1px solid var(--border);
  border-radius: 10px; padding: 10px 12px;
}
.pr-desc:focus { border-color: var(--accent); outline: 2px solid var(--accent); outline-offset: 1px; }
.pr-diag {
  margin: 0; padding: 10px 12px; border-radius: 10px;
  background: var(--bg-soft); border: 1px solid var(--border-soft);
  font-size: .8rem; line-height: 1.5; white-space: pre-wrap; word-break: break-word;
  color: var(--text-dim); max-height: 180px; overflow: auto;
}
.pr-note { font-size: .8rem; color: var(--text-faint); margin: 8px 0 0; }
.pr-err { color: var(--danger); font-size: .88rem; font-weight: 600; margin: 8px 0 0; }
.pr-err[hidden] { display: none; }
.pr-actions { display: flex; gap: 10px; margin-top: 16px; flex-wrap: wrap; }
