/* The projection's web page: one slide, the whole window, the church's
   colours (set by page.mjs). Sizes as lib/core/theme/stage_theme.dart. */
@font-face {
  font-family: 'Atkinson Hyperlegible Next';
  src: url('/assets/fonts/AtkinsonHyperlegibleNext-Variable.ttf') format('truetype');
  font-weight: 200 800;
  font-display: block;
}

/* The themes' fonts (docs/dev/projection-themes.md). Outfit is the
   website's own file: the phone's server serves it at the same path. */
@font-face {
  font-family: 'Outfit';
  src: url('/assets/fonts/Outfit-Variable.ttf') format('truetype');
  font-weight: 100 900;
  font-display: block;
}

@font-face {
  font-family: 'Alegreya';
  src: url('fonts/Alegreya-Variable.ttf') format('truetype');
  font-weight: 400 900;
  font-style: normal;
  font-display: block;
}

@font-face {
  font-family: 'Alegreya';
  src: url('fonts/Alegreya-Italic-Variable.ttf') format('truetype');
  font-weight: 400 900;
  font-style: italic;
  font-display: block;
}

@font-face {
  font-family: 'Archivo Expanded';
  src: url('fonts/ArchivoExpanded-Variable.ttf') format('truetype');
  font-weight: 100 900;
  font-display: block;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #000;
  color: #fff;
}

body.idle {
  cursor: none;
}

#screen {
  position: fixed;
  inset: 0;
  line-height: 1.2;
  overflow: hidden;
}

/* The default face, below any theme's (.t-…): an id would win over them. */
:where(#screen) {
  font-family: 'Atkinson Hyperlegible Next', system-ui, sans-serif;
  font-weight: 600;
}

/* The text: inside the overscan margins, above the caption's band. */
.area {
  position: absolute;
  left: 5vw;
  right: 5vw;
  top: 5vh;
  bottom: calc(5vh + 6vh); /* 2 × 3% of the height for the caption */
  display: flex;
  align-items: center;
  justify-content: center;
}

.lines {
  width: 100%;
  transform-origin: center;
}

.lines.center {
  text-align: center;
}

.lines p {
  margin: 0;
}

.lines .translation {
  color: var(--tr, inherit);
  opacity: var(--tro, 0.75);
}

/* A reading: under its reference's band, down to the margin. */
.area.reading {
  top: calc(5vh + 6.25vh); /* 1.5 × 1/24 of the height */
  bottom: 5vh;
}

.lines .verse-number {
  font-size: 0.6em;
  opacity: 0.85;
  margin-right: 0.4em;
}

.reference {
  position: absolute;
  left: 5vw;
  right: 5vw;
  top: 5vh;
  font-size: calc(100vh / 24);
  font-weight: 600;
  line-height: 1.2;
  opacity: 0.85;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.title {
  font-size: 12.5vh; /* 1/8 of the height */
  text-align: center;
  white-space: nowrap;
}

.corner {
  position: absolute;
  left: 5vw;
  right: 5vw;
  bottom: 5vh;
  font-size: 3vh; /* 3% of the height */
  opacity: 0.85;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rest {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.rest img.logo {
  width: 40vmin;
  height: 40vmin;
  object-fit: contain;
}

.rest img.cover {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* The photo behind the words, veiled with the background (#359). */
.backdrop,
.backdrop .veil {
  position: absolute;
  inset: 0;
}

.backdrop img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* «Starts in 4:32», low on the rest screen (#367), on the veil. */
.countdown {
  position: absolute;
  left: 50%;
  bottom: 5vh;
  transform: translateX(-50%);
  padding: 1.25vh 5vh;
  font-size: 10vh; /* 1/10 of the height */
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* Connected and waiting, or the link ended: the logo and two lines. */
.status {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2vh;
  text-align: center;
  padding: 0 5vw;
}

.status img.logo {
  width: 18vmin;
  height: 18vmin;
}

.status p {
  margin: 0;
}

.status-title {
  font-size: 6vh;
}

.status-hint {
  font-size: 3vh;
  opacity: 0.7;
}

/* Small, in a corner: readable only from close by. */
#note {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  margin: 0;
  font: 14px/1.3 'Atkinson Hyperlegible Next', system-ui, sans-serif;
  color: #8a8f98;
}

/* Words change per theme (--in, --dur); the background stays. */
#screen > :not(.bg):not(.backdrop) {
  animation: var(--in, fade) var(--dur, 180ms) ease-out;
}

@keyframes fade {
  from {
    opacity: 0;
  }
}

@keyframes rise {
  from {
    opacity: 0;
    translate: 0 2vh;
  }
}

@keyframes lift {
  from {
    opacity: 0;
    translate: 0 3vh;
  }
}

/* Themes: font, translation, the words' change. */
.t-essenziale {
  font-weight: 700;
  --dur: 180ms;
}

.t-notte {
  font-family: 'Outfit', system-ui, sans-serif;
  font-weight: 600;
  --tr: #f2d08c;
  --tro: 1;
  --in: rise;
  --dur: 260ms;
}

.t-alba {
  font-weight: 700;
  text-shadow: 0 0.3vh 2vh rgb(0 0 0 / 35%);
  --in: lift;
  --dur: 280ms;
}

.t-vetrata {
  font-family: 'Alegreya', Georgia, serif;
  font-weight: 700;
  --dur: 280ms;
}

.t-vetrata .translation {
  font-style: italic;
  font-weight: 500;
  opacity: 0.8;
}

.t-giorno {
  font-weight: 800;
  --tr: #39424f;
  --tro: 1;
  --dur: 220ms;
}

.t-giorno .translation {
  font-weight: 600;
}

.t-stelle {
  font-weight: 600;
  --in: rise;
  --dur: 280ms;
}

.t-acque {
  font-weight: 700;
  --dur: 280ms;
}

.t-brace {
  font-family: 'Outfit', system-ui, sans-serif;
  font-weight: 700;
  --in: rise;
  --dur: 240ms;
}

.t-sezioni {
  font-family: 'Archivo Expanded', 'Atkinson Hyperlegible Next', system-ui, sans-serif;
  font-weight: 800;
  transition: background-color 700ms ease;
  --in: lift;
  --dur: 240ms;
}

.t-sezioni .translation {
  font-family: 'Atkinson Hyperlegible Next', system-ui, sans-serif;
  font-weight: 600;
  opacity: 0.85;
}

/* Alba: words low and on the left, like subtitles; the caption on top. */
.t-alba .area {
  top: 11vh;
  bottom: 5vh;
  align-items: flex-end;
  justify-content: flex-start;
}

.t-alba .area.reading {
  top: calc(5vh + 6.25vh);
}

.t-alba .lines.center {
  text-align: left;
}

.t-alba .corner {
  top: 5vh;
  bottom: auto;
}

/* Background layers: gradients that move slowly, never video. */
.bg,
.bg i {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.bg {
  overflow: hidden;
}

.bg i {
  display: none;
}

.t-notte .b1,
.t-notte .b2,
.t-alba .bg i,
.t-vetrata .b1,
.t-vetrata .b2,
.t-vetrata .b3,
.t-giorno .b1,
.t-giorno .b2,
.t-stelle .b1,
.t-stelle .b2,
.t-stelle .b3,
.t-stelle .b4,
.t-acque .bg i,
.t-brace .b1,
.t-brace .b2,
.t-brace .b3 {
  display: block;
}

.t-notte .b1 {
  /* Before color-mix (older TVs): the theme's own light. */
  background: radial-gradient(ellipse 70% 65% at 50% 100%, rgb(242 181 68 / 34%), transparent 72%);
  background: radial-gradient(ellipse 70% 65% at 50% 100%, color-mix(in srgb, var(--l1, rgb(242 181 68)) 34%, transparent), transparent 72%);
  transform-origin: 50% 100%;
  animation: breathe 9s ease-in-out infinite alternate;
}

.t-notte .b2 {
  background: radial-gradient(circle 40vmax at 15% 10%, rgb(120 150 200 / 8%), transparent);
}

.t-alba .b1 {
  background: radial-gradient(ellipse 45% 60% at 20% 30%, var(--l1, #3b3f8f), transparent);
  animation: drift1 38s ease-in-out infinite alternate;
}

.t-alba .b2 {
  background: radial-gradient(ellipse 40% 55% at 80% 60%, var(--l2, #8f3d66), transparent);
  animation: drift2 46s ease-in-out infinite alternate;
}

.t-alba .b3 {
  background: radial-gradient(ellipse 35% 45% at 60% 110%, var(--l3, #b4743c), transparent);
  animation: drift3 52s ease-in-out infinite alternate;
}

.t-alba .b4 {
  background: linear-gradient(rgb(10 8 25 / 15%), rgb(10 8 25 / 55%));
}

.t-vetrata .b1 {
  /* Before color-mix (older TVs): the theme's own light. */
  background: radial-gradient(ellipse 28% 50% at 25% 35%, rgb(40 80 190 / 55%), transparent);
  background: radial-gradient(ellipse 28% 50% at 25% 35%, color-mix(in srgb, var(--l1, rgb(40 80 190)) 55%, transparent), transparent);
  animation: drift1 44s ease-in-out infinite alternate;
}

.t-vetrata .b2 {
  /* Before color-mix (older TVs): the theme's own light. */
  background: radial-gradient(ellipse 24% 44% at 70% 30%, rgb(170 30 60 / 50%), transparent);
  background: radial-gradient(ellipse 24% 44% at 70% 30%, color-mix(in srgb, var(--l2, rgb(170 30 60)) 50%, transparent), transparent);
  animation: drift2 50s ease-in-out infinite alternate;
}

.t-vetrata .b3 {
  /* Before color-mix (older TVs): the theme's own light. */
  background: radial-gradient(ellipse 22% 40% at 55% 85%, rgb(200 150 40 / 42%), transparent);
  background: radial-gradient(ellipse 22% 40% at 55% 85%, color-mix(in srgb, var(--l3, rgb(200 150 40)) 42%, transparent), transparent);
  animation: drift3 56s ease-in-out infinite alternate;
}

/* Window light: soft bands, wider than the screen so no edge slides in. */
.t-giorno .b1 {
  left: -15%;
  right: -15%;
  background: repeating-linear-gradient(
    115deg,
    transparent 0,
    transparent 9%,
    rgb(255 255 255 / 75%) 14%,
    rgb(255 255 255 / 75%) 31%,
    transparent 36%
  );
  animation: shafts 60s ease-in-out infinite alternate;
}

.t-giorno .b2 {
  /* Before color-mix (older TVs): the theme's own light. */
  background: radial-gradient(ellipse 90% 80% at 85% 0%, rgb(90 120 160 / 32%), transparent);
  background: radial-gradient(ellipse 90% 80% at 85% 0%, color-mix(in srgb, var(--l1, rgb(90 120 160)) 32%, transparent), transparent);
}

/* Stelle: three skies of stars scattered in large tiles of different sizes
   (no grid shows), shining out of step; two slide slowly, apart. */
.t-stelle .b1 {
  background:
    radial-gradient(ellipse 55% 45% at 70% 25%, rgb(70 60 150 / 35%), transparent 70%),
    radial-gradient(ellipse 50% 50% at 15% 90%, rgb(20 60 120 / 35%), transparent 70%);
}

.t-stelle .b2 {
  background-image:
    radial-gradient(circle 0.17vh at 41.6% 28.2%, #ffffff, transparent),
    radial-gradient(circle 0.17vh at 57.4% 62.3%, #ffffff, transparent),
    radial-gradient(circle 0.20vh at 89.8% 97.0%, #cfd8ff, transparent),
    radial-gradient(circle 0.13vh at 95.8% 16.3%, #ffffff, transparent),
    radial-gradient(circle 0.17vh at 24.3% 95.6%, #cfd8ff, transparent),
    radial-gradient(circle 0.15vh at 43.2% 81.3%, #ffffff, transparent),
    radial-gradient(circle 0.14vh at 53.9% 96.3%, #ffffff, transparent),
    radial-gradient(circle 0.14vh at 79.9% 79.1%, #ffffff, transparent),
    radial-gradient(circle 0.20vh at 99.1% 70.0%, #cfd8ff, transparent),
    radial-gradient(circle 0.11vh at 64.8% 36.2%, #ffffff, transparent),
    radial-gradient(circle 0.17vh at 20.2% 39.6%, #ffffff, transparent),
    radial-gradient(circle 0.21vh at 38.0% 60.8%, #ffffff, transparent),
    radial-gradient(circle 0.18vh at 23.3% 75.0%, #ffffff, transparent),
    radial-gradient(circle 0.13vh at 90.2% 37.3%, #cfd8ff, transparent),
    radial-gradient(circle 0.17vh at 39.2% 98.1%, #ffffff, transparent),
    radial-gradient(circle 0.15vh at 17.2% 12.4%, #ffffff, transparent),
    radial-gradient(circle 0.18vh at 74.8% 10.3%, #cfd8ff, transparent),
    radial-gradient(circle 0.15vh at 55.6% 22.7%, #ffffff, transparent),
    radial-gradient(circle 0.17vh at 79.8% 58.9%, #ffffff, transparent),
    radial-gradient(circle 0.21vh at 63.3% 77.6%, #ffffff, transparent);
  background-size: 100vh 83vh;
  /* One tile wider, slid by transform: no repaint a frame. */
  left: -100vh;
  will-change: transform;
  animation:
    twinkle 5s ease-in-out infinite alternate,
    stars1 588s linear infinite;
}

.t-stelle .b3 {
  background-image:
    radial-gradient(circle 0.13vh at 27.2% 26.1%, #cfd8ff, transparent),
    radial-gradient(circle 0.13vh at 50.3% 68.5%, #cfd8ff, transparent),
    radial-gradient(circle 0.11vh at 72.0% 69.2%, #cfd8ff, transparent),
    radial-gradient(circle 0.13vh at 76.7% 5.8%, #ffffff, transparent),
    radial-gradient(circle 0.14vh at 80.9% 49.5%, #cfd8ff, transparent),
    radial-gradient(circle 0.10vh at 65.3% 89.7%, #cfd8ff, transparent),
    radial-gradient(circle 0.13vh at 99.4% 24.3%, #cfd8ff, transparent),
    radial-gradient(circle 0.17vh at 22.8% 0.6%, #cfd8ff, transparent),
    radial-gradient(circle 0.14vh at 12.6% 42.4%, #ffffff, transparent),
    radial-gradient(circle 0.11vh at 56.4% 19.7%, #cfd8ff, transparent),
    radial-gradient(circle 0.17vh at 81.0% 87.0%, #cfd8ff, transparent),
    radial-gradient(circle 0.14vh at 99.4% 55.6%, #cfd8ff, transparent),
    radial-gradient(circle 0.13vh at 44.1% 40.6%, #ffffff, transparent),
    radial-gradient(circle 0.15vh at 72.8% 32.3%, #cfd8ff, transparent);
  background-size: 137vh 113vh;
  left: -137vh;
  will-change: transform;
  animation:
    twinkle 7s ease-in-out -3s infinite alternate,
    stars2 955s linear infinite reverse;
}

.t-stelle .b4 {
  background-image:
    radial-gradient(circle 0.15vh at 54.2% 59.5%, #fff4e0, transparent),
    radial-gradient(circle 0.18vh at 97.0% 24.6%, #ffffff, transparent),
    radial-gradient(circle 0.21vh at 89.9% 94.8%, #ffffff, transparent),
    radial-gradient(circle 0.20vh at 13.7% 76.5%, #ffffff, transparent),
    radial-gradient(circle 0.21vh at 57.7% 25.6%, #ffffff, transparent),
    radial-gradient(circle 0.15vh at 78.3% 60.9%, #ffffff, transparent),
    radial-gradient(circle 0.15vh at 22.2% 48.1%, #ffffff, transparent);
  background-size: 73vh 61vh;
  animation: twinkle 4s ease-in-out -1.5s infinite alternate;
}

/* Acque: light on water, two layers of soft patches swaying apart. */
.t-acque .b1 {
  background: radial-gradient(ellipse 80% 70% at 50% 0%, rgb(40 150 150 / 35%), transparent 70%);
}

.t-acque .b2 {
  background:
    radial-gradient(ellipse 18% 8% at 25% 35%, rgb(190 255 240 / 14%), transparent),
    radial-gradient(ellipse 22% 7% at 65% 55%, rgb(190 255 240 / 14%), transparent),
    radial-gradient(ellipse 16% 6% at 45% 75%, rgb(190 255 240 / 14%), transparent),
    radial-gradient(ellipse 14% 6% at 80% 25%, rgb(190 255 240 / 14%), transparent);
  animation: water1 40s ease-in-out infinite alternate;
}

.t-acque .b3 {
  background:
    radial-gradient(ellipse 20% 7% at 35% 60%, rgb(190 255 240 / 10%), transparent),
    radial-gradient(ellipse 18% 6% at 70% 80%, rgb(190 255 240 / 10%), transparent),
    radial-gradient(ellipse 15% 6% at 15% 70%, rgb(190 255 240 / 10%), transparent);
  animation: water2 52s ease-in-out infinite alternate;
}

.t-acque .b4 {
  background: linear-gradient(transparent 40%, rgb(2 20 22 / 45%));
}

/* Brace: a low fire breathing, sparks rising and fading out going up. */
.t-brace .b1 {
  background: radial-gradient(ellipse 75% 55% at 50% 110%, rgb(214 82 30 / 45%), transparent 70%);
  transform-origin: 50% 100%;
  animation: breathe 6s ease-in-out infinite alternate;
}

.t-brace .b2,
.t-brace .b3 {
  -webkit-mask-image: linear-gradient(to top, #000 20%, transparent 85%);
  mask-image: linear-gradient(to top, #000 20%, transparent 85%);
}

.t-brace .b2::before,
.t-brace .b3::before {
  content: '';
  position: absolute;
  inset: 0;
  will-change: transform;
}

.t-brace .b2::before {
  bottom: -29.6vh;
  background-image:
    radial-gradient(circle 0.56vh at 20% 30%, #ffc27f, transparent),
    radial-gradient(circle 0.4vh at 60% 70%, #ff8a3d, transparent),
    radial-gradient(circle 0.62vh at 85% 20%, #ffd49c, transparent),
    radial-gradient(circle 0.38vh at 42% 8%, #ff9a50, transparent);
  background-size: 21.3vh 29.6vh;
  /* The sparks slide one tile up inside the layer, whose mask stays put;
     the glow as drawn in the mockup. */
  filter: drop-shadow(0 0 0.28vh rgb(255 140 60 / 90%));
  animation: sparks1 14s linear infinite;
}

.t-brace .b3::before {
  bottom: -23.1vh;
  opacity: 0.8;
  background-image:
    radial-gradient(circle 0.38vh at 35% 55%, #ffb46b, transparent),
    radial-gradient(circle 0.48vh at 75% 85%, #ff9a50, transparent),
    radial-gradient(circle 0.3vh at 10% 15%, #ffc98a, transparent);
  background-size: 15.7vh 23.1vh;
  filter: drop-shadow(0 0 0.19vh rgb(255 120 40 / 80%));
  animation: sparks2 9s linear infinite;
}

@keyframes twinkle {
  from {
    opacity: 0.5;
  }

  to {
    opacity: 1;
  }
}

@keyframes stars1 {
  to {
    transform: translateX(100vh);
  }
}

@keyframes stars2 {
  to {
    transform: translateX(137vh);
  }
}

@keyframes water1 {
  to {
    transform: translate(6%, 4%) rotate(3deg);
  }
}

@keyframes water2 {
  to {
    transform: translate(-5%, -3%) rotate(-4deg);
  }
}

@keyframes sparks1 {
  to {
    transform: translateY(-29.6vh);
  }
}

@keyframes sparks2 {
  to {
    transform: translateY(-23.1vh);
  }
}

@keyframes breathe {
  from {
    opacity: 0.65;
    transform: scale(1);
  }

  to {
    opacity: 1;
    transform: scale(1.18);
  }
}

@keyframes drift1 {
  to {
    transform: translate(18%, 12%) scale(1.15);
  }
}

@keyframes drift2 {
  to {
    transform: translate(-16%, -10%) scale(1.1);
  }
}

@keyframes drift3 {
  to {
    transform: translate(-10%, -18%) scale(1.2);
  }
}

@keyframes shafts {
  to {
    transform: translateX(12%);
  }
}

/* Still: the system asks for it, or the screen stutters (page.mjs). */
.still .bg i,
.still .bg i::before {
  animation: none;
}

@media (prefers-reduced-motion: reduce) {
  .bg i,
  .bg i::before {
    animation: none;
  }

  /* The id beats the themes' own --in: plain fades. */
  #screen {
    --in: fade;
  }
}

/* The live stream's overlay (#702, `?stream=1` in OBS): a transparent page,
   the words white in a band low on the video, readable on any picture. */
html.stream,
html.stream body {
  background: transparent !important;
}

html.stream .bg,
html.stream #note {
  display: none;
}

html.stream .area {
  top: auto;
  bottom: 9vh;
  left: 12vw;
  right: 12vw;
  height: 20vh;
  isolation: isolate;
}

html.stream .area::before {
  content: '';
  position: absolute;
  inset: -2vh -3vw;
  z-index: -1;
  border-radius: 1.2vh;
  background: rgba(0, 0, 0, 0.6);
}

html.stream .lines p {
  text-shadow: 0 0.04em 0.15em rgba(0, 0, 0, 0.9);
}
