/* Justyna Lane Photography — enquiry chat widget.
   Uses the site's colour and type tokens when present, with fallbacks. */

.jl-chat{
  --jl-bg:          var(--bg, #FAF8F4);
  --jl-white:       var(--white, #FFFFFF);
  --jl-ink:         var(--ink, #2A2825);
  --jl-ink-soft:    var(--ink-soft, #6E6B63);
  --jl-line:        var(--line, #DCD8CC);
  --jl-accent-dark: var(--accent-dark, #7C7B6F);
  --jl-serif:       var(--font-display, 'Cormorant Garamond', 'Times New Roman', serif);
  --jl-sans:        var(--font-body, 'Manrope', -apple-system, sans-serif);

  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 9999;
  font-family: var(--jl-sans);
  color: var(--jl-ink);
  text-align: left;
}

/* ---------- Bubble ---------- */
.jl-chat-bubble{
  position: relative;
  z-index: 2;
  width: 56px;
  height: 56px;
  padding: 0;
  border: 1px solid var(--jl-line);
  border-radius: 50%;
  background: var(--jl-ink);
  color: var(--jl-bg);
  display: grid;
  place-items: center;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(42, 40, 37, 0.18);
  transition: transform 0.3s cubic-bezier(.4,0,.2,1);
}
.jl-chat-bubble:hover{ transform: translateY(-2px); }

.jl-chat-bubble svg{
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  display: block;
}
.jl-chat-bubble .jl-chat-icon-close{ display: none; }
.jl-chat.is-open .jl-chat-bubble .jl-chat-icon-open{ display: none; }
.jl-chat.is-open .jl-chat-bubble .jl-chat-icon-close{ display: block; }

/* ---------- Panel ---------- */
.jl-chat-panel{
  display: none;
  flex-direction: column;
  position: absolute;
  right: 0;
  bottom: 72px;
  width: 360px;
  height: min(560px, calc(100vh - 120px));
  background: var(--jl-bg);
  border: 1px solid var(--jl-line);
  box-shadow: 0 18px 48px rgba(42, 40, 37, 0.16);
}
.jl-chat.is-open .jl-chat-panel{
  display: flex;
  animation: jl-rise 0.35s cubic-bezier(.4,0,.2,1);
}
@keyframes jl-rise{
  from{ opacity: 0; transform: translateY(8px); }
  to  { opacity: 1; transform: none; }
}

.jl-chat-head{
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  padding: 20px 22px 16px;
  border-bottom: 1px solid var(--jl-line);
}
.jl-chat-eyebrow{
  margin: 0 0 4px;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--jl-accent-dark);
}
.jl-chat-title{
  margin: 0;
  font-family: var(--jl-serif);
  font-weight: 400;
  font-size: 26px;
  line-height: 1.1;
}
.jl-chat-close{
  padding: 0 4px;
  border: 0;
  background: none;
  color: var(--jl-ink-soft);
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
}
.jl-chat-close:hover{ color: var(--jl-ink); }

/* ---------- Messages ---------- */
.jl-chat-log{
  flex: 1;
  overflow-y: auto;
  padding: 18px 18px 8px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  -webkit-overflow-scrolling: touch;
}
.jl-msg{ display: flex; }
.jl-msg-user{ justify-content: flex-end; }
.jl-msg-text{
  max-width: 85%;
  padding: 10px 14px;
  font-size: 14.5px;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.jl-msg-assistant .jl-msg-text{
  background: var(--jl-white);
  border: 1px solid var(--jl-line);
}
.jl-msg-user .jl-msg-text{
  background: var(--jl-ink);
  color: var(--jl-bg);
}

/* Typing indicator */
.jl-typing .jl-msg-text{
  display: flex;
  gap: 5px;
  align-items: center;
  padding: 13px 14px;
}
.jl-typing span{
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--jl-accent-dark);
  animation: jl-dot 1.2s infinite ease-in-out;
}
.jl-typing span:nth-child(2){ animation-delay: 0.15s; }
.jl-typing span:nth-child(3){ animation-delay: 0.3s; }
@keyframes jl-dot{
  0%, 80%, 100%{ opacity: 0.25; }
  40%          { opacity: 1; }
}

/* ---------- Input ---------- */
.jl-chat-form{
  display: flex;
  gap: 8px;
  align-items: flex-end;
  padding: 12px 14px;
  border-top: 1px solid var(--jl-line);
  background: var(--jl-white);
}
.jl-chat-form textarea{
  flex: 1;
  min-width: 0;
  max-height: 120px;
  resize: none;
  padding: 10px 12px;
  border: 1px solid var(--jl-line);
  background: var(--jl-bg);
  color: var(--jl-ink);
  font: inherit;
  font-size: 15px;
  line-height: 1.4;
  outline: none;
}
.jl-chat-form textarea:focus{ border-color: var(--jl-ink); }
.jl-chat-form textarea::placeholder{ color: var(--jl-ink-soft); }

.jl-chat-send{
  padding: 12px 16px;
  border: 1px solid var(--jl-ink);
  background: none;
  color: var(--jl-ink);
  font-family: var(--jl-sans);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.3s, color 0.3s;
}
.jl-chat-send:hover:not(:disabled){
  background: var(--jl-ink);
  color: var(--jl-bg);
}
.jl-chat-send:disabled{ opacity: 0.4; cursor: default; }

.jl-chat-note{
  margin: 0;
  padding: 0 14px 12px;
  background: var(--jl-white);
  font-size: 11px;
  color: var(--jl-ink-soft);
}
.jl-chat-note a{ text-decoration: underline; text-underline-offset: 3px; }

.jl-chat-sr{
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ---------- Phones: full-screen panel ---------- */
@media (max-width: 560px){
  .jl-chat{ right: 16px; bottom: 16px; }
  .jl-chat.is-open .jl-chat-bubble{ display: none; }
  .jl-chat-panel{
    position: fixed;
    inset: 0;
    bottom: auto;
    width: auto;
    height: 100vh;
    height: 100dvh;
    border: 0;
    box-shadow: none;
  }
}

@media (prefers-reduced-motion: reduce){
  .jl-chat-bubble{ transition: none; }
  .jl-chat.is-open .jl-chat-panel{ animation: none; }
  .jl-typing span{ animation: none; opacity: 0.6; }
}
