/* linara-dolmetscher — Oberflaeche.
 *
 * Gestaltungsgedanke: Das Geraet liegt zwischen zwei Menschen auf dem Tisch.
 * Die eine Frage, die diese App jederzeit beantworten muss, ist nicht "wie
 * heisst das auf Deutsch", sondern "hoert sie mich gerade?". Deshalb ist das
 * Merkmal dieser Oberflaeche der atmende Ring um den Knopf: er folgt dem echten
 * Eingangspegel. Bewegt er sich, wird gehoert. Bewegt er sich nicht, ist etwas
 * kaputt — und dann uebernimmt die Weiter-Flaeche den ganzen Bildschirm.
 * Alles andere bleibt bewusst still, damit dieser eine Hinweis traegt.
 *
 * Farben kommen ausnahmslos aus dem Mandanten-Datensatz (--c-*), gesetzt von
 * app.js. In dieser Datei steht KEIN Markenwert — sonst waere ein dritter
 * Mandant wieder eine Codeaenderung.
 *
 * Schrift: bewusst der System-Stack. Die App zeigt Polnisch, Rumaenisch,
 * Ukrainisch, Bulgarisch — bei einer Webschrift waere jede fehlende Glyphe ein
 * Kaestchen mitten im Satz, und nachladen kostet Zeit, die beim ersten
 * Untertitel fehlt. Der System-Stack deckt alle diese Schriften sicher ab.
 */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --c-bg: #f7f6f4;
  --c-surface: #ffffff;
  --c-border: #e5e2dd;
  --c-text: #20242b;
  --c-text-dim: #6f7787;
  --c-brand: #2f3846;
  --c-brand-text: #ffffff;
  --c-live: #1f9d55;
  --c-live-text: #ffffff;
  --c-stop: #b3261e;

  --level: 0;            /* 0..1, aus dem echten Mikrofonpegel */
  --gutter: 20px;
  --radius: 14px;

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
          system-ui, sans-serif;
}

html, body {
  height: 100%;
  overscroll-behavior: none;
}

body {
  font-family: var(--font);
  background: var(--c-bg);
  color: var(--c-text);
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  /* Keine Textauswahl beim Halten des Telefons — das ist ein Werkzeug, kein Dokument. */
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  max-width: 720px;
  margin: 0 auto;
  background: var(--c-bg);
}

/* ── Kopfzeile ─────────────────────────────────────────────────────────── */

header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: max(10px, env(safe-area-inset-top)) var(--gutter) 10px;
  background: var(--c-surface);
  border-bottom: 1px solid var(--c-border);
  flex-shrink: 0;
}

#logo {
  height: 34px;
  width: auto;
  max-width: 62%;
  object-fit: contain;
  object-position: left center;
}

/* Fallback, wenn ein Mandant (noch) kein Logo hinterlegt hat. */
#logo-text {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.2px;
  color: var(--c-brand);
}

/* Die Sprachwahl ist eine MÖGLICHKEIT, kein Torwaechter: klein, rechts,
 * jederzeit erreichbar — auch waehrend die Uebersetzung laeuft. */
#lang-pill {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border: 1px solid var(--c-border);
  border-radius: 999px;
  background: var(--c-bg);
  color: var(--c-text);
  font: inherit;
  font-size: 14px;
  font-weight: 650;
  letter-spacing: 0.4px;
  cursor: pointer;
  flex-shrink: 0;
}
#lang-pill:active { transform: scale(0.97); }
#lang-pill .swap { color: var(--c-text-dim); font-weight: 400; }

/* ── Inhaltsflaeche ────────────────────────────────────────────────────── */

main {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: var(--gutter);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Startzustand: Markenaussage + eine Anweisung. Keine Frage, kein Formular. */
#intro {
  margin: auto 0;
  text-align: center;
  padding: 8px 4px 24px;
}
#tagline {
  font-size: clamp(21px, 5.6vw, 27px);
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -0.4px;
  color: var(--c-brand);
  margin-bottom: 14px;
  text-wrap: balance;
}
#greeting {
  font-size: 16px;
  line-height: 1.5;
  color: var(--c-text-dim);
  max-width: 34ch;
  margin: 0 auto;
  text-wrap: pretty;
}

/* Sagt vorab, was ohnehin passiert: es muss nichts eingestellt werden. Das
 * nimmt der Sprachwahl oben rechts den Charakter einer offenen Pflichtfrage. */
#auto-note {
  margin-top: 18px;
  font-size: 14px;
  line-height: 1.45;
  color: var(--c-text-dim);
  opacity: 0.8;
}
#auto-note strong {
  color: var(--c-brand);
  font-weight: 700;
}

/* ── Untertitel-Strom ──────────────────────────────────────────────────── */

#feed {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Eine Aeusserung: das ORIGINAL klein als Herkunftsnachweis, die ÜBERSETZUNG
 * gross. Bewusst ungleich — in einem laufenden Gespraech liest man die
 * Uebersetzung; das Original belegt nur, woher sie kommt. */
.entry {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-left: 3px solid var(--c-brand);
  border-radius: var(--radius);
  padding: 12px 14px;
  animation: rise 0.18s ease-out;
}
.entry.to-own { border-left-color: var(--c-live); }

@keyframes rise {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  .entry { animation: none; }
}

.entry .tag {
  display: inline-block;
  font-size: 11px;
  font-weight: 750;
  letter-spacing: 1.1px;
  text-transform: uppercase;
  color: var(--c-text-dim);
  margin-bottom: 6px;
}
.entry .source {
  font-size: 14.5px;
  line-height: 1.4;
  color: var(--c-text-dim);
  margin-bottom: 7px;
}
.entry .target {
  font-size: clamp(23px, 5.6vw, 30px);
  font-weight: 600;
  line-height: 1.28;
  letter-spacing: -0.4px;
  color: var(--c-text);
  text-wrap: pretty;
}

/* Die noch vorlaeufige Zeile: sichtbar, aber klar als "noch nicht fertig"
 * markiert, damit niemand einen Halbsatz fuer das Ergebnis haelt. */
#partial {
  font-size: 16px;
  line-height: 1.45;
  font-style: italic;
  color: var(--c-text-dim);
  min-height: 1.45em;
  padding: 0 2px;
}
#partial:empty { display: none; }

/* ── Fusszeile: Status + der Knopf ─────────────────────────────────────── */

footer {
  flex-shrink: 0;
  padding: 14px var(--gutter) max(18px, env(safe-area-inset-bottom));
  background: var(--c-surface);
  border-top: 1px solid var(--c-border);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

#status {
  font-size: 14px;
  line-height: 1.4;
  text-align: center;
  color: var(--c-text-dim);
  min-height: 1.4em;
  text-wrap: pretty;
}
#status.warn { color: var(--c-stop); font-weight: 600; }

/* Der Knopf mit dem atmenden Ring. Der Ring ist ein eigenes Element hinter dem
 * Knopf, damit der Pegel nur seine transform/opacity aendert — das laeuft auf
 * dem Compositor und kostet den Hauptthread nichts, der zeitgleich Audio
 * verarbeitet. */
#action-wrap {
  display: grid;
  place-items: center;
  width: 100%;
}

#action-shell {
  position: relative;
  display: inline-grid;
}

/* Der Ring liegt als Kontur um den Knopf und uebernimmt dessen Form, weil er
 * an dessen Kasten haengt statt eine feste Groesse zu haben. */
#ring {
  position: absolute;
  inset: -9px;
  border-radius: 999px;
  border: 3px solid var(--c-live);
  opacity: 0;
  pointer-events: none;
  transform: scale(1);
}
/* Ausschlag bewusst klein: der Ring soll atmen, nicht springen — und er darf
 * bei voller Lautstaerke nicht in die Statuszeile darueber wachsen. */
body.live #ring {
  opacity: calc(0.22 + var(--level) * 0.5);
  transform: scale(calc(1 + var(--level) * 0.26));
  transition: transform 0.09s ease-out, opacity 0.09s ease-out;
}
@media (prefers-reduced-motion: reduce) {
  body.live #ring { transition: none; transform: scale(1.1); opacity: 0.35; }
}

#action {
  position: relative;
  min-width: 220px;
  min-height: 62px;
  padding: 0 30px;
  border: none;
  border-radius: 999px;
  background: var(--c-brand);
  color: var(--c-brand-text);
  font: inherit;
  font-size: 19px;
  font-weight: 650;
  letter-spacing: -0.2px;
  cursor: pointer;
  /* Bewusst NIE disabled: ein Knopf, der nicht mehr reagiert, waehrend die
   * Oberflaeche "laeuft" behauptet, ist der schlimmste Zustand. Auch waehrend
   * des Startens bricht ein Druck sauber ab. */
  transition: background 0.15s, transform 0.1s;
}
#action:active { transform: scale(0.97); }
#action:focus-visible { outline: 3px solid var(--c-live); outline-offset: 3px; }
body.live #action { background: var(--c-stop); color: #fff; }
body.starting #action { background: var(--c-text-dim); }

/* ── Weiter-Flaeche ────────────────────────────────────────────────────────
 *
 * Der wichtigste Bildschirm der App. Sie erscheint, sobald die Sitzung
 * unterbrochen wurde — Bildschirmsperre, App-Wechsel, toter Socket, stummes
 * Mikrofon. Sie nimmt den GANZEN Bildschirm ein, weil sie genau eine Aussage
 * hat: hier tippen, dann laeuft es weiter. Ein kleiner Hinweis irgendwo waere
 * genau die stille Leiche, die vermieden werden soll.
 */
#resume {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 32px;
  text-align: center;
  background: var(--c-brand);
  color: var(--c-brand-text);
  border: none;
  font: inherit;
  cursor: pointer;
  width: 100%;
}
body.interrupted #resume { display: flex; }

#resume .icon {
  width: 84px;
  height: 84px;
  border-radius: 999px;
  border: 3px solid currentColor;
  display: grid;
  place-items: center;
  font-size: 38px;
  opacity: 0.95;
  animation: beat 1.9s ease-in-out infinite;
}
@keyframes beat {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.07); }
}
@media (prefers-reduced-motion: reduce) {
  #resume .icon { animation: none; }
}

#resume .headline {
  font-size: clamp(27px, 7.2vw, 36px);
  font-weight: 700;
  letter-spacing: -0.6px;
  line-height: 1.2;
}
#resume .detail {
  font-size: 16.5px;
  line-height: 1.5;
  opacity: 0.85;
  max-width: 30ch;
  text-wrap: pretty;
}

/* ── Sprachwahl (Blatt von unten) ──────────────────────────────────────── */

#sheet {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: none;
  align-items: flex-end;
  background: rgba(12, 14, 18, 0.45);
}
body.sheet-open #sheet { display: flex; }

#sheet-panel {
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  background: var(--c-surface);
  border-radius: 20px 20px 0 0;
  padding: 20px var(--gutter) max(20px, env(safe-area-inset-bottom));
  max-height: 82dvh;
  overflow-y: auto;
  animation: slide-up 0.2s ease-out;
}
@keyframes slide-up {
  from { transform: translateY(14px); opacity: 0.6; }
  to   { transform: none; opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  #sheet-panel { animation: none; }
}

#sheet-panel h2 {
  font-size: 17px;
  font-weight: 700;
  margin-bottom: 4px;
}
#sheet-panel .hint {
  font-size: 14px;
  color: var(--c-text-dim);
  line-height: 1.45;
  margin-bottom: 14px;
}

.lang-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 8px;
}
.lang-option {
  padding: 13px 14px;
  border: 1px solid var(--c-border);
  border-radius: 12px;
  background: var(--c-bg);
  color: var(--c-text);
  font: inherit;
  font-size: 15.5px;
  font-weight: 550;
  text-align: left;
  cursor: pointer;
}
.lang-option[aria-pressed="true"] {
  border-color: var(--c-brand);
  background: var(--c-surface);
  box-shadow: inset 0 0 0 1px var(--c-brand);
  font-weight: 700;
}
.lang-option:active { transform: scale(0.98); }

#sheet-close {
  margin-top: 14px;
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: 12px;
  background: var(--c-brand);
  color: var(--c-brand-text);
  font: inherit;
  font-size: 16px;
  font-weight: 650;
  cursor: pointer;
}

/* ── Einstellungen im Sprachwahl-Blatt (bislang: Kopfhoerer-Modus) ────────
 * Eine eigene Ueberschrift braucht es nicht: die Trennlinie genuegt, um die
 * Einstellung optisch von der Sprachfrage abzusetzen, ohne einen zweiten
 * Bildschirm einzufuehren. */
.sheet-divider {
  height: 1px;
  background: var(--c-border);
  margin: 18px 0 14px;
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.setting-label {
  font-size: 15.5px;
  font-weight: 700;
  color: var(--c-text);
}

/* Der Preis steht direkt unter dem Schalter, nicht in einer separaten Hilfe —
 * wer die Folge erst nach dem Umlegen versteht, hat einen schlechten Schalter
 * vor sich. */
.setting-hint {
  margin-top: 6px;
  font-size: 13.5px;
  line-height: 1.45;
  color: var(--c-text-dim);
  text-wrap: pretty;
}

#headphone-toggle {
  flex-shrink: 0;
  border: none;
  background: none;
  padding: 4px;
  cursor: pointer;
}
.toggle-track {
  display: block;
  width: 46px;
  height: 28px;
  border-radius: 999px;
  background: var(--c-border);
  padding: 3px;
  transition: background 0.15s;
}
.toggle-thumb {
  display: block;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
  transition: transform 0.15s;
}
/* Angeschaltet = dieselbe Live-Farbe wie der aufnehmende Knopf: derselbe
 * Signalwert ("es passiert gerade etwas Ungewoehnliches") wie sonst im Betrieb. */
#headphone-toggle[aria-checked="true"] .toggle-track {
  background: var(--c-live);
}
#headphone-toggle[aria-checked="true"] .toggle-thumb {
  transform: translateX(18px);
}
#headphone-toggle:focus-visible {
  outline: 3px solid var(--c-live);
  outline-offset: 3px;
  border-radius: 999px;
}

/* ── Sperrbildschirm bei fehlendem Zugang ──────────────────────────────── */

#gate {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 32px;
  text-align: center;
  background: var(--c-bg);
}
body.no-access #gate { display: flex; }
#gate h2 { font-size: 22px; font-weight: 700; }
#gate p { font-size: 16px; line-height: 1.5; color: var(--c-text-dim); max-width: 32ch; }
