/* TimerFlex Cast receiver. Mirrors TvWorkoutView: every size is a DesignSystem
   step times --u (screen height / 360, as TvMetrics.unit). Colors come from the
   phone in the state message (--bg, --text, ...); this file has no palette. */

@font-face { font-family: "Poppins"; font-weight: 400; src: url("../fonts/Poppins-Regular.ttf") format("truetype"); font-display: block; }
@font-face { font-family: "Poppins"; font-weight: 500; src: url("../fonts/Poppins-Medium.ttf") format("truetype"); font-display: block; }
@font-face { font-family: "Poppins"; font-weight: 600; src: url("../fonts/Poppins-SemiBold.ttf") format("truetype"); font-display: block; }
@font-face { font-family: "Poppins"; font-weight: 700; src: url("../fonts/Poppins-Bold.ttf") format("truetype"); font-display: block; }

:root {
  --u: calc(100vh / 360);
  /* DesignSystem Spacing */
  --space-2: calc(2 * var(--u));
  --space-4: calc(4 * var(--u));
  --space-8: calc(8 * var(--u));
  --space-12: calc(12 * var(--u));
  --space-16: calc(16 * var(--u));
  --space-20: calc(20 * var(--u));
  --space-24: calc(24 * var(--u));
  --space-32: calc(32 * var(--u));
  /* DesignSystem CornerRadius.large (logo) */
  --radius-large: calc(14 * var(--u));
  /* DesignSystem type scale; --timer is TvMetrics' giant clock (4 x h1) */
  --h1: calc(48 * var(--u));
  --h3: calc(24 * var(--u));
  --p2: calc(16 * var(--u));
  --timer: calc(192 * var(--u));

  /* Set from the phone's message; neutral until the first one arrives. */
  --bg: #000;
  --text: #fff;
  --text-secondary: #8e8e93;
  --accent: #fff;
  --live-dot: #fff;
  --track: #ffffff24;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  width: 100%; height: 100%; overflow: hidden;
  background: var(--bg); color: var(--text);
  font-family: "Poppins", system-ui, sans-serif; font-weight: 600;
  cursor: none; user-select: none;
}

#stage { width: 100%; height: 100%; }
[hidden] { display: none !important; }
.fit { font-size: calc(var(--fs) * var(--fit, 1)); }

/* Workout ---------------------------------------------------------------- */
.tv { height: 100%; display: flex; flex-direction: column; padding: var(--space-32); }

.header { display: flex; justify-content: space-between; align-items: flex-start; color: var(--text-secondary); }
.header .who { display: flex; flex-direction: column; gap: var(--space-4); min-width: 0; }
.header .title { --fs: var(--h3); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: 1.3; }
.header .coach { font-size: var(--p2); font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: 1.3; }
.header .date { font-size: var(--h3); font-weight: 500; white-space: nowrap; line-height: 1.3; }

.middle { flex: 1; display: flex; gap: var(--space-32); min-height: 0; }
.notes {
  flex: none; width: 28vw; align-self: stretch; overflow: hidden; align-self: flex-start; max-height: 100%;
  --fs: var(--h3); font-size: calc(var(--fs) * var(--vfit, 1)); font-weight: 500; line-height: 1.3;
  color: var(--text); white-space: pre-wrap; overflow-wrap: anywhere;
}
.center { flex: 1; min-width: 0; min-height: 0; display: flex; flex-direction: column; align-items: center; justify-content: flex-start; gap: var(--space-16); }
.timer-slot { flex: 1; min-height: 0; width: 100%; display: flex; align-items: center; justify-content: center; }

.status {
  display: flex; align-items: center; gap: var(--space-8); color: var(--accent);
  font-size: var(--h3); font-weight: 700; letter-spacing: var(--space-2); line-height: 1.3; white-space: nowrap;
}
.status.dim { color: var(--text-secondary); }
.status .dot { width: var(--space-12); height: var(--space-12); border-radius: 50%; background: var(--live-dot); }
.status .pause { display: inline-flex; gap: 22%; width: 0.7em; height: 0.8em; }
.status .pause i { flex: 1; background: currentColor; border-radius: 1px; }

.timer {
  --fs: var(--timer-size, var(--timer)); font-weight: 600; line-height: 1; white-space: nowrap; max-width: 100%;
  font-variant-numeric: tabular-nums; color: var(--accent); direction: ltr; unicode-bidi: isolate;
}
.timer.countdown { color: var(--text); }
.timer.paused { opacity: 0.6; }
.timer.pop { animation: pop 500ms cubic-bezier(0.23, 1, 0.32, 1); }
@keyframes pop { 0% { transform: scale(1); } 50% { transform: scale(1.12); } 100% { transform: scale(1); } }

.track { position: relative; width: 60vw; max-width: 100%; height: var(--space-20); direction: ltr; }
.track .line, .track .fill { position: absolute; left: 0; top: 50%; height: calc(var(--space-2) * 2); margin-top: calc(var(--space-2) * -1); border-radius: 999px; }
.track .line { right: 0; background: var(--track); }
.track .fill { background: var(--accent); width: 0; }
.track.countdown .fill { background: var(--text); }
.track .knob { position: absolute; top: 50%; left: 0; width: var(--space-12); height: var(--space-12); margin-top: calc(var(--space-12) / -2); border-radius: 50%; background: var(--accent); }

.secondary { font-size: var(--h3); font-weight: 500; color: var(--text-secondary); line-height: 1.3; text-align: center; max-width: 100%; }

/* Footer: info | logo | module dots */
.footer { display: flex; justify-content: center; align-items: center; gap: var(--space-24); color: var(--text-secondary); }
.footer .info { width: 36vw; display: flex; align-items: center; gap: var(--space-8); font-size: var(--h3); font-weight: 500; line-height: 1.3; min-width: 0; }
.footer .info svg { flex: none; width: calc(var(--h3) * 0.9); height: calc(var(--h3) * 0.9); }
.footer .dots-wrap { width: 36vw; display: flex; justify-content: flex-end; color: var(--text); }
.dots { display: flex; gap: var(--space-8); }
.dot-m { width: var(--space-12); height: var(--space-12); border-radius: 50%; background: var(--text); opacity: 0.24; }
.dot-m.reached { opacity: 1; }
.dots-text { font-size: calc(10 * var(--u)); font-weight: 700; font-variant-numeric: tabular-nums; }

.logo { flex: none; display: block; }
.logo img { display: block; width: calc(28 * var(--u)); height: calc(28 * var(--u)); border-radius: var(--radius-large); object-fit: cover; }
.logo .name { font-size: var(--h3); font-weight: 700; color: var(--text-secondary); white-space: nowrap; }

/* Idle: drifts a little each minute and dims, so a TV left here does not burn in. */
.idle { height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--space-24); text-align: center; opacity: 0.7; padding: var(--space-32); }
.idle .logo img { width: calc(40 * var(--u)); height: calc(40 * var(--u)); }
.idle .idle-title { --fs: var(--h1); font-weight: 700; white-space: nowrap; max-width: 100%; }
.idle .idle-subtitle { font-size: var(--h3); font-weight: 500; color: var(--text-secondary); }

/* Screen changes fade; Reduce Motion turns every animation off. */
.fade-in { animation: fade 200ms ease-out; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.idle.fade-in { animation: fade-idle 200ms ease-out; }
@keyframes fade-idle { from { opacity: 0; } to { opacity: 0.7; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
html.reduce-motion *, html.reduce-motion *::before, html.reduce-motion *::after { animation: none !important; transition: none !important; }
