/* Melly Luistert: visitor interview, design direction D.
   Melly's own palette: pure blue on white, yellow for actions and the bar, pink for notes.
   Square corners; circles only for the clock and the microphone.
   Fonts: Melly Sans (+ the Irregular "Melly Sans 2" for display) when the files are placed in
   /static/fonts/ (see README); otherwise Helvetica/Arial. */

/* @font-face rules are added by the page only when the font files are present. */

:root {
  --bg: #ffffff;
  --ink: #0000ff;          /* Melly blue: 8.6:1 on white */
  --ink-strong: #000000;
  --muted: #000000;
  --accent: #ffff00;       /* Melly yellow */
  --accent-ink: #000000;
  --note-bg: #fedafe;      /* Melly pink */
  --note-ink: #0000d7;
  --line: #0000ff;
  --hairline: #dadada;
  --focus-outer: #000000;
  --focus-inner: #ffff00;
  --selected-bg: #0000ff;
  --selected-ink: #ffff00;
  --font: "Melly Sans", Helvetica, Arial, system-ui, sans-serif;
  --display: "Melly Sans 2", "Melly Sans", Helvetica, Arial, sans-serif;
  font-size: 100%;
}
:root[data-size="1"] { font-size: 118%; }
:root[data-size="2"] { font-size: 137%; }

/* High contrast: Melly yellow on black (19.6:1) */
:root[data-contrast="high"] {
  --bg: #000000;
  --ink: #ffff00;
  --ink-strong: #ffffff;
  --muted: #ffffff;
  --accent: #ffff00;
  --accent-ink: #000000;
  --note-bg: #000000;
  --note-ink: #ffffff;
  --line: #ffff00;
  --hairline: #ffff00;
  --focus-outer: #ffffff;
  --focus-inner: #000000;
  --selected-bg: #ffff00;
  --selected-ink: #000000;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--ink); font-family: var(--font);
  font-size: 1.125rem; line-height: 1.45; min-height: 100dvh;
  display: flex; flex-direction: column;
  -webkit-text-size-adjust: 100%;
}
button, input, textarea, select { font: inherit; color: inherit; }
a { color: var(--ink); text-decoration: underline; text-underline-offset: 0.18em; }
a:hover { background: var(--accent); color: var(--accent-ink); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Focus: thick yellow + black ring, visible on every background */
:focus-visible { outline: 4px solid var(--focus-inner); outline-offset: 0; box-shadow: 0 0 0 7px var(--focus-outer); }
main:focus, h1:focus, h2:focus { outline: none; box-shadow: none; }

.skip-link { position: absolute; left: -9999px; top: 0; background: var(--accent); color: var(--accent-ink); padding: 12px 16px; z-index: 10; }
.skip-link:focus { left: 8px; top: 8px; }

/* Accessibility bar (yellow, like Melly's menu) */
.a11y-bar {
  display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr);
  background: var(--accent); color: var(--accent-ink); border-bottom: 1px solid #000000;
  position: sticky; top: 0; z-index: 5;
}
.a11y-bar > button, .a11y-bar .lang a {
  min-height: 60px; border: 0; border-inline-end: 1px solid #000000; background: transparent; color: #000000;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  font-size: 0.8125rem; font-weight: 500; cursor: pointer; padding: 6px 4px; text-decoration: none;
}
.a11y-bar .ico { font-size: 1.1875rem; line-height: 1; }
.a11y-bar > button[aria-pressed="true"] { background: #000000; color: #ffff00; }
.a11y-bar .lang { display: flex; }
.a11y-bar .lang a { flex: 1; border-inline-end: 0; }
.a11y-bar .lang a + a { border-inline-start: 1px solid #000000; }
.a11y-bar .lang a[aria-current] { background: #000000; color: #ffff00; }
.a11y-bar .lang a:hover { background: #000000; color: #ffff00; }
:root[data-contrast="high"] .a11y-bar { background: #000000; border-bottom: 2px solid #ffff00; }
:root[data-contrast="high"] .a11y-bar > button, :root[data-contrast="high"] .a11y-bar .lang a { color: #ffff00; border-color: #ffff00; }
:root[data-contrast="high"] .a11y-bar > button[aria-pressed="true"],
:root[data-contrast="high"] .a11y-bar .lang a[aria-current] { background: #ffff00; color: #000000; }

.reading {
  display: flex; align-items: center; gap: 12px; background: var(--selected-bg); color: var(--selected-ink);
  padding: 10px 20px;
}
.reading button { margin-inline-start: auto; min-height: 44px; padding: 0 16px; border: 0; background: var(--accent); color: var(--accent-ink); font-weight: 500; cursor: pointer; }
:root[data-contrast="high"] .reading button { background: #ffffff; color: #000000; }

main { flex: 1; width: 100%; max-width: 640px; margin: 0 auto; display: flex; flex-direction: column; }
.intro, .app { flex: 1; display: flex; flex-direction: column; padding: 24px 22px 0; gap: 20px; }

.brand-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand { font-family: var(--display); font-size: 1.375rem; line-height: 1.1; color: var(--ink); }
.brand.small { font-size: 1.125rem; margin-inline-start: auto; }
.display { margin: 0; font-family: var(--display); font-weight: 400; font-size: 2.625rem; line-height: 1.05; text-transform: uppercase; }
.lead { margin: 0; font-size: 1.25rem; }
.points { margin: 0; padding: 0; list-style: none; }
.points li { border-top: 1px solid var(--line); padding: 9px 0; }
.points li:last-child { border-bottom: 1px solid var(--line); }
.note { margin: 0; background: var(--note-bg); color: var(--note-ink); padding: 14px 16px; font-size: 1rem; }
.note a { color: var(--note-ink); }
:root[data-contrast="high"] .note { border: 2px solid #ffff00; }

/* Clock */
.clock-face { fill: var(--bg); stroke: var(--ink); stroke-width: 2; }
.clock-hand { stroke: var(--ink); stroke-width: 3; stroke-linecap: round; }
.clock-pin { fill: var(--accent); stroke: var(--ink); stroke-width: 1.5; }
.clock-fill { fill: var(--ink); }
.clock-tick { stroke: var(--ink); stroke-width: 1; }
.progress-row { display: flex; align-items: center; gap: 12px; }
.progress-text { font-size: 1.0625rem; font-weight: 500; }

/* Question screens */
.screen { display: flex; flex-direction: column; gap: 16px; flex: 1; }
.recap { background: var(--note-bg); color: var(--note-ink); padding: 12px 14px; font-size: 1rem; }
.recap .q { display: block; font-size: 0.875rem; }
.recap mark { background: var(--accent); color: var(--accent-ink); padding: 0 4px; }
:root[data-contrast="high"] .recap { border: 2px solid #ffff00; }
.ack { margin: 0; font-size: 1.125rem; color: var(--ink-strong); }
.question { scroll-margin-top: 90px; margin: 0; font-family: var(--display); font-weight: 400; font-size: 1.9375rem; line-height: 1.15; color: var(--ink); }
:root[data-contrast="high"] .question { color: #ffffff; }
.hint { margin: 0; font-size: 1rem; color: var(--muted); }
.field-label { font-size: 1rem; font-weight: 500; color: var(--ink-strong); }
textarea, input[type="text"] {
  width: 100%; border: 2px solid var(--ink); border-radius: 0; padding: 12px; background: var(--bg);
  color: var(--ink-strong); font-size: 1.1875rem;
}
textarea { min-height: 6.5rem; resize: vertical; }
:root[data-contrast="high"] textarea, :root[data-contrast="high"] input[type="text"] { background: #000000; color: #ffffff; border-color: #ffff00; }

/* Options as big tappable rows / squares built on real inputs */
.options { border: 0; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.options legend { padding: 0; }
.opt { position: relative; }
.opt input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.opt span {
  display: flex; align-items: center; gap: 12px; min-height: 56px; padding: 12px 14px;
  border: 1px solid var(--ink); color: var(--ink); background: var(--bg);
}
.opt span::before {
  content: ""; flex: none; width: 22px; height: 22px; border: 2px solid currentColor; background: transparent;
}
.opt input[type="radio"] + span::before { border-radius: 50%; }
.opt input:checked + span { background: var(--selected-bg); color: var(--selected-ink); border-color: var(--selected-bg); }
.opt input:checked + span::before { background: currentColor; box-shadow: inset 0 0 0 4px var(--selected-bg); }
.opt input:focus-visible + span { outline: 4px solid var(--focus-inner); box-shadow: 0 0 0 7px var(--focus-outer); }
.other-text { margin-top: 4px; }

.scale { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.scale.s5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.scale .opt span { justify-content: center; min-height: 60px; font-size: 1.5rem; font-weight: 500; padding: 0; }
.scale .opt span::before { display: none; }
:root[data-contrast="high"] .scale .opt span { border-width: 2px; }
.scale-labels { display: flex; justify-content: space-between; gap: 16px; font-size: 1rem; color: var(--muted); }
.scale-labels span:last-child { text-align: end; }
.chosen { margin: 0; font-size: 1.0625rem; color: var(--ink-strong); }

/* Buttons */
.btn {
  min-height: 64px; border-radius: 0; cursor: pointer; display: flex; align-items: center; justify-content: center;
  gap: 10px; font-size: 1.1875rem; font-weight: 500; padding: 0 16px;
}
.btn.primary { background: var(--accent); color: var(--accent-ink); border: 1px solid #000000; text-transform: uppercase; letter-spacing: 0.04em; }
.btn.secondary { background: var(--bg); color: var(--ink); border: 1px solid var(--ink); }
.btn:disabled { opacity: 0.45; cursor: default; }
:root[data-contrast="high"] .btn.primary { border-color: #ffff00; }
:root[data-contrast="high"] .btn.secondary { border-width: 2px; }
.btn.mic { min-height: 56px; border: 2px solid var(--ink); background: var(--bg); color: var(--ink); text-transform: none; letter-spacing: 0; }
.btn.mic .mic-dot { width: 34px; height: 34px; border-radius: 50%; background: var(--ink); color: var(--bg); display: flex; align-items: center; justify-content: center; flex: none; }
.btn.mic.recording { background: #d4183d; border-color: #d4183d; color: #ffffff; }
.btn.mic.recording .mic-dot { background: #ffffff; color: #d4183d; }
.voice-status { margin: 0; font-size: 0.9375rem; color: var(--muted); min-height: 1.2em; }

.actions {
  position: sticky; bottom: 0; background: var(--bg); padding: 16px 22px calc(20px + env(safe-area-inset-bottom));
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); gap: 10px; margin: auto -22px 0;
}
.actions.single { grid-template-columns: 1fr; }
.thinking { margin: 0; font-size: 1.125rem; color: var(--ink-strong); }
.error { margin: 0; background: var(--note-bg); color: var(--note-ink); padding: 12px 14px; }

.outro .display { font-size: 2.875rem; }

@media (prefers-reduced-motion: no-preference) {
  .btn.mic.recording .mic-dot { animation: pulse 1.2s ease-in-out infinite; }
  @keyframes pulse { 50% { transform: scale(1.12); } }
}
@media (forced-colors: active) {
  .opt input:checked + span { outline: 3px solid Highlight; }
  .btn, .opt span, .a11y-bar > button { border: 1px solid ButtonText; }
  .clock-fill { fill: Highlight; }
}
