/* HKAOA survey — design system (mobile-first, vanilla CSS, self-hosted).
   Calm, trustworthy, data-collection tone. Brand applied lightly.
   Rules from ui-ux-pro-max: accessibility, touch, layout, type, motion, forms. */

:root {
  /* Brand */
  --blue: #1B3F8B;
  --blue-600: #163470;
  --blue-700: #112a5c;
  --blue-050: #eef2fb;   /* selected tint */
  --blue-100: #dbe4f6;
  --red: #CC0000;
  --red-050: #fdf2f2;

  /* Neutrals */
  --ink: #171a21;
  --ink-2: #3c4351;
  --muted: #5b6472;
  --line: #e3e7ee;
  --line-2: #eef1f6;
  --surface: #ffffff;
  --bg: #f4f6fa;

  /* Type scale */
  --t-xs: .8125rem;   /* 13 */
  --t-sm: .9375rem;   /* 15 */
  --t-base: 1.0625rem;/* 17 */
  --t-lg: 1.25rem;    /* 20 */
  --t-xl: 1.625rem;   /* 26 */
  --t-2xl: 2.125rem;  /* 34 */

  /* Spacing (8pt) */
  --s-1: 4px; --s-2: 8px; --s-3: 12px; --s-4: 16px; --s-5: 24px; --s-6: 32px; --s-7: 48px;

  --r-sm: 8px; --r-md: 12px; --r-lg: 16px; --r-pill: 999px;
  --tap: 48px;

  --shadow-sm: 0 1px 2px rgba(19, 30, 60, .05);
  --shadow-md: 0 1px 3px rgba(19, 30, 60, .06), 0 8px 28px rgba(19, 30, 60, .07);
  --ring: 0 0 0 3px rgba(27, 63, 139, .28);
  --ease: cubic-bezier(.22, .61, .36, 1);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: var(--t-base);
  line-height: 1.6;
  color: var(--ink);
  background:
    radial-gradient(1200px 500px at 50% -280px, #eaf0fb 0%, rgba(234,240,251,0) 70%),
    var(--bg);
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* Header + footer */
.site-header { display: flex; justify-content: center; padding: calc(var(--s-4) + env(safe-area-inset-top)) var(--s-4) 0; }
/* The official logo PNG carries generous transparent margins; display larger so
   the visible mark reads at the intended size. Artwork itself is unaltered. */
.site-header .logo { height: 84px; width: auto; margin: -10px 0; }
.site-footer {
  text-align: center; color: var(--muted); font-size: var(--t-xs);
  padding: var(--s-4) var(--s-4) calc(var(--s-6) + env(safe-area-inset-bottom));
  display: flex; align-items: center; justify-content: center; gap: 6px;
}
.site-footer .lock { color: var(--blue); }

/* Layout */
.wrap { flex: 1; width: 100%; padding: 0 var(--s-4); }
main.card, .card {
  width: 100%; max-width: 600px; margin: var(--s-3) auto var(--s-5);
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); box-shadow: var(--shadow-md);
  padding: var(--s-6) var(--s-5);
}

/* Screen enter animation (each render replaces #app content) */
@media (prefers-reduced-motion: no-preference) {
  #app > div { animation: rise .22s var(--ease) both; }
  @keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
}

/* Typography */
h1 { font-size: var(--t-xl); line-height: 1.2; letter-spacing: -.01em; color: var(--blue); margin: 0 0 var(--s-4); }
h2 { font-size: var(--t-lg); line-height: 1.25; margin: 0 0 var(--s-2); color: var(--ink); }
p { margin: 0 0 var(--s-4); }
p:last-child { margin-bottom: 0; }
.muted { color: var(--muted); font-size: var(--t-sm); }
a { color: var(--blue); }

/* Progress */
.progress { height: 6px; border-radius: var(--r-pill); background: var(--line); overflow: hidden; margin-bottom: var(--s-2); }
.progress > .fill { height: 100%; border-radius: var(--r-pill); background: linear-gradient(90deg, var(--blue), #3a63bd); transition: width .3s var(--ease); }
.step-count { margin: 0 0 var(--s-1); font-size: var(--t-xs); color: var(--muted); font-variant-numeric: tabular-nums; }
.section-label {
  font-size: var(--t-xs); text-transform: uppercase; letter-spacing: .06em;
  color: var(--blue); font-weight: 700; margin: 0 0 var(--s-4);
}

/* Questions */
fieldset { border: 0; margin: 0; padding: 0; }
legend { font-weight: 650; margin-bottom: var(--s-3); padding: 0; font-size: var(--t-lg); line-height: 1.3; color: var(--ink); }

.option {
  display: flex; align-items: center; gap: var(--s-3);
  min-height: 52px; padding: var(--s-2) var(--s-4); margin-bottom: var(--s-2);
  border: 1.5px solid var(--line); border-radius: var(--r-md); background: var(--surface);
  cursor: pointer; touch-action: manipulation;
  transition: border-color .14s var(--ease), background .14s var(--ease), transform .06s var(--ease), box-shadow .14s var(--ease);
}
.option:hover { border-color: #b7c2d8; }
.option:active { transform: scale(.99); }
.option:focus-within { outline: none; box-shadow: var(--ring); border-color: var(--blue); }
.option:has(input:checked) { border-color: var(--blue); background: var(--blue-050); box-shadow: inset 0 0 0 1px var(--blue); }
.option input { width: 22px; height: 22px; accent-color: var(--blue); flex: none; margin: 0; }
.option span { flex: 1; }

/* Matrix — stacked groups on mobile */
.matrix-row { margin-bottom: var(--s-5); }
.matrix-row:last-child { margin-bottom: 0; }
.matrix-row > .row-label { font-weight: 600; margin-bottom: var(--s-2); font-size: var(--t-base); }

/* Inputs */
textarea, input[type="text"], input[type="tel"] {
  width: 100%; min-height: var(--tap); padding: 13px var(--s-4);
  font-size: var(--t-base); font-family: inherit; color: var(--ink);
  border: 1.5px solid var(--line); border-radius: var(--r-md); background: var(--surface);
  transition: border-color .14s var(--ease), box-shadow .14s var(--ease);
}
textarea { min-height: 132px; resize: vertical; line-height: 1.55; }
textarea:focus, input:focus { outline: none; border-color: var(--blue); box-shadow: var(--ring); }
input#mailbox { max-width: 220px; font-size: var(--t-lg); letter-spacing: .04em; font-variant-numeric: tabular-nums; }

.charcount { text-align: right; margin-top: var(--s-2); font-variant-numeric: tabular-nums; }
.warn {
  color: #9a1414; font-weight: 600; font-size: var(--t-sm);
  background: var(--red-050); border: 1px solid #f1c9c9; border-left: 3px solid var(--red);
  padding: 10px 12px; border-radius: var(--r-sm); margin-bottom: var(--s-3);
}

/* Actions — sticky within the flow so Next stays thumb-reachable on long questions */
.actions {
  position: sticky; bottom: 0; z-index: 2;
  display: flex; gap: var(--s-3); margin-top: var(--s-5);
  padding: var(--s-3) 0 calc(var(--s-1) + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--surface) 62%, rgba(255,255,255,0));
}
button {
  min-height: var(--tap); padding: 12px var(--s-5); font-size: var(--t-base); font-weight: 600;
  border-radius: var(--r-md); border: 1.5px solid var(--blue); cursor: pointer; touch-action: manipulation;
  transition: background .14s var(--ease), transform .06s var(--ease), box-shadow .14s var(--ease);
}
button:focus-visible { outline: none; box-shadow: var(--ring); }
button:active { transform: scale(.98); }
button.primary { background: var(--blue); color: #fff; flex: 1; box-shadow: var(--shadow-sm); }
button.primary:hover { background: var(--blue-600); }
button.secondary { background: var(--surface); color: var(--blue); }
button.secondary:hover { background: var(--blue-050); }
button:disabled { opacity: .5; cursor: not-allowed; transform: none; }

.error { color: var(--red); font-weight: 600; font-size: var(--t-sm); margin-top: var(--s-3); }
.hidden { display: none; }

/* Review step */
.rev-item { padding: var(--s-4) 0; border-bottom: 1px solid var(--line-2); }
.rev-item:last-of-type { border-bottom: 0; }
.rev-q { font-weight: 600; margin-bottom: var(--s-1); font-size: var(--t-sm); color: var(--ink-2); }
.rev-a { color: var(--ink); }
.rev-sub { display: flex; justify-content: space-between; gap: var(--s-3); padding: 3px 0; }
.rev-sub span { color: var(--muted); }
.rev-sub b { text-align: right; }
button.link {
  min-height: auto; margin-top: var(--s-2); padding: 4px 0; border: 0; background: none;
  color: var(--blue); text-decoration: underline; font-size: var(--t-sm); font-weight: 500;
}
button.link:active { transform: none; }

/* Success (thank-you) */
.success-mark {
  width: 64px; height: 64px; border-radius: 50%; background: var(--blue-050);
  display: grid; place-items: center; margin: 0 auto var(--s-4);
}
.success-mark svg { width: 34px; height: 34px; stroke: var(--blue); }

/* Desktop niceties */
@media (min-width: 720px) {
  main.card, .card { padding: var(--s-7) var(--s-6); }
  .site-header .logo { height: 96px; margin: -12px 0; }
}
