/*
 * Canais RGB, nao hex: as cores entram com opacidade em varios lugares
 * (rgb(var(--primary) / .15)), e isso so funciona com os canais soltos.
 * Estes valores sao o tema Cursiva e servem de pintura inicial — a API manda o tema
 * da pesquisa e theme.js sobrescreve as mesmas properties antes da primeira tela.
 */
:root {
  --bg: 11 16 25;
  --surface: 17 24 35;
  --surface-hover: 27 37 51;
  --text: 244 247 251;
  --text-secondary: 142 155 173;
  --primary: 139 92 246;
  --primary-hover: 124 58 237;
  --primary-active: 109 40 217;
  --success: 34 197 94;
  --warning: 245 158 11;
  --danger: 239 68 68;
  --info: 6 182 212;

  color-scheme: dark;

  --radius: 0.75rem;
  --radius-sm: 0.5rem;
  --gap: 1rem;
}

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

html {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background: rgb(var(--bg));
  color: rgb(var(--text));
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

::selection {
  color: rgb(var(--text));
  background: rgb(var(--primary) / 0.3);
}

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

/* ---------- estrutura ---------- */

.page {
  max-width: 42rem;
  margin: 0 auto;
  padding: 2.5rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.card {
  background: rgb(var(--surface));
  border-radius: var(--radius);
  padding: 1.5rem;
}

.card--center {
  text-align: center;
}

.question {
  background: rgb(var(--surface));
  border-radius: var(--radius);
  padding: 1.25rem;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: var(--gap);
}

.row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.row--between {
  justify-content: space-between;
}

.row--wrap {
  flex-wrap: wrap;
}

/* ---------- texto ---------- */

h1 {
  font-size: 1.25rem;
  font-weight: 600;
  margin: 0;
}

h2 {
  font-size: 1rem;
  font-weight: 600;
  margin: 0;
}

.muted {
  color: rgb(var(--text-secondary));
}

.small {
  font-size: 0.75rem;
}

.prose {
  white-space: pre-wrap;
  margin: 0.25rem 0 0;
  font-size: 0.875rem;
  color: rgb(var(--text-secondary));
}

.question__title {
  font-size: 0.875rem;
  font-weight: 500;
  margin: 0;
}

.question__hint {
  font-size: 0.75rem;
  color: rgb(var(--text-secondary));
  margin: 0.25rem 0 0;
  white-space: pre-wrap;
}

.required {
  color: rgb(var(--danger));
  margin-left: 0.25rem;
}

.error {
  color: rgb(var(--danger));
  font-size: 0.875rem;
  margin: 0.5rem 0 0;
}

.notice {
  background: rgb(var(--warning) / 0.1);
  color: rgb(var(--warning));
  border-radius: var(--radius-sm);
  padding: 0.75rem;
  font-size: 0.875rem;
  margin: 0;
}

/* ---------- progresso ---------- */

.progress {
  height: 0.25rem;
  border-radius: 999px;
  background: rgb(var(--surface-hover));
  overflow: hidden;
  margin-top: 0.25rem;
}

.progress__bar {
  height: 100%;
  border-radius: 999px;
  background: rgb(var(--primary));
  transition: width 150ms ease;
}

/* ---------- controles ---------- */

.field {
  width: 100%;
  height: 2.5rem;
  padding: 0 0.75rem;
  border-radius: var(--radius-sm);
  border: 1px solid rgb(var(--surface-hover));
  background: rgb(var(--bg));
  color: rgb(var(--text));
  font: inherit;
  font-size: 0.875rem;
}

textarea.field {
  height: auto;
  min-height: 6rem;
  padding: 0.625rem 0.75rem;
  resize: vertical;
}

.field:focus-visible {
  border-color: rgb(var(--primary));
}

.field[aria-invalid='true'] {
  border-color: rgb(var(--danger));
}

.field:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.field--narrow {
  max-width: 20rem;
}

.field--tiny {
  max-width: 7rem;
}

/* opcao (radio/checkbox) */

.choice {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.375rem 0;
  font-size: 0.875rem;
  cursor: pointer;
}

.choice input {
  accent-color: rgb(var(--primary));
  width: 1rem;
  height: 1rem;
  flex: none;
}

.choice--stacked {
  flex-direction: column;
  gap: 0.25rem;
  min-width: 2.25rem;
  text-align: center;
}

.scale {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: flex-end;
}

.stars {
  display: flex;
  gap: 0.25rem;
}

.star {
  background: none;
  border: 0;
  padding: 0.125rem;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  color: rgb(var(--text-secondary) / 0.4);
}

.star[aria-pressed='true'],
.star.is-on {
  color: rgb(var(--warning));
}

.star:disabled {
  cursor: not-allowed;
}

/* ---------- botoes ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  height: 2.5rem;
  padding: 0 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 150ms ease;
  background: rgb(var(--primary));
  color: #fff;
}

.btn:hover:not(:disabled) {
  background: rgb(var(--primary-hover));
}

.btn:active:not(:disabled) {
  background: rgb(var(--primary-active));
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn--secondary {
  background: rgb(var(--surface));
  border-color: rgb(var(--surface-hover));
  color: rgb(var(--text));
}

.btn--secondary:hover:not(:disabled) {
  background: rgb(var(--surface-hover));
}

.btn--secondary:active:not(:disabled) {
  background: rgb(var(--surface-hover));
}

.btn[aria-busy='true'] {
  cursor: progress;
}

/* ---------- utilidades ---------- */

.hidden {
  display: none !important;
}

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

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