@font-face {
  font-family: "Big Shoulders Display";
  font-weight: 800;
  font-display: swap;
  src: url(fonts/big-shoulders-display-latin.woff2) format("woff2");
}

@font-face {
  font-family: "Familjen Grotesk";
  font-weight: 400 700;
  font-display: swap;
  src: url(fonts/familjen-grotesk-latin.woff2) format("woff2");
}

:root {
  --deep: #050f42;
  --panel: #0a1c66;
  --chamber: #0d2c9c;
  --lit: #4d94ff;
  --ice: #e2f0ff;
  --yellow: #ffd21f;
  --red: #ff3b4e;
  --display: "Big Shoulders Display", "Arial Narrow", sans-serif;
  --body: "Familjen Grotesk", system-ui, sans-serif;
}

/* Phone remote */

/* The remote fits the screen, so a drag should not rubber-band the page. */
html:has(> body.remote) {
  overscroll-behavior: none;
}

.remote {
  margin: 0 auto;
  max-inline-size: 30rem;
  /* Sized so an iPhone Pro in portrait shows it all without scrolling, with
     Safari's bars showing (about 393 by 659 points). */
  padding: .625rem 1rem max(.75rem, env(safe-area-inset-bottom));
  background: var(--deep);
  color: var(--ice);
  font-family: var(--body);
  font-size: 1rem;
  line-height: 1.3;
}

/* Remote type roles, display face unless noted:
   clock 4.5rem · action 1.75rem · value 1.5rem · status 1.25rem ·
   control 1.125rem · heading 1rem · label 1rem body 600 · note .875rem body 500 */

.remote ::selection {
  background: var(--yellow);
  color: var(--deep);
}

.remote h1,
.remote h2,
.remote button,
.remote input,
.remote .status {
  font-family: var(--display);
  font-weight: 800;
  letter-spacing: .04em;
}

.remote header {
  display: flex;
  align-items: center;
  gap: .5rem;
  margin-block-end: .5rem;
}

.remote header svg {
  display: block;
  inline-size: 2rem;
  block-size: auto;
  overflow: visible; /* the scan's pulse rings reach past the mark */
}

.remote h1 {
  margin: 0;
  font-size: 1.125rem;
}

/* One short row: round and phase stacked on the left, the clock on the
   right, the bar under both. Kept low so the whole remote fits a phone. */
.remote .status {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  column-gap: .75rem;
  padding: .5rem .875rem .625rem;
  border: 2px solid var(--panel);
  background: var(--panel);
  color: var(--ice);
}

.remote[data-phase="ready"] .status { background: var(--deep); color: var(--yellow); }
.remote[data-phase="work"] .status { background: var(--chamber); border-color: var(--chamber); color: var(--ice); }
.remote[data-phase="rest"] .status { background: var(--deep); color: var(--lit); }
.remote[data-phase="done"] .status { background: var(--deep); color: var(--ice); }

.remote .status-top {
  display: flex;
  flex-direction: column;
  gap: .125rem;
  margin: 0;
  font-size: 1.25rem;
  line-height: 1.1;
}

.remote .clock {
  margin: 0;
  text-align: end;
  font-size: min(18vw, 4.5rem); /* 20:00 is 2.3em wide */
  line-height: .95;
  letter-spacing: 0; /* tracking that suits labels spreads big digits apart */
  font-variant-numeric: tabular-nums;
}

.remote .track {
  grid-column: 1 / -1;
  margin-block-start: .5rem;
  block-size: 8px;
  background: rgb(226 240 255 / .16);
}

.remote .track i {
  display: block;
  block-size: 100%;
  inline-size: 0;
  background: currentColor;
}

.remote button {
  min-block-size: 44px;
  min-inline-size: 44px;
  border: 0;
  background: var(--panel);
  color: var(--ice);
  font-size: 1.125rem;
  cursor: pointer;
  touch-action: manipulation; /* no double-tap-zoom wait before a tap counts */
}

.remote button:active:not(:disabled) {
  filter: brightness(1.25);
}

@media (hover: hover) {
  .remote button:hover:not(:disabled) {
    filter: brightness(1.15);
  }
}

.remote button:focus-visible {
  outline: 3px solid var(--yellow);
  outline-offset: 3px;
}

.remote button:disabled {
  opacity: .35;
  cursor: default;
}

.remote button[aria-pressed="true"] {
  background: var(--ice);
  color: var(--deep);
}

/* Locked mid-session, the chosen program is still information: keep it
   readable while the controls around it fade. */
.remote button[aria-pressed="true"]:disabled {
  opacity: .6;
}

.remote .acts {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: .625rem;
  margin-block-start: .875rem; /* right under the countdown */
}

.remote .go,
.remote .reset {
  min-block-size: 54px;
  font-size: 1.75rem;
}

.remote .go {
  background: var(--yellow);
  color: var(--deep);
}

.remote .reset {
  border: 2px solid var(--lit);
}

.remote h2 {
  margin: .625rem 0 .25rem;
  font-size: 1rem;
  letter-spacing: .06em;
  color: var(--lit);
}

.remote .note {
  display: none;
  margin-inline-start: .375rem;
  font-family: var(--body);
  font-weight: 500;
  font-size: .875rem;
  letter-spacing: .01em;
  color: var(--ice);
}

.remote:is([data-status="running"], [data-status="paused"], [data-status="done"]) .note {
  display: inline;
}

.remote .chips {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
}

.remote .chips.three {
  grid-template-columns: repeat(3, 1fr);
}

.remote .chip {
  min-block-size: 44px;
  padding-inline: 0; /* "3 min" stays on one line on a 320px phone */
}

.remote .step {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 2px 0;
}

.remote .step span {
  flex: 1;
  font-weight: 600; /* light text on deep blue reads thin at 400 */
  letter-spacing: .01em;
}

.remote .step button {
  inline-size: 48px;
  font-size: 1.5rem;
  /* held to repeat: no text selection, callout or double-tap zoom */
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.remote .step input {
  inline-size: 76px;
  min-block-size: 44px;
  padding: 0;
  border: 0;
  border-block-end: 2px solid var(--lit);
  border-radius: 0;
  background: none;
  color: var(--ice);
  text-align: center;
  font-size: 1.5rem; /* 16px or more, or iOS zooms the page on focus */
  font-variant-numeric: tabular-nums;
  caret-color: var(--yellow);
}

.remote .step input::placeholder {
  color: var(--lit);
}

.remote .step input:focus-visible {
  outline: 3px solid var(--yellow);
  outline-offset: 3px;
}

.remote .step input:disabled {
  opacity: .7;
  border-color: transparent;
}

.remote[data-status="paused"] .clock { opacity: .4; }
.remote[data-final] .status { background: var(--deep); border-color: var(--panel); }
.remote[data-final] .clock { color: var(--red); }

/* Done: the main button already resets, so it takes the whole row. */
.remote[data-status="done"] .acts { grid-template-columns: 1fr; }
.remote[data-status="done"] .reset { display: none; }

.remote .full {
  margin: 3rem 0;
  font-size: 1.25rem;
  line-height: 1.35;
  text-align: center;
  text-wrap: balance;
}

.remote .full p {
  margin: 0 0 .5rem;
}

.remote .full .note-full {
  margin-block-end: 1.5rem;
  font-size: 1rem;
  color: var(--lit);
}

.remote .full .go {
  inline-size: 100%;
}

/* TV page: sized for a 16:9 screen in vw/vh, with a 5% safe margin for
   overscan. Plain properties only: the TV's browser may be old. */

.tv {
  margin: 0;
  height: 100vh;
  overflow: hidden;
  display: flex;
  background: var(--deep);
  color: var(--ice);
  font-family: var(--display);
  font-weight: 800;
  line-height: 1;
}

.tv .brand {
  position: relative;
  overflow: hidden; /* clips the scan beam and pulse rings to the column */
  width: 31%;
  box-sizing: border-box;
  /* The foot is kept for the time of day, so the logo and name centre in
     the space above it. */
  padding: 5vh 3vw calc(8vh + 4.4vw) 5vw;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--deep);
  color: var(--ice);
  border-right: .4vw solid var(--panel);
}

.tv .brand svg {
  display: block;
  width: 100%;
  max-height: 55vh;
  overflow: visible;
}

/* The Cerebro scan: after the mark draws itself in (brand.js), a slow cycle
   keeps it alive. Every 8 s two rings pulse out from the logo, a beam sweeps
   down the column, and a wave of light runs through the name as the beam
   crosses it. The phone header gets the rings and the wave, not the beam.
   Paused timers hold it still; less-motion viewers get none of it. */
[data-brand] .letter {
  display: inline-block; /* so each letter can move on its own */
  animation: brand-wave 8s linear infinite;
}

[data-brand] .pulse {
  opacity: 0; /* seen only while pulsing */
  stroke: var(--lit);
  transform-origin: 85px 33.2px;
  animation: brand-pulse 8s cubic-bezier(.2, .7, .2, 1) 3s infinite; /* after the draw-in */
}

[data-brand] .pulse + .pulse {
  animation-delay: 3.5s;
}

.tv .brand .scan {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 16vh;
  background: linear-gradient(to bottom, rgba(77, 148, 255, 0), rgba(77, 148, 255, .14) 88%, var(--lit) 100%);
  opacity: 0;
  pointer-events: none;
  animation: brand-scan 8s linear 3s infinite;
}

[data-status="paused"] [data-brand] .letter,
[data-status="paused"] [data-brand] .pulse,
[data-status="paused"] [data-brand] .scan {
  animation-play-state: paused;
}

@keyframes brand-pulse {
  0% { opacity: .7; transform: scale(1); }
  20% { opacity: 0; transform: scale(1.45); }
  100% { opacity: 0; transform: scale(1.45); }
}

@keyframes brand-scan {
  0% { opacity: 0; transform: translateY(-16vh); }
  4% { opacity: 1; }
  32% { opacity: 1; }
  36% { opacity: 0; transform: translateY(100vh); }
  100% { opacity: 0; transform: translateY(100vh); }
}

@keyframes brand-wave {
  0% { color: inherit; }
  3% { color: var(--lit); }
  9% { color: inherit; }
  100% { color: inherit; }
}

@media (prefers-reduced-motion: reduce) {
  [data-brand] .letter,
  [data-brand] .pulse,
  .tv .brand .scan {
    animation: none;
  }
}

.tv .brand b {
  margin-top: 3vw;
  font-size: 5.4vw;
  letter-spacing: .06em;
  text-align: center;
}

/* Time of day, at the foot of the brand column. */
.tv .now {
  position: absolute;
  bottom: 5vh;
  left: 5vw; /* the column's padding, so it centres under the name */
  right: 3vw;
  margin: 0;
  font-size: 4.4vw; /* the widest time, 12:00:00 PM, still fits the column */
  letter-spacing: .03em;
  text-align: center;
  font-variant-numeric: tabular-nums;
  opacity: .75;
}

.tv .side {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
  padding: 5vh 5vw calc(5vh + 4vw) 4vw;
  background: var(--panel);
  color: var(--ice);
}

.tv[data-phase="ready"] .side { background: var(--deep); color: var(--yellow); }
.tv[data-phase="work"] .side { background: var(--chamber); color: var(--ice); }
.tv[data-phase="rest"] .side { background: var(--deep); color: var(--lit); }
.tv[data-phase="done"] .side { background: var(--deep); color: var(--ice); }

/* The phase word is what the room reads from the mat; the round is secondary. */
.tv .top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin: 0;
  font-size: 7vw;
  letter-spacing: .02em;
}

.tv #label {
  font-size: 4.2vw;
  opacity: .75;
}

/* Idle has no phase word. An empty one still holds its line, so the round
   label and the clock sit where they do mid-round. */
.tv #phase:empty::before {
  content: "\00a0";
}

.tv .clock {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  font-size: 26vw;
  font-size: min(26vw, 52vh);
  font-variant-numeric: tabular-nums;
}

.tv .bottom {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  font-size: 4vw; /* the smallest text on screen: about 2 cm tall on a 32-inch TV */
  letter-spacing: .03em;
  text-transform: uppercase;
}

.tv .qr {
  display: block;
  height: 17vh;
}

/* A QR code is squares: scaled up, they must stay sharp to scan. */
.tv .qr,
.tv .welcome img {
  image-rendering: pixelated;
}

.tv .track {
  position: absolute;
  left: 4vw;
  right: 5vw;
  bottom: 5vh;
  height: 2.2vw;
  background: rgba(226, 240, 255, .16);
}

.tv .track i {
  display: block;
  height: 100%;
  width: 0;
  background: currentColor;
}

/* Paused: the clock dims, so the room sees it stopped without reading. */
.tv[data-status="paused"] .clock { opacity: .4; }
/* Red on the bright work blue is hard to read at a distance: the last ten
   seconds go to the dark ground, where it is not. */
.tv[data-final] .side { background: var(--deep); }
.tv[data-final] .clock { color: var(--red); }

/* Before a phone has scanned in, the clock side is only the QR code. */
.tv .welcome {
  display: none;
}

.tv[data-welcome] .side {
  padding-bottom: 5vh; /* no progress bar to clear */
  background: var(--deep);
  color: var(--ice);
}

.tv[data-welcome] .welcome {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

/* As large as the screen allows: on a 43-inch TV about 38 cm across, to scan
   from 10 to 15 feet away. */
.tv[data-welcome] .welcome img {
  width: 72vh;
  height: 72vh;
}

.tv[data-welcome] .welcome p {
  margin: 3vh 0 0;
  font-size: 4.5vw;
  letter-spacing: .04em;
}

.tv[data-welcome] .top,
.tv[data-welcome] .clock,
.tv[data-welcome] .bottom,
.tv[data-welcome] .track {
  display: none;
}
