/* chatbot.css — Hi-Tide Harry floating chatbot widget per V1-BRIEF Section 10
   Phase 1 = FAQ + fallback collector. */

.chatbot { position: fixed; bottom: calc(var(--space-lg) + 96px); right: var(--space-lg); z-index: 99; font-family: var(--font-body); }

.chatbot__bubble {
  width: 64px; height: 64px; border-radius: 50%;
  background: var(--c-red);
  box-shadow: 0 4px 20px rgba(200,16,46,0.5);
  padding: 0; overflow: hidden;
  cursor: pointer;
  transition: transform var(--duration-mid), box-shadow var(--duration-mid);
  animation: chatbot-pulse 3s ease-in-out infinite;
  display: flex; align-items: center; justify-content: center;
}
.chatbot__bubble img { width: 56px; height: 56px; object-fit: cover; pointer-events: none; }
.chatbot__bubble:hover { transform: translateY(-2px) scale(1.04); box-shadow: 0 6px 28px rgba(200,16,46,0.6); animation: none; }

@keyframes chatbot-pulse {
  0%, 100% { box-shadow: 0 4px 20px rgba(200,16,46,0.5); }
  50%      { box-shadow: 0 4px 32px rgba(200,16,46,0.8); }
}

.chatbot__panel {
  position: absolute;
  bottom: 80px; right: 0;
  width: min(380px, calc(100vw - 2rem));
  height: min(560px, calc(100vh - 12rem));
  background: var(--c-cream);
  border-radius: 12px;
  box-shadow: 0 16px 48px rgba(10,10,10,0.4);
  display: flex; flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--c-silver);
}

.chatbot__panel[hidden] {
  display: none;
}

/* mobile chatbot rules live at the END of this file so they win source-order
   ties against the desktop base rules (see bottom of file). */

.chatbot__panel-header { display: flex; align-items: center; gap: var(--space-md); padding: var(--space-md); background: var(--c-off-black); color: var(--c-white); position: relative; }
.chatbot__panel-pose { width: 56px; height: 56px; border-radius: 50%; object-fit: cover; background: var(--c-red); padding: 4px; }
.chatbot__panel-title { display: flex; flex-direction: column; gap: 2px; }
.chatbot__panel-title strong { font-family: var(--font-display); font-weight: 700; font-size: 1.125rem; }
.chatbot__panel-title span { font-family: var(--font-italic); font-style: italic; font-size: 0.85rem; color: var(--c-silver); }
.chatbot__close { position: absolute; top: var(--space-sm); right: var(--space-sm); font-size: 1.5rem; line-height: 1; width: 2rem; height: 2rem; color: var(--c-silver); border-radius: 4px; }
.chatbot__close:hover { background: rgba(255,255,255,0.1); color: var(--c-white); }

.chatbot__messages { flex: 1; overflow-y: auto; list-style: none; padding: var(--space-md); margin: 0; display: flex; flex-direction: column; gap: var(--space-sm); background: var(--c-cream); }
.chatbot__msg { padding: 0.6rem 0.9rem; border-radius: 14px; font-size: 0.95rem; line-height: 1.4; max-width: 80%; word-wrap: break-word; }
.chatbot__msg--harry { background: var(--c-red); color: var(--c-white); align-self: flex-start; border-bottom-left-radius: 2px; }
.chatbot__msg--user { background: var(--c-silver-light); color: var(--c-off-black); align-self: flex-end; border-bottom-right-radius: 2px; }
.chatbot__msg a { color: inherit; text-decoration: underline; }
.chatbot__msg--fallback-form { background: var(--c-white); border: 1px dashed var(--c-silver); color: var(--c-off-black); display: flex; flex-direction: column; gap: var(--space-sm); width: 100%; max-width: none; }
.chatbot__msg--fallback-form input { width: 100%; padding: 0.5rem; border: 1px solid var(--c-silver); border-radius: 3px; font-size: 0.9rem; color: var(--text-on-light); }
.chatbot__msg--fallback-form button { background: var(--c-red); color: var(--c-white); padding: 0.5rem 1rem; border-radius: 3px; font-weight: 600; font-size: 0.85rem; align-self: flex-start; }

.chatbot__input { display: flex; gap: var(--space-xs); padding: var(--space-sm); background: var(--c-white); border-top: 1px solid var(--c-silver-light); }
.chatbot__input input { flex: 1; padding: 0.6rem 0.9rem; border: 1px solid var(--c-silver); border-radius: 18px; font-size: 0.95rem; color: var(--text-on-light); }
.chatbot__input input:focus { outline: none; border-color: var(--c-red); }
.chatbot__input button { background: var(--c-red); color: var(--c-white); width: 2.4rem; height: 2.4rem; border-radius: 50%; font-size: 1.1rem; line-height: 1; display: flex; align-items: center; justify-content: center; }
.chatbot__input button:hover { background: var(--c-red-deep); }

/* ─────────────────────────────────────────────────────────────────────────
   Mobile chatbot — placed at end of file to beat source-order on the base
   rules. Fixes iOS keyboard hiding the input + iOS auto-zoom on focus.
   ──────────────────────────────────────────────────────────────────────── */
@media (max-width: 480px) {
  .chatbot__panel {
    position: fixed; inset: 0; bottom: 0; right: 0;
    width: 100%;
    /* dvh adjusts when iOS Safari URL bar / keyboard slides in/out so the
       input field stays visible above the keyboard. Falls back to vh on
       browsers that don't yet support dvh. */
    height: 100vh;
    height: 100dvh;
    border-radius: 0;
    z-index: 100;
  }
  .chatbot__messages { flex: 1 1 0; min-height: 0; }
  .chatbot__input {
    flex-shrink: 0;
    padding-bottom: calc(var(--space-sm) + env(safe-area-inset-bottom, 0px));
  }
  /* iOS auto-zooms <input> with font-size < 16px on focus and the layout
     never recovers. 16px is the minimum that prevents the zoom. */
  .chatbot__input input,
  .chatbot__msg--fallback-form input { font-size: 16px; }
}

/* Cinematic Harry guide — removes the circular bot treatment and allows
   the character to travel between contextual positions on the page. */
.chatbot.harry-guide {
  --harry-side: clamp(.65rem, 2vw, 1.5rem);
  position: fixed;
  z-index: 76;
  right: var(--harry-side);
  bottom: max(1rem, env(safe-area-inset-bottom));
  width: min(15rem, 38vw);
  height: clamp(8.5rem, 18vw, 12.5rem);
  pointer-events: none;
  transform: translateX(160%) scale(.94);
  opacity: 0;
  transition: right .7s cubic-bezier(.2,.8,.2,1), left .7s cubic-bezier(.2,.8,.2,1), transform .65s cubic-bezier(.2,.8,.2,1), opacity .35s ease;
}
.chatbot.harry-guide.is-entered { transform: translateX(0) scale(1); opacity: 1; }
.chatbot.harry-guide[data-dock="left"] { right: calc(100vw - min(15rem, 38vw) - var(--harry-side)); }
.chatbot.harry-guide.is-polite:not(.is-open) { transform: translateY(58%) scale(.78); opacity: .58; }
.chatbot.harry-guide.is-walking .chatbot__bubble img { animation: harry-step .36s ease-in-out infinite alternate; }

.harry-guide .chatbot__bubble {
  position: absolute;
  inset: auto 0 0;
  width: 100%;
  height: 100%;
  display: block;
  overflow: visible;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  animation: none;
  pointer-events: auto;
  cursor: pointer;
  filter: drop-shadow(0 18px 18px rgba(0,0,0,.58));
}
.harry-guide .chatbot__bubble:hover { transform: translateY(-4px); box-shadow: none; }
.harry-guide .chatbot__bubble img {
  position: absolute;
  right: 0;
  bottom: 0;
  width: auto;
  height: 100%;
  max-width: 100%;
  object-fit: contain;
  object-position: right bottom;
  pointer-events: none;
  border-radius: 0;
}
.harry-guide__label {
  position: absolute;
  right: 0;
  bottom: .4rem;
  display: grid;
  min-width: 7.2rem;
  padding: .42rem .62rem;
  border: 1px solid rgba(216,184,106,.55);
  border-radius: .65rem;
  background: rgba(8,7,8,.9);
  color: #fff;
  text-align: left;
  transform: translateX(8%);
  backdrop-filter: blur(8px);
}
.harry-guide__label strong { font: 700 .72rem/1.1 Inter, sans-serif; }
.harry-guide__label span { margin-top: .18rem; color: #d8b86a; font: 600 .55rem/1 Inter, sans-serif; letter-spacing: .05em; text-transform: uppercase; }
.harry-guide__speech {
  position: absolute;
  right: .2rem;
  bottom: 88%;
  width: min(18rem, calc(100vw - 2rem));
  padding: .7rem .85rem;
  border: 1px solid rgba(216,184,106,.48);
  border-radius: 1rem 1rem .2rem 1rem;
  background: rgba(245,239,229,.98);
  color: #171114;
  box-shadow: 0 18px 48px rgba(0,0,0,.38);
  font: 650 .78rem/1.4 Inter, sans-serif;
  text-align: left;
  pointer-events: none;
  opacity: 0;
  transform: translateY(.5rem) scale(.96);
  transition: opacity .2s ease, transform .25s ease;
}
.harry-guide.is-speaking .harry-guide__speech { opacity: 1; transform: translateY(0) scale(1); pointer-events: auto; }
.harry-guide[data-dock="left"] .harry-guide__speech { right: auto; left: .2rem; border-radius: 1rem 1rem 1rem .2rem; }

.harry-guide .chatbot__panel {
  position: fixed;
  right: clamp(1rem, 3vw, 2rem);
  bottom: 1rem;
  width: min(27rem, calc(100vw - 2rem));
  height: min(42rem, calc(100dvh - 6.5rem));
  border: 1px solid rgba(216,184,106,.45);
  border-radius: 1.25rem;
  background: #f5efe5;
  box-shadow: 0 30px 100px rgba(0,0,0,.7);
  pointer-events: auto;
}
.chatbot.harry-guide.is-open {
  inset: 0;
  width: 100vw;
  height: 100dvh;
  transform: none !important;
  transition: none;
  opacity: 1;
}
.harry-guide.is-open > .chatbot__bubble,
.harry-guide.is-open > .harry-guide__speech { display: none; }
.harry-guide .chatbot__panel-header { background: linear-gradient(135deg, #161013, #390b17); }
.harry-guide .chatbot__panel-pose { width: 4.6rem; height: 4.6rem; border: 0; border-radius: 0; background: transparent; object-fit: contain; }
.harry-guide__chips { display: flex; flex-wrap: wrap; gap: .42rem; padding: .65rem .75rem; border-top: 1px solid #ded5d0; background: #fffaf4; }
.harry-guide__chips button { min-height: 36px; padding: .45rem .66rem; border: 1px solid #ccbfc0; border-radius: 999px; background: #fff; color: #24181c; font: 700 .7rem/1 Inter, sans-serif; }
.harry-guide__chips button:hover { border-color: #c91432; color: #a10f27; }
.harry-guide .chatbot__msg--harry { background: #a7112b; }

@keyframes harry-step { from { transform: translateY(0) rotate(-1deg); } to { transform: translateY(-5px) rotate(1deg); } }

@media (max-width: 600px) {
  .chatbot.harry-guide { width: 6.25rem; height: 7rem; bottom: .2rem; }
  .chatbot.harry-guide[data-dock="left"] { right: calc(100vw - 6.25rem - var(--harry-side)); }
  .chatbot.harry-guide.is-avoiding:not(.is-open) { transform: translateX(48%) scale(.74); opacity: .82; }
  .chatbot.harry-guide.is-avoiding[data-dock="left"]:not(.is-open) { transform: translateX(-48%) scale(.74); }
  .chatbot.harry-guide.is-avoiding .harry-guide__label,
  .chatbot.harry-guide.is-avoiding .harry-guide__speech { display: none; }
  .harry-guide__label { min-width: 6.2rem; transform: translateX(16%); }
  .harry-guide__speech { bottom: 92%; font-size: .74rem; }
  .harry-guide .chatbot__panel { inset: auto 0 0; width: 100%; height: min(85dvh, 46rem); border-radius: 1.25rem 1.25rem 0 0; }
}

@media (prefers-reduced-motion: reduce) {
  .chatbot.harry-guide { transition: none; }
  .harry-guide.is-walking .chatbot__bubble img { animation: none; }
}
