/* ==========================================================================
   EFTA Satisfaction Survey – styles (EFTA brand guide)
   Colours and fonts are defined once below. Keep text/background pairs at a
   contrast ratio of at least 4.5:1 (3:1 for borders of form controls).
   ========================================================================== */

/* ---------- Brand fonts (bundled in assets/fonts, SIL Open Font License) ---------- */
@font-face {
  font-family: "Now";
  src: url("assets/fonts/now-regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Now";
  src: url("assets/fonts/now-bold.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Playfair Display";
  src: url("assets/fonts/playfair-display-700-latin.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Playfair Display";
  src: url("assets/fonts/playfair-display-700-latin-ext.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0100-02AF, U+0304, U+0308, U+0329, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

:root {
  /* EFTA brand palette */
  --efta-navy:     #0D2134;
  --efta-royal:    #284C92;
  --efta-blue:     #5082BC;
  --efta-steel:    #7293B8;
  --efta-sky:      #8FBDEA;
  --efta-red:      #DB4745;
  --efta-charcoal: #394042;
  --efta-paper:    #F7F6F5;

  /* Roles (change these to restyle) */
  --color-bg: var(--efta-paper);          /* page background */
  --color-surface: #ffffff;               /* question panels */
  --color-text: var(--efta-charcoal);     /* body text */
  --color-heading: var(--efta-navy);      /* headings, question text */
  --color-muted: #5C6670;                 /* hints, secondary text */
  --color-primary: var(--efta-royal);     /* buttons, selected answers, progress */
  --color-primary-hover: var(--efta-navy);
  --color-on-primary: #ffffff;
  --color-selected-bg: #EAF2FB;           /* light tint of EFTA sky blue */
  --color-accent: var(--efta-red);        /* the short bar under headings */
  --color-header: var(--efta-navy);
  --color-border: #E2E0DC;                /* panel outlines */
  --color-border-strong: var(--efta-steel); /* form control outlines (3.2:1 on white) */
  --color-stripe: #F9F9F8;                /* alternate grid rows */
  --color-focus: var(--efta-royal);
  --color-error: #B3302D;                 /* darker than brand red so text passes 4.5:1 */
  --color-error-bg: #FCEEEE;
  --color-code-bg: #EEF0F2;
  --color-na-bg: #ECEEF1;                 /* shading of the N/A column in rating grids */
  --color-na-border: #9AA2AD;             /* divider between the 1–5 scale and N/A */

  /* Brand fonts (loaded above); the fallbacks only show while the font files load
     or if they can't be loaded. */
  --font-display: "Playfair Display", "Bodoni MT", Didot, "Bodoni 72", Georgia, serif;
  --font-body: "Now", "Century Gothic", "Avenir Next", Avenir, "Segoe UI", system-ui, sans-serif;
  --font-mono: ui-monospace, "Cascadia Mono", Consolas, Menlo, monospace;

  --radius: 3px;
  --max-width: 52rem;
}

*, *::before, *::after { box-sizing: border-box; }

/* `hidden` must win over component display rules (e.g. fieldset.question { display: block }),
   otherwise questions hidden by showIf stay visible while their answers are discarded. */
[hidden] { display: none !important; }

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

body {
  margin: 0;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.55;
}

.wrap {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 1rem;
}

h1, h2 { color: var(--color-heading); }
h1 { font-family: var(--font-display); font-weight: 700; font-size: 2rem; line-height: 1.15; margin: 0 0 0.75rem; }
h2 { font-size: 1.15rem; line-height: 1.3; margin: 0 0 0.75rem; }
h1:focus, h2:focus { outline: none; }
p { margin: 0 0 1rem; }

/* The brand's signature: a short red bar under display headings */
.page-title::after,
.banner-title::after {
  content: "";
  display: block;
  width: 3.5rem;
  height: 5px;
  margin-top: 0.7rem;
  background: var(--color-accent);
}

/* ---------- Header ---------- */
.site-header { background: var(--color-header); color: #fff; }
.site-header-inner {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding-top: 0.75rem;
  padding-bottom: 0.75rem;
}
.site-logo { display: block; height: 2.6rem; width: auto; }
.site-title {
  margin: 0;
  padding-left: 1rem;
  border-left: 1px solid rgba(255, 255, 255, 0.35);
  font-size: 0.95rem;
  line-height: 1.3;
}

/* On the welcome / thank-you screens the header sits on top of the photo */
body[data-view="banner"] .site-header {
  position: absolute;
  top: 0; left: 0; right: 0;
  z-index: 2;
  background: transparent;
}
body[data-view="banner"] .site-logo { height: 3.6rem; }

/* ---------- Photo banner ---------- */
.banner {
  position: relative;
  display: flex;
  align-items: flex-end;
  min-height: clamp(20rem, 48vh, 28rem);
  padding: 7rem 0 4.5rem;
  color: #fff;
  background: var(--efta-navy) url("assets/hero.jpg") center 55% / cover no-repeat;
}
.banner::before {               /* navy wash, as in the brand's banner examples */
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg,
    rgba(13, 33, 52, 0.80) 0%,
    rgba(13, 33, 52, 0.30) 38%,
    rgba(13, 33, 52, 0.88) 100%);
}
.banner .wrap { position: relative; width: 100%; }
.banner-title {
  color: #fff;
  font-size: clamp(2rem, 5.2vw, 3.2rem);
  line-height: 1.08;
  max-width: 21ch;
  margin: 0;
  text-wrap: balance;
}

/* ---------- Cards ---------- */
main { padding-bottom: 3rem; }
body[data-view="form"] main { padding-top: 1.75rem; }

.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1.75rem;
  margin-bottom: 1.25rem;
}
.card > :last-child { margin-bottom: 0; }
/* The first card after the banner overlaps the photo slightly */
.card-lead { position: relative; margin-top: -2.5rem; }
.lead { font-size: 1.08rem; max-width: 62ch; }

.callout {
  border-left: 4px solid var(--color-primary);
  background: var(--color-selected-bg);
  color: var(--color-heading);
  padding: 0.85rem 1rem;
  margin: 1.25rem 0;
  font-weight: 700;
}
.note { color: var(--color-muted); font-size: 0.95rem; max-width: 62ch; }
.contact a { color: var(--color-primary); font-weight: 700; overflow-wrap: anywhere; }
.nav + .contact { margin-top: 1.5rem; }
/* Even-height figures for the 1–5 scale (Playfair defaults to old-style figures) */
.scale-num, .matrix-col .num { font-variant-numeric: lining-nums; }
.deadline { color: var(--color-heading); font-weight: 700; }
.nav .nav-note { flex: 1 1 100%; margin: 0; order: -2; }
.form-alert > :last-child { margin-bottom: 0; }

.section-description {
  color: var(--color-muted);
  max-width: 62ch;
  margin: -0.25rem 0 1.5rem;
}

/* ---------- Focus ---------- */
:focus-visible {
  outline: 3px solid var(--color-focus);
  outline-offset: 2px;
}

/* ---------- Progress ---------- */
.progress { margin-bottom: 1.5rem; }
.progress-text { margin: 0 0 0.4rem; font-size: 0.875rem; color: var(--color-muted); }
.progress progress {
  -webkit-appearance: none;
  appearance: none;
  display: block;
  width: 100%;
  height: 4px;
  border: 0;
  background: #DCE2EA;
  color: var(--color-primary);
}
.progress progress::-webkit-progress-bar { background: #DCE2EA; }
.progress progress::-webkit-progress-value { background: var(--color-primary); transition: width 0.3s ease; }
.progress progress::-moz-progress-bar { background: var(--color-primary); }

/* ---------- Questions ---------- */
.question {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin: 0 0 1.25rem;
  min-width: 0;          /* lets fieldsets shrink on small screens */
}
fieldset.question { display: block; }

.q-text {
  display: block;
  color: var(--color-heading);
  font-weight: 700;
  font-size: 1.06rem;
  line-height: 1.4;
  margin: 0 0 0.6rem;
  padding: 0;
}
legend.q-text { float: left; width: 100%; }
.q-help, .q-error, .options, .matrix, .question textarea, .question input[type="text"] { clear: both; }

.optional { font-weight: 400; color: var(--color-muted); font-size: 0.95rem; }
.q-help { color: var(--color-muted); margin: 0 0 0.85rem; font-size: 0.95rem; }

.q-error {
  color: var(--color-error);
  font-weight: 700;
  margin: 0 0 0.75rem;
}
.question.has-error {
  border-color: var(--color-error);
  box-shadow: inset 4px 0 0 var(--color-error);
}

/* ---------- Single / multiple choice ---------- */
.options { display: grid; gap: 0.5rem; }

.choice { position: relative; display: flex; }   /* flex: boxes in a row get equal height */
.choice input {
  position: absolute;
  left: 0.95rem;
  top: 0.95rem;
  margin: 0;
  width: 1.2rem;
  height: 1.2rem;
  accent-color: var(--color-primary);
  cursor: pointer;
}
.choice label {
  display: block;
  flex: 1 1 auto;
  padding: 0.75rem 1rem 0.75rem 2.9rem;
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius);
  background: var(--color-surface);
  cursor: pointer;
  min-height: 2.75rem;
}
.choice label:hover { background: var(--color-stripe); border-color: var(--color-primary); }
.choice input:checked + label {
  border-color: var(--color-primary);
  background: var(--color-selected-bg);
  box-shadow: inset 0 0 0 1px var(--color-primary);
  color: var(--color-heading);
}
.choice-help { display: block; font-size: 0.9rem; color: var(--color-muted); margin-top: 0.2rem; }

/* Single 1–5 scale laid out in a row on wider screens */
@media (min-width: 760px) {
  .options.scale { grid-template-columns: repeat(5, 1fr); }
  .options.scale .choice input { left: 50%; transform: translateX(-50%); top: 0.85rem; }
  .options.scale .choice label { text-align: center; padding: 2.6rem 0.5rem 0.85rem; }
  .options.scale .scale-num {
    display: block;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1.5rem;
    line-height: 1.1;
    color: var(--color-heading);
  }
  .options.scale .scale-sep { display: none; }
  .options.scale .scale-word { font-size: 0.92rem; }

  /* With an N/A option: six columns, N/A set apart as in the rating grids */
  .options.scale:has(.choice-na) { grid-template-columns: repeat(5, 1fr) 1fr; column-gap: 0.5rem; }
  .options.scale .choice-na { margin-left: 0.5rem; }
  .options.scale .choice-na .scale-num { font-family: var(--font-body); font-size: 1.1rem; line-height: 1.4; }
}

/* N/A on a single rating: grey shading + dashed border, like the N/A column of the grids */
.options.scale .choice-na label { background: var(--color-na-bg); border-style: dashed; border-color: var(--color-na-border); }
.options.scale .choice-na input:checked + label { border-style: solid; border-color: var(--color-primary); background: var(--color-selected-bg); }

/* ---------- Rating grid (matrix) ---------- */
.matrix { --cols: 6; }

.matrix-head { display: none; }

.matrix-row {
  padding: 0.9rem 0.25rem;
  border-top: 1px solid var(--color-border);
}
.matrix-row:first-of-type { border-top: 0; }
.matrix-label { font-weight: 700; color: var(--color-heading); margin-bottom: 0.55rem; }

.matrix-options { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.matrix-opt {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  min-height: 2.75rem;
  padding: 0.4rem 0.8rem;
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius);
  background: var(--color-surface);
  cursor: pointer;
  font-size: 0.95rem;
}
.matrix-opt input {
  margin: 0;
  width: 1.15rem;
  height: 1.15rem;
  accent-color: var(--color-primary);
  cursor: pointer;
}
.matrix-opt:has(input:checked) {
  border-color: var(--color-primary);
  background: var(--color-selected-bg);
  box-shadow: inset 0 0 0 1px var(--color-primary);
}
/* N/A is set apart from the 1–5 scale: grey shading + dashed border */
.matrix-opt-na {
  background: var(--color-na-bg);
  border-style: dashed;
  border-color: var(--color-na-border);
  margin-left: 0.5rem;
}

.matrix-row.row-missing {
  background: var(--color-error-bg);
  box-shadow: inset 4px 0 0 var(--color-error);
}

@media (min-width: 760px) {
  .matrix-head,
  .matrix-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 1rem;
    align-items: center;
  }
  .matrix-head {
    position: sticky;
    top: 0;
    z-index: 1;
    background: var(--color-surface);
    padding: 0.5rem 0 0 0.75rem;
    border-bottom: 2px solid var(--color-heading);
    font-size: 0.78rem;
    color: var(--color-muted);
    line-height: 1.2;
  }
  .matrix-head-cols,
  .matrix-options {
    display: grid;
    grid-template-columns: repeat(var(--cols), 4.6rem);
    gap: 0;
  }
  .matrix-col { text-align: center; padding: 0 0.15rem 0.5rem; align-self: end; }
  .matrix-col .num {
    display: block;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1.15rem;
    color: var(--color-heading);
  }

  /* Keep focused controls clear of the sticky rating-grid header (WCAG 2.4.11): the top
     6.5rem of the window does not count as "in view" when the browser scrolls to focus. */
  html:has(body[data-view="form"]) { scroll-padding-top: 6.5rem; }

  /* Rows have no vertical padding so the shaded N/A cells form one continuous column */
  .matrix-row { padding: 0 0 0 0.75rem; border-top: 1px solid var(--color-border); align-items: stretch; }
  .matrix-row:nth-of-type(even) { background: var(--color-stripe); }
  .matrix-row.row-missing { background: var(--color-error-bg); }
  .matrix-label { font-weight: 400; color: var(--color-text); margin: 0; padding: 0.65rem 0; align-self: center; }

  .matrix-opt {
    justify-content: center;
    border: 0;
    border-radius: 0;
    background: transparent;
    padding: 0;
    min-height: 3rem;
    height: 100%;
  }
  .matrix-opt:hover { background: var(--color-selected-bg); }
  .matrix-opt:has(input:checked) { background: transparent; box-shadow: none; }
  .matrix-opt input { width: 1.25rem; height: 1.25rem; }

  /* N/A column: separated by a dashed divider and shaded grey */
  .matrix-col-na,
  .matrix-opt-na,
  .matrix-opt-na:has(input:checked) {
    background: var(--color-na-bg);
    border-left: 2px dashed var(--color-na-border);
    margin-left: 0;
  }
  .matrix-col-na { padding: 0.4rem 0.15rem 0.5rem; align-self: stretch; display: flex; flex-direction: column; justify-content: flex-end; }
  .matrix-col-na .num { font-family: var(--font-body); font-size: 0.95rem; }
  .matrix-opt-na:hover { background: var(--color-selected-bg); }

  /* Column headings carry the visible labels; keep text for screen readers */
  .matrix-opt .opt-text {
    position: absolute;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
  }
}

/* ---------- Text inputs ---------- */
.question textarea,
.question input[type="text"] {
  display: block;
  width: 100%;
  font: inherit;
  color: inherit;
  padding: 0.65rem 0.8rem;
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius);
  background: var(--color-surface);
}
.question textarea { min-height: 7rem; resize: vertical; }
.question textarea:focus,
.question input[type="text"]:focus { border-color: var(--color-primary); }
.question.has-error textarea,
.question.has-error input[type="text"] { border-color: var(--color-error); }

/* ---------- Error summary ---------- */
.error-summary {
  border: 2px solid var(--color-error);
  border-left-width: 6px;
  background: var(--color-surface);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin-bottom: 1.25rem;
}
.error-summary:focus { outline: 3px solid var(--color-focus); outline-offset: 2px; }
.error-summary h2 { color: var(--color-error); font-size: 1.1rem; margin-bottom: 0.5rem; }
.error-summary ul { margin: 0; padding-left: 1.2rem; }
.error-summary li { margin-bottom: 0.35rem; }
.error-summary a { color: var(--color-error); font-weight: 700; }
.error-summary .err-msg { color: var(--color-text); font-weight: 400; }

.form-alert {
  border: 2px solid var(--color-error);
  background: var(--color-error-bg);
  color: var(--color-text);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
  margin-bottom: 1rem;
}

/* ---------- Buttons / navigation ---------- */
.nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  justify-content: space-between;
  align-items: center;
  margin-top: 1.75rem;
}
.nav .spacer { flex: 1; }

.btn {
  font: inherit;
  font-weight: 700;
  min-height: 3rem;
  padding: 0.7rem 1.75rem;
  border-radius: var(--radius);
  border: 2px solid var(--color-primary);
  cursor: pointer;
}
.btn-primary { background: var(--color-primary); color: var(--color-on-primary); }
.btn-primary:hover { background: var(--color-primary-hover); border-color: var(--color-primary-hover); }
.btn-secondary { background: var(--color-surface); color: var(--color-primary); }
.btn-secondary:hover { background: var(--color-selected-bg); }
.btn[disabled] { opacity: 0.65; cursor: progress; }

@media (max-width: 480px) {
  .nav .btn-primary { flex: 1 1 100%; order: -1; }
  .nav .btn-secondary { flex: 1 1 100%; }
  .nav .spacer { display: none; }
  .site-title { font-size: 0.85rem; }
  .card { padding: 1.25rem; }
  .question { padding: 1.15rem; }
}

/* ---------- Data-protection notice and consent statement ---------- */
.privacy-notice { border-left: 3px solid var(--color-border-strong); padding-left: 0.85rem; }
.consent-statement { color: var(--color-heading); font-weight: 700; max-width: 62ch; margin: 1.25rem 0 0; }
.consent-statement + .nav { margin-top: 1rem; }

/* ---------- Test-mode JSON output ---------- */
.test-panel { border: 2px dashed var(--color-border-strong); }
.test-panel pre {
  background: var(--color-code-bg);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  padding: 1rem;
  border-radius: var(--radius);
  overflow: auto;
  max-height: 60vh;
  margin: 0 0 1rem;
}
.test-panel .nav { justify-content: flex-start; margin-top: 0; }

.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 (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

@media print {
  .site-header, .banner, .nav, .progress { display: none; }
  body { background: #fff; }
  .card-lead { margin-top: 0; }
}
