/* ---------------------------------------------------------------
   Design tokens. The ONLY place colours, fonts and spacing are set.
   Everything below, and every other page, uses these names.
   #1f5fbf is filled in by the server from config/brand.js.
   --------------------------------------------------------------- */
:root {
  --color-primary: #1f5fbf;
  --color-on-primary: #ffffff;
  --color-error: #b00020;
  --color-text: #1a1a1a;
  --color-text-muted: #666666;
  --color-background: #ffffff;
  --color-surface: #f4f4f4;

  --font-body: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-size-base: 16px;
  --font-size-large: 1.5rem;
  --font-size-small: 0.875rem;
  --font-size-caption: 1.75rem;
  --line-height-caption: 1.35;
  --font-size-poster-code: 3.2cm;
  --font-size-poster-text: 0.9cm;
  --font-size-poster-small: 0.5cm;

  --space-xs: 0.25rem;
  --space-s: 0.5rem;
  --space-m: 1rem;
  --space-l: 2rem;
  --space-xl: 4rem;

  --radius: 0.5rem;
}

/* ---------------------------------------------------------------
   Base rules. Only token names from here on, never raw values.
   --------------------------------------------------------------- */
* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: var(--font-size-base);
  color: var(--color-text);
  background: var(--color-background);
}

header {
  display: flex;
  align-items: center;
  gap: var(--space-m);
  padding: var(--space-m);
  color: var(--color-primary);
}

header img {
  width: 2.5rem;
  height: 2.5rem;
}

header h1 {
  margin: 0;
  font-size: var(--font-size-large);
}

main {
  padding: var(--space-l) var(--space-m);
}

footer {
  padding: var(--space-m);
  font-size: var(--font-size-small);
  color: var(--color-text-muted);
}

footer a {
  color: var(--color-primary);
}

/* ---------------------------------------------------------------
   Forms and controls (capture page and later operator pages)
   --------------------------------------------------------------- */
.field {
  margin-bottom: var(--space-m);
}

.field label {
  display: block;
  margin-bottom: var(--space-xs);
  font-size: var(--font-size-small);
  color: var(--color-text-muted);
}

select,
input,
button {
  font: inherit;
  padding: var(--space-s) var(--space-m);
  border: 1px solid var(--color-text-muted);
  border-radius: var(--radius);
  background: var(--color-background);
  color: var(--color-text);
}

select,
input {
  width: 100%;
  max-width: 30rem;
}

button {
  cursor: pointer;
}

button:disabled {
  opacity: 0.5;
  cursor: default;
}

.controls {
  display: flex;
  gap: var(--space-s);
  margin-bottom: var(--space-m);
}

.meter {
  width: 100%;
  max-width: 30rem;
  height: var(--space-m);
  border-radius: var(--radius);
  background: var(--color-surface);
  overflow: hidden;
}

.meter-bar {
  width: 0%;
  height: 100%;
  background: var(--color-primary);
  transition: width 50ms linear;
}

.status {
  color: var(--color-text-muted);
  font-size: var(--font-size-small);
}

/* ---------------------------------------------------------------
   Operator alarm: unmissable, stays until acknowledged.
   --------------------------------------------------------------- */
.alarm {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: var(--space-m);
  padding: var(--space-m);
  background: var(--color-error);
  color: var(--color-on-primary);
  font-size: var(--font-size-large);
  font-weight: bold;
  animation: alarm-blink 1s steps(2, start) infinite;
}

/* The class sets display:flex, which would defeat the hidden attribute. */
.alarm[hidden] {
  display: none;
}

.alarm-text {
  flex: 1;
}

.alarm-ack {
  font-size: var(--font-size-base);
  background: var(--color-on-primary);
  color: var(--color-error);
  border-color: var(--color-on-primary);
}

@keyframes alarm-blink {
  50% { background: var(--color-text); }
}

/* ---------------------------------------------------------------
   Transcript and language badge (capture page)
   --------------------------------------------------------------- */
.badge {
  display: inline-block;
  min-width: 2rem;
  padding: var(--space-xs) var(--space-s);
  border-radius: var(--radius);
  background: var(--color-primary);
  color: var(--color-on-primary);
  font-size: var(--font-size-small);
  text-align: center;
  text-transform: uppercase;
}

.hint {
  font-weight: normal;
}

/* One row per utterance: source column plus one column per target
   language. Columns come from config, so the table may be wide;
   it scrolls sideways inside its box rather than breaking the page. */
.transcript {
  min-height: 8rem;
  max-height: 28rem;
  overflow: auto;
  border: 1px solid var(--color-surface);
  border-radius: var(--radius);
  background: var(--color-surface);
}

.transcript table {
  width: 100%;
  border-collapse: collapse;
}

.transcript th,
.transcript td {
  min-width: 14rem;
  padding: var(--space-s) var(--space-m);
  vertical-align: top;
  text-align: left;
  border-bottom: 1px solid var(--color-background);
}

.transcript th {
  position: sticky;
  top: 0;
  background: var(--color-surface);
  font-size: var(--font-size-small);
  color: var(--color-text-muted);
  text-transform: uppercase;
}

.transcript td.partial,
.transcript td.pending {
  color: var(--color-text-muted);
  font-style: italic;
}

.transcript td.final {
  color: var(--color-text);
}

.transcript td.same {
  color: var(--color-text-muted);
}

/* A source cell made of several finals joined into one sentence. */
.transcript td.joined {
  border-left: 3px solid var(--color-primary);
}

/* A sentence the voice channel skipped to catch up. */
.transcript .voice-dropped {
  margin-top: var(--space-xs);
  font-size: var(--font-size-small);
  color: var(--color-error);
}

/* A final the phantom gate dropped: still visible, never translated. */
.transcript td.dropped {
  color: var(--color-text-muted);
  text-decoration: line-through;
  font-size: var(--font-size-small);
}

.transcript td.error {
  color: var(--color-error);
  font-size: var(--font-size-small);
}

.transcript .lang {
  margin-right: var(--space-s);
  font-size: var(--font-size-small);
  color: var(--color-text-muted);
  text-transform: uppercase;
}

/* ---------------------------------------------------------------
   Attendee page: one-handed phone reading. Big text, big buttons.
   --------------------------------------------------------------- */
body.attendee {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  overflow: hidden;
}

.attendee-header {
  display: flex;
  align-items: center;
  gap: var(--space-s);
  padding: var(--space-s) var(--space-m);
  padding-top: calc(var(--space-s) + env(safe-area-inset-top, 0px));
  color: var(--color-primary);
}

.attendee-header img {
  width: 1.75rem;
  height: 1.75rem;
}

.attendee-event {
  font-weight: bold;
}

.attendee-brand {
  font-size: var(--font-size-small);
  color: var(--color-text-muted);
}

.languages {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-s);
  padding: 0 var(--space-m) var(--space-s);
}

.languages button {
  flex: 1 1 auto;
  min-height: 3rem;
  font-size: var(--font-size-base);
}

.languages button.active {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: var(--color-on-primary);
}

.listen {
  margin: 0 var(--space-m) var(--space-s);
  min-height: 3.5rem;
  font-size: var(--font-size-large);
  font-weight: bold;
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: var(--color-on-primary);
}

.listen.listening {
  background: var(--color-background);
  color: var(--color-primary);
}

.connection {
  margin: 0;
  padding: var(--space-xs) var(--space-m);
  font-size: var(--font-size-small);
  color: var(--color-on-primary);
  background: var(--color-text-muted);
}

.connection.audio {
  background: var(--color-text);
}

.connection.ok {
  background: var(--color-primary);
}

.connection.bad {
  background: var(--color-error);
}

.captions {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-m);
  padding-bottom: calc(var(--space-xl) + env(safe-area-inset-bottom, 0px));
}

.caption {
  margin: 0 0 var(--space-m);
  font-size: var(--font-size-caption);
  line-height: var(--line-height-caption);
}

/* ---------------------------------------------------------------
   Printable posters: one A4 page per room. Black on white so it
   prints on any office printer; the brand colour is only an accent.
   --------------------------------------------------------------- */
@page {
  size: A4 portrait;
  margin: 1.5cm;
}

body.posters {
  background: var(--color-background);
}

.poster {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  box-sizing: border-box;
  width: 18cm;
  height: 26.7cm;
  margin: 0 auto;
  padding: 1cm;
  text-align: center;
  color: var(--color-text);
  page-break-after: always;
  break-after: page;
}

.poster-brand {
  display: flex;
  align-items: center;
  gap: 0.4cm;
  font-size: var(--font-size-poster-small);
  color: var(--color-primary);
}

.poster-brand img {
  width: 1.2cm;
  height: 1.2cm;
}

.poster-event {
  margin: 0;
  font-size: var(--font-size-poster-text);
}

.poster-code {
  margin: 0;
  font-size: var(--font-size-poster-code);
  font-weight: bold;
  letter-spacing: 0.15em;
  line-height: 1;
}

.poster-qr svg {
  display: block;
  width: 100%;
  height: 100%;
}

.poster-instruction {
  margin: 0;
  font-size: var(--font-size-poster-text);
  font-weight: bold;
}

.poster-url {
  margin: 0;
  font-size: var(--font-size-poster-small);
  color: var(--color-text-muted);
}

@media screen {
  body.posters {
    padding: var(--space-l) 0;
    background: var(--color-surface);
  }
  .poster {
    margin-bottom: var(--space-l);
    background: var(--color-background);
    box-shadow: 0 0 0 1px var(--color-text-muted);
  }
}
