/*
 * The website chat's look (docs/site-chat.md). Everything a site may want to
 * change is a variable on .rc; set them in the site's own stylesheet, e.g.
 *
 *   .rc { --rc-accent: #0b6e4f; --rc-radius: 6px; }
 *
 * The defaults take the site's own design tokens where it has them: first our
 * own sites' (--color-accent, --color-text, --font-sans, --radius-md …, the
 * alterview.dev network), then a block theme's (--wp--preset--*), then calm
 * neutrals. Every rule below sets its own font, weight, colour and alignment
 * in longhand with .rc in front, so a theme's label, heading and button rules
 * cannot leak in (2026-10-08: they did on alterview.nl).
 */
.rc {
  --rc-accent: var(--color-accent, var(--wp--preset--color--primary, var(--wp--preset--color--accent, #2f6bdf)));
  --rc-accent-hover: var(--color-accent-hover, var(--rc-accent));
  --rc-accent-ink: var(--color-text-on-accent, #ffffff);
  --rc-bg: var(--color-surface, #ffffff);
  --rc-ink: var(--color-text, #16181d);
  --rc-muted: var(--color-text-muted, #555c69);
  --rc-line: var(--color-border, #d6d9e0);
  --rc-field: var(--color-surface, #ffffff);
  --rc-bad: #b42318;
  --rc-radius: var(--radius-md, 14px);
  --rc-launch-radius: var(--radius-md, 999px);
  --rc-font: var(--font-sans, var(--wp--preset--font-family--body, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif));
  --rc-font-title: var(--font-display, var(--rc-font));
  --rc-shadow: var(--shadow-lg, 0 12px 40px rgba(16, 24, 40, 0.18), 0 2px 6px rgba(16, 24, 40, 0.08));
  /* Closed, the button sits under a cookie banner (never over its buttons);
     opened by the visitor, the panel comes on top. */
  --rc-z: 250;
  --rc-z-open: 99990;
  --rc-gap: 20px;

  position: fixed;
  right: max(var(--rc-gap), env(safe-area-inset-right));
  bottom: max(var(--rc-gap), env(safe-area-inset-bottom));
  z-index: var(--rc-z);
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 12px;
  font-family: var(--rc-font);
  font-size: 16px;
  font-weight: 400;
  line-height: 1.5;
  letter-spacing: normal;
  text-transform: none;
  text-align: left;
  color: var(--rc-ink);
}

.rc.rc-is-open { z-index: var(--rc-z-open); }

.rc *, .rc *::before, .rc *::after { box-sizing: border-box; }
.rc [hidden] { display: none !important; }
.rc p, .rc h2, .rc label, .rc button, .rc input, .rc select, .rc textarea {
  font-family: var(--rc-font);
  letter-spacing: normal;
  text-transform: none;
  text-shadow: none;
}

.rc .rc-launch {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  margin: 0;
  padding: 0 20px;
  border: 0;
  border-radius: var(--rc-launch-radius);
  background: var(--rc-accent);
  color: var(--rc-accent-ink);
  font-size: 15px;
  font-weight: 600;
  line-height: 1;
  text-align: center;
  box-shadow: var(--rc-shadow);
  cursor: pointer;
}
.rc .rc-launch:hover { background: var(--rc-accent-hover); }
.rc .rc-launch svg { flex: none; }
.rc-is-open .rc-launch { box-shadow: none; }

.rc .rc-panel {
  width: min(380px, calc(100vw - 2 * var(--rc-gap)));
  max-height: min(720px, calc(100vh - 140px));
  max-height: min(720px, calc(100dvh - 140px));
  display: flex;
  flex-direction: column;
  background: var(--rc-bg);
  border: 1px solid var(--rc-line);
  border-top: 3px solid var(--rc-accent);
  border-radius: var(--rc-radius);
  box-shadow: var(--rc-shadow);
  overflow: hidden;
}

.rc .rc-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 10px 12px 18px;
  border-bottom: 1px solid var(--rc-line);
}
.rc .rc-head h2 {
  margin: 0;
  padding: 0;
  font-family: var(--rc-font-title);
  font-size: 18px;
  font-weight: 600;
  line-height: 1.3;
  color: var(--rc-ink);
}

.rc .rc-close {
  flex: none;
  width: 40px; height: 40px;
  display: inline-grid; place-items: center;
  margin: 0; padding: 0;
  border: 0; border-radius: var(--rc-radius);
  background: transparent; color: var(--rc-muted);
  font-size: 24px; font-weight: 400; line-height: 1; text-align: center;
  box-shadow: none;
  cursor: pointer;
}
.rc .rc-close:hover { background: rgba(0, 0, 0, 0.05); color: var(--rc-ink); }

.rc .rc-body { padding: 14px 18px 18px; overflow-y: auto; overscroll-behavior: contain; }
.rc .rc-intro { margin: 0 0 14px; padding: 0; color: var(--rc-muted); font-size: 15px; font-weight: 400; line-height: 1.5; }

.rc .rc-field { margin: 0 0 12px; }
.rc .rc-field label {
  display: block;
  margin: 0 0 4px;
  padding: 0;
  color: var(--rc-ink);
  font-size: 14px;
  font-weight: 600;
  line-height: 1.4;
  opacity: 1;
}
.rc .rc-hint { margin: 0 0 6px; padding: 0; color: var(--rc-muted); font-size: 13px; font-weight: 400; line-height: 1.45; }

.rc input[type="text"], .rc input[type="email"], .rc select, .rc textarea {
  display: block;
  width: 100%;
  min-height: 44px;
  margin: 0;
  padding: 10px 12px;
  border: 1px solid var(--rc-line);
  border-radius: var(--rc-radius);
  background: var(--rc-field);
  color: var(--rc-ink);
  font-size: 16px; /* 16px: no zoom on focus on phones */
  font-weight: 400;
  line-height: 1.4;
  box-shadow: none;
}
.rc textarea { min-height: 96px; resize: vertical; }
.rc input:focus, .rc select:focus, .rc textarea:focus { border-color: var(--rc-accent); }
.rc [aria-invalid="true"] { border-color: var(--rc-bad); }

.rc .rc-hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }

.rc .rc-privacy { margin: 4px 0 14px; padding: 0; color: var(--rc-muted); font-size: 13px; font-weight: 400; line-height: 1.45; }
.rc .rc-privacy a { color: inherit; text-decoration: underline; background: none; padding: 0; }

.rc .rc-status { margin: 0 0 10px; min-height: 0; font-size: 14px; color: var(--rc-muted); }
.rc .rc-status:empty { display: none; }
.rc .rc-status.rc-bad { color: var(--rc-bad); }

.rc .rc-send, .rc .rc-again {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 48px;
  margin: 0;
  padding: 0 16px;
  border: 0;
  border-radius: var(--rc-radius);
  background: var(--rc-accent);
  color: var(--rc-accent-ink);
  font-size: 16px;
  font-weight: 600;
  line-height: 1;
  text-align: center;
  box-shadow: none;
  cursor: pointer;
}
.rc .rc-send:hover { background: var(--rc-accent-hover); }
.rc .rc-send[disabled] { opacity: 0.6; cursor: progress; }
.rc .rc-again { background: transparent; color: var(--rc-ink); border: 1px solid var(--rc-line); margin-top: 8px; }

.rc .rc-done { outline: none; }
.rc .rc-done-title { margin: 4px 0 8px; font-family: var(--rc-font-title); font-weight: 600; font-size: 18px; color: var(--rc-ink); }
.rc .rc-done-body { margin: 0 0 8px; overflow-wrap: anywhere; }

.rc button:focus-visible, .rc input:focus-visible, .rc select:focus-visible, .rc textarea:focus-visible, .rc a:focus-visible {
  outline: 3px solid var(--rc-accent);
  outline-offset: 2px;
}

/* Phones: the panel becomes a sheet along the bottom edge. */
@media (max-width: 480px) {
  .rc { right: 12px; bottom: max(12px, env(safe-area-inset-bottom)); }
  .rc.rc-is-open { left: 0; right: 0; bottom: 0; align-items: stretch; gap: 0; }
  .rc.rc-is-open .rc-launch { display: none; }
  .rc .rc-panel {
    width: 100%;
    max-height: 88vh;
    max-height: 88dvh;
    border-radius: var(--rc-radius) var(--rc-radius) 0 0;
    border-bottom: 0;
    padding-bottom: env(safe-area-inset-bottom);
  }
}

@media (prefers-reduced-motion: no-preference) {
  .rc-panel:not([hidden]) { animation: rc-in 160ms ease-out; }
  @keyframes rc-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
}

@media print { .rc { display: none !important; } }
