/* ============================================================
   Wellness We care — Health Risk Assessment
   ระบบดีไซน์กลาง · สีตาม CI ของแบรนด์ · ฟอนต์ Kanit
   ============================================================ */

@import url("fonts.css");

:root {
  /* ---- สีหลักตาม CI ---- */
  --ci-blue:       #0070ba;
  --ci-blue-light: #8bcbf1;
  --ci-grey:       #949599;

  /* ---- สีรองตาม CI ---- */
  --ci-blue-2:     #3092d0;
  --ci-sand:       #d7c9c0;
  --ci-cream:      #f4ece1;
  --ci-brown:      #6e6043;
  --ci-taupe:      #a9917b;
  --ci-forest:     #39654a;
  --ci-sage-grey:  #7e9291;
  --ci-green:      #7ba858;
  --ci-olive:      #96a07d;

  /* ---- พื้นผิวและเส้น ---- */
  --bg:          #f2f6f9;
  --bg-2:        #e8eff5;
  --surface:     #ffffff;
  --surface-2:   #f6f9fb;
  --surface-warm:#faf6f0;
  --line:        #dce5ec;
  --line-soft:   #ebf1f6;

  /* ---- ตัวอักษร ---- */
  --ink:         #22282e;
  --ink-2:       #4a545e;
  --muted:       #7d8288;

  /* ---- แบรนด์ ---- */
  --brand:       var(--ci-blue);
  --brand-2:     var(--ci-blue-2);
  --brand-soft:  #e7f2fa;
  --brand-ink:   #005387;

  /* ---- ระดับความเสี่ยง: เขียว / เหลือง / แดง ----
     เขียวใช้สี CI โดยตรง ส่วนเหลืองกับแดงเลือกโทนที่กลมกลืนกับกลุ่มสีอบอุ่นของ CI
     (สัญญาณไฟจราจรเป็นข้อกำหนดด้านการสื่อสาร จึงต้องมีเหลืองและแดงที่อ่านออกชัด) */
  --low:         var(--ci-green);
  --low-soft:    #eef5e8;
  --low-line:    #cfe2bf;
  --low-ink:     #4b7233;

  --mid:         #d99b3d;
  --mid-soft:    #fbf2e3;
  --mid-line:    #eeddba;
  --mid-ink:     #92601a;

  --high:        #c4453c;
  --high-soft:   #fbeae8;
  --high-line:   #f0c6c1;
  --high-ink:    #97302a;

  --radius:      18px;
  --radius-sm:   12px;
  --shadow:      0 1px 2px rgba(34,40,46,.04), 0 8px 24px rgba(34,40,46,.06);
  --shadow-lg:   0 2px 6px rgba(34,40,46,.05), 0 20px 48px rgba(34,40,46,.10);

  --font: "Kanit", "Sarabun", "Leelawadee UI", "Segoe UI", Tahoma, system-ui, sans-serif;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  background-image:
    radial-gradient(1100px 520px at 10% -8%, #dcecf8 0%, transparent 60%),
    radial-gradient(900px 480px at 94% 0%, var(--ci-cream) 0%, transparent 55%);
  background-attachment: fixed;
  line-height: 1.65;
  font-size: 16px;
  font-weight: 300;
  -webkit-font-smoothing: antialiased;
}

b, strong { font-weight: 600; }
h1, h2, h3, h4 { line-height: 1.34; margin: 0; font-weight: 600; letter-spacing: 0; }
p  { margin: 0; }
a  { color: var(--brand); }

/* ---------- layout ---------- */

.shell { max-width: 940px; margin: 0 auto; padding: 0 20px 72px; }
.shell-wide { max-width: 1280px; }

.topbar {
  position: sticky; top: 0; z-index: 50;
  background: rgba(255,255,255,.82);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.topbar-in {
  max-width: 940px; margin: 0 auto; padding: 12px 20px;
  display: flex; align-items: center; gap: 14px;
}
.shell-wide + .topbar-in, .topbar-in.wide { max-width: 1280px; }

.brand { display: flex; align-items: center; gap: 11px; text-decoration: none; color: inherit; min-width: 0; }
.brand-mark {
  width: 38px; height: 38px; border-radius: 11px; flex: none;
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-2) 100%);
  color: #fff; display: grid; place-items: center;
  font-weight: 600; font-size: 13px; letter-spacing: .5px;
  box-shadow: 0 4px 12px rgba(0,112,186,.26);
}
.brand-name { font-weight: 600; font-size: 14.5px; line-height: 1.25; }
.brand-sub   { font-size: 11.5px; color: var(--muted); line-height: 1.25; }

/* โลโก้แบรนด์มุมขวาบน — แสดงทุกหน้า */
.brand-logo { flex: none; display: block; }
.brand-logo img { height: 42px; width: auto; display: block; }

@media (max-width: 720px) {
  .brand-logo img { height: 32px; }
}

.spacer { flex: 1; }

/* ---------- generic cards ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 26px;
}
.card + .card { margin-top: 18px; }
.card-pad-lg { padding: 34px; }

.eyebrow {
  font-size: 12px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase;
  color: var(--brand); margin-bottom: 10px;
}

.lead { color: var(--ink-2); font-size: 15.5px; }
.small { font-size: 13.5px; color: var(--muted); }
.tiny  { font-size: 12.5px; color: var(--muted); }

/* ---------- buttons ---------- */

.btn {
  appearance: none; border: 1px solid transparent; cursor: pointer;
  font-family: inherit; font-size: 15.5px; font-weight: 700;
  padding: 13px 24px; border-radius: 12px;
  display: inline-flex; align-items: center; justify-content: center; gap: 9px;
  transition: transform .12s ease, box-shadow .18s ease, background .18s ease, border-color .18s ease;
  text-decoration: none; line-height: 1.3;
}
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 3px solid rgba(0,112,186,.40); outline-offset: 2px; }

.btn-primary {
  background: linear-gradient(135deg, var(--brand) 0%, #1a80c4 60%, var(--brand-2) 100%);
  color: #fff; box-shadow: 0 6px 18px rgba(0,112,186,.28);
}
.btn-primary:hover { box-shadow: 0 10px 26px rgba(0,112,186,.34); }
.btn-primary[disabled] {
  background: #c4d1da; color: #fff; box-shadow: none; cursor: not-allowed; transform: none;
}

.btn-ghost { background: var(--surface); color: var(--ink-2); border-color: var(--line); }
.btn-ghost:hover { border-color: #c2cfd9; background: var(--surface-2); }

.btn-quiet { background: transparent; color: var(--muted); padding: 10px 14px; font-weight: 600; font-size: 14px; }
.btn-quiet:hover { color: var(--ink); background: var(--surface-2); }

.btn-danger { background: var(--surface); color: #97302a; border-color: #f0c6c1; }
.btn-danger:hover { background: var(--high-soft); }

.btn-lg { padding: 16px 32px; font-size: 16.5px; border-radius: 14px; }
.btn-sm { padding: 9px 16px; font-size: 13.5px; border-radius: 10px; }
.btn-block { width: 100%; }

/* ---------- form fields ---------- */

.field { margin-bottom: 4px; }
.field label.lbl {
  display: block; font-weight: 600; font-size: 14.5px; margin-bottom: 7px; color: var(--ink);
}
.req { color: #e11d48; margin-inline-start: 3px; }
/* คำอธิบายสั้นต่อท้ายป้ายชื่อช่องกรอก */
.lbl-hint { font-weight: 400; font-size: 13px; color: var(--muted); }

.input, select.input {
  width: 100%; font-family: inherit; font-size: 15.5px; color: var(--ink);
  padding: 13px 15px; border-radius: 12px;
  border: 1.5px solid var(--line); background: var(--surface);
  transition: border-color .15s ease, box-shadow .15s ease;
}
.input::placeholder { color: #9fb0be; }
.input:focus {
  outline: none; border-color: var(--brand-2);
  box-shadow: 0 0 0 4px rgba(0,112,186,.15);
}
.input[readonly] { background: var(--surface-2); color: var(--ink-2); }
.input.bad { border-color: #f0a3a3; background: #fffafa; }
.input.bad:focus { box-shadow: 0 0 0 4px rgba(239,68,68,.14); }

select.input {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='9' viewBox='0 0 14 9'%3E%3Cpath d='M1 1l6 6 6-6' stroke='%236b7f93' stroke-width='2' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: left 15px center; padding-left: 40px;
}

.hint { font-size: 12.5px; color: var(--muted); margin-top: 6px; }
.err  { font-size: 12.5px; color: #dc2626; margin-top: 6px; font-weight: 600; display: none; }
.err.on { display: block; }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }

/* segmented control (gender) */
.seg { display: flex; gap: 8px; flex-wrap: wrap; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label {
  flex: 1; min-width: 96px; text-align: center; cursor: pointer;
  padding: 12px 10px; border-radius: 12px; font-size: 15px; font-weight: 600;
  border: 1.5px solid var(--line); background: var(--surface); color: var(--ink-2);
  transition: all .15s ease;
}
.seg label:hover { border-color: #b9cbd8; }
.seg input:checked + label {
  border-color: var(--brand); background: var(--brand-soft); color: var(--brand-ink);
  box-shadow: inset 0 0 0 1px var(--brand);
}
.seg input:focus-visible + label { outline: 3px solid rgba(0,112,186,.40); outline-offset: 2px; }

/* ---------- consent ---------- */

.consent {
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 18px 18px 14px;
}
/* เดิมมีหัวข้อกำกับคั่นระหว่างกลุ่ม เมื่อเอาออกแล้วต้องเว้นระยะเอง */
.consent + .consent { margin-top: 12px; }
.check { display: flex; gap: 12px; align-items: flex-start; cursor: pointer; padding: 8px 0; }
.check input { margin: 3px 0 0; width: 20px; height: 20px; flex: none; accent-color: var(--brand); cursor: pointer; }
.check span { font-size: 14.5px; color: var(--ink-2); }
.check b { color: var(--ink); font-weight: 600; }

/* ---------- progress ---------- */

.progress-wrap { padding: 0 20px; max-width: 940px; margin: 0 auto 6px; }
.progress-meta {
  display: flex; justify-content: space-between; align-items: baseline;
  font-size: 12.5px; color: var(--muted); margin-bottom: 6px; font-weight: 600;
}
.progress {
  height: 8px; background: #dfe8ef; border-radius: 99px; overflow: hidden;
}
.progress > i {
  display: block; height: 100%; width: 0;
  background: linear-gradient(90deg, var(--brand) 0%, var(--brand-2) 100%);
  border-radius: 99px; transition: width .4s cubic-bezier(.4,0,.2,1);
}

.steps { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.step-dot {
  font-size: 11.5px; font-weight: 700; color: var(--muted);
  padding: 5px 11px; border-radius: 99px; background: #e6edf3; white-space: nowrap;
}
.step-dot.on   { background: var(--brand); color: #fff; }
.step-dot.done { background: var(--brand-soft); color: var(--brand-ink); }

/* ---------- question cards ---------- */

.qcard { padding: 24px 26px; }
.qcard + .qcard { margin-top: 14px; }
.qhead { display: flex; gap: 13px; align-items: flex-start; margin-bottom: 16px; }
.qnum {
  flex: none; width: 30px; height: 30px; border-radius: 9px;
  background: var(--brand-soft); color: var(--brand-ink);
  display: grid; place-items: center; font-weight: 700; font-size: 13.5px; margin-top: 2px;
}
.qtext { font-size: 16.5px; font-weight: 600; color: var(--ink); }

.opts { display: grid; gap: 9px; }
.opt input { position: absolute; opacity: 0; pointer-events: none; }
.opt label {
  display: flex; gap: 13px; align-items: flex-start; cursor: pointer;
  padding: 13px 15px; border-radius: 13px;
  border: 1.5px solid var(--line); background: var(--surface);
  transition: border-color .14s ease, background .14s ease, box-shadow .14s ease;
  font-size: 15px; color: var(--ink-2);
}
.opt label:hover { border-color: #b9cbd8; background: var(--surface-2); }
.opt-no {
  display: inline-block; min-width: 20px; color: var(--brand);
  font-weight: 600; opacity: .8;
}
.opt input:checked + label .opt-no { opacity: 1; }

.opt-mark {
  flex: none; width: 22px; height: 22px; border-radius: 50%;
  border: 2px solid #c2cfd9; background: #fff; margin-top: 1px;
  display: grid; place-items: center; transition: all .14s ease;
}
.opt-mark::after {
  content: ""; width: 9px; height: 9px; border-radius: 50%; background: #fff; transform: scale(0);
  transition: transform .16s cubic-bezier(.34,1.56,.64,1);
}
.opt input:checked + label {
  border-color: var(--brand); background: var(--brand-soft); color: var(--brand-ink); font-weight: 600;
  box-shadow: inset 0 0 0 1px var(--brand);
}
.opt input:checked + label .opt-mark { border-color: var(--brand); background: var(--brand); }
.opt input:checked + label .opt-mark::after { transform: scale(1); }
.opt input:focus-visible + label { outline: 3px solid rgba(0,112,186,.40); outline-offset: 2px; }

.qcard.missing { border-color: #f0a3a3; box-shadow: 0 0 0 4px rgba(239,68,68,.08); }

/* ---------- nav bar ---------- */

.navbar {
  position: sticky; bottom: 0; z-index: 40; margin-top: 22px;
  background: rgba(255,255,255,.9);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--line); border-radius: 16px;
  padding: 12px 14px; display: flex; gap: 12px; align-items: center;
  box-shadow: var(--shadow-lg);
}

/* ---------- badges / pills ---------- */

.pill {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 6px 13px; border-radius: 99px; font-size: 13px; font-weight: 700;
  background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--line);
}
.pill.low  { background: var(--low-soft);  color: #4b7233; border-color: #cfe2bf; }
.pill.mid  { background: var(--mid-soft);  color: #92601a; border-color: #eeddba; }
.pill.high { background: var(--high-soft); color: #97302a; border-color: #f0c6c1; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; flex: none; }

/* ---------- notice ---------- */

.notice {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 14px 16px; border-radius: var(--radius-sm);
  background: var(--mid-soft); border: 1px solid #eeddba; color: #6e6043;
  font-size: 13.8px; line-height: 1.55;
}
.notice.info  { background: #eef4fd; border-color: #cfe0f7; color: #1e4b8f; }
.notice.brand { background: var(--brand-soft); border-color: #b7e5df; color: var(--brand-ink); }
.notice svg { flex: none; margin-top: 2px; }

/* ---------- modal ---------- */

dialog.modal {
  border: none; border-radius: 20px; padding: 0; max-width: 720px; width: calc(100% - 32px);
  box-shadow: 0 30px 80px rgba(34,40,46,.30); color: var(--ink); background: var(--surface);
}
dialog.modal-wide { max-width: 860px; }

/* เนื้อหานโยบายความเป็นส่วนตัว */
.pdpa-body h4 {
  font-size: 15.5px; margin: 26px 0 8px; color: var(--brand-ink);
  padding-bottom: 6px; border-bottom: 2px solid var(--brand-soft);
}
.pdpa-body h4:first-of-type { margin-top: 0; }
.pdpa-body h5 { font-size: 14.5px; margin: 16px 0 6px; color: var(--ink); font-weight: 600; }
.pdpa-body p { margin: 8px 0; }
.pdpa-body .lead { font-size: 14.5px; }
dialog.modal::backdrop { background: rgba(13,27,42,.55); backdrop-filter: blur(3px); }
.modal-head {
  padding: 22px 26px 16px; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 12px; position: sticky; top: 0; background: var(--surface);
  border-radius: 20px 20px 0 0;
}
.modal-body { padding: 22px 26px; max-height: 62vh; overflow: auto; font-size: 14.5px; color: var(--ink-2); }
.modal-body h4 { font-size: 15px; margin: 20px 0 6px; color: var(--ink); }
.modal-body h4:first-child { margin-top: 0; }
.modal-body ul { margin: 6px 0; padding-inline-start: 22px; }
.modal-body li { margin: 4px 0; }
.modal-foot { padding: 16px 26px 22px; display: flex; justify-content: flex-end; gap: 10px; }

/* ---------- footer ---------- */

.foot {
  text-align: center; padding: 32px 20px 12px; font-size: 12.5px;
  color: var(--muted); line-height: 1.9;
}
.foot a { color: var(--brand); text-decoration: none; }
.foot a:hover { text-decoration: underline; }
.foot .copy { display: block; }

/* หมายเหตุข้อจำกัดของผล — ต้องแสดงทุกหน้า */
.medical-note {
  max-width: 720px; margin: 20px auto 0; padding: 13px 16px;
  border-radius: var(--radius-sm); text-align: center;
  background: var(--surface-warm); border: 1px solid var(--ci-sand);
  color: var(--ci-brown); font-size: 13px; line-height: 1.7;
}
.medical-note b { color: var(--ci-brown); }

/* ---------- แถบคุกกี้ ---------- */

.cookie-bar {
  position: fixed; inset: auto 0 0 0; z-index: 90;
  background: var(--surface); border-top: 3px solid var(--brand);
  box-shadow: 0 -8px 30px rgba(34,40,46,.14);
  padding: 20px 22px calc(20px + env(safe-area-inset-bottom));
  animation: cookieUp .35s cubic-bezier(.4,0,.2,1);
}
@keyframes cookieUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
.cookie-in { max-width: 1080px; margin: 0 auto; display: flex; gap: 22px; align-items: center; flex-wrap: wrap; }
.cookie-text { flex: 1 1 420px; min-width: 0; }
.cookie-text h3 { font-size: 16px; margin-bottom: 6px; }
.cookie-text p { font-size: 13.2px; color: var(--ink-2); line-height: 1.65; }
.cookie-actions { display: flex; gap: 9px; flex-wrap: wrap; flex: 0 0 auto; }

/* ---------- ตั้งค่าคุกกี้ ---------- */

.ck-group {
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 16px 18px; margin-bottom: 12px; background: var(--surface-2);
}
.ck-head { display: flex; align-items: center; gap: 12px; justify-content: space-between; }
.ck-title { font-weight: 600; font-size: 15px; }
.ck-always {
  font-size: 12px; font-weight: 600; color: var(--low-ink);
  background: var(--low-soft); border: 1px solid var(--low-line);
  padding: 4px 11px; border-radius: 99px; white-space: nowrap;
}
.ck-desc { font-size: 13px; color: var(--ink-2); margin-top: 8px; line-height: 1.65; }
.ck-desc + .ck-desc { margin-top: 6px; color: var(--muted); font-size: 12.5px; }
.ck-default { font-size: 12px; color: var(--muted); margin-top: 6px; }

/* สวิตช์เปิด/ปิด */
.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; margin-top: 10px; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch i {
  width: 46px; height: 26px; border-radius: 99px; background: #c9d2da;
  position: relative; transition: background .2s ease; flex: none;
}
.switch i::after {
  content: ""; position: absolute; top: 3px; inset-inline-start: 3px;
  width: 20px; height: 20px; border-radius: 50%; background: #fff;
  transition: transform .2s cubic-bezier(.4,0,.2,1);
  box-shadow: 0 1px 3px rgba(0,0,0,.25);
}
.switch input:checked + i { background: var(--brand); }
.switch input:checked + i::after { transform: translateX(20px); }
.switch:dir(rtl) input:checked + i::after { transform: translateX(-20px); }
.switch input:focus-visible + i { outline: 3px solid rgba(0,112,186,.4); outline-offset: 2px; }
.switch span { font-size: 14px; font-weight: 500; color: var(--ink); }

/* ---------- กลุ่มความยินยอม ---------- */

.consent-block { margin-top: 20px; }
.consent-legend {
  font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase;
  color: var(--brand); margin: 18px 0 8px; display: flex; align-items: center; gap: 9px;
}
.consent-legend::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.consent-legend.optional { color: var(--muted); }
.consent-note { font-size: 12.5px; color: var(--muted); margin-bottom: 8px; }
.check .sub {
  display: block; font-size: 12.5px; color: var(--muted); margin-top: 4px; line-height: 1.6;
}

/* ---------- utility ---------- */

.hide { display: none !important; }
.block { display: block; }
.center { text-align: center; }
.mt4{margin-top:4px}.mt8{margin-top:8px}.mt12{margin-top:12px}.mt16{margin-top:16px}.mt20{margin-top:20px}
.mt24{margin-top:24px}.mt32{margin-top:32px}
.mb8{margin-bottom:8px}.mb12{margin-bottom:12px}.mb16{margin-bottom:16px}
.mb20{margin-bottom:20px}.mb24{margin-bottom:24px}
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

@media (max-width: 720px) {
  .grid2, .grid3 { grid-template-columns: 1fr; }
  .card { padding: 20px; }
  .card-pad-lg { padding: 24px 20px; }
  .shell { padding: 0 14px 60px; }
  .topbar-in, .progress-wrap { padding-inline: 14px; }
  .brand-sub { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
