/* terms.gg design system, light, high-contrast, Stripe-adjacent. */

:root {
  --brand: #635bff;
  --brand-dark: #4b45c6;
  --brand-light: #7a73ff;
  --brand-wash: #f5f4ff;

  --navy: #0a2540;
  --ink: #1a1f36;
  --body: #425466;
  --muted: #6b7c93;
  --faint: #8c9bab;

  --line: #e3e8ee;
  --line-soft: #eef1f6;
  --surface: #ffffff;
  --surface-sunken: #f6f9fc;
  --surface-raised: #ffffff;

  --green: #0e9f6e;
  --green-wash: #e8f8f2;
  --amber: #b45309;
  --amber-wash: #fef5e7;
  --red: #df1b41;
  --red-wash: #fdeef2;
  --blue: #0570de;
  --blue-wash: #ebf4ff;

  --r-sm: 6px;
  --r-md: 8px;
  --r-lg: 12px;
  --r-xl: 18px;

  /* Stripe's signature layered shadows. */
  --shadow-xs: 0 1px 1px rgba(0, 0, 0, 0.03), 0 3px 6px rgba(0, 0, 0, 0.02);
  --shadow-sm: 0 2px 5px -1px rgba(50, 50, 93, 0.12), 0 1px 3px -1px rgba(0, 0, 0, 0.1);
  --shadow-md: 0 6px 12px -2px rgba(50, 50, 93, 0.16), 0 3px 7px -3px rgba(0, 0, 0, 0.16);
  --shadow-lg: 0 13px 27px -5px rgba(50, 50, 93, 0.2), 0 8px 16px -8px rgba(0, 0, 0, 0.2);
  --shadow-xl: 0 30px 60px -12px rgba(50, 50, 93, 0.25), 0 18px 36px -18px rgba(0, 0, 0, 0.25);
  --ring: 0 0 0 3px rgba(99, 91, 255, 0.25);

  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Inter', Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, monospace;

  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --speed: 180ms;
}

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

/* `hidden` must win over any display rule a component sets. */
[hidden] { display: none !important; }

/* Off-screen until focused, so keyboard users can jump past the navigation. */
.skip-link {
  position: fixed; top: 8px; left: 8px; z-index: 300;
  padding: 8px 14px; border-radius: var(--r-sm);
  background: var(--navy); color: #fff; font-size: 13px; font-weight: 560;
  transform: translateY(-200%);
  transition: transform 160ms var(--ease);
}
.skip-link:focus { transform: none; color: #fff; }

html { -webkit-text-size-adjust: 100%; }

/* Nothing on a marketing or document page should scroll sideways. Tables and
   code blocks get their own scroller instead. */
html, body { overflow-x: clip; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
  color: var(--body);
  background: var(--surface);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4 {
  color: var(--navy);
  margin: 0;
  font-weight: 620;
  letter-spacing: -0.021em;
  line-height: 1.2;
}

h1 { font-size: 44px; letter-spacing: -0.032em; }
h2 { font-size: 30px; letter-spacing: -0.026em; }
h3 { font-size: 19px; }
h4 { font-size: 15px; }

p { margin: 0; }

a { color: var(--brand); text-decoration: none; transition: color var(--speed) var(--ease); }
a:hover { color: var(--brand-dark); }

img, svg { max-width: 100%; display: block; }

code, pre, .mono { font-family: var(--mono); font-size: 13px; }

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

::selection { background: rgba(99, 91, 255, 0.18); }

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

/* ------------------------------------------------------------ layout */

.wrap { width: min(1120px, 100% - 48px); margin-inline: auto; min-width: 0; }
.wrap-sm { width: min(760px, 100% - 48px); margin-inline: auto; min-width: 0; }

.stack { display: flex; flex-direction: column; }
.row { display: flex; align-items: center; }
.between { display: flex; align-items: center; justify-content: space-between; }
.gap-2 { gap: 8px; } .gap-3 { gap: 12px; } .gap-4 { gap: 16px; }
.gap-5 { gap: 24px; } .gap-6 { gap: 32px; }
.grow { flex: 1; min-width: 0; }
.wrap-flex { flex-wrap: wrap; }

/* ------------------------------------------------------------- brand */

.logo { display: inline-flex; align-items: center; gap: 9px; color: var(--navy); font-weight: 640; font-size: 17px; letter-spacing: -0.02em; }
.logo:hover { color: var(--navy); }
.logo-mark {
  /* The mark is round and carries its own silhouette, so nothing clips it. */
  width: 26px; height: 26px; flex: none;
  display: block; object-fit: contain;
}
/* Kept for the few places that still inline the mark as SVG. */
.logo-mark svg { width: 14px; height: 14px; }

/* -------------------------------------------------------------- type */

.eyebrow {
  font-size: 12px;
  font-weight: 620;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--brand);
}
.lede { font-size: 18px; line-height: 1.65; color: var(--body); }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.strong { font-weight: 600; color: var(--ink); }
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.gradient-text {
  background: linear-gradient(94deg, #635bff 4%, #0ba5ec 52%, #11b3a3 96%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* ----------------------------------------------------------- buttons */

.btn {
  --btn-bg: var(--brand);
  --btn-fg: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 16px;
  height: 40px;
  border: 0;
  border-radius: var(--r-sm);
  background: var(--btn-bg);
  color: var(--btn-fg);
  font-size: 14px;
  font-weight: 560;
  letter-spacing: -0.005em;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: var(--shadow-sm);
  transition: background var(--speed) var(--ease), box-shadow var(--speed) var(--ease),
    opacity var(--speed) var(--ease);
}
.btn:hover { background: color-mix(in srgb, var(--btn-bg) 90%, #000); color: var(--btn-fg); }
.btn:active { background: color-mix(in srgb, var(--btn-bg) 82%, #000); box-shadow: var(--shadow-xs); }
.btn[disabled] { opacity: 0.6; pointer-events: none; }

/*
 * A button that is working says so.
 *
 * This used to be a 40% dim, which on a request that takes several seconds
 * reads as a button that did not register the click, so people press it again.
 * The label is made transparent rather than removed, so the button keeps its
 * width and nothing around it moves, and a spinner takes its place. The colour
 * comes from the button's own foreground, so it is white on a solid button and
 * dark on a pale one without a rule per variant.
 */
.btn.is-loading {
  position: relative;
  pointer-events: none;
  color: transparent;
}
.btn.is-loading > * { visibility: hidden; }
.btn.is-loading::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 15px;
  height: 15px;
  margin: -8px 0 0 -8px;
  border-radius: 50%;
  border: 2px solid color-mix(in srgb, var(--btn-fg) 28%, transparent);
  border-top-color: var(--btn-fg);
  animation: btn-spin 620ms linear infinite;
}
.btn-sm.is-loading::after, .btn-icon.is-loading::after {
  width: 13px; height: 13px; margin: -7px 0 0 -7px;
}
@keyframes btn-spin { to { transform: rotate(360deg); } }
/* Still turning, slowly enough not to be the thing you look at. */
@media (prefers-reduced-motion: reduce) {
  .btn.is-loading::after { animation-duration: 2s; }
}

.btn-secondary {
  --btn-bg: #fff;
  --btn-fg: var(--ink);
  box-shadow: inset 0 0 0 1px var(--line), var(--shadow-xs);
}
.btn-secondary:hover { --btn-fg: var(--navy); background: var(--surface-sunken); box-shadow: inset 0 0 0 1px #d4dbe4, var(--shadow-xs); }

.btn-ghost {
  --btn-bg: transparent;
  --btn-fg: var(--body);
  box-shadow: none;
}
.btn-ghost:hover { --btn-bg: var(--surface-sunken); --btn-fg: var(--ink); background: var(--surface-sunken); box-shadow: none; }

.btn-danger { --btn-bg: var(--red); }
.btn-dark { --btn-bg: var(--navy); }
.btn-sm { height: 32px; padding: 0 12px; font-size: 13px; border-radius: var(--r-sm); }
.btn-lg { height: 46px; padding: 0 22px; font-size: 15px; }
.btn-block { width: 100%; }
.btn-icon { width: 32px; padding: 0; }

.link-arrow { display: inline-flex; align-items: center; gap: 5px; font-weight: 560; }
.link-arrow svg { transition: transform var(--speed) var(--ease); }
.link-arrow:hover svg { transform: translateX(3px); }

/* ------------------------------------------------------------ inputs */

.field { display: flex; flex-direction: column; gap: 6px; }
.label { font-size: 13px; font-weight: 560; color: var(--ink); }
.hint { font-size: 12.5px; color: var(--muted); }

.input, .textarea, .select {
  width: 100%;
  padding: 9px 12px;
  border-radius: var(--r-sm);
  border: 0;
  background: #fff;
  color: var(--ink);
  font-size: 14px;
  box-shadow: inset 0 0 0 1px var(--line), var(--shadow-xs);
  transition: box-shadow var(--speed) var(--ease);
}
.input::placeholder, .textarea::placeholder { color: var(--faint); }
.input:focus, .textarea:focus, .select:focus {
  outline: 0;
  box-shadow: inset 0 0 0 1px var(--brand), var(--ring);
}
.input[aria-invalid='true'] { box-shadow: inset 0 0 0 1px var(--red), 0 0 0 3px rgba(223, 27, 65, 0.15); }
.textarea { resize: vertical; min-height: 96px; line-height: 1.55; }

.select {
  appearance: none;
  padding-right: 34px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236b7c93' d='M6 8.5 2.5 5h7z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
}

.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch-track {
  width: 38px; height: 22px; border-radius: 999px;
  background: #cfd7e0; position: relative; flex: none;
  transition: background var(--speed) var(--ease);
  box-shadow: inset 0 1px 2px rgba(10, 37, 64, 0.12);
}
.switch-track::after {
  content: ''; position: absolute; top: 2px; left: 2px;
  width: 18px; height: 18px; border-radius: 50%; background: #fff;
  box-shadow: var(--shadow-sm);
  transition: transform var(--speed) var(--ease);
}
.switch input:checked + .switch-track { background: var(--brand); }
.switch input:checked + .switch-track::after { transform: translateX(16px); }
.switch input:focus-visible + .switch-track { box-shadow: var(--ring); }

/* ------------------------------------------------------------- cards */

.card {
  background: var(--surface-raised);
  border-radius: var(--r-lg);
  box-shadow: inset 0 0 0 1px var(--line-soft), var(--shadow-sm);
}
.card-pad { padding: 22px 24px; }
.card-head {
  padding: 18px 24px;
  border-bottom: 1px solid var(--line-soft);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.card-body { padding: 22px 24px; }
.card-foot {
  padding: 14px 24px;
  border-top: 1px solid var(--line-soft);
  background: var(--surface-sunken);
  border-radius: 0 0 var(--r-lg) var(--r-lg);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

/* ------------------------------------------------------------- badge */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 22px;
  padding: 0 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 560;
  letter-spacing: -0.002em;
  background: var(--surface-sunken);
  color: var(--body);
  white-space: nowrap;
}
.badge-ai { background: var(--brand-wash); color: var(--brand-dark); }
.badge-waiting { background: var(--amber-wash); color: var(--amber); }
.badge-human { background: var(--blue-wash); color: var(--blue); }
.badge-resolved { background: var(--green-wash); color: var(--green); }
.badge-error { background: var(--red-wash); color: var(--red); }
.dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }

/* ------------------------------------------------------------- misc */

.divider { height: 1px; background: var(--line-soft); border: 0; margin: 0; }

.kbd {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 20px; height: 20px; padding: 0 5px;
  border-radius: 4px; background: #fff; color: var(--muted);
  font-size: 11px; font-family: var(--mono);
  box-shadow: inset 0 0 0 1px var(--line), 0 1px 0 var(--line);
}

.spinner {
  width: 15px; height: 15px; flex: none;
  border-radius: 50%;
  border: 2px solid currentColor;
  border-right-color: transparent;
  animation: spin 640ms linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.skeleton {
  background: linear-gradient(90deg, #eef1f6 25%, #f6f9fc 50%, #eef1f6 75%);
  background-size: 300% 100%;
  animation: shimmer 1.4s ease-in-out infinite;
  border-radius: var(--r-sm);
}
@keyframes shimmer { from { background-position: 150% 0; } to { background-position: -50% 0; } }

.fade-in { animation: fadeIn 260ms var(--ease) both; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.empty {
  display: grid;
  place-items: center;
  gap: 8px;
  padding: 56px 24px;
  text-align: center;
  color: var(--muted);
}
.empty h4 { color: var(--ink); }

/* Bottom-right, so a toast never lands on top of the reply box. */
.toast-host {
  position: fixed;
  bottom: 20px; right: 20px;
  display: flex; flex-direction: column; align-items: flex-end; gap: 8px;
  z-index: 200;
  pointer-events: none;
}
@media (max-width: 560px) {
  .toast-host { left: 16px; right: 16px; align-items: stretch; }
}
.toast {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 16px;
  border-radius: var(--r-md);
  background: var(--navy);
  color: #fff;
  font-size: 14px;
  box-shadow: var(--shadow-lg);
  animation: toastIn 240ms var(--ease) both;
}
.toast-error { background: var(--red); }
.toast-success { background: var(--green); }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px) scale(0.97); } to { opacity: 1; transform: none; } }

.visually-hidden {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

@media (max-width: 720px) {
  h1 { font-size: 34px; }
  h2 { font-size: 25px; }
  .wrap, .wrap-sm { width: calc(100% - 32px); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
