/* rickhelpme.com visitor page. No web fonts. The inbox app has its own styles. */

:root {
  --bg: #f5f4f1;
  --text: #1c1b19;
  --muted: #6b6964;
  --line: #e6e3dd;
  --dot: #e8552d;
  --panel: #fff;
  --card-border: 1px solid var(--line);
  --card-shadow: 0 1px 2px rgba(28, 27, 25, 0.04), 0 14px 30px -20px rgba(28, 27, 25, 0.28);
  --act1-bg: #fff;
  --act1-text: var(--text);
  --act2-bg: #fff;
  --act2-text: var(--text);
  --act-sub: var(--muted);
  --icon1-bg: #fdebe4;
  --icon1-text: #c4491f;
  --icon2-bg: #e3f4ea;
  --icon2-text: #17804a;
  --field: #f5f4f1;
  --field-border: 1px solid transparent;
  --focus: #1c1b19;
  --accent: #1c1b19;
  --accent-text: #fff;
  /* Chat bubbles use the Apple Messages colors. */
  --me: #007aff;
  --me-text: #fff;
  --them: #e9e9eb;
  --them-text: #000;
  --ask: #f5f4f1;
  --danger: #b3261e;
  --live: #1fa35b;
  --radius: 22px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

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

html { -webkit-text-size-adjust: 100%; color-scheme: light; background: var(--bg); }

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font: 400 17px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

[hidden] { display: none !important; }

button, input, textarea { font: inherit; color: inherit; }

.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

.top, .stack { width: 100%; max-width: 480px; margin: 0 auto; padding-inline: 16px; }
.top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 14px;
  padding-top: max(16px, env(safe-area-inset-top));
  padding-bottom: 14px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--text);
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.02em;
  text-decoration: none;
}
.brand-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--dot); }
.brand-mark { font-size: 24px; line-height: 1; }

/* The visitor's name, asked once, used for both a message and a chat. */
.top .who {
  flex: 1;
  width: auto;
  min-width: 0;
  max-width: 230px;
  margin-left: auto;
  padding: 9px 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  font-size: 16px;
}
.who-error { flex-basis: 100%; margin: 0; text-align: right; }

.stack { display: grid; gap: 12px; padding-bottom: calc(32px + env(safe-area-inset-bottom)); }

/* An item is a button with a panel that slides open beneath it. */
.item {
  overflow: hidden;
  border: var(--card-border);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--card-shadow);
}
#item-message { --act-bg: var(--act1-bg); --act-text: var(--act1-text); --icon-bg: var(--icon1-bg); --icon-text: var(--icon1-text); }
#item-chat { --act-bg: var(--act2-bg); --act-text: var(--act2-text); --icon-bg: var(--icon2-bg); --icon-text: var(--icon2-text); }

.activator {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 16px 18px;
  border: 0;
  background: var(--act-bg);
  color: var(--act-text);
  text-align: left;
  cursor: pointer;
}
.activator:focus-visible { outline-offset: -3px; }
.act-icon {
  flex: none;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: var(--icon-bg);
  color: var(--icon-text);
}
.act-text { flex: 1; display: grid; gap: 2px; min-width: 0; }
.act-title { font-size: 19px; font-weight: 700; line-height: 1.2; letter-spacing: -0.02em; }
.act-sub { display: flex; align-items: center; gap: 7px; color: var(--act-sub); font-size: 15px; line-height: 1.3; }
.chev {
  flex: none;
  width: 10px;
  height: 10px;
  margin: 0 4px 4px 0;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  opacity: 0.55;
  transform: rotate(45deg);
  transition: transform 0.25s;
}
.item.open .chev { margin-bottom: -6px; transform: rotate(225deg); }

.live-dot { flex: none; width: 9px; height: 9px; border-radius: 50%; background: currentColor; opacity: 0.4; }
.live-dot.on { background: var(--live); opacity: 1; animation: pulse 2s infinite; }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(31, 163, 91, 0.5); }
  100% { box-shadow: 0 0 0 8px rgba(31, 163, 91, 0); }
}

.panel { display: grid; grid-template-rows: 0fr; transition: grid-template-rows 0.3s ease; }
.item.open .panel { grid-template-rows: 1fr; }
.panel-inner { min-height: 0; overflow: hidden; }

/* Message form */
.panel-body { display: grid; gap: 14px; padding: 16px 18px 18px; }
.f { min-width: 0; }
label { display: block; margin-bottom: 6px; color: var(--muted); font-size: 14px; font-weight: 600; }
input[type="text"], textarea {
  display: block;
  width: 100%;
  padding: 12px 14px;
  border: var(--field-border);
  border-radius: 14px;
  background: var(--field);
  color: var(--text);
  font-size: 17px;
  line-height: 1.4;
}
textarea { resize: none; }
::placeholder { color: color-mix(in srgb, var(--text) 40%, transparent); }
input:focus-visible, textarea:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
[aria-invalid="true"] { outline: 2px solid var(--danger); outline-offset: 1px; }
.error { margin: 6px 0 0; color: var(--danger); font-size: 14px; font-weight: 600; }
#message-error { margin: 0; }

/* Honeypot: off-screen for people, tempting for bots */
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

/* Send button: a round blue arrow, as in Apple Messages. */
.arrow {
  flex: none;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: var(--me);
  color: var(--me-text);
  cursor: pointer;
}
.arrow:active { opacity: 0.8; }
.arrow:disabled { opacity: 0.5; cursor: progress; }
.send-row { display: flex; align-items: center; gap: 8px; }
.send-row input { flex: 1; min-width: 0; }

/* Attachments: the button that opens the file picker, and the chosen files as chips */
.attach-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 12px;
  border: 1px dashed #cfccc5;
  border-radius: 12px;
  background: none;
  color: var(--muted);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 0; padding: 0; list-style: none; }
#c-chips { margin: 0; padding: 0 12px 8px; }
.chip {
  position: relative;
  display: flex;
  align-items: center;
  gap: 7px;
  max-width: 100%;
  padding: 5px 6px 5px 8px;
  overflow: hidden;
  border-radius: 10px;
  background: var(--field);
  font-size: 13px;
}
.chip img { flex: none; width: 28px; height: 28px; border-radius: 6px; object-fit: cover; }
.chip-name { overflow: hidden; max-width: 150px; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.chip-size { flex: none; color: var(--muted); }
.chip-x {
  flex: none;
  width: 22px;
  height: 22px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.08);
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
}
.chips.busy .chip-x { visibility: hidden; }
.chip-bar { position: absolute; left: 0; bottom: 0; width: 0; height: 3px; background: var(--me); transition: width 0.15s; }
.clip {
  flex: none;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--muted);
  cursor: pointer;
}

/* Chat */
.thread {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 92px;
  max-height: min(46dvh, 400px);
  margin: 0;
  padding: 14px 16px 12px;
  overflow-y: auto;
  overscroll-behavior: contain;
  list-style: none;
}
.bubble {
  max-width: 84%;
  padding: 9px 13px;
  border-radius: 18px;
  font-size: 16px;
  line-height: 1.38;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.bubble.them { align-self: flex-start; border-bottom-left-radius: 6px; background: var(--them); color: var(--them-text); }
.bubble.me { align-self: flex-end; border-bottom-right-radius: 6px; background: var(--me); color: var(--me-text); }
.note { align-self: center; max-width: 34ch; padding: 4px 0; color: var(--muted); font-size: 13.5px; text-align: center; text-wrap: balance; }

.ask { margin: 0 12px 10px; padding: 12px; border-radius: 14px; background: var(--ask); }
.ask p { margin: 0 0 8px; font-size: 15px; font-weight: 600; line-height: 1.3; }
.ask .error { margin: 8px 0 0; }
.ask-row { display: flex; gap: 8px; }
.ask-row input { flex: 1; min-width: 0; padding: 10px 12px; border-radius: 12px; background: var(--panel); }
.ask-row button {
  padding: 0 16px;
  border: 0;
  border-radius: 12px;
  background: var(--accent);
  color: var(--accent-text);
  font-weight: 700;
  cursor: pointer;
}

.chat-error { margin: 0 16px 8px; }
.composer { display: flex; align-items: flex-end; gap: 8px; padding: 10px 12px 12px; border-top: 1px solid var(--line); }
.composer textarea { flex: 1; max-height: 120px; padding: 10px 14px; border-radius: 20px; }

.noscript { max-width: 480px; margin: 0 auto; padding: 16px; font-weight: 600; }

@media (prefers-reduced-motion: reduce) {
  .live-dot.on { animation: none; }
  .panel, .chev { transition: none; }
}
