/* Shared look of the questionnaire and the admin page.
   Identity from the presentation (index.html); layout values from the guided-forms standard.
   Inter by Rasmus Andersson, SIL Open Font License 1.1, self-hosted (copied from unctad-ai/ibero-freezones). */

@font-face { font-family: "Inter"; font-style: normal; font-weight: 400; font-display: swap; src: url("fonts/inter-400.ttf") format("truetype"); }
@font-face { font-family: "Inter"; font-style: normal; font-weight: 500; font-display: swap; src: url("fonts/inter-500.ttf") format("truetype"); }
@font-face { font-family: "Inter"; font-style: normal; font-weight: 600; font-display: swap; src: url("fonts/inter-600.ttf") format("truetype"); }
@font-face { font-family: "Inter"; font-style: normal; font-weight: 700; font-display: swap; src: url("fonts/inter-700.ttf") format("truetype"); }

:root {
  --green: #1f6e47;
  --green-strong: #1a5839;
  --green-soft: #f0f9f4;
  --green-pale: #cfe7d8;
  --ink: #101110;
  --ink-hover: #2a2d2a;
  --grey: #555866;
  --rule: #dcdfdc;
  --input-rule: #c9ccc9;
  --control-rule: #868a86; /* border of text fields and choice cards: 3.5 to 1 on white (WCAG 1.4.11) */
  --surface: #f7f8f6;
  --panel: #ffffff;
  --error: #b42318;
  --error-soft: #fef3f2;
  --warn: #93370d;
  --warn-soft: #fffaeb;
  --focus: #1f6e47;
  --radius-panel: 20px;
  --radius-block: 12px;
  --radius-field: 8px;
  --shadow: 0 6px 14px rgba(0, 0, 0, .06);
  --font: "Inter", -apple-system, "Segoe UI", sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--surface); color: var(--ink); font-family: var(--font); font-size: 16px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
a { color: var(--green); }
a:hover { color: var(--green-strong); }
::selection { background: var(--green-pale); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* Page frame */
.q-header { background: var(--panel); border-bottom: 1px solid var(--rule); }
.q-header-inner { width: min(1200px, calc(100% - 48px)); margin: 0 auto; min-height: 64px; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.q-brand { color: var(--ink); text-decoration: none; font-weight: 700; font-size: .95rem; letter-spacing: .01em; }
.q-brand:hover { color: var(--green); }
.q-shell { width: min(1200px, calc(100% - 48px)); margin: 0 auto; padding: 48px 0 72px; }
.q-grid { display: grid; grid-template-columns: minmax(0, 820px) minmax(260px, 320px); gap: 28px; align-items: start; }
.q-grid > .stepper { grid-column: 1 / -1; margin-bottom: 8px; }
.q-main { background: var(--panel); border-radius: var(--radius-panel); box-shadow: var(--shadow); padding: 40px; min-width: 0; }
.q-aside { background: var(--panel); border: 1px solid var(--rule); border-radius: var(--radius-block); padding: 24px; position: sticky; top: 24px; }
.q-aside h2 { font-size: 1rem; margin: 0 0 12px; }
.q-aside ul { margin: 0; padding-left: 18px; color: var(--grey); font-size: .9rem; }
.q-aside li + li { margin-top: 10px; }
.q-footer { width: min(1200px, calc(100% - 48px)); margin: 0 auto; padding: 0 0 40px; color: var(--grey); font-size: .85rem; }

/* Text */
.q-eyebrow { font-size: .78rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--green); margin: 0 0 8px; }
.q-title { font-size: clamp(1.7rem, 3.2vw, 2.4rem); font-weight: 600; line-height: 1.2; letter-spacing: -.02em; margin: 0 0 8px; }
.q-title:focus { outline: none; }
.q-title:focus-visible { outline: 2px solid var(--focus); outline-offset: 4px; }
.q-lede { color: var(--grey); margin: 0 0 24px; max-width: 62ch; }
.q-small { font-size: .85rem; color: var(--grey); }
.q-help { font-size: .85rem; color: var(--grey); line-height: 1.45; margin: 6px 0 14px; }

/* Buttons: dark filled pill for the main action, outlined pill for secondary, quiet link */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 10px 18px; border-radius: 999px; border: 1px solid transparent; font: inherit; font-size: .95rem; font-weight: 600; cursor: pointer; text-decoration: none; transition: background-color .15s ease, border-color .15s ease, color .15s ease; }
.btn-primary { background: var(--ink); color: #fff; }
.btn-primary:hover { background: var(--ink-hover); color: #fff; }
.btn-secondary { background: var(--panel); color: var(--ink); border-color: var(--control-rule); }
.btn-secondary:hover { border-color: var(--ink); color: var(--ink); }
.btn-link { background: none; border: none; min-height: 32px; padding: 4px 2px; color: var(--green); font-weight: 600; text-decoration: underline; text-underline-offset: 3px; border-radius: 4px; }
.btn-link:hover { color: var(--green-strong); }
.btn-danger { background: var(--panel); color: var(--error); border-color: var(--error); }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; }
.btn.is-busy { cursor: progress; }
.q-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 16px; margin-top: 28px; }
.q-actions .spacer { flex: 1 1 auto; }

/* Fields */
.field { margin: 0 0 18px; }
.field-label { display: block; font-size: .875rem; font-weight: 600; margin: 0 0 8px; }
.field-help { display: block; font-size: .8rem; color: var(--grey); margin: -4px 0 8px; }
.field-error { display: block; font-size: .85rem; color: var(--error); font-weight: 500; margin: 6px 0 0; }
.input { width: 100%; font: inherit; font-size: 1rem; color: var(--ink); background: var(--panel); border: 1px solid var(--control-rule); border-radius: var(--radius-field); padding: 12px 14px; }
textarea.input { min-height: 112px; resize: vertical; }
.input:hover { border-color: var(--grey); }
.input:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; border-color: var(--focus); }
.input[aria-invalid="true"], .field.is-invalid .input { border-color: var(--error); }
.input[readonly] { background: var(--surface); }
.input[disabled] { background: var(--surface); color: var(--grey); }
.field-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr)); gap: 0 16px; }

/* Question block: one flat bordered block per question */
.qblock { border: 1px solid var(--rule); border-radius: var(--radius-block); padding: 20px; margin: 0 0 16px; min-width: 0; background: var(--panel); }
.qblock-legend { font-size: 1rem; font-weight: 600; padding: 0; margin: 0 0 4px; float: left; width: 100%; }
.qblock-legend + * { clear: left; }
.qblock.is-followup { margin: 12px 0 0 20px; border-left: 3px solid var(--green-pale); background: var(--surface); }
.qblock-note { font-size: .85rem; color: var(--warn); background: var(--warn-soft); border-radius: var(--radius-field); padding: 8px 12px; margin: 12px 0 0; }
.qblock-tools { margin-top: 8px; }

/* Choice cards: native radios and checkboxes inside clickable bordered options */
.choices { display: flex; flex-wrap: wrap; gap: 10px; margin: 8px 0 0; }
.choices.is-stacked { flex-direction: column; align-items: stretch; }
.choice { display: flex; align-items: center; gap: 8px; min-height: 44px; padding: 8px 12px; border: 1px solid var(--control-rule); border-radius: var(--radius-field); background: var(--panel); cursor: pointer; font-size: .95rem; transition: border-color .15s ease, background-color .15s ease; }
.choice:hover { border-color: var(--grey); }
.choice input { width: 18px; height: 18px; margin: 0; accent-color: var(--green); flex: 0 0 auto; }
.choice:has(input:focus-visible) { outline: 2px solid var(--focus); outline-offset: 2px; }
.choice.is-checked, .choice:has(input:checked) { border-color: var(--green); background: var(--green-soft); color: var(--green-strong); font-weight: 600; }
.choice.is-disabled, .choice:has(input:disabled) { cursor: not-allowed; opacity: .7; }

/* Stepper */
.stepper { list-style: none; display: flex; gap: 0; padding: 0; margin: 0 0 36px; counter-reset: step; }
.stepper-item { flex: 1 1 0; position: relative; min-width: 0; }
.stepper-item + .stepper-item::before { content: ""; position: absolute; top: 22px; left: -50%; right: 50%; height: 1px; background: var(--rule); }
.stepper-btn { position: relative; z-index: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; width: 100%; background: none; border: none; padding: 10px 4px; font: inherit; color: var(--grey); cursor: pointer; border-radius: 8px; min-height: 44px; }
.stepper-btn[disabled] { cursor: not-allowed; }
.stepper-marker { width: 24px; height: 24px; border-radius: 50%; border: 1px solid var(--input-rule); background: var(--panel); display: grid; place-items: center; font-size: .75rem; font-weight: 700; transition: background-color .2s ease; }
.stepper-label { font-size: .8rem; font-weight: 600; text-align: center; line-height: 1.3; }
.stepper-note { font-size: .72rem; color: var(--grey); text-align: center; }
.stepper-item.is-current .stepper-marker { background: var(--ink); border-color: var(--ink); color: #fff; }
.stepper-item.is-current .stepper-label { color: var(--ink); }
.stepper-item.is-done .stepper-marker { background: var(--green); border-color: var(--green); color: #fff; }
.stepper-item.is-locked .stepper-label { opacity: .7; }

/* Panels and messages */
.panel { border: 1px solid var(--rule); border-radius: var(--radius-block); padding: 16px; background: var(--panel); margin: 0 0 16px; }
.notice { border-radius: var(--radius-block); padding: 14px 16px; margin: 0 0 16px; background: var(--green-soft); border: 1px solid var(--green-pale); color: var(--ink); }
.notice-warn { background: var(--warn-soft); border-color: #fedf89; color: var(--warn); }
.notice-error { background: var(--error-soft); border-color: #fecdca; color: var(--error); }
.notice-success { background: var(--green-soft); border-color: var(--green-pale); color: var(--green-strong); }
.notice > :first-child { margin-top: 0; }
.notice > :last-child { margin-bottom: 0; }
.notice .q-actions { margin-top: 12px; }
.banner { background: var(--ink); color: #fff; text-align: center; padding: 10px 16px; font-size: .9rem; font-weight: 600; }
.saveline { font-size: .85rem; color: var(--grey); min-height: 1.5em; }
.saveline.is-error { color: var(--error); font-weight: 600; }
.linkbox { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.linkbox .input { flex: 1 1 280px; font-size: .9rem; }
.disclosure { border: 1px solid var(--rule); border-radius: var(--radius-block); padding: 12px 16px; background: var(--panel); margin: 16px 0 0; }
.disclosure > summary { cursor: pointer; font-weight: 600; min-height: 32px; display: flex; align-items: center; }
.tag { display: inline-block; font-size: .75rem; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--surface); border: 1px solid var(--rule); color: var(--grey); }
.tag-draft { background: var(--warn-soft); border-color: #fedf89; color: var(--warn); }

/* Tables (admin) */
.table-wrap { overflow-x: auto; border: 1px solid var(--rule); border-radius: var(--radius-block); background: var(--panel); }
.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th, .table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--rule); vertical-align: top; }
.table th { font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--grey); background: var(--surface); }
.table tr:last-child td { border-bottom: none; }

@media (max-width: 900px) {
  .q-grid { grid-template-columns: 1fr; }
  .q-aside { position: static; margin-top: 28px; }
}
@media (max-width: 640px) {
  .q-shell, .q-header-inner, .q-footer { width: calc(100% - 28px); }
  .q-shell { padding: 28px 0 52px; }
  .q-main { padding: 22px; }
  .stepper-label, .stepper-note { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .q-actions .btn { flex: 1 1 100%; }
  .qblock.is-followup { margin-left: 8px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}
