/* St Lucie Smoke & Cigars — shop assistant chat panel.
   Uses the site's own colours, fonts and corner radius (css/site.css variables).
   Every class starts with "sla-" so nothing here can collide with the site's styles.

   Layers (the site's own: header 50, cart backdrop 80, cart drawer 90, age gate 100):
     launcher 60, panel 70. So the cart drawer slides over the chat, and the age gate
     covers everything. The panel never reaches the header, so the cart button stays
     in view and in reach. */

.sla-launch {
  position: fixed;
  right: max(14px, env(safe-area-inset-right));
  bottom: calc(14px + env(safe-area-inset-bottom));
  z-index: 60;
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  min-height: 46px;
  padding: 0 1rem 0 0.85rem;
  border: 1px solid var(--gold, #c29a3d);
  border-radius: 2px;
  background: var(--brown-3, #1c1614);
  color: var(--cream, #f6f0e4);
  font-family: var(--font-body, system-ui, sans-serif);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  cursor: pointer;
  box-shadow: 0 10px 30px rgba(28, 22, 20, 0.35);
  transition: background 0.15s, color 0.15s;
}
.sla-launch:hover { background: var(--brown-2, #3a2e29); color: var(--gold-2, #d9b86a); }
.sla-launch svg { display: block; flex: none; color: var(--gold-2, #d9b86a); }
.sla-launch[hidden] { display: none; }
/* Not before the 21+ gate has been answered, and not on top of the open cart. */
html:not(.age-ok) .sla-launch, html:not(.age-ok) .sla-panel { display: none; }

.sla-panel {
  position: fixed;
  left: 0;
  right: 0;
  bottom: var(--sla-bottom, 0px);
  z-index: 70;
  display: flex;
  flex-direction: column;
  height: min(var(--sla-avail, 78vh), 640px);
  max-height: var(--sla-avail, 78vh);
  background: var(--brown-3, #1c1614);
  color: var(--cream, #f6f0e4);
  border-top: 1px solid rgba(194, 154, 61, 0.55);
  box-shadow: 0 -18px 50px rgba(28, 22, 20, 0.45);
  font-family: var(--font-body, system-ui, sans-serif);
  font-size: 0.95rem;
  line-height: 1.5;
}
@supports (height: 1dvh) { .sla-panel { height: min(var(--sla-avail, 78dvh), 640px); max-height: var(--sla-avail, 78dvh); } }
.sla-panel[hidden] { display: none; }
@media (min-width: 720px) {
  .sla-launch { right: 24px; bottom: 24px; }
  .sla-panel {
    left: auto;
    right: 24px;
    bottom: 24px;
    width: 396px;
    height: min(var(--sla-avail, 80vh), 620px);
    border: 1px solid rgba(194, 154, 61, 0.55);
    border-radius: 2px;
    box-shadow: 0 18px 50px rgba(28, 22, 20, 0.45);
  }
}

/* ---------- head ---------- */
.sla-head {
  flex: none;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem 0.7rem 0.7rem 1rem;
  background: var(--brown, #2b2320);
  border-bottom: 1px solid rgba(194, 154, 61, 0.35);
}
.sla-head-text { flex: 1; min-width: 0; }
.sla-title { margin: 0; font-family: var(--font-display, Georgia, serif); font-weight: 500; font-size: 1.3rem; line-height: 1.15; color: var(--cream, #f6f0e4); letter-spacing: 0; }
.sla-sub { margin: 0.15rem 0 0; font-size: 0.64rem; font-weight: 600; letter-spacing: 0.18em; text-transform: uppercase; color: var(--gold-2, #d9b86a); }
.sla-head-btn {
  flex: none;
  min-width: 44px;
  height: 44px;
  padding: 0 0.6rem;
  border: 1px solid rgba(246, 240, 228, 0.3);
  border-radius: 2px;
  background: transparent;
  color: var(--cream, #f6f0e4);
  font-family: inherit;
  font-size: 0.66rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  cursor: pointer;
}
.sla-head-btn:hover { border-color: var(--cream, #f6f0e4); }
.sla-close { font-size: 1.5rem; letter-spacing: 0; line-height: 1; padding: 0; }

/* ---------- conversation ---------- */
.sla-log {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 1rem 1rem 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  scroll-behavior: smooth;
}
.sla-msg { margin: 0; max-width: 100%; overflow-wrap: anywhere; white-space: pre-line; }
.sla-msg--bot { padding-left: 0.8rem; border-left: 1px solid var(--gold, #c29a3d); color: rgba(246, 240, 228, 0.94); }
.sla-msg--you {
  align-self: flex-end;
  max-width: 86%;
  padding: 0.5rem 0.8rem;
  border: 1px solid rgba(246, 240, 228, 0.16);
  border-radius: 2px;
  background: rgba(246, 240, 228, 0.07);
  color: var(--cream, #f6f0e4);
}
.sla-msg--note { font-size: 0.82rem; color: rgba(246, 240, 228, 0.66); padding-left: 0.8rem; }
.sla-msg a, .sla-foot a, .sla-card-done a { color: var(--gold-2, #d9b86a); white-space: nowrap; }

.sla-starters { padding: 0; gap: 0.45rem; }
.sla-starter {
  min-height: 40px;
  padding: 0.4rem 0.75rem;
  border: 1px solid rgba(246, 240, 228, 0.28);
  border-radius: 2px;
  background: transparent;
  color: var(--cream, #f6f0e4);
  font: inherit;
  font-size: 0.84rem;
  text-align: left;
  cursor: pointer;
}
.sla-starter:hover { border-color: var(--gold, #c29a3d); color: var(--gold-2, #d9b86a); }

.sla-typing { display: inline-flex; gap: 5px; align-items: center; padding: 0.35rem 0 0.35rem 0.8rem; border-left: 1px solid var(--gold, #c29a3d); }
.sla-typing span { width: 6px; height: 6px; border-radius: 50%; background: var(--gold-2, #d9b86a); opacity: 0.35; animation: sla-pulse 1.2s infinite ease-in-out; }
.sla-typing span:nth-child(2) { animation-delay: 0.15s; }
.sla-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes sla-pulse { 0%, 80%, 100% { opacity: 0.3; } 40% { opacity: 1; } }

/* ---------- cards: product rows, add-to-cart card, hand-off form ---------- */
.sla-card {
  background: var(--cream, #f6f0e4);
  color: var(--ink, #221b18);
  border-radius: 2px;
  padding: 0.35rem 0.85rem;
}
.sla-items { list-style: none; margin: 0; padding: 0; }
.sla-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.55rem 0;
  border-bottom: 1px dotted rgba(107, 93, 84, 0.45);
}
.sla-item:last-child { border-bottom: 0; }
.sla-item-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.sla-item-name { font-weight: 500; font-size: 0.92rem; line-height: 1.3; color: var(--brown, #2b2320); overflow-wrap: anywhere; }
.sla-item-detail { font-size: 0.72rem; line-height: 1.35; color: var(--muted, #6b5d54); }
.sla-item-price { flex: none; font-variant-numeric: tabular-nums; font-weight: 600; font-size: 0.92rem; color: var(--brown, #2b2320); white-space: nowrap; text-align: right; }
.sla-item-price small { display: block; font-weight: 500; font-size: 0.72rem; color: var(--muted, #6b5d54); }
.sla-item .buy { flex: none; display: inline-flex; justify-content: flex-end; min-width: 3.5rem; }
/* The Add button and the quantity stepper are the site's own (js/cart.js draws them);
   inside the panel they keep the short "Add" label at every screen width. */
.sla-panel .btn-add { min-height: 40px; width: auto; }
.sla-panel .btn-add .add-long { display: none; }
.sla-panel .btn-add .add-short { display: inline; }
.sla-panel .stepper { height: 40px; width: auto; }
.sla-tag { flex: none; font-size: 0.66rem; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; color: var(--gold-3, #9e7a2a); border: 1px solid rgba(194, 154, 61, 0.5); border-radius: 2px; padding: 0.15rem 0.45rem; white-space: nowrap; }

.sla-card-title { margin: 0.5rem 0 0.2rem; font-size: 0.68rem; font-weight: 600; letter-spacing: 0.18em; text-transform: uppercase; color: var(--gold-3, #9e7a2a); }
.sla-card-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.6rem; padding: 0.6rem 0 0.55rem; }
.sla-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0.5rem 1.1rem;
  border: 1px solid var(--gold, #c29a3d);
  border-radius: 2px;
  background: var(--gold, #c29a3d);
  color: var(--brown, #2b2320);
  font-family: inherit;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  cursor: pointer;
}
.sla-btn:hover { background: var(--gold-2, #d9b86a); border-color: var(--gold-2, #d9b86a); }
.sla-btn[disabled] { opacity: 0.5; cursor: default; }
.sla-card-done { margin: 0; padding: 0.6rem 0; font-size: 0.88rem; color: var(--brown, #2b2320); }
.sla-card-done a { color: var(--gold-3, #9e7a2a); }
.sla-fine { margin: 0; font-size: 0.74rem; line-height: 1.4; color: var(--muted, #6b5d54); }

.sla-field { display: block; margin: 0.55rem 0 0; }
.sla-field span { display: block; font-size: 0.68rem; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted, #6b5d54); margin-bottom: 0.25rem; }
.sla-field input, .sla-field textarea {
  width: 100%;
  font: inherit;
  font-size: 16px;                 /* 16px: phones zoom the page when a smaller text box is tapped */
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--line, #ddcfb6);
  border-radius: 2px;
  background: var(--white, #fdfaf4);
  color: var(--ink, #221b18);
}
.sla-field textarea { min-height: 4.2rem; resize: vertical; }
.sla-field [aria-invalid="true"] { border-color: #8c2f1b; }
.sla-error { margin: 0.3rem 0 0; font-size: 0.8rem; color: #8c2f1b; }
.sla-error[hidden] { display: none; }

/* ---------- composer ---------- */
.sla-form {
  flex: none;
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
  padding: 0.6rem 0.7rem;
  border-top: 1px solid rgba(246, 240, 228, 0.12);
  background: var(--brown-3, #1c1614);
}
.sla-input {
  flex: 1;
  min-width: 0;
  min-height: 44px;
  max-height: 7.5rem;
  resize: none;
  font: inherit;
  font-size: 16px;
  line-height: 1.4;
  padding: 0.6rem 0.75rem;
  border: 1px solid rgba(246, 240, 228, 0.24);
  border-radius: 2px;
  background: rgba(246, 240, 228, 0.06);
  color: var(--cream, #f6f0e4);
}
.sla-input::placeholder { color: rgba(246, 240, 228, 0.5); }
.sla-input:focus { border-color: var(--gold, #c29a3d); }
.sla-input[disabled] { opacity: 0.5; }
.sla-send { flex: none; min-width: 4.4rem; }
.sla-foot {
  flex: none;
  margin: 0;
  padding: 0 0.9rem calc(0.6rem + env(safe-area-inset-bottom));
  font-size: 0.72rem;
  line-height: 1.4;
  color: rgba(246, 240, 228, 0.62);
  background: var(--brown-3, #1c1614);
}

/* Little room (a phone with the keyboard up): see fit() in assistant.js. */
.sla-compact .sla-foot { display: none; }
.sla-compact .sla-sub { display: none; }
.sla-compact .sla-head { padding-top: 0.3rem; padding-bottom: 0.3rem; }
.sla-compact .sla-head-btn { height: 36px; min-width: 36px; }
.sla-compact .sla-title { font-size: 1.1rem; }
.sla-compact .sla-form { padding-top: 0.4rem; padding-bottom: calc(0.4rem + env(safe-area-inset-bottom)); }
.sla-compact .sla-log { padding-top: 0.6rem; }

.sla-launch, .sla-panel button, .sla-panel a { -webkit-tap-highlight-color: transparent; }
.sla-btn:active, .sla-starter:active, .sla-head-btn:active { opacity: 0.8; }

.sla-panel :focus-visible, .sla-launch:focus-visible { outline: 2px solid var(--gold-2, #d9b86a); outline-offset: 2px; }
.sla-card :focus-visible { outline-color: var(--gold-3, #9e7a2a); }
.sla-sr { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

@media (prefers-reduced-motion: reduce) {
  .sla-log { scroll-behavior: auto; }
  .sla-typing span { animation: none; opacity: 0.7; }
  .sla-launch { transition: none; }
}
@media print { .sla-launch, .sla-panel { display: none !important; } }
