/* Prevod — tablet page. Exercise-book look (light) or chalkboard (dark).
   Written for Chrome on Android 9 tablets (~1200×800), both orientations. */

:root {
  --paper: #f8fafc;
  --rule: #dbe5ef;          /* ruled lines of the exercise book */
  --margin: #e5a1a8;        /* red margin rule */
  --ink-ru: #16325c;        /* fountain-pen blue: the Russian text */
  --ink-sr: #5c6b7a;        /* slate: the Serbian text */
  --ink-ui: #1f2933;
  --bar: #ffffff;
  --bar-line: #d7dee6;
  --live: #2f7d5b;
  --pause: #b7791f;
  --alert: #b23a48;
  --fresh: #fff4c7;         /* highlighter on the newest line */
  --pending: #9aa7b4;
  --btn: #eef3f8;
  --btn-ink: #16325c;

  --fs: 28px;               /* Russian size; set from settings */
  --fs-sr: calc(var(--fs) * 0.74);
  --app-h: 100%;
}

html[data-theme="board"] {
  --paper: #1f3a30;
  --rule: #2a4a3e;
  --margin: #6c4a45;
  --ink-ru: #f3f5ef;
  --ink-sr: #a8c1b4;
  --ink-ui: #e8efe9;
  --bar: #183027;
  --bar-line: #2d5044;
  --live: #7fd3a8;
  --pause: #f0c068;
  --alert: #f08a8a;
  --fresh: #2e5446;
  --pending: #7d9a8c;
  --btn: #28493c;
  --btn-ink: #f3f5ef;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%; overflow: hidden;
  background: var(--paper); color: var(--ink-ui);
  font-family: Roboto, "Noto Sans", "Segoe UI", Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* ---------- app frame ---------- */
#app { height: var(--app-h); display: flex; flex-direction: column; }

.topbar {
  flex: none; display: flex; align-items: center; gap: 12px;
  padding: 8px 12px 8px 20px; min-height: 64px;
  background: var(--bar); border-bottom: 1px solid var(--bar-line);
}
.subject { flex: 1; min-width: 0; line-height: 1.15; }
.subject .ru { font-size: 22px; font-weight: 600; color: var(--ink-ru); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.subject .sr { font-size: 15px; color: var(--ink-sr); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.status {
  flex: none; display: flex; align-items: center; gap: 8px;
  font-size: 16px; font-weight: 500; padding: 6px 12px; border-radius: 18px;
  background: var(--btn); color: var(--ink-ui); white-space: nowrap;
}
.status .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--pending); }
.status[data-kind="live"] .dot { background: var(--live); animation: pulse 2s ease-in-out infinite; }
.status[data-kind="pause"] { color: var(--pause); }
.status[data-kind="pause"] .dot { background: var(--pause); border-radius: 2px; }
.status[data-kind="alert"] { color: var(--alert); }
.status[data-kind="alert"] .dot { background: var(--alert); }
@keyframes pulse { 50% { opacity: .35; } }
@media (prefers-reduced-motion: reduce) { .status .dot { animation: none !important; } }

.tools { flex: none; display: flex; gap: 6px; }
.icon-btn {
  width: 48px; height: 48px; border: 0; border-radius: 12px; background: var(--btn); color: var(--btn-ink);
  font-size: 20px; font-weight: 600; display: flex; align-items: center; justify-content: center; cursor: pointer;
}
.icon-btn:active { filter: brightness(.92); }
.icon-btn:focus-visible, .btn:focus-visible, .choice button:focus-visible { outline: 3px solid var(--ink-ru); outline-offset: 2px; }
.icon-btn svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.banner {
  flex: none; padding: 8px 20px; font-size: 16px; background: var(--alert); color: #fff;
}

/* ---------- the exercise-book page ---------- */
.page-wrap { flex: 1; min-height: 0; position: relative; }
.page {
  position: absolute; top: 0; right: 0; bottom: 0; left: 0; overflow-y: auto; overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 16px 24px 24px 56px;
  background-image: linear-gradient(to right, transparent 39px, var(--margin) 39px, var(--margin) 41px, transparent 41px);
  background-attachment: local;
}

.line {
  border-bottom: 1px solid var(--rule);
  padding: 12px 8px 14px 8px;
  border-radius: 4px;
  transition: background-color 1.5s ease;
}
.line.fresh { background: var(--fresh); transition: none; }
.line .ru { font-size: var(--fs); line-height: 1.35; color: var(--ink-ru); }
.line .sr { font-size: var(--fs-sr); line-height: 1.4; color: var(--ink-sr); margin-top: 4px; }
.line .ru.pending::after {
  content: "…"; color: var(--pending); letter-spacing: 2px;
}
.line .ru.pending { color: var(--pending); }
.line .ru.none { display: none; }
.pause-mark {
  margin: 10px 8px; font-size: calc(var(--fs-sr) * .9); color: var(--pause);
  border-top: 2px dashed var(--pause); padding-top: 6px; opacity: .85;
}

/* Side by side: Russian left, Serbian right, rows aligned. */
html[data-cols="2"] .line { display: grid; grid-template-columns: 1.15fr 1fr; column-gap: 32px; align-items: start; }
html[data-cols="2"] .line .sr { margin-top: 0; padding-top: calc((var(--fs) - var(--fs-sr)) * .45); border-left: 1px solid var(--rule); padding-left: 24px; }
html[data-cols="2"] .pause-mark { grid-column: 1 / -1; }

html[data-show-sr="0"] .line .sr { display: none; }
html[data-show-sr="0"] .line { display: block; }
html[data-show-sr="0"] .live { display: none; }

.empty {
  max-width: 34em; margin: 12vh auto 0; text-align: center; color: var(--ink-sr); font-size: 22px; line-height: 1.5;
}
.empty .ru { color: var(--ink-ru); font-size: 26px; margin-bottom: 8px; }

/* ---------- live strip: what the teacher is saying right now ---------- */
.live {
  flex: none; min-height: 64px; max-height: 30%; overflow: hidden;
  display: flex; align-items: flex-start; gap: 12px;
  padding: 12px 24px 14px 56px; border-top: 1px solid var(--bar-line); background: var(--bar);
}
.live .mic { flex: none; width: 12px; height: 12px; margin-top: calc(var(--fs-sr) * .45); border-radius: 50%; background: var(--live); animation: pulse 1.2s ease-in-out infinite; }
.live .text {
  font-size: var(--fs-sr); line-height: 1.4; color: var(--ink-sr); font-style: italic;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.live.idle .mic { background: var(--pending); animation: none; }
.live.paused { background: var(--pause); border-top-color: var(--pause); }
.live.paused .mic { display: none; }
.live.paused .text { color: #fff; font-style: normal; font-size: 22px; }

.jump {
  position: absolute; right: 24px; bottom: 16px; z-index: 2;
  border: 0; border-radius: 28px; padding: 14px 22px; font-size: 18px; font-weight: 600;
  background: var(--ink-ru); color: var(--paper); box-shadow: 0 4px 14px rgba(20, 40, 70, .25); cursor: pointer;
}

/* ---------- join screen ---------- */
.join {
  height: var(--app-h); display: flex; align-items: center; justify-content: center; padding: 24px;
  background-image: linear-gradient(to right, transparent 39px, var(--margin) 39px, var(--margin) 41px, transparent 41px),
                    repeating-linear-gradient(to bottom, transparent 0, transparent 47px, var(--rule) 47px, var(--rule) 48px);
}
.join form { width: 100%; max-width: 460px; }
.join h1 { font-size: 34px; font-weight: 600; color: var(--ink-ru); margin: 0 0 4px; line-height: 1.2; }
.join p.sr { font-size: 18px; color: var(--ink-sr); margin: 0 0 28px; }
.join input {
  width: 100%; font: inherit; font-size: 40px; letter-spacing: 8px; text-align: center; padding: 14px 12px;
  border: 2px solid var(--bar-line); border-radius: 14px; background: var(--bar); color: var(--ink-ru);
}
.join input:focus { outline: none; border-color: var(--ink-ru); }
.join .error { color: var(--alert); font-size: 18px; min-height: 28px; margin: 10px 2px 0; }
.btn {
  display: block; width: 100%; margin-top: 12px; border: 0; border-radius: 14px; padding: 18px;
  font-size: 22px; font-weight: 600; background: var(--ink-ru); color: var(--paper); cursor: pointer;
}
.btn[disabled] { opacity: .5; }
.join > div { width: 100%; max-width: 460px; }
.pick-list { display: flex; flex-direction: column; gap: 4px; }
.pick-btn { font-size: 28px; padding: 22px; }
.link-btn {
  display: block; margin: 18px auto 0; border: 0; background: none; color: var(--ink-sr); font: inherit;
  font-size: 18px; padding: 8px 12px; cursor: pointer; text-decoration: underline; text-underline-offset: 4px;
}

/* ---------- settings sheet ---------- */
.sheet-bg { position: fixed; top: 0; right: 0; bottom: 0; left: 0; background: rgba(15, 25, 35, .45); z-index: 10; display: flex; align-items: flex-end; justify-content: center; }
.sheet {
  width: 100%; max-width: 640px; max-height: 92%; overflow-y: auto; background: var(--bar); color: var(--ink-ui);
  border-radius: 20px 20px 0 0; padding: 20px 24px 28px;
}
.sheet h2 { margin: 0 0 16px; font-size: 24px; color: var(--ink-ru); }
.row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 0; border-bottom: 1px solid var(--bar-line); }
.row:last-of-type { border-bottom: 0; }
.row .label { font-size: 19px; }
.row .label small { display: block; font-size: 14px; color: var(--ink-sr); }
.choice { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.choice button {
  border: 2px solid var(--bar-line); background: var(--paper); border-radius: 10px; padding: 10px 14px; font-size: 17px; cursor: pointer; min-width: 48px;
}
.choice button[aria-pressed="true"] { border-color: var(--ink-ru); background: var(--ink-ru); color: var(--paper); }
.sheet .btn.secondary { background: var(--btn); color: var(--btn-ink); }
.sheet .meta { margin-top: 14px; font-size: 13px; color: var(--ink-sr); text-align: center; }

/* ---------- smaller or portrait screens ---------- */
@media (max-width: 700px) {
  .topbar { padding-left: 12px; gap: 8px; }
  .status .label-long { display: none; }
  .page { padding-left: 44px; padding-right: 12px; }
  .page, .join { background-image: linear-gradient(to right, transparent 27px, var(--margin) 27px, var(--margin) 29px, transparent 29px); }
  .live { padding-left: 44px; }
}
