/* Teleprompter4u licensed reading-screen PWA.
   Brand-aligned: deep navy reading stage, sky-blue accent, large high-contrast
   lines. Sinhala renders via Noto Sans Sinhala. Self-contained so the service
   worker only ever caches this one stylesheet. */

:root {
  color-scheme: dark;
  --bg: #0a2c47;
  --bg-2: #0b3a5c;
  --panel: rgba(255, 255, 255, 0.05);
  --panel-line: rgba(143, 196, 230, 0.18);
  --text: #ffffff;
  --muted: #9cc3de;
  --accent: #0ea5e9;
  --accent-warm: #f7a872;
  --good: #34d399;
  --line-size: 40px;
  --ui: "Figtree", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --read: "Noto Sans", "Noto Sans Sinhala", -apple-system, system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }

body {
  margin: 0;
  background:
    radial-gradient(1200px 600px at 80% -10%, #114a73 0%, rgba(17, 74, 115, 0) 60%),
    linear-gradient(180deg, var(--bg-2), var(--bg));
  color: var(--text);
  font-family: var(--ui);
  -webkit-font-smoothing: antialiased;
}

button {
  min-width: 44px;
  min-height: 36px;
  border: 1px solid var(--panel-line);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}
button:hover { background: rgba(255, 255, 255, 0.12); border-color: var(--accent); }

.hidden { display: none !important; }

/* ---------- App shell ---------- */
/* Once connected, the reading view is pure high-contrast black so the lines are
   legible from across a room. The join gate keeps the branded navy look. */
.app {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  grid-template-rows: auto 1fr;
  background: #000000;
}

.toolbar {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 16px;
  align-items: center;
  min-height: 60px;
  padding: 11px 18px;
  padding-top: max(11px, env(safe-area-inset-top));
  border-bottom: 1px solid #1c1c1c;
  background: #000000;
}

.brand { display: inline-flex; align-items: center; gap: 9px; }
.brand-mark { display: block; border-radius: 7px; }
.brand-text { font-weight: 800; font-size: 16px; letter-spacing: -0.01em; color: #fff; }
.brand-accent { color: #6fc6f0; }

/* ---------- Single neutral connection indicator ---------- */
.status { display: flex; justify-content: center; min-width: 0; }
.conn {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 6px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid #2a2a2a;
  color: #c7c7c7;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}
.conn-dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--accent-warm);
}
.conn.good { color: #d6f5e6; }
.conn.good .conn-dot {
  background: var(--good);
  box-shadow: 0 0 0 0 rgba(52, 211, 153, 0.5);
  animation: pulse 2s infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0.5); }
  70% { box-shadow: 0 0 0 7px rgba(52, 211, 153, 0); }
  100% { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0); }
}
@media (prefers-reduced-motion: reduce) { .conn.good .conn-dot { animation: none; } }

.actions { display: flex; gap: 8px; align-items: center; }

.pill.remaining {
  display: inline-flex; align-items: center; min-height: 28px; padding: 0 12px;
  border-radius: 999px; font-size: 13px; font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: #d6ecfb; background: rgba(14, 165, 233, 0.16); border: 1px solid rgba(14, 165, 233, 0.3);
}
.pill.remaining.warn { color: #ffe6c2; background: rgba(247, 168, 114, 0.16); border-color: rgba(247, 168, 114, 0.34); }
.pill.remaining.bad { color: #ffd9d6; background: rgba(248, 113, 113, 0.18); border-color: rgba(248, 113, 113, 0.36); }

/* ---------- Reading stage ---------- */
.stage {
  position: relative;
  overflow: auto;
  overflow-anchor: none;
  scroll-behavior: auto;
  padding: 30px clamp(18px, 3vw, 48px) 76px;
}
.lines {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 30px;
  margin: 0 auto;
  max-width: 1100px;
}
.line {
  padding-bottom: 26px;
  border-bottom: 1px solid #1f1f1f;
  scroll-margin-bottom: 76px;
}
.line.interim { opacity: 0.6; }

/* High-contrast reading: white source, bright-yellow translation, both large. */
.original, .translation { margin: 0; overflow-wrap: anywhere; font-family: var(--read); }
.original {
  font-size: var(--line-size);
  line-height: 1.25;
  font-weight: 600;
  color: #ffffff;
}
.translation {
  margin-top: 12px;
  font-size: var(--line-size);
  line-height: 1.28;
  font-weight: 700;
  color: #ffd23f;
}
.meta {
  margin-top: 14px;
  color: #6e6e6e;
  font-family: var(--ui);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.empty {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  color: #777; font-size: 22px; font-weight: 500;
  z-index: 1;
}
.empty.hidden { display: none; }

/* ---------- Watermark overlay ---------- */
.watermark {
  position: absolute; inset: 0; z-index: 3;
  pointer-events: none; user-select: none;
  opacity: 0.08;
  background-image: var(--wm-tile, none);
  background-repeat: repeat;
  transform: rotate(-30deg) scale(1.6);
  transform-origin: center;
  mix-blend-mode: screen;
}

/* ---------- Join / code-entry gate ---------- */
.join {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background:
    radial-gradient(1000px 520px at 50% -10%, #114a73 0%, rgba(17, 74, 115, 0) 60%),
    linear-gradient(180deg, var(--bg-2), var(--bg));
  z-index: 20;
  padding: env(safe-area-inset-top) 16px env(safe-area-inset-bottom);
}
.join.hidden { display: none !important; }

.join-card {
  width: min(440px, 92vw);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--panel-line);
  border-radius: 18px;
  padding: 34px 30px;
  text-align: center;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
}
.join-brand { display: inline-flex; align-items: center; gap: 10px; margin-bottom: 18px; }
.join-brand .brand-text { font-size: 18px; }
.join-card h1 { font-family: var(--ui); font-size: 22px; margin: 0 0 6px; color: #fff; letter-spacing: -0.01em; }
.join-card p { color: var(--muted); font-size: 14.5px; margin: 0 0 22px; }

.join-card input {
  width: 100%;
  font-family: var(--ui);
  font-size: 27px; font-weight: 700;
  letter-spacing: 0.22em;
  text-align: center; text-transform: uppercase;
  padding: 15px;
  border-radius: 12px;
  border: 1px solid var(--panel-line);
  background: rgba(0, 0, 0, 0.22);
  color: #fff;
}
.join-card input:focus { outline: 3px solid rgba(14, 165, 233, 0.4); border-color: var(--accent); }

.join-card button {
  margin-top: 14px; width: 100%; padding: 14px;
  font-family: var(--ui); font-size: 16px; font-weight: 700;
  border: none; border-radius: 12px;
  background: linear-gradient(180deg, #0ea5e9, #0369a1);
  color: #fff; cursor: pointer;
}
.join-card button:hover { opacity: 0.94; }
.join-card button.install {
  background: transparent;
  border: 1px solid var(--panel-line);
  color: var(--muted); font-weight: 600;
}
.join-error { color: #ff9a8f; font-size: 13.5px; min-height: 18px; margin-top: 12px; }
.install-hint { color: var(--muted); font-size: 12.5px; margin: 12px 0 0; }

/* ---------- Bump / generic modal ---------- */
.modal {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: rgba(5, 20, 33, 0.8);
  z-index: 40; padding: 16px;
}
.modal.hidden { display: none !important; }
.modal-card {
  width: min(420px, 92vw);
  background: var(--bg-2);
  border: 1px solid var(--panel-line);
  border-radius: 18px;
  padding: 30px 28px; text-align: center;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
}
.modal-card h2 { font-family: var(--ui); margin: 0 0 8px; font-size: 20px; color: #fff; }
.modal-card p { margin: 0 0 22px; color: var(--muted); font-size: 14.5px; line-height: 1.5; }
.modal-card button.primary {
  width: 100%; padding: 14px;
  font-family: var(--ui); font-size: 16px; font-weight: 700;
  border: none; border-radius: 12px;
  background: linear-gradient(180deg, #0ea5e9, #0369a1); color: #fff; cursor: pointer;
}

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  max-width: min(520px, 92vw);
  z-index: 50;
  padding: 13px 20px; border-radius: 12px;
  background: rgba(247, 168, 114, 0.18); color: #ffe6c2;
  border: 1px solid rgba(247, 168, 114, 0.34);
  font-size: 14.5px; font-weight: 600;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.45);
  text-align: center;
  backdrop-filter: blur(6px);
}
.toast.bad { background: rgba(248, 113, 113, 0.2); color: #ffd9d6; border-color: rgba(248, 113, 113, 0.4); }
.toast.hidden { display: none !important; }

/* ---------- Responsive ---------- */
@media (max-width: 760px) {
  .toolbar { grid-template-columns: auto auto; row-gap: 10px; }
  .status { grid-column: 1 / -1; order: 3; justify-content: flex-start; }
  .stage { padding: 22px 16px 60px; }
  .original { font-size: calc(var(--line-size) * 0.66); }
  .translation { font-size: calc(var(--line-size) * 0.72); }
}
