/* ==========================================================================
   Association Hypnose Humanitaire — Questionnaire HNI
   Design system matched to hypnosehumanitaire.org
   Navy + light-blue palette · DM Serif Display / DM Sans · iOS-app feel
   ========================================================================== */

:root {
  /* Brand palette (from hypnosehumanitaire.org) */
  --navy:        #002D62;
  --navy-deep:   #001A3A;
  --navy-soft:   #1A4A8A;
  --blue:        #8EA8C4;
  --blue-strong: #4E7CB5;

  /* Neutrals */
  --bg:          #F5F7FA;
  --bg-accent:   #EAF0F7;
  --card:        #FFFFFF;
  --ink:         #0F1E33;
  --text:        #3C4A5E;
  --muted:       #6B7A8F;
  --border:      #E1E8F1;
  --tint:        #EAF1FA;   /* selected fill */

  /* Semantic */
  --success:     #1F7A5A;
  --success-bg:  #E7F4EE;
  --warn:        #B7791F;
  --warn-bg:     #FBF3E2;
  --danger:      #C0453F;
  --danger-bg:   #FBECEB;

  /* Shape & motion */
  --r-lg: 22px;
  --r-md: 16px;
  --r-sm: 13px;
  --r-pill: 999px;
  --shadow-sm: 0 1px 2px rgba(15, 30, 51, .05);
  --shadow-md: 0 1px 2px rgba(15, 30, 51, .04), 0 10px 30px -14px rgba(15, 30, 51, .18);
  --shadow-lg: 0 2px 4px rgba(15, 30, 51, .05), 0 24px 48px -20px rgba(15, 30, 51, .30);
  --ease: cubic-bezier(.2, .7, .2, 1);

  /* Typography */
  --font-sans:  'DM Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-serif: 'DM Serif Display', Georgia, 'Times New Roman', serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

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

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  /* Subtle brand wash from the top */
  background-image:
    radial-gradient(120% 60% at 50% -10%, rgba(0, 45, 98, .06), transparent 60%);
}

/* Layout ------------------------------------------------------------------ */
.app {
  max-width: 640px;
  margin: 0 auto;
  padding: 18px 16px calc(24px + env(safe-area-inset-bottom));
}

/* Hero header ------------------------------------------------------------- */
.hero {
  position: relative;
  overflow: hidden;
  background: linear-gradient(155deg, var(--navy) 0%, var(--navy-deep) 100%);
  color: #fff;
  border-radius: var(--r-lg);
  padding: 26px 24px 28px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-md);
}
.hero::after {
  /* soft light-blue glow, echoing the site hero */
  content: "";
  position: absolute;
  top: -60px; right: -50px;
  width: 220px; height: 220px;
  background: radial-gradient(circle, rgba(142, 168, 196, .35), transparent 70%);
  pointer-events: none;
}
.hero-emblem {
  width: 70px; height: 70px;
  margin-bottom: 18px;
  padding: 9px;
  background: #fff;
  border-radius: 18px;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 8px 20px -10px rgba(0, 0, 0, .5);
}
.hero-emblem img { width: 100%; height: 100%; object-fit: contain; display: block; }
.hero-eyebrow {
  font-size: 11px;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--blue);
  font-weight: 500;
  margin-bottom: 10px;
}
.hero-title {
  font-family: var(--font-serif);
  font-weight: 400;
  font-size: clamp(26px, 7vw, 34px);
  line-height: 1.12;
  letter-spacing: -.01em;
}
.hero-title .accent {
  font-style: italic;
  color: var(--blue);
}
.hero-sub {
  margin-top: 10px;
  font-size: 14px;
  color: rgba(255, 255, 255, .72);
  line-height: 1.5;
}

/* Progress ---------------------------------------------------------------- */
.progress {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 16px;
  margin-bottom: 14px;
  box-shadow: var(--shadow-sm);
}
.progress-top {
  display: flex; justify-content: space-between; align-items: baseline;
  font-size: 13px; color: var(--muted); margin-bottom: 10px;
}
.progress-top .pct { color: var(--navy); font-weight: 600; font-variant-numeric: tabular-nums; font-size: 12px; }
.track {
  height: 8px; background: var(--bg-accent);
  border-radius: var(--r-pill); overflow: hidden;
}
.fill {
  height: 100%;
  background: linear-gradient(90deg, var(--navy-soft), var(--navy));
  border-radius: var(--r-pill);
  transition: width .5s var(--ease);
}
.steps { display: flex; gap: 7px; margin-top: 14px; }
.step {
  flex: 1;
  height: 34px;
  min-width: 0;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  background: var(--card);
  color: var(--muted);
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  transition: all .2s var(--ease);
  display: flex; align-items: center; justify-content: center;
}
.step:active { transform: scale(.94); }
.step.done { background: var(--navy); border-color: var(--navy); color: #fff; }
.step.active {
  border-color: var(--navy);
  color: var(--navy);
  background: var(--tint);
  box-shadow: 0 0 0 3px rgba(0, 45, 98, .10);
}

/* Banners ----------------------------------------------------------------- */
.banner {
  border-radius: var(--r-md);
  padding: 12px 14px;
  margin-bottom: 14px;
  font-size: 13.5px;
  line-height: 1.5;
  display: flex; align-items: flex-start; gap: 10px;
  border: 1px solid transparent;
}
.banner-icon { flex-shrink: 0; font-size: 16px; line-height: 1.4; }
.banner-info   { background: var(--bg-accent);  border-color: #D3E0F0; color: var(--navy); }
.banner-amber  { background: var(--warn-bg);     border-color: #F0DCB0; color: #6B4E12; }
.banner-green  { background: var(--success-bg);  border-color: #BFE3D2; color: #1B5E43; }
.banner-red    { background: var(--danger-bg);   border-color: #F1C9C6; color: #8A2C27; }

/* Section card ------------------------------------------------------------ */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 22px 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-md);
}
.card-head {
  display: flex; align-items: center; gap: 14px;
  padding-bottom: 18px; margin-bottom: 20px;
  border-bottom: 1px solid var(--border);
}
.card-icon {
  width: 46px; height: 46px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  background: var(--bg-accent);
  border-radius: 13px;
}
.card-title {
  font-family: var(--font-serif);
  font-weight: 400;
  font-size: 22px;
  color: var(--navy);
  line-height: 1.15;
}
.card-badge {
  display: inline-block;
  margin-top: 5px;
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
}

/* Question block ---------------------------------------------------------- */
.q { margin-bottom: 24px; scroll-margin-top: 20px; }
.q:last-child { margin-bottom: 4px; }
.q-label {
  font-size: 15.5px;
  font-weight: 500;
  color: var(--ink);
  line-height: 1.45;
  margin-bottom: 12px;
}
.q-sub { font-size: 13px; color: var(--muted); margin: -6px 0 12px; }
.q-required { color: var(--danger); margin-left: 3px; }

.q.invalid { animation: shake .35s var(--ease); }
.q.invalid .q-label { color: var(--danger); }
.q.invalid .opt, .q.invalid .field, .q.invalid .seg, .q.invalid .scale-btn {
  border-color: #E6A9A5;
}
@keyframes shake {
  0%,100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}

/* Info callout */
.info-note {
  background: var(--bg-accent);
  border: 1px solid #DCE6F3;
  border-left: 3px solid var(--navy);
  border-radius: var(--r-sm);
  padding: 14px 16px;
  margin-bottom: 22px;
  font-size: 13.5px;
  color: var(--navy);
  line-height: 1.6;
}
.info-note strong { font-weight: 600; }
.info-note em { color: var(--blue-strong); font-style: normal; }

/* Options (radio / checkbox) --------------------------------------------- */
.options {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 10px;
}
.options.single { grid-template-columns: 1fr; }

.opt {
  position: relative;
  display: flex; align-items: center; gap: 13px;
  min-height: 54px;
  padding: 12px 16px;
  border: 1.5px solid var(--border);
  border-radius: 14px;
  background: var(--card);
  font-size: 14.5px;
  color: var(--text);
  cursor: pointer;
  transition: border-color .18s var(--ease), background .18s var(--ease), transform .1s var(--ease);
  -webkit-tap-highlight-color: transparent;
}
.opt input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}
.opt span { flex: 1; line-height: 1.4; }
.opt:active { transform: scale(.985); }
@media (hover: hover) {
  .opt:hover { border-color: var(--blue); }
}

/* Custom control drawn as the leading flex item */
.opt::before {
  content: "";
  flex-shrink: 0;
  width: 22px; height: 22px;
  border: 2px solid #C3CEDD;
  background: #fff;
  transition: all .18s var(--ease);
}
.opt--radio::before { border-radius: 50%; }
.opt--check::before { border-radius: 7px; }

.opt:has(input:checked) {
  border-color: var(--navy);
  background: var(--tint);
  color: var(--ink);
  font-weight: 500;
}
.opt--radio:has(input:checked)::before {
  border-color: var(--navy);
  background: var(--navy);
  box-shadow: inset 0 0 0 4px #fff;
}
.opt--check:has(input:checked)::before {
  border-color: var(--navy);
  background: var(--navy);
}
.opt--check:has(input:checked)::after {
  content: "";
  position: absolute;
  left: 22px;
  width: 6px; height: 11px;
  border: 2.5px solid #fff;
  border-top: 0; border-left: 0;
  transform: rotate(45deg);
  top: 50%;
  margin-top: -8px;
}

/* "Other" free-text reveal */
.other-wrap { margin-top: 10px; display: none; }
.other-wrap.visible { display: block; }

/* Scale (0–10) — segmented pills ----------------------------------------- */
.scale-row {
  display: grid;
  grid-template-columns: repeat(11, 1fr);
  gap: 6px;
}
.scale-btn {
  height: 46px;
  border: 1.5px solid var(--border);
  border-radius: 11px;
  background: var(--card);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all .16s var(--ease);
  -webkit-tap-highlight-color: transparent;
  padding: 0;
}
.scale-btn:active { transform: scale(.9); }
@media (hover: hover) { .scale-btn:hover { border-color: var(--blue); } }
.scale-btn.selected {
  background: var(--navy);
  color: #fff;
  border-color: var(--navy);
  box-shadow: 0 4px 12px -4px rgba(0, 45, 98, .5);
}
.scale-labels {
  display: flex; justify-content: space-between;
  font-size: 11.5px; color: var(--muted); margin-top: 8px;
}
@media (max-width: 420px) {
  .scale-row { grid-template-columns: repeat(6, 1fr); }
  .scale-btn { height: 42px; }
}

/* Segmented control (matrix rows) ---------------------------------------- */
.matrix-row {
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #FBFCFE;
  margin-bottom: 10px;
}
.matrix-row-label {
  font-size: 14px; font-weight: 500; color: var(--ink);
  margin-bottom: 10px;
}
.segmented { display: flex; flex-wrap: wrap; gap: 6px; }
.seg {
  position: relative;
  flex: 1 1 auto;
  min-width: 62px;
  text-align: center;
  padding: 9px 8px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  background: var(--card);
  font-size: 12.5px;
  color: var(--muted);
  cursor: pointer;
  transition: all .16s var(--ease);
  -webkit-tap-highlight-color: transparent;
}
.seg input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}
.seg span { line-height: 1.2; }
.seg:active { transform: scale(.95); }
@media (hover: hover) { .seg:hover { border-color: var(--blue); } }
.seg:has(input:checked) {
  background: var(--navy);
  border-color: var(--navy);
  color: #fff;
  font-weight: 600;
}

/* Text fields ------------------------------------------------------------- */
.field {
  width: 100%;
  border: 1.5px solid var(--border);
  border-radius: 13px;
  padding: 13px 15px;
  font-size: 16px; /* >=16px prevents iOS zoom on focus */
  font-family: var(--font-sans);
  background: #FBFCFE;
  color: var(--ink);
  transition: border-color .18s var(--ease), box-shadow .18s var(--ease);
  -webkit-appearance: none;
  appearance: none;
}
.field::placeholder { color: #A6B2C2; }
.field:focus {
  outline: none;
  border-color: var(--navy);
  background: #fff;
  box-shadow: 0 0 0 4px rgba(0, 45, 98, .10);
}
textarea.field { min-height: 96px; resize: vertical; line-height: 1.55; }
input[type="date"].field { min-height: 50px; }

/* Buttons ----------------------------------------------------------------- */
.btn {
  appearance: none;
  border: none;
  font-family: var(--font-sans);
  font-size: 15.5px;
  font-weight: 600;
  border-radius: 14px;
  padding: 15px 20px;
  cursor: pointer;
  transition: transform .12s var(--ease), background .18s var(--ease), box-shadow .18s var(--ease);
  -webkit-tap-highlight-color: transparent;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn-primary {
  background: var(--navy); color: #fff;
  box-shadow: 0 8px 20px -8px rgba(0, 45, 98, .6);
}
@media (hover: hover) { .btn-primary:hover { background: var(--navy-deep); } }
.btn-ghost {
  background: var(--card); color: var(--navy);
  border: 1.5px solid var(--border);
}
@media (hover: hover) { .btn-ghost:hover { border-color: var(--blue); } }
.btn-success {
  background: var(--success); color: #fff;
  box-shadow: 0 8px 20px -8px rgba(31, 122, 90, .6);
}
.btn-block { width: 100%; }

/* Secondary actions (save / backup / reset) */
.secondary-actions {
  display: flex; flex-direction: column; gap: 10px;
  margin-top: 4px;
  scroll-margin-bottom: calc(100px + env(safe-area-inset-bottom));
}
.link-btn {
  background: none; border: none;
  color: var(--muted);
  font-family: var(--font-sans);
  font-size: 13.5px;
  cursor: pointer;
  padding: 8px;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.link-btn:hover { color: var(--navy); }
.link-btn--inline {
  display: inline;
  padding: 0;
  font-size: inherit;
  font-weight: 600;
  color: inherit;
  text-decoration: underline;
}

/* Offline / print / email options */
.offline-tip { margin-top: 0; }
.offline-options {
  background: var(--bg-accent);
  border: 1px solid #D6E1F0;
  border-radius: var(--r-md);
  padding: 16px 18px;
  margin-top: 4px;
  scroll-margin-bottom: calc(100px + env(safe-area-inset-bottom));
}
.offline-options h3 {
  font-size: 14px;
  color: var(--navy);
  font-weight: 600;
  margin-bottom: 6px;
}
.offline-intro, .offline-foot {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.5;
}
.offline-list {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.55;
  margin: 10px 0 14px;
  padding-left: 18px;
}
.offline-list li { margin-bottom: 6px; }
.offline-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}
@media (min-width: 480px) {
  .offline-actions { grid-template-columns: 1fr 1fr; }
}
.btn-offline {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  padding: 12px 14px;
  background: var(--card);
  color: var(--navy);
  border: 1.5px solid #CBD8E8;
  border-radius: 12px;
  font-family: var(--font-sans);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  line-height: 1.3;
}
.btn-offline:active { transform: scale(.98); }
.offline-foot { margin-top: 14px; margin-bottom: 0; }

/* Backup card (legacy) */
.backup {
  background: var(--bg-accent);
  border: 1px solid #D6E1F0;
  border-radius: var(--r-md);
  padding: 16px 18px;
  margin-top: 4px;
  scroll-margin-bottom: calc(100px + env(safe-area-inset-bottom));
}
.backup h3 { font-size: 14px; color: var(--navy); font-weight: 600; margin-bottom: 5px; }
.backup p { font-size: 13px; color: var(--muted); line-height: 1.5; }
.backup .btn-dl {
  display: inline-block; margin-top: 12px;
  padding: 11px 18px;
  background: var(--card); color: var(--navy);
  border: 1.5px solid #CBD8E8; border-radius: 12px;
  font-size: 13.5px; font-weight: 600;
  text-decoration: none; cursor: pointer;
}
.btn-dl:active { transform: scale(.97); }

/* Privacy + submit error */
.privacy {
  font-size: 12.5px; color: var(--muted);
  margin-top: 20px; padding: 14px 16px;
  background: var(--bg-accent);
  border-radius: var(--r-sm); line-height: 1.55;
}
.submit-error {
  background: var(--danger-bg); border: 1px solid #F1C9C6;
  border-radius: var(--r-md); padding: 16px;
  margin-bottom: 14px; font-size: 14px; color: #8A2C27; line-height: 1.5;
}
.submit-error strong { display: block; margin-bottom: 4px; }

/* Send status (config screen legacy) */
.send-status {
  margin-top: 10px; font-size: 13px; padding: 10px 14px;
  border-radius: var(--r-sm); display: none;
}
.send-status.sending { display: block; background: var(--warn-bg); color: #6B4E12; }
.send-status.success { display: block; background: var(--success-bg); color: #1B5E43; }
.send-status.error   { display: block; background: var(--danger-bg); color: #8A2C27; }

/* Sticky bottom navigation ----------------------------------------------- */
.bottom-spacer {
  height: calc(88px + env(safe-area-inset-bottom));
  pointer-events: none;
}
.bottombar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 40;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: rgba(245, 247, 250, .82);
  -webkit-backdrop-filter: saturate(180%) blur(18px);
  backdrop-filter: saturate(180%) blur(18px);
  border-top: 1px solid var(--border);
}
.bottombar-inner {
  max-width: 640px; margin: 0 auto;
  display: flex; gap: 10px; align-items: stretch;
}
.bottombar .btn-primary, .bottombar .btn-success { flex: 1; }
.bottombar .btn-ghost { flex: 0 0 auto; min-width: 56px; padding: 15px 18px; }

/* Completion screen ------------------------------------------------------- */
.complete {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 44px 26px 34px;
  text-align: center;
  box-shadow: var(--shadow-md);
}
.complete-badge {
  width: 76px; height: 76px; margin: 0 auto 22px;
  border-radius: 50%;
  background: var(--success-bg);
  display: flex; align-items: center; justify-content: center;
}
.complete-badge svg { width: 38px; height: 38px; }
.complete h2 {
  font-family: var(--font-serif); font-weight: 400;
  font-size: 27px; color: var(--navy); margin-bottom: 10px; line-height: 1.2;
}
.complete > p { color: var(--muted); font-size: 15px; max-width: 30ch; margin: 0 auto; }

/* Footer ------------------------------------------------------------------ */
.footer {
  text-align: center; font-size: 12.5px; color: var(--muted);
  margin-top: 26px; padding: 8px 0 12px; line-height: 1.9;
  scroll-margin-bottom: calc(100px + env(safe-area-inset-bottom));
}
.footer a { color: var(--navy); text-decoration: none; font-weight: 500; }
.footer a:hover { text-decoration: underline; }
.footer .sep { opacity: .4; margin: 0 4px; }

/* Confirmation modal ------------------------------------------------------ */
.btn-danger {
  background: var(--danger); color: #fff;
  box-shadow: 0 8px 20px -8px rgba(192, 69, 63, .55);
}
@media (hover: hover) { .btn-danger:hover { background: #A6382F; } }

.modal-overlay {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: center; justify-content: center;
  padding: 24px calc(24px + env(safe-area-inset-right)) calc(24px + env(safe-area-inset-bottom)) calc(24px + env(safe-area-inset-left));
  background: rgba(0, 26, 58, .48);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  opacity: 0;
  transition: opacity .22s var(--ease);
}
.modal-overlay.open { opacity: 1; }
.modal {
  width: 100%; max-width: 380px;
  background: var(--card);
  border-radius: 24px;
  padding: 28px 26px 22px;
  box-shadow: var(--shadow-lg);
  text-align: center;
  transform: translateY(14px) scale(.95);
  opacity: 0;
  transition: transform .28s var(--ease), opacity .28s var(--ease);
}
.modal-overlay.open .modal { transform: none; opacity: 1; }
.modal-icon {
  width: 62px; height: 62px; margin: 0 auto 18px;
  border-radius: 50%;
  background: var(--danger-bg);
  display: flex; align-items: center; justify-content: center;
}
.modal-icon svg { width: 30px; height: 30px; }
.modal h3 {
  font-family: var(--font-serif); font-weight: 400;
  font-size: 23px; color: var(--navy); margin-bottom: 9px; line-height: 1.2;
}
.modal p { font-size: 14.5px; color: var(--muted); line-height: 1.55; margin-bottom: 24px; }
.modal-actions { display: flex; gap: 10px; }
.modal-actions .btn { flex: 1; }
@media (max-width: 380px) {
  .modal-actions { flex-direction: column-reverse; }
}

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