/*
 * Pit Crew widget — Westy.
 *
 * Note: this file ships unused at the document level — the JS module
 * inlines an identical stylesheet inside the widget's Shadow DOM so we
 * never bleed styles into the host theme. We keep this copy on disk for
 * editor tooling + admin preview.
 *
 * Palette:
 *   --stc-ink:       #1f1a14   (warm near-black)
 *   --stc-paper:     #f4ecdc   (warm paper)
 *   --stc-wheat:     #d8b378   (accent)
 *   --stc-wheat-dim: #b0894d
 *   --stc-rust:      #b04a2b
 */

:host {
  --stc-ink: #1f1a14;
  --stc-paper: #f4ecdc;
  --stc-wheat: #d8b378;
  --stc-wheat-dim: #b0894d;
  --stc-rust: #b04a2b;
  --stc-shadow: 0 18px 48px rgba(31, 26, 20, 0.28);
  position: fixed;
  z-index: 999999;
  bottom: 0;
  right: 0;
  pointer-events: none;
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

button {
  font-family: inherit;
  cursor: pointer;
}

/* Idle pill */
.pc-idle {
  pointer-events: auto;
  position: absolute;
  bottom: 16px;
  right: 16px;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  height: 48px;
  max-width: 320px;
  padding: 4px 18px 4px 4px;
  background: var(--stc-ink);
  color: var(--stc-paper);
  border: 1px solid var(--stc-wheat);
  border-radius: 999px;
  box-shadow: var(--stc-shadow);
  cursor: pointer;
  transition: transform 200ms ease, box-shadow 200ms ease;
}
.pc-idle:hover {
  transform: translateY(-2px);
  box-shadow: 0 22px 56px rgba(31, 26, 20, 0.34);
}
.pc-idle .pc-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--stc-paper);
  background-size: cover;
  background-position: center;
  flex: 0 0 auto;
}
.pc-idle .pc-label {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.4px;
  text-transform: uppercase;
}
.pc-idle .pc-glow {
  position: absolute;
  inset: -4px;
  border-radius: 999px;
  pointer-events: none;
  box-shadow: 0 0 0 0 rgba(216, 179, 120, 0.45);
  animation: pc-pulse 3.4s ease-in-out infinite;
}
@keyframes pc-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(216, 179, 120, 0.45); }
  50%      { box-shadow: 0 0 0 8px rgba(216, 179, 120, 0); }
}

/* Nudge bubble */
.pc-nudge {
  pointer-events: auto;
  position: absolute;
  bottom: 76px;
  right: 16px;
  max-width: 300px;
  padding: 14px 16px;
  background: var(--stc-paper);
  color: var(--stc-ink);
  border: 1px solid var(--stc-wheat);
  border-radius: 14px 14px 4px 14px;
  box-shadow: var(--stc-shadow);
  font-size: 14px;
  line-height: 1.4;
  cursor: pointer;
  animation: pc-fade-in 240ms ease-out;
}
.pc-nudge::after {
  content: "";
  position: absolute;
  bottom: -8px;
  right: 24px;
  width: 14px;
  height: 14px;
  background: var(--stc-paper);
  border-right: 1px solid var(--stc-wheat);
  border-bottom: 1px solid var(--stc-wheat);
  transform: rotate(45deg);
}
.pc-nudge .pc-nudge-close {
  position: absolute;
  top: 6px;
  right: 8px;
  background: none;
  border: 0;
  color: var(--stc-wheat-dim);
  font-size: 16px;
  line-height: 1;
}

/* Takeover panel */
.pc-takeover {
  pointer-events: auto;
  position: fixed;
  right: 24px;
  bottom: 24px;
  width: 420px;
  max-width: calc(100vw - 32px);
  max-height: calc(100vh - 48px);
  background: var(--stc-paper);
  color: var(--stc-ink);
  border-radius: 18px;
  box-shadow: var(--stc-shadow);
  border: 1px solid var(--stc-wheat);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  animation: pc-slide-up 260ms ease-out;
}
.pc-takeover .pc-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 20px;
  background: linear-gradient(180deg, var(--stc-ink) 0%, #2a221a 100%);
  color: var(--stc-paper);
}
.pc-takeover .pc-head .pc-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background-size: cover;
  background-position: center;
  border: 2px solid var(--stc-wheat);
  flex: 0 0 auto;
}
.pc-takeover .pc-head h2 {
  margin: 0;
  font-family: "Playfair Display", Georgia, serif;
  font-size: 20px;
  letter-spacing: 0.2px;
}
.pc-takeover .pc-head small {
  display: block;
  font-size: 11px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--stc-wheat);
}
.pc-takeover .pc-close {
  margin-left: auto;
  background: transparent;
  color: var(--stc-paper);
  border: 1px solid var(--stc-wheat-dim);
  border-radius: 999px;
  width: 30px;
  height: 30px;
  font-size: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.pc-takeover .pc-body {
  padding: 18px 20px;
  overflow-y: auto;
  flex: 1 1 auto;
}
.pc-takeover h3 {
  font-family: "Playfair Display", Georgia, serif;
  font-size: 22px;
  margin: 0 0 6px 0;
  line-height: 1.2;
}
.pc-takeover p {
  margin: 0 0 14px 0;
  font-size: 14px;
  line-height: 1.5;
}

/* YMM picker */
.pc-ymm {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-bottom: 14px;
}
.pc-ymm input,
.pc-ymm select {
  width: 100%;
  padding: 9px 10px;
  border: 1px solid var(--stc-wheat-dim);
  background: #fff;
  color: var(--stc-ink);
  border-radius: 6px;
  font-size: 13px;
}

/* Email + consent */
.pc-form label {
  display: block;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--stc-wheat-dim);
  margin: 6px 0 4px;
}
.pc-form input[type="email"] {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--stc-wheat-dim);
  background: #fff;
  color: var(--stc-ink);
  border-radius: 6px;
  font-size: 14px;
}
.pc-form .pc-consent {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 12px;
  margin: 10px 0 14px;
  color: #4a3e2a;
  line-height: 1.45;
}
.pc-form .pc-consent input {
  margin-top: 3px;
}
.pc-actions {
  display: flex;
  gap: 8px;
  margin-top: 6px;
}
.pc-btn {
  border: 0;
  background: var(--stc-ink);
  color: var(--stc-paper);
  padding: 11px 18px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.3px;
}
.pc-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.pc-btn.pc-secondary {
  background: transparent;
  color: var(--stc-ink);
  border: 1px solid var(--stc-wheat-dim);
}
.pc-error {
  background: #fde7e0;
  color: #8a2410;
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 12px;
  margin-bottom: 10px;
}
.pc-success {
  background: #e2efd9;
  color: #2f5018;
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 13px;
  margin-bottom: 10px;
}
.pc-code {
  display: inline-block;
  font-family: Menlo, Consolas, monospace;
  background: var(--stc-ink);
  color: var(--stc-wheat);
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 16px;
  letter-spacing: 2px;
  margin: 6px 8px 6px 0;
}

/* Chat surface */
.pc-chat {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 420px;
  overflow-y: auto;
  padding: 12px 0;
}
.pc-msg {
  max-width: 85%;
  padding: 10px 12px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.45;
  white-space: pre-wrap;
  word-wrap: break-word;
}
.pc-msg.user {
  background: var(--stc-ink);
  color: var(--stc-paper);
  align-self: flex-end;
  border-bottom-right-radius: 3px;
}
.pc-msg.assistant {
  background: #fff;
  color: var(--stc-ink);
  border: 1px solid var(--stc-wheat);
  align-self: flex-start;
  border-bottom-left-radius: 3px;
}
.pc-typing {
  align-self: flex-start;
  font-size: 12px;
  color: var(--stc-wheat-dim);
  font-style: italic;
}
.pc-chat-input {
  display: flex;
  gap: 8px;
  padding: 10px 0 0 0;
  border-top: 1px solid var(--stc-wheat);
  margin-top: 8px;
}
.pc-chat-input input {
  flex: 1 1 auto;
  padding: 10px 12px;
  border: 1px solid var(--stc-wheat-dim);
  border-radius: 8px;
  font-size: 14px;
}

/* Mobile: full-height sheet */
@media (max-width: 640px) {
  .pc-takeover {
    right: 0;
    bottom: 0;
    width: 100vw;
    max-width: 100vw;
    height: 92vh;
    max-height: 92vh;
    border-radius: 18px 18px 0 0;
    border-bottom: 0;
  }
  .pc-idle {
    bottom: 12px;
    right: 12px;
  }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .pc-idle, .pc-nudge, .pc-takeover, .pc-idle .pc-glow {
    animation: none !important;
    transition: none !important;
  }
}

@keyframes pc-fade-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes pc-slide-up {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}
