/*
 * Shared "fixed-width page" look for the front page / table of contents /
 * question pages. Intentionally NOT responsive: the questionnaire is meant
 * to look like a document (screen, print, or PDF), not a fluid web layout.
 */

body {
  margin: 0;
  background: #eef0f4;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* Authentication form styling used by signup/login/verify */
.form, .auth-form {
  max-width: 480px; margin: 40px auto; padding: 20px; background: #fff; border-radius: 8px;
}
.form h2, .auth-form h2 { margin-top: 0; }
.form input, .auth-form input { width: 100%; padding: 8px; margin-bottom: 12px; border: 1px solid #d0d5dd; border-radius: 6px; }
.form button, .auth-form button { padding: 10px 14px; border-radius: 6px; border: 1px solid #4a5df9; background: #4a5df9; color: #fff; cursor: pointer; }
.form .hint, .auth-form .hint { color: #666; font-size: 13px; }

.qn-root {
  box-sizing: border-box;
  width: 820px;
  margin: 40px auto;
  padding: 0;
}

.qn-root * {
  box-sizing: border-box;
}

.qn-question-gated {
  display: none;
}

/* Hidden by conditional logic ("show only if"), see render.js setupConditionalLogic */
.qn-logic-hidden {
  display: none !important;
}

.qn-page {
  background: inherit;
  padding: 48px 56px;
  margin-bottom: 28px;
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: 8px;
  position: relative;
}

/* Free-plan branding: an inline SVG tiling the Quickforms.pro wordmark
   (see render.js's applyWatermark -- deliberately real content, not a CSS
   background-image, so it isn't silently dropped when printed/saved as PDF). */
.qn-watermark-overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  mix-blend-mode: multiply;
  opacity: 0.6;
}

.qn-logo {
  /* Actual size is set inline (px width, height:auto) from the size chosen
     via the resize handles in the builder; this is just an overflow guard. */
  max-width: 100%;
  display: block;
  margin-bottom: 20px;
}

.qn-headline {
  font-size: 2em;
  margin: 0 0 18px;
}

.qn-body {
  line-height: 1.6;
}

.qn-body img {
  max-width: 100%;
  height: auto;
}

.qn-thanks-share-label {
  color: #8b909c;
  margin-top: 28px;
}

/* ---------- Timed quizzes (a questionnaire with grading.timeLimitMinutes) ---------- */

.qn-timer-bar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  justify-content: center;
  padding: 10px 16px;
  margin-bottom: 20px;
  background: #12172a;
  color: #fff;
  border-radius: 8px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.qn-timer-bar.qn-timer-low {
  background: #c0392b;
}

.qn-timer-bar.qn-timer-expired {
  background: #8b909c;
}

/* ---------- Auto-graded score, shown on the thank-you page ---------- */

.qn-score-box {
  margin: 24px 0;
  padding: 20px;
  border-radius: 10px;
  background: #eef0ff;
  text-align: center;
}

.qn-score-value {
  font-size: 1.8em;
  font-weight: 700;
  color: #12172a;
}

.qn-score-pct {
  margin-top: 4px;
  color: #4a5df9;
  font-weight: 600;
}

.qn-score-pending {
  color: #8b909c;
  font-style: italic;
}

.qn-share-row { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; margin-bottom: 20px; }
.qn-share-btn {
  display: flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; border-radius: 50%; text-decoration: none;
  transition: transform .12s ease, opacity .12s ease;
}
.qn-share-btn:hover { transform: scale(1.08); opacity: .9; }

.qn-toc-title {
  margin-top: 0;
}

.qn-toc-list {
  line-height: 1.9;
}

.qn-toc-list a {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px dotted currentColor;
}

.qn-question-headline {
  font-size: 1.5em;
  margin: 0 0 14px;
  padding-bottom: 8px;
  border-bottom: 2px solid currentColor;
}

.qn-question-desc {
  margin-bottom: 22px;
  line-height: 1.6;
}

.qn-question-desc img {
  max-width: 100%;
  height: auto;
}

.qn-field {
  margin-bottom: 20px;
}

.qn-field-label {
  display: block;
  font-weight: 600;
  margin-bottom: 8px;
}

.qn-required {
  color: #c0392b;
}

.qn-field input[type="text"],
.qn-field input[type="number"],
.qn-field input[type="date"],
.qn-field input[type="time"],
.qn-field textarea,
.qn-field select {
  width: 100%;
  max-width: 460px;
  padding: 9px 11px;
  border: 1px solid #c6cad2;
  border-radius: 5px;
  font: inherit;
  background: #fff;
  color: inherit;
}

.qn-field textarea {
  resize: vertical;
}

.qn-option-group {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.qn-option {
  display: flex;
  align-items: center;
  gap: 7px;
  font-weight: normal;
  cursor: pointer;
}

.qn-rating-group {
  display: flex;
  flex-direction: row-reverse;
  justify-content: flex-end;
  gap: 4px;
}

.qn-rating-input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}

.qn-rating-star {
  font-size: 28px;
  line-height: 1;
  color: #d7d9e0;
  cursor: pointer;
  user-select: none;
}

.qn-rating-star:hover,
.qn-rating-star:hover ~ .qn-rating-star,
.qn-rating-input:checked ~ .qn-rating-star {
  color: #f5b301;
}

.qn-submit-wrap {
  margin-top: 36px;
}

.qn-progress {
  height: 8px;
  margin-bottom: 20px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.12);
  overflow: hidden;
}

.qn-progress-fill {
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: #4a5df9;
  transition: width 0.25s ease;
}

.qn-pagination-error {
  margin-top: 16px;
  color: #c0392b;
  font-size: 0.9em;
}

.qn-pagination-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 36px;
}

.qn-pagination-progress {
  color: inherit;
  opacity: 0.65;
  font-size: 0.9em;
}

.qn-pagination-back,
.qn-pagination-next {
  padding: 11px 26px;
  font-size: 1em;
  border-radius: 6px;
  cursor: pointer;
}

.qn-pagination-next {
  border: none;
  background: #4a5df9;
  color: #fff;
}

.qn-pagination-next:hover {
  background: #3a4bd6;
}

.qn-pagination-back {
  border: 1px solid #c6cad2;
  background: #fff;
  color: #333;
}

.qn-pagination-back:hover {
  background: #f2f3f7;
}

.qn-submit-btn {
  padding: 11px 30px;
  font-size: 1em;
  border-radius: 6px;
  border: none;
  background: #4a5df9;
  color: #fff;
  cursor: pointer;
}

.qn-submit-btn:hover {
  background: #3a4bd6;
}

/* ---------- Print-mode (inert, fill-by-hand) field styling ---------- */

.qn-field-print .qn-field-label {
  display: flex;
  gap: 4px;
}

.qn-print-line {
  border-bottom: 1px solid #333;
  height: 30px;
  min-width: 120px;
}

.qn-print-line-single {
  max-width: 420px;
  padding: 0 4px;
  line-height: 30px;
}

.qn-print-textarea .qn-print-line {
  margin-bottom: 10px;
}

.qn-check-symbol {
  display: inline-block;
  width: 1.3em;
}

.qn-option-print {
  margin-bottom: 5px;
}

.qn-rating-print {
  font-size: 22px;
  letter-spacing: 4px;
  color: #333;
}

.qn-print-note {
  font-style: italic;
  color: #666;
}

/* ---------- Chrome that should never appear in the printed/exported output ---------- */

.qn-noprint {
  /* used on surrounding nav/buttons in view.php / print.php */
}

@media print {
  body {
    background: #fff;
  }
  .qn-noprint {
    display: none !important;
  }
  .qn-root {
    width: auto;
    margin: 0;
  }
  .qn-page {
    border: none;
    border-radius: 0;
    margin-bottom: 0;
    page-break-after: always;
  }
  .qn-page:last-child {
    page-break-after: auto;
  }
}

/* ---------- Submit spinner (shown while a response is being sent) ---------- */

.qn-submit-spinner {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  background: rgba(20, 22, 33, .55);
}

.qn-spinner {
  width: 44px;
  height: 44px;
  border: 4px solid rgba(255, 255, 255, .35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: qn-spin .8s linear infinite;
}

.qn-spinner-text {
  color: #fff;
  font-size: 15px;
  font-weight: 600;
}

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

/* Shown to the owner on their own live form: submissions made while logged in as the owner are not saved */
.qn-owner-banner {
  margin-bottom: 16px;
  padding: 10px 14px;
  border-radius: 6px;
  background: #fff3cd;
  color: #5c4500;
  border: 1px solid #f0d98a;
  font-size: 14px;
  line-height: 1.4;
}

/* Notice that unfinished answers were put back (render.js, setupDraftAutosave) */
.qn-draft-banner {
  margin-bottom: 16px;
  padding: 10px 14px;
  border-radius: 6px;
  background: #eef0ff;
  border: 1px solid #d6dafc;
  color: #2a3a9b;
  font-size: 14px;
  line-height: 1.4;
}
.qn-draft-startover {
  background: none;
  border: none;
  padding: 0;
  color: inherit;
  font: inherit;
  font-weight: 600;
  text-decoration: underline;
  cursor: pointer;
}

/* Accessibility (render.js): text for screen readers only */
.qn-visually-hidden { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* Rating stars: keep the hidden radio keyboard-friendly (visible focus) and give the stars enough contrast */
.qn-rating-input:focus-visible + .qn-rating-star { outline: 3px solid #4a5df9; outline-offset: 2px; border-radius: 4px; }
.qn-rating-star { -webkit-text-stroke: 1px #6b6f7a; } /* the outline of a star meets 3:1 against a white page even when it is not filled */
.qn-page h1:focus, .qn-page h2:focus { outline: none; } /* focus moved here on purpose after Next/Back; no ring around a heading */
