/* ============================================================
   Base & Reset
   ============================================================ */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background: #f0f2f5;
  color: #1a1a2e;
  min-height: 100vh;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 24px 16px 48px;
  line-height: 1.6;
}

/* ============================================================
   Screens
   ============================================================ */
.screen {
  display: none;
  width: 100%;
  max-width: 600px;
}

.screen.active {
  display: block;
}

/* ============================================================
   Card
   ============================================================ */
.card {
  background: #ffffff;
  border-radius: 20px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.08), 0 1px 4px rgba(0, 0, 0, 0.04);
  padding: 32px 24px;
}

/* ============================================================
   Loading screen
   ============================================================ */
#screen-loading .card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  padding: 56px 24px;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid #e8eaf0;
  border-top-color: #4f87f5;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-text {
  color: #7a7a9a;
  font-size: 0.95rem;
}

/* ============================================================
   Status screens (error / finished / success)
   ============================================================ */
#screen-error .card,
#screen-finished .card,
#screen-success .card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 16px;
  padding: 56px 32px;
}

.status-icon {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.75rem;
  font-weight: 700;
  flex-shrink: 0;
}

.error-icon {
  background: #fde8e8;
  color: #d0312d;
}

.finished-icon {
  background: #fff3e0;
  color: #e67e22;
}

.expired-icon {
  background: #f0f0f5;
  color: #7a7a9a;
  font-size: 1.5rem;
}

.success-icon {
  background: #e8f5e9;
  color: #27ae60;
}

#screen-error h2,
#screen-finished h2,
#screen-success h2 {
  font-size: 1.3rem;
  font-weight: 700;
  color: #1a1a2e;
}

#screen-error p,
#screen-finished p,
#screen-success p {
  color: #5a5a7a;
  font-size: 0.95rem;
  max-width: 340px;
}

/* ============================================================
   Form screen — header
   ============================================================ */
.page-title {
  font-size: 1.7rem;
  font-weight: 800;
  color: #1a1a2e;
  letter-spacing: -0.02em;
  margin-bottom: 12px;
}

.intro-greeting {
  font-size: 1.15rem;
  font-weight: 600;
  color: #1a1a2e;
  margin-bottom: 10px;
}

.intro-text {
  font-size: 0.95rem;
  color: #5a5a7a;
  border-left: 3px solid #4f87f5;
  padding-left: 14px;
  margin-bottom: 32px;
  line-height: 1.65;
}

/* ============================================================
   Question block
   ============================================================ */
.question-block {
  border-top: 1px solid #eef0f5;
  padding-top: 28px;
  margin-bottom: 28px;
}

.question-block:last-of-type {
  margin-bottom: 0;
}

/* ============================================================
   Progress bar
   ============================================================ */
.progress-bar {
  height: 8px;
  background: #eef0f5;
  border-radius: 99px;
  margin-bottom: 14px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;              /* idle: empty */
  border-radius: 99px;
  transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1),
              background 0.3s ease;
}

/* Progress states set by JS */
.progress-fill[data-state="selten"]        { width: 20%; }
.progress-fill[data-state="manchmal"]      { width: 55%; }
.progress-fill[data-state="sehr"]          { width: 100%; }
.progress-fill[data-state="ich weiss nicht"] {
  width: 100%;
  background: #b0b8cc !important;  /* neutral grey, override category color */
}

/* ============================================================
   Question title row (icon + title)
   ============================================================ */
.question-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.question-icon {
  width: 28px;
  height: 28px;
  object-fit: contain;
  flex-shrink: 0;
}

/* ============================================================
   Question text
   ============================================================ */
.question-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: #1a1a2e;
  margin-bottom: 0;
}

.question-desc {
  font-size: 0.875rem;
  color: #5a5a7a;
  margin-bottom: 18px;
  line-height: 1.6;
}

/* ============================================================
   Answer buttons
   ============================================================ */
.button-group {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 14px;
}

.answer-btn {
  background: #f5f7fb;
  border: 2px solid transparent;
  border-radius: 12px;
  padding: 12px 8px;
  font-size: 0.9rem;
  font-weight: 500;
  color: #3a3a5c;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s, transform 0.1s;
  text-align: center;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.answer-btn:hover {
  background: #e8ecf8;
  border-color: #c5d2f0;
}

.answer-btn:active {
  transform: scale(0.97);
}

.answer-btn.selected {
  background: #eef3fe;
  border-color: #4f87f5;
  color: #2060d8;
  font-weight: 600;
}

/* ============================================================
   Comment textarea
   ============================================================ */
.comment-field {
  width: 100%;
  border: 1.5px solid #dde1eb;
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 0.875rem;
  font-family: inherit;
  color: #1a1a2e;
  background: #fafbfd;
  resize: vertical;
  transition: border-color 0.15s, box-shadow 0.15s;
  outline: none;
  line-height: 1.5;
}

.comment-field::placeholder {
  color: #aab0c4;
}

.comment-field:focus {
  border-color: #4f87f5;
  box-shadow: 0 0 0 3px rgba(79, 135, 245, 0.12);
  background: #fff;
}

.comment-field.error {
  border-color: #d0312d;
  box-shadow: 0 0 0 3px rgba(208, 49, 45, 0.1);
}

/* ============================================================
   Validation messages
   ============================================================ */
.validation-msg {
  display: none;
  font-size: 0.8rem;
  color: #d0312d;
  margin-top: 6px;
  margin-bottom: 8px;
  font-weight: 500;
}

.validation-msg.visible {
  display: block;
}

/* ============================================================
   Submit section
   ============================================================ */
.submit-section {
  padding-top: 28px;
  border-top: 1px solid #eef0f5;
  margin-top: 8px;
}

#val-general {
  margin-bottom: 12px;
}

.submit-btn {
  width: 100%;
  background: #4f87f5;
  color: #fff;
  border: none;
  border-radius: 14px;
  padding: 16px;
  font-size: 1rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s, opacity 0.15s;
  letter-spacing: 0.01em;
  -webkit-tap-highlight-color: transparent;
}

.submit-btn:hover:not(:disabled) {
  background: #3570e0;
}

.submit-btn:active:not(:disabled) {
  transform: scale(0.98);
}

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

.submit-btn.loading::after {
  content: '';
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255,255,255,0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin-left: 10px;
  vertical-align: middle;
}

/* ============================================================
   Question 7 (comment only)
   ============================================================ */
.question-block--comment-only .comment-field {
  margin-top: 0;
}

/* ============================================================
   Responsive — larger screens
   ============================================================ */
@media (min-width: 480px) {
  .card {
    padding: 40px 36px;
  }

  .button-group {
    grid-template-columns: repeat(4, 1fr);
  }

  .page-title {
    font-size: 2rem;
  }
}
