/* Bytelie AI Transition Guide — homepage intake widget.
   Scoped under .atg-widget so this file can also be embedded in other pages
   without colliding with their styles. Inherits the host page's design tokens
   (--bg, --ink, --accent, …) where present and falls back to safe defaults. */

.atg-widget {
  /* Fallback tokens (only used if host page hasn't defined them) */
  --atg-bg: var(--bg, #FDFDFB);
  --atg-bg-2: var(--bg-2, #F5F5F1);
  --atg-card: var(--card, #FFFFFF);
  --atg-ink: var(--ink, #18170F);
  --atg-ink-2: var(--ink-2, #29261B);
  --atg-muted: var(--muted, #6B6759);
  --atg-muted-2: var(--muted-2, #9A9588);
  --atg-line: var(--line, rgba(24,23,15,0.09));
  --atg-line-2: var(--line-2, rgba(24,23,15,0.05));
  --atg-accent: var(--accent, #DDEB5A);
  --atg-accent-ink: var(--accent-ink, #1B2A00);
  --atg-accent-soft: var(--accent-soft, #EAF1A6);
  --atg-danger: #B33;
  --atg-danger-soft: rgba(180, 50, 50, 0.08);

  font-family: 'Inter', ui-sans-serif, system-ui, -apple-system, sans-serif;
  color: var(--atg-ink);
  background: var(--atg-card);
  border: 1px solid var(--atg-line);
  border-radius: 18px;
  padding: clamp(24px, 3vw, 36px);
  box-shadow:
    0 1px 0 rgba(255,255,255,0.6) inset,
    0 24px 60px -36px rgba(24,23,15,0.18),
    0 6px 18px -14px rgba(24,23,15,0.10);
  position: relative;
  overflow: hidden;
}

.atg-widget * { box-sizing: border-box; }

/* Header */
.atg-head { display: flex; flex-direction: column; gap: 8px; margin-bottom: 22px; }
.atg-eyebrow {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--atg-muted);
  display: inline-flex; align-items: center; gap: 8px;
}
.atg-eyebrow::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%;
  background: var(--atg-accent);
  box-shadow: 0 0 0 4px var(--atg-accent-soft);
}
.atg-title {
  font-size: clamp(22px, 2.4vw, 28px);
  letter-spacing: -0.02em;
  font-weight: 500;
  margin: 0;
  line-height: 1.15;
  text-wrap: balance;
}
.atg-title em {
  font-family: 'Instrument Serif', Georgia, serif;
  font-style: normal; font-weight: 400;
}
.atg-sub {
  font-size: 14px; color: var(--atg-muted);
  margin: 0; max-width: 56ch; line-height: 1.5;
  text-wrap: pretty;
}

/* Mobile: drop the widget's intro block — the page <h1> above already frames
   the form, so the eyebrow, title, and sub paragraph are redundant boilerplate
   that pushes the actual question off-screen. */
@media (max-width: 768px) {
  .atg-widget { padding: 18px; border-radius: 14px; }
  .atg-widget .atg-head { display: none; }
  .atg-progress { margin-bottom: 16px; }
}

/* Progress */
.atg-progress {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 22px;
}
.atg-progress-track {
  flex: 1; height: 4px; border-radius: 999px;
  background: var(--atg-bg-2);
  overflow: hidden;
}
.atg-progress-fill {
  height: 100%; width: 0%;
  background: var(--atg-ink);
  border-radius: 999px;
  transition: width .25s ease;
}
.atg-progress-step {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 11px; color: var(--atg-muted);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

/* Answer summary chips — show condensed previous answers above each step */
.atg-summary {
  display: none;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: var(--atg-bg-2);
  border: 1px solid var(--atg-line-2);
  border-radius: 12px;
  margin-bottom: 18px;
}
.atg-summary.is-shown { display: flex; animation: atg-fade .25s ease both; }
.atg-summary-label {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--atg-muted);
  margin-right: 2px;
}
.atg-chip {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 10px 5px 12px;
  border-radius: 999px;
  background: var(--atg-card);
  border: 1px solid var(--atg-line);
  font: inherit;
  font-size: 12.5px;
  color: var(--atg-ink-2);
  cursor: pointer;
  line-height: 1;
  transition: border-color .15s ease, background .15s ease, transform .15s ease, color .15s ease;
}
.atg-chip:hover {
  border-color: var(--atg-ink);
  background: var(--atg-bg);
  color: var(--atg-ink);
}
.atg-chip:focus-visible {
  outline: none;
  border-color: var(--atg-ink);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--atg-ink) 12%, transparent);
}
.atg-chip:active { transform: translateY(1px); }
.atg-chip-key {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--atg-muted-2);
  font-weight: 500;
}
.atg-chip-val {
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 18ch;
}
.atg-chip-edit {
  display: inline-grid; place-items: center;
  width: 16px; height: 16px;
  border-radius: 50%;
  color: var(--atg-muted-2);
  background: var(--atg-bg-2);
  transition: color .15s ease, background .15s ease;
}
.atg-chip:hover .atg-chip-edit {
  color: var(--atg-accent-ink);
  background: var(--atg-accent);
}
@media (max-width: 480px) {
  .atg-summary { padding: 8px 10px; gap: 6px; }
  .atg-chip { font-size: 12px; padding: 4px 8px 4px 10px; }
  .atg-chip-val { max-width: 12ch; }
}

/* Step container */
.atg-step { display: none; }
.atg-step.is-active { display: block; animation: atg-fade .25s ease both; }
@keyframes atg-fade {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: none; }
}

.atg-q {
  font-size: 18px;
  letter-spacing: -0.01em;
  font-weight: 500;
  margin: 0 0 6px;
  line-height: 1.3;
  text-wrap: balance;
}
.atg-help {
  font-size: 13px; color: var(--atg-muted);
  margin: 0 0 18px; line-height: 1.5;
  text-wrap: pretty;
}

/* Option pills (single & multi select) */
.atg-options {
  list-style: none; padding: 0; margin: 0;
  display: grid; gap: 8px;
}
.atg-options.cols-2 { grid-template-columns: 1fr 1fr; }
@media (max-width: 540px) { .atg-options.cols-2 { grid-template-columns: 1fr; } }

.atg-opt {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--atg-line);
  border-radius: 12px;
  background: var(--atg-bg);
  cursor: pointer;
  font-size: 14px;
  line-height: 1.3;
  transition: border-color .15s ease, background .15s ease, box-shadow .15s ease;
  user-select: none;
  position: relative;
}
.atg-opt:hover { border-color: color-mix(in srgb, var(--atg-ink) 18%, var(--atg-line)); }
.atg-opt input { position: absolute; opacity: 0; pointer-events: none; }
.atg-opt .atg-mark {
  flex: 0 0 18px; width: 18px; height: 18px;
  border: 1.5px solid var(--atg-line);
  border-radius: 50%;
  display: grid; place-items: center;
  transition: border-color .15s ease, background .15s ease;
}
.atg-opt[data-multi="true"] .atg-mark { border-radius: 4px; }
.atg-opt .atg-mark::after {
  content: ""; width: 8px; height: 8px;
  border-radius: inherit;
  background: var(--atg-ink);
  opacity: 0;
  transition: opacity .12s ease;
}
.atg-opt[data-multi="true"] .atg-mark::after {
  width: 10px; height: 10px;
  background: transparent;
  border-bottom: 2px solid var(--atg-accent-ink);
  border-right: 2px solid var(--atg-accent-ink);
  border-radius: 0;
  transform: rotate(45deg) translate(-1px, -2px);
  border-radius: 1px;
}
.atg-opt.is-selected {
  border-color: var(--atg-ink);
  background: var(--atg-bg-2);
}
.atg-opt.is-selected .atg-mark { border-color: var(--atg-ink); background: var(--atg-accent); }
.atg-opt.is-selected .atg-mark::after { opacity: 1; }
.atg-opt .atg-opt-label { flex: 1; min-width: 0; }

/* Tool groups (multi-select) */
.atg-tool-grid {
  list-style: none; padding: 0; margin: 0;
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
}
@media (max-width: 540px) { .atg-tool-grid { grid-template-columns: 1fr; } }
.atg-tool-grid .atg-opt { padding: 10px 12px; font-size: 13.5px; }

/* Collapsible category panels for the tool multi-select */
.atg-cat {
  border: 1px solid var(--atg-line);
  border-radius: 12px;
  background: var(--atg-bg);
  margin-top: 8px;
  overflow: hidden;
}
.atg-cat:first-child { margin-top: 0; }
.atg-cat-head {
  appearance: none;
  background: transparent;
  border: 0;
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  cursor: pointer;
  font: inherit;
  text-align: left;
  color: var(--atg-ink);
}
.atg-cat-head:hover { background: var(--atg-bg-2); }
.atg-cat-head:focus-visible {
  outline: none;
  box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--atg-ink) 25%, transparent);
}
.atg-cat-chev {
  display: inline-block;
  transition: transform .2s ease;
  color: var(--atg-muted-2);
  font-size: 16px;
  line-height: 1;
}
.atg-cat-head[aria-expanded="true"] .atg-cat-chev { transform: rotate(90deg); }
.atg-cat-label { flex: 1; font-weight: 500; font-size: 14px; }
.atg-cat-count {
  display: inline-flex;
  min-width: 22px;
  height: 20px;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--atg-accent);
  color: var(--atg-accent-ink);
  font-size: 11px;
  font-weight: 600;
  align-items: center;
  justify-content: center;
}
.atg-cat-body {
  display: none;
  padding: 12px 14px 14px;
  border-top: 1px dashed var(--atg-line-2);
}
.atg-cat.is-open .atg-cat-body { display: block; animation: atg-fade .25s ease both; }

/* Flat (non-collapsible) panels — single-control groups like "No tools yet"
 * and "Anything else". No header, no top border, and no fade-in. */
.atg-cat.is-flat .atg-cat-body {
  border-top: 0;
  animation: none;
}
.atg-cat.is-flat .atg-cat-body .atg-cat-other { margin-top: 0; }
.atg-cat-other { margin-top: 12px; }
.atg-cat-other label {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  font-size: 12.5px;
  color: var(--atg-ink-2);
  font-weight: 500;
  margin-bottom: 6px;
}
.atg-cat-other label .atg-optional {
  font-size: 11px;
  color: var(--atg-muted-2);
  font-weight: 400;
  letter-spacing: 0.04em;
}
.atg-cat-other input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--atg-line);
  border-radius: 10px;
  font: inherit;
  font-size: 13.5px;
  color: var(--atg-ink);
  background: var(--atg-bg);
}
.atg-cat-other input:focus {
  outline: none;
  border-color: var(--atg-ink);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--atg-ink) 12%, transparent);
}

/* Inline soft warning (200_plus team_size) */
.atg-soft-warning {
  margin-top: 12px;
  padding: 12px 14px;
  background: var(--atg-accent-soft);
  border: 1px solid color-mix(in srgb, var(--atg-accent) 60%, transparent);
  border-radius: 12px;
  font-size: 13px; color: var(--atg-accent-ink);
  line-height: 1.5;
  display: none;
}
.atg-soft-warning.is-shown { display: block; animation: atg-fade .25s ease both; }

/* Final step: email + optional + consent */
.atg-field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.atg-field label {
  font-size: 13px; color: var(--atg-ink-2); font-weight: 500;
  display: flex; align-items: baseline; justify-content: space-between; gap: 8px;
}
.atg-field label .atg-optional {
  font-size: 11px; color: var(--atg-muted-2);
  font-weight: 400; letter-spacing: 0.04em;
}
.atg-field input[type="email"],
.atg-field input[type="text"],
.atg-field input[type="url"] {
  padding: 12px 14px;
  border: 1px solid var(--atg-line);
  border-radius: 12px;
  font: inherit; font-size: 14px;
  color: var(--atg-ink);
  background: var(--atg-bg);
  width: 100%;
}
.atg-field input:focus {
  outline: none;
  border-color: var(--atg-ink);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--atg-ink) 12%, transparent);
}

.atg-optional-toggle {
  appearance: none; background: transparent; border: 0;
  font: inherit; font-size: 13px; color: var(--atg-muted);
  cursor: pointer; padding: 4px 0;
  display: inline-flex; align-items: center; gap: 6px;
  margin-bottom: 6px;
}
.atg-optional-toggle:hover { color: var(--atg-ink); }
.atg-optional-toggle .atg-chev {
  display: inline-block; transition: transform .2s ease;
}
.atg-optional-toggle[aria-expanded="true"] .atg-chev { transform: rotate(90deg); }
.atg-optional-block {
  display: none;
  border-top: 1px dashed var(--atg-line-2);
  padding-top: 14px;
  margin-bottom: 6px;
}
.atg-optional-block.is-shown { display: block; animation: atg-fade .25s ease both; }

.atg-consent {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 14px;
  background: var(--atg-bg-2);
  border-radius: 12px;
  margin-top: 8px;
  font-size: 13px; line-height: 1.5;
  color: var(--atg-ink-2);
  cursor: pointer;
  user-select: none;
}
.atg-consent input {
  flex: 0 0 18px; width: 18px; height: 18px;
  margin: 2px 0 0 0;
  accent-color: var(--atg-ink);
}
.atg-consent a { color: inherit; text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 2px; }

/* Honeypot — invisible, off-screen but focusable for bots */
.atg-honey {
  position: absolute; left: -9999px; top: -9999px;
  width: 1px; height: 1px; opacity: 0; pointer-events: none;
}

/* Field-level error */
.atg-error {
  display: none;
  margin-top: 8px;
  font-size: 12.5px;
  color: var(--atg-danger);
  background: var(--atg-danger-soft);
  border-radius: 8px;
  padding: 8px 10px;
  line-height: 1.4;
}
.atg-error.is-shown { display: block; }

/* Footer / nav buttons */
.atg-footer {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin-top: 24px; padding-top: 18px;
  border-top: 1px solid var(--atg-line-2);
  flex-wrap: wrap;
}
.atg-back-row { display: flex; gap: 8px; align-items: center; }
.atg-btn {
  appearance: none; border: 0; cursor: pointer;
  display: inline-flex; align-items: center; gap: 8px;
  padding: 11px 18px;
  border-radius: 999px;
  font: inherit; font-size: 14px; font-weight: 500;
  line-height: 1; white-space: nowrap;
  transition: transform .15s ease, background .15s ease, color .15s ease, box-shadow .15s ease;
}
.atg-btn:disabled { cursor: not-allowed; opacity: 0.45; }
.atg-btn-primary { background: var(--atg-ink); color: var(--atg-bg); }
.atg-btn-primary:not(:disabled):hover { transform: translateY(-1px); box-shadow: 0 8px 24px -8px var(--atg-ink); }
.atg-btn-accent { background: var(--atg-accent); color: var(--atg-accent-ink); }
.atg-btn-accent:not(:disabled):hover { transform: translateY(-1px); box-shadow: 0 8px 24px -8px var(--atg-accent); }
.atg-btn-ghost {
  background: transparent;
  color: var(--atg-ink);
  border: 1px solid var(--atg-line);
}
.atg-btn-ghost:not(:disabled):hover { background: var(--atg-bg-2); }

.atg-foot-meta {
  font-size: 12px; color: var(--atg-muted);
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  letter-spacing: 0.04em;
}

/* Loading state on submit */
.atg-btn.is-loading { position: relative; color: transparent !important; }
.atg-btn.is-loading::after {
  content: ""; position: absolute; left: 50%; top: 50%;
  width: 14px; height: 14px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  animation: atg-spin .7s linear infinite;
  color: var(--atg-bg);
}
.atg-btn-accent.is-loading::after { color: var(--atg-accent-ink); }
@keyframes atg-spin { to { transform: translate(-50%, -50%) rotate(360deg); } }

/* Success card */
.atg-success { display: none; text-align: left; padding: 6px 0; }
.atg-success.is-shown { display: block; animation: atg-fade .3s ease both; }
.atg-success-icon {
  width: 44px; height: 44px; border-radius: 50%;
  background: var(--atg-accent); color: var(--atg-accent-ink);
  display: grid; place-items: center;
  margin-bottom: 16px;
}
.atg-success h3 {
  font-size: clamp(22px, 2.6vw, 28px);
  letter-spacing: -0.02em; font-weight: 500;
  margin: 0 0 8px; line-height: 1.2;
  text-wrap: balance;
}
.atg-success h3 em {
  font-family: 'Instrument Serif', Georgia, serif;
  font-style: normal; font-weight: 400;
}
.atg-success p {
  margin: 0 0 14px; color: var(--atg-muted);
  font-size: 14px; line-height: 1.55;
  max-width: 56ch;
}
.atg-success-actions { margin: 6px 0 14px; display: flex; flex-wrap: wrap; gap: 10px; }
.atg-success-link { display: none; align-items: center; gap: 6px; }
.atg-success-meta {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 11px; letter-spacing: 0.04em;
  color: var(--atg-muted-2); margin: 0;
}
.atg-success-meta code {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  color: var(--atg-muted); user-select: all;
}

/* Generating state — shown immediately on 202 while the worker runs. */
.atg-success-spinner {
  width: 28px; height: 28px; border-radius: 50%;
  border: 3px solid var(--atg-line, #e6e6e6);
  border-top-color: var(--atg-accent, #111);
  animation: atg-spin 0.9s linear infinite;
  margin-bottom: 14px;
}
@keyframes atg-spin { to { transform: rotate(360deg); } }
.atg-success-meta-line {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 11px; letter-spacing: 0.04em;
  color: var(--atg-muted-2); margin: 0 0 6px;
}
.atg-success-elapsed { color: var(--atg-muted-2); }

/* Reduce motion */
@media (prefers-reduced-motion: reduce) {
  .atg-step.is-active,
  .atg-soft-warning.is-shown,
  .atg-success.is-shown,
  .atg-optional-block.is-shown { animation: none; }
  .atg-progress-fill { transition: none; }
  .atg-success-spinner { animation: none; border-top-color: transparent; }
}

.atg-title em,
.atg-success h3 em,
.atg-help em {
  font-family: inherit;
  font-style: normal;
  font-weight: 650;
  letter-spacing: 0;
}
