/* ==========================================================================
   survey-chatbot — styles
   Clean, academic look. UChicago Booth maroon accent. No external assets.
   ========================================================================== */

:root {
  --maroon: #800000;
  --maroon-dark: #5e0000;
  --ink: #1f2024;
  --muted: #5f6368;
  --line: #e0e0e3;
  --line-strong: #c8c8cc;
  --bg: #f3f3f4;
  --card: #ffffff;
  --maroon-tint: #f6ecec;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 6px 24px rgba(0, 0, 0, 0.05);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  line-height: 1.6;
  display: flex;
  flex-direction: column;
  min-height: 100%;
  -webkit-font-smoothing: antialiased;
}

.wrap {
  width: 100%;
  max-width: 730px;
  margin: 0 auto;
  padding: 0 20px;
}

/* ---- Header / footer ---------------------------------------------------- */
.site-header {
  background: var(--maroon);
  color: #fff;
  padding: 14px 0;
}
.site-header-inner {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}
.logo-mark {
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: 0.01em;
}
.study-tag {
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  opacity: 0.85;
  white-space: nowrap;
}
.site-footer {
  margin-top: auto;
  padding: 22px 0;
  color: var(--muted);
  font-size: 0.82rem;
  text-align: center;
}
.footer-note { margin: 0; }
.footer-paper { margin: 8px 0 0; }
.footer-paper a { font-weight: 600; }

/* ---- App / progress ----------------------------------------------------- */
#app { padding-top: 26px; padding-bottom: 26px; flex: 1; }

.progress { margin-bottom: 18px; }
.progress-bar {
  height: 7px;
  background: var(--line);
  border-radius: 99px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: var(--maroon);
  border-radius: 99px;
  transition: width 0.35s ease;
}
.progress-label {
  margin-top: 6px;
  font-size: 0.78rem;
  color: var(--muted);
}

/* ---- Screen card -------------------------------------------------------- */
.screen {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 34px 36px;
  outline: none;
}
.screen:focus-visible { box-shadow: var(--shadow), 0 0 0 3px var(--maroon-tint); }

.screen-title {
  font-size: 1.4rem;
  margin: 0 0 4px;
  color: var(--ink);
}
.screen-eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.09em;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--maroon);
  margin-bottom: 6px;
}
.intro { color: #34353a; margin: 12px 0 6px; }
.muted { color: var(--muted); }

/* ---- Consent ------------------------------------------------------------ */
.consent-section { margin: 18px 0; }
.consent-section h3 {
  font-size: 0.95rem;
  margin: 0 0 2px;
  color: var(--maroon-dark);
}
.consent-section p { margin: 0; }
.agreement {
  background: var(--maroon-tint);
  border: 1px solid #e7d4d4;
  border-radius: var(--radius);
  padding: 14px 16px;
  margin: 22px 0 10px;
  font-size: 0.93rem;
}

/* ---- Questions ---------------------------------------------------------- */
.question { margin: 26px 0; }
.question:first-of-type { margin-top: 18px; }
.q-prompt {
  font-weight: 600;
  margin-bottom: 12px;
}
.q-optional {
  display: inline-block;
  font-weight: 400;
  font-size: 0.78rem;
  color: var(--muted);
  margin-left: 6px;
}
.q-help {
  font-size: 0.85rem;
  color: var(--muted);
  margin: -6px 0 12px;
}

/* Single-choice list */
.options { display: flex; flex-direction: column; gap: 8px; }
.option {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 11px 14px;
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s;
}
.option:hover { border-color: var(--maroon); }
.option:has(input:checked) {
  border-color: var(--maroon);
  background: var(--maroon-tint);
}
.option:has(input:focus-visible) { box-shadow: 0 0 0 3px var(--maroon-tint); }
.option input { margin: 4px 0 0; accent-color: var(--maroon); flex: none; }

/* Matrix question */
.matrix-factor {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 13px 15px;
  margin-bottom: 10px;
  background: #fcfcfc;
}
.factor-label { font-weight: 600; margin-bottom: 9px; font-size: 0.95rem; }
.chip-group { display: flex; flex-wrap: wrap; gap: 7px; }
.chip {
  position: relative;
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 99px;
  padding: 6px 13px;
  font-size: 0.85rem;
  cursor: pointer;
  user-select: none;
  transition: all 0.12s;
}
.chip:hover { border-color: var(--maroon); }
.chip input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}
.chip:has(input:checked) {
  background: var(--maroon);
  border-color: var(--maroon);
  color: #fff;
}
.chip:has(input:focus-visible) { box-shadow: 0 0 0 3px var(--maroon-tint); }

/* Free text */
textarea.q-text {
  width: 100%;
  min-height: 92px;
  font-family: var(--font);
  font-size: 0.95rem;
  padding: 11px 13px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  resize: vertical;
}
textarea.q-text:focus-visible {
  outline: none;
  border-color: var(--maroon);
  box-shadow: 0 0 0 3px var(--maroon-tint);
}

/* Numeric input */
.q-number { display: flex; align-items: center; gap: 8px; }
.q-number-prefix { font-weight: 600; color: var(--muted); }
input.q-num {
  font: inherit;
  font-size: 0.95rem;
  padding: 11px 13px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  width: 220px;
  max-width: 100%;
}
input.q-num:focus-visible {
  outline: none;
  border-color: var(--maroon);
  box-shadow: 0 0 0 3px var(--maroon-tint);
}

/* ---- Buttons / nav ------------------------------------------------------ */
.nav-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 30px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}
.btn {
  font: inherit;
  font-weight: 600;
  border-radius: 8px;
  padding: 11px 22px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 0.12s, border-color 0.12s, opacity 0.12s;
}
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--maroon-tint); }
.btn-primary { background: var(--maroon); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--maroon-dark); }
.btn-secondary { background: #fff; color: var(--maroon); border-color: var(--line-strong); }
.btn-secondary:hover:not(:disabled) { border-color: var(--maroon); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-hidden { visibility: hidden; }

/* ---- Chatbot ------------------------------------------------------------ */
.chat {
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  margin-top: 16px;
}
.chat-log {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  height: 340px;
  overflow-y: auto;
  background: #fafafa;
}
.msg { max-width: 86%; padding: 10px 14px; border-radius: 14px; font-size: 0.93rem; }
.msg.bot {
  background: #fff;
  border: 1px solid var(--line);
  border-bottom-left-radius: 4px;
  align-self: flex-start;
}
.msg.user {
  background: var(--maroon);
  color: #fff;
  border-bottom-right-radius: 4px;
  align-self: flex-end;
}
.msg p { margin: 0 0 8px; }
.msg p:last-child { margin-bottom: 0; }
.msg ul { margin: 6px 0; padding-left: 20px; }
.msg code {
  background: rgba(0, 0, 0, 0.06);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 0.88em;
}
.msg.user code { background: rgba(255, 255, 255, 0.2); }

.typing { display: inline-flex; gap: 4px; align-items: center; }
.typing span {
  width: 7px; height: 7px;
  background: var(--line-strong);
  border-radius: 50%;
  animation: blink 1.3s infinite both;
}
.typing span:nth-child(2) { animation-delay: 0.2s; }
.typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink { 0%, 80%, 100% { opacity: 0.25; } 40% { opacity: 1; } }

.suggested {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  padding: 12px 16px 0;
  background: #fafafa;
}
.suggest-chip {
  font: inherit;
  font-size: 0.83rem;
  background: #fff;
  border: 1px solid var(--line-strong);
  color: var(--maroon);
  border-radius: 99px;
  padding: 6px 13px;
  cursor: pointer;
}
.suggest-chip:hover:not(:disabled) { border-color: var(--maroon); background: var(--maroon-tint); }
.suggest-chip:disabled { opacity: 0.5; cursor: default; }

.chat-input-row {
  display: flex;
  gap: 8px;
  padding: 12px 16px 16px;
  background: #fafafa;
  border-top: 1px solid var(--line);
}
.chat-input {
  flex: 1;
  font: inherit;
  font-size: 0.93rem;
  padding: 10px 13px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  resize: none;
  max-height: 120px;
}
.chat-input:focus-visible {
  outline: none;
  border-color: var(--maroon);
  box-shadow: 0 0 0 3px var(--maroon-tint);
}
.chat-send { flex: none; }
.chat-note { font-size: 0.78rem; color: var(--muted); margin-top: 10px; }
.paper-link { margin: 6px 0 0; }
.paper-link a { font-weight: 600; }

/* ---- End / notice screens ---------------------------------------------- */
.notice { text-align: center; padding: 14px 0; }
.notice .big-check {
  width: 56px; height: 56px;
  margin: 0 auto 14px;
  border-radius: 50%;
  background: var(--maroon-tint);
  color: var(--maroon);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.7rem;
}
.notice p { color: #34353a; }
a { color: var(--maroon); }

/* ---- Responsive --------------------------------------------------------- */
@media (max-width: 560px) {
  .screen { padding: 24px 20px; }
  .site-header-inner { flex-direction: column; align-items: flex-start; gap: 2px; }
  .logo-mark { font-size: 0.85rem; }
  .nav-row { flex-direction: column-reverse; }
  .nav-row .btn { width: 100%; }
  .chat-log { height: 300px; }
  .msg { max-width: 92%; }
}

/* Very narrow screens: stack the chat send button below the input. */
@media (max-width: 360px) {
  .chat-input-row { flex-wrap: wrap; }
  .chat-send { width: 100%; }
}
