/* Eshit: live captions for deaf and hard-of-hearing people, often elderly. Its own look, not a client brand:
   high contrast, large type, and the phone's own light or dark setting. Every value lives in :root; the dark block
   changes colours only. Every text and border colour is checked against the surface behind it (WCAG 2.2 AA,
   docs/ui/1-finding-patterns.md). The phone's own fonts: the CSP in _headers loads none. */
:root {
  color-scheme: light dark;
  --bg: #ffffff;
  --surface: #eef1f5;
  --text: #111418;
  --text-2: #4a5058;
  --line: #6b7280;
  --accent: #0a49c4;
  --on-accent: #ffffff;
  --stop: #a4161a;
  --on-stop: #ffffff;
  --error: #8c1d18;
  --error-bg: #fdecea;
  --backdrop: rgba(17, 20, 24, .6);

  --sans: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --fs-small: 16px;
  --fs: 20px;
  --fs-btn: 22px;
  --fs-big: 24px;
  --fs-title: 28px;
  --fs-main: 30px;
  --harf: 32px; /* caption size: 24–64, chosen in the settings (app.js) */

  --gutter: 16px;
  --tap: 56px;
  --tap-main: 88px;
  --pill: 999px;
  --box: 16px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --surface: #16191d;
    --text: #f5f7fa;
    --text-2: #b4bac2;
    --line: #7b8390;
    --accent: #9cc0ff;
    --on-accent: #06224d;
    --stop: #f6aea9;
    --on-stop: #410e0b;
    --error: #ffb4ab;
    --error-bg: #2a0a08;
    --backdrop: rgba(0, 0, 0, .75);
  }
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 400 var(--fs)/1.4 var(--sans); }
h1, h2, p { margin: 0; }
button, input, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.ic { width: 24px; height: 24px; flex: none; }
.noscript { margin: 24px var(--gutter); font-size: var(--fs-big); }

/* The page holder: one screen, never scrolled. Only the captions scroll, so the main button stays in reach. */
.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  max-width: 960px;
  margin-inline: auto;
  padding: env(safe-area-inset-top) max(var(--gutter), env(safe-area-inset-right)) env(safe-area-inset-bottom) max(var(--gutter), env(safe-area-inset-left));
}

.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-block: 8px; }
.brand { display: flex; align-items: center; gap: 12px; font-size: var(--fs-title); font-weight: 800; line-height: 1.2; }
.brand-mark { width: 36px; height: 36px; border-radius: 8px; }

.main { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 12px; padding-bottom: 12px; }

/* Captions: the accuracy note stays above; the lines scroll, the newest at the bottom. */
.captions { flex: 1; min-height: 0; display: flex; flex-direction: column; border-radius: var(--box); background: var(--surface); }
.note { margin: 0 16px; padding: 12px 0 8px; border-bottom: 1px solid var(--line); color: var(--text-2); font-size: var(--fs-small); }
.scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 8px 16px 16px;
  border-radius: 0 0 var(--box) var(--box);
  font-size: var(--harf);
  font-weight: 600;
  line-height: 1.3;
  overflow-wrap: anywhere;
}
.lines > p { margin: 0 0 .4em; }
.partial { color: var(--text-2); }

.status { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 12px; }
.status .error { flex-basis: 100%; }
.status-line { font-weight: 700; }
.muted { color: var(--text-2); font-size: var(--fs-small); }
.error { padding: 12px 16px; border-left: 6px solid var(--error); border-radius: 12px; background: var(--error-bg); color: var(--error); font-weight: 600; line-height: 1.35; }

/* Buttons: one base, a fill or a line, never smaller than --tap. */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-height: var(--tap);
  padding: 8px 24px;
  border: 2px solid transparent;
  border-radius: var(--pill);
  background: transparent;
  color: var(--text);
  font-size: var(--fs-btn);
  font-weight: 700;
  line-height: 1.2;
  text-align: center;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background-color .15s, border-color .15s, color .15s;
}
.btn[aria-disabled="true"] { opacity: .55; cursor: default; }
.btn-line { border-color: var(--line); }
.btn-line:hover, .btn-line[aria-pressed="true"] { background: var(--surface); }
.btn-line[aria-pressed="true"] { border-color: var(--accent); }
.btn-accent { background: var(--accent); color: var(--on-accent); }
.btn-main { width: 100%; min-height: var(--tap-main); background: var(--accent); color: var(--on-accent); font-size: var(--fs-main); font-weight: 800; }
.btn-main .ic { width: 36px; height: 36px; }
.btn-main .ic-stop, .btn-main.on .ic-mic { display: none; }
.btn-main.on .ic-stop { display: block; }
.btn-main.on { background: var(--stop); color: var(--on-stop); }
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.actions .btn { padding-inline: 12px; }

.foot { padding-bottom: 12px; color: var(--text-2); font-size: var(--fs-small); }

/* Overlays: full screen on a phone; on a wide screen a window in the middle (the full-screen text stays full). */
dialog { border: 0; padding: 0; background: var(--bg); color: var(--text); }
dialog::backdrop { background: var(--backdrop); }
.sheet, .full { width: 100%; height: 100%; max-width: none; max-height: none; margin: 0; }
.sheet {
  padding: max(16px, env(safe-area-inset-top)) max(var(--gutter), env(safe-area-inset-right)) max(24px, env(safe-area-inset-bottom)) max(var(--gutter), env(safe-area-inset-left));
  overflow-y: auto;
  overscroll-behavior: contain;
}
@media (min-width: 760px) and (min-height: 600px) {
  .sheet { width: min(640px, 100% - 64px); height: fit-content; max-height: calc(100% - 64px); margin: auto; padding: 24px 32px 32px; border: 2px solid var(--line); border-radius: 24px; }
}
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 24px; }
.sheet-head h2 { font-size: var(--fs-title); font-weight: 800; line-height: 1.2; }
.x { display: grid; place-items: center; flex: none; width: var(--tap); height: var(--tap); padding: 0; border: 2px solid var(--line); border-radius: var(--pill); background: transparent; color: var(--text); cursor: pointer; }
.x:hover { background: var(--surface); }
.x .ic { width: 28px; height: 28px; }

.reply { display: block; width: 100%; min-height: 168px; padding: 12px 16px; border: 2px solid var(--line); border-radius: var(--box); background: var(--bg); font-size: var(--fs-big); line-height: 1.35; resize: vertical; }
.sheet .error { margin-top: 12px; }
.sheet-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 16px; }

.phrases { display: grid; gap: 12px; margin: 0; padding: 0; list-style: none; }
.phrase { width: 100%; min-height: 72px; justify-content: flex-start; padding: 12px 20px; border-radius: var(--box); font-size: var(--fs-big); text-align: left; }

/* The full-screen text: app.js picks the largest size that fits; «Aylantir» turns the text, not the buttons. */
.full {
  padding: max(12px, env(safe-area-inset-top)) max(var(--gutter), env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(var(--gutter), env(safe-area-inset-left));
  overflow: hidden;
}
.full[open] { display: flex; flex-direction: column; gap: 12px; }
.full-head { display: flex; justify-content: flex-end; }
.full-box { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.full-text { width: 100%; font-size: 64px; font-weight: 800; line-height: 1.15; text-align: center; overflow-wrap: break-word; transition: transform .3s; }
/* Measured with whole words (app.js keeps a pixel beside the widest one), so break-word only splits a word that is
   wider than the screen even at the smallest size. */
.full-text.olcham { overflow-wrap: normal; }
.full-text.turned { transform: rotate(180deg); }
.full .error { flex: none; }
.full-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.group { min-width: 0; margin: 0 0 24px; padding: 0; border: 0; }
.group legend { margin-bottom: 12px; padding: 0; font-weight: 700; }
.stepper { display: flex; align-items: center; gap: 16px; }
.stepper .btn { min-width: 96px; font-size: var(--fs-title); }
.stepper-value { min-width: 3ch; font-size: var(--fs-title); font-weight: 800; text-align: center; font-variant-numeric: tabular-nums; }
.choices { display: grid; gap: 12px; }
.choice { position: relative; display: block; }
.choice input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.choice span { display: flex; align-items: center; gap: 12px; min-height: var(--tap); padding: 8px 16px; border: 2px solid var(--line); border-radius: var(--box); font-weight: 600; }
.choice span::before { content: ''; flex: none; width: 24px; height: 24px; border: 2px solid currentColor; border-radius: 50%; }
.choice input:checked + span { border-color: var(--accent); background: var(--accent); color: var(--on-accent); }
.choice input:checked + span::before { border-width: 7px; }
.choice input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 3px; }
.sample { padding: 12px 16px; border-radius: var(--box); background: var(--surface); font-size: var(--harf); font-weight: 600; line-height: 1.3; overflow-wrap: anywhere; }

/* Turnstile's check (public/tekshiruv.js). While it needs nothing from the user it is an invisible window that is not
   modal and lets every tap through, so the page and «Töxtat» stay usable; it is opened modal, as a small window with a
   close button and a backdrop, only when Turnstile asks for a click. */
.check { margin: auto; background: transparent; overflow: visible; }
.check:not(.seen) { position: fixed; inset: 0; pointer-events: none; }
.check > .x { display: none; }
.check.seen { padding: 16px; border-radius: var(--box); background: var(--bg); }
.check.seen::backdrop { background: var(--backdrop); }
.check.seen > .x { display: grid; margin: 0 0 12px auto; }

/* A short screen (a small phone, or a browser's own bars): the captions keep the room, the controls get tighter. */
@media (max-height: 700px) {
  .top { padding-block: 4px; }
  .main { gap: 8px; padding-bottom: 8px; }
  .note { padding-top: 8px; }
  .btn-main { min-height: 64px; }
}

/* A phone on its side: captions on the left, the controls on the right, so both fit without scrolling. */
@media (orientation: landscape) and (max-height: 560px) {
  .top { padding-block: 4px; }
  .main { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); grid-template-rows: 1fr auto auto; gap: 12px 16px; }
  .captions { grid-column: 1; grid-row: 1 / 4; }
  .status { grid-column: 2; grid-row: 1; align-self: end; }
  .btn-main { grid-column: 2; grid-row: 2; min-height: 72px; }
  .actions { grid-column: 2; grid-row: 3; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
