/* ============================================================================
   The logo interview, in the chat box (owner, Sept 29) — js/logo-interview.js.
   One question at a time, answered with big taps (44px and up, a phone's
   thumb), then four logos in a 2x2 grid with "Use this one" on each.
   Every colour is a tenant token; the only literal colours on these cards are
   the swatch dots, which are set inline from the question's own data.
   ========================================================================== */

/* "Do you have a logo?" answered two ways, side by side (chat.js renderGuide) */
.guide__acts {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 10px 0 0 15px;
}
.guide__acts .msg__action {
  margin: 0;
  min-height: 44px;
  padding: 8px 16px;
  font-size: var(--fs-body);
}
.guide__acts .guide__design {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
}
.guide__acts .guide__design:hover { background: var(--accent); opacity: .92; }

.msg--logo { align-items: stretch; gap: 0; }
.msg--logo > * { padding-left: 15px; border-left: 1px solid var(--line); }

.logoq__say {
  font-size: var(--fs-body);
  line-height: 1.55;
  color: var(--ink-70);
  padding-bottom: 4px;
}
.logoq__time { color: var(--muted); font-variant-numeric: tabular-nums; font-size: var(--fs-small); }

.msg--logo .logoq__q {
  font-size: var(--fs-lead);
  line-height: 1.4;
  color: var(--ink);
  padding-top: 4px;
}
.msg--logo .logoq__q strong { font-weight: 700; }
.logoq__hint {
  font-size: var(--fs-small);
  color: var(--muted);
  line-height: 1.5;
  padding-top: 3px;
}

/* ---- the taps ---- */
.logoq__choices {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding-top: 10px;
}
.logoq__chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 8px 16px;
  border: 1px solid var(--accent-line);
  border-radius: 999px;
  background: var(--paper);
  color: var(--ink);
  font-size: var(--fs-body);
  font-weight: 500;
  line-height: 1.2;
  text-align: left;
  max-width: 100%;
  cursor: pointer;
  transition: background var(--dur, 160ms) var(--ease), border-color var(--dur, 160ms) var(--ease);
}
.logoq__chip:hover:not(:disabled) { background: var(--accent-soft); border-color: var(--accent); }
.logoq__chip:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.logoq__chip:disabled { opacity: .55; cursor: default; }
.logoq__chip--ghost {
  border-style: dashed;
  color: var(--ink-70);
  font-weight: 500;
}
.logoq__label { overflow-wrap: anywhere; }
.logoq__swatch { display: inline-flex; flex: none; }
.logoq__swatch i {
  display: block;
  width: 16px; height: 16px;
  border-radius: 50%;
  border: 1px solid var(--line);
}
.logoq__swatch i + i { margin-left: -5px; }

/* "Type my own" */
.logoq__text {
  display: flex;
  gap: 8px;
  padding-top: 10px;
  max-width: 100%;
}
.logoq__text[hidden] { display: none; }
.logoq__input {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 44px;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--paper);
  color: var(--ink);
  font: inherit;
  font-size: var(--fs-body);
}
.logoq__input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.logoq__ok { min-height: 44px; min-width: 64px; flex: none; }

.logoq__foot, .logoq__more, .logoq__acts {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 12px;
  padding-top: 8px;
}
.logoq__more, .logoq__acts { justify-content: flex-start; padding-top: 12px; }
.logoq__progress { font-size: var(--fs-micro); color: var(--muted); }
.logoq__link {
  min-height: 44px;
  padding: 0 6px;
  font-size: var(--fs-small);
  color: var(--accent);
  font-weight: 500;
  text-decoration: underline;
  text-underline-offset: 2px;
  background: none;
  border: 0;
  cursor: pointer;
}
.logoq__link:disabled { opacity: .5; cursor: default; }
.logoq__again, .logoq__big { min-height: 44px; padding: 0 18px; }

.logoq__error {
  margin-top: 10px;
  padding: 9px 12px 9px 15px;
  font-size: var(--fs-small);
  color: var(--warn-ink);
  background: var(--warn-soft);
  border-left: 2px solid var(--warn) !important;
  border-radius: 0 var(--r-sm) var(--r-sm) 0;
}

/* ---- four logos, 2x2 ---- */
.logogrid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  padding-top: 10px;
}
.logotile {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 8px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  min-width: 0;
}
.logotile.is-zoom { grid-column: 1 / -1; }
.logotile.is-kept { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.logotile__pic {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background: none;
  cursor: zoom-in;
  border-radius: var(--r-sm);
}
.logotile.is-zoom .logotile__pic { cursor: zoom-out; }
.logotile__img {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: contain;
  border-radius: var(--r-sm);
  /* a transparent logo reads as one on a checkerboard, never on a white box */
  background-color: var(--paper);
  background-image:
    linear-gradient(45deg, var(--line-soft) 25%, transparent 25%, transparent 75%, var(--line-soft) 75%),
    linear-gradient(45deg, var(--line-soft) 25%, transparent 25%, transparent 75%, var(--line-soft) 75%);
  background-size: 16px 16px;
  background-position: 0 0, 8px 8px;
}
.logotile__img--wait {
  background: linear-gradient(100deg, var(--line-soft) 20%, var(--accent-soft) 40%, var(--line-soft) 60%);
  background-size: 300% 100%;
  animation: logowait 1.6s var(--ease) infinite;
}
@keyframes logowait { from { background-position: 100% 0; } to { background-position: 0 0; } }
@media (prefers-reduced-motion: reduce) {
  .logotile__img--wait { animation: none; }
}
.logotile__use { min-height: 44px; width: 100%; justify-content: center; }
.logotile__flag, .logotile__kept {
  align-self: flex-start;
  font-size: var(--fs-micro);
  padding: 2px 8px;
  border-radius: 999px;
}
.logotile__flag { color: var(--warn-ink); background: var(--warn-soft); }
.logotile__kept { color: var(--accent); background: var(--accent-soft); font-weight: 600; }
.logotile__busy {
  position: absolute;
  left: 8px; right: 8px; top: 8px;
  aspect-ratio: 1 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 10px;
  font-size: var(--fs-small);
  font-weight: 600;
  color: var(--ink);
  background: var(--paper);
  opacity: .92;
  border-radius: var(--r-sm);
}
.logotile.is-busy .logotile__img { filter: blur(1px); }

/* a finished card keeps its question and its logos, not its buttons */
.msg--logo.is-done .logoq__q { color: var(--ink-70); }

/* ---- a phone (and any window where the chat is the short dock) ----
   The thread is normally a short strip above the card; four logos need room,
   so while the interview is open the strip grows. It shrinks back the moment
   the logo is on the card. */
@media (max-width: 1199px) {
  .dock.has-logoq .dock__thread { max-height: min(62dvh, 560px); }
}
@media (max-width: 480px) {
  .logogrid { gap: 8px; }
  .logotile { padding: 6px; }
  .logoq__chip { padding: 8px 14px; }
}

/* ============================================================================
   "Choose your logo" (owner, Sept 30) — js/logo-picker.js.
   The four candidates, LARGE, beside the chat: over the canvas on a desktop
   (>= 1200px), a full-width bottom sheet under the chat's input anywhere
   narrower. It never covers the composer; js/logo-picker.js measures the chat
   and places it in viewport pixels. Every colour is a tenant token.
   ========================================================================== */

.logopick {
  position: fixed;
  z-index: 31;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-float);
  overflow: hidden;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 180ms var(--ease), transform 220ms var(--ease);
}
.logopick[hidden] { display: none; }
/* the rest of the workspace, dimmed behind it on a desktop (never the chat) */
.logopick-scrim {
  position: fixed;
  top: 0; right: 0; bottom: 0; left: 0;
  z-index: 30;
  background: color-mix(in srgb, var(--workspace) 80%, transparent);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
}
.logopick-scrim[hidden] { display: none; }
.logopick.is-in { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) {
  .logopick { transition: none; transform: none; }
}

.logopick__head {
  flex: 0 0 auto;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px 12px 20px;
  border-bottom: 1px solid var(--line-soft);
}
.logopick__words { min-width: 0; }
.logopick__title {
  font-size: var(--fs-lead);
  font-weight: 700;
  letter-spacing: -0.005em;
  color: var(--ink);
  line-height: 1.3;
}
.logopick__sub {
  font-size: var(--fs-small);
  color: var(--muted);
  line-height: 1.45;
  padding-top: 2px;
}
.logopick__close {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  min-width: 44px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--paper);
  color: var(--ink-70);
  font-size: var(--fs-small);
  font-weight: 600;
  cursor: pointer;
}
.logopick__close:hover { background: var(--accent-soft); color: var(--accent); border-color: var(--accent-line); }
.logopick__close:focus-visible, .pickt__use:focus-visible, .logopick__more:focus-visible, .logopick__change:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* the four: two by two, sharing whatever height the panel has */
.logopick__grid {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-rows: repeat(2, minmax(0, 1fr));
  gap: 14px;
  padding: 16px 20px;
  /* the neutral backdrop the tiles sit on */
  background: var(--workspace);
  overflow: auto;
}
.pickt {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
  min-height: 0;
  padding: 10px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
}
.pickt:focus-within { border-color: var(--accent-line); box-shadow: 0 0 0 3px var(--accent-soft); }
.pickt__logo {
  position: relative;
  flex: 1 1 auto;
  min-height: 96px;
  border-radius: var(--r-sm);
  overflow: hidden;
  /* a transparent logo reads as one on a checkerboard, never on a white box */
  background-color: var(--paper);
  background-image:
    linear-gradient(45deg, var(--line-soft) 25%, transparent 25%, transparent 75%, var(--line-soft) 75%),
    linear-gradient(45deg, var(--line-soft) 25%, transparent 25%, transparent 75%, var(--line-soft) 75%);
  background-size: 16px 16px;
  background-position: 0 0, 8px 8px;
}
.pickt__img {
  position: absolute;
  inset: 6px;
  width: calc(100% - 12px);
  height: calc(100% - 12px);
  object-fit: contain;
}
.pickt__flag { position: absolute; left: 8px; top: 8px; }
.pickt__shimmer { position: absolute; inset: 0; }
.pickt__busy {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 12px;
  font-size: var(--fs-small);
  font-weight: 600;
  color: var(--ink);
  background: var(--paper);
  opacity: .92;
}
.pickt.is-busy .pickt__img { filter: blur(1px); }

.pickt__row {
  flex: 0 0 auto;
  display: flex;
  align-items: flex-end;
  gap: 10px;
  min-width: 0;
}
.pickt__on {
  flex: 0 0 56%;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.pickt__caption { font-size: var(--fs-micro); color: var(--muted); }
.pickt__use {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 44px;
  padding: 8px 10px;
  justify-content: center;
  font-size: var(--fs-small);
  font-weight: 600;
  white-space: nowrap;
}

/* the customer's own card, small */
.pickcard {
  position: relative;
  width: 100%;
  overflow: hidden;
  /* the details layer sizes its type in cqh: this box is its trim */
  container-type: size;
  background: var(--paper);
  border-radius: 3px;
  box-shadow: 0 0 0 1px var(--line), 0 4px 12px -6px rgba(20, 22, 28, 0.28);
  pointer-events: none;
}
.pickcard--wait {
  background: linear-gradient(100deg, var(--line-soft) 20%, var(--accent-soft) 40%, var(--line-soft) 60%);
  background-size: 300% 100%;
  animation: logowait 1.6s var(--ease) infinite;
}
@media (prefers-reduced-motion: reduce) { .pickcard--wait { animation: none; } }
.pickcard__art {
  position: absolute;
  max-width: none;
  z-index: 0;
}
.pickcard__layer { position: absolute; inset: 0; pointer-events: none; }
.pickcard .contact-layer { z-index: 3; }
.pickcard .aclip--under { z-index: 2; }
.pickcard .aclip--over { z-index: 4; }
/* a copied details layer shows the type only: no handles, outlines or hints */
.pickcard .contact-layer * { pointer-events: none !important; outline: none !important; }
.pickcard__logo {
  position: absolute;
  z-index: 2;
  max-width: none;
  object-fit: fill;
}
.pickcard__logo.is-unplaced { right: 6%; top: 8%; width: 24%; height: auto; }

.logopick__status {
  flex: 0 0 auto;
  padding: 8px 20px 0;
  font-size: var(--fs-small);
  color: var(--muted);
}
.logopick__status[hidden], .logopick__error[hidden] { display: none; }
.logopick__error { margin: 8px 20px 0; }

.logopick__foot {
  flex: 0 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 14px;
  padding: 12px 20px 14px;
  border-top: 1px solid var(--line-soft);
  background: var(--paper);
}
.logopick__more { min-height: 44px; padding: 0 18px; }
.logopick__more[hidden] { display: none; }

/* the sheet: under the chat, full width, scrolls if the screen is short */
.logopick[data-mode="sheet"] {
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  border-bottom: 0;
  box-shadow: 0 -8px 40px -12px rgba(0, 0, 0, .28);
}
.logopick[data-mode="sheet"] .logopick__head { padding: 12px 12px 10px 16px; }
.logopick[data-mode="sheet"] .logopick__sub { display: none; }
.logopick[data-mode="sheet"] .logopick__grid {
  grid-template-rows: none;
  grid-auto-rows: max-content;
  gap: 10px;
  padding: 12px;
}
.logopick[data-mode="sheet"] .pickt { padding: 8px; gap: 8px; min-height: auto; }
.logopick[data-mode="sheet"] .pickt__logo { flex: 0 0 auto; height: 88px; min-height: 0; }
.logopick[data-mode="sheet"] .pickt__row { flex-direction: column; align-items: stretch; gap: 8px; }
.logopick[data-mode="sheet"] .pickt__on { flex: 0 0 auto; }
.logopick[data-mode="sheet"] .pickt__use { width: 100%; }
.logopick[data-mode="sheet"] .logopick__foot { padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); }

/* ---- the chat keeps the four, small, in one row ---- */
.logogrid--mini { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.logogrid--mini .logotile { padding: 4px; gap: 4px; }
.logogrid--mini .logotile__pic { cursor: pointer; }
.logogrid--mini .logotile__flag { font-size: 10px; padding: 1px 5px; }
.logogrid--mini .logotile__busy { font-size: 0; padding: 0; }
.logoq__bigger { min-height: 44px; padding: 0 16px; }

/* while the chooser is open on a phone or tablet, the chat above it stays a
   short strip (its newest line and the input), so the four get the room */
@media (max-width: 1199px) {
  .dock.has-logopick .dock__thread { max-height: min(12dvh, 104px); }
  /* "choose my card" is for later; while choosing a logo it only takes room */
  .dock.has-logopick .dock__next { display: none; }
}
