/* Progress bar widget. Sizes follow the embed box (vw/vh of the frame). */
:root {
  --fill-default: #2383e2;
}
@media (prefers-color-scheme: dark) {
  :root:not(.t-light) {
    --fill-default: #529cca;
  }
}
:root.t-dark {
  --fill-default: #529cca;
}
.pg {
  --fill: var(--accent, var(--fill-default));
  --trk: var(--tile, var(--tile-default));
  display: grid;
  gap: min(3.2vh, 3vw);
  width: min(100%, 900px);
}
.pg p {
  margin: 0;
}
.head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1em;
}
.label {
  overflow: hidden;
  font-size: clamp(12px, min(5.4vw, 14vh), 40px);
  font-weight: 700;
  letter-spacing: -0.01em;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.pct {
  font-size: clamp(12px, min(5.4vw, 14vh), 40px);
  font-weight: 700;
  letter-spacing: -0.01em;
  white-space: nowrap;
}
.f-display .label,
.f-display .pct {
  font-weight: 800;
}
.f-serif .label,
.f-serif .pct {
  font-weight: 500;
}
.sub {
  font-size: clamp(11px, min(3.4vw, 8.5vh), 22px);
  font-weight: 500;
  opacity: 0.6;
}

/* Bar */
.track {
  overflow: hidden;
  height: clamp(8px, min(4.4vw, 11vh), 44px);
  border-radius: 999px;
  background: var(--trk);
}
.fill {
  height: 100%;
  min-width: 0;
  border-radius: inherit;
  background: var(--fill);
}

/* All four as bars: label, bar and percent on each row */
.s-bar .pg.all {
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: min(4.6vh, 3vw) min(3vw, 5vh);
}
.pg.all .label,
.pg.all .pct {
  font-size: clamp(11px, min(3.2vw, 8.5vh), 24px);
}
.pg.all .pct {
  min-width: 3.6em;
  text-align: right;
}
.pg.all .track {
  height: clamp(6px, min(2.4vw, 6vh), 26px);
}

/* Dots: one per day, hour or year */
.s-dots .pg {
  height: 100%;
  grid-template-rows: auto minmax(0, 1fr) auto;
}
.dots {
  position: relative;
  min-height: 0;
}
/* Out of the flow, so the dots never push the box taller: progress.js sizes them to fit. */
.grid {
  position: absolute;
  inset: 0;
  display: grid;
  align-content: center;
  justify-content: center;
  place-items: center;
}
.dot {
  width: var(--dot, 8px);
  height: var(--dot, 8px);
  border-radius: 50%;
  background: var(--trk);
}
.dot.done {
  background: var(--fill);
}
.dot.now {
  box-shadow: inset 0 0 0 max(1.5px, calc(var(--dot, 8px) * 0.18)) var(--fill);
  background: transparent;
}

/* Ring */
.ring {
  /* Stacked: room under the ring for the title and the days left line. */
  --d: min(64vh, 60vw);
  position: relative;
  display: grid;
  flex: none;
  place-items: center;
  width: var(--d);
  height: var(--d);
}
.ring svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  transform: rotate(-90deg);
}
.rt,
.ra {
  fill: none;
  stroke-width: 9;
}
.rt {
  stroke: var(--trk);
}
.ra {
  stroke: var(--fill);
  stroke-dasharray: 100 200;
  stroke-linecap: round;
}
.ring .pct {
  position: relative;
  font-size: calc(var(--d) * 0.19);
  letter-spacing: -0.03em;
}
.s-ring .pg:not(.all) {
  grid-template-columns: auto;
  justify-items: center;
  width: auto;
}
.s-ring .txt {
  display: grid;
  min-width: 0;
  max-width: 100%;
  justify-items: center;
  gap: 0.6vh;
  text-align: center;
}
@media (min-aspect-ratio: 5/4) {
  .s-ring .pg:not(.all) {
    /* A long title shortens with an ellipsis instead of running past the edge. */
    grid-template-columns: auto minmax(0, max-content);
    max-width: 100%;
    align-items: center;
    gap: min(5vw, 8vh);
  }
  .s-ring .pg:not(.all) .ring {
    --d: min(84vh, 42vw);
  }
  .s-ring .txt {
    justify-items: start;
    text-align: left;
  }
}
.s-ring .pg.all {
  grid-template-columns: repeat(4, auto);
  justify-content: center;
  gap: min(4vw, 6vh);
  width: auto;
}
.pg.all .cell {
  display: grid;
  justify-items: center;
  gap: min(2.4vh, 2vw);
}
.pg.all .ring {
  --d: min(66vh, 19vw);
}
.pg.all .ring .pct {
  font-size: calc(var(--d) * 0.19);
}
.s-ring .pg.all .label {
  font-size: clamp(10px, min(2.8vw, 8vh), 20px);
}
