/**
 * Eligibility check survey ([khaosat_1] EN / [khaosat_1_vn] VI, section#khaosat)
 *
 * Styling only: markup, field names and the scoring JavaScript in functions.php are
 * untouched. The result button must stay the `.ketqua span` (it holds the click handler).
 */

#khaosat {
  --sv-navy: #003150;
  --sv-teal: #00759a;
  --sv-teal-soft: #e8f4f8;
  --sv-line: #d5dde5;
  --sv-muted: #5a6470;
}

/* ---------- Popup screens (first questions) ---------- */
#khaosat .noidung-screen {
  width: min(600px, calc(100vw - 32px));
  padding: 44px 48px 40px;
  border-radius: 16px;
  box-shadow: 0 24px 60px rgba(0, 49, 80, 0.22);
}

#khaosat .tieude-screen {
  margin-bottom: 28px;
  color: var(--sv-navy);
  font-size: 28px;
  font-weight: 600;
  line-height: 1.3;
}

#khaosat .first-quiz-steam-description {
  margin: 14px 0 0;
  color: var(--sv-muted);
  font-size: 14px;
  font-weight: 400;
  line-height: 1.5;
}

#khaosat .screen2 .noidung-screen {
  padding: 40px 36px 36px;
}

/* Dimmed backdrop behind the popup */
.lopphu {
  background: rgba(0, 24, 40, 0.6) !important;
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
}

/* ---------- Answer options: selectable cards with a custom radio ---------- */
#khaosat .wpcf7-radio .wpcf7-list-item {
  margin: 0;
  padding: 0;
  min-height: 0;
  background: none;
  border-radius: 0;
}

#khaosat .wpcf7-radio .wpcf7-list-item label {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  margin: 0;
  padding: 12px 16px;
  color: #000 !important;
  font-size: 15px !important;
  font-weight: 500;
  line-height: 1.4 !important;
  background: #fff;
  border: 1.5px solid var(--sv-line);
  border-radius: 10px;
  cursor: pointer;
  transition: border-color 0.15s, background-color 0.15s, box-shadow 0.15s;
}

#khaosat .wpcf7-radio .wpcf7-list-item label:hover {
  border-color: var(--sv-teal);
  background: #f5fafc;
}

#khaosat .wpcf7-radio .wpcf7-list-item label:has(input:checked) {
  border-color: var(--sv-teal);
  background: var(--sv-teal-soft);
  box-shadow: 0 0 0 1px var(--sv-teal) inset;
}

#khaosat .wpcf7-radio input[type="radio"] {
  flex: none;
  -webkit-appearance: none;
  appearance: none;
  width: 20px !important;
  height: 20px !important;
  margin: 0 !important;
  border: 2px solid #8a96a3;
  border-radius: 50%;
  background: #fff;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
}

#khaosat .wpcf7-radio input[type="radio"]:checked {
  border-color: var(--sv-teal);
  box-shadow: inset 0 0 0 4px #fff;
  background: var(--sv-teal);
}

#khaosat .wpcf7-radio input[type="radio"]:focus-visible {
  outline: 3px solid rgba(0, 117, 154, 0.35);
  outline-offset: 2px;
}

#khaosat .wpcf7-list-item-label {
  color: inherit !important;
  font-size: inherit !important;
}

/* After "Result" the script disables the inputs: keep the answers readable */
#khaosat .wpcf7-radio .wpcf7-list-item label:has(input:disabled) {
  cursor: default;
}

#khaosat .wpcf7-radio .wpcf7-list-item label:has(input:disabled:not(:checked)) {
  opacity: 0.55;
}

/* Popup: options stacked, full width */
#khaosat .radio-option .wpcf7-radio {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 12px;
}

#khaosat .radio-option .wpcf7-radio .wpcf7-list-item {
  width: auto;
}

#khaosat .radio-option .wpcf7-radio .wpcf7-list-item label {
  padding: 14px 18px;
  font-size: 16px !important;
}

/* ---------- Question cards ---------- */
#khaosat .wpcf7-form {
  counter-reset: aav-q;
}

#khaosat .cauhoi {
  counter-increment: aav-q; /* hidden questions (display:none) are not counted */
  max-width: 760px;
  margin: 0 auto 16px;
  padding: 24px 28px !important;
  background: #fff;
  border: 1px solid #e3e9ef;
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0, 49, 80, 0.05);
}

#khaosat .tieudeformhoi {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 18px;
  color: var(--sv-navy);
  font-size: 17px !important;
  font-weight: 600;
  line-height: 1.45;
}

#khaosat .tieudeformhoi::before {
  content: counter(aav-q);
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  margin-top: -2px;
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  background: var(--sv-navy);
  border-radius: 50%;
}

/* Options inside a question: wrap side by side, indented under the title text */
#khaosat .tralloi-cauhoi {
  padding-left: 40px;
}

#khaosat .tralloi-cauhoi .wpcf7-radio {
  display: flex !important;
  flex-wrap: wrap;
  gap: 10px;
}

#khaosat .tralloi-cauhoi .wpcf7-radio .wpcf7-list-item {
  flex: 0 1 auto;
  width: auto !important;
}

/* Questions with many options: two even columns */
#khaosat .cauhoi8 .tralloi-cauhoi .wpcf7-radio {
  display: grid !important;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

#khaosat .cauhoi8 .wpcf7-list-item {
  padding-right: 0 !important;
}

/* Hint shown under a question when the answer is not eligible */
#khaosat .tinhtrang.active:not(:empty) {
  display: flex !important;
  align-items: flex-start;
  gap: 10px;
  margin: 16px 0 0 40px;
  padding: 10px 14px;
  color: #8a1c14;
  font-size: 14px;
  line-height: 1.5;
  background: #fdecea;
  border-left: 4px solid #c62828;
  border-radius: 6px;
}

#khaosat .tinhtrang.active:not(:empty)::before {
  content: "!";
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  background: #c62828;
  border-radius: 50%;
}

/* ---------- "Result" button (.ketqua span is the click target) ---------- */
#khaosat .ketqua {
  max-width: 760px;
  margin: 28px auto 32px;
  padding: 0 !important;
}

#khaosat .ketqua span {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 14px 36px !important;
  color: #fff !important;
  font-size: 16px;
  font-weight: 600;
  background: linear-gradient(100deg, #003150 0%, #004a73 50%, #00759a 100%) !important;
  background-size: 160% 100% !important;
  border-radius: 10px !important;
  box-shadow: 0 6px 18px rgba(0, 49, 80, 0.22);
  cursor: pointer;
  user-select: none;
  transition: background-position 0.4s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

#khaosat .ketqua span::after {
  content: "\2192";
  font-size: 18px;
  line-height: 1;
}

#khaosat .ketqua span:hover {
  background-position: 100% 0 !important;
  box-shadow: 0 10px 24px rgba(0, 49, 80, 0.3);
  transform: translateY(-1px);
}

/* ---------- Result cards ---------- */
#khaosat .formhienthi-cuoi {
  max-width: 760px;
  margin: 0 auto 24px;
  padding: 32px 32px 28px !important;
  text-align: left;
  background: #fff;
  border: 1px solid #e3e9ef;
  border-top: 6px solid var(--sv-teal);
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(0, 49, 80, 0.10);
}

#khaosat .formhienthi-cuoi.khongdudieukiennew {
  border-top-color: #c62828;
}

#khaosat .formhienthi-cuoi.khongxacdinh {
  border-top-color: #b26a00;
}

#khaosat .tieude-fromcuoi {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 20px !important;
  color: var(--sv-navy);
  font-size: 28px !important;
  font-style: normal;
  font-weight: 600;
  line-height: 1.3 !important;
}

#khaosat .tieude-fromcuoi::before {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  color: #fff;
  font-size: 22px;
  font-weight: 700;
  border-radius: 50%;
}

#khaosat .dudieukiennew .tieude-fromcuoi::before {
  content: "\2713";
  background: var(--sv-teal);
}

#khaosat .khongdudieukiennew .tieude-fromcuoi::before {
  content: "\2715";
  background: #c62828;
}

#khaosat .khongxacdinh .tieude-fromcuoi::before {
  content: "?";
  background: #b26a00;
}

#khaosat .noidung-formcuoi {
  padding: 20px 22px !important;
  color: #000;
  font-size: 15px;
  line-height: 1.6;
  background: #f5f8fa !important;
  border-radius: 8px !important;
}

#khaosat .noidung-formcuoi p:last-child {
  margin-bottom: 0;
}

/* Links were plain browser blue */
#khaosat .noidung-formcuoi a {
  color: var(--sv-teal) !important;
}

/* ---------- Mobile ---------- */
@media (max-width: 549px) {
  #khaosat .noidung-screen,
  #khaosat .screen2 .noidung-screen {
    padding: 28px 20px 24px;
  }

  #khaosat .tieude-screen {
    margin-bottom: 20px;
    font-size: 22px;
  }

  #khaosat .cauhoi {
    padding: 18px 16px !important;
  }

  #khaosat .tieudeformhoi {
    font-size: 16px !important;
  }

  #khaosat .tralloi-cauhoi {
    padding-left: 0;
  }

  #khaosat .tralloi-cauhoi .wpcf7-radio .wpcf7-list-item {
    flex: 1 1 100%;
  }

  #khaosat .cauhoi8 .tralloi-cauhoi .wpcf7-radio {
    grid-template-columns: 1fr;
  }

  #khaosat .tinhtrang.active:not(:empty) {
    margin-left: 0;
  }

  #khaosat .formhienthi-cuoi {
    padding: 24px 16px 20px !important;
  }

  #khaosat .tieude-fromcuoi {
    font-size: 22px !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  #khaosat .ketqua span,
  #khaosat .wpcf7-radio .wpcf7-list-item label,
  #khaosat .wpcf7-radio input[type="radio"] {
    transition: none;
  }
}

/* ---------- Borderless variant (less visual noise) ----------
   Fills instead of outlines: question cards on a light tint, options on a slightly
   darker tint, the selected option in Teal tint. Only the radio circle keeps a ring. */
#khaosat .cauhoi {
  background: #f5f8fa;
  border: 0;
  box-shadow: none;
}

#khaosat .wpcf7-radio .wpcf7-list-item label {
  background: #fff;
  border: 0;
  box-shadow: none;
}

#khaosat .wpcf7-radio .wpcf7-list-item label:hover {
  background: #eaf3f7;
}

#khaosat .wpcf7-radio .wpcf7-list-item label:has(input:checked) {
  background: #d9eef5;
  box-shadow: none;
}

/* Popup options sit on white: give them the tint instead */
#khaosat .radio-option .wpcf7-radio .wpcf7-list-item label {
  background: #f0f4f7;
}

#khaosat .radio-option .wpcf7-radio .wpcf7-list-item label:hover {
  background: #e3eef4;
}

#khaosat .tinhtrang.active:not(:empty) {
  border-left: 0;
}

#khaosat .formhienthi-cuoi {
  border: 0;
  border-top: 0;
}

/* Popup: softer shadow */
#khaosat .noidung-screen {
  box-shadow: 0 2px 6px rgba(0, 49, 80, 0.05), 0 12px 32px rgba(0, 49, 80, 0.08);
}

/* ---------- Survey embedded on its own page ([khaosat_* show="true"]) ----------
   The Customizer forces #khaosat.true{min-height:100vh} and the question screens are
   fixed popups, which left ~900px of empty page around a floating card. On these pages
   the screens sit in the page flow and the section grows with its content. The popup
   behaviour (opened from a .kiemtranangluc button, show="false") is unchanged. */
#khaosat.true {
  min-height: 0 !important;
  padding-top: 40px;
  padding-bottom: 56px;
}

#khaosat.true .sreen {
  position: static;
  z-index: auto;
  transform: none;
  margin: 0 auto 24px;
}

/* Keep the screen visible only while active (Flatsome/Customizer show it via classes) */
#khaosat.true .sreen:not(.active) {
  display: none;
}

#khaosat.true .noidung-screen {
  box-shadow: 0 2px 6px rgba(0, 49, 80, 0.05), 0 12px 32px rgba(0, 49, 80, 0.08);
}

@media (max-width: 549px) {
  #khaosat.true {
    padding-top: 20px;
    padding-bottom: 32px;
  }
}

/* Classification first: while question 1 (disability) or question 2 (disadvantaged
   area) is still open, no question set is shown. The script reveals Stream 2 as soon
   as question 1 is answered "No", before question 2 is answered; hide it until then. */
#khaosat.true .sreen.active ~ :is(.hiencanh1, .hiencanh2, .hiencanh3) {
  display: none !important;
}
