/* High-contrast, large-type, full-screen camera UI. The whole screen is the gesture surface. */
:root {
  --fg: #fff;
  --bg: #000;
  --accent: #ffd400;
  --bad: #ff8a80;
}

/* Every element must opt out of browser touch handling. touch-action is not inherited, and a scrollable
   child (like the answer box) otherwise lets Chrome start a pan and cancel our swipe (pointercancel). */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; touch-action: none; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--fg);
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: none; /* we handle swipes ourselves; also stops pull-to-refresh */
  user-select: none;
  -webkit-user-select: none;
}

#video {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0.55; /* dimmed so the text stays readable for low-vision users */
}

main {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 0.6rem;
  padding: max(1rem, env(safe-area-inset-top)) 1rem max(1rem, env(safe-area-inset-bottom));
  background: linear-gradient(to bottom, rgba(0,0,0,0.65), rgba(0,0,0,0) 30%, rgba(0,0,0,0) 40%, rgba(0,0,0,0.88) 100%);
}

#status {
  margin: 0;
  position: absolute;
  top: max(1rem, env(safe-area-inset-top));
  left: 1rem;
  right: 1rem;
  text-align: center;
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--accent);
  text-shadow: 0 1px 4px #000;
}

body[data-mode='listening'] #status { color: #7CFC00; }
body[data-mode='busy'] #status { color: #8ecbff; }
body[data-mode='error'] #status { color: var(--bad); }
body[data-mode='listening'] main { box-shadow: inset 0 0 0 6px #7CFC00; }
body[data-mode='busy'] main { animation: pulse 1.4s ease-in-out infinite; }

@keyframes pulse { 50% { box-shadow: inset 0 0 0 6px rgba(142, 203, 255, 0.8); } }
@media (prefers-reduced-motion: reduce) { body[data-mode='busy'] main { animation: none; } }

#heard {
  margin: 0;
  min-height: 1.4em;
  font-size: 1.15rem;
  font-style: italic;
  color: #cfd8dc;
}

#answer {
  margin: 0;
  max-height: 45vh;
  overflow: hidden; /* not scrollable: scrolling would steal swipes. Answers are 2-3 sentences. */
  font-size: 1.7rem;
  line-height: 1.35;
  font-weight: 600;
  text-shadow: 0 1px 3px #000;
}
#answer.refused { color: var(--bad); }

#start {
  position: absolute;
  inset: 20% 8% auto 8%;
  padding: 2rem 1rem;
  font-size: 1.8rem;
  font-weight: 800;
  color: #000;
  background: var(--accent);
  border: 0;
  border-radius: 1.2rem;
}

.controls { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.controls button {
  flex: 1 1 30%;
  min-height: 48px;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--fg);
  background: rgba(255, 255, 255, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 0.6rem;
}

button:focus-visible { outline: 4px solid var(--accent); outline-offset: 2px; }

#debug {
  margin: 0;
  max-height: 22vh;
  overflow: auto;
  padding: 0.4rem;
  font-size: 0.65rem;
  line-height: 1.25;
  white-space: pre-wrap;
  color: #9f9;
  background: rgba(0, 0, 0, 0.8);
  user-select: text;
  touch-action: pan-y; /* debug panel only (?debug=1): lets you scroll the log */
}

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
