/* ScanRep: black, white and greys. The heat colours only mark what has been worked. */
/* The script reads these colours for the hero's line, so they stay as six-digit hex. */
:root {
  --bg: #ffffff;
  --ink: #000000;
  --grey: #6c6c70;
  --panel: #f2f2f7;
  --idle: #d3d3d9;
  --rule: #8e8e93; /* outlines: the faintest grey that still reads on the page */
  --hair: #e5e5ea;
  --dim: #c7c7cc; /* where the wave of the icon starts */
  --lift: rgb(0 0 0 / 0.3); /* what lifts the share card off the page */
  /* The heat colours are the app's own for each mode. */
  --today: #ee2747;
  --recent: #f7a253;
  --fading: #ebcda8;

  --d-bg: #000000;
  --d-ink: #f2f2f7;
  --d-grey: #8e8e93;
  --d-panel: #1c1c1e;
  --d-idle: #3a3a3e;
  --d-rule: #5c5c62;
  --d-hair: #2a2a2d;
  --d-dim: #3a3a3d;
  --d-today: #ff3d57;
  --d-recent: #ff8f3a;
  --d-fading: #a3835e;

  --round: ui-rounded, "SF Pro Rounded", system-ui, sans-serif;
  --text: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --gutter: clamp(min(1.25rem, 6.25vw), 5vw, 4.5rem);
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: var(--d-bg);
    --ink: var(--d-ink);
    --grey: var(--d-grey);
    --panel: var(--d-panel);
    --idle: var(--d-idle);
    --rule: var(--d-rule);
    --hair: var(--d-hair);
    --dim: var(--d-dim);
    --lift: rgb(255 255 255 / 0.16);
    --today: var(--d-today);
    --recent: var(--d-recent);
    --fading: var(--d-fading);
  }
}

/* Dark in any mode, as in the app: the watch's screen and the share card. */
.watch-screen, .share {
  --bg: var(--d-bg);
  --ink: var(--d-ink);
  --grey: var(--d-grey);
  --panel: var(--d-panel);
  --hair: var(--d-hair);
  --today: var(--d-today);
  --recent: var(--d-recent);
  color: var(--ink);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--text);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  font-size: 1.0625rem;
  line-height: 1.5;
  /* A word wider than the screen breaks instead of widening the page (very large text, very narrow screens). */
  overflow-wrap: anywhere;
}

h1, h2, h3 {
  margin: 0;
  font-family: var(--round);
  font-weight: 800;
  line-height: 1.02;
  letter-spacing: -0.02em;
  text-wrap: balance;
}

/* Display type never outgrows the screen: with text at 200 % on a phone it stays as large as fits. */
h2 { font-size: min(clamp(2.1rem, 1.25rem + 3.6vw, 4rem), max(1.2rem, 10.5vw)); }
p, ul, ol, figure, fieldset { margin: 0; padding: 0; }
ul, ol { list-style: none; }
fieldset { border: 0; min-inline-size: 0; }
img, svg { display: block; max-inline-size: 100%; }
img { block-size: auto; }
a { color: inherit; text-underline-offset: 0.2em; }
.defs { position: absolute; }
.stop-dim { stop-color: var(--dim); }
.stop-ink { stop-color: var(--ink); }
.stop-recent { stop-color: var(--recent); }
.stop-today { stop-color: var(--today); }
.note { color: var(--grey); font-size: 0.95rem; }

:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 3px;
  border-radius: 4px;
}

.btn {
  min-block-size: 2.75rem;
  padding: 0.55rem min(1.1rem, 5.5vw);
  border: 1.5px solid var(--rule);
  border-radius: 999px;
  background: transparent;
  color: var(--ink);
  font: 600 0.95rem/1.2 var(--text);
  cursor: pointer;
  transition: border-color 0.15s, background-color 0.15s, color 0.15s;
}
.btn:hover { border-color: var(--ink); }
.btn-solid { border-color: var(--ink); background: var(--ink); color: var(--bg); }
.btn-solid:hover { background: transparent; color: var(--ink); }

/* ---- top ---- */

.top {
  position: absolute;
  inset: 0 0 auto;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.1rem var(--gutter);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  font: 800 min(1.2rem, 6vw)/1 var(--round);
  letter-spacing: -0.01em;
  text-decoration: none;
}
.brand svg { inline-size: min(2.6rem, 13vw); block-size: auto; }
.lang { color: var(--grey); font-size: 0.95rem; }
.lang:hover { color: var(--ink); }

/* ---- the watch, drawn in 3D: a face, fourteen slices of case behind it, a crown and two straps ---- */

.watch {
  --ww: 12rem;
  --d: calc(var(--ww) * 0.2);
  inline-size: var(--ww);
  aspect-ratio: 0.82;
  perspective: calc(var(--ww) * 5);
}

.watch-3d {
  position: relative;
  block-size: 100%;
  transform-style: preserve-3d;
  transform: rotateX(var(--rx, 6deg)) rotateY(var(--ry, -24deg));
}

.watch-face, .watch-depth i { position: absolute; inset: 0; border-radius: 27% / 22%; }
.watch-depth, .watch-crown { position: absolute; transform-style: preserve-3d; }
.watch-depth { inset: 0; }

.watch-depth i {
  background: linear-gradient(165deg, #5b5b60, #2a2a2d 30%, #121213 75%, #1c1c1e);
  transform: translateZ(calc(var(--i) * var(--d) / -14));
}
.watch-depth i:nth-child(1) { --i: 1; } .watch-depth i:nth-child(2) { --i: 2; }
.watch-depth i:nth-child(3) { --i: 3; } .watch-depth i:nth-child(4) { --i: 4; }
.watch-depth i:nth-child(5) { --i: 5; } .watch-depth i:nth-child(6) { --i: 6; }
.watch-depth i:nth-child(7) { --i: 7; } .watch-depth i:nth-child(8) { --i: 8; }
.watch-depth i:nth-child(9) { --i: 9; } .watch-depth i:nth-child(10) { --i: 10; }
.watch-depth i:nth-child(11) { --i: 11; } .watch-depth i:nth-child(12) { --i: 12; }
.watch-depth i:nth-child(13) { --i: 13; } .watch-depth i:nth-child(14) { --i: 14; }

.watch-face {
  background: linear-gradient(140deg, #77777d 0%, #323236 16%, #141415 58%, #232326 100%);
  box-shadow: inset 0 0 0 1px rgb(255 255 255 / 0.16);
}

.watch-crown { inset: 22% -5.5% auto auto; inline-size: 6.5%; block-size: 17%; }
.watch-crown i {
  position: absolute;
  inset: 0;
  border-radius: 35% / 14%;
  background: linear-gradient(180deg, #8a8a90, #3a3a3e 45%, #1c1c1e);
  transform: translateZ(calc(var(--d) * (-0.2 - 0.14 * var(--i))));
}
.watch-crown i:nth-child(1) { --i: 1; } .watch-crown i:nth-child(2) { --i: 2; } .watch-crown i:nth-child(3) { --i: 3; }

.watch-band {
  position: absolute;
  inset-inline: 13%;
  block-size: 70%;
  border-radius: 9% / 5%;
}
.watch-band-a {
  inset-block-end: 95%;
  background: linear-gradient(to top, #2c2c2f, #1a1a1c 45%, transparent);
  transform-origin: 50% 100%;
  transform: translateZ(calc(var(--d) * -0.6)) rotateX(40deg);
}
.watch-band-b {
  inset-block-start: 95%;
  background: linear-gradient(to bottom, #2c2c2f, #1a1a1c 45%, transparent);
  transform-origin: 50% 0;
  transform: translateZ(calc(var(--d) * -0.6)) rotateX(-40deg);
}

.watch-screen {
  position: absolute;
  inset: 5.5% 6%;
  overflow: hidden;
  border-radius: 23% / 19%;
  background: var(--bg);
}
/* The light on the glass. */
.watch-screen::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(118deg, rgb(255 255 255 / 0.11), transparent 30%);
  pointer-events: none;
}

/* Watch type scales with the watch, not with the reader's text size: it is a drawing of a screen. */
.ws-count { display: grid; align-content: space-between; padding: 13% 12% 12%; block-size: 100%; }
.ws-top, .ws-unit { color: var(--grey); font-size: calc(var(--ww) * 0.068); line-height: 1.2; }
.ws-number { font: 800 calc(var(--ww) * 0.43) / 0.86 var(--round); letter-spacing: -0.03em; transform-origin: 0 100%; }
.ws-unit { margin-block-start: calc(var(--ww) * -0.05); }
.ws-foot { font: 700 calc(var(--ww) * 0.075) / 1.2 var(--round); }

/* ---- the stage ---- */

.stage {
  --sw: min(clamp(8.25rem, 15vw, 14.5rem), 41.25vw); /* the watch's width */
  --watch-end: min(2rem, 10vw); /* and how far it sits from the bottom of the first screen */
  position: relative;
  container: stage / inline-size;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  padding-block: 4rem 2rem;
  overflow: hidden;
}

/* On a phone the first screen is the headline and the demo: figure, line, watch and buttons.
   The words that explain it come right under, so the watch is never below the fold. */
.stage-copy { display: contents; }
.stage h1, .lead, .status, .hint, .stage-status { margin-inline: var(--gutter); }

.stage h1 {
  grid-row: 1;
  margin-block-start: clamp(1rem, 3svh, 3.5rem);
  font-size: min(clamp(2.75rem, 1.3rem + 5.2vw, 5.5rem), max(1.5rem, 13.75vw));
  line-height: 0.98;
}

.lead {
  grid-row: 4;
  max-inline-size: 30rem;
  margin-block-start: 1.25rem;
  font-size: 1.125rem;
  text-wrap: pretty;
}

.status { grid-row: 5; margin-block-start: 0.6rem; color: var(--grey); }

/* The figure fills the room above the watch; the line is written under it. */
.stage-view {
  position: relative;
  grid-area: 3 / 1;
  display: grid;
  grid-template-rows: minmax(0, 1fr);
  justify-items: center;
  /* What a phone's first screen has left under the headline, with a line or two of the words showing. */
  block-size: clamp(15rem, 100svh - 15.5rem - var(--said, 0rem), 44rem);
  /* The figure stops a little into the watch, never behind its face. */
  padding-block-end: calc(var(--watch-end) + var(--sw) * 1.22 - 3rem);
  contain: size;
}

.stage canvas {
  position: absolute;
  inset: 0;
  display: block;
  inline-size: 100%;
  block-size: 100%;
}

/* The figure lifts; the line is written along the bottom of the screen, into the watch. */
.stage-figure {
  align-self: center;
  inline-size: auto;
  block-size: 100%;
  max-block-size: 100vw;
  aspect-ratio: 1;
}
.stage.is-live .stage-figure { visibility: hidden; } /* the canvas draws it from here on */

.stage-watch {
  --ww: var(--sw);
  position: absolute;
  inset-inline-end: 0.75rem;
  inset-block-end: var(--watch-end);
  z-index: 1;
}
.stage-watch .watch-band-a { block-size: 50%; } /* a shorter strap: it must not reach the words */

.stage-poster { display: none; }

/* The buttons lie over the bottom of the demo, beside the watch. */
.stage-foot {
  position: relative;
  z-index: 2;
  grid-area: 3 / 1; /* the same cell as the demo, or the grid would open a second column for it */
  align-self: end;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  /* The watch stands in the corner, so the buttons stop short of it. */
  padding: 0.5rem calc(var(--sw) + 1.5rem) 1.5rem var(--gutter);
}
/* Narrower than elsewhere, so both fit on one row beside the watch on a 360 px phone. */
.stage-foot .btn { padding-inline: min(0.85rem, 5.5vw); }
/* The line may pass behind a button, never through its words. */
.stage-foot .btn:not(.btn-solid) { background: var(--bg); }

.hint, .stage-status { grid-row: 6; max-inline-size: 30rem; margin-block-start: 0.6rem; color: var(--grey); font-size: 0.95rem; }
/* What «Hazlo tú» answers goes right under the headline: below the demo it would be out of sight. */
.stage-status { grid-row: 2; }
/* The demo gives the message its room, so the watch and the buttons stay in the first screen. */
.stage:has(.stage-status:not(:empty)) { --said: 3.5rem; }
/* Empty, it takes no room but stays in the page, so a screen reader hears the message when it comes. */
.stage-status:empty { margin-block: 0; }

@media (hover: none) { .hint { display: none; } }

/* Very large text: the buttons no longer fit beside the watch, so they go under the words. */
@container stage (inline-size < 18rem) {
  .stage-foot { grid-row: 7; padding: 1rem var(--gutter) 0; }
}

/* What needs the script stays out of sight until it has run: a blocked or broken script leaves no dead button. */
:root:not(.js) .needs-js { visibility: hidden; }

@media (scripting: none) {
  .needs-js { display: none; }
  .stage canvas { display: none; }
  /* The still wave ends at the watch, level with the middle of its screen. */
  .stage-poster {
    position: absolute;
    inset-inline-end: calc(var(--sw) + 2rem);
    inset-block-end: calc(var(--watch-end) + var(--sw) * 0.61 - 2.5rem);
    display: block;
    /* As wide as the room before the watch; the drawing keeps to the watch's end of it. */
    inline-size: calc(100% - var(--gutter) - var(--sw) - 2rem);
    block-size: 5rem;
  }
}

@media (min-width: 60rem) and (min-aspect-ratio: 5/4) {
  /* One scene across the whole first screen: the words, the figure beside them and the line below. */
  .stage {
    --watch-end: 7svh;
    /* The middle row keeps the room the line needs, so on a short window it never runs through the words. */
    grid-template-rows: auto minmax(calc(var(--sw) * 0.75 + var(--watch-end)), 1fr) auto;
    min-block-size: max(100svh, 36rem);
    padding-block-end: 0;
  }
  .stage-copy {
    position: relative;
    z-index: 2;
    display: block;
    max-inline-size: 60%;
    padding: clamp(1.25rem, 4svh, 3.5rem) var(--gutter) 0;
  }
  .stage h1, .lead, .status, .hint, .stage-status { margin-inline: 0; }
  .stage h1 { margin-block-start: 0; }
  .stage-view { position: static; grid-row: 2; justify-items: end; block-size: auto; padding-block-end: 4.5rem; }
  .stage-figure {
    position: absolute;
    inset-block-start: 13svh;
    inset-inline-end: calc(var(--gutter) / 2);
    /* The watch never stands on the lifter's feet: the figure ends above it (first term)
       or begins to its right (second), whichever leaves it larger. The drawing fills
       its square from 12 % across to 95 % down. */
    block-size: min(70svh, 44vw, max(84svh - var(--sw) * 1.3, (100vw - var(--gutter) / 2 - max(41vw, 36rem) - var(--sw) * 1.08) / 0.88));
  }
  /* Never under the paragraph, however narrow the window. */
  .stage-watch { inset-inline: max(41%, 36rem) auto; }
  .stage-poster { inset-inline-end: calc(100% - max(41%, 36rem) + 1rem); inline-size: calc(max(41%, 36rem) - 1rem - var(--gutter)); }
  .stage-foot { grid-row: 3; justify-content: end; padding-inline-end: var(--gutter); }
}

/* ---- the watch in three steps: it stays, the words go by ---- */

.flow {
  position: relative;
  display: grid;
  max-inline-size: 86rem;
  margin-inline: auto;
  padding-inline: var(--gutter);
  overflow-x: clip; /* a turned strap must not widen the page; clip keeps the pin sticky */
}

.flow-pin {
  position: sticky;
  inset-block-start: 0;
  z-index: 1;
  display: grid;
  place-items: center;
  block-size: 52svh;
  /* Opaque, so the words scroll away under the watch instead of through it. */
  background: linear-gradient(var(--bg) 82%, transparent);
}

.flow-watch { --ww: min(clamp(9rem, 26svh, 13rem), 60vw); --ry: -30deg; --rx: 8deg; }
.flow-watch .watch-3d { transition: transform 0.9s cubic-bezier(0.2, 0.7, 0.2, 1); }
.flow[data-beat="2"] .flow-watch { --ry: -6deg; --rx: 5deg; }
.flow[data-beat="3"] .flow-watch { --ry: 24deg; --rx: 4deg; }

.beat {
  display: grid;
  align-content: center;
  gap: 1rem;
  min-block-size: 62svh;
  padding-block: 3rem;
}
.beat p { max-inline-size: 30rem; font-size: 1.125rem; text-wrap: pretty; }

.ws { position: absolute; inset: 0; opacity: 0; transition: opacity 0.35s; }
.ws-1, .flow[data-beat="2"] .ws-2, .flow[data-beat="3"] .ws-3 { opacity: 1; }
.flow[data-beat="2"] .ws-1, .flow[data-beat="3"] .ws-1 { opacity: 0; }

.ws-entry { display: grid; align-content: space-between; padding: 11% 10% 9%; }
.ws-pick { display: flex; align-items: center; gap: 6%; font: 700 calc(var(--ww) * 0.068) / 1.15 var(--round); }
.ws-pick img { inline-size: 30%; }
.ws-weight { font: 800 calc(var(--ww) * 0.3) / 0.9 var(--round); letter-spacing: -0.03em; }
.ws-weight small { margin-inline-start: 0.2em; color: var(--grey); font-size: 0.36em; letter-spacing: 0; }
.ws-keys { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4%; }
.ws-keys span {
  padding-block: 7%;
  border-radius: 999px;
  background: var(--panel);
  font: 700 calc(var(--ww) * 0.06) / 1 var(--round);
  text-align: center;
}

.ws-done { display: grid; align-content: center; justify-items: start; gap: 4%; padding: 12%; }
.ws-done svg { inline-size: 34%; fill: none; stroke: var(--ink); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.ws-saved { font: 800 calc(var(--ww) * 0.085) / 1.1 var(--round); }
.ws-sum { color: var(--grey); font-size: calc(var(--ww) * 0.07); line-height: 1.2; }
.ws-sum b { color: var(--ink); font-family: var(--round); }

@media (min-width: 62rem) {
  .flow { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); column-gap: 4rem; }
  .flow-pin { grid-column: 2; grid-row: 1; align-self: start; block-size: 100svh; background: none; }
  .flow-beats { grid-column: 1; grid-row: 1; }
  .flow-watch { --ww: clamp(13rem, 36svh, 21rem); }
  .beat { min-block-size: 100svh; }
}

@media (prefers-reduced-motion: reduce) {
  .flow-watch .watch-3d { transition: none; }
}

/* Where the browser can tie an animation to scrolling, the watch turns with the page instead of in three jumps. */
@media (prefers-reduced-motion: no-preference) {
  @supports ((animation-timeline: view()) and (animation-range: entry)) {
    @keyframes watch-turn {
      from { transform: rotateX(9deg) rotateY(-36deg); }
      to { transform: rotateX(4deg) rotateY(28deg); }
    }
    .flow { view-timeline: --flow block; }
    .flow-watch .watch-3d {
      animation: watch-turn linear both;
      animation-timeline: --flow;
      animation-range: contain 0% contain 100%;
      transition: none;
    }
  }
}

/* ---- the sections after it: words on one side, the piece on the other ---- */

.band {
  display: grid;
  gap: 2.5rem;
  max-inline-size: 86rem;
  margin-inline: auto;
  padding: clamp(4rem, 10svh, 7rem) var(--gutter);
  container: band / inline-size;
}

.band-copy { display: grid; align-content: start; gap: 1.25rem; }
.band-copy > p:not(.note) { max-inline-size: 31rem; font-size: 1.125rem; text-wrap: pretty; }

@media (min-width: 62rem) {
  .band { grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); align-items: center; column-gap: 5rem; }
  .band-flip { grid-template-columns: minmax(0, 6fr) minmax(0, 5fr); }
  .band-flip > .band-copy { order: 2; }
  .band-wide { grid-template-columns: 1fr; }
}

/* ---- heat ---- */

/* On a phone the figure sits between the words and the controls, so it is in sight while you change it. */
.heat-controls { display: grid; gap: 1.25rem; }
.controls { display: grid; gap: 1.1rem; }

@media (min-width: 62rem) {
  .heat { grid-template-areas: "copy figure" "controls figure"; row-gap: 1.75rem; }
  .heat > .band-copy { grid-area: copy; align-self: end; }
  .heat-figure { grid-area: figure; }
  .heat-controls { grid-area: controls; align-self: start; }
}
.seg { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.seg legend, .days label { margin-block-end: 0.5rem; color: var(--grey); font-size: 0.9rem; }

.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span {
  display: block;
  padding: 0.5rem 0.95rem;
  border: 1.5px solid var(--rule);
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  transition: border-color 0.15s, background-color 0.15s, color 0.15s;
}
.seg span:hover { border-color: var(--ink); }
.seg input:checked + span { border-color: var(--ink); background: var(--ink); color: var(--bg); }
.seg input:focus-visible + span { outline: 2px solid var(--ink); outline-offset: 3px; }

.days { display: grid; max-inline-size: 22rem; }
.days output { font: 700 1.05rem/1.3 var(--round); }

.days input {
  --track: 0.375rem;
  --thumb: 1.5rem;
  appearance: none;
  inline-size: 100%;
  block-size: 2.75rem;
  margin: 0;
  background: transparent;
  cursor: pointer;
}
.days input::-webkit-slider-runnable-track { block-size: var(--track); border-radius: 999px; background: var(--rule); }
.days input::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  inline-size: var(--thumb);
  block-size: var(--thumb);
  margin-block-start: calc((var(--track) - var(--thumb)) / 2);
  border: 0;
  border-radius: 50%;
  background: var(--ink);
}
.days input::-moz-range-track { block-size: var(--track); border-radius: 999px; background: var(--rule); }
.days input::-moz-range-thumb { inline-size: var(--thumb); block-size: var(--thumb); border: 0; border-radius: 50%; background: var(--ink); }
.days input:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

.heat-figure { justify-self: center; inline-size: min(100%, 30rem); }
.heat-figure img {
  inline-size: 100%;
  /* The figure is grey and the worked muscle is the only colour in it, so cooling it is a filter. */
  filter: hue-rotate(0deg) saturate(1);
  transition: filter 0.5s, opacity 0.2s;
}
.heat-figure[data-level="1"] img { filter: hue-rotate(16deg) saturate(0.9); }
.heat-figure[data-level="2"] img { filter: hue-rotate(24deg) saturate(0.38); }
.heat-figure[data-level="3"] img { filter: hue-rotate(0deg) saturate(0); }
.heat-figure.is-loading img { opacity: 0; }

/* ---- progress: the three blocks of the app's tab ---- */

.panels { display: grid; gap: 0.9rem; }
.panel { display: grid; align-content: start; gap: 1rem; padding: min(1.25rem, 6.25vw); border-radius: 1.25rem; background: var(--panel); }
.panel h3 { font-size: 1.25rem; letter-spacing: -0.01em; }

.bars { display: grid; gap: 0.6rem; }
.bar { display: grid; grid-template-columns: 5rem 1fr 1.75rem; align-items: center; gap: 0.6rem; font-size: 0.95rem; }
.bar-track {
  block-size: 0.875rem;
  overflow: hidden;
  border-radius: 999px;
  /* The right half is the 10 to 20 band. */
  background: linear-gradient(to right, var(--hair) 50%, var(--idle) 50%);
}
.bar-fill { display: block; inline-size: calc(var(--v) / 20 * 100%); block-size: 100%; border-radius: 999px; background: var(--heat); transform-origin: 0 50%; }
.bar-n { font: 700 1rem/1 var(--round); text-align: end; }
.v6 { --v: 6; } .v8 { --v: 8; } .v9 { --v: 9; } .v11 { --v: 11; } .v12 { --v: 12; } .v14 { --v: 14; }
.h0 { --heat: var(--today); } .h1 { --heat: var(--recent); } .h2 { --heat: var(--fading); }

.lifts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.75rem; }
.lifts li { display: grid; gap: 0.35rem; padding: 0.9rem; border-radius: 0.9rem; background: var(--bg); }
.lift-name { color: var(--grey); font-size: 0.9rem; }
.lift-kg { font: 800 1.9rem/1 var(--round); letter-spacing: -0.02em; }
.lift-kg small { margin-inline-start: 0.2em; color: var(--grey); font-size: 0.5em; letter-spacing: 0; }
.spark { inline-size: 100%; margin-block-start: 0.25rem; overflow: visible; }
.spark polyline { fill: none; stroke: var(--grey); stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.spark circle { fill: var(--today); }

.weeks { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 0.4rem; }
.weeks li {
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--idle);
  font: 700 0.95rem/1 var(--round);
}
/* Black on the heat colours: white does not reach the contrast a small number needs. */
.weeks .full { background: var(--today); color: #000; box-shadow: 0 0 14px rgb(255 61 87 / 0.45); }
.weeks .one { background: var(--fading); color: #000; }
/* A week with no workout keeps the page's ink: grey on the grey disc was too faint to read. */

/* Very large text: one thing per row, so a number is never squeezed out of its place. */
@container band (inline-size < 18rem) {
  .bar { grid-template-columns: minmax(0, 1fr) auto; }
  .bar-track { grid-column: 1 / -1; grid-row: 2; }
  .lifts { grid-template-columns: minmax(0, 1fr); }
  .weeks { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

@media (min-width: 40rem) {
  .panels { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .panel-week { grid-row: span 2; }
}

/* ---- medals ---- */

.medal-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1.75rem 0.75rem; }
.medal { display: grid; justify-items: center; align-content: start; gap: 0.3rem; color: var(--grey); text-align: center; font-size: 0.85rem; line-height: 1.25; }
.medal svg { inline-size: min(100%, 7.5rem); margin-block-end: 0.35rem; overflow: visible; }
.medal b { color: var(--ink); font: 700 0.95rem/1.2 var(--round); text-wrap: balance; }
.medal .plate { fill: none; stroke: var(--rule); stroke-width: 2; stroke-dasharray: 5 5; }
/* In the drawing's own units: the number belongs to the medal and scales with it, not with the text size. */
.medal text { fill: currentColor; font: 800 20px var(--round); text-anchor: middle; }
.medal .month { font-size: 38px; }
.medal.is-earned svg { color: #fff; filter: drop-shadow(0 0 12px rgb(255 61 87 / 0.5)); }
.medal.is-earned .plate { fill: url(#medal-heat); stroke: none; }
.medal .rim { fill: none; stroke: rgb(255 255 255 / 0.35); stroke-width: 1.6; }

/* Very large text: a list, the medal beside its name, so no name is broken to fit a third of the screen. */
@container band (inline-size < 18rem) {
  .medal-grid { grid-template-columns: minmax(0, 1fr); gap: 1.25rem; }
  .medal { grid-template-columns: 22cqi minmax(0, 1fr); justify-items: start; column-gap: 0.75rem; text-align: start; }
  .medal svg { grid-row: span 2; align-self: center; margin-block-end: 0; }
}

@media (min-width: 62rem) {
  .medal-grid { grid-template-columns: repeat(9, minmax(0, 1fr)); }
}

@media (prefers-reduced-motion: no-preference) {
  @supports ((animation-timeline: view()) and (animation-range: entry)) {
    /* The earned ones light up as the row comes into view. */
    @keyframes medal-light { from { opacity: 0.25; filter: grayscale(1); scale: 0.92; } }
    .medal.is-earned svg {
      animation: medal-light linear both;
      animation-timeline: view();
      animation-range: entry 40% cover 32%;
    }
    @keyframes bar-grow { from { transform: scaleX(0); } }
    .bar-fill {
      animation: bar-grow linear both;
      animation-timeline: view();
      animation-range: entry 60% cover 30%;
    }
  }
}

/* ---- the share card ---- */

.card-scene { display: grid; place-items: center; perspective: 70rem; container-type: inline-size; }

.share {
  /* The card is a picture of the app's card: its type follows the card's width, like the watch's. */
  --u: min(1rem, 5.7cqi);
  display: grid;
  grid-template-rows: auto auto auto auto 1fr;
  gap: calc(var(--u) * 0.6);
  inline-size: min(100%, 21rem);
  aspect-ratio: 9 / 16;
  padding: calc(var(--u) * 1.25) calc(var(--u) * 1.1);
  overflow: clip; /* not hidden: on a narrow phone the card grows a little rather than lose its last row */
  border-radius: calc(var(--u) * 1.75);
  background: var(--bg);
  box-shadow: 0 0 0 1px var(--hair), 0 3rem 6rem -2.5rem var(--lift);
  transform: rotateX(var(--tilt-x, 0deg)) rotateY(var(--tilt-y, 0deg));
  transition: transform 0.25s ease-out;
}

.share-top { display: flex; align-items: center; gap: calc(var(--u) * 0.5); font-size: calc(var(--u) * 0.85); }
.share-top b { font: 700 calc(var(--u) * 0.9)/1 var(--round); }
.share-top span { margin-inline-start: auto; color: var(--grey); }

.share-star {
  /* The glow behind the day's best exercise. */
  background: radial-gradient(closest-side, rgb(255 61 87 / 0.3), rgb(255 143 58 / 0.08) 62%, transparent);
}
.share-star img { inline-size: 78%; margin-inline: auto; }
.share h3 { font-size: calc(var(--u) * 1.45); }
.share-stats { display: flex; flex-wrap: wrap; gap: calc(var(--u) * 0.2) calc(var(--u) * 0.9); color: var(--grey); font-size: calc(var(--u) * 0.85); }
.share-stats b { color: var(--ink); font: 700 calc(var(--u) * 0.95)/1 var(--round); }

.share-lines { display: grid; align-content: start; gap: calc(var(--u) * 0.3); font-size: calc(var(--u) * 0.8); }
.share-lines li { display: grid; grid-template-columns: calc(var(--u) * 2) 1fr auto; align-items: center; gap: calc(var(--u) * 0.5); }
.share-lines img { inline-size: calc(var(--u) * 2); }
.share-lines b { font: 700 calc(var(--u) * 0.85)/1 var(--round); white-space: nowrap; }
.share-lines .is-star b {
  background: linear-gradient(90deg, var(--recent), var(--today));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

@media (prefers-reduced-motion: no-preference) {
  @supports ((animation-timeline: view()) and (animation-range: entry)) {
    @keyframes card-settle { from { rotate: y -22deg; translate: 0 2rem; } }
    .card-scene {
      animation: card-settle linear both;
      animation-timeline: view();
      animation-range: entry 10% cover 38%;
    }
  }
}

/* ---- the end ---- */

/* The one centred piece of the page: it is the closing line, not a section to read across. */
.soon {
  display: grid;
  grid-template-columns: minmax(0, 1fr); /* a long word must not widen the page */
  justify-items: center;
  gap: 1.25rem;
  padding: clamp(5rem, 14svh, 10rem) var(--gutter) clamp(4rem, 10svh, 7rem);
  text-align: center;
}
.soon-wave { inline-size: min(100%, 30rem); block-size: auto; margin-block-end: 1.5rem; }
.soon h2 { font-size: min(clamp(2.2rem, 0.6rem + 8vw, 5.5rem), max(1.1rem, 11vw)); }
.soon p { max-inline-size: 31rem; font-size: 1.125rem; text-wrap: pretty; }

.foot {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem 2rem;
  padding: 1.5rem var(--gutter) 2.5rem;
  border-block-start: 1px solid var(--hair);
  color: var(--grey);
  font-size: 0.85rem;
}
.foot { text-align: center; }
