@font-face {
  font-family: "Atkinson Hyperlegible Next";
  src: url("/fonts/atkinson-hyperlegible-next-latin-400-normal.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "Atkinson Hyperlegible Next";
  src: url("/fonts/atkinson-hyperlegible-next-latin-700-normal.woff2") format("woff2");
  font-weight: 700;
  font-display: swap;
}

:root {
  --font-size: 46px;
  --bg: #000;
  --text: #fff;
  --partial: rgba(255, 255, 255, 0.72);
  --muted: #b5b5b5;
  --button-bg: #1f1f1f;
  --button-text: #fff;
  --accent: #ffd54a;
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #fff;
  --text: #000;
  --partial: rgba(0, 0, 0, 0.66);
  --muted: #555;
  --button-bg: #ececec;
  --button-text: #000;
  --accent: #0a4fb8;
  color-scheme: light;
}

* { box-sizing: border-box; }

html {
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Atkinson Hyperlegible Next", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: var(--font-size);
  line-height: 1.38;
  -webkit-tap-highlight-color: transparent;
}

#transcript {
  max-width: 34em;
  margin: 0 auto;
  /* Room at the bottom so the newest line is not hidden behind the buttons. */
  padding: max(24px, env(safe-area-inset-top)) max(28px, env(safe-area-inset-right)) calc(2.2em + env(safe-area-inset-bottom)) max(28px, env(safe-area-inset-left));
  overflow-wrap: break-word;
  hyphens: manual;
}

#transcript p {
  margin: 0 0 0.7em;
}

.partial {
  color: var(--partial);
}

/* Version B: whole words fade in; interim words brighten when confirmed */
.w { transition: color 0.4s ease; }
.w.fresh { animation: word-in 0.22s ease-out; }
@keyframes word-in { from { opacity: 0; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .w.fresh { animation: none; } }

/* "♪ Virsi 159: …" while the congregation sings */
#transcript p.music {
  color: var(--accent);
  font-size: 0.8em;
  font-weight: 700;
  border-left: 0.2em solid var(--accent);
  padding-left: 0.5em;
}

#message {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  padding: 32px;
  text-align: center;
  color: var(--muted);
  font-size: max(26px, calc(var(--font-size) * 0.75));
  white-space: pre-line;
  pointer-events: none;
}
#message[hidden] { display: none; }

button {
  font: inherit;
  font-size: 22px;
  font-weight: 700;
  color: var(--button-text);
  background: var(--button-bg);
  border: 2px solid var(--muted);
  border-radius: 14px;
  min-height: 56px;
  min-width: 56px;
  padding: 8px 18px;
  cursor: pointer;
  touch-action: manipulation;
}

#settings-toggle {
  position: fixed;
  right: max(14px, env(safe-area-inset-right));
  bottom: max(14px, env(safe-area-inset-bottom));
  opacity: 0.55;
}

#latest {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: max(14px, env(safe-area-inset-bottom));
  border-color: var(--accent);
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.4);
}

#settings {
  position: fixed;
  right: max(14px, env(safe-area-inset-right));
  bottom: calc(max(14px, env(safe-area-inset-bottom)) + 70px);
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  background: var(--bg);
  border: 2px solid var(--muted);
  border-radius: 18px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
}
#settings[hidden] { display: none; }
#settings .row { display: flex; gap: 12px; }
#settings .row button { flex: 1; font-size: 28px; }
#settings { max-width: calc(100vw - 28px); box-sizing: border-box; }
#languages[hidden] { display: none; }
#languages button { font-size: 22px; min-width: 0; }
#languages button[aria-pressed="true"] { border-color: var(--accent); }

#connection {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: #8a5a00;
  color: #fff;
  font-size: 20px;
  text-align: center;
}
#connection[hidden] { display: none; }

#debug {
  position: fixed;
  top: 8px;
  left: 8px;
  padding: 6px 10px;
  font: 14px ui-monospace, Menlo, monospace;
  background: rgba(40, 40, 40, 0.85);
  color: #9f9;
  border-radius: 6px;
}
#debug[hidden] { display: none; }
