/**
 * Messenger — styles for js/apps/messenger-view.js (prototype v2).
 * Win98 bevels from the --win98-* tokens; every cursor routes through the
 * --cur-* tokens plus the --crt-cursor intent token; motion is transform /
 * opacity only, eased, and off under prefers-reduced-motion.
 */

.msgr {
  --msgr-online: #3FA34D;
  --msgr-ink: #111;
  --msgr-muted: #5d5d5d;
  --msgr-you: #1C4030;
  --msgr-rocco: #7a2f12;
  --msgr-ease: cubic-bezier(0.22, 1, 0.36, 1);
  --msgr-raised:
    inset -1px -1px 0 var(--win98-dark, #000),
    inset 1px 1px 0 var(--win98-light, #fff),
    inset -2px -2px 0 var(--win98-shadow, #808080),
    inset 2px 2px 0 var(--win98-hilight, #DFDFDF);
  --msgr-sunken:
    inset -1px -1px 0 var(--win98-light, #fff),
    inset 1px 1px 0 var(--win98-shadow, #808080),
    inset -2px -2px 0 var(--win98-hilight, #DFDFDF),
    inset 2px 2px 0 var(--win98-dark, #000);
  --msgr-pressed:
    inset -1px -1px 0 var(--win98-light, #fff),
    inset 1px 1px 0 var(--win98-dark, #000),
    inset -2px -2px 0 var(--win98-hilight, #DFDFDF),
    inset 2px 2px 0 var(--win98-shadow, #808080);
  position: relative;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  padding: 0 3px 3px;
  background: var(--win98-face, #C0C0C0);
  color: var(--msgr-ink);
  font-family: var(--font-sans, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif);
  font-size: 13px;
  line-height: 1.4;
  cursor: var(--cur-arrow); --crt-cursor: arrow;
}

/* Phone shell: fill the app view instead of centering a short poster. */
.mob-appview-content:has(> .msgr) {
  flex: 1 1 auto;
  min-height: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
}
.mob-appview-content > .msgr { flex: 1 1 auto; }

.msgr *, .msgr *::before, .msgr *::after { box-sizing: border-box; }

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

/* ── Contact header ── */
.msgr-contact {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 3px 7px;
}

.msgr-avatar {
  width: 38px;
  height: 38px;
  flex: none;
  padding: 2px;
  background: #fff;
  box-shadow: var(--msgr-sunken);
}

.msgr-avatar img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 60% 30%;
}

.msgr-who { flex: 1; min-width: 0; }

.msgr-name {
  display: block;
  font-size: 13px;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.msgr-presence {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  color: var(--msgr-muted);
}

.msgr-dot {
  position: relative;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #9a9a9a;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.35);
}

/* Online: a green layer fades in over the grey (opacity, not colour). */
.msgr-dot::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: var(--msgr-online);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.35);
  opacity: 0;
  transition: opacity 300ms var(--msgr-ease);
}
.msgr-dot.is-online::after { opacity: 1; }

/* ── Buttons ── */
.msgr-tool,
.msgr-send {
  appearance: none;
  border: 0;
  border-radius: 0;
  margin: 0;
  background: var(--win98-face, #C0C0C0);
  color: var(--msgr-ink);
  font-family: inherit;
  letter-spacing: 0;
  text-transform: none;
  box-shadow: var(--msgr-raised);
  cursor: var(--cur-hand); --crt-cursor: hand;
}

.msgr-tool {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex: none;
  padding: 3px 7px;
  font-size: 11.5px;
}

.msgr-tool:active,
.msgr-send:not([disabled]):active { box-shadow: var(--msgr-pressed); }

.msgr-tool:focus-visible,
.msgr-send:focus-visible,
.msgr-box:focus-visible,
.msgr-log:focus-visible {
  outline: 1px dotted #000;
  outline-offset: -4px;
}

/* Persistent framing: outside the scrolling transcript. */
.msgr-intro {
  flex: 0 0 auto;
  margin: 0 2px 6px;
  padding: 6px 7px;
  background: var(--win98-tooltip, #FFFFE1);
  color: var(--msgr-ink);
  font-size: 11.5px;
  line-height: 1.4;
}

/* ── Log ── */
.msgr-log {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 8px 10px 6px;
  background: #fff;
  box-shadow: var(--msgr-sunken);
  user-select: text;
  -webkit-user-select: text;
  cursor: var(--cur-text); --crt-cursor: text;
}

.msgr-sys {
  margin: 4px 0 8px;
  text-align: center;
  font-size: 11px;
  color: var(--msgr-muted);
}

.msgr-grp {
  margin: 0 0 8px;
  animation: msgr-in 240ms var(--msgr-ease) both;
}

.msgr-says {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 11.5px;
  color: var(--msgr-muted);
}
.msgr-says b { color: var(--msgr-rocco); font-weight: 650; }
.msgr-grp--you .msgr-says b { color: var(--msgr-you); }

.msgr-msg {
  margin: 2px 0 0;
  padding-left: 10px;
  font-size: 13.5px;
  line-height: 1.42;
  overflow-wrap: anywhere;
  animation: msgr-in-sm 220ms var(--msgr-ease) both;
}
.msgr-msg--note { font-style: italic; color: var(--msgr-muted); }

.msgr-receipt {
  margin-top: 1px;
  padding-left: 10px;
  font-size: 10.5px;
  color: var(--msgr-muted);
}
.msgr-chk { color: var(--msgr-online); }

@keyframes msgr-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}
@keyframes msgr-in-sm {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: none; }
}

/* Case-study link card */
.msgr-card {
  display: flex;
  align-items: stretch;
  gap: 8px;
  margin: 6px 0 2px 10px;
  padding: 5px;
  background: var(--win98-face, #C0C0C0);
  box-shadow: var(--msgr-raised);
  animation: msgr-in-sm 240ms var(--msgr-ease) both;
  cursor: var(--cur-arrow); --crt-cursor: arrow;
}

.msgr-thumb {
  width: 64px;
  height: 64px;
  flex: none;
  padding: 2px;
  background: #fff;
  box-shadow: var(--msgr-sunken);
}
.msgr-thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.msgr-card-text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 1px;
}
.msgr-eyebrow {
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--msgr-muted);
}
.msgr-card-name { font-size: 13.5px; font-weight: 650; line-height: 1.2; }
.msgr-card-desc { display: block; font-size: 12px; color: #333; }
.msgr-card-opened { margin-top: 2px; font-size: 10.5px; color: #2e7d3a; }
.msgr-card-open { align-self: center; }

/* Rocco is typing… */
.msgr-typing {
  display: flex;
  align-items: center;
  gap: 7px;
  height: 20px;
  padding-left: 10px;
  font-size: 11.5px;
  color: var(--msgr-muted);
  opacity: 0;
  transition: opacity 180ms var(--msgr-ease);
}
.msgr-typing.is-on { opacity: 1; }

.msgr-dots { display: inline-flex; gap: 3px; }
.msgr-dots i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #8a8a8a;
  opacity: 0.5;
}
.msgr-typing.is-on .msgr-dots i { animation: msgr-bounce 1.1s ease-in-out infinite; }
.msgr-typing.is-on .msgr-dots i:nth-child(2) { animation-delay: 0.15s; }
.msgr-typing.is-on .msgr-dots i:nth-child(3) { animation-delay: 0.3s; }

@keyframes msgr-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30% { transform: translateY(-3px); opacity: 1; }
}

/* ── Composer ── */
.msgr-composer {
  flex: 0 0 auto;
  display: flex;
  align-items: stretch;
  gap: 5px;
  padding: 6px 2px 5px;
}

.msgr-box {
  flex: 1;
  min-width: 0;
  height: 50px;
  margin: 0;
  padding: 5px 7px;
  border: 0;
  border-radius: 0;
  resize: none;
  background: #fff;
  color: var(--msgr-ink);
  font: 13.5px/1.4 var(--font-sans, sans-serif);
  box-shadow: var(--msgr-sunken);
  cursor: var(--cur-text); --crt-cursor: text;
}
.msgr-box::placeholder { color: #8f8f8f; }

.msgr-send {
  position: relative;
  isolation: isolate;
  width: 60px;
  flex: none;
  padding: 0;
  font-size: 12.5px;
  font-weight: 600;
}

.msgr-send[disabled] {
  color: var(--win98-shadow, #808080);
  text-shadow: 1px 1px 0 var(--win98-light, #fff);
  cursor: var(--cur-arrow); --crt-cursor: arrow;
}

/* Reply ready: a soft highlight breathes under the label (opacity only). */
.msgr-send::before {
  content: '';
  position: absolute;
  inset: 3px;
  z-index: -1;
  background: #fff;
  opacity: 0;
  pointer-events: none;
}
.msgr-send.is-ready::before { animation: msgr-ready 1.6s ease-in-out infinite; }

@keyframes msgr-ready {
  50% { opacity: 0.35; }
}

/* ── Status bar ── */
.msgr-status {
  flex: 0 0 auto;
  min-height: 20px;
  padding: 2px 7px;
  font-size: 11px;
  color: var(--msgr-ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  box-shadow: var(--msgr-sunken);
}

/* ── "Rocco has just signed in." toast ── */
.msgr-toast {
  position: absolute;
  width: 210px;
  padding: 3px;
  background: var(--win98-tooltip, #FFFFE1);
  color: #111;
  font-family: var(--font-sans, sans-serif);
  box-shadow:
    inset -1px -1px 0 var(--win98-dark, #000),
    inset 1px 1px 0 var(--win98-light, #fff),
    inset -2px -2px 0 var(--win98-shadow, #808080),
    inset 2px 2px 0 var(--win98-hilight, #DFDFDF),
    0 8px 18px rgba(0, 0, 0, 0.3);
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 300ms cubic-bezier(0.22, 1, 0.36, 1), transform 300ms cubic-bezier(0.22, 1, 0.36, 1);
  pointer-events: none;
}
.msgr-toast.is-on { opacity: 1; transform: none; }
.msgr-toast--inset { right: 10px; bottom: 110px; z-index: 3; }

.msgr-toast-title {
  padding: 3px 6px;
  background: var(--win98-face, #C0C0C0);
  font-size: 11px;
  font-weight: 600;
  box-shadow: inset 0 -1px 0 var(--win98-shadow, #808080);
}
.msgr-toast-body { padding: 7px; font-size: 12px; }

/* Restored from the session: no entrance animation. */
.msgr-grp.is-instant, .msgr-msg.is-instant, .msgr-card.is-instant { animation: none; }

@media (prefers-reduced-motion: reduce) {
  .msgr-grp, .msgr-msg, .msgr-card { animation: none; }
  .msgr-typing.is-on .msgr-dots i, .msgr-send.is-ready::before { animation: none; }
  .msgr-dot::after, .msgr-typing, .msgr-toast { transition: none; }
}
