/* The stage screen: black, one huge number, readable from the back of the room. */
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; overflow: hidden; overscroll-behavior: none; }
body {
  background: #000; color: #fff; cursor: none;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  display: grid; place-items: center;
  touch-action: manipulation; -webkit-user-select: none; user-select: none;
  -webkit-text-size-adjust: 100%; text-size-adjust: 100%;
}
body.active { cursor: default; }

.clock {
  font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; letter-spacing: -.02em;
  font-size: min(30vw, 62vh); text-align: center; white-space: nowrap;
}
.clock[data-len=m] { font-size: min(25vw, 62vh); }
.clock[data-len=l] { font-size: min(19vw, 62vh); }
.clock[data-len=text] { font-size: 4vw; font-weight: 500; white-space: normal; padding: 0 5vw; }
body[data-phase=idle] .clock { color: #8a8f98; font-weight: 600; }
body[data-phase=yellow] .clock { color: #ffd60a; }
body[data-phase=red] .clock, body[data-phase=over] .clock { color: #ff453a; }
/* Over time: the number blinks, unless the technician has switched that off for the room. */
body[data-phase=over].blink .clock { animation: blink 1s ease-in-out infinite; }
@keyframes blink { 50% { opacity: .2; } }

/* Speaker's name on the left, time of day on the right. A long name goes on as many lines as it needs and
   shrinks (--tfit, see stage.js) until it ends above the number; only when that is not enough is it cut off. */
.topbar { position: fixed; top: 3vh; left: 5vw; right: 5vw; display: flex; gap: 4vw; align-items: baseline; justify-content: space-between; font-size: min(8.4vh, 7vw); line-height: 1.15; }
.title { flex: 1; min-width: 0; font-weight: 600; color: #c9ced6; font-size: calc(1em * var(--tfit, 1)); overflow-wrap: anywhere; }
.title.clamped { overflow: hidden; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: var(--tlines); line-clamp: var(--tlines); }
.daytime { flex: none; color: #8a8f98; font-variant-numeric: tabular-nums; white-space: nowrap; }
.state { position: fixed; top: calc(50% + min(17vw, 34vh)); left: 0; right: 0; text-align: center; font-size: max(3.2vh, 12px); letter-spacing: .3em; text-transform: uppercase; color: #8a8f98; }

.message {
  position: fixed; left: 0; right: 0; bottom: 0; padding: 3vh 5vw;
  background: #fff; color: #000; text-align: center; font-weight: 700; line-height: 1.15;
  font-size: calc(min(7vw, 11vh) * var(--fit, 1)); overflow-wrap: anywhere;   /* --fit: a long message shrinks, see stage.js */
}
/* With a message showing, the number moves up and shrinks so the two never overlap. */
body.has-message .clock { font-size: min(24vw, 44vh); transform: translateY(-11vh); }
body.has-message .clock[data-len=m] { font-size: min(20vw, 44vh); }
body.has-message .clock[data-len=l] { font-size: min(15vw, 44vh); }
body.has-message .state { display: none; }
.message { max-height: 34vh; overflow: hidden; }
/* The bottom line says one thing only: that the connection is lost. Nothing of our own is shown on a
   stage screen – the screen is the customer's. */
.bottom { position: fixed; left: 5vw; right: 5vw; bottom: 3vh; display: flex; justify-content: center; z-index: 3;
          font-size: max(2vh, 11px); color: #5c6370; text-align: center; }

/* The room's own design (Designer V2) fills the screen, letterboxed in black, and the default elements
   step aside; the lost-connection line and the full-screen button stay on top of it. */
.design, .design.dz-root { position: fixed; inset: 0; background: #000; z-index: 1; }     /* .dz-root (design.css) would make it relative */
body.has-design .topbar, body.has-design .clock, body.has-design .state, body.has-design .message { display: none !important; }
.lost { color: #ffd60a; }
/* With a message showing only a lost connection is said, up by the name. */
.message:not([hidden]) ~ .bottom { bottom: auto; top: 15vh; justify-content: flex-end; }

.full {
  position: fixed; left: 50%; top: 20vh; transform: translateX(-50%); z-index: 3;
  font: inherit; font-size: 1rem; padding: .7rem 1.2rem; border-radius: 99px; cursor: pointer;
  background: #1f232c; color: #eef0f4; border: 1px solid #3a4150;
  opacity: 0; pointer-events: none; transition: opacity .25s;
}
body.active .full { opacity: 1; pointer-events: auto; }
@media (pointer: coarse) { .full { padding: .9rem 1.4rem; } .full .key { display: none; } }

/* Upright screen (phone or tablet held on end): the name goes on its own lines above the time of day. */
@media (orientation: portrait) {
  .topbar { flex-direction: column; align-items: center; gap: 1vh; text-align: center; font-size: min(8.4vh, 6vw); }
  .title { flex: none; max-width: 100%; }
}

/* ---------- held in the hand: the speaker's phone (/p/…) and the rehearsal page (/r/…) */
body.handheld { display: flex; flex-direction: column; align-items: center; justify-content: space-between; cursor: default;
  padding: max(3vh, env(safe-area-inset-top)) 5vw max(3vh, env(safe-area-inset-bottom)); gap: 1.5vh; }
.handheld .clock { flex: 1; display: flex; align-items: center; font-size: min(26vw, 34vh); }
.handheld .clock[data-len=m] { font-size: min(21vw, 34vh); }
.handheld .clock[data-len=l] { font-size: min(16vw, 34vh); }
.hh-top { width: 100%; text-align: center; }
.hh-event { color: #8a8f98; font-size: max(2.2vh, 13px); }
.hh-title { color: #c9ced6; font-weight: 600; font-size: min(4.5vh, 6vw); line-height: 1.2; overflow-wrap: anywhere; }
.hh-state { min-height: 1.4em; font-size: max(2.6vh, 13px); letter-spacing: .25em; text-transform: uppercase; color: #8a8f98; }
.handheld .message { position: static; width: 100%; border-radius: 10px; padding: 1.5vh 4vw; font-size: min(6vw, 5vh); max-height: none; }
.hh-foot { width: 100%; max-width: 34rem; display: grid; gap: 1.2vh; justify-items: center; text-align: center; }
.hh-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; width: 100%; }
.hh-button { font: inherit; font-size: 1.1rem; font-weight: 600; min-height: 3rem; width: 100%; padding: .7rem 1rem; border-radius: 12px; cursor: pointer;
  background: #4f8cff; color: #fff; border: 1px solid #4f8cff; }
.hh-button.quiet { background: #1f232c; border-color: #3a4150; color: #eef0f4; }
.hh-button:disabled { opacity: .45; cursor: default; }
.hh-note { margin: 0; color: #8a8f98; font-size: max(1.9vh, 13px); line-height: 1.35; }
/* The signal: the whole screen flashes in the colour that was just reached. */
body[data-flash] { animation: flash 1.4s steps(1, end); }
body[data-flash=yellow] { --flash: #ffd60a; }
body[data-flash=red], body[data-flash=over] { --flash: #ff453a; }
body[data-flash=message] { --flash: #ffffff; }
@keyframes flash { 0%, 28%, 56% { background: var(--flash); } 14%, 42%, 70%, 100% { background: #000; } }

