/**
 * Mr. hmm V1 — isolated styles (mr-hmm-* prefix only).
 * Loaded only when $mr_hmm_enabled is true in includes/bottom_nav.php.
 */

:root {
  --mr-hmm-nav-height: calc(72px + env(safe-area-inset-bottom, 0px));
  --mr-hmm-panel-gap: 14px;
}

/* ── Bottom nav layout with centre launcher ── */
.bottom-nav.mr-hmm-nav-elevated {
  z-index: 10000;
}

.mr-hmm-nav-inner.bottom-nav-inner {
  grid-template-columns: 1fr 1fr auto 1fr 1fr;
  align-items: end;
}

.mr-hmm-nav-slot {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
}

#mr-hmm-launcher {
  appearance: none;
  border: none;
  outline: none;
  margin: 0;
  padding: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(circle at 30% 24%,
      rgba(255, 255, 255, 0.88) 0%,
      rgba(255, 255, 255, 0.40) 22%,
      rgba(255, 230, 225, 0.16) 55%,
      rgba(255, 255, 255, 0.05) 100%);
  width: 58px;
  height: 58px;
  border-radius: 50%;
  box-shadow:
    0 8px 18px rgba(80, 40, 25, 0.2),
    inset 0 1px 3px rgba(255, 255, 255, 0.72),
    inset 0 -3px 7px rgba(180, 90, 70, 0.1);
  transform: translateY(-14px);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
  position: relative;
  z-index: 1;
  overflow: hidden;
}

/* Same logo treatment as index.html .logo-image, scaled for the crystal ball */
.mr-hmm-launcher-logo {
  display: block;
  width: 28px;
  height: 28px;
  max-width: 28px;
  max-height: 28px;
  object-fit: contain;
  background: transparent;
  border: none;
  box-shadow: none;
  filter: drop-shadow(0 3px 7px rgba(0, 0, 0, 0.22));
  position: relative;
  z-index: 1;
  pointer-events: none;
}

#mr-hmm-launcher::before {
  content: "";
  position: absolute;
  inset: 7px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 28%, rgba(255, 255, 255, 0.5) 0%, transparent 60%);
  pointer-events: none;
}

#mr-hmm-launcher:hover,
#mr-hmm-launcher:focus-visible {
  transform: translateY(-16px);
  box-shadow:
    0 10px 22px rgba(80, 40, 25, 0.24),
    inset 0 1px 3px rgba(255, 255, 255, 0.78),
    inset 0 -3px 7px rgba(180, 90, 70, 0.12);
  outline: none;
}

#mr-hmm-launcher.mr-hmm-launcher-active {
  box-shadow:
    0 10px 24px rgba(80, 40, 25, 0.26),
    inset 0 1px 4px rgba(255, 255, 255, 0.82),
    inset 0 -3px 8px rgba(180, 90, 70, 0.14);
  transform: translateY(-16px) scale(1.04);
}

/* ── Body lock while chat open ── */
body.mr-hmm-open {
  overflow: hidden;
  overscroll-behavior: none;
}

/* ── Root overlay container ── */
#mr-hmm-root {
  position: fixed;
  inset: 0;
  z-index: 9000;
  pointer-events: none;
  visibility: hidden;
  overflow: hidden;
}

#mr-hmm-root.mr-hmm-root-open {
  pointer-events: auto;
  visibility: visible;
}

#mr-hmm-root.mr-hmm-root-open #mr-hmm-overlay {
  opacity: 1;
}

#mr-hmm-root.mr-hmm-root-open #mr-hmm-panel {
  opacity: 1;
  transform: scale(1) translateY(0);
}

/* Full-viewport frosted lens behind chat panel */
#mr-hmm-overlay {
  position: fixed;
  inset: 0;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100vw;
  height: 100dvh;
  max-width: none;
  margin: 0;
  padding: 0;
  transform: none;
  opacity: 0;
  transition: opacity 0.22s ease;
  pointer-events: auto;
  background: rgba(245, 247, 250, 0.15);
  backdrop-filter: blur(16px) saturate(120%);
  -webkit-backdrop-filter: blur(16px) saturate(120%);
}

/* ── Chat panel — thick frosted glass lens ── */
#mr-hmm-panel {
  position: fixed;
  top: max(14px, env(safe-area-inset-top, 0px));
  left: 12px;
  right: 12px;
  width: auto;
  max-width: none;
  height: calc(100dvh - var(--mr-hmm-nav-height) - 28px);
  margin: 0;
  z-index: 9100;
  display: flex;
  flex-direction: column;
  border-radius: 22px;
  overflow: hidden;
  opacity: 0;
  transform: scale(0.98) translateY(6px);
  transition: opacity 0.22s ease, transform 0.22s ease;
  pointer-events: auto;
  background: linear-gradient(
    135deg,
    rgba(255, 255, 255, 0.62),
    rgba(255, 255, 255, 0.28)
  );
  backdrop-filter: blur(30px) saturate(145%);
  -webkit-backdrop-filter: blur(30px) saturate(145%);
  border: 1px solid rgba(255, 255, 255, 0.58);
  box-shadow:
    0 18px 45px rgba(80, 50, 30, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.72),
    inset 0 -1px 0 rgba(255, 255, 255, 0.18);
  color: #111;
}

.mr-hmm-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px 12px;
  flex-shrink: 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.35);
  background: rgba(255, 255, 255, 0.08);
}

#mr-hmm-panel.mr-hmm-panel--dark .mr-hmm-header {
  border-bottom-color: rgba(255, 255, 255, 0.1);
  background: rgba(0, 0, 0, 0.12);
}

.mr-hmm-title {
  font-size: 1.125rem;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.mr-hmm-header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.mr-hmm-icon-btn {
  appearance: none;
  border: none;
  background: transparent;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: inherit;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.15s ease;
}

.mr-hmm-icon-btn:hover,
.mr-hmm-icon-btn:focus-visible {
  background: rgba(255, 255, 255, 0.28);
  outline: none;
}

#mr-hmm-panel.mr-hmm-panel--dark .mr-hmm-icon-btn:hover,
#mr-hmm-panel.mr-hmm-panel--dark .mr-hmm-icon-btn:focus-visible {
  background: rgba(255, 255, 255, 0.1);
}

.mr-hmm-icon-btn svg {
  width: 22px;
  height: 22px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.mr-hmm-memo {
  margin: 12px 14px 0;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.5);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.45);
  flex-shrink: 0;
}

.mr-hmm-memo--important {
  border-color: rgba(245, 158, 11, 0.55);
  background: rgba(255, 251, 235, 0.72);
}

.mr-hmm-memo--urgent {
  border-color: rgba(220, 38, 38, 0.55);
  background: rgba(254, 242, 242, 0.78);
}

.mr-hmm-memo-title {
  font-size: 0.82rem;
  font-weight: 700;
  margin-bottom: 4px;
  color: #374151;
}

.mr-hmm-memo-body {
  font-size: 0.92rem;
  line-height: 1.45;
  color: inherit;
}

.mr-hmm-memo-link {
  display: inline-block;
  margin-top: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  color: #B80F18;
  text-decoration: none;
}

.mr-hmm-memo-link:hover {
  text-decoration: underline;
}

#mr-hmm-panel.mr-hmm-panel--dark .mr-hmm-memo {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.14);
}

.mr-hmm-messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 20px 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  font-size: 1rem;
  -webkit-overflow-scrolling: touch;
}

.mr-hmm-msg {
  max-width: 88%;
  padding: 12px 16px;
  border-radius: 18px;
  line-height: 1.5;
  word-wrap: break-word;
}

.mr-hmm-msg--bot {
  align-self: flex-start;
  background: rgba(255, 255, 255, 0.42);
  border: 1px solid rgba(255, 255, 255, 0.45);
  color: inherit;
  border-bottom-left-radius: 6px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.5);
}

#mr-hmm-panel.mr-hmm-panel--dark .mr-hmm-msg--bot {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.12);
}

.mr-hmm-msg--user {
  align-self: flex-end;
  background: rgba(230, 107, 36, 0.88);
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: #fff;
  border-bottom-right-radius: 6px;
  box-shadow: 0 4px 14px rgba(201, 85, 24, 0.28);
}

.mr-hmm-msg--thinking {
  align-self: flex-start;
  background: rgba(255, 255, 255, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.4);
  color: inherit;
  font-style: italic;
  opacity: 0.85;
  border-bottom-left-radius: 6px;
}

#mr-hmm-send:disabled,
#mr-hmm-input:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

#mr-hmm-panel.mr-hmm-panel--dark .mr-hmm-msg--user {
  background: rgba(201, 85, 24, 0.92);
}

.mr-hmm-composer {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  padding: 12px 14px 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.35);
  flex-shrink: 0;
  background: rgba(255, 255, 255, 0.14);
}

#mr-hmm-panel.mr-hmm-panel--dark .mr-hmm-composer {
  border-top-color: rgba(255, 255, 255, 0.1);
  background: rgba(0, 0, 0, 0.14);
}

#mr-hmm-input {
  flex: 1;
  border: 1px solid rgba(255, 255, 255, 0.55);
  border-radius: 16px;
  padding: 12px 14px;
  font: inherit;
  font-size: 1rem;
  background: rgba(255, 255, 255, 0.55);
  color: inherit;
  min-height: 48px;
  resize: none;
  box-shadow: inset 0 1px 2px rgba(80, 50, 30, 0.06);
}

#mr-hmm-panel.mr-hmm-panel--dark #mr-hmm-input {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.15);
  color: #f2f2f2;
}

#mr-hmm-input:focus {
  outline: 2px solid rgba(230, 107, 36, 0.45);
  outline-offset: 0;
  border-color: transparent;
}

#mr-hmm-send {
  appearance: none;
  border: none;
  background: #e66b24;
  color: #fff;
  font: inherit;
  font-weight: 700;
  font-size: 0.9375rem;
  padding: 12px 18px;
  border-radius: 16px;
  cursor: pointer;
  min-height: 48px;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.15s ease;
  box-shadow: 0 4px 14px rgba(201, 85, 24, 0.28);
}

#mr-hmm-send:hover,
#mr-hmm-send:focus-visible {
  background: #c95518;
  outline: none;
}

@media (min-width: 480px) {
  #mr-hmm-panel {
    left: 16px;
    right: 16px;
  }
}

/* ── Leave confirmation card ── */
#mr-hmm-leave-confirm {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 9200;
  width: min(calc(100vw - 32px), 320px);
  border-radius: 18px;
  padding: 20px 18px 16px;
  pointer-events: auto;
  text-align: center;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  color: #111;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.2);
}

#mr-hmm-leave-confirm[hidden] {
  display: none !important;
}

.mr-hmm-leave-title {
  font-weight: 700;
  font-size: 1.1rem;
  margin: 0 0 8px;
}

.mr-hmm-leave-text {
  margin: 0 0 18px;
  font-size: 0.9375rem;
  opacity: 0.85;
  line-height: 1.45;
}

.mr-hmm-leave-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.mr-hmm-leave-btn {
  appearance: none;
  border: none;
  font: inherit;
  font-weight: 700;
  font-size: 0.9375rem;
  padding: 12px 16px;
  border-radius: 12px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.mr-hmm-leave-btn--stay {
  background: #e66b24;
  color: #fff;
}

.mr-hmm-leave-btn--leave {
  background: rgba(0, 0, 0, 0.06);
  color: inherit;
}
