/* The church screen. Pure black, not the Riah grey: projectors show black as "off", so the words
   float. One column per language (one to three), big type sized for the back row. Latin text is
   Space Grotesk (Riah's UI face); Thai is the bundled Sarabun (type/type.css); other scripts fall
   back to the system fonts that carry Chinese, Burmese and Lao on every Mac and PC. */
:root {
  color-scheme: dark;
  --bg: #000;
  --ink: var(--riah-ink, #ededef);
  /* Words still being spoken: a step back from final, still easy to read from the back. */
  --soft: rgba(244, 244, 241, 0.78);
  --rule: rgba(255, 255, 255, 0.16);
  --scale: 1;
  --cols: 1fr 1fr;
  /* Text size by column count: two columns read from about 15 m on a 3 m wide screen. */
  --fs: calc(var(--scale) * min(6vh, 3.1vw));
  --gap: 5vw;
  --font: "Space Grotesk", "Sarabun", -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", "Helvetica Neue", Arial,
    "Sukhumvit Set", "Thonburi", "Leelawadee UI", "Noto Sans Thai",
    "PingFang SC", "PingFang TC", "Hiragino Sans", "Microsoft YaHei", "Noto Sans CJK SC",
    "Myanmar Sangam MN", "Myanmar Text", "Noto Sans Myanmar", "Lao Sangam MN", "Noto Sans Lao", sans-serif;
}

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
}

body.idle { cursor: none; }

.stage[data-cols="1"] { --fs: calc(var(--scale) * min(7.4vh, 4.2vw)); }
.stage[data-cols="3"] { --fs: calc(var(--scale) * min(4.8vh, 2.2vw)); --gap: 3.5vw; }

.stage {
  position: fixed;
  inset: 0;
  display: grid;
  grid-template-rows: auto 1fr;
  padding: 4.5vh 5vw 6vh;
  box-sizing: border-box;
}

.labels {
  display: grid;
  grid-template-columns: var(--cols);
  column-gap: var(--gap);
  padding-bottom: 1.4vh;
  color: var(--soft);
  font-size: calc(var(--fs) * 0.42);
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.stage.no-labels .labels { visibility: hidden; }
/* "Hide subtitles" (songs): the projector goes dark, lines keep coming in underneath. */
.stage.is-hidden { visibility: hidden; }

/* Thin rules between the columns, drawn on a grid laid out like the rows. */
.guides {
  position: absolute;
  inset: 4.5vh 5vw 6vh;
  display: grid;
  grid-template-columns: var(--cols);
  column-gap: var(--gap);
  pointer-events: none;
}

.guides > span + span { position: relative; }

.guides > span + span::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: calc(var(--gap) / -2);
  width: 1px;
  background: var(--rule);
}

.view {
  position: relative;
  overflow: hidden;
  /* older lines fade out as they rise */
  -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 30%);
  mask-image: linear-gradient(to bottom, transparent 0, #000 30%);
}

.rows {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  gap: calc(var(--fs) * 0.62);
  will-change: transform;
}

.row {
  display: grid;
  grid-template-columns: var(--cols);
  column-gap: var(--gap);
  align-items: start;
  transition: opacity 600ms ease;
}

.cell {
  min-width: 0;
  font-size: var(--fs);
  line-height: 1.3;
  font-weight: 600;
  overflow-wrap: anywhere;
  text-wrap: pretty;
  transition: opacity 360ms ease, color 360ms ease;
}

.cell:lang(th), .cell:lang(lo), .cell:lang(my), .cell:lang(shn), .cell:lang(km) { line-height: 1.6; }

/* Thai letters sit small on the line next to Latin; a touch larger reads level with the English. */
.cell:lang(th) { font-size: calc(var(--fs) * 1.08); }

/* The line being spoken right now, and translations that may still change: readable, not final. */
.row.partial .src, .cell.draft { color: var(--soft); }
.row.partial:empty, .row.partial.empty { display: none; }

/* A translation arrives after its line. Its row grows and the rows above glide up (420 ms); the new
   text stays invisible until that glide is over, so it never shows on top of the row below. */
.cell.dst { transition: opacity 360ms ease 420ms, color 360ms ease; }
.cell.dst.waiting { opacity: 0; transition: none; }

/* Older finished lines step back. */
.row.done:nth-last-child(n + 4) { opacity: 0.55; }

.link-dot {
  position: fixed;
  top: 14px;
  right: 14px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #e9ba45;
  opacity: 0;
  transition: opacity 300ms ease;
}

.link-dot.on { opacity: 0.8; }

/* Standby card: before the service, while the app is stopped. */
.standby {
  position: fixed;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 2.4vh;
  background: var(--bg);
  opacity: 0;
  visibility: hidden;
  transition: opacity 600ms ease, visibility 0s linear 600ms;
}

.stage.standby-on ~ .standby {
  opacity: 1;
  visibility: visible;
  transition: opacity 600ms ease;
}

.standby-head {
  padding-bottom: 1.6vh;
  font-size: max(18px, 4.2vh);
}

.standby-head .riah-lockup { font-size: 1em; }

.standby-note {
  margin: 0;
  color: var(--riah-dim, #82828a);
  font: 400 max(13px, 2.2vh)/1.4 var(--riah-font-ui, sans-serif);
}

/* Bar (?layout=bar) and column (?layout=side): a small window on top of the slideshow. See-through
   where there are no words; a dark band behind the words so they read over any slide. Text is sized
   from the window itself. */
html[data-layout] { --bg: transparent; }
html[data-layout] .stage {
  grid-template-rows: minmax(0, 1fr);
  background: rgba(0, 0, 0, 0.84);
  transition: opacity 400ms ease;
}
html[data-layout] .stage:not(.has-words) { opacity: 0; }
html[data-layout] .labels, html[data-layout] .guides, html[data-layout] .standby { display: none; }
html[data-layout] .view {
  -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 20%);
  mask-image: linear-gradient(to bottom, transparent 0, #000 20%);
}

html[data-layout="bar"] .stage { padding: 2.5vh 4vw 4vh; --fs: calc(var(--scale) * min(17vh, 3.1vw)); }
html[data-layout="bar"] .stage[data-cols="1"] { --fs: calc(var(--scale) * min(21vh, 4.2vw)); }
html[data-layout="bar"] .stage[data-cols="3"] { --fs: calc(var(--scale) * min(14vh, 2.2vw)); }

/* The column is narrow, so a line's languages stack: the spoken words small, the translation under it. */
html[data-layout="side"] .stage { padding: 4vh 7vw 5vh; --fs: calc(var(--scale) * min(4.2vh, 8vw)); }
html[data-layout="side"] .rows { gap: calc(var(--fs) * 0.9); }
html[data-layout="side"] .row { grid-template-columns: minmax(0, 1fr); row-gap: calc(var(--fs) * 0.2); }
html[data-layout="side"] .cell.src { font-size: calc(var(--fs) * 0.78); color: var(--soft); }

@media (prefers-reduced-motion: reduce) {
  .row, .cell, .cell.dst, .standby, html[data-layout] .stage { transition: none; }
}
