/* The participant screen (RUN-5; §17.1, §17.3).
 *
 * - R-UX-01: one column from 360 px; two columns on a tablet in landscape and on a phone held
 *   sideways, portrait and landscape alike.
 * - R-UX-02: every size is relative to the root, and the root follows the OS text-size setting
 *   (`-apple-system-body` is iOS Dynamic Type; elsewhere the browser's own setting). Body text is
 *   never below 1rem. No size here is in pixels.
 * - R-UX-03: every colour is a token below; tests/test_participant_css.py checks each pairing
 *   for WCAG 2.1 AA. Recording state is carried by text and shape as well as colour.
 */

:root {
  --color-bg: #ffffff;
  --color-surface: #f3f4f6;
  --color-text: #111827;
  --color-muted: #4b5563;
  --color-accent: #1d4ed8;
  --color-on-accent: #ffffff;
  --color-recording: #b91c1c;
  --color-border: #6b7280;
  --color-callout: #fef3c7;
  --color-passage: #e0e7ff;
  --color-disabled-bg: #e5e7eb;
  --color-disabled-text: #374151;
  --color-focus: #1d4ed8;
}

html {
  font-size: 100%;
  font: -apple-system-body;
}

body {
  margin: 0;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 1.125rem;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

[hidden] {
  display: none !important;
}

.screen {
  box-sizing: border-box;
  max-width: 64rem;
  min-height: 100vh;
  margin: 0 auto;
  padding: 1rem;
  display: grid;
  gap: 1.5rem;
  align-content: start;
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas:
    "header"
    "content"
    "panel";
}

.screen-header {
  grid-area: header;
}

.screen-content {
  grid-area: content;
}

.screen-panel {
  grid-area: panel;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.screen-context {
  margin: 0;
  color: var(--color-muted);
  font-size: 1rem;
}

.status {
  font-size: 1.25rem;
}

/* --- blocks (§14.4) --------------------------------------------------------------------------- */

.block-heading {
  margin: 0 0 1rem;
  font-size: clamp(1.75rem, 1.25rem + 2vw, 2.75rem);
  line-height: 1.2;
}

.block-paragraph,
.block-list {
  margin: 0 0 1rem;
  max-width: 40em;
  font-size: 1.25rem;
}

.block-list {
  padding-left: 1.5em;
}

.block-callout {
  margin: 0 0 1rem;
  max-width: 40em;
  padding: 1rem 1.25rem;
  border-left: 0.375rem solid var(--color-border);
  background: var(--color-callout);
  font-size: 1.125rem;
}

/* A passage is read aloud (§14.4): its own shape, larger, set apart from the instructions. */
.block-passage {
  margin: 0 0 1rem;
  max-width: 36em;
  padding: 1.25rem 1.5rem;
  border-left: 0.5rem solid var(--color-accent);
  background: var(--color-passage);
}

.block-passage-label {
  margin: 0 0 0.5rem;
  color: var(--color-text);
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.block-passage-text {
  margin: 0;
  font-size: 1.5rem;
  line-height: 1.6;
}

.block-image {
  margin: 0 0 1rem;
  padding: 1.5rem 1rem;
  border: 0.125rem dashed var(--color-border);
  background: var(--color-surface);
  font-size: 1rem;
}

/* --- timer, recording indicator, controls ------------------------------------------------------ */

.timer {
  margin: 0;
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
}

.timer-value {
  font-size: clamp(2.5rem, 2rem + 3vw, 4rem);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.timer-label,
.timer-guidance,
.controls-note,
.note {
  color: var(--color-muted);
  font-size: 1rem;
}

.timer-guidance,
.note {
  margin: 0;
}

.recording {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 0.625rem;
  font-size: 1.125rem;
  font-weight: 600;
}

.recording-shape {
  flex: none;
  width: 0.875em;
  height: 0.875em;
}

/* Live: a filled circle in the recording colour. Not recording: a hollow square. */
.recording-on {
  color: var(--color-recording);
}

.recording-on .recording-shape {
  border-radius: 50%;
  background: currentColor;
}

.recording-off {
  color: var(--color-muted);
}

.recording-off .recording-shape {
  box-sizing: border-box;
  border: 0.15em solid currentColor;
}

/* Muted (R-RC-11): a hollow circle struck through, in the text colour, beside the words
   "Microphone off". Distinct from both recording and not recording by shape and text. */
.recording-muted {
  color: var(--color-text);
}

.recording-muted .recording-shape {
  box-sizing: border-box;
  position: relative;
  border: 0.15em solid currentColor;
  border-radius: 50%;
}

.recording-muted .recording-shape::after {
  content: "";
  position: absolute;
  top: 50%;
  left: -0.15em;
  right: -0.15em;
  height: 0.15em;
  margin-top: -0.075em;
  background: currentColor;
  transform: rotate(-45deg);
}

/* R-RC-07: small and peripheral, five short bars lit by the measured level. */
.level-meter {
  display: inline-flex;
  align-items: flex-end;
  gap: 0.125rem;
  height: 0.875em;
  margin-left: 0.25rem;
}

.level-bar {
  width: 0.25em;
  background: var(--color-border);
}

.level-bar:nth-child(1) { height: 20%; }
.level-bar:nth-child(2) { height: 40%; }
.level-bar:nth-child(3) { height: 60%; }
.level-bar:nth-child(4) { height: 80%; }
.level-bar:nth-child(5) { height: 100%; }

.level-meter[data-level="1"] .level-bar:nth-child(-n + 1),
.level-meter[data-level="2"] .level-bar:nth-child(-n + 2),
.level-meter[data-level="3"] .level-bar:nth-child(-n + 3),
.level-meter[data-level="4"] .level-bar:nth-child(-n + 4),
.level-meter[data-level="5"] .level-bar:nth-child(-n + 5) {
  background: currentColor;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
}

.button {
  min-height: 3rem;
  padding: 0.75rem 1.5rem;
  border: 0.125rem solid var(--color-accent);
  border-radius: 0.5rem;
  background: var(--color-accent);
  color: var(--color-on-accent);
  font: inherit;
  font-size: 1.125rem;
  font-weight: 600;
  cursor: pointer;
}

.button-secondary {
  background: var(--color-bg);
  color: var(--color-accent);
}

.button:disabled {
  border-color: var(--color-border);
  background: var(--color-disabled-bg);
  color: var(--color-disabled-text);
  cursor: not-allowed;
}

.button:focus-visible {
  outline: 0.1875rem solid var(--color-focus);
  outline-offset: 0.1875rem;
}

/* Narrow phones: controls take the full width, easy to reach. */
@media (max-width: 30rem) {
  .controls .button {
    flex: 1 1 100%;
  }
}

/* A tablet in landscape, or any screen wide enough: instructions left, timer and controls right. */
@media (min-width: 48rem) and (orientation: landscape) {
  .screen {
    padding: 1.5rem 2rem;
    grid-template-columns: minmax(0, 2fr) minmax(16rem, 1fr);
    grid-template-areas:
      "header header"
      "content panel";
  }
}

/* A phone on its side: little height, so the same two columns, tighter. */
@media (orientation: landscape) and (max-height: 32rem) {
  .screen {
    min-height: 0;
    gap: 1rem;
    grid-template-columns: minmax(0, 3fr) minmax(12rem, 2fr);
    grid-template-areas:
      "header header"
      "content panel";
  }

  .block-heading {
    font-size: 1.75rem;
  }
}
.consent-option {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  margin: 1.25rem 0;
  cursor: pointer;
}

.consent-option input {
  width: 1.5rem;
  height: 1.5rem;
  flex-shrink: 0;
  margin-top: 0.2rem;
}

.consent-wording { white-space: pre-line; }

/* --- feedback settings (B4) and the R-FB-09 disclosure ----------------------------------------- */

.settings-group {
  margin: 1.5rem 0;
  padding: 0;
  border: 0;
}

.settings-question {
  font-weight: 700;
}

.settings-option {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 0.75rem 0;
  cursor: pointer;
}

.settings-option input {
  width: 1.5rem;
  height: 1.5rem;
  flex-shrink: 0;
}

.settings-text {
  width: 100%;
  font: inherit;
  padding: 0.5rem;
  border: 1px solid var(--color-border);
}

.disclosure { margin-top: 2rem; }
.disclosure-heading { font-size: 1rem; }
.disclosure-list dt { font-weight: 700; margin-top: 0.75rem; }
.disclosure-list dd { margin: 0; }
/* Authored images are private, normalised raster assets (ADR 0035). */
.block-image img { max-width: 100%; height: auto; }

/* --- pre-flight check (R-UX-05, B9/B10) -------------------------------------------------------- */

.checklist {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 0.5rem;
}

.check {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.check-status {
  color: var(--color-muted);
}

/* Each state has its own shape beside its word (R-UX-03): dashed circle while checking, filled
   circle when ready, hollow square when not yet, hollow diamond for a warning. */
.check-shape {
  flex: none;
  box-sizing: border-box;
  width: 0.875em;
  height: 0.875em;
  border: 0.15em solid currentColor;
}

.check[data-state="pending"] .check-shape {
  border-style: dashed;
  border-radius: 50%;
}

.check[data-state="ok"] .check-shape {
  border-radius: 50%;
  background: currentColor;
}

.check[data-state="warning"] .check-shape {
  transform: rotate(45deg) scale(0.8);
}
