/* Pomodoro widget: ring, bar or digits, session dots, controls. Tokens from _shared/embed.css. */

.pm {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5em;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  font-size: clamp(9px, min(4.4vw, 5.4vh), 20px);
}

/* Tall or square embeds: title, dial, dots, buttons in one column. */
.pm-side {
  display: contents;
}

.pm-head {
  order: -1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.1em;
  max-width: 100%;
  min-width: 0;
}

.pm-title {
  max-width: 100%;
  overflow: hidden;
  font-size: 0.95em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pm-phase {
  color: var(--accent);
  font-size: 0.85em;
  font-weight: 650;
  white-space: nowrap;
}

.pm[data-phase="short"] .pm-phase,
.pm[data-phase="long"] .pm-phase {
  color: var(--muted);
}

/* The dial is a size container, so the digits scale with it. */
.pm-dial {
  position: relative;
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 0;
  container-type: size;
}

.pm-time {
  font-size: 3em;
  line-height: 1;
  white-space: nowrap;
}

.pm--ring .pm-ring {
  width: 100cqmin;
  height: 100cqmin;
  overflow: visible;
}

.pm--ring .pm-time {
  position: absolute;
  font-size: 9vmin;
  font-size: 21cqmin;
}

.pm--digits .pm-time {
  font-size: 14vmin;
  font-size: min(62cqh, 21cqw);
}

.pm--bar .pm-time {
  font-size: 10vmin;
  font-size: min(48cqh, 17cqw);
}

.pm-ring-track,
.pm-ring-fill {
  fill: none;
  stroke-width: 7;
}

.pm-ring-track {
  stroke: var(--track);
}

.pm-ring-fill {
  stroke: var(--fill);
  stroke-linecap: round;
  transition: stroke-dashoffset 0.3s linear;
}

.pm[data-phase="short"] .pm-ring-fill,
.pm[data-phase="long"] .pm-ring-fill,
.pm[data-phase="short"] .pm-fill,
.pm[data-phase="long"] .pm-fill {
  stroke: color-mix(in srgb, var(--accent) 55%, var(--muted));
  background: color-mix(in srgb, var(--accent) 55%, var(--muted));
}

:root[data-style="neon"] .pm-ring-fill {
  filter: drop-shadow(0 0 2px var(--accent));
}

.pm-track {
  width: min(100%, 24em);
  height: 0.5em;
  margin-top: 0.45em;
  overflow: hidden;
  border-radius: 999px;
  background: var(--track);
}

.pm-fill {
  width: calc(var(--p, 1) * 100%);
  height: 100%;
  border-radius: inherit;
  background: var(--fill);
  transition: width 0.3s linear;
}

.pm-dots {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.35em;
}

.pm-dot {
  width: 0.55em;
  height: 0.55em;
  border-radius: 50%;
  background: var(--track);
}

.pm-dot.on {
  background: var(--accent);
}

.pm-dot.now {
  background: color-mix(in srgb, var(--accent) 45%, transparent);
  box-shadow: 0 0 0 0.12em var(--accent-soft);
}

.pm[data-running="1"] .pm-dot.now {
  animation: pm-pulse 1.6s ease-in-out infinite;
}

@keyframes pm-pulse {
  50% {
    opacity: 0.45;
  }
}

.pm-controls {
  display: flex;
  gap: 0.4em;
}

.pm-controls .px-btn {
  font-size: 0.85em;
}

.pm-start {
  min-width: 5.6em;
}

/* Wide, short embeds: the dial on the left, everything else beside it. */
@media (min-aspect-ratio: 9/5) {
  .pm {
    flex-direction: row;
    gap: 1.1em;
    padding: 0 3%;
    font-size: clamp(9px, min(3vw, 9.5vh), 20px);
  }

  .pm-dial {
    height: 100%;
  }

  .pm--ring .pm-dial {
    flex: 0 0 auto;
    width: auto;
    aspect-ratio: 1;
  }

  .pm--bar .pm-dial,
  .pm--digits .pm-dial {
    flex: 1 1 0;
    min-width: 0;
  }

  .pm-side {
    display: flex;
    flex: none;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    gap: 0.55em;
    min-width: 0;
  }

  .pm-head {
    order: 0;
    align-items: flex-start;
  }

  .pm-dots {
    justify-content: flex-start;
  }
}

@media (max-height: 120px) {
  .pm-dots {
    display: none;
  }
}

@media (max-height: 90px), (max-width: 200px) {
  .pm-reset,
  .pm-skip {
    display: none;
  }
}
