/* ================================================================
   GIFTWRAP - desk.css ("The Wrapping Desk")
   Concierge chat panel styled in The Wrapping Table palette.
   All colors, fonts, and radii come from theme.css.
   ================================================================ */

/* ---------- floating launcher ---------- */
.desk-fab {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 80;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 8px 18px 8px 10px;
  border-radius: 999px;
  border: 1px solid var(--night-line);
  background: var(--night);
  color: var(--on-night);
  font-family: var(--sans);
  font-size: 14.5px;
  font-weight: 600;
  box-shadow: 0 14px 32px -12px color-mix(in srgb, var(--night) 65%, transparent);
  transition: transform var(--t-fast) var(--ease-out), background var(--t-fast), border-color var(--t-fast);
}
.desk-fab:hover {
  background: var(--night-2);
  border-color: var(--kraft-deep);
  transform: translateY(-2px);
}
.desk-fab:active {
  transform: translateY(0);
}
.desk-fab img {
  width: 28px;
  height: 28px;
  display: block;
  flex: none;
}
.desk-fab-label {
  white-space: nowrap;
}
.desk-fab[hidden],
.desk-send-card[hidden],
.js-open-desk[hidden],
.js-desk-entry[hidden] {
  display: none !important;
}

/* ---------- inline send-page card ---------- */
.desk-send-card {
  margin-top: 22px;
  padding: 18px 20px;
  background: var(--card);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  display: grid;
  gap: 10px;
  justify-items: start;
}
.desk-send-card[hidden] {
  display: none;
}
.desk-send-k {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.04em;
  color: var(--ribbon);
  text-transform: uppercase;
}
.desk-send-p {
  font-size: 14.5px;
  color: var(--ink-soft);
  line-height: 1.5;
}

/* ---------- chat panel ---------- */
.desk-panel {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 95;
  width: min(420px, calc(100vw - 32px));
  height: min(620px, calc(100svh - 40px));
  display: flex;
  flex-direction: column;
  background: var(--paper);
  color: var(--ink);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 26px 64px -20px color-mix(in srgb, var(--night) 48%, transparent);
}
.desk-panel[hidden] {
  display: none;
}
.desk-panel::before {
  content: "";
  display: block;
  height: 3px;
  flex: none;
  background: var(--ribbon);
}

/* header */
.desk-head {
  flex: none;
  background: var(--night);
  color: var(--on-night);
  padding: 13px 14px 13px 16px;
  display: flex;
  align-items: center;
  gap: 11px;
  border-bottom: 1px solid var(--night-line);
}
.desk-head-seal {
  width: 30px;
  height: 30px;
  flex: none;
  display: block;
}
.desk-head-text {
  min-width: 0;
  flex: 1;
}
body .desk-panel .desk-title {
  margin: 0;
  font-family: var(--serif);
  font-weight: var(--display-weight);
  font-size: 24px;
  line-height: 1.08;
  letter-spacing: 0;
  color: var(--on-night);
}
.desk-sub {
  margin-top: 2px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--on-night-soft);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.desk-head-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: none;
}
.desk-reset {
  min-height: 36px;
  padding: 0 10px;
  border-radius: var(--radius-small);
  border: 1px solid var(--night-line);
  background: transparent;
  color: var(--on-night-soft);
  font-family: var(--mono);
  font-size: 11.5px;
  transition: border-color var(--t-fast), color var(--t-fast);
}
.desk-reset:hover {
  border-color: var(--on-night-soft);
  color: var(--on-night);
}
.desk-reset[hidden] {
  display: none;
}
.desk-close {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: var(--radius-small);
  background: transparent;
  color: var(--on-night);
  transition: background var(--t-fast);
}
.desk-close:hover {
  background: var(--night-2);
}
.desk-close svg {
  width: 18px;
  height: 18px;
}

/* messages log */
.desk-log {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overscroll-behavior: contain;
}

.desk-msg {
  max-width: 90%;
  font-size: 15px;
  line-height: 1.55;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.desk-msg p + p {
  margin-top: 8px;
}

.desk-msg.is-bot {
  align-self: flex-start;
  background: var(--card);
  color: var(--ink);
  border: 1px solid var(--hairline);
  border-radius: 4px 12px 12px 12px;
  padding: 11px 14px;
}
.desk-who {
  display: block;
  margin-bottom: 5px;
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ribbon);
}

.desk-msg.is-user {
  align-self: flex-end;
  background: var(--ink);
  color: var(--paper);
  border-radius: 12px 12px 4px 12px;
  padding: 10px 14px;
  white-space: pre-wrap;
}

/* apply-to-card action (shown on send.html when a quoted note is drafted) */
.desk-use-note {
  margin-top: 10px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  padding: 5px 12px;
  border-radius: var(--radius-small);
  border: 1px solid var(--hairline);
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 12.5px;
  font-weight: 600;
  transition: border-color var(--t-fast), color var(--t-fast);
}
.desk-use-note:hover {
  border-color: var(--ribbon);
  color: var(--ribbon);
}
.desk-use-note.applied {
  border-color: var(--st-unwrapped);
  color: var(--st-unwrapped);
}

/* starter suggestion chips */
.desk-starters {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 2px;
}
.desk-starters[hidden] {
  display: none;
}
.desk-starters-label {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--ink-faint);
}
.desk-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.desk-chip {
  min-height: 40px;
  padding: 8px 12px;
  border-radius: var(--radius-small);
  border: 1px solid var(--hairline);
  background: var(--card);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 13.5px;
  font-weight: 500;
  text-align: left;
  line-height: 1.3;
  transition: border-color var(--t-fast), background var(--t-fast), color var(--t-fast);
}
.desk-chip:hover {
  border-color: var(--ribbon);
  background: var(--ribbon-tint);
  color: var(--ribbon-deep);
}

/* typing indicator */
.desk-typing {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  background: var(--card);
  border: 1px solid var(--hairline);
  border-radius: 4px 12px 12px 12px;
  padding: 10px 14px;
  font-size: 13.5px;
  color: var(--ink-soft);
}
.desk-dots {
  display: inline-flex;
  gap: 4px;
  align-items: center;
}
.desk-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ribbon);
  opacity: 0.35;
  animation: desk-dot-pulse 1.1s ease-in-out infinite;
}
.desk-dots span:nth-child(2) {
  animation-delay: 0.18s;
}
.desk-dots span:nth-child(3) {
  animation-delay: 0.36s;
}
@keyframes desk-dot-pulse {
  0%, 80%, 100% { opacity: 0.3; transform: translateY(0); }
  40% { opacity: 1; transform: translateY(-2px); }
}

/* resting / error notice */
.desk-notice {
  background: var(--ribbon-tint);
  border: 1px solid color-mix(in srgb, var(--ribbon) 35%, transparent);
  border-radius: var(--radius-small);
  padding: 13px 14px;
  color: var(--ink);
  font-size: 14px;
  line-height: 1.5;
  display: grid;
  gap: 8px;
}
.desk-notice-title {
  font-family: var(--serif);
  font-size: 20px;
  line-height: 1.1;
  color: var(--ribbon-deep);
}
.desk-notice-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 2px;
}
.desk-notice-link {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 6px 12px;
  border-radius: var(--radius-small);
  border: 1px solid var(--ribbon-deep);
  background: var(--card);
  color: var(--ribbon-deep);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
}
.desk-notice-link:hover {
  background: var(--ribbon-deep);
  color: var(--on-ribbon);
}

/* composer */
.desk-form {
  flex: none;
  border-top: 1px solid var(--hairline);
  background: var(--card);
  padding: 10px 12px;
  display: flex;
  align-items: flex-end;
  gap: 8px;
}
.desk-input {
  flex: 1;
  min-width: 0;
  min-height: 44px;
  max-height: 112px;
  resize: none;
  padding: 10px 12px;
  border: 1px solid var(--hairline);
  border-radius: var(--radius-small);
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.4;
  cursor: text;
}
.desk-input::placeholder {
  color: var(--ink-faint);
}
.desk-input:focus {
  outline: 2px solid var(--ribbon);
  outline-offset: 1px;
  border-color: var(--ribbon);
}
.desk-input:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}
.desk-send {
  flex: none;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: var(--radius-small);
  background: var(--ribbon);
  color: var(--on-ribbon);
  display: grid;
  place-items: center;
  transition: background var(--t-fast), opacity var(--t-fast);
}
.desk-send:hover:not(:disabled) {
  background: var(--ribbon-deep);
}
.desk-send:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.desk-send svg {
  width: 18px;
  height: 18px;
}

/* ---------- mobile (390px and narrow screens) ---------- */
@media (max-width: 640px) {
  .desk-fab {
    right: 14px;
    bottom: 14px;
    padding: 7px 14px 7px 9px;
    font-size: 13.5px;
  }
  .desk-fab img {
    width: 24px;
    height: 24px;
  }
}

@media (max-width: 560px) {
  .desk-panel {
    inset: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    max-width: 100vw;
    height: 100dvh;
    max-height: 100dvh;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }
  .desk-form {
    padding: 10px 12px max(12px, env(safe-area-inset-bottom));
  }
}

@media (prefers-reduced-motion: reduce) {
  .desk-fab, .desk-chip, .desk-send, .desk-reset, .desk-close {
    transition: none;
  }
  .desk-dots span {
    animation: none;
    opacity: 0.7;
  }
}
