/* Interval timer. Visual language stays with the guide pages; this file only covers the tool. */

.timer-tool {
  padding: 20px 16px 16px;
  margin: 0 0 20px;
}

.timer-tool p {
  margin: 0;
  font-size: 15px;
  line-height: 1.45;
}

.timer-tool .timer-noscript {
  margin-bottom: 12px;
  font-weight: 700;
}

.timer-presets {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  border: 0;
  margin: 0 0 12px;
  padding: 0;
  min-inline-size: 0;
}

.timer-presets legend {
  grid-column: 1 / -1;
  padding: 0;
  margin: 0 0 4px;
  font-size: 14px;
  font-weight: 700;
}

.timer-preset {
  position: relative;
  min-width: 0;
}

.timer-preset input {
  position: absolute;
  inset: 0;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.timer-preset span {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 8px 10px;
  border-radius: 999px;
  border: 1px solid rgba(22, 33, 27, 0.18);
  background: rgba(255, 255, 255, 0.72);
  font-size: 14px;
  font-weight: 700;
  line-height: 1.25;
  text-align: center;
}

.timer-preset input:checked + span {
  background: var(--ink);
  color: #fff;
  border-color: var(--ink);
}

.timer-preset input:focus-visible + span,
.timer-btn:focus-visible,
.timer-options input:focus-visible,
.timer-custom input:focus-visible {
  outline: 3px solid var(--accent-deepest);
  outline-offset: 3px;
}

.timer-custom {
  display: grid;
  gap: 10px;
  margin: 0 0 12px;
}

.timer-custom[hidden],
.timer-exercises[hidden],
.timer-figure[hidden],
.timer-tool .timer-next[hidden],
.timer-tool .timer-wake-hint[hidden] {
  display: none !important;
}

.timer-custom-fields {
  display: grid;
  gap: 10px;
}

.timer-custom label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 14px;
  font-weight: 700;
}

.timer-custom input {
  width: 100%;
  min-height: 48px;
  padding: 8px 12px;
  border-radius: 12px;
  border: 1px solid rgba(22, 33, 27, 0.22);
  background: #fff;
  color: var(--ink);
  font: 700 18px/1 var(--font-rounded);
}

.timer-custom input[aria-invalid="true"] {
  border-color: #7a1f1a;
  box-shadow: inset 0 0 0 1px #7a1f1a;
}

.timer-tool .timer-range {
  color: var(--ink-secondary);
  font-size: 14px;
}

.timer-tool .timer-error {
  color: #7a1f1a;
  font-weight: 700;
  min-height: 0;
}

.timer-tool .timer-error:empty {
  display: none;
}

.timer-options {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 18px;
  margin: 0 0 14px;
}

.timer-options label {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  font-size: 15px;
  font-weight: 700;
}

.timer-options input {
  width: 22px;
  height: 22px;
  margin: 0;
  accent-color: var(--accent-deepest);
}

.timer-stage {
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
  margin-bottom: 14px;
}

.timer-readout {
  width: 100%;
  text-align: center;
}

.timer-tool .timer-phase {
  font-family: var(--font-rounded);
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent-deepest);
}

.timer-tool[data-phase="rest"] .timer-phase { color: var(--rest-accent-deep); }
.timer-tool[data-phase="done"] .timer-phase { color: var(--ink); }

.timer-tool .timer-clock {
  margin: 2px 0 6px;
  font-family: var(--font-rounded);
  font-weight: 800;
  font-size: clamp(56px, 18vw, 96px);
  line-height: 0.95;
  letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
}

.timer-meta {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 6px 18px;
  margin-bottom: 10px;
  color: var(--ink-secondary);
  font-weight: 700;
}

.timer-meta strong {
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.timer-bar {
  height: 12px;
  border-radius: 999px;
  background: rgba(22, 33, 27, 0.08);
  border: 1px solid rgba(22, 33, 27, 0.16);
  overflow: hidden;
}

.timer-bar-fill {
  display: block;
  height: 100%;
  width: 0;
  background: var(--accent-deep);
}

.timer-tool[data-phase="rest"] .timer-bar-fill { background: var(--rest-accent); }
.timer-tool[data-phase="done"] .timer-bar-fill { background: var(--accent-deepest); }
.timer-tool[data-phase="idle"] .timer-bar-fill { width: 0; }

.timer-exercises {
  width: min(100%, 280px);
}

.timer-figure {
  margin: 0;
}

.timer-figure img {
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 200px;
  margin: 0 auto;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.55);
}

.timer-tool .timer-now {
  margin-top: 8px;
  font-family: var(--font-rounded);
  font-size: 22px;
  font-weight: 800;
  line-height: 1.25;
  text-align: center;
}

.timer-tool .timer-next {
  margin-top: 2px;
  text-align: center;
  color: var(--ink-secondary);
  font-weight: 700;
}

.timer-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.timer-btn {
  min-height: 48px;
  padding: 12px 16px;
  border-radius: 14px;
  border: 1px solid rgba(22, 33, 27, 0.18);
  background: #fff;
  color: var(--ink);
  font-family: var(--font-rounded);
  font-size: 17px;
  font-weight: 800;
  cursor: pointer;
  touch-action: manipulation;
}

.timer-btn-primary {
  border-color: transparent;
  background: var(--accent-deepest);
  color: #fff;
}

.timer-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.timer-tool .timer-keys,
.timer-tool .timer-wake-hint {
  margin-top: 10px;
  color: var(--ink-secondary);
  font-size: 13px;
}

.timer-tool .timer-keys kbd {
  font-family: var(--font-text);
  font-weight: 700;
  border: 1px solid rgba(22, 33, 27, 0.2);
  border-radius: 6px;
  padding: 1px 6px;
  background: rgba(255, 255, 255, 0.7);
}

.timer-tool .timer-live {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.timer-tool { position: relative; }

@media (min-width: 520px) {
  .timer-presets { grid-template-columns: repeat(3, 1fr); }
  .timer-custom-fields { grid-template-columns: repeat(3, 1fr); }
}

@media (min-width: 640px) {
  .timer-tool { padding: 24px 24px 20px; }
  .timer-actions { grid-template-columns: 1.3fr 1fr 1fr; }
}

@media (min-width: 760px) {
  .timer-presets { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .timer-stage {
    flex-direction: row;
    align-items: center;
    justify-content: center;
  }
  .timer-readout { flex: 1; }
  .timer-exercises { flex: 0 0 220px; }
}

@media (max-width: 400px) {
  .timer-figure img { max-height: 150px; }
  .timer-tool .timer-now { font-size: 20px; }
}

@media (prefers-reduced-motion: reduce) {
  .timer-bar-fill,
  .timer-btn { transition: none; }
}

@media (prefers-contrast: more) {
  .timer-tool {
    background: #fff;
    border: 2px solid var(--ink);
  }
  .timer-preset span,
  .timer-btn,
  .timer-custom input,
  .timer-bar {
    border: 2px solid var(--ink);
  }
  .timer-tool .timer-phase,
  .timer-tool .timer-next,
  .timer-tool .timer-keys,
  .timer-tool .timer-wake-hint,
  .timer-meta { color: var(--ink); }
}

@media (forced-colors: active) {
  .timer-preset input:checked + span {
    background: Highlight;
    color: HighlightText;
    forced-color-adjust: none;
  }
  .timer-btn-primary {
    background: ButtonFace;
    color: ButtonText;
    border: 2px solid ButtonText;
  }
  .timer-bar-fill { background: Highlight; }
  .timer-btn:focus-visible,
  .timer-preset input:focus-visible + span { outline-color: Highlight; }
}
