/* ANE brand tokens — canonical values, see knowledge-base/02-brands/ane-design-system.md.
   Dark background is a deliberate UX choice (legibility at arm's length in a dim
   lecture hall), not a brand deviation — ANE's system supports full dark mode. */
@import url('https://fonts.googleapis.com/css2?family=Be+Vietnam+Pro:wght@400;500;600;700;800&display=swap');

:root {
  color-scheme: dark;
  --bg: #0d1117;
  --panel: #161b22;
  --text: #e6edf3;
  --muted: #8b949e;

  --ane-500: #415097;      /* Indigo — chrome/structure: header, focus rings, lang bar */
  --ane-action-500: #f27131; /* Orange — CTA: "start this" invitation (Start, PIN submit) */
  --danger: #f85149;       /* Recording-active safety signal (Stop button + live dot) —
                               intentionally NOT brand orange: universal red = "recording,
                               handle with care" beats brand consistency for a safety cue */
}

* {
  box-sizing: border-box;
}

html, body {
  height: 100%;
  margin: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: "Be Vietnam Pro", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

button, select {
  font-family: inherit;
  touch-action: manipulation; /* kill the 300ms mobile tap delay */
  cursor: pointer;
}

:focus-visible {
  outline: 2px solid var(--ane-500);
  outline-offset: 2px;
}

.hidden {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

.screen {
  min-height: 100dvh; /* dvh, not vh — avoids iOS Safari toolbar resize jump */
  display: flex;
  flex-direction: column;
}

/* PIN screen */
#pin-screen {
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.pin-box {
  width: 100%;
  max-width: 320px;
  text-align: center;
}

.pin-box h1 {
  font-size: 1.4rem;
  margin-bottom: 4px;
}

.subtitle {
  color: var(--muted);
  margin-top: 0;
  margin-bottom: 24px;
}

#pin-input {
  width: 100%;
  font-size: 1.4rem;
  text-align: center;
  letter-spacing: 0.3em;
  padding: 14px 12px;
  border-radius: 10px;
  border: 1px solid #30363d;
  background: var(--panel);
  color: var(--text);
  margin-bottom: 16px;
}

#pin-input:focus {
  outline: 2px solid var(--ane-500);
}

#pin-submit {
  width: 100%;
  min-height: 44px;
  font-size: 1.1rem;
  padding: 14px;
  border-radius: 10px;
  border: none;
  background: var(--ane-action-500);
  color: #fff;
  font-weight: 600;
  transition: transform 150ms ease-out, filter 150ms ease-out;
}

#pin-submit:active {
  transform: scale(0.98);
  filter: brightness(0.92);
}

.error {
  color: var(--danger);
  margin-top: 16px;
  font-size: 0.95rem;
}

/* Main screen */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  background: var(--panel);
  border-bottom: 2px solid var(--ane-500);
}

.brand {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.brand-mark {
  font-weight: 800;
  letter-spacing: 0.06em;
  color: var(--ane-500);
  font-size: 0.85rem;
}

.live-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--danger);
  animation: pulse 1.6s ease-in-out infinite;
}

/* Language bar — two native <select> chips + a swap button. Native select
   (not a custom dropdown) is deliberate: free accessible picker UI on every
   phone OS, zero custom popover/keyboard-trap code to get wrong. */
.lang-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  flex: 1;
  justify-content: flex-end;
}

.lang-chip {
  min-width: 0;
  flex: 1;
  max-width: 128px;
}

.lang-chip select {
  width: 100%;
  min-height: 40px;
  padding: 8px 10px;
  border-radius: 20px;
  border: 1px solid #30363d;
  background: var(--panel);
  color: var(--text);
  font-size: 0.85rem;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
}

.swap-btn {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid #30363d;
  background: transparent;
  color: var(--ane-500);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 200ms ease-out, background-color 200ms ease-out;
}

.swap-btn svg {
  width: 18px;
  height: 18px;
}

.swap-btn:active {
  transform: rotate(180deg);
  background: var(--bg);
}

.lang-bar.locked select,
.lang-bar.locked .swap-btn {
  opacity: 0.5;
  pointer-events: none;
}

.reconnect {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  color: #e3b341;
  font-size: 0.85rem;
  background: rgba(227, 179, 65, 0.08);
}

.reconnect-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  animation: pulse 1.2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

/* Split screen — top half = source language as spoken, bottom half = the
   translation the reader actually needs. Each pane scrolls independently. */
.captions-split {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.pane {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.pane-translated {
  border-top: 2px solid var(--ane-500);
}

.pane-label {
  flex-shrink: 0;
  padding: 6px 16px;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  background: var(--panel);
}

.captions {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.captions:empty::before {
  content: attr(data-empty);
  color: var(--muted);
  font-style: italic;
  font-size: 0.9rem;
}

.caption-line {
  animation: caption-in 300ms ease-out;
  line-height: 1.4;
}

/* original pane = smaller/muted (source-language reference); translated pane =
   larger/bold/near-white (the payload the reader actually needs) — weight+size
   contrast carries the hierarchy instead of color, so it still reads correctly
   if someone is color-blind. */
.pane-original .caption-line {
  font-size: 1.05rem;
  color: var(--muted);
}

.pane-translated .caption-line {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text);
}

.caption-line.live {
  opacity: 0.75;
  font-style: italic;
}

@keyframes caption-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
  .caption-line, .live-dot, .reconnect-dot, .fab-ring {
    animation: none;
  }
}

#mic-error {
  margin: 0 16px 12px;
}

/* Footer — big circular mic FAB (learned from Google/Microsoft live-translate
   conversation mode): tap to toggle, pulsing ring + audio-reactive bars while
   listening, elapsed timer so a lecturer-length session doesn't feel silent
   or stuck. Label lives outside the button so the FAB stays a true circle. */
.controls {
  padding: 14px 16px;
  padding-bottom: max(14px, env(safe-area-inset-bottom));
  background: var(--panel);
  border-top: 1px solid #30363d;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.rec-status {
  display: flex;
  align-items: center;
  gap: 14px;
  height: 24px;
}

.rec-timer {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: var(--danger);
  font-size: 0.95rem;
}

.rec-bars {
  display: flex;
  align-items: center;
  gap: 3px;
  height: 24px;
}

.rec-bars span {
  width: 4px;
  height: 6px;
  border-radius: 2px;
  background: var(--danger);
  transition: height 90ms ease-out;
}

.fab {
  position: relative;
  width: 84px;
  height: 84px;
  border-radius: 50%;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  transition: background-color 200ms ease-out, transform 150ms ease-out;
}

.fab:active {
  transform: scale(0.96);
}

/* Start = ANE CTA orange (an invitation to act); Stop = red (recording is
   active, handle with care) — see :root comment for why Stop isn't orange too. */
.fab.start {
  background: var(--ane-action-500);
}

.fab.stop {
  background: var(--danger);
}

.fab-ring {
  position: absolute;
  inset: -8px;
  border-radius: 50%;
  border: 2px solid var(--danger);
  opacity: 0;
}

.fab.stop .fab-ring {
  animation: fab-pulse 1.6s ease-out infinite;
}

@keyframes fab-pulse {
  0% { opacity: 0.6; transform: scale(1); }
  100% { opacity: 0; transform: scale(1.45); }
}

.btn-icon {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
}

.fab-label {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--muted);
}
